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 "*Remove matches for this regexp 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 (defvar gnus-tmp-downloaded nil)
851 (defcustom gnus-summary-highlight
852 '(((eq mark gnus-canceled-mark)
853 . gnus-summary-cancelled-face)
854 ((and (> score default-high)
855 (or (eq mark gnus-dormant-mark)
856 (eq mark gnus-ticked-mark)))
857 . gnus-summary-high-ticked-face)
858 ((and (< score default-low)
859 (or (eq mark gnus-dormant-mark)
860 (eq mark gnus-ticked-mark)))
861 . gnus-summary-low-ticked-face)
862 ((or (eq mark gnus-dormant-mark)
863 (eq mark gnus-ticked-mark))
864 . gnus-summary-normal-ticked-face)
865 ((and (> score default-high) (eq mark gnus-ancient-mark))
866 . gnus-summary-high-ancient-face)
867 ((and (< score default-low) (eq mark gnus-ancient-mark))
868 . gnus-summary-low-ancient-face)
869 ((eq mark gnus-ancient-mark)
870 . gnus-summary-normal-ancient-face)
872 . gnus-agent-downloaded-article-face)
873 ((and (> score default-high) (eq mark gnus-unread-mark))
874 . gnus-summary-high-unread-face)
875 ((and (< score default-low) (eq mark gnus-unread-mark))
876 . gnus-summary-low-unread-face)
877 ((eq mark gnus-unread-mark)
878 . gnus-summary-normal-unread-face)
879 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
880 gnus-undownloaded-mark)))
881 . gnus-summary-high-unread-face)
882 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
883 gnus-undownloaded-mark)))
884 . gnus-summary-low-unread-face)
885 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
886 (memq article gnus-newsgroup-unreads))
887 . gnus-summary-normal-unread-face)
888 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
889 . gnus-summary-normal-read-face)
890 ((> score default-high)
891 . gnus-summary-high-read-face)
892 ((< score default-low)
893 . gnus-summary-low-read-face)
895 . gnus-summary-normal-read-face))
896 "*Controls the highlighting of summary buffer lines.
898 A list of (FORM . FACE) pairs. When deciding how a a particular
899 summary line should be displayed, each form is evaluated. The content
900 of the face field after the first true form is used. You can change
901 how those summary lines are displayed, by editing the face field.
903 You can use the following variables in the FORM field.
905 score: The article's score
906 default: The default article score.
907 default-high: The default score for high scored articles.
908 default-low: The default score for low scored articles.
909 below: The score below which articles are automatically marked as read.
910 mark: The articles mark."
911 :group 'gnus-summary-visual
912 :type '(repeat (cons (sexp :tag "Form" nil)
915 (defcustom gnus-alter-header-function nil
916 "Function called to allow alteration of article header structures.
917 The function is called with one parameter, the article header vector,
918 which it may alter in any way.")
920 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
921 "Variable that says which function should be used to decode a string with encoded words.")
923 (defcustom gnus-extra-headers '(To Newsgroups)
924 "*Extra headers to parse."
927 :type '(repeat symbol))
929 (defcustom gnus-ignored-from-addresses
930 (and user-mail-address (regexp-quote user-mail-address))
931 "*Regexp of From headers that may be suppressed in favor of To headers."
936 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
937 "List of charsets that should be ignored.
938 When these charsets are used in the \"charset\" parameter, the
939 default charset will be used instead."
941 :type '(repeat symbol)
942 :group 'gnus-charset)
944 (gnus-define-group-parameter
948 "Return the ignored charsets of GROUP."
949 :variable gnus-group-ignored-charsets-alist
951 '(("alt\\.chinese\\.text" iso-8859-1))
953 "Alist of regexps (to match group names) and charsets that should be ignored.
954 When these charsets are used in the \"charset\" parameter, the
955 default charset will be used instead."
956 :variable-group gnus-charset
957 :variable-type '(repeat (cons (regexp :tag "Group")
959 :parameter-type '(choice :tag "Ignored charsets"
962 :parameter-document "\
963 List of charsets that should be ignored.
965 When these charsets are used in the \"charset\" parameter, the
966 default charset will be used instead.")
968 (defcustom gnus-group-highlight-words-alist nil
969 "Alist of group regexps and highlight regexps.
970 This variable uses the same syntax as `gnus-emphasis-alist'."
972 :type '(repeat (cons (regexp :tag "Group")
973 (repeat (list (regexp :tag "Highlight regexp")
974 (number :tag "Group for entire word" 0)
975 (number :tag "Group for displayed part" 0)
977 gnus-emphasis-highlight-words)))))
978 :group 'gnus-summary-visual)
980 (defcustom gnus-summary-show-article-charset-alist
982 "Alist of number and charset.
983 The article will be shown with the charset corresponding to the
985 For example: ((1 . cn-gb-2312) (2 . big5))."
987 :type '(repeat (cons (number :tag "Argument" 1)
988 (symbol :tag "Charset")))
989 :group 'gnus-charset)
991 (defcustom gnus-preserve-marks t
992 "Whether marks are preserved when moving, copying and respooling messages."
995 :group 'gnus-summary-marks)
997 (defcustom gnus-alter-articles-to-read-function nil
998 "Function to be called to alter the list of articles to be selected."
999 :type '(choice (const nil) function)
1000 :group 'gnus-summary)
1002 (defcustom gnus-orphan-score nil
1003 "*All orphans get this score added. Set in the score file."
1004 :group 'gnus-score-default
1005 :type '(choice (const nil)
1008 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1009 "*A regexp to match MIME parts when saving multiple parts of a message
1010 with gnus-summary-save-parts (X m). This regexp will be used by default
1011 when prompting the user for which type of files to save."
1012 :group 'gnus-summary
1015 (defcustom gnus-read-all-available-headers nil
1016 "Whether Gnus should parse all headers made available to it.
1017 This is mostly relevant for slow backends where the user may
1018 wish to widen the summary buffer to include all headers
1019 that were fetched. Say, for nnultimate groups."
1020 :group 'gnus-summary
1021 :type '(choice boolean regexp))
1023 (defcustom gnus-summary-muttprint-program "muttprint"
1024 "Command (and optional arguments) used to run Muttprint."
1026 :group 'gnus-summary
1029 (defcustom gnus-article-loose-mime nil
1030 "If non-nil, don't require MIME-Version header.
1031 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1032 supply the MIME-Version header or deliberately strip it From the mail.
1033 Set it to non-nil, Gnus will treat some articles as MIME even if
1034 the MIME-Version header is missed."
1037 :group 'gnus-article)
1039 ;;; Internal variables
1041 (defvar gnus-summary-display-cache nil)
1042 (defvar gnus-article-mime-handles nil)
1043 (defvar gnus-article-decoded-p nil)
1044 (defvar gnus-article-charset nil)
1045 (defvar gnus-article-ignored-charsets nil)
1046 (defvar gnus-scores-exclude-files nil)
1047 (defvar gnus-page-broken nil)
1049 (defvar gnus-original-article nil)
1050 (defvar gnus-article-internal-prepare-hook nil)
1051 (defvar gnus-newsgroup-process-stack nil)
1053 (defvar gnus-thread-indent-array nil)
1054 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1055 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1056 "Function called to sort the articles within a thread after it has been gathered together.")
1058 (defvar gnus-summary-save-parts-type-history nil)
1059 (defvar gnus-summary-save-parts-last-directory nil)
1061 ;; Avoid highlighting in kill files.
1062 (defvar gnus-summary-inhibit-highlight nil)
1063 (defvar gnus-newsgroup-selected-overlay nil)
1064 (defvar gnus-inhibit-limiting nil)
1065 (defvar gnus-newsgroup-adaptive-score-file nil)
1066 (defvar gnus-current-score-file nil)
1067 (defvar gnus-current-move-group nil)
1068 (defvar gnus-current-copy-group nil)
1069 (defvar gnus-current-crosspost-group nil)
1070 (defvar gnus-newsgroup-display nil)
1072 (defvar gnus-newsgroup-dependencies nil)
1073 (defvar gnus-newsgroup-adaptive nil)
1074 (defvar gnus-summary-display-article-function nil)
1075 (defvar gnus-summary-highlight-line-function nil
1076 "Function called after highlighting a summary line.")
1078 (defvar gnus-summary-line-format-alist
1079 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1080 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1081 (?s gnus-tmp-subject-or-nil ?s)
1082 (?n gnus-tmp-name ?s)
1083 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1085 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1087 (?F gnus-tmp-from ?s)
1088 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1089 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1090 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1091 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1092 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1093 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1094 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1095 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1096 (?L gnus-tmp-lines ?s)
1097 (?I gnus-tmp-indentation ?s)
1098 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1099 (?R gnus-tmp-replied ?c)
1100 (?\[ gnus-tmp-opening-bracket ?c)
1101 (?\] gnus-tmp-closing-bracket ?c)
1102 (?\> (make-string gnus-tmp-level ? ) ?s)
1103 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1104 (?i gnus-tmp-score ?d)
1105 (?z gnus-tmp-score-char ?c)
1106 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1107 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1108 (?U gnus-tmp-unread ?c)
1109 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1111 (?t (gnus-summary-number-of-articles-in-thread
1112 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1114 (?e (gnus-summary-number-of-articles-in-thread
1115 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1117 (?u gnus-tmp-user-defined ?s)
1118 (?P (gnus-pick-line-number) ?d)
1119 (?B gnus-tmp-thread-tree-header-string ?s)
1120 (user-date (gnus-user-date
1121 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1122 "An alist of format specifications that can appear in summary lines.
1123 These are paired with what variables they correspond with, along with
1124 the type of the variable (string, integer, character, etc).")
1126 (defvar gnus-summary-dummy-line-format-alist
1127 `((?S gnus-tmp-subject ?s)
1128 (?N gnus-tmp-number ?d)
1129 (?u gnus-tmp-user-defined ?s)))
1131 (defvar gnus-summary-mode-line-format-alist
1132 `((?G gnus-tmp-group-name ?s)
1133 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1134 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1135 (?A gnus-tmp-article-number ?d)
1136 (?Z gnus-tmp-unread-and-unselected ?s)
1137 (?V gnus-version ?s)
1138 (?U gnus-tmp-unread-and-unticked ?d)
1139 (?S gnus-tmp-subject ?s)
1140 (?e gnus-tmp-unselected ?d)
1141 (?u gnus-tmp-user-defined ?s)
1142 (?d (length gnus-newsgroup-dormant) ?d)
1143 (?t (length gnus-newsgroup-marked) ?d)
1144 (?h (length gnus-newsgroup-spam-marked) ?d)
1145 (?r (length gnus-newsgroup-reads) ?d)
1146 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1147 (?E gnus-newsgroup-expunged-tally ?d)
1148 (?s (gnus-current-score-file-nondirectory) ?s)))
1150 (defvar gnus-last-search-regexp nil
1151 "Default regexp for article search command.")
1153 (defvar gnus-last-shell-command nil
1154 "Default shell command on article.")
1156 (defvar gnus-newsgroup-begin nil)
1157 (defvar gnus-newsgroup-end nil)
1158 (defvar gnus-newsgroup-last-rmail nil)
1159 (defvar gnus-newsgroup-last-mail nil)
1160 (defvar gnus-newsgroup-last-folder nil)
1161 (defvar gnus-newsgroup-last-file nil)
1162 (defvar gnus-newsgroup-auto-expire nil)
1163 (defvar gnus-newsgroup-active nil)
1165 (defvar gnus-newsgroup-data nil)
1166 (defvar gnus-newsgroup-data-reverse nil)
1167 (defvar gnus-newsgroup-limit nil)
1168 (defvar gnus-newsgroup-limits nil)
1170 (defvar gnus-newsgroup-unreads nil
1171 "Sorted list of unread articles in the current newsgroup.")
1173 (defvar gnus-newsgroup-unselected nil
1174 "Sorted list of unselected unread articles in the current newsgroup.")
1176 (defvar gnus-newsgroup-reads nil
1177 "Alist of read articles and article marks in the current newsgroup.")
1179 (defvar gnus-newsgroup-expunged-tally nil)
1181 (defvar gnus-newsgroup-marked nil
1182 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1184 (defvar gnus-newsgroup-spam-marked nil
1185 "List of ranges of articles that have been marked as spam.")
1187 (defvar gnus-newsgroup-killed nil
1188 "List of ranges of articles that have been through the scoring process.")
1190 (defvar gnus-newsgroup-cached nil
1191 "Sorted list of articles that come from the article cache.")
1193 (defvar gnus-newsgroup-saved nil
1194 "List of articles that have been saved.")
1196 (defvar gnus-newsgroup-kill-headers nil)
1198 (defvar gnus-newsgroup-replied nil
1199 "List of articles that have been replied to in the current newsgroup.")
1201 (defvar gnus-newsgroup-forwarded nil
1202 "List of articles that have been forwarded in the current newsgroup.")
1204 (defvar gnus-newsgroup-recent nil
1205 "List of articles that have are recent in the current newsgroup.")
1207 (defvar gnus-newsgroup-expirable nil
1208 "Sorted list of articles in the current newsgroup that can be expired.")
1210 (defvar gnus-newsgroup-processable nil
1211 "List of articles in the current newsgroup that can be processed.")
1213 (defvar gnus-newsgroup-downloadable nil
1214 "Sorted list of articles in the current newsgroup that can be processed.")
1216 (defvar gnus-newsgroup-undownloaded nil
1217 "List of articles in the current newsgroup that haven't been downloaded..")
1219 (defvar gnus-newsgroup-unsendable nil
1220 "List of articles in the current newsgroup that won't be sent.")
1222 (defvar gnus-newsgroup-bookmarks nil
1223 "List of articles in the current newsgroup that have bookmarks.")
1225 (defvar gnus-newsgroup-dormant nil
1226 "Sorted list of dormant articles in the current newsgroup.")
1228 (defvar gnus-newsgroup-unseen nil
1229 "List of unseen articles in the current newsgroup.")
1231 (defvar gnus-newsgroup-seen nil
1232 "Range of seen articles in the current newsgroup.")
1234 (defvar gnus-newsgroup-articles nil
1235 "List of articles in the current newsgroup.")
1237 (defvar gnus-newsgroup-scored nil
1238 "List of scored articles in the current newsgroup.")
1240 (defvar gnus-newsgroup-headers nil
1241 "List of article headers in the current newsgroup.")
1243 (defvar gnus-newsgroup-threads nil)
1245 (defvar gnus-newsgroup-prepared nil
1246 "Whether the current group has been prepared properly.")
1248 (defvar gnus-newsgroup-ancient nil
1249 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1251 (defvar gnus-newsgroup-sparse nil)
1253 (defvar gnus-current-article nil)
1254 (defvar gnus-article-current nil)
1255 (defvar gnus-current-headers nil)
1256 (defvar gnus-have-all-headers nil)
1257 (defvar gnus-last-article nil)
1258 (defvar gnus-newsgroup-history nil)
1259 (defvar gnus-newsgroup-charset nil)
1260 (defvar gnus-newsgroup-ephemeral-charset nil)
1261 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1263 (defvar gnus-article-before-search nil)
1265 (defconst gnus-summary-local-variables
1266 '(gnus-newsgroup-name
1267 gnus-newsgroup-begin gnus-newsgroup-end
1268 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1269 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1270 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1271 gnus-newsgroup-unselected gnus-newsgroup-marked
1272 gnus-newsgroup-spam-marked
1273 gnus-newsgroup-reads gnus-newsgroup-saved
1274 gnus-newsgroup-replied gnus-newsgroup-forwarded
1275 gnus-newsgroup-recent
1276 gnus-newsgroup-expirable
1277 gnus-newsgroup-processable gnus-newsgroup-killed
1278 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1279 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1280 gnus-newsgroup-seen gnus-newsgroup-articles
1281 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1282 gnus-newsgroup-headers gnus-newsgroup-threads
1283 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1284 gnus-current-article gnus-current-headers gnus-have-all-headers
1285 gnus-last-article gnus-article-internal-prepare-hook
1286 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1287 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1288 gnus-thread-expunge-below
1289 gnus-score-alist gnus-current-score-file
1290 (gnus-summary-expunge-below . global)
1291 (gnus-summary-mark-below . global)
1292 (gnus-orphan-score . global)
1293 gnus-newsgroup-active gnus-scores-exclude-files
1294 gnus-newsgroup-history gnus-newsgroup-ancient
1295 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1296 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1297 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1298 (gnus-newsgroup-expunged-tally . 0)
1299 gnus-cache-removable-articles gnus-newsgroup-cached
1300 gnus-newsgroup-data gnus-newsgroup-data-reverse
1301 gnus-newsgroup-limit gnus-newsgroup-limits
1302 gnus-newsgroup-charset gnus-newsgroup-display)
1303 "Variables that are buffer-local to the summary buffers.")
1305 (defvar gnus-newsgroup-variables nil
1306 "A list of variables that have separate values in different newsgroups.
1307 A list of newsgroup (summary buffer) local variables, or cons of
1308 variables and their default values (when the default values are not
1309 nil), that should be made global while the summary buffer is active.
1310 These variables can be used to set variables in the group parameters
1311 while still allowing them to affect operations done in other
1312 buffers. For example:
1314 \(setq gnus-newsgroup-variables
1315 '(message-use-followup-to
1316 (gnus-visible-headers .
1317 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1320 ;; Byte-compiler warning.
1321 (eval-when-compile (defvar gnus-article-mode-map))
1325 (defvar gnus-decode-encoded-word-methods
1326 '(mail-decode-encoded-word-string)
1327 "List of methods used to decode encoded words.
1329 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1330 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1331 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1332 whose names match REGEXP.
1335 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1336 mail-decode-encoded-word-string
1337 (\"chinese\" . rfc1843-decode-string))")
1339 (defvar gnus-decode-encoded-word-methods-cache nil)
1341 (defun gnus-multi-decode-encoded-word-string (string)
1342 "Apply the functions from `gnus-encoded-word-methods' that match."
1343 (unless (and gnus-decode-encoded-word-methods-cache
1344 (eq gnus-newsgroup-name
1345 (car gnus-decode-encoded-word-methods-cache)))
1346 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1349 (nconc gnus-decode-encoded-word-methods-cache (list x))
1350 (if (and gnus-newsgroup-name
1351 (string-match (car x) gnus-newsgroup-name))
1352 (nconc gnus-decode-encoded-word-methods-cache
1354 gnus-decode-encoded-word-methods))
1355 (let ((xlist gnus-decode-encoded-word-methods-cache))
1358 (setq string (funcall (pop xlist) string))))
1361 ;; Subject simplification.
1363 (defun gnus-simplify-whitespace (str)
1364 "Remove excessive whitespace from STR."
1367 (while (string-match "[ \t][ \t]+" mystr)
1368 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1370 (substring mystr (match-end 0)))))
1372 (when (string-match "^[ \t]+" mystr)
1373 (setq mystr (substring mystr (match-end 0))))
1375 (when (string-match "[ \t]+$" mystr)
1376 (setq mystr (substring mystr 0 (match-beginning 0))))
1379 (defun gnus-simplify-all-whitespace (str)
1380 "Remove all whitespace from STR."
1382 (while (string-match "[ \t\n]+" mystr)
1383 (setq mystr (replace-match "" nil nil mystr)))
1386 (defsubst gnus-simplify-subject-re (subject)
1387 "Remove \"Re:\" from subject lines."
1388 (if (string-match message-subject-re-regexp subject)
1389 (substring subject (match-end 0))
1392 (defun gnus-simplify-subject (subject &optional re-only)
1393 "Remove `Re:' and words in parentheses.
1394 If RE-ONLY is non-nil, strip leading `Re:'s only."
1395 (let ((case-fold-search t)) ;Ignore case.
1396 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1397 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1398 (setq subject (substring subject (match-end 0))))
1399 ;; Remove uninteresting prefixes.
1400 (when (and (not re-only)
1401 gnus-simplify-ignored-prefixes
1402 (string-match gnus-simplify-ignored-prefixes subject))
1403 (setq subject (substring subject (match-end 0))))
1404 ;; Remove words in parentheses from end.
1406 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1407 (setq subject (substring subject 0 (match-beginning 0)))))
1408 ;; Return subject string.
1411 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1413 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1414 (goto-char (point-min))
1415 (while (re-search-forward regexp nil t)
1416 (replace-match (or newtext ""))))
1418 (defun gnus-simplify-buffer-fuzzy ()
1419 "Simplify string in the buffer fuzzily.
1420 The string in the accessible portion of the current buffer is simplified.
1421 It is assumed to be a single-line subject.
1422 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1423 matter is removed. Additional things can be deleted by setting
1424 `gnus-simplify-subject-fuzzy-regexp'."
1425 (let ((case-fold-search t)
1427 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1429 (while (not (eq modified-tick (buffer-modified-tick)))
1430 (setq modified-tick (buffer-modified-tick))
1432 ((listp gnus-simplify-subject-fuzzy-regexp)
1433 (mapcar 'gnus-simplify-buffer-fuzzy-step
1434 gnus-simplify-subject-fuzzy-regexp))
1435 (gnus-simplify-subject-fuzzy-regexp
1436 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1437 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1438 (gnus-simplify-buffer-fuzzy-step
1439 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1440 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1442 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1443 (gnus-simplify-buffer-fuzzy-step " +" " ")
1444 (gnus-simplify-buffer-fuzzy-step " $")
1445 (gnus-simplify-buffer-fuzzy-step "^ +")))
1447 (defun gnus-simplify-subject-fuzzy (subject)
1448 "Simplify a subject string fuzzily.
1449 See `gnus-simplify-buffer-fuzzy' for details."
1451 (gnus-set-work-buffer)
1452 (let ((case-fold-search t))
1453 ;; Remove uninteresting prefixes.
1454 (when (and gnus-simplify-ignored-prefixes
1455 (string-match gnus-simplify-ignored-prefixes subject))
1456 (setq subject (substring subject (match-end 0))))
1458 (inline (gnus-simplify-buffer-fuzzy))
1461 (defsubst gnus-simplify-subject-fully (subject)
1462 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1464 (gnus-simplify-subject-functions
1465 (gnus-map-function gnus-simplify-subject-functions subject))
1466 ((null gnus-summary-gather-subject-limit)
1467 (gnus-simplify-subject-re subject))
1468 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1469 (gnus-simplify-subject-fuzzy subject))
1470 ((numberp gnus-summary-gather-subject-limit)
1471 (gnus-limit-string (gnus-simplify-subject-re subject)
1472 gnus-summary-gather-subject-limit))
1476 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1477 "Check whether two subjects are equal.
1478 If optional argument simple-first is t, first argument is already
1481 ((null simple-first)
1482 (equal (gnus-simplify-subject-fully s1)
1483 (gnus-simplify-subject-fully s2)))
1486 (gnus-simplify-subject-fully s2)))))
1488 (defun gnus-summary-bubble-group ()
1489 "Increase the score of the current group.
1490 This is a handy function to add to `gnus-summary-exit-hook' to
1491 increase the score of each group you read."
1492 (gnus-group-add-score gnus-newsgroup-name))
1496 ;;; Gnus summary mode
1499 (put 'gnus-summary-mode 'mode-class 'special)
1501 (defvar gnus-article-commands-menu)
1504 ;; Non-orthogonal keys
1506 (gnus-define-keys gnus-summary-mode-map
1507 " " gnus-summary-next-page
1508 "\177" gnus-summary-prev-page
1509 [delete] gnus-summary-prev-page
1510 [backspace] gnus-summary-prev-page
1511 "\r" gnus-summary-scroll-up
1512 "\M-\r" gnus-summary-scroll-down
1513 "n" gnus-summary-next-unread-article
1514 "p" gnus-summary-prev-unread-article
1515 "N" gnus-summary-next-article
1516 "P" gnus-summary-prev-article
1517 "\M-\C-n" gnus-summary-next-same-subject
1518 "\M-\C-p" gnus-summary-prev-same-subject
1519 "\M-n" gnus-summary-next-unread-subject
1520 "\M-p" gnus-summary-prev-unread-subject
1521 "." gnus-summary-first-unread-article
1522 "," gnus-summary-best-unread-article
1523 "\M-s" gnus-summary-search-article-forward
1524 "\M-r" gnus-summary-search-article-backward
1525 "<" gnus-summary-beginning-of-article
1526 ">" gnus-summary-end-of-article
1527 "j" gnus-summary-goto-article
1528 "^" gnus-summary-refer-parent-article
1529 "\M-^" gnus-summary-refer-article
1530 "u" gnus-summary-tick-article-forward
1531 "!" gnus-summary-tick-article-forward
1532 "U" gnus-summary-tick-article-backward
1533 "d" gnus-summary-mark-as-read-forward
1534 "D" gnus-summary-mark-as-read-backward
1535 "E" gnus-summary-mark-as-expirable
1536 "\M-u" gnus-summary-clear-mark-forward
1537 "\M-U" gnus-summary-clear-mark-backward
1538 "k" gnus-summary-kill-same-subject-and-select
1539 "\C-k" gnus-summary-kill-same-subject
1540 "\M-\C-k" gnus-summary-kill-thread
1541 "\M-\C-l" gnus-summary-lower-thread
1542 "e" gnus-summary-edit-article
1543 "#" gnus-summary-mark-as-processable
1544 "\M-#" gnus-summary-unmark-as-processable
1545 "\M-\C-t" gnus-summary-toggle-threads
1546 "\M-\C-s" gnus-summary-show-thread
1547 "\M-\C-h" gnus-summary-hide-thread
1548 "\M-\C-f" gnus-summary-next-thread
1549 "\M-\C-b" gnus-summary-prev-thread
1550 [(meta down)] gnus-summary-next-thread
1551 [(meta up)] gnus-summary-prev-thread
1552 "\M-\C-u" gnus-summary-up-thread
1553 "\M-\C-d" gnus-summary-down-thread
1554 "&" gnus-summary-execute-command
1555 "c" gnus-summary-catchup-and-exit
1556 "\C-w" gnus-summary-mark-region-as-read
1557 "\C-t" gnus-summary-toggle-truncation
1558 "?" gnus-summary-mark-as-dormant
1559 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1560 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1561 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1562 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1563 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1564 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1565 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1566 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1567 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1568 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1569 "=" gnus-summary-expand-window
1570 "\C-x\C-s" gnus-summary-reselect-current-group
1571 "\M-g" gnus-summary-rescan-group
1572 "w" gnus-summary-stop-page-breaking
1573 "\C-c\C-r" gnus-summary-caesar-message
1574 "f" gnus-summary-followup
1575 "F" gnus-summary-followup-with-original
1576 "C" gnus-summary-cancel-article
1577 "r" gnus-summary-reply
1578 "R" gnus-summary-reply-with-original
1579 "\C-c\C-f" gnus-summary-mail-forward
1580 "o" gnus-summary-save-article
1581 "\C-o" gnus-summary-save-article-mail
1582 "|" gnus-summary-pipe-output
1583 "\M-k" gnus-summary-edit-local-kill
1584 "\M-K" gnus-summary-edit-global-kill
1586 "\C-c\C-d" gnus-summary-describe-group
1587 "q" gnus-summary-exit
1588 "Q" gnus-summary-exit-no-update
1589 "\C-c\C-i" gnus-info-find-node
1590 gnus-mouse-2 gnus-mouse-pick-article
1591 "m" gnus-summary-mail-other-window
1592 "a" gnus-summary-post-news
1593 "i" gnus-summary-news-other-window
1594 "x" gnus-summary-limit-to-unread
1595 "s" gnus-summary-isearch-article
1596 "t" gnus-summary-toggle-header
1597 "g" gnus-summary-show-article
1598 "l" gnus-summary-goto-last-article
1599 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1600 "\C-d" gnus-summary-enter-digest-group
1601 "\M-\C-d" gnus-summary-read-document
1602 "\M-\C-e" gnus-summary-edit-parameters
1603 "\M-\C-a" gnus-summary-customize-parameters
1605 "*" gnus-cache-enter-article
1606 "\M-*" gnus-cache-remove-article
1607 "\M-&" gnus-summary-universal-argument
1608 "\C-l" gnus-recenter
1609 "I" gnus-summary-increase-score
1610 "L" gnus-summary-lower-score
1611 "\M-i" gnus-symbolic-argument
1612 "h" gnus-summary-select-article-buffer
1614 "b" gnus-article-view-part
1615 "\M-t" gnus-summary-toggle-display-buttonized
1617 "V" gnus-summary-score-map
1618 "X" gnus-uu-extract-map
1619 "S" gnus-summary-send-map)
1621 ;; Sort of orthogonal keymap
1622 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1623 "t" gnus-summary-tick-article-forward
1624 "!" gnus-summary-tick-article-forward
1625 "d" gnus-summary-mark-as-read-forward
1626 "r" gnus-summary-mark-as-read-forward
1627 "c" gnus-summary-clear-mark-forward
1628 " " gnus-summary-clear-mark-forward
1629 "e" gnus-summary-mark-as-expirable
1630 "x" gnus-summary-mark-as-expirable
1631 "?" gnus-summary-mark-as-dormant
1632 "b" gnus-summary-set-bookmark
1633 "B" gnus-summary-remove-bookmark
1634 "#" gnus-summary-mark-as-processable
1635 "\M-#" gnus-summary-unmark-as-processable
1636 "S" gnus-summary-limit-include-expunged
1637 "C" gnus-summary-catchup
1638 "H" gnus-summary-catchup-to-here
1639 "h" gnus-summary-catchup-from-here
1640 "\C-c" gnus-summary-catchup-all
1641 "k" gnus-summary-kill-same-subject-and-select
1642 "K" gnus-summary-kill-same-subject
1643 "P" gnus-uu-mark-map)
1645 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1646 "c" gnus-summary-clear-above
1647 "u" gnus-summary-tick-above
1648 "m" gnus-summary-mark-above
1649 "k" gnus-summary-kill-below)
1651 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1652 "/" gnus-summary-limit-to-subject
1653 "n" gnus-summary-limit-to-articles
1654 "w" gnus-summary-pop-limit
1655 "s" gnus-summary-limit-to-subject
1656 "a" gnus-summary-limit-to-author
1657 "u" gnus-summary-limit-to-unread
1658 "m" gnus-summary-limit-to-marks
1659 "M" gnus-summary-limit-exclude-marks
1660 "v" gnus-summary-limit-to-score
1661 "*" gnus-summary-limit-include-cached
1662 "D" gnus-summary-limit-include-dormant
1663 "T" gnus-summary-limit-include-thread
1664 "d" gnus-summary-limit-exclude-dormant
1665 "t" gnus-summary-limit-to-age
1666 "." gnus-summary-limit-to-unseen
1667 "x" gnus-summary-limit-to-extra
1668 "p" gnus-summary-limit-to-display-predicate
1669 "E" gnus-summary-limit-include-expunged
1670 "c" gnus-summary-limit-exclude-childless-dormant
1671 "C" gnus-summary-limit-mark-excluded-as-read
1672 "o" gnus-summary-insert-old-articles
1673 "N" gnus-summary-insert-new-articles)
1675 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1676 "n" gnus-summary-next-unread-article
1677 "p" gnus-summary-prev-unread-article
1678 "N" gnus-summary-next-article
1679 "P" gnus-summary-prev-article
1680 "\C-n" gnus-summary-next-same-subject
1681 "\C-p" gnus-summary-prev-same-subject
1682 "\M-n" gnus-summary-next-unread-subject
1683 "\M-p" gnus-summary-prev-unread-subject
1684 "f" gnus-summary-first-unread-article
1685 "b" gnus-summary-best-unread-article
1686 "j" gnus-summary-goto-article
1687 "g" gnus-summary-goto-subject
1688 "l" gnus-summary-goto-last-article
1689 "o" gnus-summary-pop-article)
1691 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1692 "k" gnus-summary-kill-thread
1693 "l" gnus-summary-lower-thread
1694 "i" gnus-summary-raise-thread
1695 "T" gnus-summary-toggle-threads
1696 "t" gnus-summary-rethread-current
1697 "^" gnus-summary-reparent-thread
1698 "s" gnus-summary-show-thread
1699 "S" gnus-summary-show-all-threads
1700 "h" gnus-summary-hide-thread
1701 "H" gnus-summary-hide-all-threads
1702 "n" gnus-summary-next-thread
1703 "p" gnus-summary-prev-thread
1704 "u" gnus-summary-up-thread
1705 "o" gnus-summary-top-thread
1706 "d" gnus-summary-down-thread
1707 "#" gnus-uu-mark-thread
1708 "\M-#" gnus-uu-unmark-thread)
1710 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1711 "g" gnus-summary-prepare
1712 "c" gnus-summary-insert-cached-articles)
1714 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1715 "c" gnus-summary-catchup-and-exit
1716 "C" gnus-summary-catchup-all-and-exit
1717 "E" gnus-summary-exit-no-update
1718 "Q" gnus-summary-exit
1719 "Z" gnus-summary-exit
1720 "n" gnus-summary-catchup-and-goto-next-group
1721 "R" gnus-summary-reselect-current-group
1722 "G" gnus-summary-rescan-group
1723 "N" gnus-summary-next-group
1724 "s" gnus-summary-save-newsrc
1725 "P" gnus-summary-prev-group)
1727 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1728 " " gnus-summary-next-page
1729 "n" gnus-summary-next-page
1730 "\177" gnus-summary-prev-page
1731 [delete] gnus-summary-prev-page
1732 "p" gnus-summary-prev-page
1733 "\r" gnus-summary-scroll-up
1734 "\M-\r" gnus-summary-scroll-down
1735 "<" gnus-summary-beginning-of-article
1736 ">" gnus-summary-end-of-article
1737 "b" gnus-summary-beginning-of-article
1738 "e" gnus-summary-end-of-article
1739 "^" gnus-summary-refer-parent-article
1740 "r" gnus-summary-refer-parent-article
1741 "D" gnus-summary-enter-digest-group
1742 "R" gnus-summary-refer-references
1743 "T" gnus-summary-refer-thread
1744 "g" gnus-summary-show-article
1745 "s" gnus-summary-isearch-article
1746 "P" gnus-summary-print-article
1747 "M" gnus-mailing-list-insinuate
1748 "t" gnus-article-babel)
1750 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1751 "b" gnus-article-add-buttons
1752 "B" gnus-article-add-buttons-to-head
1753 "o" gnus-article-treat-overstrike
1754 "e" gnus-article-emphasize
1755 "w" gnus-article-fill-cited-article
1756 "Q" gnus-article-fill-long-lines
1757 "C" gnus-article-capitalize-sentences
1758 "c" gnus-article-remove-cr
1759 "q" gnus-article-de-quoted-unreadable
1760 "6" gnus-article-de-base64-unreadable
1761 "Z" gnus-article-decode-HZ
1762 "h" gnus-article-wash-html
1763 "u" gnus-article-unsplit-urls
1764 "s" gnus-summary-force-verify-and-decrypt
1765 "f" gnus-article-display-x-face
1766 "l" gnus-summary-stop-page-breaking
1767 "r" gnus-summary-caesar-message
1768 "m" gnus-summary-morse-message
1769 "t" gnus-summary-toggle-header
1770 "g" gnus-treat-smiley
1771 "v" gnus-summary-verbose-headers
1772 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1773 "p" gnus-article-verify-x-pgp-sig
1774 "d" gnus-article-treat-dumbquotes
1775 "k" gnus-article-outlook-deuglify-article)
1777 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1778 "a" gnus-article-hide
1779 "h" gnus-article-hide-headers
1780 "b" gnus-article-hide-boring-headers
1781 "s" gnus-article-hide-signature
1782 "c" gnus-article-hide-citation
1783 "C" gnus-article-hide-citation-in-followups
1784 "l" gnus-article-hide-list-identifiers
1785 "p" gnus-article-hide-pgp
1786 "B" gnus-article-strip-banner
1787 "P" gnus-article-hide-pem
1788 "\C-c" gnus-article-hide-citation-maybe)
1790 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1791 "a" gnus-article-highlight
1792 "h" gnus-article-highlight-headers
1793 "c" gnus-article-highlight-citation
1794 "s" gnus-article-highlight-signature)
1796 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1797 "f" gnus-article-treat-fold-headers
1798 "u" gnus-article-treat-unfold-headers
1799 "n" gnus-article-treat-fold-newsgroups)
1801 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1802 "x" gnus-article-display-x-face
1803 "s" gnus-treat-smiley
1804 "D" gnus-article-remove-images
1805 "f" gnus-treat-from-picon
1806 "m" gnus-treat-mail-picon
1807 "n" gnus-treat-newsgroups-picon)
1809 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1810 "w" gnus-article-decode-mime-words
1811 "c" gnus-article-decode-charset
1812 "v" gnus-mime-view-all-parts
1813 "b" gnus-article-view-part)
1815 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1816 "z" gnus-article-date-ut
1817 "u" gnus-article-date-ut
1818 "l" gnus-article-date-local
1819 "p" gnus-article-date-english
1820 "e" gnus-article-date-lapsed
1821 "o" gnus-article-date-original
1822 "i" gnus-article-date-iso8601
1823 "s" gnus-article-date-user)
1825 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1826 "t" gnus-article-remove-trailing-blank-lines
1827 "l" gnus-article-strip-leading-blank-lines
1828 "m" gnus-article-strip-multiple-blank-lines
1829 "a" gnus-article-strip-blank-lines
1830 "A" gnus-article-strip-all-blank-lines
1831 "s" gnus-article-strip-leading-space
1832 "e" gnus-article-strip-trailing-space
1833 "w" gnus-article-remove-leading-whitespace)
1835 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1837 "f" gnus-summary-fetch-faq
1838 "d" gnus-summary-describe-group
1839 "h" gnus-summary-describe-briefly
1840 "i" gnus-info-find-node
1841 "c" gnus-group-fetch-charter
1842 "C" gnus-group-fetch-control)
1844 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1845 "e" gnus-summary-expire-articles
1846 "\M-\C-e" gnus-summary-expire-articles-now
1847 "\177" gnus-summary-delete-article
1848 [delete] gnus-summary-delete-article
1849 [backspace] gnus-summary-delete-article
1850 "m" gnus-summary-move-article
1851 "r" gnus-summary-respool-article
1852 "w" gnus-summary-edit-article
1853 "c" gnus-summary-copy-article
1854 "B" gnus-summary-crosspost-article
1855 "q" gnus-summary-respool-query
1856 "t" gnus-summary-respool-trace
1857 "i" gnus-summary-import-article
1858 "I" gnus-summary-create-article
1859 "p" gnus-summary-article-posted-p)
1861 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1862 "o" gnus-summary-save-article
1863 "m" gnus-summary-save-article-mail
1864 "F" gnus-summary-write-article-file
1865 "r" gnus-summary-save-article-rmail
1866 "f" gnus-summary-save-article-file
1867 "b" gnus-summary-save-article-body-file
1868 "h" gnus-summary-save-article-folder
1869 "v" gnus-summary-save-article-vm
1870 "p" gnus-summary-pipe-output
1871 "P" gnus-summary-muttprint
1872 "s" gnus-soup-add-article)
1874 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1875 "b" gnus-summary-display-buttonized
1876 "m" gnus-summary-repair-multipart
1877 "v" gnus-article-view-part
1878 "o" gnus-article-save-part
1879 "c" gnus-article-copy-part
1880 "C" gnus-article-view-part-as-charset
1881 "e" gnus-article-view-part-externally
1882 "E" gnus-article-encrypt-body
1883 "i" gnus-article-inline-part
1884 "|" gnus-article-pipe-part)
1886 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1887 "p" gnus-summary-mark-as-processable
1888 "u" gnus-summary-unmark-as-processable
1889 "U" gnus-summary-unmark-all-processable
1890 "v" gnus-uu-mark-over
1891 "s" gnus-uu-mark-series
1892 "r" gnus-uu-mark-region
1893 "g" gnus-uu-unmark-region
1894 "R" gnus-uu-mark-by-regexp
1895 "G" gnus-uu-unmark-by-regexp
1896 "t" gnus-uu-mark-thread
1897 "T" gnus-uu-unmark-thread
1898 "a" gnus-uu-mark-all
1899 "b" gnus-uu-mark-buffer
1900 "S" gnus-uu-mark-sparse
1901 "k" gnus-summary-kill-process-mark
1902 "y" gnus-summary-yank-process-mark
1903 "w" gnus-summary-save-process-mark
1904 "i" gnus-uu-invert-processable)
1906 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1907 ;;"x" gnus-uu-extract-any
1908 "m" gnus-summary-save-parts
1909 "u" gnus-uu-decode-uu
1910 "U" gnus-uu-decode-uu-and-save
1911 "s" gnus-uu-decode-unshar
1912 "S" gnus-uu-decode-unshar-and-save
1913 "o" gnus-uu-decode-save
1914 "O" gnus-uu-decode-save
1915 "b" gnus-uu-decode-binhex
1916 "B" gnus-uu-decode-binhex
1917 "p" gnus-uu-decode-postscript
1918 "P" gnus-uu-decode-postscript-and-save)
1921 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1922 "u" gnus-uu-decode-uu-view
1923 "U" gnus-uu-decode-uu-and-save-view
1924 "s" gnus-uu-decode-unshar-view
1925 "S" gnus-uu-decode-unshar-and-save-view
1926 "o" gnus-uu-decode-save-view
1927 "O" gnus-uu-decode-save-view
1928 "b" gnus-uu-decode-binhex-view
1929 "B" gnus-uu-decode-binhex-view
1930 "p" gnus-uu-decode-postscript-view
1931 "P" gnus-uu-decode-postscript-and-save-view))
1933 (defvar gnus-article-post-menu nil)
1935 (defconst gnus-summary-menu-maxlen 20)
1937 (defun gnus-summary-menu-split (menu)
1938 ;; If we have lots of elements, divide them into groups of 20
1939 ;; and make a pane (or submenu) for each one.
1940 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1941 (let ((menu menu) sublists next
1944 ;; Pull off the next gnus-summary-menu-maxlen elements
1945 ;; and make them the next element of sublist.
1946 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1948 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1950 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1951 (aref (car (last menu)) 0)) menu)
1955 (nreverse sublists))
1956 ;; Few elements--put them all in one pane.
1959 (defun gnus-summary-make-menu-bar ()
1960 (gnus-turn-off-edit-menu 'summary)
1962 (unless (boundp 'gnus-summary-misc-menu)
1965 gnus-summary-kill-menu gnus-summary-mode-map ""
1970 ["Customize" gnus-score-customize t])
1971 (gnus-make-score-map 'increase)
1972 (gnus-make-score-map 'lower)
1974 ["Kill below" gnus-summary-kill-below t]
1975 ["Mark above" gnus-summary-mark-above t]
1976 ["Tick above" gnus-summary-tick-above t]
1977 ["Clear above" gnus-summary-clear-above t])
1978 ["Current score" gnus-summary-current-score t]
1979 ["Set score" gnus-summary-set-score t]
1980 ["Switch current score file..." gnus-score-change-score-file t]
1981 ["Set mark below..." gnus-score-set-mark-below t]
1982 ["Set expunge below..." gnus-score-set-expunge-below t]
1983 ["Edit current score file" gnus-score-edit-current-scores t]
1984 ["Edit score file" gnus-score-edit-file t]
1985 ["Trace score" gnus-score-find-trace t]
1986 ["Find words" gnus-score-find-favourite-words t]
1987 ["Rescore buffer" gnus-summary-rescore t]
1988 ["Increase score..." gnus-summary-increase-score t]
1989 ["Lower score..." gnus-summary-lower-score t]))))
1991 ;; Define both the Article menu in the summary buffer and the
1992 ;; equivalent Commands menu in the article buffer here for
1996 ["All" gnus-article-hide t]
1997 ["Headers" gnus-article-hide-headers t]
1998 ["Signature" gnus-article-hide-signature t]
1999 ["Citation" gnus-article-hide-citation t]
2000 ["List identifiers" gnus-article-hide-list-identifiers t]
2001 ["PGP" gnus-article-hide-pgp t]
2002 ["Banner" gnus-article-strip-banner t]
2003 ["Boring headers" gnus-article-hide-boring-headers t])
2005 ["All" gnus-article-highlight t]
2006 ["Headers" gnus-article-highlight-headers t]
2007 ["Signature" gnus-article-highlight-signature t]
2008 ["Citation" gnus-article-highlight-citation t])
2010 ["Words" gnus-article-decode-mime-words t]
2011 ["Charset" gnus-article-decode-charset t]
2012 ["QP" gnus-article-de-quoted-unreadable t]
2013 ["Base64" gnus-article-de-base64-unreadable t]
2014 ["View MIME buttons" gnus-summary-display-buttonized t]
2015 ["View all" gnus-mime-view-all-parts t]
2016 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2017 ["Encrypt body" gnus-article-encrypt-body t]
2018 ["Extract all parts" gnus-summary-save-parts t])
2020 ["Local" gnus-article-date-local t]
2021 ["ISO8601" gnus-article-date-iso8601 t]
2022 ["UT" gnus-article-date-ut t]
2023 ["Original" gnus-article-date-original t]
2024 ["Lapsed" gnus-article-date-lapsed t]
2025 ["User-defined" gnus-article-date-user t])
2027 ["Remove images" gnus-article-remove-images t]
2028 ["Toggle smiley" gnus-treat-smiley t]
2029 ["Show X-Face" gnus-article-display-x-face t]
2030 ["Show picons in From" gnus-treat-from-picon t]
2031 ["Show picons in mail headers" gnus-treat-mail-picon t]
2032 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2033 ("View as different encoding"
2034 ,@(gnus-summary-menu-split
2037 ;; Since easymenu under FSF Emacs doesn't allow lambda
2038 ;; forms for menu commands, we should provide intern'ed
2039 ;; function symbols.
2040 (let ((command (intern (format "\
2041 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2045 (let ((gnus-summary-show-article-charset-alist
2047 (gnus-summary-show-article 1))))
2048 `[,(symbol-name cs) ,command t]))
2049 (sort (if (fboundp 'coding-system-list)
2050 (coding-system-list)
2051 (mapcar 'car mm-mime-mule-charset-alist))
2055 ["Leading" gnus-article-strip-leading-blank-lines t]
2056 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2057 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2058 ["All of the above" gnus-article-strip-blank-lines t]
2059 ["All" gnus-article-strip-all-blank-lines t]
2060 ["Leading space" gnus-article-strip-leading-space t]
2061 ["Trailing space" gnus-article-strip-trailing-space t]
2062 ["Leading space in headers"
2063 gnus-article-remove-leading-whitespace t])
2064 ["Overstrike" gnus-article-treat-overstrike t]
2065 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2066 ["Emphasis" gnus-article-emphasize t]
2067 ["Word wrap" gnus-article-fill-cited-article t]
2068 ["Fill long lines" gnus-article-fill-long-lines t]
2069 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2070 ["CR" gnus-article-remove-cr t]
2071 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2072 ["Base64" gnus-article-de-base64-unreadable t]
2073 ["Rot 13" gnus-summary-caesar-message
2074 ,@(if (featurep 'xemacs) '(t)
2075 '(:help "\"Caesar rotate\" article by 13"))]
2076 ["Morse decode" gnus-summary-morse-message t]
2077 ["Unix pipe..." gnus-summary-pipe-message t]
2078 ["Add buttons" gnus-article-add-buttons t]
2079 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2080 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2081 ["Verbose header" gnus-summary-verbose-headers t]
2082 ["Toggle header" gnus-summary-toggle-header t]
2083 ["Unfold headers" gnus-article-treat-unfold-headers t]
2084 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2085 ["Html" gnus-article-wash-html t]
2086 ["URLs" gnus-article-unsplit-urls t]
2087 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2088 ["HZ" gnus-article-decode-HZ t]
2089 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2092 ["Save in default format" gnus-summary-save-article
2093 ,@(if (featurep 'xemacs) '(t)
2094 '(:help "Save article using default method"))]
2095 ["Save in file" gnus-summary-save-article-file
2096 ,@(if (featurep 'xemacs) '(t)
2097 '(:help "Save article in file"))]
2098 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2099 ["Save in MH folder" gnus-summary-save-article-folder t]
2100 ["Save in VM folder" gnus-summary-save-article-vm t]
2101 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2102 ["Save body in file" gnus-summary-save-article-body-file t]
2103 ["Pipe through a filter" gnus-summary-pipe-output t]
2104 ["Add to SOUP packet" gnus-soup-add-article t]
2105 ["Print with Muttprint" gnus-summary-muttprint t]
2106 ["Print" gnus-summary-print-article t])
2108 ["Respool article..." gnus-summary-respool-article t]
2109 ["Move article..." gnus-summary-move-article
2110 (gnus-check-backend-function
2111 'request-move-article gnus-newsgroup-name)]
2112 ["Copy article..." gnus-summary-copy-article t]
2113 ["Crosspost article..." gnus-summary-crosspost-article
2114 (gnus-check-backend-function
2115 'request-replace-article gnus-newsgroup-name)]
2116 ["Import file..." gnus-summary-import-article t]
2117 ["Create article..." gnus-summary-create-article t]
2118 ["Check if posted" gnus-summary-article-posted-p t]
2119 ["Edit article" gnus-summary-edit-article
2120 (not (gnus-group-read-only-p))]
2121 ["Delete article" gnus-summary-delete-article
2122 (gnus-check-backend-function
2123 'request-expire-articles gnus-newsgroup-name)]
2124 ["Query respool" gnus-summary-respool-query t]
2125 ["Trace respool" gnus-summary-respool-trace t]
2126 ["Delete expirable articles" gnus-summary-expire-articles-now
2127 (gnus-check-backend-function
2128 'request-expire-articles gnus-newsgroup-name)])
2130 ["Uudecode" gnus-uu-decode-uu
2131 ,@(if (featurep 'xemacs) '(t)
2132 '(:help "Decode uuencoded article(s)"))]
2133 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2134 ["Unshar" gnus-uu-decode-unshar t]
2135 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2136 ["Save" gnus-uu-decode-save t]
2137 ["Binhex" gnus-uu-decode-binhex t]
2138 ["Postscript" gnus-uu-decode-postscript t]
2139 ["All MIME parts" gnus-summary-save-parts t])
2141 ["Enter article" gnus-cache-enter-article t]
2142 ["Remove article" gnus-cache-remove-article t])
2143 ["Translate" gnus-article-babel t]
2144 ["Select article buffer" gnus-summary-select-article-buffer t]
2145 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2146 ["Isearch article..." gnus-summary-isearch-article t]
2147 ["Beginning of the article" gnus-summary-beginning-of-article t]
2148 ["End of the article" gnus-summary-end-of-article t]
2149 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2150 ["Fetch referenced articles" gnus-summary-refer-references t]
2151 ["Fetch current thread" gnus-summary-refer-thread t]
2152 ["Fetch article with id..." gnus-summary-refer-article t]
2153 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2154 ["Redisplay" gnus-summary-show-article t]
2155 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2157 gnus-summary-article-menu gnus-summary-mode-map ""
2158 (cons "Article" innards))
2160 (if (not (keymapp gnus-summary-article-menu))
2162 gnus-article-commands-menu gnus-article-mode-map ""
2163 (cons "Commands" innards))
2164 ;; in Emacs, don't share menu.
2165 (setq gnus-article-commands-menu
2166 (copy-keymap gnus-summary-article-menu))
2167 (define-key gnus-article-mode-map [menu-bar commands]
2168 (cons "Commands" gnus-article-commands-menu))))
2171 gnus-summary-thread-menu gnus-summary-mode-map ""
2173 ["Toggle threading" gnus-summary-toggle-threads t]
2174 ["Hide threads" gnus-summary-hide-all-threads t]
2175 ["Show threads" gnus-summary-show-all-threads t]
2176 ["Hide thread" gnus-summary-hide-thread t]
2177 ["Show thread" gnus-summary-show-thread t]
2178 ["Go to next thread" gnus-summary-next-thread t]
2179 ["Go to previous thread" gnus-summary-prev-thread t]
2180 ["Go down thread" gnus-summary-down-thread t]
2181 ["Go up thread" gnus-summary-up-thread t]
2182 ["Top of thread" gnus-summary-top-thread t]
2183 ["Mark thread as read" gnus-summary-kill-thread t]
2184 ["Lower thread score" gnus-summary-lower-thread t]
2185 ["Raise thread score" gnus-summary-raise-thread t]
2186 ["Rethread current" gnus-summary-rethread-current t]))
2189 gnus-summary-post-menu gnus-summary-mode-map ""
2191 ["Send a message (mail or news)" gnus-summary-post-news
2192 ,@(if (featurep 'xemacs) '(t)
2193 '(:help "Post an article"))]
2194 ["Followup" gnus-summary-followup
2195 ,@(if (featurep 'xemacs) '(t)
2196 '(:help "Post followup to this article"))]
2197 ["Followup and yank" gnus-summary-followup-with-original
2198 ,@(if (featurep 'xemacs) '(t)
2199 '(:help "Post followup to this article, quoting its contents"))]
2200 ["Supersede article" gnus-summary-supersede-article t]
2201 ["Cancel article" gnus-summary-cancel-article
2202 ,@(if (featurep 'xemacs) '(t)
2203 '(:help "Cancel an article you posted"))]
2204 ["Reply" gnus-summary-reply t]
2205 ["Reply and yank" gnus-summary-reply-with-original t]
2206 ["Wide reply" gnus-summary-wide-reply t]
2207 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2208 ,@(if (featurep 'xemacs) '(t)
2209 '(:help "Mail a reply, quoting this article"))]
2210 ["Very wide reply" gnus-summary-very-wide-reply t]
2211 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2212 ,@(if (featurep 'xemacs) '(t)
2213 '(:help "Mail a very wide reply, quoting this article"))]
2214 ["Mail forward" gnus-summary-mail-forward t]
2215 ["Post forward" gnus-summary-post-forward t]
2216 ["Digest and mail" gnus-uu-digest-mail-forward t]
2217 ["Digest and post" gnus-uu-digest-post-forward t]
2218 ["Resend message" gnus-summary-resend-message t]
2219 ["Resend message edit" gnus-summary-resend-message-edit t]
2220 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2221 ["Send a mail" gnus-summary-mail-other-window t]
2222 ["Create a local message" gnus-summary-news-other-window t]
2223 ["Uuencode and post" gnus-uu-post-news
2224 ,@(if (featurep 'xemacs) '(t)
2225 '(:help "Post a uuencoded article"))]
2226 ["Followup via news" gnus-summary-followup-to-mail t]
2227 ["Followup via news and yank"
2228 gnus-summary-followup-to-mail-with-original t]
2230 ;;["Send" gnus-summary-send-draft t]
2231 ;;["Send bounced" gnus-resend-bounced-mail t])
2235 ((not (keymapp gnus-summary-post-menu))
2236 (setq gnus-article-post-menu gnus-summary-post-menu))
2237 ((not gnus-article-post-menu)
2238 ;; Don't share post menu.
2239 (setq gnus-article-post-menu
2240 (copy-keymap gnus-summary-post-menu))))
2241 (define-key gnus-article-mode-map [menu-bar post]
2242 (cons "Post" gnus-article-post-menu))
2245 gnus-summary-misc-menu gnus-summary-mode-map ""
2248 ["Mark as read" gnus-summary-mark-as-read-forward t]
2249 ["Mark same subject and select"
2250 gnus-summary-kill-same-subject-and-select t]
2251 ["Mark same subject" gnus-summary-kill-same-subject t]
2252 ["Catchup" gnus-summary-catchup
2253 ,@(if (featurep 'xemacs) '(t)
2254 '(:help "Mark unread articles in this group as read"))]
2255 ["Catchup all" gnus-summary-catchup-all t]
2256 ["Catchup to here" gnus-summary-catchup-to-here t]
2257 ["Catchup from here" gnus-summary-catchup-from-here t]
2258 ["Catchup region" gnus-summary-mark-region-as-read t]
2259 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2261 ["Tick" gnus-summary-tick-article-forward t]
2262 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2263 ["Remove marks" gnus-summary-clear-mark-forward t]
2264 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2265 ["Set bookmark" gnus-summary-set-bookmark t]
2266 ["Remove bookmark" gnus-summary-remove-bookmark t])
2268 ["Marks..." gnus-summary-limit-to-marks t]
2269 ["Subject..." gnus-summary-limit-to-subject t]
2270 ["Author..." gnus-summary-limit-to-author t]
2271 ["Age..." gnus-summary-limit-to-age t]
2272 ["Extra..." gnus-summary-limit-to-extra t]
2273 ["Score..." gnus-summary-limit-to-score t]
2274 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2275 ["Unread" gnus-summary-limit-to-unread t]
2276 ["Unseen" gnus-summary-limit-to-unseen t]
2277 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2278 ["Articles" gnus-summary-limit-to-articles t]
2279 ["Pop limit" gnus-summary-pop-limit t]
2280 ["Show dormant" gnus-summary-limit-include-dormant t]
2281 ["Hide childless dormant"
2282 gnus-summary-limit-exclude-childless-dormant t]
2283 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2284 ["Hide marked" gnus-summary-limit-exclude-marks t]
2285 ["Show expunged" gnus-summary-limit-include-expunged t])
2287 ["Set mark" gnus-summary-mark-as-processable t]
2288 ["Remove mark" gnus-summary-unmark-as-processable t]
2289 ["Remove all marks" gnus-summary-unmark-all-processable t]
2290 ["Mark above" gnus-uu-mark-over t]
2291 ["Mark series" gnus-uu-mark-series t]
2292 ["Mark region" gnus-uu-mark-region t]
2293 ["Unmark region" gnus-uu-unmark-region t]
2294 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2295 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2296 ["Mark all" gnus-uu-mark-all t]
2297 ["Mark buffer" gnus-uu-mark-buffer t]
2298 ["Mark sparse" gnus-uu-mark-sparse t]
2299 ["Mark thread" gnus-uu-mark-thread t]
2300 ["Unmark thread" gnus-uu-unmark-thread t]
2301 ("Process Mark Sets"
2302 ["Kill" gnus-summary-kill-process-mark t]
2303 ["Yank" gnus-summary-yank-process-mark
2304 gnus-newsgroup-process-stack]
2305 ["Save" gnus-summary-save-process-mark t]))
2307 ["Page forward" gnus-summary-next-page
2308 ,@(if (featurep 'xemacs) '(t)
2309 '(:help "Show next page of article"))]
2310 ["Page backward" gnus-summary-prev-page
2311 ,@(if (featurep 'xemacs) '(t)
2312 '(:help "Show previous page of article"))]
2313 ["Line forward" gnus-summary-scroll-up t])
2315 ["Next unread article" gnus-summary-next-unread-article t]
2316 ["Previous unread article" gnus-summary-prev-unread-article t]
2317 ["Next article" gnus-summary-next-article t]
2318 ["Previous article" gnus-summary-prev-article t]
2319 ["Next unread subject" gnus-summary-next-unread-subject t]
2320 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2321 ["Next article same subject" gnus-summary-next-same-subject t]
2322 ["Previous article same subject" gnus-summary-prev-same-subject t]
2323 ["First unread article" gnus-summary-first-unread-article t]
2324 ["Best unread article" gnus-summary-best-unread-article t]
2325 ["Go to subject number..." gnus-summary-goto-subject t]
2326 ["Go to article number..." gnus-summary-goto-article t]
2327 ["Go to the last article" gnus-summary-goto-last-article t]
2328 ["Pop article off history" gnus-summary-pop-article t])
2330 ["Sort by number" gnus-summary-sort-by-number t]
2331 ["Sort by author" gnus-summary-sort-by-author t]
2332 ["Sort by subject" gnus-summary-sort-by-subject t]
2333 ["Sort by date" gnus-summary-sort-by-date t]
2334 ["Sort by score" gnus-summary-sort-by-score t]
2335 ["Sort by lines" gnus-summary-sort-by-lines t]
2336 ["Sort by characters" gnus-summary-sort-by-chars t]
2337 ["Randomize" gnus-summary-sort-by-random t]
2338 ["Original sort" gnus-summary-sort-by-original t])
2340 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2341 ["Describe group" gnus-summary-describe-group t]
2342 ["Fetch charter" gnus-group-fetch-charter
2343 ,@(if (featurep 'xemacs) nil
2344 '(:help "Display the charter of the current group"))]
2345 ["Fetch control message" gnus-group-fetch-control
2346 ,@(if (featurep 'xemacs) nil
2347 '(:help "Display the archived control message for the current group"))]
2348 ["Read manual" gnus-info-find-node t])
2350 ["Pick and read" gnus-pick-mode t]
2351 ["Binary" gnus-binary-mode t])
2353 ["Regenerate" gnus-summary-prepare t]
2354 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2355 ["Toggle threading" gnus-summary-toggle-threads t])
2356 ["See old articles" gnus-summary-insert-old-articles t]
2357 ["See new articles" gnus-summary-insert-new-articles t]
2358 ["Filter articles..." gnus-summary-execute-command t]
2359 ["Run command on subjects..." gnus-summary-universal-argument t]
2360 ["Search articles forward..." gnus-summary-search-article-forward t]
2361 ["Search articles backward..." gnus-summary-search-article-backward t]
2362 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2363 ["Expand window" gnus-summary-expand-window t]
2364 ["Expire expirable articles" gnus-summary-expire-articles
2365 (gnus-check-backend-function
2366 'request-expire-articles gnus-newsgroup-name)]
2367 ["Edit local kill file" gnus-summary-edit-local-kill t]
2368 ["Edit main kill file" gnus-summary-edit-global-kill t]
2369 ["Edit group parameters" gnus-summary-edit-parameters t]
2370 ["Customize group parameters" gnus-summary-customize-parameters t]
2371 ["Send a bug report" gnus-bug t]
2373 ["Catchup and exit" gnus-summary-catchup-and-exit
2374 ,@(if (featurep 'xemacs) '(t)
2375 '(:help "Mark unread articles in this group as read, then exit"))]
2376 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2377 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2378 ["Exit group" gnus-summary-exit
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "Exit current group, return to group selection mode"))]
2381 ["Exit group without updating" gnus-summary-exit-no-update t]
2382 ["Exit and goto next group" gnus-summary-next-group t]
2383 ["Exit and goto prev group" gnus-summary-prev-group t]
2384 ["Reselect group" gnus-summary-reselect-current-group t]
2385 ["Rescan group" gnus-summary-rescan-group t]
2386 ["Update dribble" gnus-summary-save-newsrc t])))
2388 (gnus-run-hooks 'gnus-summary-menu-hook)))
2390 (defvar gnus-summary-tool-bar-map nil)
2392 ;; Emacs 21 tool bar. Should be no-op otherwise.
2393 (defun gnus-summary-make-tool-bar ()
2394 (if (and (fboundp 'tool-bar-add-item-from-menu)
2395 (default-value 'tool-bar-mode)
2396 (not gnus-summary-tool-bar-map))
2397 (setq gnus-summary-tool-bar-map
2398 (let ((tool-bar-map (make-sparse-keymap))
2399 (load-path (mm-image-load-path)))
2400 (tool-bar-add-item-from-menu
2401 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2402 (tool-bar-add-item-from-menu
2403 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2404 (tool-bar-add-item-from-menu
2405 'gnus-summary-post-news "post" gnus-summary-mode-map)
2406 (tool-bar-add-item-from-menu
2407 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2408 (tool-bar-add-item-from-menu
2409 'gnus-summary-followup "followup" gnus-summary-mode-map)
2410 (tool-bar-add-item-from-menu
2411 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2412 (tool-bar-add-item-from-menu
2413 'gnus-summary-reply "reply" gnus-summary-mode-map)
2414 (tool-bar-add-item-from-menu
2415 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2416 (tool-bar-add-item-from-menu
2417 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2418 (tool-bar-add-item-from-menu
2419 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2420 (tool-bar-add-item-from-menu
2421 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2422 (tool-bar-add-item-from-menu
2423 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2424 (tool-bar-add-item-from-menu
2425 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2426 (tool-bar-add-item-from-menu
2427 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2428 (tool-bar-add-item-from-menu
2429 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2431 (if gnus-summary-tool-bar-map
2432 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2434 (defun gnus-score-set-default (var value)
2435 "A version of set that updates the GNU Emacs menu-bar."
2437 ;; It is the message that forces the active status to be updated.
2440 (defun gnus-make-score-map (type)
2441 "Make a summary score map of type TYPE."
2444 (let ((headers '(("author" "from" string)
2445 ("subject" "subject" string)
2446 ("article body" "body" string)
2447 ("article head" "head" string)
2448 ("xref" "xref" string)
2449 ("extra header" "extra" string)
2450 ("lines" "lines" number)
2451 ("followups to author" "followup" string)))
2452 (types '((number ("less than" <)
2455 (string ("substring" s)
2459 (perms '(("temporary" (current-time-string))
2467 (if (eq type 'lower)
2472 (setq header (car headers))
2478 (let ((ts (cdr (assoc (nth 2 header) types)))
2494 'gnus-summary-score-entry
2496 (if (or (string= (nth 1 header)
2498 (string= (nth 1 header)
2501 (list 'gnus-summary-header
2503 (list 'quote (nth 1 (car ts)))
2504 (list 'gnus-score-delta-default
2511 (list (nreverse outp))))
2514 (list (nreverse outt))))
2516 (setq headers (cdr headers)))
2517 (list (nreverse outh))))))))
2521 (defun gnus-summary-mode (&optional group)
2522 "Major mode for reading articles.
2524 All normal editing commands are switched off.
2525 \\<gnus-summary-mode-map>
2526 Each line in this buffer represents one article. To read an
2527 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2528 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2531 You can also post articles and send mail from this buffer. To
2532 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2533 of an article, type `\\[gnus-summary-reply]'.
2535 There are approx. one gazillion commands you can execute in this
2536 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2538 The following commands are available:
2540 \\{gnus-summary-mode-map}"
2542 (kill-all-local-variables)
2543 (when (gnus-visual-p 'summary-menu 'menu)
2544 (gnus-summary-make-menu-bar)
2545 (gnus-summary-make-tool-bar))
2546 (gnus-summary-make-local-variables)
2547 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2548 (gnus-summary-make-local-variables))
2549 (gnus-make-thread-indent-array)
2550 (gnus-simplify-mode-line)
2551 (setq major-mode 'gnus-summary-mode)
2552 (setq mode-name "Summary")
2553 (make-local-variable 'minor-mode-alist)
2554 (use-local-map gnus-summary-mode-map)
2555 (buffer-disable-undo)
2556 (setq buffer-read-only t) ;Disable modification
2557 (setq truncate-lines t)
2558 (setq selective-display t)
2559 (setq selective-display-ellipses t) ;Display `...'
2560 (gnus-summary-set-display-table)
2561 (gnus-set-default-directory)
2562 (setq gnus-newsgroup-name group)
2563 (make-local-variable 'gnus-summary-line-format)
2564 (make-local-variable 'gnus-summary-line-format-spec)
2565 (make-local-variable 'gnus-summary-dummy-line-format)
2566 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2567 (make-local-variable 'gnus-summary-mark-positions)
2568 (make-local-hook 'pre-command-hook)
2569 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2570 (gnus-run-hooks 'gnus-summary-mode-hook)
2571 (turn-on-gnus-mailing-list-mode)
2572 (mm-enable-multibyte)
2573 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2574 (gnus-update-summary-mark-positions))
2576 (defun gnus-summary-make-local-variables ()
2577 "Make all the local summary buffer variables."
2579 (dolist (local gnus-summary-local-variables)
2582 (if (eq (cdr local) 'global)
2583 ;; Copy the global value of the variable.
2584 (setq global (symbol-value (car local)))
2585 ;; Use the value from the list.
2586 (setq global (eval (cdr local))))
2587 (set (make-local-variable (car local)) global))
2588 ;; Simple nil-valued local variable.
2589 (set (make-local-variable local) nil)))))
2591 (defun gnus-summary-clear-local-variables ()
2592 (let ((locals gnus-summary-local-variables))
2594 (if (consp (car locals))
2595 (and (vectorp (caar locals))
2596 (set (caar locals) nil))
2597 (and (vectorp (car locals))
2598 (set (car locals) nil)))
2599 (setq locals (cdr locals)))))
2601 ;; Summary data functions.
2603 (defmacro gnus-data-number (data)
2606 (defmacro gnus-data-set-number (data number)
2607 `(setcar ,data ,number))
2609 (defmacro gnus-data-mark (data)
2612 (defmacro gnus-data-set-mark (data mark)
2613 `(setcar (nthcdr 1 ,data) ,mark))
2615 (defmacro gnus-data-pos (data)
2618 (defmacro gnus-data-set-pos (data pos)
2619 `(setcar (nthcdr 2 ,data) ,pos))
2621 (defmacro gnus-data-header (data)
2624 (defmacro gnus-data-set-header (data header)
2625 `(setf (nth 3 ,data) ,header))
2627 (defmacro gnus-data-level (data)
2630 (defmacro gnus-data-unread-p (data)
2631 `(= (nth 1 ,data) gnus-unread-mark))
2633 (defmacro gnus-data-read-p (data)
2634 `(/= (nth 1 ,data) gnus-unread-mark))
2636 (defmacro gnus-data-pseudo-p (data)
2637 `(consp (nth 3 ,data)))
2639 (defmacro gnus-data-find (number)
2640 `(assq ,number gnus-newsgroup-data))
2642 (defmacro gnus-data-find-list (number &optional data)
2643 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2644 (memq (assq ,number bdata)
2647 (defmacro gnus-data-make (number mark pos header level)
2648 `(list ,number ,mark ,pos ,header ,level))
2650 (defun gnus-data-enter (after-article number mark pos header level offset)
2651 (let ((data (gnus-data-find-list after-article)))
2653 (error "No such article: %d" after-article))
2654 (setcdr data (cons (gnus-data-make number mark pos header level)
2656 (setq gnus-newsgroup-data-reverse nil)
2657 (gnus-data-update-list (cddr data) offset)))
2659 (defun gnus-data-enter-list (after-article list &optional offset)
2661 (let ((data (and after-article (gnus-data-find-list after-article)))
2665 (let ((odata gnus-newsgroup-data))
2666 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2668 (gnus-data-update-list odata offset)))
2669 ;; Find the last element in the list to be spliced into the main
2672 (setq list (cdr list)))
2675 (setcdr list gnus-newsgroup-data)
2676 (setq gnus-newsgroup-data ilist)
2678 (gnus-data-update-list (cdr list) offset)))
2679 (setcdr list (cdr data))
2682 (gnus-data-update-list (cdr list) offset))))
2683 (setq gnus-newsgroup-data-reverse nil))))
2685 (defun gnus-data-remove (article &optional offset)
2686 (let ((data gnus-newsgroup-data))
2687 (if (= (gnus-data-number (car data)) article)
2689 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2690 gnus-newsgroup-data-reverse nil)
2692 (gnus-data-update-list gnus-newsgroup-data offset)))
2694 (when (= (gnus-data-number (cadr data)) article)
2695 (setcdr data (cddr data))
2697 (gnus-data-update-list (cdr data) offset))
2699 gnus-newsgroup-data-reverse nil))
2700 (setq data (cdr data))))))
2702 (defmacro gnus-data-list (backward)
2704 (or gnus-newsgroup-data-reverse
2705 (setq gnus-newsgroup-data-reverse
2706 (reverse gnus-newsgroup-data)))
2707 gnus-newsgroup-data))
2709 (defun gnus-data-update-list (data offset)
2710 "Add OFFSET to the POS of all data entries in DATA."
2711 (setq gnus-newsgroup-data-reverse nil)
2713 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2714 (setq data (cdr data))))
2716 (defun gnus-summary-article-pseudo-p (article)
2717 "Say whether this article is a pseudo article or not."
2718 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2720 (defmacro gnus-summary-article-sparse-p (article)
2721 "Say whether this article is a sparse article or not."
2722 `(memq ,article gnus-newsgroup-sparse))
2724 (defmacro gnus-summary-article-ancient-p (article)
2725 "Say whether this article is a sparse article or not."
2726 `(memq ,article gnus-newsgroup-ancient))
2728 (defun gnus-article-parent-p (number)
2729 "Say whether this article is a parent or not."
2730 (let ((data (gnus-data-find-list number)))
2731 (and (cdr data) ; There has to be an article after...
2732 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2733 (gnus-data-level (nth 1 data))))))
2735 (defun gnus-article-children (number)
2736 "Return a list of all children to NUMBER."
2737 (let* ((data (gnus-data-find-list number))
2738 (level (gnus-data-level (car data)))
2740 (setq data (cdr data))
2742 (= (gnus-data-level (car data)) (1+ level)))
2743 (push (gnus-data-number (car data)) children)
2744 (setq data (cdr data)))
2747 (defmacro gnus-summary-skip-intangible ()
2748 "If the current article is intangible, then jump to a different article."
2749 '(let ((to (get-text-property (point) 'gnus-intangible)))
2750 (and to (gnus-summary-goto-subject to))))
2752 (defmacro gnus-summary-article-intangible-p ()
2753 "Say whether this article is intangible or not."
2754 '(get-text-property (point) 'gnus-intangible))
2756 (defun gnus-article-read-p (article)
2757 "Say whether ARTICLE is read or not."
2758 (not (or (memq article gnus-newsgroup-marked)
2759 (memq article gnus-newsgroup-spam-marked)
2760 (memq article gnus-newsgroup-unreads)
2761 (memq article gnus-newsgroup-unselected)
2762 (memq article gnus-newsgroup-dormant))))
2764 ;; Some summary mode macros.
2766 (defmacro gnus-summary-article-number ()
2767 "The article number of the article on the current line.
2768 If there isn't an article number here, then we return the current
2771 (gnus-summary-skip-intangible)
2772 (or (get-text-property (point) 'gnus-number)
2773 (gnus-summary-last-subject))))
2775 (defmacro gnus-summary-article-header (&optional number)
2776 "Return the header of article NUMBER."
2777 `(gnus-data-header (gnus-data-find
2778 ,(or number '(gnus-summary-article-number)))))
2780 (defmacro gnus-summary-thread-level (&optional number)
2781 "Return the level of thread that starts with article NUMBER."
2782 `(if (and (eq gnus-summary-make-false-root 'dummy)
2783 (get-text-property (point) 'gnus-intangible))
2785 (gnus-data-level (gnus-data-find
2786 ,(or number '(gnus-summary-article-number))))))
2788 (defmacro gnus-summary-article-mark (&optional number)
2789 "Return the mark of article NUMBER."
2790 `(gnus-data-mark (gnus-data-find
2791 ,(or number '(gnus-summary-article-number)))))
2793 (defmacro gnus-summary-article-pos (&optional number)
2794 "Return the position of the line of article NUMBER."
2795 `(gnus-data-pos (gnus-data-find
2796 ,(or number '(gnus-summary-article-number)))))
2798 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2799 (defmacro gnus-summary-article-subject (&optional number)
2800 "Return current subject string or nil if nothing."
2803 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2804 '(gnus-data-header (assq (gnus-summary-article-number)
2805 gnus-newsgroup-data)))))
2808 (mail-header-subject headers))))
2810 (defmacro gnus-summary-article-score (&optional number)
2811 "Return current article score."
2812 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2813 gnus-newsgroup-scored))
2814 gnus-summary-default-score 0))
2816 (defun gnus-summary-article-children (&optional number)
2817 "Return a list of article numbers that are children of article NUMBER."
2818 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2819 (level (gnus-data-level (car data)))
2821 (while (and (setq data (cdr data))
2822 (> (setq l (gnus-data-level (car data))) level))
2823 (and (= (1+ level) l)
2824 (push (gnus-data-number (car data))
2826 (nreverse children)))
2828 (defun gnus-summary-article-parent (&optional number)
2829 "Return the article number of the parent of article NUMBER."
2830 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2831 (gnus-data-list t)))
2832 (level (gnus-data-level (car data))))
2834 () ; This is a root.
2835 ;; We search until we find an article with a level less than
2836 ;; this one. That function has to be the parent.
2837 (while (and (setq data (cdr data))
2838 (not (< (gnus-data-level (car data)) level))))
2839 (and data (gnus-data-number (car data))))))
2841 (defun gnus-unread-mark-p (mark)
2842 "Say whether MARK is the unread mark."
2843 (= mark gnus-unread-mark))
2845 (defun gnus-read-mark-p (mark)
2846 "Say whether MARK is one of the marks that mark as read.
2847 This is all marks except unread, ticked, dormant, and expirable."
2848 (not (or (= mark gnus-unread-mark)
2849 (= mark gnus-ticked-mark)
2850 (= mark gnus-dormant-mark)
2851 (= mark gnus-expirable-mark))))
2853 (defmacro gnus-article-mark (number)
2854 "Return the MARK of article NUMBER.
2855 This macro should only be used when computing the mark the \"first\"
2856 time; i.e., when generating the summary lines. After that,
2857 `gnus-summary-article-mark' should be used to examine the
2860 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2861 ;;;; ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2862 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2863 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2864 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2865 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2866 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2867 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2868 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2869 gnus-ancient-mark))))
2871 ;; Saving hidden threads.
2873 (defmacro gnus-save-hidden-threads (&rest forms)
2874 "Save hidden threads, eval FORMS, and restore the hidden threads."
2875 (let ((config (make-symbol "config")))
2876 `(let ((,config (gnus-hidden-threads-configuration)))
2880 (gnus-restore-hidden-threads-configuration ,config)))))
2881 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2882 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2884 (defun gnus-data-compute-positions ()
2885 "Compute the positions of all articles."
2886 (setq gnus-newsgroup-data-reverse nil)
2887 (let ((data gnus-newsgroup-data))
2889 (gnus-save-hidden-threads
2890 (gnus-summary-show-all-threads)
2891 (goto-char (point-min))
2893 (while (get-text-property (point) 'gnus-intangible)
2895 (gnus-data-set-pos (car data) (+ (point) 3))
2896 (setq data (cdr data))
2897 (forward-line 1))))))
2899 (defun gnus-hidden-threads-configuration ()
2900 "Return the current hidden threads configuration."
2903 (goto-char (point-min))
2904 (while (search-forward "\r" nil t)
2905 (push (1- (point)) config))
2908 (defun gnus-restore-hidden-threads-configuration (config)
2909 "Restore hidden threads configuration from CONFIG."
2911 (let (point buffer-read-only)
2912 (while (setq point (pop config))
2913 (when (and (< point (point-max))
2915 (eq (char-after) ?\n))
2916 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2918 ;; Various summary mode internalish functions.
2920 (defun gnus-mouse-pick-article (e)
2923 (gnus-summary-next-page nil t))
2925 (defun gnus-summary-set-display-table ()
2926 "Change the display table.
2927 Odd characters have a tendency to mess
2928 up nicely formatted displays - we make all possible glyphs
2929 display only a single character."
2931 ;; We start from the standard display table, if any.
2932 (let ((table (or (copy-sequence standard-display-table)
2933 (make-display-table)))
2935 ;; Nix out all the control chars...
2936 (while (>= (setq i (1- i)) 0)
2937 (aset table i [??]))
2938 ;; ... but not newline and cr, of course. (cr is necessary for the
2939 ;; selective display).
2940 (aset table ?\n nil)
2941 (aset table ?\r nil)
2942 ;; We keep TAB as well.
2943 (aset table ?\t nil)
2944 ;; We nix out any glyphs over 126 that are not set already.
2946 (while (>= (setq i (1- i)) 127)
2947 ;; Only modify if the entry is nil.
2948 (unless (aref table i)
2949 (aset table i [??]))))
2950 (setq buffer-display-table table)))
2952 (defun gnus-summary-set-article-display-arrow (pos)
2953 "Update the overlay arrow to point to line at position POS."
2954 (when (and gnus-summary-display-arrow
2955 (boundp 'overlay-arrow-position)
2956 (boundp 'overlay-arrow-string))
2960 (unless overlay-arrow-position
2961 (setq overlay-arrow-position (make-marker)))
2962 (setq overlay-arrow-string "=>"
2963 overlay-arrow-position (set-marker overlay-arrow-position
2965 (current-buffer))))))
2967 (defun gnus-summary-buffer-name (group)
2968 "Return the summary buffer name of GROUP."
2969 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2971 (defun gnus-summary-setup-buffer (group)
2972 "Initialize summary buffer."
2973 (let ((buffer (gnus-summary-buffer-name group))
2974 (dead-name (concat "*Dead Summary "
2975 (gnus-group-decoded-name group) "*")))
2976 ;; If a dead summary buffer exists, we kill it.
2977 (when (gnus-buffer-live-p dead-name)
2978 (gnus-kill-buffer dead-name))
2979 (if (get-buffer buffer)
2982 (setq gnus-summary-buffer (current-buffer))
2983 (not gnus-newsgroup-prepared))
2984 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2985 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2986 (gnus-summary-mode group)
2988 (gnus-carpal-setup-buffer 'summary))
2989 (unless gnus-single-article-buffer
2990 (make-local-variable 'gnus-article-buffer)
2991 (make-local-variable 'gnus-article-current)
2992 (make-local-variable 'gnus-original-article-buffer))
2993 (setq gnus-newsgroup-name group)
2994 ;; Set any local variables in the group parameters.
2995 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2998 (defun gnus-set-global-variables ()
2999 "Set the global equivalents of the buffer-local variables.
3000 They are set to the latest values they had. These reflect the summary
3001 buffer that was in action when the last article was fetched."
3002 (when (eq major-mode 'gnus-summary-mode)
3003 (setq gnus-summary-buffer (current-buffer))
3004 (let ((name gnus-newsgroup-name)
3005 (marked gnus-newsgroup-marked)
3006 (spam gnus-newsgroup-spam-marked)
3007 (unread gnus-newsgroup-unreads)
3008 (headers gnus-current-headers)
3009 (data gnus-newsgroup-data)
3010 (summary gnus-summary-buffer)
3011 (article-buffer gnus-article-buffer)
3012 (original gnus-original-article-buffer)
3013 (gac gnus-article-current)
3014 (reffed gnus-reffed-article-number)
3015 (score-file gnus-current-score-file)
3016 (default-charset gnus-newsgroup-charset)
3018 (let ((locals gnus-newsgroup-variables))
3020 (if (consp (car locals))
3021 (push (eval (caar locals)) vlist)
3022 (push (eval (car locals)) vlist))
3023 (setq locals (cdr locals)))
3024 (setq vlist (nreverse vlist)))
3026 (set-buffer gnus-group-buffer)
3027 (setq gnus-newsgroup-name name
3028 gnus-newsgroup-marked marked
3029 gnus-newsgroup-spam-marked spam
3030 gnus-newsgroup-unreads unread
3031 gnus-current-headers headers
3032 gnus-newsgroup-data data
3033 gnus-article-current gac
3034 gnus-summary-buffer summary
3035 gnus-article-buffer article-buffer
3036 gnus-original-article-buffer original
3037 gnus-reffed-article-number reffed
3038 gnus-current-score-file score-file
3039 gnus-newsgroup-charset default-charset)
3040 (let ((locals gnus-newsgroup-variables))
3042 (if (consp (car locals))
3043 (set (caar locals) (pop vlist))
3044 (set (car locals) (pop vlist)))
3045 (setq locals (cdr locals))))
3046 ;; The article buffer also has local variables.
3047 (when (gnus-buffer-live-p gnus-article-buffer)
3048 (set-buffer gnus-article-buffer)
3049 (setq gnus-summary-buffer summary))))))
3051 (defun gnus-summary-article-unread-p (article)
3052 "Say whether ARTICLE is unread or not."
3053 (memq article gnus-newsgroup-unreads))
3055 (defun gnus-summary-first-article-p (&optional article)
3056 "Return whether ARTICLE is the first article in the buffer."
3057 (if (not (setq article (or article (gnus-summary-article-number))))
3059 (eq article (caar gnus-newsgroup-data))))
3061 (defun gnus-summary-last-article-p (&optional article)
3062 "Return whether ARTICLE is the last article in the buffer."
3063 (if (not (setq article (or article (gnus-summary-article-number))))
3064 ;; All non-existent numbers are the last article. :-)
3066 (not (cdr (gnus-data-find-list article)))))
3068 (defun gnus-make-thread-indent-array ()
3070 (unless (and gnus-thread-indent-array
3071 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3072 (setq gnus-thread-indent-array (make-vector 201 "")
3073 gnus-thread-indent-array-level gnus-thread-indent-level)
3075 (aset gnus-thread-indent-array n
3076 (make-string (* n gnus-thread-indent-level) ? ))
3079 (defun gnus-update-summary-mark-positions ()
3080 "Compute where the summary marks are to go."
3082 (when (gnus-buffer-exists-p gnus-summary-buffer)
3083 (set-buffer gnus-summary-buffer))
3084 (let ((gnus-replied-mark 129)
3085 (gnus-score-below-mark 130)
3086 (gnus-score-over-mark 130)
3087 (gnus-download-mark 131)
3088 (spec gnus-summary-line-format-spec)
3091 (gnus-set-work-buffer)
3092 (let ((gnus-summary-line-format-spec spec)
3093 (gnus-newsgroup-downloadable '((0 . t))))
3094 (gnus-summary-insert-line
3095 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3096 0 nil 128 t nil "" nil 1)
3097 (goto-char (point-min))
3098 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3099 (- (point) (point-min) 1)))))
3100 (goto-char (point-min))
3101 (push (cons 'replied (and (search-forward "\201" nil t)
3102 (- (point) (point-min) 1)))
3104 (goto-char (point-min))
3105 (push (cons 'score (and (search-forward "\202" nil t)
3106 (- (point) (point-min) 1)))
3108 (goto-char (point-min))
3109 (push (cons 'download
3110 (and (search-forward "\203" nil t)
3111 (- (point) (point-min) 1)))
3113 (setq gnus-summary-mark-positions pos))))
3115 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3116 "Insert a dummy root in the summary buffer."
3118 (gnus-add-text-properties
3119 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3120 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3122 (defun gnus-summary-extract-address-component (from)
3123 (or (car (funcall gnus-extract-address-components from))
3126 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3127 (let ((mail-parse-charset gnus-newsgroup-charset)
3128 ; Is it really necessary to do this next part for each summary line?
3129 ; Luckily, doesn't seem to slow things down much.
3130 (mail-parse-ignored-charsets
3131 (save-excursion (set-buffer gnus-summary-buffer)
3132 gnus-newsgroup-ignored-charsets)))
3134 (and gnus-ignored-from-addresses
3135 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3136 (let ((extra-headers (mail-header-extra header))
3140 ((setq to (cdr (assq 'To extra-headers)))
3143 (gnus-summary-extract-address-component
3144 (funcall gnus-decode-encoded-word-function to)))))
3145 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3146 (concat "=> " newsgroups)))))
3147 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3149 (defun gnus-summary-insert-line (gnus-tmp-header
3150 gnus-tmp-level gnus-tmp-current
3151 gnus-tmp-unread gnus-tmp-replied
3152 gnus-tmp-expirable gnus-tmp-subject-or-nil
3153 &optional gnus-tmp-dummy gnus-tmp-score
3155 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3156 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3157 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3158 (gnus-tmp-score-char
3159 (if (or (null gnus-summary-default-score)
3160 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3161 gnus-summary-zcore-fuzz))
3163 (if (< gnus-tmp-score gnus-summary-default-score)
3164 gnus-score-below-mark gnus-score-over-mark)))
3165 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3167 (cond (gnus-tmp-process gnus-process-mark)
3168 ((memq gnus-tmp-current gnus-newsgroup-cached)
3170 (gnus-tmp-replied gnus-replied-mark)
3171 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3172 gnus-forwarded-mark)
3173 ((memq gnus-tmp-current gnus-newsgroup-saved)
3175 ((memq gnus-tmp-number gnus-newsgroup-recent)
3177 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3180 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3183 ((string-match "<[^>]+> *$" gnus-tmp-from)
3184 (let ((beg (match-beginning 0)))
3185 (or (and (string-match "^\".+\"" gnus-tmp-from)
3186 (substring gnus-tmp-from 1 (1- (match-end 0))))
3187 (substring gnus-tmp-from 0 beg))))
3188 ((string-match "(.+)" gnus-tmp-from)
3189 (substring gnus-tmp-from
3190 (1+ (match-beginning 0)) (1- (match-end 0))))
3192 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3193 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3194 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3195 (buffer-read-only nil))
3196 (when (string= gnus-tmp-name "")
3197 (setq gnus-tmp-name gnus-tmp-from))
3198 (unless (numberp gnus-tmp-lines)
3199 (setq gnus-tmp-lines -1))
3200 (if (= gnus-tmp-lines -1)
3201 (setq gnus-tmp-lines "?")
3202 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3203 (gnus-put-text-property
3205 (progn (eval gnus-summary-line-format-spec) (point))
3206 'gnus-number gnus-tmp-number)
3207 (when (gnus-visual-p 'summary-highlight 'highlight)
3209 (gnus-run-hooks 'gnus-summary-update-hook)
3212 (defun gnus-summary-update-line (&optional dont-update)
3213 "Update summary line after change."
3214 (when (and gnus-summary-default-score
3215 (not gnus-summary-inhibit-highlight))
3216 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3217 (article (gnus-summary-article-number))
3218 (score (gnus-summary-article-score article)))
3220 (if (and gnus-summary-mark-below
3221 (< (gnus-summary-article-score)
3222 gnus-summary-mark-below))
3223 ;; This article has a low score, so we mark it as read.
3224 (when (memq article gnus-newsgroup-unreads)
3225 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3226 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3227 ;; This article was previously marked as read on account
3228 ;; of a low score, but now it has risen, so we mark it as
3230 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3231 (gnus-summary-update-mark
3232 (if (or (null gnus-summary-default-score)
3233 (<= (abs (- score gnus-summary-default-score))
3234 gnus-summary-zcore-fuzz))
3236 (if (< score gnus-summary-default-score)
3237 gnus-score-below-mark gnus-score-over-mark))
3239 ;; Do visual highlighting.
3240 (when (gnus-visual-p 'summary-highlight 'highlight)
3241 (gnus-run-hooks 'gnus-summary-update-hook)))))
3243 (defvar gnus-tmp-new-adopts nil)
3245 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3246 "Return the number of articles in THREAD.
3247 This may be 0 in some cases -- if none of the articles in
3248 the thread are to be displayed."
3250 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3252 ((not (listp thread))
3254 ((and (consp thread) (cdr thread))
3257 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3260 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3263 (when (and level (zerop level) gnus-tmp-new-adopts)
3266 'gnus-summary-number-of-articles-in-thread
3267 gnus-tmp-new-adopts))))
3269 (if (> number 1) gnus-not-empty-thread-mark
3270 gnus-empty-thread-mark)
3273 (defsubst gnus-summary-line-message-size (head)
3274 "Return pretty-printed version of message size.
3275 This function is intended to be used in
3276 `gnus-summary-line-format-alist', which see."
3277 (let ((c (or (mail-header-chars head) -1)))
3278 (cond ((< c 0) "n/a") ; chars not available
3279 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3280 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3281 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3282 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3285 (defun gnus-summary-set-local-parameters (group)
3286 "Go through the local params of GROUP and set all variable specs in that list."
3287 (let ((params (gnus-group-find-parameter group))
3288 (vars '(quit-config)) ; Ignore quit-config.
3291 (setq elem (car params)
3292 params (cdr params))
3293 (and (consp elem) ; Has to be a cons.
3294 (consp (cdr elem)) ; The cdr has to be a list.
3295 (symbolp (car elem)) ; Has to be a symbol in there.
3296 (not (memq (car elem) vars))
3297 (ignore-errors ; So we set it.
3298 (push (car elem) vars)
3299 (make-local-variable (car elem))
3300 (set (car elem) (eval (nth 1 elem))))))))
3302 (defun gnus-summary-read-group (group &optional show-all no-article
3303 kill-buffer no-display backward
3305 "Start reading news in newsgroup GROUP.
3306 If SHOW-ALL is non-nil, already read articles are also listed.
3307 If NO-ARTICLE is non-nil, no article is selected initially.
3308 If NO-DISPLAY, don't generate a summary buffer."
3312 (let ((gnus-auto-select-next nil))
3313 (or (gnus-summary-read-group-1
3314 group show-all no-article
3315 kill-buffer no-display
3318 select-articles nil)))))
3319 (eq gnus-auto-select-next 'quietly))
3320 (set-buffer gnus-group-buffer)
3321 ;; The entry function called above goes to the next
3322 ;; group automatically, so we go two groups back
3323 ;; if we are searching for the previous group.
3325 (gnus-group-prev-unread-group 2))
3326 (if (not (equal group (gnus-group-group-name)))
3327 (setq group (gnus-group-group-name))
3331 (defun gnus-summary-read-group-1 (group show-all no-article
3332 kill-buffer no-display
3333 &optional select-articles)
3334 ;; Killed foreign groups can't be entered.
3335 ;; (when (and (not (gnus-group-native-p group))
3336 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3337 ;; (error "Dead non-native groups can't be entered"))
3338 (gnus-message 5 "Retrieving newsgroup: %s..."
3339 (gnus-group-decoded-name group))
3340 (let* ((new-group (gnus-summary-setup-buffer group))
3341 (quit-config (gnus-group-quit-config group))
3342 (did-select (and new-group (gnus-select-newsgroup
3343 group show-all select-articles))))
3345 ;; This summary buffer exists already, so we just select it.
3347 (gnus-set-global-variables)
3349 (gnus-kill-or-deaden-summary kill-buffer))
3350 (gnus-configure-windows 'summary 'force)
3351 (gnus-set-mode-line 'summary)
3352 (gnus-summary-position-point)
3355 ;; We couldn't select this group.
3357 (when (and (eq major-mode 'gnus-summary-mode)
3358 (not (equal (current-buffer) kill-buffer)))
3359 (kill-buffer (current-buffer))
3360 (if (not quit-config)
3362 ;; Update the info -- marks might need to be removed,
3364 (gnus-summary-update-info)
3365 (set-buffer gnus-group-buffer)
3366 (gnus-group-jump-to-group group)
3367 (gnus-group-next-unread-group 1))
3368 (gnus-handle-ephemeral-exit quit-config)))
3369 (let ((grpinfo (gnus-get-info group)))
3370 (if (null (gnus-info-read grpinfo))
3371 (gnus-message 3 "Group %s contains no messages"
3372 (gnus-group-decoded-name group))
3373 (gnus-message 3 "Can't select group")))
3375 ;; The user did a `C-g' while prompting for number of articles,
3376 ;; so we exit this group.
3377 ((eq did-select 'quit)
3378 (and (eq major-mode 'gnus-summary-mode)
3379 (not (equal (current-buffer) kill-buffer))
3380 (kill-buffer (current-buffer)))
3382 (gnus-kill-or-deaden-summary kill-buffer))
3383 (if (not quit-config)
3385 (set-buffer gnus-group-buffer)
3386 (gnus-group-jump-to-group group)
3387 (gnus-group-next-unread-group 1)
3388 (gnus-configure-windows 'group 'force))
3389 (gnus-handle-ephemeral-exit quit-config))
3390 ;; Finally signal the quit.
3392 ;; The group was successfully selected.
3394 (gnus-set-global-variables)
3395 ;; Save the active value in effect when the group was entered.
3396 (setq gnus-newsgroup-active
3398 (gnus-active gnus-newsgroup-name)))
3399 ;; You can change the summary buffer in some way with this hook.
3400 (gnus-run-hooks 'gnus-select-group-hook)
3401 (gnus-update-format-specifications
3402 nil 'summary 'summary-mode 'summary-dummy)
3403 (gnus-update-summary-mark-positions)
3404 ;; Do score processing.
3405 (when gnus-use-scoring
3406 (gnus-possibly-score-headers))
3407 ;; Check whether to fill in the gaps in the threads.
3408 (when gnus-build-sparse-threads
3409 (gnus-build-sparse-threads))
3410 ;; Find the initial limit.
3411 (if gnus-show-threads
3413 (let ((gnus-newsgroup-dormant nil))
3414 (gnus-summary-initial-limit show-all))
3415 (gnus-summary-initial-limit show-all))
3416 ;; When unthreaded, all articles are always shown.
3417 (setq gnus-newsgroup-limit
3419 (lambda (header) (mail-header-number header))
3420 gnus-newsgroup-headers)))
3421 ;; Generate the summary buffer.
3423 (gnus-summary-prepare))
3424 (when gnus-use-trees
3425 (gnus-tree-open group)
3426 (setq gnus-summary-highlight-line-function
3427 'gnus-tree-highlight-article))
3428 ;; If the summary buffer is empty, but there are some low-scored
3429 ;; articles or some excluded dormants, we include these in the
3431 (when (and (zerop (buffer-size))
3433 (cond (gnus-newsgroup-dormant
3434 (gnus-summary-limit-include-dormant))
3435 ((and gnus-newsgroup-scored show-all)
3436 (gnus-summary-limit-include-expunged t))))
3437 ;; Function `gnus-apply-kill-file' must be called in this hook.
3438 (gnus-run-hooks 'gnus-apply-kill-hook)
3439 (if (and (zerop (buffer-size))
3442 ;; This newsgroup is empty.
3443 (gnus-summary-catchup-and-exit nil t)
3444 (gnus-message 6 "No unread news")
3446 (gnus-kill-or-deaden-summary kill-buffer))
3447 ;; Return nil from this function.
3449 ;; Hide conversation thread subtrees. We cannot do this in
3450 ;; gnus-summary-prepare-hook since kill processing may not
3451 ;; work with hidden articles.
3452 (gnus-summary-maybe-hide-threads)
3454 (gnus-kill-or-deaden-summary kill-buffer))
3455 (gnus-summary-auto-select-subject)
3456 ;; Show first unread article if requested.
3457 (if (and (not no-article)
3459 gnus-newsgroup-unreads
3460 gnus-auto-select-first)
3462 (gnus-configure-windows 'summary)
3463 (let ((art (gnus-summary-article-number)))
3464 (unless (or (memq art gnus-newsgroup-undownloaded)
3465 (memq art gnus-newsgroup-downloadable))
3466 (gnus-summary-goto-article art))))
3467 ;; Don't select any articles.
3468 (gnus-summary-position-point)
3469 (gnus-configure-windows 'summary 'force)
3470 (gnus-set-mode-line 'summary))
3471 (when (get-buffer-window gnus-group-buffer t)
3472 ;; Gotta use windows, because recenter does weird stuff if
3473 ;; the current buffer ain't the displayed window.
3474 (let ((owin (selected-window)))
3475 (select-window (get-buffer-window gnus-group-buffer t))
3476 (when (gnus-group-goto-group group)
3478 (select-window owin)))
3479 ;; Mark this buffer as "prepared".
3480 (setq gnus-newsgroup-prepared t)
3481 (gnus-run-hooks 'gnus-summary-prepared-hook)
3484 (defun gnus-summary-auto-select-subject ()
3485 "Select the subject line on initial group entry."
3486 (goto-char (point-min))
3488 ((eq gnus-auto-select-subject 'best)
3489 (gnus-summary-best-unread-subject))
3490 ((eq gnus-auto-select-subject 'unread)
3491 (gnus-summary-first-unread-subject))
3492 ((eq gnus-auto-select-subject 'unseen)
3493 (gnus-summary-first-unseen-subject))
3494 ((eq gnus-auto-select-subject 'unseen-or-unread)
3495 (gnus-summary-first-unseen-or-unread-subject))
3496 ((eq gnus-auto-select-subject 'first)
3499 ((gnus-functionp gnus-auto-select-subject)
3500 (funcall gnus-auto-select-subject))))
3502 (defun gnus-summary-prepare ()
3503 "Generate the summary buffer."
3505 (let ((buffer-read-only nil))
3507 (setq gnus-newsgroup-data nil
3508 gnus-newsgroup-data-reverse nil)
3509 (gnus-run-hooks 'gnus-summary-generate-hook)
3510 ;; Generate the buffer, either with threads or without.
3511 (when gnus-newsgroup-headers
3512 (gnus-summary-prepare-threads
3513 (if gnus-show-threads
3514 (gnus-sort-gathered-threads
3515 (funcall gnus-summary-thread-gathering-function
3517 (gnus-cut-threads (gnus-make-threads)))))
3518 ;; Unthreaded display.
3519 (gnus-sort-articles gnus-newsgroup-headers))))
3520 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3521 ;; Call hooks for modifying summary buffer.
3522 (goto-char (point-min))
3523 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3525 (defsubst gnus-general-simplify-subject (subject)
3526 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3529 ;; Truncate the subject.
3530 (gnus-simplify-subject-functions
3531 (gnus-map-function gnus-simplify-subject-functions subject))
3532 ((numberp gnus-summary-gather-subject-limit)
3533 (setq subject (gnus-simplify-subject-re subject))
3534 (if (> (length subject) gnus-summary-gather-subject-limit)
3535 (substring subject 0 gnus-summary-gather-subject-limit)
3537 ;; Fuzzily simplify it.
3538 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3539 (gnus-simplify-subject-fuzzy subject))
3540 ;; Just remove the leading "Re:".
3542 (gnus-simplify-subject-re subject))))
3544 (if (and gnus-summary-gather-exclude-subject
3545 (string-match gnus-summary-gather-exclude-subject subject))
3546 nil ; This article shouldn't be gathered
3549 (defun gnus-summary-simplify-subject-query ()
3550 "Query where the respool algorithm would put this article."
3552 (gnus-summary-select-article)
3553 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3555 (defun gnus-gather-threads-by-subject (threads)
3556 "Gather threads by looking at Subject headers."
3557 (if (not gnus-summary-make-false-root)
3559 (let ((hashtb (gnus-make-hashtable 1024))
3562 subject hthread whole-subject)
3564 (setq subject (gnus-general-simplify-subject
3565 (setq whole-subject (mail-header-subject
3568 (if (setq hthread (gnus-gethash subject hashtb))
3570 ;; We enter a dummy root into the thread, if we
3571 ;; haven't done that already.
3572 (unless (stringp (caar hthread))
3573 (setcar hthread (list whole-subject (car hthread))))
3574 ;; We add this new gathered thread to this gathered
3576 (setcdr (car hthread)
3577 (nconc (cdar hthread) (list (car threads))))
3578 ;; Remove it from the list of threads.
3579 (setcdr prev (cdr threads))
3580 (setq threads prev))
3581 ;; Enter this thread into the hash table.
3582 (gnus-sethash subject threads hashtb)))
3584 (setq threads (cdr threads)))
3587 (defun gnus-gather-threads-by-references (threads)
3588 "Gather threads by looking at References headers."
3589 (let ((idhashtb (gnus-make-hashtable 1024))
3590 (thhashtb (gnus-make-hashtable 1024))
3593 ids references id gthread gid entered ref)
3595 (when (setq references (mail-header-references (caar threads)))
3596 (setq id (mail-header-id (caar threads))
3597 ids (inline (gnus-split-references references))
3599 (while (setq ref (pop ids))
3600 (setq ids (delete ref ids))
3601 (if (not (setq gid (gnus-gethash ref idhashtb)))
3603 (gnus-sethash ref id idhashtb)
3604 (gnus-sethash id threads thhashtb))
3605 (setq gthread (gnus-gethash gid thhashtb))
3607 ;; We enter a dummy root into the thread, if we
3608 ;; haven't done that already.
3609 (unless (stringp (caar gthread))
3610 (setcar gthread (list (mail-header-subject (caar gthread))
3612 ;; We add this new gathered thread to this gathered
3614 (setcdr (car gthread)
3615 (nconc (cdar gthread) (list (car threads)))))
3616 ;; Add it into the thread hash table.
3617 (gnus-sethash id gthread thhashtb)
3619 ;; Remove it from the list of threads.
3620 (setcdr prev (cdr threads))
3621 (setq threads prev))))
3623 (setq threads (cdr threads)))
3626 (defun gnus-sort-gathered-threads (threads)
3627 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3628 (let ((result threads))
3630 (when (stringp (caar threads))
3631 (setcdr (car threads)
3632 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3633 (setq threads (cdr threads)))
3636 (defun gnus-thread-loop-p (root thread)
3637 "Say whether ROOT is in THREAD."
3638 (let ((stack (list thread))
3641 (while (setq thread (pop stack))
3642 (setq th (cdr thread))
3644 (not (eq (caar th) root)))
3647 ;; We have found a loop.
3649 (setcdr thread (delq (car th) (cdr thread)))
3650 (if (boundp (setq ref-dep (intern "none"
3651 gnus-newsgroup-dependencies)))
3652 (setcdr (symbol-value ref-dep)
3653 (nconc (cdr (symbol-value ref-dep))
3655 (set ref-dep (list nil (car th))))
3658 ;; Push all the subthreads onto the stack.
3659 (push (cdr thread) stack)))
3662 (defun gnus-make-threads ()
3663 "Go through the dependency hashtb and find the roots. Return all threads."
3665 (while (catch 'infloop
3668 ;; Deal with self-referencing References loops.
3669 (when (and (car (symbol-value refs))
3676 (car (symbol-value refs)) thread))
3677 (cdr (symbol-value refs)))))))
3680 (unless (car (symbol-value refs))
3681 ;; These threads do not refer back to any other
3682 ;; articles, so they're roots.
3683 (setq threads (append (cdr (symbol-value refs)) threads))))
3684 gnus-newsgroup-dependencies)))
3687 ;; Build the thread tree.
3688 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3689 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3691 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3692 if it was already present.
3694 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3695 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3696 Message-IDs will be renamed to a unique Message-ID before being
3699 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3700 (let* ((id (mail-header-id header))
3701 (id-dep (and id (intern id dependencies)))
3702 parent-id ref ref-dep ref-header replaced)
3703 ;; Enter this `header' in the `dependencies' table.
3707 ;; The first two cases do the normal part: enter a new `header'
3708 ;; in the `dependencies' table.
3709 ((not (boundp id-dep))
3710 (set id-dep (list header)))
3711 ((null (car (symbol-value id-dep)))
3712 (setcar (symbol-value id-dep) header))
3714 ;; From here the `header' was already present in the
3715 ;; `dependencies' table.
3717 ;; Overrides an existing entry;
3718 ;; just set the header part of the entry.
3719 (setcar (symbol-value id-dep) header)
3722 ;; Renames the existing `header' to a unique Message-ID.
3723 ((not gnus-summary-ignore-duplicates)
3724 ;; An article with this Message-ID has already been seen.
3725 ;; We rename the Message-ID.
3726 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3728 (mail-header-set-id header id))
3730 ;; The last case ignores an existing entry, except it adds any
3731 ;; additional Xrefs (in case the two articles came from different
3733 ;; Also sets `header' to `nil' meaning that the `dependencies'
3734 ;; table was *not* modified.
3736 (mail-header-set-xref
3737 (car (symbol-value id-dep))
3738 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3740 (or (mail-header-xref header) "")))
3743 (when (and header (not replaced))
3744 ;; First check that we are not creating a References loop.
3745 (setq parent-id (gnus-parent-id (mail-header-references header)))
3746 (setq ref parent-id)
3748 (setq ref-dep (intern-soft ref dependencies))
3750 (setq ref-header (car (symbol-value ref-dep))))
3751 (if (string= id ref)
3752 ;; Yuk! This is a reference loop. Make the article be a
3755 (mail-header-set-references (car (symbol-value id-dep)) "none")
3757 (setq parent-id nil))
3758 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3759 (setq ref-dep (intern (or parent-id "none") dependencies))
3760 (if (boundp ref-dep)
3761 (setcdr (symbol-value ref-dep)
3762 (nconc (cdr (symbol-value ref-dep))
3763 (list (symbol-value id-dep))))
3764 (set ref-dep (list nil (symbol-value id-dep)))))
3767 (defun gnus-extract-message-id-from-in-reply-to (string)
3768 (if (string-match "<[^>]+>" string)
3769 (substring string (match-beginning 0) (match-end 0))
3772 (defun gnus-build-sparse-threads ()
3773 (let ((headers gnus-newsgroup-headers)
3774 (mail-parse-charset gnus-newsgroup-charset)
3775 (gnus-summary-ignore-duplicates t)
3776 header references generation relations
3777 subject child end new-child date)
3778 ;; First we create an alist of generations/relations, where
3779 ;; generations is how much we trust the relation, and the relation
3781 (gnus-message 7 "Making sparse threads...")
3783 (nnheader-set-temp-buffer " *gnus sparse threads*")
3784 (while (setq header (pop headers))
3785 (when (and (setq references (mail-header-references header))
3786 (not (string= references "")))
3788 (setq child (mail-header-id header)
3789 subject (mail-header-subject header)
3790 date (mail-header-date header)
3792 (while (search-backward ">" nil t)
3793 (setq end (1+ (point)))
3794 (when (search-backward "<" nil t)
3795 (setq new-child (buffer-substring (point) end))
3796 (push (list (incf generation)
3797 child (setq child new-child)
3801 (push (list (1+ generation) child nil subject) relations))
3803 (kill-buffer (current-buffer)))
3804 ;; Sort over trustworthiness.
3807 (when (gnus-dependencies-add-header
3808 (make-full-mail-header
3809 gnus-reffed-article-number
3810 (nth 3 relation) "" (or (nth 4 relation) "")
3812 (or (nth 2 relation) "") 0 0 "")
3813 gnus-newsgroup-dependencies nil)
3814 (push gnus-reffed-article-number gnus-newsgroup-limit)
3815 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3816 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3817 gnus-newsgroup-reads)
3818 (decf gnus-reffed-article-number)))
3819 (sort relations 'car-less-than-car))
3820 (gnus-message 7 "Making sparse threads...done")))
3822 (defun gnus-build-old-threads ()
3823 ;; Look at all the articles that refer back to old articles, and
3824 ;; fetch the headers for the articles that aren't there. This will
3825 ;; build complete threads - if the roots haven't been expired by the
3827 (let ((mail-parse-charset gnus-newsgroup-charset)
3831 (when (not (car (symbol-value refs)))
3832 (setq heads (cdr (symbol-value refs)))
3834 (if (memq (mail-header-number (caar heads))
3835 gnus-newsgroup-dormant)
3836 (setq heads (cdr heads))
3837 (setq id (symbol-name refs))
3838 (while (and (setq id (gnus-build-get-header id))
3839 (not (car (gnus-id-to-thread id)))))
3840 (setq heads nil)))))
3841 gnus-newsgroup-dependencies)))
3843 ;; This function has to be called with point after the article number
3844 ;; on the beginning of the line.
3845 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3846 (let ((eol (gnus-point-at-eol))
3847 (buffer (current-buffer))
3848 header references in-reply-to)
3850 ;; overview: [num subject from date id refs chars lines misc]
3853 (narrow-to-region (point) eol)
3858 (make-full-mail-header
3860 (condition-case () ; subject
3861 (funcall gnus-decode-encoded-word-function
3862 (setq x (nnheader-nov-field)))
3864 (condition-case () ; from
3865 (funcall gnus-decode-encoded-word-function
3866 (setq x (nnheader-nov-field)))
3868 (nnheader-nov-field) ; date
3869 (nnheader-nov-read-message-id) ; id
3870 (setq references (nnheader-nov-field)) ; refs
3871 (nnheader-nov-read-integer) ; chars
3872 (nnheader-nov-read-integer) ; lines
3874 (if (looking-at "Xref: ")
3875 (goto-char (match-end 0)))
3876 (nnheader-nov-field)) ; Xref
3877 (nnheader-nov-parse-extra)))) ; extra
3881 (when (and (string= references "")
3882 (setq in-reply-to (mail-header-extra header))
3883 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3884 (mail-header-set-references
3885 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3887 (when gnus-alter-header-function
3888 (funcall gnus-alter-header-function header))
3889 (gnus-dependencies-add-header header dependencies force-new)))
3891 (defun gnus-build-get-header (id)
3892 "Look through the buffer of NOV lines and find the header to ID.
3893 Enter this line into the dependencies hash table, and return
3894 the id of the parent article (if any)."
3895 (let ((deps gnus-newsgroup-dependencies)
3899 (set-buffer nntp-server-buffer)
3900 (let ((case-fold-search nil))
3901 (goto-char (point-min))
3902 (while (and (not found)
3903 (search-forward id nil t))
3905 (setq found (looking-at
3906 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3907 (regexp-quote id))))
3908 (or found (beginning-of-line 2)))
3912 (setq header (gnus-nov-parse-line
3913 (read (current-buffer)) deps))
3914 (gnus-parent-id (mail-header-references header))))))
3916 (let ((number (mail-header-number header)))
3917 (push number gnus-newsgroup-limit)
3918 (push header gnus-newsgroup-headers)
3919 (if (memq number gnus-newsgroup-unselected)
3921 (setq gnus-newsgroup-unreads
3922 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3924 (setq gnus-newsgroup-unselected
3925 (delq number gnus-newsgroup-unselected)))
3926 (push number gnus-newsgroup-ancient)))))))
3928 (defun gnus-build-all-threads ()
3929 "Read all the headers."
3930 (let ((gnus-summary-ignore-duplicates t)
3931 (mail-parse-charset gnus-newsgroup-charset)
3932 (dependencies gnus-newsgroup-dependencies)
3935 (set-buffer nntp-server-buffer)
3936 (let ((case-fold-search nil))
3937 (goto-char (point-min))
3940 (setq article (read (current-buffer))
3941 header (gnus-nov-parse-line article dependencies)))
3944 (set-buffer gnus-summary-buffer)
3945 (push header gnus-newsgroup-headers)
3946 (if (memq (setq article (mail-header-number header))
3947 gnus-newsgroup-unselected)
3949 (setq gnus-newsgroup-unreads
3950 (gnus-add-to-sorted-list
3951 gnus-newsgroup-unreads article))
3952 (setq gnus-newsgroup-unselected
3953 (delq article gnus-newsgroup-unselected)))
3954 (push article gnus-newsgroup-ancient)))
3955 (forward-line 1)))))))
3957 (defun gnus-summary-update-article-line (article header)
3958 "Update the line for ARTICLE using HEADERS."
3959 (let* ((id (mail-header-id header))
3960 (thread (gnus-id-to-thread id)))
3962 (error "Article in no thread"))
3963 ;; Update the thread.
3964 (setcar thread header)
3965 (gnus-summary-goto-subject article)
3966 (let* ((datal (gnus-data-find-list article))
3968 (length (when (cdr datal)
3969 (- (gnus-data-pos data)
3970 (gnus-data-pos (cadr datal)))))
3971 (buffer-read-only nil)
3972 (level (gnus-summary-thread-level)))
3974 (gnus-summary-insert-line
3975 header level nil (gnus-article-mark article)
3976 (memq article gnus-newsgroup-replied)
3977 (memq article gnus-newsgroup-expirable)
3978 ;; Only insert the Subject string when it's different
3979 ;; from the previous Subject string.
3984 (mail-header-subject
3987 (gnus-data-find-list
3989 (gnus-data-list t)))))
3990 ;; Error on the side of excessive subjects.
3992 (mail-header-subject header)))
3994 (mail-header-subject header))
3995 nil (cdr (assq article gnus-newsgroup-scored))
3996 (memq article gnus-newsgroup-processable))
3998 (gnus-data-update-list
3999 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4001 (defun gnus-summary-update-article (article &optional iheader)
4002 "Update ARTICLE in the summary buffer."
4003 (set-buffer gnus-summary-buffer)
4004 (let* ((header (gnus-summary-article-header article))
4005 (id (mail-header-id header))
4006 (data (gnus-data-find article))
4007 (thread (gnus-id-to-thread id))
4008 (references (mail-header-references header))
4012 (when (and references
4013 (not (equal "" references)))
4016 (buffer-read-only nil)
4022 (delq thread parent)))
4023 (if (gnus-summary-insert-subject id header)
4024 ;; Set the (possibly) new article number in the data structure.
4025 (gnus-data-set-number data (gnus-id-to-article id))
4029 (defun gnus-rebuild-thread (id &optional line)
4030 "Rebuild the thread containing ID.
4031 If LINE, insert the rebuilt thread starting on line LINE."
4032 (let ((buffer-read-only nil)
4033 old-pos current thread data)
4034 (if (not gnus-show-threads)
4035 (setq thread (list (car (gnus-id-to-thread id))))
4036 ;; Get the thread this article is part of.
4037 (setq thread (gnus-remove-thread id)))
4038 (setq old-pos (gnus-point-at-bol))
4039 (setq current (save-excursion
4040 (and (re-search-backward "[\r\n]" nil t)
4041 (gnus-summary-article-number))))
4042 ;; If this is a gathered thread, we have to go some re-gathering.
4043 (when (stringp (car thread))
4044 (let ((subject (car thread))
4046 (setq thread (cdr thread))
4048 (unless (memq (setq thr (gnus-id-to-thread
4050 (mail-header-id (caar thread)))))
4053 (setq thread (cdr thread)))
4054 ;; We now have all (unique) roots.
4055 (if (= (length roots) 1)
4056 ;; All the loose roots are now one solid root.
4057 (setq thread (car roots))
4058 (setq thread (cons subject (gnus-sort-threads roots))))))
4060 ;; We then insert this thread into the summary buffer.
4062 (goto-char (point-min))
4063 (forward-line (1- line)))
4064 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4065 (if gnus-show-threads
4066 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4067 (gnus-summary-prepare-unthreaded thread))
4068 (setq data (nreverse gnus-newsgroup-data))
4069 (setq threads gnus-newsgroup-threads))
4070 ;; We splice the new data into the data structure.
4071 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4072 ;;!!! then we want to insert at the beginning of the buffer.
4073 ;;!!! That happens to be true with Gnus now, but that may
4074 ;;!!! change in the future. Perhaps.
4075 (gnus-data-enter-list
4076 (if line nil current) data (- (point) old-pos))
4077 (setq gnus-newsgroup-threads
4078 (nconc threads gnus-newsgroup-threads))
4079 (gnus-data-compute-positions))))
4081 (defun gnus-number-to-header (number)
4082 "Return the header for article NUMBER."
4083 (let ((headers gnus-newsgroup-headers))
4085 (not (= number (mail-header-number (car headers)))))
4090 (defun gnus-parent-headers (in-headers &optional generation)
4091 "Return the headers of the GENERATIONeth parent of HEADERS."
4093 (setq generation 1))
4095 (headers in-headers)
4098 (not (zerop generation))
4099 (setq references (mail-header-references headers)))
4100 (setq headers (if (and references
4101 (setq parent (gnus-parent-id references)))
4102 (car (gnus-id-to-thread parent))
4105 (and (not (eq headers in-headers))
4108 (defun gnus-id-to-thread (id)
4109 "Return the (sub-)thread where ID appears."
4110 (gnus-gethash id gnus-newsgroup-dependencies))
4112 (defun gnus-id-to-article (id)
4113 "Return the article number of ID."
4114 (let ((thread (gnus-id-to-thread id)))
4117 (mail-header-number (car thread)))))
4119 (defun gnus-id-to-header (id)
4120 "Return the article headers of ID."
4121 (car (gnus-id-to-thread id)))
4123 (defun gnus-article-displayed-root-p (article)
4124 "Say whether ARTICLE is a root(ish) article."
4125 (let ((level (gnus-summary-thread-level article))
4126 (refs (mail-header-references (gnus-summary-article-header article)))
4132 ((null (gnus-parent-id refs)) t)
4134 (null (setq particle (gnus-id-to-article
4135 (gnus-parent-id refs))))
4136 (null (gnus-summary-thread-level particle)))))))
4138 (defun gnus-root-id (id)
4139 "Return the id of the root of the thread where ID appears."
4141 (while (and id (setq prev (car (gnus-id-to-thread id))))
4143 id (gnus-parent-id (mail-header-references prev))))
4146 (defun gnus-articles-in-thread (thread)
4147 "Return the list of articles in THREAD."
4148 (cons (mail-header-number (car thread))
4149 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4151 (defun gnus-remove-thread (id &optional dont-remove)
4152 "Remove the thread that has ID in it."
4153 (let (headers thread last-id)
4154 ;; First go up in this thread until we find the root.
4155 (setq last-id (gnus-root-id id)
4156 headers (message-flatten-list (gnus-id-to-thread last-id)))
4157 ;; We have now found the real root of this thread. It might have
4158 ;; been gathered into some loose thread, so we have to search
4159 ;; through the threads to find the thread we wanted.
4160 (let ((threads gnus-newsgroup-threads)
4163 (setq sub (car threads))
4164 (if (stringp (car sub))
4165 ;; This is a gathered thread, so we look at the roots
4166 ;; below it to find whether this article is in this
4169 (setq sub (cdr sub))
4171 (when (member (caar sub) headers)
4172 (setq thread (car threads)
4175 (setq sub (cdr sub))))
4176 ;; It's an ordinary thread, so we check it.
4177 (when (eq (car sub) (car headers))
4180 (setq threads (cdr threads)))
4181 ;; If this article is in no thread, then it's a root.
4184 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4185 (setq thread (gnus-id-to-thread last-id)))
4188 thread ; We return this thread.
4190 (if (stringp (car thread))
4192 ;; If we use dummy roots, then we have to remove the
4193 ;; dummy root as well.
4194 (when (eq gnus-summary-make-false-root 'dummy)
4195 ;; We go to the dummy root by going to
4196 ;; the first sub-"thread", and then one line up.
4197 (gnus-summary-goto-article
4198 (mail-header-number (caadr thread)))
4201 (gnus-data-compute-positions))
4202 (setq thread (cdr thread))
4204 (gnus-remove-thread-1 (car thread))
4205 (setq thread (cdr thread))))
4206 (gnus-remove-thread-1 thread))))))))
4208 (defun gnus-remove-thread-1 (thread)
4209 "Remove the thread THREAD recursively."
4210 (let ((number (mail-header-number (pop thread)))
4212 (setq thread (reverse thread))
4214 (gnus-remove-thread-1 (pop thread)))
4215 (when (setq d (gnus-data-find number))
4216 (goto-char (gnus-data-pos d))
4217 (gnus-summary-show-thread)
4220 (- (gnus-point-at-bol)
4222 (1+ (gnus-point-at-eol))
4223 (gnus-delete-line)))))))
4225 (defun gnus-sort-threads-1 (threads func)
4226 (sort (mapcar (lambda (thread)
4229 (gnus-sort-threads-1 (cdr thread) func))))
4232 (defun gnus-sort-threads (threads)
4234 (if (not gnus-thread-sort-functions)
4236 (gnus-message 8 "Sorting threads...")
4238 (gnus-sort-threads-1
4240 (gnus-make-sort-function gnus-thread-sort-functions))
4241 (gnus-message 8 "Sorting threads...done"))))
4243 (defun gnus-sort-articles (articles)
4245 (when gnus-article-sort-functions
4246 (gnus-message 7 "Sorting articles...")
4248 (setq gnus-newsgroup-headers
4249 (sort articles (gnus-make-sort-function
4250 gnus-article-sort-functions)))
4251 (gnus-message 7 "Sorting articles...done"))))
4253 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4254 (defmacro gnus-thread-header (thread)
4255 "Return header of first article in THREAD.
4256 Note that THREAD must never, ever be anything else than a variable -
4257 using some other form will lead to serious barfage."
4258 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4259 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4260 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4263 (defsubst gnus-article-sort-by-number (h1 h2)
4264 "Sort articles by article number."
4265 (< (mail-header-number h1)
4266 (mail-header-number h2)))
4268 (defun gnus-thread-sort-by-number (h1 h2)
4269 "Sort threads by root article number."
4270 (gnus-article-sort-by-number
4271 (gnus-thread-header h1) (gnus-thread-header h2)))
4273 (defsubst gnus-article-sort-by-random (h1 h2)
4274 "Sort articles by article number."
4277 (defun gnus-thread-sort-by-random (h1 h2)
4278 "Sort threads by root article number."
4279 (gnus-article-sort-by-random
4280 (gnus-thread-header h1) (gnus-thread-header h2)))
4282 (defsubst gnus-article-sort-by-lines (h1 h2)
4283 "Sort articles by article Lines header."
4284 (< (mail-header-lines h1)
4285 (mail-header-lines h2)))
4287 (defun gnus-thread-sort-by-lines (h1 h2)
4288 "Sort threads by root article Lines header."
4289 (gnus-article-sort-by-lines
4290 (gnus-thread-header h1) (gnus-thread-header h2)))
4292 (defsubst gnus-article-sort-by-chars (h1 h2)
4293 "Sort articles by octet length."
4294 (< (mail-header-chars h1)
4295 (mail-header-chars h2)))
4297 (defun gnus-thread-sort-by-chars (h1 h2)
4298 "Sort threads by root article octet length."
4299 (gnus-article-sort-by-chars
4300 (gnus-thread-header h1) (gnus-thread-header h2)))
4302 (defsubst gnus-article-sort-by-author (h1 h2)
4303 "Sort articles by root author."
4305 (let ((extract (funcall
4306 gnus-extract-address-components
4307 (mail-header-from h1))))
4308 (or (car extract) (cadr extract) ""))
4309 (let ((extract (funcall
4310 gnus-extract-address-components
4311 (mail-header-from h2))))
4312 (or (car extract) (cadr extract) ""))))
4314 (defun gnus-thread-sort-by-author (h1 h2)
4315 "Sort threads by root author."
4316 (gnus-article-sort-by-author
4317 (gnus-thread-header h1) (gnus-thread-header h2)))
4319 (defsubst gnus-article-sort-by-subject (h1 h2)
4320 "Sort articles by root subject."
4322 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4323 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4325 (defun gnus-thread-sort-by-subject (h1 h2)
4326 "Sort threads by root subject."
4327 (gnus-article-sort-by-subject
4328 (gnus-thread-header h1) (gnus-thread-header h2)))
4330 (defsubst gnus-article-sort-by-date (h1 h2)
4331 "Sort articles by root article date."
4333 (gnus-date-get-time (mail-header-date h1))
4334 (gnus-date-get-time (mail-header-date h2))))
4336 (defun gnus-thread-sort-by-date (h1 h2)
4337 "Sort threads by root article date."
4338 (gnus-article-sort-by-date
4339 (gnus-thread-header h1) (gnus-thread-header h2)))
4341 (defsubst gnus-article-sort-by-score (h1 h2)
4342 "Sort articles by root article score.
4343 Unscored articles will be counted as having a score of zero."
4344 (> (or (cdr (assq (mail-header-number h1)
4345 gnus-newsgroup-scored))
4346 gnus-summary-default-score 0)
4347 (or (cdr (assq (mail-header-number h2)
4348 gnus-newsgroup-scored))
4349 gnus-summary-default-score 0)))
4351 (defun gnus-thread-sort-by-score (h1 h2)
4352 "Sort threads by root article score."
4353 (gnus-article-sort-by-score
4354 (gnus-thread-header h1) (gnus-thread-header h2)))
4356 (defun gnus-thread-sort-by-total-score (h1 h2)
4357 "Sort threads by the sum of all scores in the thread.
4358 Unscored articles will be counted as having a score of zero."
4359 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4361 (defun gnus-thread-total-score (thread)
4362 ;; This function find the total score of THREAD.
4367 (if (stringp (car thread))
4368 (apply gnus-thread-score-function 0
4369 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4370 (gnus-thread-total-score-1 thread)))
4372 (gnus-thread-total-score-1 (list thread)))))
4374 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4375 "Sort threads such that the thread with the most recently arrived article comes first."
4376 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4378 (defun gnus-thread-highest-number (thread)
4379 "Return the highest article number in THREAD."
4380 (apply 'max (mapcar (lambda (header)
4381 (mail-header-number header))
4382 (message-flatten-list thread))))
4384 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4385 "Sort threads such that the thread with the most recently dated article comes first."
4386 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4388 (defun gnus-thread-latest-date (thread)
4389 "Return the highest article date in THREAD."
4390 (let ((previous-time 0))
4395 (mail-header-parse-date
4397 (mail-header-date header)
4398 (error previous-time))))))
4400 (message-flatten-list thread)
4402 (< (mail-header-number h1)
4403 (mail-header-number h2))))))))
4405 (defun gnus-thread-total-score-1 (root)
4406 ;; This function find the total score of the thread below ROOT.
4407 (setq root (car root))
4408 (apply gnus-thread-score-function
4410 (mapcar 'gnus-thread-total-score
4411 (cdr (gnus-id-to-thread (mail-header-id root))))
4412 (when (> (mail-header-number root) 0)
4413 (list (or (cdr (assq (mail-header-number root)
4414 gnus-newsgroup-scored))
4415 gnus-summary-default-score 0))))
4416 (list gnus-summary-default-score)
4419 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4420 (defvar gnus-tmp-prev-subject nil)
4421 (defvar gnus-tmp-false-parent nil)
4422 (defvar gnus-tmp-root-expunged nil)
4423 (defvar gnus-tmp-dummy-line nil)
4425 (eval-when-compile (defvar gnus-tmp-header))
4426 (defun gnus-extra-header (type &optional header)
4427 "Return the extra header of TYPE."
4428 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4431 (defvar gnus-tmp-thread-tree-header-string "")
4433 (defcustom gnus-sum-thread-tree-root "> "
4434 "With %B spec, used for the root of a thread.
4435 If nil, use subject instead."
4437 :group 'gnus-thread)
4438 (defcustom gnus-sum-thread-tree-single-indent ""
4439 "With %B spec, used for a thread with just one message.
4440 If nil, use subject instead."
4442 :group 'gnus-thread)
4443 (defcustom gnus-sum-thread-tree-vertical "| "
4444 "With %B spec, used for drawing a vertical line."
4446 :group 'gnus-thread)
4447 (defcustom gnus-sum-thread-tree-indent " "
4448 "With %B spec, used for indenting."
4450 :group 'gnus-thread)
4451 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4452 "With %B spec, used for a leaf with brothers."
4454 :group 'gnus-thread)
4455 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4456 "With %B spec, used for a leaf without brothers."
4458 :group 'gnus-thread)
4460 (defun gnus-summary-prepare-threads (threads)
4461 "Prepare summary buffer from THREADS and indentation LEVEL.
4462 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4463 or a straight list of headers."
4464 (gnus-message 7 "Generating summary...")
4466 (setq gnus-newsgroup-threads threads)
4469 (let ((gnus-tmp-level 0)
4470 (default-score (or gnus-summary-default-score 0))
4471 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4472 thread number subject stack state gnus-tmp-gathered beg-match
4473 new-roots gnus-tmp-new-adopts thread-end simp-subject
4474 gnus-tmp-header gnus-tmp-unread
4475 gnus-tmp-replied gnus-tmp-subject-or-nil
4476 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4477 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4478 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4481 (setq gnus-tmp-prev-subject nil)
4483 (if (vectorp (car threads))
4484 ;; If this is a straight (sic) list of headers, then a
4485 ;; threaded summary display isn't required, so we just create
4486 ;; an unthreaded one.
4487 (gnus-summary-prepare-unthreaded threads)
4489 ;; Do the threaded display.
4491 (while (or threads stack gnus-tmp-new-adopts new-roots)
4493 (if (and (= gnus-tmp-level 0)
4496 (not gnus-tmp-false-parent)
4497 (or gnus-tmp-new-adopts new-roots))
4498 (if gnus-tmp-new-adopts
4499 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4500 thread (list (car gnus-tmp-new-adopts))
4501 gnus-tmp-header (caar thread)
4502 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4504 (setq thread (list (car new-roots))
4505 gnus-tmp-header (caar thread)
4506 new-roots (cdr new-roots))))
4509 ;; If there are some threads, we do them before the
4510 ;; threads on the stack.
4511 (setq thread threads
4512 gnus-tmp-header (caar thread))
4513 ;; There were no current threads, so we pop something off
4515 (setq state (car stack)
4516 gnus-tmp-level (car state)
4517 tree-stack (cadr state)
4518 thread (caddr state)
4520 gnus-tmp-header (caar thread))))
4522 (setq gnus-tmp-false-parent nil)
4523 (setq gnus-tmp-root-expunged nil)
4524 (setq thread-end nil)
4526 (if (stringp gnus-tmp-header)
4527 ;; The header is a dummy root.
4529 ((eq gnus-summary-make-false-root 'adopt)
4530 ;; We let the first article adopt the rest.
4531 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4533 (setq gnus-tmp-gathered
4535 (lambda (h) (mail-header-number (car h)))
4538 (setq thread (cons (list (caar thread)
4541 (setq gnus-tmp-level -1
4542 gnus-tmp-false-parent t))
4543 ((eq gnus-summary-make-false-root 'empty)
4544 ;; We print adopted articles with empty subject fields.
4545 (setq gnus-tmp-gathered
4547 (lambda (h) (mail-header-number (car h)))
4550 (setq gnus-tmp-level -1))
4551 ((eq gnus-summary-make-false-root 'dummy)
4552 ;; We remember that we probably want to output a dummy
4554 (setq gnus-tmp-dummy-line gnus-tmp-header)
4555 (setq gnus-tmp-prev-subject gnus-tmp-header))
4557 ;; We do not make a root for the gathered
4558 ;; sub-threads at all.
4559 (setq gnus-tmp-level -1)))
4561 (setq number (mail-header-number gnus-tmp-header)
4562 subject (mail-header-subject gnus-tmp-header)
4563 simp-subject (gnus-simplify-subject-fully subject))
4566 ;; If the thread has changed subject, we might want to make
4567 ;; this subthread into a root.
4568 ((and (null gnus-thread-ignore-subject)
4569 (not (zerop gnus-tmp-level))
4570 gnus-tmp-prev-subject
4571 (not (string= gnus-tmp-prev-subject simp-subject)))
4572 (setq new-roots (nconc new-roots (list (car thread)))
4574 gnus-tmp-header nil))
4575 ;; If the article lies outside the current limit,
4576 ;; then we do not display it.
4577 ((not (memq number gnus-newsgroup-limit))
4578 (setq gnus-tmp-gathered
4580 (lambda (h) (mail-header-number (car h)))
4583 (setq gnus-tmp-new-adopts (if (cdar thread)
4584 (append gnus-tmp-new-adopts
4586 gnus-tmp-new-adopts)
4588 gnus-tmp-header nil)
4589 (when (zerop gnus-tmp-level)
4590 (setq gnus-tmp-root-expunged t)))
4591 ;; Perhaps this article is to be marked as read?
4592 ((and gnus-summary-mark-below
4593 (< (or (cdr (assq number gnus-newsgroup-scored))
4595 gnus-summary-mark-below)
4596 ;; Don't touch sparse articles.
4597 (not (gnus-summary-article-sparse-p number))
4598 (not (gnus-summary-article-ancient-p number)))
4599 (setq gnus-newsgroup-unreads
4600 (delq number gnus-newsgroup-unreads))
4601 (if gnus-newsgroup-auto-expire
4602 (setq gnus-newsgroup-expirable
4603 (gnus-add-to-sorted-list
4604 gnus-newsgroup-expirable number))
4605 (push (cons number gnus-low-score-mark)
4606 gnus-newsgroup-reads))))
4608 (when gnus-tmp-header
4609 ;; We may have an old dummy line to output before this
4611 (when (and gnus-tmp-dummy-line
4614 (mail-header-subject gnus-tmp-header)))
4615 (gnus-summary-insert-dummy-line
4616 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4617 (setq gnus-tmp-dummy-line nil))
4619 ;; Compute the mark.
4620 (setq gnus-tmp-unread (gnus-article-mark number))
4622 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4623 gnus-tmp-header gnus-tmp-level)
4624 gnus-newsgroup-data)
4626 ;; Actually insert the line.
4628 gnus-tmp-subject-or-nil
4630 ((and gnus-thread-ignore-subject
4631 gnus-tmp-prev-subject
4632 (not (string= gnus-tmp-prev-subject simp-subject)))
4634 ((zerop gnus-tmp-level)
4635 (if (and (eq gnus-summary-make-false-root 'empty)
4636 (memq number gnus-tmp-gathered)
4637 gnus-tmp-prev-subject
4638 (string= gnus-tmp-prev-subject simp-subject))
4639 gnus-summary-same-subject
4641 (t gnus-summary-same-subject)))
4642 (if (and (eq gnus-summary-make-false-root 'adopt)
4643 (= gnus-tmp-level 1)
4644 (memq number gnus-tmp-gathered))
4645 (setq gnus-tmp-opening-bracket ?\<
4646 gnus-tmp-closing-bracket ?\>)
4647 (setq gnus-tmp-opening-bracket ?\[
4648 gnus-tmp-closing-bracket ?\]))
4650 gnus-tmp-indentation
4651 (aref gnus-thread-indent-array gnus-tmp-level)
4652 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4653 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4654 gnus-summary-default-score 0)
4656 (if (or (null gnus-summary-default-score)
4657 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4658 gnus-summary-zcore-fuzz))
4660 (if (< gnus-tmp-score gnus-summary-default-score)
4661 gnus-score-below-mark gnus-score-over-mark))
4663 (cond ((memq number gnus-newsgroup-processable)
4665 ((memq number gnus-newsgroup-cached)
4667 ((memq number gnus-newsgroup-replied)
4669 ((memq number gnus-newsgroup-forwarded)
4670 gnus-forwarded-mark)
4671 ((memq number gnus-newsgroup-saved)
4673 ((memq number gnus-newsgroup-recent)
4675 ((memq number gnus-newsgroup-unseen)
4678 gnus-tmp-from (mail-header-from gnus-tmp-header)
4681 ((string-match "<[^>]+> *$" gnus-tmp-from)
4682 (setq beg-match (match-beginning 0))
4683 (or (and (string-match "^\".+\"" gnus-tmp-from)
4684 (substring gnus-tmp-from 1 (1- (match-end 0))))
4685 (substring gnus-tmp-from 0 beg-match)))
4686 ((string-match "(.+)" gnus-tmp-from)
4687 (substring gnus-tmp-from
4688 (1+ (match-beginning 0)) (1- (match-end 0))))
4690 gnus-tmp-thread-tree-header-string
4692 ((not gnus-show-threads) "")
4693 ((zerop gnus-tmp-level)
4695 (or gnus-sum-thread-tree-root subject)
4696 (or gnus-sum-thread-tree-single-indent subject)))
4698 (concat (apply 'concat
4699 (mapcar (lambda (item)
4701 gnus-sum-thread-tree-vertical
4702 gnus-sum-thread-tree-indent))
4703 (cdr (reverse tree-stack))))
4705 gnus-sum-thread-tree-leaf-with-other
4706 gnus-sum-thread-tree-single-leaf)))))
4707 (when (string= gnus-tmp-name "")
4708 (setq gnus-tmp-name gnus-tmp-from))
4709 (unless (numberp gnus-tmp-lines)
4710 (setq gnus-tmp-lines -1))
4711 (if (= gnus-tmp-lines -1)
4712 (setq gnus-tmp-lines "?")
4713 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4714 (gnus-put-text-property
4716 (progn (eval gnus-summary-line-format-spec) (point))
4717 'gnus-number number)
4720 (gnus-run-hooks 'gnus-summary-update-hook)
4723 (setq gnus-tmp-prev-subject simp-subject)))
4725 (when (nth 1 thread)
4726 (push (list (max 0 gnus-tmp-level)
4727 (copy-list tree-stack)
4730 (push (if (nth 1 thread) 1 0) tree-stack)
4731 (incf gnus-tmp-level)
4732 (setq threads (if thread-end nil (cdar thread)))
4734 (setq gnus-tmp-level 0)))))
4735 (gnus-message 7 "Generating summary...done"))
4737 (defun gnus-summary-prepare-unthreaded (headers)
4738 "Generate an unthreaded summary buffer based on HEADERS."
4739 (let (header number mark)
4744 ;; We may have to root out some bad articles...
4745 (when (memq (setq number (mail-header-number
4746 (setq header (pop headers))))
4747 gnus-newsgroup-limit)
4748 ;; Mark article as read when it has a low score.
4749 (when (and gnus-summary-mark-below
4750 (< (or (cdr (assq number gnus-newsgroup-scored))
4751 gnus-summary-default-score 0)
4752 gnus-summary-mark-below)
4753 (not (gnus-summary-article-ancient-p number)))
4754 (setq gnus-newsgroup-unreads
4755 (delq number gnus-newsgroup-unreads))
4756 (if gnus-newsgroup-auto-expire
4757 (push number gnus-newsgroup-expirable)
4758 (push (cons number gnus-low-score-mark)
4759 gnus-newsgroup-reads)))
4761 (setq mark (gnus-article-mark number))
4762 (push (gnus-data-make number mark (1+ (point)) header 0)
4763 gnus-newsgroup-data)
4764 (gnus-summary-insert-line
4766 mark (memq number gnus-newsgroup-replied)
4767 (memq number gnus-newsgroup-expirable)
4768 (mail-header-subject header) nil
4769 (cdr (assq number gnus-newsgroup-scored))
4770 (memq number gnus-newsgroup-processable))))))
4772 (defun gnus-summary-remove-list-identifiers ()
4773 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4774 (let ((regexp (if (consp gnus-list-identifiers)
4775 (mapconcat 'identity gnus-list-identifiers " *\\|")
4776 gnus-list-identifiers))
4779 (dolist (header gnus-newsgroup-headers)
4780 (setq subject (mail-header-subject header)
4782 (while (string-match
4783 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4786 (concat (substring subject 0 (match-beginning 2))
4787 (substring subject (match-end 0)))
4791 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4793 (concat (substring subject 0 (match-beginning 1))
4794 (substring subject (match-end 1)))))
4796 (mail-header-set-subject header subject))))))
4798 (defun gnus-fetch-headers (articles)
4799 "Fetch headers of ARTICLES."
4800 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4801 (gnus-message 5 "Fetching headers for %s..." name)
4804 (setq gnus-headers-retrieved-by
4805 (gnus-retrieve-headers
4806 articles gnus-newsgroup-name
4807 ;; We might want to fetch old headers, but
4808 ;; not if there is only 1 article.
4810 (not (eq gnus-fetch-old-headers 'some))
4811 (not (numberp gnus-fetch-old-headers)))
4812 (> (length articles) 1))
4813 gnus-fetch-old-headers))))
4814 (gnus-get-newsgroup-headers-xover
4815 articles nil nil gnus-newsgroup-name t)
4816 (gnus-get-newsgroup-headers))
4817 (gnus-message 5 "Fetching headers for %s...done" name))))
4819 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4820 "Select newsgroup GROUP.
4821 If READ-ALL is non-nil, all articles in the group are selected.
4822 If SELECT-ARTICLES, only select those articles from GROUP."
4823 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4824 ;;!!! Dirty hack; should be removed.
4825 (gnus-summary-ignore-duplicates
4826 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4828 gnus-summary-ignore-duplicates))
4829 (info (nth 2 entry))
4830 articles fetched-articles cached)
4832 (unless (gnus-check-server
4833 (set (make-local-variable 'gnus-current-select-method)
4834 (gnus-find-method-for-group group)))
4835 (error "Couldn't open server"))
4837 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4838 (gnus-activate-group group) ; Or we can activate it...
4839 (progn ; Or we bug out.
4840 (when (equal major-mode 'gnus-summary-mode)
4841 (kill-buffer (current-buffer)))
4842 (error "Couldn't activate group %s: %s"
4843 group (gnus-status-message group))))
4845 (unless (gnus-request-group group t)
4846 (when (equal major-mode 'gnus-summary-mode)
4847 (kill-buffer (current-buffer)))
4848 (error "Couldn't request group %s: %s"
4849 group (gnus-status-message group)))
4851 (setq gnus-newsgroup-name group
4852 gnus-newsgroup-unselected nil
4853 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4855 (let ((display (gnus-group-find-parameter group 'display)))
4856 (setq gnus-newsgroup-display
4858 ((not (zerop (or (car-safe read-all) 0)))
4859 ;; The user entered the group with C-u SPC/RET, let's show
4865 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4867 ;; The following is probably the "correct" solution, but
4868 ;; it makes Gnus fetch all headers and then limit the
4869 ;; articles (which is slow), so instead we hack the
4870 ;; select-articles parameter instead. -- Simon Josefsson
4873 ;; (gnus-byte-compile
4874 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4876 (setq select-articles
4877 (gnus-uncompress-range
4878 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4882 (cdr (gnus-active group)))))
4887 (gnus-summary-setup-default-charset)
4889 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4890 (when (gnus-virtual-group-p group)
4891 (setq cached gnus-newsgroup-cached))
4893 (setq gnus-newsgroup-unreads
4894 (gnus-sorted-ndifference
4895 (gnus-sorted-ndifference gnus-newsgroup-unreads
4896 gnus-newsgroup-marked)
4897 gnus-newsgroup-dormant))
4899 (setq gnus-newsgroup-processable nil)
4901 (gnus-update-read-articles group gnus-newsgroup-unreads)
4903 ;; Adjust and set lists of article marks.
4905 (gnus-adjust-marked-articles info))
4906 (if (setq articles select-articles)
4907 (setq gnus-newsgroup-unselected
4908 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4909 (setq articles (gnus-articles-to-read group read-all)))
4913 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4915 ((eq articles 0) nil)
4917 ;; Init the dependencies hash table.
4918 (setq gnus-newsgroup-dependencies
4919 (gnus-make-hashtable (length articles)))
4920 (gnus-set-global-variables)
4921 ;; Retrieve the headers and read them in.
4923 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4925 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4927 (setq gnus-newsgroup-cached cached))
4929 ;; Suppress duplicates?
4930 (when gnus-suppress-duplicates
4931 (gnus-dup-suppress-articles))
4933 ;; Set the initial limit.
4934 (setq gnus-newsgroup-limit (copy-sequence articles))
4935 ;; Remove canceled articles from the list of unread articles.
4936 (setq fetched-articles
4937 (mapcar (lambda (headers) (mail-header-number headers))
4938 gnus-newsgroup-headers))
4939 (setq gnus-newsgroup-articles fetched-articles)
4940 (setq gnus-newsgroup-unreads
4941 (gnus-sorted-nintersection
4942 gnus-newsgroup-unreads fetched-articles))
4943 (gnus-compute-unseen-list)
4945 ;; Removed marked articles that do not exist.
4946 (gnus-update-missing-marks
4947 (gnus-sorted-difference articles fetched-articles))
4948 ;; We might want to build some more threads first.
4949 (when (and gnus-fetch-old-headers
4950 (eq gnus-headers-retrieved-by 'nov))
4951 (if (eq gnus-fetch-old-headers 'invisible)
4952 (gnus-build-all-threads)
4953 (gnus-build-old-threads)))
4954 ;; Let the Gnus agent mark articles as read.
4956 (gnus-agent-get-undownloaded-list))
4957 ;; Remove list identifiers from subject
4958 (when gnus-list-identifiers
4959 (gnus-summary-remove-list-identifiers))
4960 ;; Check whether auto-expire is to be done in this group.
4961 (setq gnus-newsgroup-auto-expire
4962 (gnus-group-auto-expirable-p group))
4963 ;; Set up the article buffer now, if necessary.
4964 (unless gnus-single-article-buffer
4965 (gnus-article-setup-buffer))
4966 ;; First and last article in this newsgroup.
4967 (when gnus-newsgroup-headers
4968 (setq gnus-newsgroup-begin
4969 (mail-header-number (car gnus-newsgroup-headers))
4972 (gnus-last-element gnus-newsgroup-headers))))
4973 ;; GROUP is successfully selected.
4974 (or gnus-newsgroup-headers t)))))
4976 (defun gnus-compute-unseen-list ()
4977 ;; The `seen' marks are treated specially.
4978 (if (not gnus-newsgroup-seen)
4979 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4980 (setq gnus-newsgroup-unseen
4981 (gnus-inverse-list-range-intersection
4982 gnus-newsgroup-articles gnus-newsgroup-seen))))
4984 (defun gnus-summary-display-make-predicate (display)
4985 (require 'gnus-agent)
4986 (when (= (length display) 1)
4987 (setq display (car display)))
4988 (unless gnus-summary-display-cache
4989 (dolist (elem (append '((unread . unread)
4992 gnus-article-mark-lists))
4993 (push (cons (cdr elem)
4995 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4996 gnus-summary-display-cache)))
4997 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
4998 (gnus-category-predicate-cache gnus-summary-display-cache))
4999 (gnus-get-predicate display)))
5001 ;; Uses the dynamically bound `number' variable.
5003 (defun gnus-article-marked-p (type &optional article)
5004 (let ((article (or article number)))
5007 (memq article gnus-newsgroup-marked))
5009 (memq article gnus-newsgroup-spam-marked))
5011 (memq article gnus-newsgroup-unsendable))
5012 ((eq type 'undownload)
5013 (memq article gnus-newsgroup-undownloaded))
5014 ((eq type 'download)
5015 (memq article gnus-newsgroup-downloadable))
5017 (memq article gnus-newsgroup-unreads))
5019 (memq article gnus-newsgroup-reads))
5021 (memq article gnus-newsgroup-dormant) )
5023 (memq article gnus-newsgroup-expirable))
5025 (memq article gnus-newsgroup-replied))
5027 (memq article gnus-newsgroup-killed))
5028 ((eq type 'bookmark)
5029 (assq article gnus-newsgroup-bookmarks))
5031 (assq article gnus-newsgroup-scored))
5033 (memq article gnus-newsgroup-saved))
5035 (memq article gnus-newsgroup-cached))
5037 (memq article gnus-newsgroup-forwarded))
5039 (not (memq article gnus-newsgroup-unseen)))
5041 (memq article gnus-newsgroup-recent))
5044 (defun gnus-articles-to-read (group &optional read-all)
5045 "Find out what articles the user wants to read."
5047 ;; Select all articles if `read-all' is non-nil, or if there
5048 ;; are no unread articles.
5050 (and (zerop (length gnus-newsgroup-marked))
5051 (zerop (length gnus-newsgroup-unreads)))
5052 ;; Fetch all if the predicate is non-nil.
5053 gnus-newsgroup-display)
5054 ;; We want to select the headers for all the articles in
5055 ;; the group, so we select either all the active
5056 ;; articles in the group, or (if that's nil), the
5057 ;; articles in the cache.
5059 (gnus-uncompress-range (gnus-active group))
5060 (gnus-cache-articles-in-group group))
5061 ;; Select only the "normal" subset of articles.
5063 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5064 gnus-newsgroup-unreads)))
5065 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5066 (scored (length scored-list))
5067 (number (length articles))
5068 (marked (+ (length gnus-newsgroup-marked)
5069 (length gnus-newsgroup-dormant)))
5074 ((numberp gnus-newsgroup-display)
5075 gnus-newsgroup-display)
5079 ((and (or (<= scored marked) (= scored number))
5080 (numberp gnus-large-newsgroup)
5081 (> number gnus-large-newsgroup))
5082 (let* ((cursor-in-echo-area nil)
5083 (initial (gnus-parameter-large-newsgroup-initial
5084 gnus-newsgroup-name))
5088 "How many articles from %s (%s %d): "
5090 (gnus-group-decoded-name gnus-newsgroup-name)
5092 (if initial "max" "default")
5095 (cons (number-to-string initial)
5097 (if (string-match "^[ \t]*$" input) number input)))
5098 ((and (> scored marked) (< scored number)
5099 (> (- scored number) 20))
5102 (format "%s %s (%d scored, %d total): "
5103 "How many articles from"
5104 (gnus-group-decoded-name group)
5106 (if (string-match "^[ \t]*$" input)
5110 (message "Quit getting the articles to read")
5112 (setq select (if (stringp select) (string-to-number select) select))
5113 (if (or (null select) (zerop select))
5115 (if (and (not (zerop scored)) (<= (abs select) scored))
5117 (setq articles (sort scored-list '<))
5118 (setq number (length articles)))
5119 (setq articles (copy-sequence articles)))
5121 (when (< (abs select) number)
5123 ;; Select the N oldest articles.
5124 (setcdr (nthcdr (1- (abs select)) articles) nil)
5125 ;; Select the N most recent articles.
5126 (setq articles (nthcdr (- number select) articles))))
5127 (setq gnus-newsgroup-unselected
5128 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5129 (when gnus-alter-articles-to-read-function
5130 (setq gnus-newsgroup-unreads
5132 (funcall gnus-alter-articles-to-read-function
5133 gnus-newsgroup-name gnus-newsgroup-unreads)
5137 (defun gnus-killed-articles (killed articles)
5140 (when (inline (gnus-member-of-range (car articles) killed))
5141 (push (car articles) out))
5142 (setq articles (cdr articles)))
5145 (defun gnus-uncompress-marks (marks)
5146 "Uncompress the mark ranges in MARKS."
5147 (let ((uncompressed '(score bookmark))
5150 (if (memq (caar marks) uncompressed)
5151 (push (car marks) out)
5152 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5153 (setq marks (cdr marks)))
5156 (defun gnus-article-mark-to-type (mark)
5157 "Return the type of MARK."
5158 (or (cadr (assq mark gnus-article-special-mark-lists))
5161 (defun gnus-article-unpropagatable-p (mark)
5162 "Return whether MARK should be propagated to backend."
5163 (memq mark gnus-article-unpropagated-mark-lists))
5165 (defun gnus-adjust-marked-articles (info)
5166 "Set all article lists and remove all marks that are no longer valid."
5167 (let* ((marked-lists (gnus-info-marks info))
5168 (active (gnus-active (gnus-info-group info)))
5171 (types gnus-article-mark-lists)
5172 marks var articles article mark mark-type)
5174 (dolist (marks marked-lists)
5175 (setq mark (car marks)
5176 mark-type (gnus-article-mark-to-type mark)
5177 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5179 ;; We set the variable according to the type of the marks list,
5180 ;; and then adjust the marks to a subset of the active articles.
5182 ;; Adjust "simple" lists.
5183 ((eq mark-type 'list)
5184 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5185 (when (memq mark '(tick dormant expire reply save))
5187 (when (or (< (setq article (pop articles)) min) (> article max))
5188 (set var (delq article (symbol-value var)))))))
5190 ((eq mark-type 'tuple)
5191 (set var (setq articles (cdr marks)))
5192 (when (not (listp (cdr (symbol-value var))))
5193 (set var (list (symbol-value var))))
5194 (when (not (listp (cdr articles)))
5195 (setq articles (list articles)))
5197 (when (or (not (consp (setq article (pop articles))))
5198 (< (car article) min)
5199 (> (car article) max))
5200 (set var (delq article (symbol-value var))))))
5201 ;; Adjust ranges (sloppily).
5202 ((eq mark-type 'range)
5205 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5206 ;; It should be (seen (NUM1 . NUM2)).
5207 (when (numberp (cddr marks))
5208 (setcdr marks (list (cdr marks))))
5209 (setq articles (cdr marks))
5210 (while (and articles
5211 (or (and (consp (car articles))
5212 (> min (cdar articles)))
5213 (and (numberp (car articles))
5214 (> min (car articles)))))
5216 (set var articles))))))))
5218 (defun gnus-update-missing-marks (missing)
5219 "Go through the list of MISSING articles and remove them from the mark lists."
5222 ;; Go through all types.
5223 (dolist (elem gnus-article-mark-lists)
5224 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5225 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5226 (when (symbol-value var)
5227 ;; This list has articles. So we delete all missing
5228 ;; articles from it.
5231 (set var (delq (pop m) (symbol-value var))))))))))
5233 (defun gnus-update-marks ()
5234 "Enter the various lists of marked articles into the newsgroup info list."
5235 (let ((types gnus-article-mark-lists)
5236 (info (gnus-get-info gnus-newsgroup-name))
5237 type list newmarked symbol delta-marks)
5239 ;; Add all marks lists to the list of marks lists.
5240 (while (setq type (pop types))
5241 (setq list (symbol-value
5243 (intern (format "gnus-newsgroup-%s" (car type))))))
5246 ;; Get rid of the entries of the articles that have the
5248 (when (and (eq (cdr type) 'score)
5252 (prev (cons nil list))
5255 (if (or (not (consp (car arts)))
5256 (= (cdar arts) gnus-summary-default-score))
5257 (setcdr prev (cdr arts))
5259 (setq arts (cdr arts)))
5260 (setq list (cdr all)))))
5262 (when (eq (cdr type) 'seen)
5263 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5265 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5266 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5268 (when (and (gnus-check-backend-function
5269 'request-set-mark gnus-newsgroup-name)
5270 (not (gnus-article-unpropagatable-p (cdr type))))
5271 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5272 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5273 (add (gnus-remove-from-range
5274 (gnus-copy-sequence list) old)))
5276 (push (list add 'add (list (cdr type))) delta-marks))
5278 (push (list del 'del (list (cdr type))) delta-marks))))
5281 (push (cons (cdr type) list) newmarked)))
5284 (unless (gnus-check-group gnus-newsgroup-name)
5285 (error "Can't open server for %s" gnus-newsgroup-name))
5286 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5288 ;; Enter these new marks into the info of the group.
5290 (setcar (nthcdr 3 info) newmarked)
5291 ;; Add the marks lists to the end of the info.
5293 (setcdr (nthcdr 2 info) (list newmarked))))
5295 ;; Cut off the end of the info if there's nothing else there.
5299 (when (nthcdr (decf i) info)
5300 (setcdr (nthcdr i info) nil)))))))
5302 (defun gnus-set-mode-line (where)
5303 "Set the mode line of the article or summary buffers.
5304 If WHERE is `summary', the summary mode line format will be used."
5305 ;; Is this mode line one we keep updated?
5306 (when (and (memq where gnus-updated-mode-lines)
5308 (intern (format "gnus-%s-mode-line-format-spec" where))))
5311 ;; We evaluate this in the summary buffer since these
5312 ;; variables are buffer-local to that buffer.
5313 (set-buffer gnus-summary-buffer)
5314 ;; We bind all these variables that are used in the `eval' form
5316 (let* ((mformat (symbol-value
5318 (format "gnus-%s-mode-line-format-spec" where))))
5319 (gnus-tmp-group-name (gnus-group-decoded-name
5320 gnus-newsgroup-name))
5321 (gnus-tmp-article-number (or gnus-current-article 0))
5322 (gnus-tmp-unread gnus-newsgroup-unreads)
5323 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5324 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5325 (gnus-tmp-unread-and-unselected
5326 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5327 (zerop gnus-tmp-unselected))
5329 ((zerop gnus-tmp-unselected)
5330 (format "{%d more}" gnus-tmp-unread-and-unticked))
5331 (t (format "{%d(+%d) more}"
5332 gnus-tmp-unread-and-unticked
5333 gnus-tmp-unselected))))
5335 (if (and gnus-current-headers
5336 (vectorp gnus-current-headers))
5337 (gnus-mode-string-quote
5338 (mail-header-subject gnus-current-headers))
5340 bufname-length max-len
5341 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5342 (setq mode-string (eval mformat))
5343 (setq bufname-length (if (string-match "%b" mode-string)
5346 (if (eq where 'summary)
5348 (get-buffer gnus-article-buffer))))
5351 (setq max-len (max 4 (if gnus-mode-non-string-length
5353 gnus-mode-non-string-length
5355 (length mode-string))))
5356 ;; We might have to chop a bit of the string off...
5357 (when (> (length mode-string) max-len)
5359 (concat (truncate-string-to-width mode-string (- max-len 3))
5361 ;; Pad the mode string a bit.
5362 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5363 ;; Update the mode line.
5364 (setq mode-line-buffer-identification
5365 (gnus-mode-line-buffer-identification (list mode-string)))
5366 (set-buffer-modified-p t))))
5368 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5369 "Go through the HEADERS list and add all Xrefs to a hash table.
5370 The resulting hash table is returned, or nil if no Xrefs were found."
5371 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5372 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5373 (xref-hashtb (gnus-make-hashtable))
5374 start group entry number xrefs header)
5376 (setq header (pop headers))
5377 (when (and (setq xrefs (mail-header-xref header))
5378 (not (memq (setq number (mail-header-number header))
5381 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5382 (setq start (match-end 0))
5383 (setq group (if prefix
5384 (concat prefix (substring xrefs (match-beginning 1)
5386 (substring xrefs (match-beginning 1) (match-end 1))))
5388 (string-to-int (substring xrefs (match-beginning 2)
5390 (if (setq entry (gnus-gethash group xref-hashtb))
5391 (setcdr entry (cons number (cdr entry)))
5392 (gnus-sethash group (cons number nil) xref-hashtb)))))
5393 (and start xref-hashtb)))
5395 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5396 "Look through all the headers and mark the Xrefs as read."
5397 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5398 name entry info xref-hashtb idlist method nth4)
5400 (set-buffer gnus-group-buffer)
5401 (when (setq xref-hashtb
5402 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5405 (unless (string= from-newsgroup (setq name (symbol-name group)))
5406 (setq idlist (symbol-value group))
5407 ;; Dead groups are not updated.
5409 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5411 (when (stringp (setq nth4 (gnus-info-method info)))
5412 (setq nth4 (gnus-server-to-method nth4))))
5413 ;; Only do the xrefs if the group has the same
5414 ;; select method as the group we have just read.
5415 (or (gnus-methods-equal-p
5416 nth4 (gnus-find-method-for-group from-newsgroup))
5418 (equal nth4 (setq method (gnus-find-method-for-group
5420 (and (equal (car nth4) (car method))
5421 (equal (nth 1 nth4) (nth 1 method))))
5422 gnus-use-cross-reference
5423 (or (not (eq gnus-use-cross-reference t))
5425 ;; Only do cross-references on subscribed
5426 ;; groups, if that is what is wanted.
5427 (<= (gnus-info-level info) gnus-level-subscribed))
5428 (gnus-group-make-articles-read name idlist))))
5431 (defun gnus-compute-read-articles (group articles)
5432 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5433 (info (nth 2 entry))
5434 (active (gnus-active group))
5437 ;; First peel off all invalid article numbers.
5439 (let ((ids articles)
5441 (while (setq id (pop ids))
5442 (when (and first (> id (cdr active)))
5443 ;; We'll end up in this situation in one particular
5444 ;; obscure situation. If you re-scan a group and get
5445 ;; a new article that is cross-posted to a different
5446 ;; group that has not been re-scanned, you might get
5447 ;; crossposted article that has a higher number than
5448 ;; Gnus believes possible. So we re-activate this
5449 ;; group as well. This might mean doing the
5450 ;; crossposting thingy will *increase* the number
5451 ;; of articles in some groups. Tsk, tsk.
5452 (setq active (or (gnus-activate-group group) active)))
5453 (when (or (> id (cdr active))
5454 (< id (car active)))
5455 (setq articles (delq id articles))))))
5456 ;; If the read list is nil, we init it.
5458 (null (gnus-info-read info))
5460 (setq ninfo (cons 1 (1- (car active))))
5461 (setq ninfo (gnus-info-read info)))
5462 ;; Then we add the read articles to the range.
5464 ninfo (setq articles (sort articles '<))))))
5466 (defun gnus-group-make-articles-read (group articles)
5467 "Update the info of GROUP to say that ARTICLES are read."
5469 (entry (gnus-gethash group gnus-newsrc-hashtb))
5470 (info (nth 2 entry))
5471 (active (gnus-active group))
5474 (setq range (gnus-compute-read-articles group articles))
5476 (set-buffer gnus-group-buffer)
5479 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5480 (gnus-info-set-read ',info ',(gnus-info-read info))
5481 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5482 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5483 (gnus-group-update-group ,group t))))
5484 ;; Add the read articles to the range.
5485 (gnus-info-set-read info range)
5486 (gnus-request-set-mark group (list (list range 'add '(read))))
5487 ;; Then we have to re-compute how many unread
5488 ;; articles there are in this group.
5492 (setq num (- (1+ (cdr active)) (car active))))
5493 ((not (listp (cdr range)))
5494 (setq num (- (cdr active) (- (1+ (cdr range))
5498 (if (numberp (car range))
5500 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5501 (setq range (cdr range)))
5502 (setq num (- (cdr active) num))))
5503 ;; Update the number of unread articles.
5505 ;; Update the group buffer.
5506 (gnus-group-update-group group t)))))
5508 (defvar gnus-newsgroup-none-id 0)
5510 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5511 (let ((cur nntp-server-buffer)
5514 (save-excursion (set-buffer gnus-summary-buffer)
5515 gnus-newsgroup-dependencies)))
5517 (mail-parse-charset gnus-newsgroup-charset)
5518 (mail-parse-ignored-charsets
5519 (save-excursion (condition-case nil
5520 (set-buffer gnus-summary-buffer)
5522 gnus-newsgroup-ignored-charsets)))
5524 (set-buffer nntp-server-buffer)
5525 ;; Translate all TAB characters into SPACE characters.
5526 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5527 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5528 (gnus-run-hooks 'gnus-parse-headers-hook)
5529 (let ((case-fold-search t)
5530 in-reply-to header p lines chars)
5531 (goto-char (point-min))
5532 ;; Search to the beginning of the next header. Error messages
5533 ;; do not begin with 2 or 3.
5534 (while (re-search-forward "^[23][0-9]+ " nil t)
5537 ;; This implementation of this function, with nine
5538 ;; search-forwards instead of the one re-search-forward and
5539 ;; a case (which basically was the old function) is actually
5540 ;; about twice as fast, even though it looks messier. You
5541 ;; can't have everything, I guess. Speed and elegance
5542 ;; doesn't always go hand in hand.
5551 (narrow-to-region (point)
5552 (or (and (search-forward "\n.\n" nil t)
5558 (if (search-forward "\nsubject:" nil t)
5559 (funcall gnus-decode-encoded-word-function
5560 (nnheader-header-value))
5565 (if (search-forward "\nfrom:" nil t)
5566 (funcall gnus-decode-encoded-word-function
5567 (nnheader-header-value))
5572 (if (search-forward "\ndate:" nil t)
5573 (nnheader-header-value) ""))
5577 (setq id (if (re-search-forward
5578 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5579 ;; We do it this way to make sure the Message-ID
5580 ;; is (somewhat) syntactically valid.
5581 (buffer-substring (match-beginning 1)
5583 ;; If there was no message-id, we just fake one
5584 ;; to make subsequent routines simpler.
5585 (nnheader-generate-fake-message-id))))
5589 (if (search-forward "\nreferences:" nil t)
5593 (nnheader-header-value)
5598 (search-backward ">" end t)
5601 (search-backward "<" end t)
5603 ;; Get the references from the in-reply-to header if there
5604 ;; were no references and the in-reply-to header looks
5606 (if (and (search-forward "\nin-reply-to:" nil t)
5607 (setq in-reply-to (nnheader-header-value))
5608 (string-match "<[^>]+>" in-reply-to))
5610 (setq ref (substring in-reply-to (match-beginning 0)
5612 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5613 (setq ref2 (substring in-reply-to (match-beginning 0)
5615 (when (> (length ref2) (length ref))
5622 (if (search-forward "\nchars: " nil t)
5623 (if (numberp (setq chars (ignore-errors (read cur))))
5629 (if (search-forward "\nlines: " nil t)
5630 (if (numberp (setq lines (ignore-errors (read cur))))
5636 (and (search-forward "\nxref:" nil t)
5637 (nnheader-header-value)))
5639 (when gnus-extra-headers
5640 (let ((extra gnus-extra-headers)
5644 (when (search-forward
5645 (concat "\n" (symbol-name (car extra)) ":") nil t)
5646 (push (cons (car extra) (nnheader-header-value))
5650 (when (equal id ref)
5653 (when gnus-alter-header-function
5654 (funcall gnus-alter-header-function header)
5655 (setq id (mail-header-id header)
5656 ref (gnus-parent-id (mail-header-references header))))
5659 (gnus-dependencies-add-header
5660 header dependencies force-new))
5661 (push header headers))
5662 (goto-char (point-max))
5664 (nreverse headers)))))
5666 ;; Goes through the xover lines and returns a list of vectors
5667 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5668 force-new dependencies
5669 group also-fetch-heads)
5670 "Parse the news overview data in the server buffer.
5671 Return a list of headers that match SEQUENCE (see
5672 `nntp-retrieve-headers')."
5673 ;; Get the Xref when the users reads the articles since most/some
5674 ;; NNTP servers do not include Xrefs when using XOVER.
5675 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5676 (let ((mail-parse-charset gnus-newsgroup-charset)
5677 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5678 (cur nntp-server-buffer)
5679 (dependencies (or dependencies gnus-newsgroup-dependencies))
5681 ((eq gnus-read-all-available-headers t)
5683 ((stringp gnus-read-all-available-headers)
5684 (string-match gnus-read-all-available-headers group))
5687 number headers header)
5689 (set-buffer nntp-server-buffer)
5690 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5691 ;; Allow the user to mangle the headers before parsing them.
5692 (gnus-run-hooks 'gnus-parse-headers-hook)
5693 (goto-char (point-min))
5694 (gnus-parse-without-error
5695 (while (and (or sequence allp)
5697 (setq number (read cur))
5699 (while (and sequence
5700 (< (car sequence) number))
5701 (setq sequence (cdr sequence))))
5704 (eq number (car sequence))))
5706 (setq sequence (cdr sequence))
5707 (setq header (inline
5708 (gnus-nov-parse-line
5709 number dependencies force-new)))))
5710 (push header headers))
5712 ;; A common bug in inn is that if you have posted an article and
5713 ;; then retrieves the active file, it will answer correctly --
5714 ;; the new article is included. However, a NOV entry for the
5715 ;; article may not have been generated yet, so this may fail.
5716 ;; We work around this problem by retrieving the last few
5717 ;; headers using HEAD.
5718 (if (or (not also-fetch-heads)
5720 ;; We (probably) got all the headers.
5722 (let ((gnus-nov-is-evil t))
5725 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5726 (gnus-get-newsgroup-headers))))))))
5728 (defun gnus-article-get-xrefs ()
5729 "Fill in the Xref value in `gnus-current-headers', if necessary.
5730 This is meant to be called in `gnus-article-internal-prepare-hook'."
5731 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5732 gnus-current-headers)))
5733 (or (not gnus-use-cross-reference)
5735 (and (mail-header-xref headers)
5736 (not (string= (mail-header-xref headers) "")))
5737 (let ((case-fold-search t)
5740 (nnheader-narrow-to-headers)
5741 (goto-char (point-min))
5742 (when (or (and (not (eobp))
5743 (eq (downcase (char-after)) ?x)
5744 (looking-at "Xref:"))
5745 (search-forward "\nXref:" nil t))
5746 (goto-char (1+ (match-end 0)))
5747 (setq xref (buffer-substring (point)
5748 (progn (end-of-line) (point))))
5749 (mail-header-set-xref headers xref)))))))
5751 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5752 "Find article ID and insert the summary line for that article.
5753 OLD-HEADER can either be a header or a line number to insert
5754 the subject line on."
5755 (let* ((line (and (numberp old-header) old-header))
5756 (old-header (and (vectorp old-header) old-header))
5757 (header (cond ((and old-header use-old-header)
5760 (gnus-number-to-header id))
5761 (gnus-number-to-header id))
5763 (gnus-read-header id))))
5764 (number (and (numberp id) id))
5767 ;; Rebuild the thread that this article is part of and go to the
5768 ;; article we have fetched.
5769 (when (and (not gnus-show-threads)
5772 (setq d (gnus-data-find (mail-header-number old-header))))
5773 (goto-char (gnus-data-pos d))
5776 (- (gnus-point-at-bol)
5778 (1+ (gnus-point-at-eol))
5779 (gnus-delete-line))))))
5781 (mail-header-set-number header (mail-header-number old-header)))
5782 (setq gnus-newsgroup-sparse
5783 (delq (setq number (mail-header-number header))
5784 gnus-newsgroup-sparse))
5785 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5786 (push number gnus-newsgroup-limit)
5787 (gnus-rebuild-thread (mail-header-id header) line)
5788 (gnus-summary-goto-subject number nil t))
5789 (when (and (numberp number)
5791 ;; We have to update the boundaries even if we can't fetch the
5792 ;; article if ID is a number -- so that the next `P' or `N'
5793 ;; command will fetch the previous (or next) article even
5794 ;; if the one we tried to fetch this time has been canceled.
5795 (when (> number gnus-newsgroup-end)
5796 (setq gnus-newsgroup-end number))
5797 (when (< number gnus-newsgroup-begin)
5798 (setq gnus-newsgroup-begin number))
5799 (setq gnus-newsgroup-unselected
5800 (delq number gnus-newsgroup-unselected)))
5801 ;; Report back a success?
5802 (and header (mail-header-number header))))
5804 ;;; Process/prefix in the summary buffer
5806 (defun gnus-summary-work-articles (n)
5807 "Return a list of articles to be worked upon.
5808 The prefix argument, the list of process marked articles, and the
5809 current article will be taken into consideration."
5811 (set-buffer gnus-summary-buffer)
5814 ;; A numerical prefix has been given.
5815 (setq n (prefix-numeric-value n))
5816 (let ((backward (< n 0))
5817 (n (abs (prefix-numeric-value n)))
5822 (push (setq article (gnus-summary-article-number))
5825 (gnus-summary-find-prev nil article)
5826 (gnus-summary-find-next nil article)))
5828 (nreverse articles)))
5829 ((and (gnus-region-active-p) (mark))
5830 (message "region active")
5831 ;; Work on the region between point and mark.
5832 (let ((max (max (point) (mark)))
5835 (goto-char (min (min (point) (mark))))
5838 (push (setq article (gnus-summary-article-number)) articles)
5839 (gnus-summary-find-next nil article)
5841 (nreverse articles))))
5842 (gnus-newsgroup-processable
5843 ;; There are process-marked articles present.
5844 ;; Save current state.
5845 (gnus-summary-save-process-mark)
5847 (reverse gnus-newsgroup-processable))
5849 ;; Just return the current article.
5850 (list (gnus-summary-article-number))))))
5852 (defmacro gnus-summary-iterate (arg &rest forms)
5853 "Iterate over the process/prefixed articles and do FORMS.
5854 ARG is the interactive prefix given to the command. FORMS will be
5855 executed with point over the summary line of the articles."
5856 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5857 `(let ((,articles (gnus-summary-work-articles ,arg)))
5859 (gnus-summary-goto-subject (car ,articles))
5863 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5864 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5866 (defun gnus-summary-save-process-mark ()
5867 "Push the current set of process marked articles on the stack."
5869 (push (copy-sequence gnus-newsgroup-processable)
5870 gnus-newsgroup-process-stack))
5872 (defun gnus-summary-kill-process-mark ()
5873 "Push the current set of process marked articles on the stack and unmark."
5875 (gnus-summary-save-process-mark)
5876 (gnus-summary-unmark-all-processable))
5878 (defun gnus-summary-yank-process-mark ()
5879 "Pop the last process mark state off the stack and restore it."
5881 (unless gnus-newsgroup-process-stack
5882 (error "Empty mark stack"))
5883 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5885 (defun gnus-summary-process-mark-set (set)
5886 "Make SET into the current process marked articles."
5887 (gnus-summary-unmark-all-processable)
5889 (gnus-summary-set-process-mark (pop set))))
5891 ;;; Searching and stuff
5893 (defun gnus-summary-search-group (&optional backward use-level)
5894 "Search for next unread newsgroup.
5895 If optional argument BACKWARD is non-nil, search backward instead."
5897 (set-buffer gnus-group-buffer)
5898 (when (gnus-group-search-forward
5899 backward nil (if use-level (gnus-group-group-level) nil))
5900 (gnus-group-group-name))))
5902 (defun gnus-summary-best-group (&optional exclude-group)
5903 "Find the name of the best unread group.
5904 If EXCLUDE-GROUP, do not go to this group."
5906 (set-buffer gnus-group-buffer)
5908 (gnus-group-best-unread-group exclude-group))))
5910 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5911 (if backward (gnus-summary-find-prev)
5912 (let* ((dummy (gnus-summary-article-intangible-p))
5913 (article (or article (gnus-summary-article-number)))
5914 (arts (gnus-data-find-list article))
5916 (when (and (not dummy)
5917 (or (not gnus-summary-check-current)
5919 (not (gnus-data-unread-p (car arts)))))
5920 (setq arts (cdr arts)))
5925 (when (or (and undownloaded
5926 (eq gnus-undownloaded-mark
5927 (gnus-data-mark (car arts))))
5928 (gnus-data-unread-p (car arts)))
5929 (setq result (car arts)
5931 (setq arts (cdr arts)))
5934 (goto-char (gnus-data-pos result))
5935 (gnus-data-number result)))))
5937 (defun gnus-summary-find-prev (&optional unread article)
5938 (let* ((eobp (eobp))
5939 (article (or article (gnus-summary-article-number)))
5940 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5942 (when (and (not eobp)
5943 (or (not gnus-summary-check-current)
5945 (not (gnus-data-unread-p (car arts)))))
5946 (setq arts (cdr arts)))
5951 (when (gnus-data-unread-p (car arts))
5952 (setq result (car arts)
5954 (setq arts (cdr arts)))
5957 (goto-char (gnus-data-pos result))
5958 (gnus-data-number result))))
5960 (defun gnus-summary-find-subject (subject &optional unread backward article)
5961 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5962 (article (or article (gnus-summary-article-number)))
5963 (articles (gnus-data-list backward))
5964 (arts (gnus-data-find-list article articles))
5966 (when (or (not gnus-summary-check-current)
5968 (not (gnus-data-unread-p (car arts))))
5969 (setq arts (cdr arts)))
5971 (and (or (not unread)
5972 (gnus-data-unread-p (car arts)))
5973 (vectorp (gnus-data-header (car arts)))
5975 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5976 (setq result (car arts)
5978 (setq arts (cdr arts)))
5980 (goto-char (gnus-data-pos result))
5981 (gnus-data-number result))))
5983 (defun gnus-summary-search-forward (&optional unread subject backward)
5984 "Search forward for an article.
5985 If UNREAD, look for unread articles. If SUBJECT, look for
5986 articles with that subject. If BACKWARD, search backward instead."
5987 (cond (subject (gnus-summary-find-subject subject unread backward))
5988 (backward (gnus-summary-find-prev unread))
5989 (t (gnus-summary-find-next unread))))
5991 (defun gnus-recenter (&optional n)
5992 "Center point in window and redisplay frame.
5993 Also do horizontal recentering."
5995 (when (and gnus-auto-center-summary
5996 (not (eq gnus-auto-center-summary 'vertical)))
5997 (gnus-horizontal-recenter))
6000 (defun gnus-summary-recenter ()
6001 "Center point in the summary window.
6002 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6003 displayed, no centering will be performed."
6004 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6005 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6007 (let* ((top (cond ((< (window-height) 4) 0)
6008 ((< (window-height) 7) 1)
6009 (t (if (numberp gnus-auto-center-summary)
6010 gnus-auto-center-summary
6012 (height (1- (window-height)))
6013 (bottom (save-excursion (goto-char (point-max))
6014 (forward-line (- height))
6016 (window (get-buffer-window (current-buffer))))
6017 ;; The user has to want it.
6018 (when gnus-auto-center-summary
6019 (when (get-buffer-window gnus-article-buffer)
6020 ;; Only do recentering when the article buffer is displayed,
6021 ;; Set the window start to either `bottom', which is the biggest
6022 ;; possible valid number, or the second line from the top,
6023 ;; whichever is the least.
6024 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6025 (if (> bottom top-pos)
6026 ;; Keep the second line from the top visible
6027 (set-window-start window top-pos t)
6028 ;; Try to keep the bottom line visible; if it's partially
6029 ;; obscured, either scroll one more line to make it fully
6030 ;; visible, or revert to using TOP-POS.
6032 (goto-char (point-max))
6034 (let ((last-line-start (point)))
6036 (set-window-start window (point) t)
6037 (when (not (pos-visible-in-window-p last-line-start window))
6039 (set-window-start window (min (point) top-pos) t)))))))
6040 ;; Do horizontal recentering while we're at it.
6041 (when (and (get-buffer-window (current-buffer) t)
6042 (not (eq gnus-auto-center-summary 'vertical)))
6043 (let ((selected (selected-window)))
6044 (select-window (get-buffer-window (current-buffer) t))
6045 (gnus-summary-position-point)
6046 (gnus-horizontal-recenter)
6047 (select-window selected))))))
6049 (defun gnus-summary-jump-to-group (newsgroup)
6050 "Move point to NEWSGROUP in group mode buffer."
6051 ;; Keep update point of group mode buffer if visible.
6052 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6053 (save-window-excursion
6054 ;; Take care of tree window mode.
6055 (when (get-buffer-window gnus-group-buffer)
6056 (pop-to-buffer gnus-group-buffer))
6057 (gnus-group-jump-to-group newsgroup))
6059 ;; Take care of tree window mode.
6060 (if (get-buffer-window gnus-group-buffer)
6061 (pop-to-buffer gnus-group-buffer)
6062 (set-buffer gnus-group-buffer))
6063 (gnus-group-jump-to-group newsgroup))))
6065 ;; This function returns a list of article numbers based on the
6066 ;; difference between the ranges of read articles in this group and
6067 ;; the range of active articles.
6068 (defun gnus-list-of-unread-articles (group)
6069 (let* ((read (gnus-info-read (gnus-get-info group)))
6070 (active (or (gnus-active group) (gnus-activate-group group)))
6073 ;; If none are read, then all are unread.
6075 (setq first (car active))
6076 ;; If the range of read articles is a single range, then the
6077 ;; first unread article is the article after the last read
6078 ;; article. Sounds logical, doesn't it?
6079 (if (and (not (listp (cdr read)))
6080 (or (< (car read) (car active))
6081 (progn (setq read (list read))
6083 (setq first (max (car active) (1+ (cdr read))))
6084 ;; `read' is a list of ranges.
6085 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6088 (setq first (car active)))
6091 (while (< first nlast)
6093 (setq first (1+ first))))
6094 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6095 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6096 (setq read (cdr read)))))
6097 ;; And add the last unread articles.
6098 (while (<= first last)
6100 (setq first (1+ first)))
6101 ;; Return the list of unread articles.
6102 (delq 0 (nreverse unread))))
6104 (defun gnus-list-of-read-articles (group)
6105 "Return a list of unread, unticked and non-dormant articles."
6106 (let* ((info (gnus-get-info group))
6107 (marked (gnus-info-marks info))
6108 (active (gnus-active group)))
6110 (gnus-list-range-difference
6111 (gnus-list-range-difference
6112 (gnus-sorted-complement
6113 (gnus-uncompress-range active)
6114 (gnus-list-of-unread-articles group))
6115 (cdr (assq 'dormant marked)))
6116 (cdr (assq 'tick marked))))))
6118 ;; Various summary commands
6120 (defun gnus-summary-select-article-buffer ()
6121 "Reconfigure windows to show article buffer."
6123 (if (not (gnus-buffer-live-p gnus-article-buffer))
6124 (error "There is no article buffer for this summary buffer")
6125 (gnus-configure-windows 'article)
6126 (select-window (get-buffer-window gnus-article-buffer))))
6128 (defun gnus-summary-universal-argument (arg)
6129 "Perform any operation on all articles that are process/prefixed."
6131 (let ((articles (gnus-summary-work-articles arg))
6138 (substitute-command-keys
6139 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6141 (gnus-error 1 "Undefined key")
6144 (gnus-summary-goto-subject (setq article (pop articles)))
6145 (let (gnus-newsgroup-processable)
6146 (command-execute func))
6147 (gnus-summary-remove-process-mark article)))))
6148 (gnus-summary-position-point))
6150 (defun gnus-summary-toggle-truncation (&optional arg)
6151 "Toggle truncation of summary lines.
6152 With arg, turn line truncation on if arg is positive."
6154 (setq truncate-lines
6155 (if (null arg) (not truncate-lines)
6156 (> (prefix-numeric-value arg) 0)))
6159 (defun gnus-summary-find-uncancelled ()
6160 "Return the number of an uncancelled article.
6161 The current article is considered, then following articles, then previous
6162 articles. If all articles are cancelled then return a dummy 0."
6164 (dolist (rev '(nil t))
6165 (unless found ; don't demand the reverse list if we don't need it
6166 (let ((data (gnus-data-find-list
6167 (gnus-summary-article-number) (gnus-data-list rev))))
6168 (while (and data (not found))
6169 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6170 (setq found (gnus-data-number (car data))))
6171 (setq data (cdr data))))))
6174 (defun gnus-summary-reselect-current-group (&optional all rescan)
6175 "Exit and then reselect the current newsgroup.
6176 The prefix argument ALL means to select all articles."
6178 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6179 (error "Ephemeral groups can't be reselected"))
6180 (let ((current-subject (gnus-summary-find-uncancelled))
6181 (group gnus-newsgroup-name))
6182 (setq gnus-newsgroup-begin nil)
6184 ;; We have to adjust the point of group mode buffer because
6185 ;; point was moved to the next unread newsgroup by exiting.
6186 (gnus-summary-jump-to-group group)
6189 (gnus-group-get-new-news-this-group 1)))
6190 (gnus-group-read-group all t)
6191 (gnus-summary-goto-subject current-subject nil t)))
6193 (defun gnus-summary-rescan-group (&optional all)
6194 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6196 (gnus-summary-reselect-current-group all t))
6198 (defun gnus-summary-update-info (&optional non-destructive)
6200 (let ((group gnus-newsgroup-name))
6202 (when gnus-newsgroup-kill-headers
6203 (setq gnus-newsgroup-killed
6204 (gnus-compress-sequence
6206 (gnus-list-range-intersection
6207 gnus-newsgroup-unselected gnus-newsgroup-killed)
6208 gnus-newsgroup-unreads)
6210 (unless (listp (cdr gnus-newsgroup-killed))
6211 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6212 (let ((headers gnus-newsgroup-headers))
6213 ;; Set the new ranges of read articles.
6215 (set-buffer gnus-group-buffer)
6216 (gnus-undo-force-boundary))
6217 (gnus-update-read-articles
6218 group (gnus-sorted-union
6219 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6220 ;; Set the current article marks.
6221 (let ((gnus-newsgroup-scored
6222 (if (and (not gnus-save-score)
6223 (not non-destructive))
6225 gnus-newsgroup-scored)))
6227 (gnus-update-marks)))
6228 ;; Do the cross-ref thing.
6229 (when gnus-use-cross-reference
6230 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6231 ;; Do not switch windows but change the buffer to work.
6232 (set-buffer gnus-group-buffer)
6233 (unless (gnus-ephemeral-group-p group)
6234 (gnus-group-update-group group)))))))
6236 (defun gnus-summary-save-newsrc (&optional force)
6237 "Save the current number of read/marked articles in the dribble buffer.
6238 The dribble buffer will then be saved.
6239 If FORCE (the prefix), also save the .newsrc file(s)."
6241 (gnus-summary-update-info t)
6243 (gnus-save-newsrc-file)
6244 (gnus-dribble-save)))
6246 (defun gnus-summary-exit (&optional temporary)
6247 "Exit reading current newsgroup, and then return to group selection mode.
6248 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6250 (gnus-set-global-variables)
6251 (when (gnus-buffer-live-p gnus-article-buffer)
6253 (set-buffer gnus-article-buffer)
6254 (mm-destroy-parts gnus-article-mime-handles)
6255 ;; Set it to nil for safety reason.
6256 (setq gnus-article-mime-handle-alist nil)
6257 (setq gnus-article-mime-handles nil)))
6258 (gnus-kill-save-kill-buffer)
6259 (gnus-async-halt-prefetch)
6260 (let* ((group gnus-newsgroup-name)
6261 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6264 (buf (current-buffer)))
6266 ;; Do adaptive scoring, and possibly save score files.
6267 (when gnus-newsgroup-adaptive
6268 (gnus-score-adaptive))
6269 (when gnus-use-scoring
6271 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6272 ;; If we have several article buffers, we kill them at exit.
6273 (unless gnus-single-article-buffer
6274 (gnus-kill-buffer gnus-original-article-buffer)
6275 (setq gnus-article-current nil))
6276 (when gnus-use-cache
6277 (gnus-cache-possibly-remove-articles)
6278 (gnus-cache-save-buffers))
6279 (gnus-async-prefetch-remove-group group)
6280 (when gnus-suppress-duplicates
6281 (gnus-dup-enter-articles))
6282 (when gnus-use-trees
6283 (gnus-tree-close group))
6284 (when gnus-use-cache
6285 (gnus-cache-write-active))
6286 ;; Remove entries for this group.
6287 (nnmail-purge-split-history (gnus-group-real-name group))
6288 ;; Make all changes in this group permanent.
6290 (gnus-run-hooks 'gnus-exit-group-hook)
6291 (gnus-summary-update-info))
6292 (gnus-close-group group)
6293 ;; Make sure where we were, and go to next newsgroup.
6294 (set-buffer gnus-group-buffer)
6296 (gnus-group-jump-to-group group))
6297 (gnus-run-hooks 'gnus-summary-exit-hook)
6298 (unless (or quit-config
6299 ;; If this group has disappeared from the summary
6300 ;; buffer, don't skip forwards.
6301 (not (string= group (gnus-group-group-name))))
6302 (gnus-group-next-unread-group 1))
6303 (setq group-point (point))
6306 ;; If we have several article buffers, we kill them at exit.
6307 (unless gnus-single-article-buffer
6308 (gnus-kill-buffer gnus-article-buffer)
6309 (gnus-kill-buffer gnus-original-article-buffer)
6310 (setq gnus-article-current nil))
6312 (if (not gnus-kill-summary-on-exit)
6314 (gnus-deaden-summary)
6316 ;; We set all buffer-local variables to nil. It is unclear why
6317 ;; this is needed, but if we don't, buffer-local variables are
6318 ;; not garbage-collected, it seems. This would the lead to en
6319 ;; ever-growing Emacs.
6320 (gnus-summary-clear-local-variables)
6321 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6322 (gnus-summary-clear-local-variables))
6323 (when (get-buffer gnus-article-buffer)
6324 (bury-buffer gnus-article-buffer))
6325 ;; We clear the global counterparts of the buffer-local
6326 ;; variables as well, just to be on the safe side.
6327 (set-buffer gnus-group-buffer)
6328 (gnus-summary-clear-local-variables)
6329 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6330 (gnus-summary-clear-local-variables)))
6331 (setq gnus-current-select-method gnus-select-method)
6332 (pop-to-buffer gnus-group-buffer)
6333 (if (not quit-config)
6335 (goto-char group-point)
6336 (gnus-configure-windows 'group 'force))
6337 (gnus-handle-ephemeral-exit quit-config))
6338 ;; Return to group mode buffer.
6339 (when (eq mode 'gnus-summary-mode)
6340 (gnus-kill-buffer buf))
6341 ;; Clear the current group name.
6343 (setq gnus-newsgroup-name nil)))))
6345 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6346 (defun gnus-summary-exit-no-update (&optional no-questions)
6347 "Quit reading current newsgroup without updating read article info."
6349 (let* ((group gnus-newsgroup-name)
6350 (quit-config (gnus-group-quit-config group)))
6351 (when (or no-questions
6353 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6354 (gnus-async-halt-prefetch)
6356 (delq 'gnus-summary-expire-articles
6357 (copy-sequence gnus-summary-prepare-exit-hook)))
6358 (when (gnus-buffer-live-p gnus-article-buffer)
6360 (set-buffer gnus-article-buffer)
6361 (mm-destroy-parts gnus-article-mime-handles)
6362 ;; Set it to nil for safety reason.
6363 (setq gnus-article-mime-handle-alist nil)
6364 (setq gnus-article-mime-handles nil)))
6365 ;; If we have several article buffers, we kill them at exit.
6366 (unless gnus-single-article-buffer
6367 (gnus-kill-buffer gnus-article-buffer)
6368 (gnus-kill-buffer gnus-original-article-buffer)
6369 (setq gnus-article-current nil))
6370 (if (not gnus-kill-summary-on-exit)
6371 (gnus-deaden-summary)
6372 (gnus-close-group group)
6373 (gnus-summary-clear-local-variables)
6374 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6375 (gnus-summary-clear-local-variables))
6376 (set-buffer gnus-group-buffer)
6377 (gnus-summary-clear-local-variables)
6378 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6379 (gnus-summary-clear-local-variables))
6380 (when (get-buffer gnus-summary-buffer)
6381 (kill-buffer gnus-summary-buffer)))
6382 (unless gnus-single-article-buffer
6383 (setq gnus-article-current nil))
6384 (when gnus-use-trees
6385 (gnus-tree-close group))
6386 (gnus-async-prefetch-remove-group group)
6387 (when (get-buffer gnus-article-buffer)
6388 (bury-buffer gnus-article-buffer))
6389 ;; Return to the group buffer.
6390 (gnus-configure-windows 'group 'force)
6391 ;; Clear the current group name.
6392 (setq gnus-newsgroup-name nil)
6393 (when (equal (gnus-group-group-name) group)
6394 (gnus-group-next-unread-group 1))
6396 (gnus-handle-ephemeral-exit quit-config)))))
6398 (defun gnus-handle-ephemeral-exit (quit-config)
6399 "Handle movement when leaving an ephemeral group.
6400 The state which existed when entering the ephemeral is reset."
6401 (if (not (buffer-name (car quit-config)))
6402 (gnus-configure-windows 'group 'force)
6403 (set-buffer (car quit-config))
6404 (cond ((eq major-mode 'gnus-summary-mode)
6405 (gnus-set-global-variables))
6406 ((eq major-mode 'gnus-article-mode)
6408 ;; The `gnus-summary-buffer' variable may point
6409 ;; to the old summary buffer when using a single
6411 (unless (gnus-buffer-live-p gnus-summary-buffer)
6412 (set-buffer gnus-group-buffer))
6413 (set-buffer gnus-summary-buffer)
6414 (gnus-set-global-variables))))
6415 (if (or (eq (cdr quit-config) 'article)
6416 (eq (cdr quit-config) 'pick))
6418 ;; The current article may be from the ephemeral group
6419 ;; thus it is best that we reload this article
6420 (gnus-summary-show-article)
6421 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6422 (gnus-configure-windows 'pick 'force)
6423 (gnus-configure-windows (cdr quit-config) 'force)))
6424 (gnus-configure-windows (cdr quit-config) 'force))
6425 (when (eq major-mode 'gnus-summary-mode)
6426 (gnus-summary-next-subject 1 nil t)
6427 (gnus-summary-recenter)
6428 (gnus-summary-position-point))))
6432 (defvar gnus-dead-summary-mode-map nil)
6434 (unless gnus-dead-summary-mode-map
6435 (setq gnus-dead-summary-mode-map (make-keymap))
6436 (suppress-keymap gnus-dead-summary-mode-map)
6437 (substitute-key-definition
6438 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6439 (dolist (key '("\C-d" "\r" "\177" [delete]))
6440 (define-key gnus-dead-summary-mode-map
6441 key 'gnus-summary-wake-up-the-dead))
6442 (dolist (key '("q" "Q"))
6443 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6445 (defvar gnus-dead-summary-mode nil
6446 "Minor mode for Gnus summary buffers.")
6448 (defun gnus-dead-summary-mode (&optional arg)
6449 "Minor mode for Gnus summary buffers."
6451 (when (eq major-mode 'gnus-summary-mode)
6452 (make-local-variable 'gnus-dead-summary-mode)
6453 (setq gnus-dead-summary-mode
6454 (if (null arg) (not gnus-dead-summary-mode)
6455 (> (prefix-numeric-value arg) 0)))
6456 (when gnus-dead-summary-mode
6457 (gnus-add-minor-mode
6458 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6460 (defun gnus-deaden-summary ()
6461 "Make the current summary buffer into a dead summary buffer."
6462 ;; Kill any previous dead summary buffer.
6463 (when (and gnus-dead-summary
6464 (buffer-name gnus-dead-summary))
6466 (set-buffer gnus-dead-summary)
6467 (when gnus-dead-summary-mode
6468 (kill-buffer (current-buffer)))))
6469 ;; Make this the current dead summary.
6470 (setq gnus-dead-summary (current-buffer))
6471 (gnus-dead-summary-mode 1)
6472 (let ((name (buffer-name)))
6473 (when (string-match "Summary" name)
6475 (concat (substring name 0 (match-beginning 0)) "Dead "
6476 (substring name (match-beginning 0)))
6480 (defun gnus-kill-or-deaden-summary (buffer)
6481 "Kill or deaden the summary BUFFER."
6483 (when (and (buffer-name buffer)
6484 (not gnus-single-article-buffer))
6487 (gnus-kill-buffer gnus-article-buffer)
6488 (gnus-kill-buffer gnus-original-article-buffer)))
6491 (gnus-kill-summary-on-exit
6492 (when (and gnus-use-trees
6493 (gnus-buffer-exists-p buffer))
6496 (gnus-tree-close gnus-newsgroup-name)))
6497 (gnus-kill-buffer buffer))
6498 ;; Deaden the buffer.
6499 ((gnus-buffer-exists-p buffer)
6502 (gnus-deaden-summary))))))
6504 (defun gnus-summary-wake-up-the-dead (&rest args)
6505 "Wake up the dead summary buffer."
6507 (gnus-dead-summary-mode -1)
6508 (let ((name (buffer-name)))
6509 (when (string-match "Dead " name)
6511 (concat (substring name 0 (match-beginning 0))
6512 (substring name (match-end 0)))
6514 (gnus-message 3 "This dead summary is now alive again"))
6516 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6517 (defun gnus-summary-fetch-faq (&optional faq-dir)
6518 "Fetch the FAQ for the current group.
6519 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6523 (when current-prefix-arg
6525 "FAQ dir: " (and (listp gnus-group-faq-directory)
6526 (mapcar (lambda (file) (list file))
6527 gnus-group-faq-directory))))))
6528 (let (gnus-faq-buffer)
6529 (when (setq gnus-faq-buffer
6530 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6531 (gnus-configure-windows 'summary-faq))))
6533 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6534 (defun gnus-summary-describe-group (&optional force)
6535 "Describe the current newsgroup."
6537 (gnus-group-describe-group force gnus-newsgroup-name))
6539 (defun gnus-summary-describe-briefly ()
6540 "Describe summary mode commands briefly."
6542 (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")))
6544 ;; Walking around group mode buffer from summary mode.
6546 (defun gnus-summary-next-group (&optional no-article target-group backward)
6547 "Exit current newsgroup and then select next unread newsgroup.
6548 If prefix argument NO-ARTICLE is non-nil, no article is selected
6549 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6550 previous group instead."
6552 ;; Stop pre-fetching.
6553 (gnus-async-halt-prefetch)
6554 (let ((current-group gnus-newsgroup-name)
6555 (current-buffer (current-buffer))
6557 (while (not entered)
6558 ;; Then we find what group we are supposed to enter.
6559 (set-buffer gnus-group-buffer)
6560 (gnus-group-jump-to-group current-group)
6563 (if (eq gnus-keep-same-level 'best)
6564 (gnus-summary-best-group gnus-newsgroup-name)
6565 (gnus-summary-search-group backward gnus-keep-same-level))))
6566 (if (not target-group)
6567 ;; There are no further groups, so we return to the group
6570 (gnus-message 5 "Returning to the group buffer")
6572 (when (gnus-buffer-live-p current-buffer)
6573 (set-buffer current-buffer)
6574 (gnus-summary-exit))
6575 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6576 ;; We try to enter the target group.
6577 (gnus-group-jump-to-group target-group)
6578 (let ((unreads (gnus-group-group-unread)))
6579 (if (and (or (eq t unreads)
6580 (and unreads (not (zerop unreads))))
6582 ;; Now we semi-exit this group to update Xrefs
6583 ;; and all variables. We can't do a real exit,
6584 ;; because the window conf must remain the same
6585 ;; in case the user is prompted for info, and we
6586 ;; don't want the window conf to change before
6588 (when (gnus-buffer-live-p current-buffer)
6589 (set-buffer current-buffer)
6590 (gnus-summary-exit t))
6591 (gnus-summary-read-group
6592 target-group nil no-article
6593 (and (buffer-name current-buffer) current-buffer)
6596 (setq current-group target-group
6597 target-group nil)))))))
6599 (defun gnus-summary-prev-group (&optional no-article)
6600 "Exit current newsgroup and then select previous unread newsgroup.
6601 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6603 (gnus-summary-next-group no-article nil t))
6605 ;; Walking around summary lines.
6607 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6608 "Go to the first unread subject.
6609 If UNREAD is non-nil, go to the first unread article.
6610 Returns the article selected or nil if there are no unread articles."
6615 ((null gnus-newsgroup-data)
6616 (gnus-message 3 "No articles in the group")
6618 ;; Pick the first article.
6620 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6621 (gnus-data-number (car gnus-newsgroup-data)))
6622 ;; No unread articles.
6623 ((null gnus-newsgroup-unreads)
6624 (gnus-message 3 "No more unread articles")
6626 ;; Find the first unread article.
6628 (let ((data gnus-newsgroup-data))
6630 (and (not (and undownloaded
6631 (eq gnus-undownloaded-mark
6632 (gnus-data-mark (car data)))))
6635 (gnus-data-number (car data))
6636 gnus-newsgroup-unseen))
6637 (not (gnus-data-unread-p (car data))))
6638 (not (gnus-data-unread-p (car data))))))
6639 (setq data (cdr data)))
6641 (goto-char (gnus-data-pos (car data)))
6642 (gnus-data-number (car data))))))
6643 (gnus-summary-position-point)))
6645 (defun gnus-summary-next-subject (n &optional unread dont-display)
6646 "Go to next N'th summary line.
6647 If N is negative, go to the previous N'th subject line.
6648 If UNREAD is non-nil, only unread articles are selected.
6649 The difference between N and the actual number of steps taken is
6652 (let ((backward (< n 0))
6656 (gnus-summary-find-prev unread)
6657 (gnus-summary-find-next unread)))
6658 (unless (zerop (setq n (1- n)))
6659 (gnus-summary-show-thread)))
6661 (gnus-message 7 "No more%s articles"
6662 (if unread " unread" "")))
6663 (unless dont-display
6664 (gnus-summary-recenter)
6665 (gnus-summary-position-point))
6668 (defun gnus-summary-next-unread-subject (n)
6669 "Go to next N'th unread summary line."
6671 (gnus-summary-next-subject n t))
6673 (defun gnus-summary-prev-subject (n &optional unread)
6674 "Go to previous N'th summary line.
6675 If optional argument UNREAD is non-nil, only unread article is selected."
6677 (gnus-summary-next-subject (- n) unread))
6679 (defun gnus-summary-prev-unread-subject (n)
6680 "Go to previous N'th unread summary line."
6682 (gnus-summary-next-subject (- n) t))
6684 (defun gnus-summary-goto-subject (article &optional force silent)
6685 "Go the subject line of ARTICLE.
6686 If FORCE, also allow jumping to articles not currently shown."
6687 (interactive "nArticle number: ")
6688 (unless (numberp article)
6689 (error "Article %s is not a number" article))
6691 (data (gnus-data-find article)))
6692 ;; We read in the article if we have to.
6695 (gnus-summary-insert-subject
6697 (if (or (numberp force) (vectorp force)) force)
6699 (setq data (gnus-data-find article)))
6704 (gnus-message 3 "Can't find article %d" article))
6706 (let ((pt (gnus-data-pos data)))
6708 (gnus-summary-set-article-display-arrow pt))
6709 (gnus-summary-position-point)
6712 ;; Walking around summary lines with displaying articles.
6714 (defun gnus-summary-expand-window (&optional arg)
6715 "Make the summary buffer take up the entire Emacs frame.
6716 Given a prefix, will force an `article' buffer configuration."
6719 (gnus-configure-windows 'article 'force)
6720 (gnus-configure-windows 'summary 'force)))
6722 (defun gnus-summary-display-article (article &optional all-header)
6723 "Display ARTICLE in article buffer."
6724 (when (gnus-buffer-live-p gnus-article-buffer)
6725 (with-current-buffer gnus-article-buffer
6726 (mm-enable-multibyte)))
6727 (gnus-set-global-variables)
6728 (when (gnus-buffer-live-p gnus-article-buffer)
6729 (with-current-buffer gnus-article-buffer
6730 (setq gnus-article-charset gnus-newsgroup-charset)
6731 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6732 (mm-enable-multibyte)))
6736 (if gnus-summary-display-article-function
6737 (funcall gnus-summary-display-article-function article all-header)
6738 (gnus-article-prepare article all-header))
6739 (gnus-run-hooks 'gnus-select-article-hook)
6740 (when (and gnus-current-article
6741 (not (zerop gnus-current-article)))
6742 (gnus-summary-goto-subject gnus-current-article))
6743 (gnus-summary-recenter)
6744 (when (and gnus-use-trees gnus-show-threads)
6745 (gnus-possibly-generate-tree article)
6746 (gnus-highlight-selected-tree article))
6747 ;; Successfully display article.
6748 (gnus-article-set-window-start
6749 (cdr (assq article gnus-newsgroup-bookmarks))))))
6751 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6752 "Select the current article.
6753 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6754 non-nil, the article will be re-fetched even if it already present in
6755 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6757 ;; Make sure we are in the summary buffer to work around bbdb bug.
6758 (unless (eq major-mode 'gnus-summary-mode)
6759 (set-buffer gnus-summary-buffer))
6760 (let ((article (or article (gnus-summary-article-number)))
6761 (all-headers (not (not all-headers))) ;Must be t or nil.
6762 gnus-summary-display-article-function)
6764 (gnus-summary-article-pseudo-p article)
6765 (error "This is a pseudo-article"))
6767 (set-buffer gnus-summary-buffer)
6768 (if (or (and gnus-single-article-buffer
6769 (or (null gnus-current-article)
6770 (null gnus-article-current)
6771 (null (get-buffer gnus-article-buffer))
6772 (not (eq article (cdr gnus-article-current)))
6773 (not (equal (car gnus-article-current)
6774 gnus-newsgroup-name))))
6775 (and (not gnus-single-article-buffer)
6776 (or (null gnus-current-article)
6777 (not (eq gnus-current-article article))))
6779 ;; The requested article is different from the current article.
6781 (gnus-summary-display-article article all-headers)
6782 (when (gnus-buffer-live-p gnus-article-buffer)
6783 (with-current-buffer gnus-article-buffer
6784 (if (not gnus-article-decoded-p) ;; a local variable
6785 (mm-disable-multibyte))))
6786 (gnus-article-set-window-start
6787 (cdr (assq article gnus-newsgroup-bookmarks)))
6791 (defun gnus-summary-force-verify-and-decrypt ()
6793 (let ((mm-verify-option 'known)
6794 (mm-decrypt-option 'known)
6795 (gnus-buttonized-mime-types (append (list "multipart/signed"
6796 "multipart/encrypted")
6797 gnus-buttonized-mime-types)))
6798 (gnus-summary-select-article nil 'force)))
6800 (defun gnus-summary-set-current-mark (&optional current-mark)
6801 "Obsolete function."
6804 (defun gnus-summary-next-article (&optional unread subject backward push)
6805 "Select the next article.
6806 If UNREAD, only unread articles are selected.
6807 If SUBJECT, only articles with SUBJECT are selected.
6808 If BACKWARD, the previous article is selected instead of the next."
6811 ;; Is there such an article?
6812 ((and (gnus-summary-search-forward unread subject backward)
6813 (or (gnus-summary-display-article (gnus-summary-article-number))
6814 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6815 (gnus-summary-position-point))
6816 ;; If not, we try the first unread, if that is wanted.
6818 gnus-auto-select-same
6819 (gnus-summary-first-unread-article))
6820 (gnus-summary-position-point)
6821 (gnus-message 6 "Wrapped"))
6822 ;; Try to get next/previous article not displayed in this group.
6823 ((and gnus-auto-extend-newsgroup
6824 (not unread) (not subject))
6825 (gnus-summary-goto-article
6826 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6827 nil (count-lines (point-min) (point))))
6828 ;; Go to next/previous group.
6830 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6831 (gnus-summary-jump-to-group gnus-newsgroup-name))
6832 (let ((cmd last-command-char)
6835 (set-buffer gnus-group-buffer)
6838 (if (eq gnus-keep-same-level 'best)
6839 (gnus-summary-best-group gnus-newsgroup-name)
6840 (gnus-summary-search-group backward gnus-keep-same-level))))
6841 ;; For some reason, the group window gets selected. We change
6843 (select-window (get-buffer-window (current-buffer)))
6844 ;; Select next unread newsgroup automagically.
6846 ((or (not gnus-auto-select-next)
6848 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6849 ((or (eq gnus-auto-select-next 'quietly)
6850 (and (eq gnus-auto-select-next 'slightly-quietly)
6852 (and (eq gnus-auto-select-next 'almost-quietly)
6853 (gnus-summary-last-article-p)))
6855 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6857 (gnus-message 7 "No more%s articles (%s)..."
6858 (if unread " unread" "")
6859 (if group (concat "selecting " group)
6861 (gnus-summary-next-group nil group backward)))
6863 (when (gnus-key-press-event-p last-input-event)
6864 (gnus-summary-walk-group-buffer
6865 gnus-newsgroup-name cmd unread backward point))))))))
6867 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6868 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6869 (?\C-p (gnus-group-prev-unread-group 1))))
6870 (cursor-in-echo-area t)
6871 keve key group ended)
6873 (set-buffer gnus-group-buffer)
6876 (if (eq gnus-keep-same-level 'best)
6877 (gnus-summary-best-group gnus-newsgroup-name)
6878 (gnus-summary-search-group backward gnus-keep-same-level))))
6881 5 "No more%s articles%s" (if unread " unread" "")
6883 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6884 (format " (Type %s for %s [%s])"
6885 (single-key-description cmd) group
6886 (car (gnus-gethash group gnus-newsrc-hashtb)))
6887 (format " (Type %s to exit %s)"
6888 (single-key-description cmd)
6889 gnus-newsgroup-name)))
6890 ;; Confirm auto selection.
6891 (setq key (car (setq keve (gnus-read-event-char))))
6894 ((assq key keystrokes)
6895 (let ((obuf (current-buffer)))
6896 (switch-to-buffer gnus-group-buffer)
6898 (gnus-group-jump-to-group group))
6899 (eval (cadr (assq key keystrokes)))
6900 (setq group (gnus-group-group-name))
6901 (switch-to-buffer obuf))
6905 (gnus-ephemeral-group-p gnus-newsgroup-name))
6907 (gnus-summary-next-group nil group backward)))
6909 (push (cdr keve) unread-command-events))))))
6911 (defun gnus-summary-next-unread-article ()
6912 "Select unread article after current one."
6914 (gnus-summary-next-article
6915 (or (not (eq gnus-summary-goto-unread 'never))
6916 (gnus-summary-last-article-p (gnus-summary-article-number)))
6917 (and gnus-auto-select-same
6918 (gnus-summary-article-subject))))
6920 (defun gnus-summary-prev-article (&optional unread subject)
6921 "Select the article after the current one.
6922 If UNREAD is non-nil, only unread articles are selected."
6924 (gnus-summary-next-article unread subject t))
6926 (defun gnus-summary-prev-unread-article ()
6927 "Select unread article before current one."
6929 (gnus-summary-prev-article
6930 (or (not (eq gnus-summary-goto-unread 'never))
6931 (gnus-summary-first-article-p (gnus-summary-article-number)))
6932 (and gnus-auto-select-same
6933 (gnus-summary-article-subject))))
6935 (defun gnus-summary-next-page (&optional lines circular)
6936 "Show next page of the selected article.
6937 If at the end of the current article, select the next article.
6938 LINES says how many lines should be scrolled up.
6940 If CIRCULAR is non-nil, go to the start of the article instead of
6941 selecting the next article when reaching the end of the current
6944 (setq gnus-summary-buffer (current-buffer))
6945 (gnus-set-global-variables)
6946 (let ((article (gnus-summary-article-number))
6947 (article-window (get-buffer-window gnus-article-buffer t))
6949 ;; If the buffer is empty, we have no article.
6951 (error "No article to select"))
6952 (gnus-configure-windows 'article)
6953 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6954 (if (and (eq gnus-summary-goto-unread 'never)
6955 (not (gnus-summary-last-article-p article)))
6956 (gnus-summary-next-article)
6957 (gnus-summary-next-unread-article))
6958 (if (or (null gnus-current-article)
6959 (null gnus-article-current)
6960 (/= article (cdr gnus-article-current))
6961 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6962 ;; Selected subject is different from current article's.
6963 (gnus-summary-display-article article)
6964 (when article-window
6965 (gnus-eval-in-buffer-window gnus-article-buffer
6966 (setq endp (gnus-article-next-page lines)))
6969 (gnus-summary-beginning-of-article))
6971 (gnus-message 3 "End of message"))
6973 (if (and (eq gnus-summary-goto-unread 'never)
6974 (not (gnus-summary-last-article-p article)))
6975 (gnus-summary-next-article)
6976 (gnus-summary-next-unread-article))))))))
6977 (gnus-summary-recenter)
6978 (gnus-summary-position-point)))
6980 (defun gnus-summary-prev-page (&optional lines move)
6981 "Show previous page of selected article.
6982 Argument LINES specifies lines to be scrolled down.
6983 If MOVE, move to the previous unread article if point is at
6984 the beginning of the buffer."
6986 (let ((article (gnus-summary-article-number))
6987 (article-window (get-buffer-window gnus-article-buffer t))
6989 (gnus-configure-windows 'article)
6990 (if (or (null gnus-current-article)
6991 (null gnus-article-current)
6992 (/= article (cdr gnus-article-current))
6993 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6994 ;; Selected subject is different from current article's.
6995 (gnus-summary-display-article article)
6996 (gnus-summary-recenter)
6997 (when article-window
6998 (gnus-eval-in-buffer-window gnus-article-buffer
6999 (setq endp (gnus-article-prev-page lines)))
7000 (when (and move endp)
7002 (gnus-message 3 "Beginning of message"))
7004 (if (and (eq gnus-summary-goto-unread 'never)
7005 (not (gnus-summary-first-article-p article)))
7006 (gnus-summary-prev-article)
7007 (gnus-summary-prev-unread-article))))))))
7008 (gnus-summary-position-point))
7010 (defun gnus-summary-prev-page-or-article (&optional lines)
7011 "Show previous page of selected article.
7012 Argument LINES specifies lines to be scrolled down.
7013 If at the beginning of the article, go to the next article."
7015 (gnus-summary-prev-page lines t))
7017 (defun gnus-summary-scroll-up (lines)
7018 "Scroll up (or down) one line current article.
7019 Argument LINES specifies lines to be scrolled up (or down if negative)."
7021 (gnus-configure-windows 'article)
7022 (gnus-summary-show-thread)
7023 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7024 (gnus-eval-in-buffer-window gnus-article-buffer
7026 (when (gnus-article-next-page lines)
7027 (gnus-message 3 "End of message")))
7029 (gnus-article-prev-page (- lines))))))
7030 (gnus-summary-recenter)
7031 (gnus-summary-position-point))
7033 (defun gnus-summary-scroll-down (lines)
7034 "Scroll down (or up) one line current article.
7035 Argument LINES specifies lines to be scrolled down (or up if negative)."
7037 (gnus-summary-scroll-up (- lines)))
7039 (defun gnus-summary-next-same-subject ()
7040 "Select next article which has the same subject as current one."
7042 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7044 (defun gnus-summary-prev-same-subject ()
7045 "Select previous article which has the same subject as current one."
7047 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7049 (defun gnus-summary-next-unread-same-subject ()
7050 "Select next unread article which has the same subject as current one."
7052 (gnus-summary-next-article t (gnus-summary-article-subject)))
7054 (defun gnus-summary-prev-unread-same-subject ()
7055 "Select previous unread article which has the same subject as current one."
7057 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7059 (defun gnus-summary-first-unread-article ()
7060 "Select the first unread article.
7061 Return nil if there are no unread articles."
7064 (when (gnus-summary-first-subject t)
7065 (gnus-summary-show-thread)
7066 (gnus-summary-first-subject t)
7067 (gnus-summary-display-article (gnus-summary-article-number)))
7068 (gnus-summary-position-point)))
7070 (defun gnus-summary-first-unread-subject ()
7071 "Place the point on the subject line of the first unread article.
7072 Return nil if there are no unread articles."
7075 (when (gnus-summary-first-subject t)
7076 (gnus-summary-show-thread)
7077 (gnus-summary-first-subject t))
7078 (gnus-summary-position-point)))
7080 (defun gnus-summary-first-unseen-subject ()
7081 "Place the point on the subject line of the first unseen article.
7082 Return nil if there are no unseen articles."
7085 (when (gnus-summary-first-subject t t t)
7086 (gnus-summary-show-thread)
7087 (gnus-summary-first-subject t t t))
7088 (gnus-summary-position-point)))
7090 (defun gnus-summary-first-unseen-or-unread-subject ()
7091 "Place the point on the subject line of the first unseen article.
7092 Return nil if there are no unseen articles."
7095 (unless (when (gnus-summary-first-subject t t t)
7096 (gnus-summary-show-thread)
7097 (gnus-summary-first-subject t t t))
7098 (when (gnus-summary-first-subject t)
7099 (gnus-summary-show-thread)
7100 (gnus-summary-first-subject t)))
7101 (gnus-summary-position-point)))
7103 (defun gnus-summary-first-article ()
7104 "Select the first article.
7105 Return nil if there are no articles."
7108 (when (gnus-summary-first-subject)
7109 (gnus-summary-show-thread)
7110 (gnus-summary-first-subject)
7111 (gnus-summary-display-article (gnus-summary-article-number)))
7112 (gnus-summary-position-point)))
7114 (defun gnus-summary-best-unread-article (&optional arg)
7115 "Select the unread article with the highest score.
7116 If given a prefix argument, select the next unread article that has a
7117 score higher than the default score."
7119 (let ((article (if arg
7120 (gnus-summary-better-unread-subject)
7121 (gnus-summary-best-unread-subject))))
7123 (gnus-summary-goto-article article)
7124 (error "No unread articles"))))
7126 (defun gnus-summary-best-unread-subject ()
7127 "Select the unread subject with the highest score."
7129 (let ((best -1000000)
7130 (data gnus-newsgroup-data)
7133 (and (gnus-data-unread-p (car data))
7135 (gnus-summary-article-score (gnus-data-number (car data))))
7138 article (gnus-data-number (car data))))
7139 (setq data (cdr data)))
7141 (gnus-summary-goto-subject article))
7142 (gnus-summary-position-point)
7145 (defun gnus-summary-better-unread-subject ()
7146 "Select the first unread subject that has a score over the default score."
7148 (let ((data gnus-newsgroup-data)
7150 (while (and (setq article (gnus-data-number (car data)))
7151 (or (gnus-data-read-p (car data))
7152 (not (> (gnus-summary-article-score article)
7153 gnus-summary-default-score))))
7154 (setq data (cdr data)))
7156 (gnus-summary-goto-subject article))
7157 (gnus-summary-position-point)
7160 (defun gnus-summary-last-subject ()
7161 "Go to the last displayed subject line in the group."
7162 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7164 (gnus-summary-goto-subject article))))
7166 (defun gnus-summary-goto-article (article &optional all-headers force)
7167 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7168 If ALL-HEADERS is non-nil, no header lines are hidden.
7169 If FORCE, go to the article even if it isn't displayed. If FORCE
7170 is a number, it is the line the article is to be displayed on."
7174 "Article number or Message-ID: "
7175 (mapcar (lambda (number) (list (int-to-string number)))
7176 gnus-newsgroup-limit))
7180 (if (and (stringp article)
7181 (string-match "@" article))
7182 (gnus-summary-refer-article article)
7183 (when (stringp article)
7184 (setq article (string-to-number article)))
7185 (if (gnus-summary-goto-subject article force)
7186 (gnus-summary-display-article article all-headers)
7187 (gnus-message 4 "Couldn't go to article %s" article) nil))
7188 (gnus-summary-position-point)))
7190 (defun gnus-summary-goto-last-article ()
7191 "Go to the previously read article."
7194 (when gnus-last-article
7195 (gnus-summary-goto-article gnus-last-article nil t))
7196 (gnus-summary-position-point)))
7198 (defun gnus-summary-pop-article (number)
7199 "Pop one article off the history and go to the previous.
7200 NUMBER articles will be popped off."
7203 (setq gnus-newsgroup-history
7204 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7206 (gnus-summary-goto-article (car to) nil t)
7207 (error "Article history empty")))
7208 (gnus-summary-position-point))
7210 ;; Summary commands and functions for limiting the summary buffer.
7212 (defun gnus-summary-limit-to-articles (n)
7213 "Limit the summary buffer to the next N articles.
7214 If not given a prefix, use the process marked articles instead."
7217 (let ((articles (gnus-summary-work-articles n)))
7218 (setq gnus-newsgroup-processable nil)
7219 (gnus-summary-limit articles))
7220 (gnus-summary-position-point)))
7222 (defun gnus-summary-pop-limit (&optional total)
7223 "Restore the previous limit.
7224 If given a prefix, remove all limits."
7227 (setq gnus-newsgroup-limits
7228 (list (mapcar (lambda (h) (mail-header-number h))
7229 gnus-newsgroup-headers))))
7230 (unless gnus-newsgroup-limits
7231 (error "No limit to pop"))
7233 (gnus-summary-limit nil 'pop)
7234 (gnus-summary-position-point)))
7236 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7237 "Limit the summary buffer to articles that have subjects that match a regexp.
7238 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7240 (list (read-string (if current-prefix-arg
7241 "Exclude subject (regexp): "
7242 "Limit to subject (regexp): "))
7243 nil current-prefix-arg))
7245 (setq header "subject"))
7246 (when (not (equal "" subject))
7248 (let ((articles (gnus-summary-find-matching
7249 (or header "subject") subject 'all nil nil
7252 (error "Found no matches for \"%s\"" subject))
7253 (gnus-summary-limit articles))
7254 (gnus-summary-position-point))))
7256 (defun gnus-summary-limit-to-author (from &optional not-matching)
7257 "Limit the summary buffer to articles that have authors that match a regexp.
7258 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7260 (list (read-string (if current-prefix-arg
7261 "Exclude author (regexp): "
7262 "Limit to author (regexp): "))
7263 current-prefix-arg))
7264 (gnus-summary-limit-to-subject from "from" not-matching))
7266 (defun gnus-summary-limit-to-age (age &optional younger-p)
7267 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7268 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7269 articles that are younger than AGE days."
7271 (let ((younger current-prefix-arg)
7274 (while (not days-got)
7275 (setq days (if younger
7276 (read-string "Limit to articles within (in days): ")
7277 (read-string "Limit to articles older than (in days): ")))
7278 (when (> (length days) 0)
7279 (setq days (read days)))
7285 (setq younger (not younger))
7286 (setq days (* days -1)))))
7287 (message "Please enter a number.")
7289 (list days younger)))
7291 (let ((data gnus-newsgroup-data)
7292 (cutoff (days-to-time age))
7293 articles d date is-younger)
7294 (while (setq d (pop data))
7295 (when (and (vectorp (gnus-data-header d))
7296 (setq date (mail-header-date (gnus-data-header d))))
7297 (setq is-younger (time-less-p
7298 (time-since (condition-case ()
7305 (push (gnus-data-number d) articles))))
7306 (gnus-summary-limit (nreverse articles)))
7307 (gnus-summary-position-point)))
7309 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7310 "Limit the summary buffer to articles that match an 'extra' header."
7314 (gnus-completing-read-with-default
7315 (symbol-name (car gnus-extra-headers))
7316 (if current-prefix-arg
7317 "Exclude extra header:"
7318 "Limit extra header:")
7320 (cons (symbol-name x) x))
7325 (read-string (format "%s header %s (regexp): "
7326 (if current-prefix-arg "Exclude" "Limit to")
7328 current-prefix-arg)))
7329 (when (not (equal "" regexp))
7331 (let ((articles (gnus-summary-find-matching
7332 (cons 'extra header) regexp 'all nil nil
7335 (error "Found no matches for \"%s\"" regexp))
7336 (gnus-summary-limit articles))
7337 (gnus-summary-position-point))))
7339 (defun gnus-summary-limit-to-display-predicate ()
7340 "Limit the summary buffer to the predicated in the `display' group parameter."
7342 (unless gnus-newsgroup-display
7343 (error "There is no `display' group parameter"))
7345 (dolist (number gnus-newsgroup-articles)
7346 (when (funcall gnus-newsgroup-display)
7347 (push number articles)))
7348 (gnus-summary-limit articles))
7349 (gnus-summary-position-point))
7351 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7353 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7355 (defun gnus-summary-limit-to-unread (&optional all)
7356 "Limit the summary buffer to articles that are not marked as read.
7357 If ALL is non-nil, limit strictly to unread articles."
7360 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7361 (gnus-summary-limit-to-marks
7362 ;; Concat all the marks that say that an article is read and have
7364 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7365 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7366 gnus-low-score-mark gnus-expirable-mark
7367 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7368 gnus-duplicate-mark gnus-souped-mark)
7371 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7372 (make-obsolete 'gnus-summary-delete-marked-with
7373 'gnus-summary-limit-exclude-marks)
7375 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7376 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7377 If REVERSE, limit the summary buffer to articles that are marked
7378 with MARKS. MARKS can either be a string of marks or a list of marks.
7379 Returns how many articles were removed."
7380 (interactive "sMarks: ")
7381 (gnus-summary-limit-to-marks marks t))
7383 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7384 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7385 If REVERSE (the prefix), limit the summary buffer to articles that are
7386 not marked with MARKS. MARKS can either be a string of marks or a
7388 Returns how many articles were removed."
7389 (interactive "sMarks: \nP")
7391 (let ((data gnus-newsgroup-data)
7392 (marks (if (listp marks) marks
7393 (append marks nil))) ; Transform to list.
7396 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7397 (memq (gnus-data-mark (car data)) marks))
7398 (push (gnus-data-number (car data)) articles))
7399 (setq data (cdr data)))
7400 (gnus-summary-limit articles))
7401 (gnus-summary-position-point)))
7403 (defun gnus-summary-limit-to-score (score)
7404 "Limit to articles with score at or above SCORE."
7405 (interactive "NLimit to articles with score of at least: ")
7406 (let ((data gnus-newsgroup-data)
7409 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7411 (push (gnus-data-number (car data)) articles))
7412 (setq data (cdr data)))
7414 (gnus-summary-limit articles)
7415 (gnus-summary-position-point))))
7417 (defun gnus-summary-limit-to-unseen ()
7418 "Limit to unseen articles."
7421 (gnus-summary-limit gnus-newsgroup-unseen)
7422 (gnus-summary-position-point)))
7424 (defun gnus-summary-limit-include-thread (id)
7425 "Display all the hidden articles that is in the thread with ID in it.
7426 When called interactively, ID is the Message-ID of the current
7428 (interactive (list (mail-header-id (gnus-summary-article-header))))
7429 (let ((articles (gnus-articles-in-thread
7430 (gnus-id-to-thread (gnus-root-id id)))))
7432 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7433 (gnus-summary-limit-include-matching-articles
7435 (regexp-quote (gnus-simplify-subject-re
7436 (mail-header-subject (gnus-id-to-header id)))))
7437 (gnus-summary-position-point))))
7439 (defun gnus-summary-limit-include-matching-articles (header regexp)
7440 "Display all the hidden articles that have HEADERs that match REGEXP."
7441 (interactive (list (read-string "Match on header: ")
7442 (read-string "Regexp: ")))
7443 (let ((articles (gnus-find-matching-articles header regexp)))
7445 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7446 (gnus-summary-position-point))))
7448 (defun gnus-summary-limit-include-dormant ()
7449 "Display all the hidden articles that are marked as dormant.
7450 Note that this command only works on a subset of the articles currently
7451 fetched for this group."
7453 (unless gnus-newsgroup-dormant
7454 (error "There are no dormant articles in this group"))
7456 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7457 (gnus-summary-position-point)))
7459 (defun gnus-summary-limit-exclude-dormant ()
7460 "Hide all dormant articles."
7463 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7464 (gnus-summary-position-point)))
7466 (defun gnus-summary-limit-exclude-childless-dormant ()
7467 "Hide all dormant articles that have no children."
7469 (let ((data (gnus-data-list t))
7470 articles d children)
7471 ;; Find all articles that are either not dormant or have
7473 (while (setq d (pop data))
7474 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7476 (gnus-article-children (gnus-data-number d)))
7479 (when (memq (car children) articles)
7484 (push (gnus-data-number d) articles)))
7487 (gnus-summary-limit articles)
7488 (gnus-summary-position-point))))
7490 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7491 "Mark all unread excluded articles as read.
7492 If ALL, mark even excluded ticked and dormants as read."
7494 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7495 (let ((articles (gnus-sorted-ndifference
7497 (mapcar (lambda (h) (mail-header-number h))
7498 gnus-newsgroup-headers)
7500 gnus-newsgroup-limit))
7502 (setq gnus-newsgroup-unreads
7503 (gnus-sorted-intersection gnus-newsgroup-unreads
7504 gnus-newsgroup-limit))
7506 (setq gnus-newsgroup-dormant nil
7507 gnus-newsgroup-marked nil
7508 gnus-newsgroup-reads
7510 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7511 gnus-newsgroup-reads))
7512 (while (setq article (pop articles))
7513 (unless (or (memq article gnus-newsgroup-dormant)
7514 (memq article gnus-newsgroup-marked))
7515 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7517 (defun gnus-summary-limit (articles &optional pop)
7519 ;; We pop the previous limit off the stack and use that.
7520 (setq articles (car gnus-newsgroup-limits)
7521 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7522 ;; We use the new limit, so we push the old limit on the stack.
7523 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7525 (setq gnus-newsgroup-limit articles)
7526 (let ((total (length gnus-newsgroup-data))
7527 (data (gnus-data-find-list (gnus-summary-article-number)))
7528 (gnus-summary-mark-below nil) ; Inhibit this.
7530 ;; This will do all the work of generating the new summary buffer
7531 ;; according to the new limit.
7532 (gnus-summary-prepare)
7533 ;; Hide any threads, possibly.
7534 (gnus-summary-maybe-hide-threads)
7535 ;; Try to return to the article you were at, or one in the
7538 ;; We try to find some article after the current one.
7540 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7543 (setq data (cdr data))))
7545 ;; If there is no data, that means that we were after the last
7546 ;; article. The same goes when we can't find any articles
7547 ;; after the current one.
7548 (goto-char (point-max))
7549 (gnus-summary-find-prev))
7550 (gnus-set-mode-line 'summary)
7551 ;; We return how many articles were removed from the summary
7552 ;; buffer as a result of the new limit.
7553 (- total (length gnus-newsgroup-data))))
7555 (defsubst gnus-invisible-cut-children (threads)
7558 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7563 (defsubst gnus-cut-thread (thread)
7564 "Go forwards in the thread until we find an article that we want to display."
7565 (when (or (eq gnus-fetch-old-headers 'some)
7566 (eq gnus-fetch-old-headers 'invisible)
7567 (numberp gnus-fetch-old-headers)
7568 (eq gnus-build-sparse-threads 'some)
7569 (eq gnus-build-sparse-threads 'more))
7570 ;; Deal with old-fetched headers and sparse threads.
7574 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7575 (gnus-summary-article-ancient-p
7576 (mail-header-number (car thread))))
7577 (if (or (<= (length (cdr thread)) 1)
7578 (eq gnus-fetch-old-headers 'invisible))
7579 (setq gnus-newsgroup-limit
7580 (delq (mail-header-number (car thread))
7581 gnus-newsgroup-limit)
7582 thread (cadr thread))
7583 (when (gnus-invisible-cut-children (cdr thread))
7584 (let ((th (cdr thread)))
7586 (if (memq (mail-header-number (caar th))
7587 gnus-newsgroup-limit)
7588 (setq thread (car th)
7590 (setq th (cdr th))))))))))
7593 (defun gnus-cut-threads (threads)
7594 "Cut off all uninteresting articles from the beginning of threads."
7595 (when (or (eq gnus-fetch-old-headers 'some)
7596 (eq gnus-fetch-old-headers 'invisible)
7597 (numberp gnus-fetch-old-headers)
7598 (eq gnus-build-sparse-threads 'some)
7599 (eq gnus-build-sparse-threads 'more))
7602 (setcar th (gnus-cut-thread (car th)))
7603 (setq th (cdr th)))))
7604 ;; Remove nixed out threads.
7607 (defun gnus-summary-initial-limit (&optional show-if-empty)
7608 "Figure out what the initial limit is supposed to be on group entry.
7609 This entails weeding out unwanted dormants, low-scored articles,
7610 fetch-old-headers verbiage, and so on."
7611 ;; Most groups have nothing to remove.
7612 (if (or gnus-inhibit-limiting
7613 (and (null gnus-newsgroup-dormant)
7614 (eq gnus-newsgroup-display 'gnus-not-ignore)
7615 (not (eq gnus-fetch-old-headers 'some))
7616 (not (numberp gnus-fetch-old-headers))
7617 (not (eq gnus-fetch-old-headers 'invisible))
7618 (null gnus-summary-expunge-below)
7619 (not (eq gnus-build-sparse-threads 'some))
7620 (not (eq gnus-build-sparse-threads 'more))
7621 (null gnus-thread-expunge-below)
7622 (not gnus-use-nocem)))
7624 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7625 (setq gnus-newsgroup-limit nil)
7628 (unless (car (symbol-value node))
7629 ;; These threads have no parents -- they are roots.
7630 (let ((nodes (cdr (symbol-value node)))
7633 (if (and gnus-thread-expunge-below
7634 (< (gnus-thread-total-score (car nodes))
7635 gnus-thread-expunge-below))
7636 (gnus-expunge-thread (pop nodes))
7637 (setq thread (pop nodes))
7638 (gnus-summary-limit-children thread))))))
7639 gnus-newsgroup-dependencies)
7640 ;; If this limitation resulted in an empty group, we might
7641 ;; pop the previous limit and use it instead.
7642 (when (and (not gnus-newsgroup-limit)
7644 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7645 gnus-newsgroup-limit))
7647 (defun gnus-summary-limit-children (thread)
7648 "Return 1 if this subthread is visible and 0 if it is not."
7649 ;; First we get the number of visible children to this thread. This
7650 ;; is done by recursing down the thread using this function, so this
7651 ;; will really go down to a leaf article first, before slowly
7652 ;; working its way up towards the root.
7656 (apply '+ (mapcar 'gnus-summary-limit-children
7659 (number (mail-header-number (car thread)))
7662 (not (memq number gnus-newsgroup-marked))
7664 ;; If this article is dormant and has absolutely no visible
7665 ;; children, then this article isn't visible.
7666 (and (memq number gnus-newsgroup-dormant)
7668 ;; If this is "fetch-old-headered" and there is no
7669 ;; visible children, then we don't want this article.
7670 (and (or (eq gnus-fetch-old-headers 'some)
7671 (numberp gnus-fetch-old-headers))
7672 (gnus-summary-article-ancient-p number)
7674 ;; If this is "fetch-old-headered" and `invisible', then
7675 ;; we don't want this article.
7676 (and (eq gnus-fetch-old-headers 'invisible)
7677 (gnus-summary-article-ancient-p number))
7678 ;; If this is a sparsely inserted article with no children,
7679 ;; we don't want it.
7680 (and (eq gnus-build-sparse-threads 'some)
7681 (gnus-summary-article-sparse-p number)
7683 ;; If we use expunging, and this article is really
7684 ;; low-scored, then we don't want this article.
7685 (when (and gnus-summary-expunge-below
7687 (or (cdr (assq number gnus-newsgroup-scored))
7688 gnus-summary-default-score))
7689 gnus-summary-expunge-below))
7690 ;; We increase the expunge-tally here, but that has
7691 ;; nothing to do with the limits, really.
7692 (incf gnus-newsgroup-expunged-tally)
7693 ;; We also mark as read here, if that's wanted.
7694 (when (and gnus-summary-mark-below
7695 (< score gnus-summary-mark-below))
7696 (setq gnus-newsgroup-unreads
7697 (delq number gnus-newsgroup-unreads))
7698 (if gnus-newsgroup-auto-expire
7699 (push number gnus-newsgroup-expirable)
7700 (push (cons number gnus-low-score-mark)
7701 gnus-newsgroup-reads)))
7703 ;; Do the `display' group parameter.
7704 (and gnus-newsgroup-display
7705 (not (funcall gnus-newsgroup-display)))
7706 ;; Check NoCeM things.
7707 (if (and gnus-use-nocem
7708 (gnus-nocem-unwanted-article-p
7709 (mail-header-id (car thread))))
7711 (setq gnus-newsgroup-unreads
7712 (delq number gnus-newsgroup-unreads))
7714 ;; Nope, invisible article.
7716 ;; Ok, this article is to be visible, so we add it to the limit
7718 (push number gnus-newsgroup-limit)
7721 (defun gnus-expunge-thread (thread)
7722 "Mark all articles in THREAD as read."
7723 (let* ((number (mail-header-number (car thread))))
7724 (incf gnus-newsgroup-expunged-tally)
7725 ;; We also mark as read here, if that's wanted.
7726 (setq gnus-newsgroup-unreads
7727 (delq number gnus-newsgroup-unreads))
7728 (if gnus-newsgroup-auto-expire
7729 (push number gnus-newsgroup-expirable)
7730 (push (cons number gnus-low-score-mark)
7731 gnus-newsgroup-reads)))
7732 ;; Go recursively through all subthreads.
7733 (mapcar 'gnus-expunge-thread (cdr thread)))
7735 ;; Summary article oriented commands
7737 (defun gnus-summary-refer-parent-article (n)
7738 "Refer parent article N times.
7739 If N is negative, go to ancestor -N instead.
7740 The difference between N and the number of articles fetched is returned."
7744 (when (not (natnump n))
7749 (setq header (gnus-summary-article-header))
7750 (if (and (eq (mail-header-number header)
7751 (cdr gnus-article-current))
7752 (equal gnus-newsgroup-name
7753 (car gnus-article-current)))
7754 ;; If we try to find the parent of the currently
7755 ;; displayed article, then we take a look at the actual
7756 ;; References header, since this is slightly more
7757 ;; reliable than the References field we got from the
7760 (set-buffer gnus-original-article-buffer)
7761 (nnheader-narrow-to-headers)
7762 (unless (setq ref (message-fetch-field "references"))
7763 (setq ref (message-fetch-field "in-reply-to")))
7766 ;; It's not the current article, so we take a bet on
7767 ;; the value we got from the server.
7768 (mail-header-references header)))
7770 (not (equal ref "")))
7771 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7772 (gnus-message 1 "Couldn't find parent"))
7773 (gnus-message 1 "No references in article %d"
7774 (gnus-summary-article-number))
7777 (gnus-summary-position-point)
7780 (defun gnus-summary-refer-references ()
7781 "Fetch all articles mentioned in the References header.
7782 Return the number of articles fetched."
7784 (let ((ref (mail-header-references (gnus-summary-article-header)))
7785 (current (gnus-summary-article-number))
7789 (error "No References in the current article")
7790 ;; For each Message-ID in the References header...
7791 (while (string-match "<[^>]*>" ref)
7793 ;; ... fetch that article.
7794 (gnus-summary-refer-article
7795 (prog1 (match-string 0 ref)
7796 (setq ref (substring ref (match-end 0))))))
7797 (gnus-summary-goto-subject current)
7798 (gnus-summary-position-point)
7801 (defun gnus-summary-refer-thread (&optional limit)
7802 "Fetch all articles in the current thread.
7803 If LIMIT (the numerical prefix), fetch that many old headers instead
7804 of what's specified by the `gnus-refer-thread-limit' variable."
7806 (let ((id (mail-header-id (gnus-summary-article-header)))
7807 (limit (if limit (prefix-numeric-value limit)
7808 gnus-refer-thread-limit)))
7809 ;; We want to fetch LIMIT *old* headers, but we also have to
7810 ;; re-fetch all the headers in the current buffer, because many of
7811 ;; them may be undisplayed. So we adjust LIMIT.
7812 (when (numberp limit)
7813 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7814 (unless (eq gnus-fetch-old-headers 'invisible)
7815 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7816 ;; Retrieve the headers and read them in.
7817 (if (eq (gnus-retrieve-headers
7818 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7820 (gnus-build-all-threads)
7821 (error "Can't fetch thread from backends that don't support NOV"))
7822 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7823 (gnus-summary-limit-include-thread id)))
7825 (defun gnus-summary-refer-article (message-id)
7826 "Fetch an article specified by MESSAGE-ID."
7827 (interactive "sMessage-ID: ")
7828 (when (and (stringp message-id)
7829 (not (zerop (length message-id))))
7830 ;; Construct the correct Message-ID if necessary.
7831 ;; Suggested by tale@pawl.rpi.edu.
7832 (unless (string-match "^<" message-id)
7833 (setq message-id (concat "<" message-id)))
7834 (unless (string-match ">$" message-id)
7835 (setq message-id (concat message-id ">")))
7836 (let* ((header (gnus-id-to-header message-id))
7838 (gnus-summary-article-sparse-p
7839 (mail-header-number header))
7840 (memq (mail-header-number header)
7841 gnus-newsgroup-limit)))
7844 ;; If the article is present in the buffer we just go to it.
7846 (or (not (gnus-summary-article-sparse-p
7847 (mail-header-number header)))
7850 (gnus-summary-goto-article
7851 (mail-header-number header) nil t)
7853 (gnus-summary-update-article (mail-header-number header)))))
7855 ;; We fetch the article.
7857 (dolist (gnus-override-method (gnus-refer-article-methods))
7858 (gnus-check-server gnus-override-method)
7859 ;; Fetch the header, and display the article.
7860 (when (setq number (gnus-summary-insert-subject message-id))
7861 (gnus-summary-select-article nil nil nil number)
7863 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7865 (defun gnus-refer-article-methods ()
7866 "Return a list of referable methods."
7868 ;; No method, so we default to current and native.
7869 ((null gnus-refer-article-method)
7870 (list gnus-current-select-method gnus-select-method))
7872 ((eq 'current gnus-refer-article-method)
7873 (list gnus-current-select-method))
7874 ;; List of select methods.
7875 ((not (and (symbolp (car gnus-refer-article-method))
7876 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7878 (dolist (method gnus-refer-article-method)
7879 (push (if (eq 'current method)
7880 gnus-current-select-method
7884 ;; One single select method.
7886 (list gnus-refer-article-method))))
7888 (defun gnus-summary-edit-parameters ()
7889 "Edit the group parameters of the current group."
7891 (gnus-group-edit-group gnus-newsgroup-name 'params))
7893 (defun gnus-summary-customize-parameters ()
7894 "Customize the group parameters of the current group."
7896 (gnus-group-customize gnus-newsgroup-name))
7898 (defun gnus-summary-enter-digest-group (&optional force)
7899 "Enter an nndoc group based on the current article.
7900 If FORCE, force a digest interpretation. If not, try
7901 to guess what the document format is."
7903 (let ((conf gnus-current-window-configuration))
7905 (gnus-summary-select-article))
7906 (setq gnus-current-window-configuration conf)
7907 (let* ((name (format "%s-%d"
7908 (gnus-group-prefixed-name
7909 gnus-newsgroup-name (list 'nndoc ""))
7911 (set-buffer gnus-summary-buffer)
7912 gnus-current-article)))
7913 (ogroup gnus-newsgroup-name)
7914 (params (append (gnus-info-params (gnus-get-info ogroup))
7915 (list (cons 'to-group ogroup))
7916 (list (cons 'save-article-group ogroup))))
7917 (case-fold-search t)
7918 (buf (current-buffer))
7921 (set-buffer gnus-original-article-buffer)
7922 ;; Have the digest group inherit the main mail address of
7923 ;; the parent article.
7924 (when (setq to-address (or (gnus-fetch-field "reply-to")
7925 (gnus-fetch-field "from")))
7926 (setq params (append
7927 (list (cons 'to-address
7928 (funcall gnus-decode-encoded-word-function
7930 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7931 (insert-buffer-substring gnus-original-article-buffer)
7932 ;; Remove lines that may lead nndoc to misinterpret the
7935 (goto-char (point-min))
7936 (or (search-forward "\n\n" nil t) (point)))
7937 (goto-char (point-min))
7938 (delete-matching-lines "^Path:\\|^From ")
7941 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7942 (gnus-newsgroup-ephemeral-ignored-charsets
7943 gnus-newsgroup-ignored-charsets))
7944 (gnus-group-read-ephemeral-group
7945 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7947 ,(if force 'mbox 'guess)))
7949 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7951 ;; Make all postings to this group go to the parent group.
7952 (nconc (gnus-info-params (gnus-get-info name))
7954 ;; Couldn't select this doc group.
7955 (switch-to-buffer buf)
7956 (gnus-set-global-variables)
7957 (gnus-configure-windows 'summary)
7958 (gnus-message 3 "Article couldn't be entered?"))
7959 (kill-buffer dig)))))
7961 (defun gnus-summary-read-document (n)
7962 "Open a new group based on the current article(s).
7963 This will allow you to read digests and other similar
7964 documents as newsgroups.
7965 Obeys the standard process/prefix convention."
7967 (let* ((articles (gnus-summary-work-articles n))
7968 (ogroup gnus-newsgroup-name)
7969 (params (append (gnus-info-params (gnus-get-info ogroup))
7970 (list (cons 'to-group ogroup))))
7971 article group egroup groups vgroup)
7972 (while (setq article (pop articles))
7973 (setq group (format "%s-%d" gnus-newsgroup-name article))
7974 (gnus-summary-remove-process-mark article)
7975 (when (gnus-summary-display-article article)
7978 (insert-buffer-substring gnus-original-article-buffer)
7979 ;; Remove some headers that may lead nndoc to make
7981 (message-narrow-to-head)
7982 (goto-char (point-min))
7983 (delete-matching-lines "^\\(Path\\):\\|^From ")
7986 (gnus-group-read-ephemeral-group
7987 group `(nndoc ,group (nndoc-address ,(current-buffer))
7988 (nndoc-article-type guess))
7991 ;; Make all postings to this group go to the parent group.
7992 (nconc (gnus-info-params (gnus-get-info egroup))
7994 (push egroup groups))
7995 ;; Couldn't select this doc group.
7996 (gnus-error 3 "Article couldn't be entered"))))))
7997 ;; Now we have selected all the documents.
8000 (error "None of the articles could be interpreted as documents"))
8001 ((gnus-group-read-ephemeral-group
8002 (setq vgroup (format
8003 "nnvirtual:%s-%s" gnus-newsgroup-name
8004 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8005 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8007 (cons (current-buffer) 'summary)))
8009 (error "Couldn't select virtual nndoc group")))))
8011 (defun gnus-summary-isearch-article (&optional regexp-p)
8012 "Do incremental search forward on the current article.
8013 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8015 (gnus-summary-select-article)
8016 (gnus-configure-windows 'article)
8017 (gnus-eval-in-buffer-window gnus-article-buffer
8020 (isearch-forward regexp-p))))
8022 (defun gnus-summary-search-article-forward (regexp &optional backward)
8023 "Search for an article containing REGEXP forward.
8024 If BACKWARD, search backward instead."
8027 (format "Search article %s (regexp%s): "
8028 (if current-prefix-arg "backward" "forward")
8029 (if gnus-last-search-regexp
8030 (concat ", default " gnus-last-search-regexp)
8032 current-prefix-arg))
8033 (if (string-equal regexp "")
8034 (setq regexp (or gnus-last-search-regexp ""))
8035 (setq gnus-last-search-regexp regexp)
8036 (setq gnus-article-before-search gnus-current-article))
8037 ;; Intentionally set gnus-last-article.
8038 (setq gnus-last-article gnus-article-before-search)
8039 (let ((gnus-last-article gnus-last-article))
8040 (if (gnus-summary-search-article regexp backward)
8041 (gnus-summary-show-thread)
8042 (error "Search failed: \"%s\"" regexp))))
8044 (defun gnus-summary-search-article-backward (regexp)
8045 "Search for an article containing REGEXP backward."
8048 (format "Search article backward (regexp%s): "
8049 (if gnus-last-search-regexp
8050 (concat ", default " gnus-last-search-regexp)
8052 (gnus-summary-search-article-forward regexp 'backward))
8054 (defun gnus-summary-search-article (regexp &optional backward)
8055 "Search for an article containing REGEXP.
8056 Optional argument BACKWARD means do search for backward.
8057 `gnus-select-article-hook' is not called during the search."
8058 ;; We have to require this here to make sure that the following
8059 ;; dynamic binding isn't shadowed by autoloading.
8060 (require 'gnus-async)
8062 (let ((gnus-select-article-hook nil) ;Disable hook.
8063 (gnus-article-prepare-hook nil)
8064 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8065 (gnus-use-article-prefetch nil)
8066 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8067 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8068 (sum (current-buffer))
8069 (gnus-display-mime-function nil)
8072 (gnus-save-hidden-threads
8073 (gnus-summary-select-article)
8074 (set-buffer gnus-article-buffer)
8075 (goto-char (window-point (get-buffer-window (current-buffer))))
8079 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8081 (re-search-backward regexp nil t)
8082 (re-search-forward regexp nil t))
8083 ;; We found the regexp.
8088 (get-buffer-window (current-buffer))
8092 (get-buffer-window (current-buffer))
8095 (setq point (point)))
8096 ;; We didn't find it, so we go to the next article.
8099 (while (eq found 'not)
8100 (if (not (if backward (gnus-summary-find-prev)
8101 (gnus-summary-find-next)))
8102 ;; No more articles.
8104 ;; Select the next article and adjust point.
8105 (unless (gnus-summary-article-sparse-p
8106 (gnus-summary-article-number))
8108 (gnus-summary-select-article)
8109 (set-buffer gnus-article-buffer)
8111 (goto-char (if backward (point-max) (point-min))))))))
8112 (gnus-message 7 ""))
8113 ;; Return whether we found the regexp.
8114 (when (eq found 'found)
8116 (gnus-summary-show-thread)
8117 (gnus-summary-goto-subject gnus-current-article)
8118 (gnus-summary-position-point)
8121 (defun gnus-find-matching-articles (header regexp)
8122 "Return a list of all articles that match REGEXP on HEADER.
8123 This search includes all articles in the current group that Gnus has
8124 fetched headers for, whether they are displayed or not."
8125 (let ((articles nil)
8126 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8127 (case-fold-search t))
8128 (dolist (header gnus-newsgroup-headers)
8129 (when (string-match regexp (funcall func header))
8130 (push (mail-header-number header) articles)))
8131 (nreverse articles)))
8133 (defun gnus-summary-find-matching (header regexp &optional backward unread
8134 not-case-fold not-matching)
8135 "Return a list of all articles that match REGEXP on HEADER.
8136 The search stars on the current article and goes forwards unless
8137 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8138 If UNREAD is non-nil, only unread articles will
8139 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8140 in the comparisons. If NOT-MATCHING, return a list of all articles that
8141 not match REGEXP on HEADER."
8142 (let ((case-fold-search (not not-case-fold))
8145 (if (eq (car header) 'extra)
8148 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8150 (error "%s is an invalid header" header))
8151 (unless (fboundp (intern (concat "mail-header-" header)))
8152 (error "%s is not a valid header" header))
8153 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8154 (dolist (d (if (eq backward 'all)
8156 (gnus-data-find-list
8157 (gnus-summary-article-number)
8158 (gnus-data-list backward))))
8159 (when (and (or (not unread) ; We want all articles...
8160 (gnus-data-unread-p d)) ; Or just unreads.
8161 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8165 (funcall func (gnus-data-header d))))
8166 (string-match regexp
8167 (funcall func (gnus-data-header d)))))
8168 (push (gnus-data-number d) articles))) ; Success!
8169 (nreverse articles)))
8171 (defun gnus-summary-execute-command (header regexp command &optional backward)
8172 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8173 If HEADER is an empty string (or nil), the match is done on the entire
8174 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8176 (list (let ((completion-ignore-case t))
8179 (mapcar (lambda (header) (list (format "%s" header)))
8181 '("Number" "Subject" "From" "Lines" "Date"
8182 "Message-ID" "Xref" "References" "Body")
8183 gnus-extra-headers))
8184 nil 'require-match))
8185 (read-string "Regexp: ")
8186 (read-key-sequence "Command: ")
8187 current-prefix-arg))
8188 (when (equal header "Body")
8190 ;; Hidden thread subtrees must be searched as well.
8191 (gnus-summary-show-all-threads)
8192 ;; We don't want to change current point nor window configuration.
8194 (save-window-excursion
8196 gnus-treat-strip-trailing-blank-lines
8197 gnus-treat-strip-leading-blank-lines
8198 gnus-treat-strip-multiple-blank-lines
8199 gnus-treat-hide-boring-headers
8200 gnus-treat-fold-newsgroups
8201 gnus-article-prepare-hook)
8202 (gnus-message 6 "Executing %s..." (key-description command))
8203 ;; We'd like to execute COMMAND interactively so as to give arguments.
8204 (gnus-execute header regexp
8205 `(call-interactively ',(key-binding command))
8207 (gnus-message 6 "Executing %s...done" (key-description command))))))
8209 (defun gnus-summary-beginning-of-article ()
8210 "Scroll the article back to the beginning."
8212 (gnus-summary-select-article)
8213 (gnus-configure-windows 'article)
8214 (gnus-eval-in-buffer-window gnus-article-buffer
8216 (goto-char (point-min))
8217 (when gnus-page-broken
8218 (gnus-narrow-to-page))))
8220 (defun gnus-summary-end-of-article ()
8221 "Scroll to the end of the article."
8223 (gnus-summary-select-article)
8224 (gnus-configure-windows 'article)
8225 (gnus-eval-in-buffer-window gnus-article-buffer
8227 (goto-char (point-max))
8229 (when gnus-page-broken
8230 (gnus-narrow-to-page))))
8232 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8233 "Truncate to LEN and quote all \"(\"'s in STRING."
8234 (gnus-replace-in-string (if (and len (> (length string) len))
8235 (substring string 0 len)
8239 (defun gnus-summary-print-article (&optional filename n)
8240 "Generate and print a PostScript image of the N next (mail) articles.
8242 If N is negative, print the N previous articles. If N is nil and articles
8243 have been marked with the process mark, print these instead.
8245 If the optional first argument FILENAME is nil, send the image to the
8246 printer. If FILENAME is a string, save the PostScript image in a file with
8247 that name. If FILENAME is a number, prompt the user for the name of the file
8249 (interactive (list (ps-print-preprint current-prefix-arg)))
8250 (dolist (article (gnus-summary-work-articles n))
8251 (gnus-summary-select-article nil nil 'pseudo article)
8252 (gnus-eval-in-buffer-window gnus-article-buffer
8253 (gnus-print-buffer))
8254 (gnus-summary-remove-process-mark article))
8255 (ps-despool filename))
8257 (defun gnus-print-buffer ()
8258 (let ((buffer (generate-new-buffer " *print*")))
8261 (copy-to-buffer buffer (point-min) (point-max))
8263 (gnus-article-delete-invisible-text)
8264 (gnus-remove-text-with-property 'gnus-decoration)
8265 (when (gnus-visual-p 'article-highlight 'highlight)
8266 ;; Copy-to-buffer doesn't copy overlay. So redo
8268 (let ((gnus-article-buffer buffer))
8269 (gnus-article-highlight-citation t)
8270 (gnus-article-highlight-signature)))
8271 (let ((ps-left-header
8274 (gnus-summary-print-truncate-and-quote
8275 (mail-header-subject gnus-current-headers)
8278 (gnus-summary-print-truncate-and-quote
8279 (mail-header-from gnus-current-headers)
8283 "/pagenumberstring load"
8285 (mail-header-date gnus-current-headers) ")"))))
8286 (gnus-run-hooks 'gnus-ps-print-hook)
8289 (ps-spool-buffer-with-faces)
8290 (ps-spool-buffer)))))
8291 (kill-buffer buffer))))
8293 (defun gnus-summary-show-article (&optional arg)
8294 "Force redisplaying of the current article.
8295 If ARG (the prefix) is a number, show the article with the charset
8296 defined in `gnus-summary-show-article-charset-alist', or the charset
8298 If ARG (the prefix) is non-nil and not a number, show the raw article
8299 without any article massaging functions being run. Normally, the key strokes
8304 (gnus-summary-show-article t)
8305 (let ((gnus-newsgroup-charset
8306 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8307 (mm-read-coding-system
8308 "View as charset: " ;; actually it is coding system.
8310 (set-buffer gnus-article-buffer)
8311 (mm-detect-coding-region (point) (point-max))))))
8312 (gnus-newsgroup-ignored-charsets 'gnus-all))
8313 (gnus-summary-select-article nil 'force)
8314 (let ((deps gnus-newsgroup-dependencies)
8317 (set-buffer gnus-original-article-buffer)
8319 (message-narrow-to-head)
8320 (setq head (buffer-string))
8321 (goto-char (point-min))
8322 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8323 (goto-char (point-max))
8325 (setq lines (1- (count-lines (point) (point-max))))))
8327 (insert (format "211 %d Article retrieved.\n"
8328 (cdr gnus-article-current)))
8330 (if lines (insert (format "Lines: %d\n" lines)))
8332 (let ((nntp-server-buffer (current-buffer)))
8333 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8334 (gnus-data-set-header
8335 (gnus-data-find (cdr gnus-article-current))
8337 (gnus-summary-update-article-line
8338 (cdr gnus-article-current) header)
8339 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8340 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8342 ;; Select the article the normal way.
8343 (gnus-summary-select-article nil 'force))
8345 ;; We have to require this here to make sure that the following
8346 ;; dynamic binding isn't shadowed by autoloading.
8347 (require 'gnus-async)
8349 ;; Bind the article treatment functions to nil.
8350 (let ((gnus-have-all-headers t)
8351 gnus-article-prepare-hook
8352 gnus-article-decode-hook
8353 gnus-display-mime-function
8355 ;; Destroy any MIME parts.
8356 (when (gnus-buffer-live-p gnus-article-buffer)
8358 (set-buffer gnus-article-buffer)
8359 (mm-destroy-parts gnus-article-mime-handles)
8360 ;; Set it to nil for safety reason.
8361 (setq gnus-article-mime-handle-alist nil)
8362 (setq gnus-article-mime-handles nil)))
8363 (gnus-summary-select-article nil 'force))))
8364 (gnus-summary-goto-subject gnus-current-article)
8365 (gnus-summary-position-point))
8367 (defun gnus-summary-show-raw-article ()
8368 "Show the raw article without any article massaging functions being run."
8370 (gnus-summary-show-article t))
8372 (defun gnus-summary-verbose-headers (&optional arg)
8373 "Toggle permanent full header display.
8374 If ARG is a positive number, turn header display on.
8375 If ARG is a negative number, turn header display off."
8377 (setq gnus-show-all-headers
8378 (cond ((or (not (numberp arg))
8380 (not gnus-show-all-headers))
8383 (gnus-summary-show-article))
8385 (defun gnus-summary-toggle-header (&optional arg)
8386 "Show the headers if they are hidden, or hide them if they are shown.
8387 If ARG is a positive number, show the entire header.
8388 If ARG is a negative number, hide the unwanted header lines."
8390 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8391 (get-buffer-window gnus-article-buffer t))))
8392 (with-current-buffer gnus-article-buffer
8394 (article-narrow-to-head)
8395 (let* ((buffer-read-only nil)
8396 (inhibit-point-motion-hooks t)
8397 (hidden (if (numberp arg)
8399 (gnus-article-hidden-text-p 'headers)))
8401 (delete-region (point-min) (point-max))
8402 (with-current-buffer gnus-original-article-buffer
8403 (goto-char (setq s (point-min)))
8404 (setq e (if (search-forward "\n\n" nil t)
8407 (insert-buffer-substring gnus-original-article-buffer s e)
8408 (article-decode-encoded-words)
8410 (let ((gnus-treat-hide-headers nil)
8411 (gnus-treat-hide-boring-headers nil))
8412 (gnus-delete-wash-type 'headers)
8413 (gnus-treat-article 'head))
8414 (gnus-treat-article 'head))
8417 (set-window-start window (goto-char (point-min))))
8418 (setq gnus-page-broken
8419 (when gnus-break-pages
8420 (gnus-narrow-to-page)
8422 (gnus-set-mode-line 'article)))))
8424 (defun gnus-summary-show-all-headers ()
8425 "Make all header lines visible."
8427 (gnus-summary-toggle-header 1))
8429 (defun gnus-summary-caesar-message (&optional arg)
8430 "Caesar rotate the current article by 13.
8431 The numerical prefix specifies how many places to rotate each letter
8434 (gnus-summary-select-article)
8435 (let ((mail-header-separator ""))
8436 (gnus-eval-in-buffer-window gnus-article-buffer
8439 (let ((start (window-start))
8441 (message-caesar-buffer-body arg)
8442 (set-window-start (get-buffer-window (current-buffer)) start))))))
8444 (autoload 'unmorse-region "morse"
8445 "Convert morse coded text in region to ordinary ASCII text."
8448 (defun gnus-summary-morse-message (&optional arg)
8449 "Morse decode the current article."
8451 (gnus-summary-select-article)
8452 (let ((mail-header-separator ""))
8453 (gnus-eval-in-buffer-window gnus-article-buffer
8457 (let ((pos (window-start))
8459 (goto-char (point-min))
8460 (when (message-goto-body)
8461 (gnus-narrow-to-body))
8462 (goto-char (point-min))
8463 (while (re-search-forward "·" (point-max) t)
8464 (replace-match "."))
8465 (unmorse-region (point-min) (point-max))
8467 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8469 (defun gnus-summary-stop-page-breaking ()
8470 "Stop page breaking in the current article."
8472 (gnus-summary-select-article)
8473 (gnus-eval-in-buffer-window gnus-article-buffer
8475 (when (gnus-visual-p 'page-marker)
8476 (let ((buffer-read-only nil))
8477 (gnus-remove-text-with-property 'gnus-prev)
8478 (gnus-remove-text-with-property 'gnus-next))
8479 (setq gnus-page-broken nil))))
8481 (defun gnus-summary-move-article (&optional n to-newsgroup
8482 select-method action)
8483 "Move the current article to a different newsgroup.
8484 If N is a positive number, move the N next articles.
8485 If N is a negative number, move the N previous articles.
8486 If N is nil and any articles have been marked with the process mark,
8487 move those articles instead.
8488 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8489 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8490 re-spool using this method.
8492 When called interactively with TO-NEWSGROUP being nil, the value of
8493 the variable `gnus-move-split-methods' is used for finding a default
8494 for the target newsgroup.
8496 For this function to work, both the current newsgroup and the
8497 newsgroup that you want to move to have to support the `request-move'
8498 and `request-accept' functions.
8500 ACTION can be either `move' (the default), `crosspost' or `copy'."
8503 (setq action 'move))
8504 ;; Check whether the source group supports the required functions.
8505 (cond ((and (eq action 'move)
8506 (not (gnus-check-backend-function
8507 'request-move-article gnus-newsgroup-name)))
8508 (error "The current group does not support article moving"))
8509 ((and (eq action 'crosspost)
8510 (not (gnus-check-backend-function
8511 'request-replace-article gnus-newsgroup-name)))
8512 (error "The current group does not support article editing")))
8513 (let ((articles (gnus-summary-work-articles n))
8514 (prefix (if (gnus-check-backend-function
8515 'request-move-article gnus-newsgroup-name)
8516 (gnus-group-real-prefix gnus-newsgroup-name)
8518 (names '((move "Move" "Moving")
8519 (copy "Copy" "Copying")
8520 (crosspost "Crosspost" "Crossposting")))
8521 (copy-buf (save-excursion
8522 (nnheader-set-temp-buffer " *copy article*")))
8523 art-group to-method new-xref article to-groups)
8524 (unless (assq action names)
8525 (error "Unknown action %s" action))
8526 ;; Read the newsgroup name.
8527 (when (and (not to-newsgroup)
8528 (not select-method))
8529 (if (and gnus-move-split-methods
8531 (and (memq gnus-current-article articles)
8532 (gnus-buffer-live-p gnus-original-article-buffer))))
8533 ;; When `gnus-move-split-methods' is non-nil, we have to
8534 ;; select an article to give `gnus-read-move-group-name' an
8535 ;; opportunity to suggest an appropriate default. However,
8536 ;; we needn't render or mark the article.
8537 (let ((gnus-display-mime-function nil)
8538 (gnus-article-prepare-hook nil)
8539 (gnus-mark-article-hook nil))
8540 (gnus-summary-select-article nil nil nil (car articles))))
8542 (gnus-read-move-group-name
8543 (cadr (assq action names))
8544 (symbol-value (intern (format "gnus-current-%s-group" action)))
8546 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8547 (setq to-method (or select-method
8548 (gnus-server-to-method
8549 (gnus-group-method to-newsgroup))))
8550 ;; Check the method we are to move this article to...
8551 (unless (gnus-check-backend-function
8552 'request-accept-article (car to-method))
8553 (error "%s does not support article copying" (car to-method)))
8554 (unless (gnus-check-server to-method)
8555 (error "Can't open server %s" (car to-method)))
8556 (gnus-message 6 "%s to %s: %s..."
8557 (caddr (assq action names))
8558 (or (car select-method) to-newsgroup) articles)
8560 (setq article (pop articles))
8564 ;; Move the article.
8566 ;; Remove this article from future suppression.
8567 (gnus-dup-unsuppress-article article)
8568 (gnus-request-move-article
8569 article ; Article to move
8570 gnus-newsgroup-name ; From newsgroup
8571 (nth 1 (gnus-find-method-for-group
8572 gnus-newsgroup-name)) ; Server
8573 (list 'gnus-request-accept-article
8574 to-newsgroup (list 'quote select-method)
8575 (not articles) t) ; Accept form
8576 (not articles))) ; Only save nov last time
8577 ;; Copy the article.
8580 (set-buffer copy-buf)
8581 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8582 (gnus-request-accept-article
8583 to-newsgroup select-method (not articles) t))))
8584 ;; Crosspost the article.
8585 ((eq action 'crosspost)
8586 (let ((xref (message-tokenize-header
8587 (mail-header-xref (gnus-summary-article-header article))
8589 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8590 ":" (number-to-string article)))
8592 (setq xref (list (system-name))))
8595 (mapconcat 'identity
8596 (delete "Xref:" (delete new-xref xref))
8600 (set-buffer copy-buf)
8601 ;; First put the article in the destination group.
8602 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8603 (when (consp (setq art-group
8604 (gnus-request-accept-article
8605 to-newsgroup select-method (not articles))))
8606 (setq new-xref (concat new-xref " " (car art-group)
8608 (number-to-string (cdr art-group))))
8609 ;; Now we have the new Xrefs header, so we insert
8610 ;; it and replace the new article.
8611 (nnheader-replace-header "Xref" new-xref)
8612 (gnus-request-replace-article
8613 (cdr art-group) to-newsgroup (current-buffer))
8617 (gnus-message 1 "Couldn't %s article %s: %s"
8618 (cadr (assq action names)) article
8619 (nnheader-get-report (car to-method))))
8620 ((eq art-group 'junk)
8621 (when (eq action 'move)
8622 (gnus-summary-mark-article article gnus-canceled-mark)
8623 (gnus-message 4 "Deleted article %s" article)))
8625 (let* ((pto-group (gnus-group-prefixed-name
8626 (car art-group) to-method))
8628 (gnus-gethash pto-group gnus-newsrc-hashtb))
8629 (info (nth 2 entry))
8630 (to-group (gnus-info-group info))
8632 ;; Update the group that has been moved to.
8634 (memq action '(move copy)))
8635 (unless (member to-group to-groups)
8636 (push to-group to-groups))
8638 (unless (memq article gnus-newsgroup-unreads)
8639 (push 'read to-marks)
8641 info (gnus-add-to-range (gnus-info-read info)
8642 (list (cdr art-group)))))
8644 ;; See whether the article is to be put in the cache.
8645 (let ((marks gnus-article-mark-lists)
8646 (to-article (cdr art-group)))
8648 ;; Enter the article into the cache in the new group,
8649 ;; if that is required.
8650 (when gnus-use-cache
8651 (gnus-cache-possibly-enter-article
8653 (memq article gnus-newsgroup-marked)
8654 (memq article gnus-newsgroup-dormant)
8655 (memq article gnus-newsgroup-unreads)))
8657 (when gnus-preserve-marks
8658 ;; Copy any marks over to the new group.
8659 (when (and (equal to-group gnus-newsgroup-name)
8660 (not (memq article gnus-newsgroup-unreads)))
8661 ;; Mark this article as read in this group.
8662 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8663 (setcdr (gnus-active to-group) to-article)
8664 (setcdr gnus-newsgroup-active to-article))
8667 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8668 (when (memq article (symbol-value
8669 (intern (format "gnus-newsgroup-%s"
8671 (push (cdar marks) to-marks)
8672 ;; If the other group is the same as this group,
8673 ;; then we have to add the mark to the list.
8674 (when (equal to-group gnus-newsgroup-name)
8675 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8678 (intern (format "gnus-newsgroup-%s"
8680 ;; Copy the marks to other group.
8681 (gnus-add-marked-articles
8682 to-group (cdar marks) (list to-article) info)))
8683 (setq marks (cdr marks)))
8685 (gnus-request-set-mark to-group (list (list (list to-article)
8690 (concat "(gnus-group-set-info '"
8691 (gnus-prin1-to-string (gnus-get-info to-group))
8694 ;; Update the Xref header in this article to point to
8695 ;; the new crossposted article we have just created.
8696 (when (eq action 'crosspost)
8698 (set-buffer copy-buf)
8699 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8700 (nnheader-replace-header "Xref" new-xref)
8701 (gnus-request-replace-article
8702 article gnus-newsgroup-name (current-buffer)))))
8704 ;;;!!!Why is this necessary?
8705 (set-buffer gnus-summary-buffer)
8707 (gnus-summary-goto-subject article)
8708 (when (eq action 'move)
8709 (gnus-summary-mark-article article gnus-canceled-mark))))
8710 (gnus-summary-remove-process-mark article))
8711 ;; Re-activate all groups that have been moved to.
8713 (set-buffer gnus-group-buffer)
8714 (let ((gnus-group-marked to-groups))
8715 (gnus-group-get-new-news-this-group nil t)))
8717 (gnus-kill-buffer copy-buf)
8718 (gnus-summary-position-point)
8719 (gnus-set-mode-line 'summary)))
8721 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8722 "Move the current article to a different newsgroup.
8723 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8724 When called interactively, if TO-NEWSGROUP is nil, use the value of
8725 the variable `gnus-move-split-methods' for finding a default target
8727 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8728 re-spool using this method."
8730 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8732 (defun gnus-summary-crosspost-article (&optional n)
8733 "Crosspost the current article to some other group."
8735 (gnus-summary-move-article n nil nil 'crosspost))
8737 (defcustom gnus-summary-respool-default-method nil
8738 "Default method type for respooling an article.
8739 If nil, use to the current newsgroup method."
8741 :group 'gnus-summary-mail)
8743 (defun gnus-summary-respool-article (&optional n method)
8744 "Respool the current article.
8745 The article will be squeezed through the mail spooling process again,
8746 which means that it will be put in some mail newsgroup or other
8747 depending on `nnmail-split-methods'.
8748 If N is a positive number, respool the N next articles.
8749 If N is a negative number, respool the N previous articles.
8750 If N is nil and any articles have been marked with the process mark,
8751 respool those articles instead.
8753 Respooling can be done both from mail groups and \"real\" newsgroups.
8754 In the former case, the articles in question will be moved from the
8755 current group into whatever groups they are destined to. In the
8756 latter case, they will be copied into the relevant groups."
8758 (list current-prefix-arg
8759 (let* ((methods (gnus-methods-using 'respool))
8761 (symbol-name (or gnus-summary-respool-default-method
8762 (car (gnus-find-method-for-group
8763 gnus-newsgroup-name)))))
8765 (gnus-completing-read-with-default
8766 methname "What backend do you want to use when respooling?"
8767 methods nil t nil 'gnus-mail-method-history))
8770 ((zerop (length (setq ms (gnus-servers-using-backend
8772 (list (intern method) ""))
8776 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8777 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8780 (error "No method given for respooling"))
8781 (if (assoc (symbol-name
8782 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8783 (gnus-methods-using 'respool))
8784 (gnus-summary-move-article n nil method)
8785 (gnus-summary-copy-article n nil method)))
8787 (defun gnus-summary-import-article (file &optional edit)
8788 "Import an arbitrary file into a mail newsgroup."
8789 (interactive "fImport file: \nP")
8790 (let ((group gnus-newsgroup-name)
8791 (now (current-time))
8792 atts lines group-art)
8793 (unless (gnus-check-backend-function 'request-accept-article group)
8794 (error "%s does not support article importing" group))
8795 (or (file-readable-p file)
8796 (not (file-regular-p file))
8797 (error "Can't read %s" file))
8799 (set-buffer (gnus-get-buffer-create " *import file*"))
8801 (nnheader-insert-file-contents file)
8802 (goto-char (point-min))
8803 (if (nnheader-article-p)
8805 (goto-char (point-min))
8806 (search-forward "\n\n" nil t)
8807 (narrow-to-region (point-min) (1- (point)))
8808 (goto-char (point-min))
8809 (unless (re-search-forward "^date:" nil t)
8810 (goto-char (point-max))
8811 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8812 ;; This doesn't look like an article, so we fudge some headers.
8813 (setq atts (file-attributes file)
8814 lines (count-lines (point-min) (point-max)))
8815 (insert "From: " (read-string "From: ") "\n"
8816 "Subject: " (read-string "Subject: ") "\n"
8817 "Date: " (message-make-date (nth 5 atts)) "\n"
8818 "Message-ID: " (message-make-message-id) "\n"
8819 "Lines: " (int-to-string lines) "\n"
8820 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8821 (setq group-art (gnus-request-accept-article group nil t))
8822 (kill-buffer (current-buffer)))
8823 (setq gnus-newsgroup-active (gnus-activate-group group))
8825 (gnus-summary-goto-article (cdr group-art) nil t)
8827 (gnus-summary-edit-article))))
8829 (defun gnus-summary-create-article ()
8830 "Create an article in a mail newsgroup."
8832 (let ((group gnus-newsgroup-name)
8833 (now (current-time))
8835 (unless (gnus-check-backend-function 'request-accept-article group)
8836 (error "%s does not support article importing" group))
8838 (set-buffer (gnus-get-buffer-create " *import file*"))
8840 (goto-char (point-min))
8841 ;; This doesn't look like an article, so we fudge some headers.
8842 (insert "From: " (read-string "From: ") "\n"
8843 "Subject: " (read-string "Subject: ") "\n"
8844 "Date: " (message-make-date now) "\n"
8845 "Message-ID: " (message-make-message-id) "\n")
8846 (setq group-art (gnus-request-accept-article group nil t))
8847 (kill-buffer (current-buffer)))
8848 (setq gnus-newsgroup-active (gnus-activate-group group))
8850 (gnus-summary-goto-article (cdr group-art) nil t)
8851 (gnus-summary-edit-article)))
8853 (defun gnus-summary-article-posted-p ()
8854 "Say whether the current (mail) article is available from news as well.
8855 This will be the case if the article has both been mailed and posted."
8857 (let ((id (mail-header-references (gnus-summary-article-header)))
8858 (gnus-override-method (car (gnus-refer-article-methods))))
8859 (if (gnus-request-head id "")
8860 (gnus-message 2 "The current message was found on %s"
8861 gnus-override-method)
8862 (gnus-message 2 "The current message couldn't be found on %s"
8863 gnus-override-method)
8866 (defun gnus-summary-expire-articles (&optional now)
8867 "Expire all articles that are marked as expirable in the current group."
8869 (when (gnus-check-backend-function
8870 'request-expire-articles gnus-newsgroup-name)
8871 ;; This backend supports expiry.
8872 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8873 (expirable (if total
8875 ;; We need to update the info for
8876 ;; this group for `gnus-list-of-read-articles'
8877 ;; to give us the right answer.
8878 (gnus-run-hooks 'gnus-exit-group-hook)
8879 (gnus-summary-update-info)
8880 (gnus-list-of-read-articles gnus-newsgroup-name))
8881 (setq gnus-newsgroup-expirable
8882 (sort gnus-newsgroup-expirable '<))))
8883 (expiry-wait (if now 'immediate
8884 (gnus-group-find-parameter
8885 gnus-newsgroup-name 'expiry-wait)))
8886 (nnmail-expiry-target
8887 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8888 nnmail-expiry-target))
8891 ;; There are expirable articles in this group, so we run them
8892 ;; through the expiry process.
8893 (gnus-message 6 "Expiring articles...")
8894 (unless (gnus-check-group gnus-newsgroup-name)
8895 (error "Can't open server for %s" gnus-newsgroup-name))
8896 ;; The list of articles that weren't expired is returned.
8899 (let ((nnmail-expiry-wait-function nil)
8900 (nnmail-expiry-wait expiry-wait))
8901 (setq es (gnus-request-expire-articles
8902 expirable gnus-newsgroup-name)))
8903 (setq es (gnus-request-expire-articles
8904 expirable gnus-newsgroup-name)))
8906 (setq gnus-newsgroup-expirable es))
8907 ;; We go through the old list of expirable, and mark all
8908 ;; really expired articles as nonexistent.
8909 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8910 (let ((gnus-use-cache nil))
8911 (dolist (article expirable)
8912 (when (and (not (memq article es))
8913 (gnus-data-find article))
8914 (gnus-summary-mark-article article gnus-canceled-mark))))))
8915 (gnus-message 6 "Expiring articles...done")))))
8917 (defun gnus-summary-expire-articles-now ()
8918 "Expunge all expirable articles in the current group.
8919 This means that *all* articles that are marked as expirable will be
8920 deleted forever, right now."
8922 (or gnus-expert-user
8924 "Are you really, really, really sure you want to delete all these messages? ")
8926 (gnus-summary-expire-articles t))
8928 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8929 (defun gnus-summary-delete-article (&optional n)
8930 "Delete the N next (mail) articles.
8931 This command actually deletes articles. This is not a marking
8932 command. The article will disappear forever from your life, never to
8934 If N is negative, delete backwards.
8935 If N is nil and articles have been marked with the process mark,
8936 delete these instead."
8938 (unless (gnus-check-backend-function 'request-expire-articles
8939 gnus-newsgroup-name)
8940 (error "The current newsgroup does not support article deletion"))
8941 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8942 (error "Couldn't open server"))
8943 ;; Compute the list of articles to delete.
8944 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8945 (nnmail-expiry-target 'delete)
8947 (if (and gnus-novice-user
8948 (not (gnus-yes-or-no-p
8949 (format "Do you really want to delete %s forever? "
8950 (if (> (length articles) 1)
8951 (format "these %s articles" (length articles))
8954 ;; Delete the articles.
8955 (setq not-deleted (gnus-request-expire-articles
8956 articles gnus-newsgroup-name 'force))
8958 (gnus-summary-remove-process-mark (car articles))
8959 ;; The backend might not have been able to delete the article
8961 (unless (memq (car articles) not-deleted)
8962 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8963 (setq articles (cdr articles)))
8965 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8966 (gnus-summary-position-point)
8967 (gnus-set-mode-line 'summary)
8970 (defun gnus-summary-edit-article (&optional arg)
8971 "Edit the current article.
8972 This will have permanent effect only in mail groups.
8973 If ARG is nil, edit the decoded articles.
8974 If ARG is 1, edit the raw articles.
8975 If ARG is 2, edit the raw articles even in read-only groups.
8976 If ARG is 3, edit the articles with the current handles.
8977 Otherwise, allow editing of articles even in read-only
8980 (let (force raw current-handles)
8989 (setq current-handles
8990 (and (gnus-buffer-live-p gnus-article-buffer)
8991 (with-current-buffer gnus-article-buffer
8993 gnus-article-mime-handles
8994 (setq gnus-article-mime-handles nil))))))
8997 (when (and raw (not force)
8998 (member gnus-newsgroup-name '("nndraft:delayed"
9001 (error "Can't edit the raw article in group %s"
9002 gnus-newsgroup-name))
9004 (set-buffer gnus-summary-buffer)
9005 (let ((mail-parse-charset gnus-newsgroup-charset)
9006 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9007 (gnus-set-global-variables)
9008 (when (and (not force)
9009 (gnus-group-read-only-p))
9010 (error "The current newsgroup does not support article editing"))
9011 (gnus-summary-show-article t)
9012 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9013 (with-current-buffer gnus-article-buffer
9014 (mm-enable-multibyte)))
9015 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9017 (gnus-article-edit-article
9020 (let ((mbl mml-buffer-list))
9021 (setq mml-buffer-list nil)
9022 (mime-to-mml ,'current-handles)
9023 (let ((mbl1 mml-buffer-list))
9024 (setq mml-buffer-list mbl)
9025 (set (make-local-variable 'mml-buffer-list) mbl1))
9026 (make-local-hook 'kill-buffer-hook)
9027 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9028 `(lambda (no-highlight)
9029 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9030 (message-options message-options)
9031 (message-options-set-recipient)
9032 (mail-parse-ignored-charsets
9033 ',gnus-newsgroup-ignored-charsets))
9034 ,(if (not raw) '(progn
9036 (mml-destroy-buffers)
9037 (remove-hook 'kill-buffer-hook
9038 'mml-destroy-buffers t)
9039 (kill-local-variable 'mml-buffer-list)))
9040 (gnus-summary-edit-article-done
9041 ,(or (mail-header-references gnus-current-headers) "")
9042 ,(gnus-group-read-only-p)
9043 ,gnus-summary-buffer no-highlight))))))))
9045 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9047 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9049 "Make edits to the current article permanent."
9052 ;; The buffer restriction contains the entire article if it exists.
9053 (when (article-goto-body)
9054 (let ((lines (count-lines (point) (point-max)))
9055 (length (- (point-max) (point)))
9056 (case-fold-search t)
9057 (body (copy-marker (point))))
9058 (goto-char (point-min))
9059 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9060 (delete-region (match-beginning 1) (match-end 1))
9061 (insert (number-to-string length)))
9062 (goto-char (point-min))
9063 (when (re-search-forward
9064 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9065 (delete-region (match-beginning 1) (match-end 1))
9066 (insert (number-to-string length)))
9067 (goto-char (point-min))
9068 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9069 (delete-region (match-beginning 1) (match-end 1))
9070 (insert (number-to-string lines))))))
9071 ;; Replace the article.
9072 (let ((buf (current-buffer)))
9074 (insert-buffer-substring buf)
9076 (if (and (not read-only)
9077 (not (gnus-request-replace-article
9078 (cdr gnus-article-current) (car gnus-article-current)
9079 (current-buffer) t)))
9080 (error "Couldn't replace article")
9081 ;; Update the summary buffer.
9083 (equal (message-tokenize-header references " ")
9084 (message-tokenize-header
9085 (or (message-fetch-field "references") "") " ")))
9086 ;; We only have to update this line.
9089 (message-narrow-to-head)
9090 (let ((head (buffer-string))
9093 (insert (format "211 %d Article retrieved.\n"
9094 (cdr gnus-article-current)))
9097 (let ((nntp-server-buffer (current-buffer)))
9098 (setq header (car (gnus-get-newsgroup-headers
9101 (set-buffer gnus-summary-buffer)
9102 (gnus-data-set-header
9103 (gnus-data-find (cdr gnus-article-current))
9105 (gnus-summary-update-article-line
9106 (cdr gnus-article-current) header)
9107 (if (gnus-summary-goto-subject
9108 (cdr gnus-article-current) nil t)
9109 (gnus-summary-update-secondary-mark
9110 (cdr gnus-article-current))))))))
9112 (set-buffer (or buffer gnus-summary-buffer))
9113 (gnus-summary-update-article (cdr gnus-article-current))
9114 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9115 (gnus-summary-update-secondary-mark
9116 (cdr gnus-article-current))))
9117 ;; Prettify the article buffer again.
9118 (unless no-highlight
9120 (set-buffer gnus-article-buffer)
9121 ;;;!!! Fix this -- article should be rehighlighted.
9122 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9123 (set-buffer gnus-original-article-buffer)
9124 (gnus-request-article
9125 (cdr gnus-article-current)
9126 (car gnus-article-current) (current-buffer))))
9127 ;; Prettify the summary buffer line.
9128 (when (gnus-visual-p 'summary-highlight 'highlight)
9129 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9131 (defun gnus-summary-edit-wash (key)
9132 "Perform editing command KEY in the article buffer."
9136 (message "%s" (concat (this-command-keys) "- "))
9139 (gnus-summary-edit-article)
9140 (execute-kbd-macro (concat (this-command-keys) key))
9141 (gnus-article-edit-done))
9145 (defun gnus-summary-respool-query (&optional silent trace)
9146 "Query where the respool algorithm would put this article."
9148 (let (gnus-mark-article-hook)
9149 (gnus-summary-select-article)
9151 (set-buffer gnus-original-article-buffer)
9153 (message-narrow-to-head)
9154 (let ((groups (nnmail-article-group 'identity trace)))
9157 (message "This message would go to %s"
9158 (mapconcat 'car groups ", "))
9159 (message "This message would go to no groups"))
9162 (defun gnus-summary-respool-trace ()
9163 "Trace where the respool algorithm would put this article.
9164 Display a buffer showing all fancy splitting patterns which matched."
9166 (gnus-summary-respool-query nil t))
9168 ;; Summary marking commands.
9170 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9171 "Mark articles which has the same subject as read, and then select the next.
9172 If UNMARK is positive, remove any kind of mark.
9173 If UNMARK is negative, tick articles."
9176 (setq unmark (prefix-numeric-value unmark)))
9178 (gnus-summary-mark-same-subject
9179 (gnus-summary-article-subject) unmark)))
9180 ;; Select next unread article. If auto-select-same mode, should
9181 ;; select the first unread article.
9182 (gnus-summary-next-article t (and gnus-auto-select-same
9183 (gnus-summary-article-subject)))
9184 (gnus-message 7 "%d article%s marked as %s"
9185 count (if (= count 1) " is" "s are")
9186 (if unmark "unread" "read"))))
9188 (defun gnus-summary-kill-same-subject (&optional unmark)
9189 "Mark articles which has the same subject as read.
9190 If UNMARK is positive, remove any kind of mark.
9191 If UNMARK is negative, tick articles."
9194 (setq unmark (prefix-numeric-value unmark)))
9196 (gnus-summary-mark-same-subject
9197 (gnus-summary-article-subject) unmark)))
9198 ;; If marked as read, go to next unread subject.
9200 ;; Go to next unread subject.
9201 (gnus-summary-next-subject 1 t))
9202 (gnus-message 7 "%d articles are marked as %s"
9203 count (if unmark "unread" "read"))))
9205 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9206 "Mark articles with same SUBJECT as read, and return marked number.
9207 If optional argument UNMARK is positive, remove any kinds of marks.
9208 If optional argument UNMARK is negative, mark articles as unread instead."
9212 ((null unmark) ; Mark as read.
9215 (gnus-summary-mark-article-as-read gnus-killed-mark)
9216 (gnus-summary-show-thread) t)
9217 (gnus-summary-find-subject subject))
9218 (setq count (1+ count))))
9219 ((> unmark 0) ; Tick.
9222 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9223 (gnus-summary-show-thread) t)
9224 (gnus-summary-find-subject subject))
9225 (setq count (1+ count))))
9226 (t ; Mark as unread.
9229 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9230 (gnus-summary-show-thread) t)
9231 (gnus-summary-find-subject subject))
9232 (setq count (1+ count)))))
9233 (gnus-set-mode-line 'summary)
9234 ;; Return the number of marked articles.
9237 (defun gnus-summary-mark-as-processable (n &optional unmark)
9238 "Set the process mark on the next N articles.
9239 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9240 the process mark instead. The difference between N and the actual
9241 number of articles marked is returned."
9243 (if (and (null n) (gnus-region-active-p))
9244 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9245 (setq n (prefix-numeric-value n))
9246 (let ((backward (< n 0))
9251 (gnus-summary-remove-process-mark
9252 (gnus-summary-article-number))
9253 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9254 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9257 (gnus-message 7 "No more articles"))
9258 (gnus-summary-recenter)
9259 (gnus-summary-position-point)
9262 (defun gnus-summary-unmark-as-processable (n)
9263 "Remove the process mark from the next N articles.
9264 If N is negative, unmark backward instead. The difference between N and
9265 the actual number of articles unmarked is returned."
9267 (gnus-summary-mark-as-processable n t))
9269 (defun gnus-summary-unmark-all-processable ()
9270 "Remove the process mark from all articles."
9273 (while gnus-newsgroup-processable
9274 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9275 (gnus-summary-position-point))
9277 (defun gnus-summary-add-mark (article type)
9278 "Mark ARTICLE with a mark of TYPE."
9279 (let ((vtype (car (assq type gnus-article-mark-lists)))
9282 (error "No such mark type: %s" type)
9283 (setq var (intern (format "gnus-newsgroup-%s" type)))
9284 (set var (cons article (symbol-value var)))
9285 (if (memq type '(processable cached replied forwarded recent saved))
9286 (gnus-summary-update-secondary-mark article)
9287 ;;; !!! This is bogus. We should find out what primary
9288 ;;; !!! mark we want to set.
9289 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9291 (defun gnus-summary-mark-as-expirable (n)
9292 "Mark N articles forward as expirable.
9293 If N is negative, mark backward instead. The difference between N and
9294 the actual number of articles marked is returned."
9296 (gnus-summary-mark-forward n gnus-expirable-mark))
9298 (defun gnus-summary-mark-as-spam (n)
9299 "Mark N articles forward as spam.
9300 If N is negative, mark backward instead. The difference between N and
9301 the actual number of articles marked is returned."
9303 (gnus-summary-mark-forward n gnus-spam-mark))
9305 (defun gnus-summary-mark-article-as-replied (article)
9306 "Mark ARTICLE as replied to and update the summary line.
9307 ARTICLE can also be a list of articles."
9308 (interactive (list (gnus-summary-article-number)))
9309 (let ((articles (if (listp article) article (list article))))
9310 (dolist (article articles)
9311 (push article gnus-newsgroup-replied)
9312 (let ((buffer-read-only nil))
9313 (when (gnus-summary-goto-subject article nil t)
9314 (gnus-summary-update-secondary-mark article))))))
9316 (defun gnus-summary-mark-article-as-forwarded (article)
9317 "Mark ARTICLE as forwarded and update the summary line.
9318 ARTICLE can also be a list of articles."
9319 (let ((articles (if (listp article) article (list article))))
9320 (dolist (article articles)
9321 (push article gnus-newsgroup-forwarded)
9322 (let ((buffer-read-only nil))
9323 (when (gnus-summary-goto-subject article nil t)
9324 (gnus-summary-update-secondary-mark article))))))
9326 (defun gnus-summary-set-bookmark (article)
9327 "Set a bookmark in current article."
9328 (interactive (list (gnus-summary-article-number)))
9329 (when (or (not (get-buffer gnus-article-buffer))
9330 (not gnus-current-article)
9331 (not gnus-article-current)
9332 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9333 (error "No current article selected"))
9334 ;; Remove old bookmark, if one exists.
9335 (let ((old (assq article gnus-newsgroup-bookmarks)))
9337 (setq gnus-newsgroup-bookmarks
9338 (delq old gnus-newsgroup-bookmarks))))
9339 ;; Set the new bookmark, which is on the form
9340 ;; (article-number . line-number-in-body).
9344 (set-buffer gnus-article-buffer)
9348 (goto-char (point-min))
9349 (search-forward "\n\n" nil t)
9352 gnus-newsgroup-bookmarks)
9353 (gnus-message 6 "A bookmark has been added to the current article."))
9355 (defun gnus-summary-remove-bookmark (article)
9356 "Remove the bookmark from the current article."
9357 (interactive (list (gnus-summary-article-number)))
9358 ;; Remove old bookmark, if one exists.
9359 (let ((old (assq article gnus-newsgroup-bookmarks)))
9362 (setq gnus-newsgroup-bookmarks
9363 (delq old gnus-newsgroup-bookmarks))
9364 (gnus-message 6 "Removed bookmark."))
9365 (gnus-message 6 "No bookmark in current article."))))
9367 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9368 (defun gnus-summary-mark-as-dormant (n)
9369 "Mark N articles forward as dormant.
9370 If N is negative, mark backward instead. The difference between N and
9371 the actual number of articles marked is returned."
9373 (gnus-summary-mark-forward n gnus-dormant-mark))
9375 (defun gnus-summary-set-process-mark (article)
9376 "Set the process mark on ARTICLE and update the summary line."
9377 (setq gnus-newsgroup-processable
9379 (delq article gnus-newsgroup-processable)))
9380 (when (gnus-summary-goto-subject article)
9381 (gnus-summary-show-thread)
9382 (gnus-summary-goto-subject article)
9383 (gnus-summary-update-secondary-mark article)))
9385 (defun gnus-summary-remove-process-mark (article)
9386 "Remove the process mark from ARTICLE and update the summary line."
9387 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9388 (when (gnus-summary-goto-subject article)
9389 (gnus-summary-show-thread)
9390 (gnus-summary-goto-subject article)
9391 (gnus-summary-update-secondary-mark article)))
9393 (defun gnus-summary-set-saved-mark (article)
9394 "Set the process mark on ARTICLE and update the summary line."
9395 (push article gnus-newsgroup-saved)
9396 (when (gnus-summary-goto-subject article)
9397 (gnus-summary-update-secondary-mark article)))
9399 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9400 "Mark N articles as read forwards.
9401 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9402 The difference between N and the actual number of articles marked is
9404 If NO-EXPIRE, auto-expiry will be inhibited."
9406 (gnus-summary-show-thread)
9407 (let ((backward (< n 0))
9408 (gnus-summary-goto-unread
9409 (and gnus-summary-goto-unread
9410 (not (eq gnus-summary-goto-unread 'never))
9411 (not (memq mark (list gnus-unread-mark
9412 gnus-ticked-mark gnus-dormant-mark)))))
9414 (mark (or mark gnus-del-mark)))
9416 (gnus-summary-mark-article nil mark no-expire)
9417 (zerop (gnus-summary-next-subject
9419 (and gnus-summary-goto-unread
9420 (not (eq gnus-summary-goto-unread 'never)))
9424 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9425 (gnus-summary-recenter)
9426 (gnus-summary-position-point)
9427 (gnus-set-mode-line 'summary)
9430 (defun gnus-summary-mark-article-as-read (mark)
9431 "Mark the current article quickly as read with MARK."
9432 (let ((article (gnus-summary-article-number)))
9433 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9434 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9435 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9436 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9437 (push (cons article mark) gnus-newsgroup-reads)
9438 ;; Possibly remove from cache, if that is used.
9439 (when gnus-use-cache
9440 (gnus-cache-enter-remove-article article))
9441 ;; Allow the backend to change the mark.
9442 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9443 ;; Check for auto-expiry.
9444 (when (and gnus-newsgroup-auto-expire
9445 (memq mark gnus-auto-expirable-marks))
9446 (setq mark gnus-expirable-mark)
9447 ;; Let the backend know about the mark change.
9448 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9449 (push article gnus-newsgroup-expirable))
9450 ;; Set the mark in the buffer.
9451 (gnus-summary-update-mark mark 'unread)
9454 (defun gnus-summary-mark-article-as-unread (mark)
9455 "Mark the current article quickly as unread with MARK."
9456 (let* ((article (gnus-summary-article-number))
9457 (old-mark (gnus-summary-article-mark article)))
9458 ;; Allow the backend to change the mark.
9459 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9460 (if (eq mark old-mark)
9464 (gnus-error 1 "Can't mark negative article numbers")
9466 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9467 (setq gnus-newsgroup-spam-marked
9468 (delq article gnus-newsgroup-spam-marked))
9469 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9470 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9471 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9472 (cond ((= mark gnus-ticked-mark)
9473 (setq gnus-newsgroup-marked
9474 (gnus-add-to-sorted-list gnus-newsgroup-marked
9476 ((= mark gnus-spam-mark)
9477 (setq gnus-newsgroup-spam-marked
9478 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9480 ((= mark gnus-dormant-mark)
9481 (setq gnus-newsgroup-dormant
9482 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9485 (setq gnus-newsgroup-unreads
9486 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9488 (gnus-pull article gnus-newsgroup-reads)
9490 ;; See whether the article is to be put in the cache.
9492 (vectorp (gnus-summary-article-header article))
9494 (gnus-cache-possibly-enter-article
9495 gnus-newsgroup-name article
9496 (= mark gnus-ticked-mark)
9497 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9500 (gnus-summary-update-mark mark 'unread)
9503 (defun gnus-summary-mark-article (&optional article mark no-expire)
9504 "Mark ARTICLE with MARK. MARK can be any character.
9505 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9506 `??' (dormant) and `?E' (expirable).
9507 If MARK is nil, then the default character `?r' is used.
9508 If ARTICLE is nil, then the article on the current line will be
9510 If NO-EXPIRE, auto-expiry will be inhibited."
9511 ;; The mark might be a string.
9512 (when (stringp mark)
9513 (setq mark (aref mark 0)))
9514 ;; If no mark is given, then we check auto-expiring.
9516 (setq mark gnus-del-mark))
9517 (when (and (not no-expire)
9518 gnus-newsgroup-auto-expire
9519 (memq mark gnus-auto-expirable-marks))
9520 (setq mark gnus-expirable-mark))
9521 (let ((article (or article (gnus-summary-article-number)))
9522 (old-mark (gnus-summary-article-mark article)))
9523 ;; Allow the backend to change the mark.
9524 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9525 (if (eq mark old-mark)
9528 (error "No article on current line"))
9529 (if (not (if (or (= mark gnus-unread-mark)
9530 (= mark gnus-ticked-mark)
9531 (= mark gnus-spam-mark)
9532 (= mark gnus-dormant-mark))
9533 (gnus-mark-article-as-unread article mark)
9534 (gnus-mark-article-as-read article mark)))
9536 ;; See whether the article is to be put in the cache.
9538 (not (= mark gnus-canceled-mark))
9539 (vectorp (gnus-summary-article-header article))
9541 (gnus-cache-possibly-enter-article
9542 gnus-newsgroup-name article
9543 (= mark gnus-ticked-mark)
9544 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9546 (when (gnus-summary-goto-subject article nil t)
9547 (let ((buffer-read-only nil))
9548 (gnus-summary-show-thread)
9550 (gnus-summary-update-mark mark 'unread)
9553 (defun gnus-summary-update-secondary-mark (article)
9554 "Update the secondary (read, process, cache) mark."
9555 (gnus-summary-update-mark
9556 (cond ((memq article gnus-newsgroup-processable)
9558 ((memq article gnus-newsgroup-cached)
9560 ((memq article gnus-newsgroup-replied)
9562 ((memq article gnus-newsgroup-forwarded)
9563 gnus-forwarded-mark)
9564 ((memq article gnus-newsgroup-saved)
9566 ((memq article gnus-newsgroup-recent)
9568 ((memq article gnus-newsgroup-unseen)
9572 (when (gnus-visual-p 'summary-highlight 'highlight)
9573 (gnus-run-hooks 'gnus-summary-update-hook))
9576 (defun gnus-summary-update-mark (mark type)
9577 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9578 (buffer-read-only nil))
9579 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9581 (when (looking-at "\r")
9583 (when (<= (+ forward (point)) (point-max))
9584 ;; Go to the right position on the line.
9585 (goto-char (+ forward (point)))
9586 ;; Replace the old mark with the new mark.
9587 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9588 ;; Optionally update the marks by some user rule.
9589 (when (eq type 'unread)
9591 (gnus-data-find (gnus-summary-article-number)) mark)
9592 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9594 (defun gnus-mark-article-as-read (article &optional mark)
9595 "Enter ARTICLE in the pertinent lists and remove it from others."
9596 ;; Make the article expirable.
9597 (let ((mark (or mark gnus-del-mark)))
9598 (setq gnus-newsgroup-expirable
9599 (if (= mark gnus-expirable-mark)
9600 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9601 (delq article gnus-newsgroup-expirable)))
9602 ;; Remove from unread and marked lists.
9603 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9604 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9605 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9606 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9607 (push (cons article mark) gnus-newsgroup-reads)
9608 ;; Possibly remove from cache, if that is used.
9609 (when gnus-use-cache
9610 (gnus-cache-enter-remove-article article))
9613 (defun gnus-mark-article-as-unread (article &optional mark)
9614 "Enter ARTICLE in the pertinent lists and remove it from others."
9615 (let ((mark (or mark gnus-ticked-mark)))
9618 (gnus-error 1 "Can't mark negative article numbers")
9620 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9621 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9622 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9623 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9624 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9626 ;; Unsuppress duplicates?
9627 (when gnus-suppress-duplicates
9628 (gnus-dup-unsuppress-article article))
9630 (cond ((= mark gnus-ticked-mark)
9631 (setq gnus-newsgroup-marked
9632 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9633 ((= mark gnus-spam-mark)
9634 (setq gnus-newsgroup-spam-marked
9635 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9637 ((= mark gnus-dormant-mark)
9638 (setq gnus-newsgroup-dormant
9639 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9641 (setq gnus-newsgroup-unreads
9642 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9643 (gnus-pull article gnus-newsgroup-reads)
9646 (defalias 'gnus-summary-mark-as-unread-forward
9647 'gnus-summary-tick-article-forward)
9648 (make-obsolete 'gnus-summary-mark-as-unread-forward
9649 'gnus-summary-tick-article-forward)
9650 (defun gnus-summary-tick-article-forward (n)
9651 "Tick N articles forwards.
9652 If N is negative, tick backwards instead.
9653 The difference between N and the number of articles ticked is returned."
9655 (gnus-summary-mark-forward n gnus-ticked-mark))
9657 (defalias 'gnus-summary-mark-as-unread-backward
9658 'gnus-summary-tick-article-backward)
9659 (make-obsolete 'gnus-summary-mark-as-unread-backward
9660 'gnus-summary-tick-article-backward)
9661 (defun gnus-summary-tick-article-backward (n)
9662 "Tick N articles backwards.
9663 The difference between N and the number of articles ticked is returned."
9665 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9667 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9668 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9669 (defun gnus-summary-tick-article (&optional article clear-mark)
9670 "Mark current article as unread.
9671 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9672 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9674 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9677 (defun gnus-summary-mark-as-read-forward (n)
9678 "Mark N articles as read forwards.
9679 If N is negative, mark backwards instead.
9680 The difference between N and the actual number of articles marked is
9683 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9685 (defun gnus-summary-mark-as-read-backward (n)
9686 "Mark the N articles as read backwards.
9687 The difference between N and the actual number of articles marked is
9690 (gnus-summary-mark-forward
9691 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9693 (defun gnus-summary-mark-as-read (&optional article mark)
9694 "Mark current article as read.
9695 ARTICLE specifies the article to be marked as read.
9696 MARK specifies a string to be inserted at the beginning of the line."
9697 (gnus-summary-mark-article article mark))
9699 (defun gnus-summary-clear-mark-forward (n)
9700 "Clear marks from N articles forward.
9701 If N is negative, clear backward instead.
9702 The difference between N and the number of marks cleared is returned."
9704 (gnus-summary-mark-forward n gnus-unread-mark))
9706 (defun gnus-summary-clear-mark-backward (n)
9707 "Clear marks from N articles backward.
9708 The difference between N and the number of marks cleared is returned."
9710 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9712 (defun gnus-summary-mark-unread-as-read ()
9713 "Intended to be used by `gnus-summary-mark-article-hook'."
9714 (when (memq gnus-current-article gnus-newsgroup-unreads)
9715 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9717 (defun gnus-summary-mark-read-and-unread-as-read ()
9718 "Intended to be used by `gnus-summary-mark-article-hook'."
9719 (let ((mark (gnus-summary-article-mark)))
9720 (when (or (gnus-unread-mark-p mark)
9721 (gnus-read-mark-p mark))
9722 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9724 (defun gnus-summary-mark-unread-as-ticked ()
9725 "Intended to be used by `gnus-summary-mark-article-hook'."
9726 (when (memq gnus-current-article gnus-newsgroup-unreads)
9727 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9729 (defun gnus-summary-mark-region-as-read (point mark all)
9730 "Mark all unread articles between point and mark as read.
9731 If given a prefix, mark all articles between point and mark as read,
9732 even ticked and dormant ones."
9733 (interactive "r\nP")
9742 (memq (setq article (gnus-summary-article-number))
9743 gnus-newsgroup-unreads))
9744 (gnus-summary-mark-article article gnus-del-mark))
9746 (gnus-summary-find-next))))))
9748 (defun gnus-summary-mark-below (score mark)
9749 "Mark articles with score less than SCORE with MARK."
9750 (interactive "P\ncMark: ")
9751 (setq score (if score
9752 (prefix-numeric-value score)
9753 (or gnus-summary-default-score 0)))
9755 (set-buffer gnus-summary-buffer)
9756 (goto-char (point-min))
9759 (and (< (gnus-summary-article-score) score)
9760 (gnus-summary-mark-article nil mark))
9761 (gnus-summary-find-next)))))
9763 (defun gnus-summary-kill-below (&optional score)
9764 "Mark articles with score below SCORE as read."
9766 (gnus-summary-mark-below score gnus-killed-mark))
9768 (defun gnus-summary-clear-above (&optional score)
9769 "Clear all marks from articles with score above SCORE."
9771 (gnus-summary-mark-above score gnus-unread-mark))
9773 (defun gnus-summary-tick-above (&optional score)
9774 "Tick all articles with score above SCORE."
9776 (gnus-summary-mark-above score gnus-ticked-mark))
9778 (defun gnus-summary-mark-above (score mark)
9779 "Mark articles with score over SCORE with MARK."
9780 (interactive "P\ncMark: ")
9781 (setq score (if score
9782 (prefix-numeric-value score)
9783 (or gnus-summary-default-score 0)))
9785 (set-buffer gnus-summary-buffer)
9786 (goto-char (point-min))
9788 (when (> (gnus-summary-article-score) score)
9789 (gnus-summary-mark-article nil mark))
9791 (gnus-summary-find-next)))))
9793 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9794 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9795 (defun gnus-summary-limit-include-expunged (&optional no-error)
9796 "Display all the hidden articles that were expunged for low scores."
9798 (let ((buffer-read-only nil))
9799 (let ((scored gnus-newsgroup-scored)
9802 (unless (gnus-summary-article-header (caar scored))
9803 (and (setq h (gnus-number-to-header (caar scored)))
9804 (< (cdar scored) gnus-summary-expunge-below)
9806 (setq scored (cdr scored)))
9808 (when (not no-error)
9809 (error "No expunged articles hidden"))
9810 (goto-char (point-min))
9811 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9812 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9813 (mapcar (lambda (x) (push (mail-header-number x)
9814 gnus-newsgroup-limit))
9816 (gnus-summary-prepare-unthreaded (nreverse headers))
9817 (goto-char (point-min))
9818 (gnus-summary-position-point)
9821 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9822 "Mark all unread articles in this newsgroup as read.
9823 If prefix argument ALL is non-nil, ticked and dormant articles will
9824 also be marked as read.
9825 If QUIETLY is non-nil, no questions will be asked.
9826 If TO-HERE is non-nil, it should be a point in the buffer. All
9827 articles before (after, if REVERSE is set) this point will be marked as read.
9828 Note that this function will only catch up the unread article
9829 in the current summary buffer limitation.
9830 The number of articles marked as read is returned."
9835 (not gnus-interactive-catchup) ;Without confirmation?
9839 "Mark absolutely all articles as read? "
9840 "Mark all unread articles as read? ")))
9842 (not gnus-newsgroup-adaptive)
9843 (not gnus-newsgroup-auto-expire)
9844 (not gnus-suppress-duplicates)
9845 (or (not gnus-use-cache)
9846 (eq gnus-use-cache 'passive)))
9849 (setq gnus-newsgroup-marked nil
9850 gnus-newsgroup-spam-marked nil
9851 gnus-newsgroup-dormant nil))
9852 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9853 ;; We actually mark all articles as canceled, which we
9854 ;; have to do when using auto-expiry or adaptive scoring.
9855 (gnus-summary-show-all-threads)
9856 (if (and to-here reverse)
9860 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9861 (gnus-summary-find-next (not all) nil nil t))))
9862 (when (gnus-summary-first-subject (not all) t)
9864 (if to-here (< (point) to-here) t)
9865 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9866 (gnus-summary-find-next (not all) nil nil t)))))
9867 (gnus-set-mode-line 'summary))
9869 (gnus-summary-position-point)))
9871 (defun gnus-summary-catchup-to-here (&optional all)
9872 "Mark all unticked articles before the current one as read.
9873 If ALL is non-nil, also mark ticked and dormant articles as read."
9876 (gnus-save-hidden-threads
9877 (let ((beg (point)))
9878 ;; We check that there are unread articles.
9879 (when (or all (gnus-summary-find-prev))
9880 (gnus-summary-catchup all t beg)))))
9881 (gnus-summary-position-point))
9883 (defun gnus-summary-catchup-from-here (&optional all)
9884 "Mark all unticked articles after the current one as read.
9885 If ALL is non-nil, also mark ticked and dormant articles as read."
9888 (gnus-save-hidden-threads
9889 (let ((beg (point)))
9890 ;; We check that there are unread articles.
9891 (when (or all (gnus-summary-find-next))
9892 (gnus-summary-catchup all t beg nil t)))))
9894 (gnus-summary-position-point))
9895 (defun gnus-summary-catchup-all (&optional quietly)
9896 "Mark all articles in this newsgroup as read.
9897 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
9898 instead, which marks only unread articles as read."
9900 (gnus-summary-catchup t quietly))
9902 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9903 "Mark all unread articles in this group as read, then exit.
9904 If prefix argument ALL is non-nil, all articles are marked as read.
9905 If QUIETLY is non-nil, no questions will be asked."
9907 (when (gnus-summary-catchup all quietly nil 'fast)
9908 ;; Select next newsgroup or exit.
9909 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9910 (eq gnus-auto-select-next 'quietly))
9911 (gnus-summary-next-group nil)
9912 (gnus-summary-exit))))
9914 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9915 "Mark all articles in this newsgroup as read, and then exit.
9916 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
9917 instead, which marks only unread articles as read."
9919 (gnus-summary-catchup-and-exit t quietly))
9921 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9922 "Mark all articles in this group as read and select the next group.
9923 If given a prefix, mark all articles, unread as well as ticked, as
9927 (gnus-summary-catchup all))
9928 (gnus-summary-next-group))
9934 (defmacro gnus-with-article (article &rest forms)
9935 "Select ARTICLE and perform FORMS in the original article buffer.
9936 Then replace the article with the result."
9938 ;; We don't want the article to be marked as read.
9939 (let (gnus-mark-article-hook)
9940 (gnus-summary-select-article t t nil ,article))
9941 (set-buffer gnus-original-article-buffer)
9943 (if (not (gnus-check-backend-function
9944 'request-replace-article (car gnus-article-current)))
9945 (gnus-message 5 "Read-only group; not replacing")
9946 (unless (gnus-request-replace-article
9947 ,article (car gnus-article-current)
9949 (error "Couldn't replace article")))
9950 ;; The cache and backlog have to be flushed somewhat.
9951 (when gnus-keep-backlog
9952 (gnus-backlog-remove-article
9953 (car gnus-article-current) (cdr gnus-article-current)))
9954 (when gnus-use-cache
9955 (gnus-cache-update-article
9956 (car gnus-article-current) (cdr gnus-article-current)))))
9958 (put 'gnus-with-article 'lisp-indent-function 1)
9959 (put 'gnus-with-article 'edebug-form-spec '(form body))
9961 ;; Thread-based commands.
9963 (defun gnus-summary-articles-in-thread (&optional article)
9964 "Return a list of all articles in the current thread.
9965 If ARTICLE is non-nil, return all articles in the thread that starts
9967 (let* ((article (or article (gnus-summary-article-number)))
9968 (data (gnus-data-find-list article))
9969 (top-level (gnus-data-level (car data)))
9971 (cond ((null gnus-thread-operation-ignore-subject)
9972 (gnus-simplify-subject-re
9973 (mail-header-subject (gnus-data-header (car data)))))
9974 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9975 (gnus-simplify-subject-fuzzy
9976 (mail-header-subject (gnus-data-header (car data)))))
9978 (end-point (save-excursion
9979 (if (gnus-summary-go-to-next-thread)
9980 (point) (point-max))))
9983 (< (gnus-data-pos (car data)) end-point))
9984 (when (or (not top-subject)
9985 (string= top-subject
9986 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9987 (gnus-simplify-subject-fuzzy
9988 (mail-header-subject
9989 (gnus-data-header (car data))))
9990 (gnus-simplify-subject-re
9991 (mail-header-subject
9992 (gnus-data-header (car data)))))))
9993 (push (gnus-data-number (car data)) articles))
9994 (unless (and (setq data (cdr data))
9995 (> (gnus-data-level (car data)) top-level))
9997 ;; Return the list of articles.
9998 (nreverse articles)))
10000 (defun gnus-summary-rethread-current ()
10001 "Rethread the thread the current article is part of."
10003 (let* ((gnus-show-threads t)
10004 (article (gnus-summary-article-number))
10005 (id (mail-header-id (gnus-summary-article-header)))
10006 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10008 (error "No article on the current line"))
10009 (gnus-rebuild-thread id)
10010 (gnus-summary-goto-subject article)))
10012 (defun gnus-summary-reparent-thread ()
10013 "Make the current article child of the marked (or previous) article.
10015 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10016 is non-nil or the Subject: of both articles are the same."
10018 (unless (not (gnus-group-read-only-p))
10019 (error "The current newsgroup does not support article editing"))
10020 (unless (<= (length gnus-newsgroup-processable) 1)
10021 (error "No more than one article may be marked"))
10022 (save-window-excursion
10023 (let ((gnus-article-buffer " *reparent*")
10024 (current-article (gnus-summary-article-number))
10025 ;; First grab the marked article, otherwise one line up.
10026 (parent-article (if (not (null gnus-newsgroup-processable))
10027 (car gnus-newsgroup-processable)
10029 (if (eq (forward-line -1) 0)
10030 (gnus-summary-article-number)
10031 (error "Beginning of summary buffer"))))))
10032 (unless (not (eq current-article parent-article))
10033 (error "An article may not be self-referential"))
10034 (let ((message-id (mail-header-id
10035 (gnus-summary-article-header parent-article))))
10036 (unless (and message-id (not (equal message-id "")))
10037 (error "No message-id in desired parent"))
10038 (gnus-with-article current-article
10040 (goto-char (point-min))
10041 (message-narrow-to-head)
10042 (if (re-search-forward "^References: " nil t)
10044 (re-search-forward "^[^ \t]" nil t)
10047 (insert " " message-id))
10048 (insert "References: " message-id "\n"))))
10049 (set-buffer gnus-summary-buffer)
10050 (gnus-summary-unmark-all-processable)
10051 (gnus-summary-update-article current-article)
10052 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10053 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10054 (gnus-summary-rethread-current)
10055 (gnus-message 3 "Article %d is now the child of article %d"
10056 current-article parent-article)))))
10058 (defun gnus-summary-toggle-threads (&optional arg)
10059 "Toggle showing conversation threads.
10060 If ARG is positive number, turn showing conversation threads on."
10062 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10063 (setq gnus-show-threads
10064 (if (null arg) (not gnus-show-threads)
10065 (> (prefix-numeric-value arg) 0)))
10066 (gnus-summary-prepare)
10067 (gnus-summary-goto-subject current)
10068 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10069 (gnus-summary-position-point)))
10071 (defun gnus-summary-show-all-threads ()
10072 "Show all threads."
10075 (let ((buffer-read-only nil))
10076 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10077 (gnus-summary-position-point))
10079 (defun gnus-summary-show-thread ()
10080 "Show thread subtrees.
10081 Returns nil if no thread was there to be shown."
10083 (let ((buffer-read-only nil)
10085 ;; first goto end then to beg, to have point at beg after let
10086 (end (progn (end-of-line) (point)))
10087 (beg (progn (beginning-of-line) (point))))
10089 ;; Any hidden lines here?
10090 (search-forward "\r" end t)
10091 (subst-char-in-region beg end ?\^M ?\n t)
10093 (gnus-summary-position-point))))
10095 (defun gnus-summary-maybe-hide-threads ()
10096 "If requested, hide the threads that should be hidden."
10097 (when (and gnus-show-threads
10098 gnus-thread-hide-subtree)
10099 (gnus-summary-hide-all-threads
10100 (if (or (consp gnus-thread-hide-subtree)
10101 (gnus-functionp gnus-thread-hide-subtree))
10102 (gnus-make-predicate gnus-thread-hide-subtree)
10105 ;;; Hiding predicates.
10107 (defun gnus-article-unread-p (header)
10108 (memq (mail-header-number header) gnus-newsgroup-unreads))
10110 (defun gnus-article-unseen-p (header)
10111 (memq (mail-header-number header) gnus-newsgroup-unseen))
10113 (defun gnus-map-articles (predicate articles)
10114 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10115 (apply 'gnus-or (mapcar predicate
10116 (mapcar 'gnus-summary-article-header articles))))
10118 (defun gnus-summary-hide-all-threads (&optional predicate)
10119 "Hide all thread subtrees.
10120 If PREDICATE is supplied, threads that satisfy this predicate
10121 will not be hidden."
10124 (goto-char (point-min))
10127 (when (or (not predicate)
10129 predicate (gnus-summary-article-children)))
10130 (gnus-summary-hide-thread))
10131 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10132 (gnus-summary-position-point))
10134 (defun gnus-summary-hide-thread ()
10135 "Hide thread subtrees.
10136 If PREDICATE is supplied, threads that satisfy this predicate
10137 will not be hidden.
10138 Returns nil if no threads were there to be hidden."
10140 (let ((buffer-read-only nil)
10142 (article (gnus-summary-article-number)))
10144 ;; Go forward until either the buffer ends or the subthread
10146 (when (and (not (eobp))
10147 (or (zerop (gnus-summary-next-thread 1 t))
10148 (goto-char (point-max))))
10150 (if (and (> (point) start)
10151 (search-backward "\n" start t))
10153 (subst-char-in-region start (point) ?\n ?\^M)
10154 (gnus-summary-goto-subject article))
10158 (defun gnus-summary-go-to-next-thread (&optional previous)
10159 "Go to the same level (or less) next thread.
10160 If PREVIOUS is non-nil, go to previous thread instead.
10161 Return the article number moved to, or nil if moving was impossible."
10162 (let ((level (gnus-summary-thread-level))
10163 (way (if previous -1 1))
10166 (while (and (not (eobp))
10167 (< level (gnus-summary-thread-level)))
10168 (forward-line way))
10175 (gnus-summary-article-number)
10176 (goto-char beg)))))
10178 (defun gnus-summary-next-thread (n &optional silent)
10179 "Go to the same level next N'th thread.
10180 If N is negative, search backward instead.
10181 Returns the difference between N and the number of skips actually
10184 If SILENT, don't output messages."
10186 (let ((backward (< n 0))
10188 (while (and (> n 0)
10189 (gnus-summary-go-to-next-thread backward))
10192 (gnus-summary-position-point))
10193 (when (and (not silent) (/= 0 n))
10194 (gnus-message 7 "No more threads"))
10197 (defun gnus-summary-prev-thread (n)
10198 "Go to the same level previous N'th thread.
10199 Returns the difference between N and the number of skips actually
10202 (gnus-summary-next-thread (- n)))
10204 (defun gnus-summary-go-down-thread ()
10205 "Go down one level in the current thread."
10206 (let ((children (gnus-summary-article-children)))
10208 (gnus-summary-goto-subject (car children)))))
10210 (defun gnus-summary-go-up-thread ()
10211 "Go up one level in the current thread."
10212 (let ((parent (gnus-summary-article-parent)))
10214 (gnus-summary-goto-subject parent))))
10216 (defun gnus-summary-down-thread (n)
10217 "Go down thread N steps.
10218 If N is negative, go up instead.
10219 Returns the difference between N and how many steps down that were
10224 (while (and (> n 0)
10225 (if up (gnus-summary-go-up-thread)
10226 (gnus-summary-go-down-thread)))
10228 (gnus-summary-position-point)
10230 (gnus-message 7 "Can't go further"))
10233 (defun gnus-summary-up-thread (n)
10234 "Go up thread N steps.
10235 If N is negative, go down instead.
10236 Returns the difference between N and how many steps down that were
10239 (gnus-summary-down-thread (- n)))
10241 (defun gnus-summary-top-thread ()
10242 "Go to the top of the thread."
10244 (while (gnus-summary-go-up-thread))
10245 (gnus-summary-article-number))
10247 (defun gnus-summary-kill-thread (&optional unmark)
10248 "Mark articles under current thread as read.
10249 If the prefix argument is positive, remove any kinds of marks.
10250 If the prefix argument is negative, tick articles instead."
10253 (setq unmark (prefix-numeric-value unmark)))
10254 (let ((articles (gnus-summary-articles-in-thread)))
10256 ;; Expand the thread.
10257 (gnus-summary-show-thread)
10258 ;; Mark all the articles.
10260 (gnus-summary-goto-subject (car articles))
10261 (cond ((null unmark)
10262 (gnus-summary-mark-article-as-read gnus-killed-mark))
10264 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10266 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10267 (setq articles (cdr articles))))
10268 ;; Hide killed subtrees.
10270 gnus-thread-hide-killed
10271 (gnus-summary-hide-thread))
10272 ;; If marked as read, go to next unread subject.
10273 (when (null unmark)
10274 ;; Go to next unread subject.
10275 (gnus-summary-next-subject 1 t)))
10276 (gnus-set-mode-line 'summary))
10278 ;; Summary sorting commands
10280 (defun gnus-summary-sort-by-number (&optional reverse)
10281 "Sort the summary buffer by article number.
10282 Argument REVERSE means reverse order."
10284 (gnus-summary-sort 'number reverse))
10286 (defun gnus-summary-sort-by-random (&optional reverse)
10287 "Randomize the order in the summary buffer.
10288 Argument REVERSE means to randomize in reverse order."
10290 (gnus-summary-sort 'random reverse))
10292 (defun gnus-summary-sort-by-author (&optional reverse)
10293 "Sort the summary buffer by author name alphabetically.
10294 If `case-fold-search' is non-nil, case of letters is ignored.
10295 Argument REVERSE means reverse order."
10297 (gnus-summary-sort 'author reverse))
10299 (defun gnus-summary-sort-by-subject (&optional reverse)
10300 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10301 If `case-fold-search' is non-nil, case of letters is ignored.
10302 Argument REVERSE means reverse order."
10304 (gnus-summary-sort 'subject reverse))
10306 (defun gnus-summary-sort-by-date (&optional reverse)
10307 "Sort the summary buffer by date.
10308 Argument REVERSE means reverse order."
10310 (gnus-summary-sort 'date reverse))
10312 (defun gnus-summary-sort-by-score (&optional reverse)
10313 "Sort the summary buffer by score.
10314 Argument REVERSE means reverse order."
10316 (gnus-summary-sort 'score reverse))
10318 (defun gnus-summary-sort-by-lines (&optional reverse)
10319 "Sort the summary buffer by the number of lines.
10320 Argument REVERSE means reverse order."
10322 (gnus-summary-sort 'lines reverse))
10324 (defun gnus-summary-sort-by-chars (&optional reverse)
10325 "Sort the summary buffer by article length.
10326 Argument REVERSE means reverse order."
10328 (gnus-summary-sort 'chars reverse))
10330 (defun gnus-summary-sort-by-original (&optional reverse)
10331 "Sort the summary buffer using the default sorting method.
10332 Argument REVERSE means reverse order."
10334 (let* ((buffer-read-only)
10335 (gnus-summary-prepare-hook nil))
10336 ;; We do the sorting by regenerating the threads.
10337 (gnus-summary-prepare)
10338 ;; Hide subthreads if needed.
10339 (gnus-summary-maybe-hide-threads)))
10341 (defun gnus-summary-sort (predicate reverse)
10342 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10343 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10344 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10345 (gnus-thread-sort-functions
10350 (gnus-sort-gathered-threads-function
10351 gnus-thread-sort-functions)
10352 (gnus-article-sort-functions
10356 (,article t2 t1))))
10358 (gnus-summary-prepare-hook nil))
10359 ;; We do the sorting by regenerating the threads.
10360 (gnus-summary-prepare)
10361 ;; Hide subthreads if needed.
10362 (gnus-summary-maybe-hide-threads)))
10364 ;; Summary saving commands.
10366 (defun gnus-summary-save-article (&optional n not-saved)
10367 "Save the current article using the default saver function.
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.
10372 The variable `gnus-default-article-saver' specifies the saver function."
10374 (let* ((articles (gnus-summary-work-articles n))
10375 (save-buffer (save-excursion
10376 (nnheader-set-temp-buffer " *Gnus Save*")))
10377 (num (length articles))
10379 (dolist (article articles)
10380 (setq header (gnus-summary-article-header article))
10381 (if (not (vectorp header))
10382 ;; This is a pseudo-article.
10383 (if (assq 'name header)
10384 (gnus-copy-file (cdr (assq 'name header)))
10385 (gnus-message 1 "Article %d is unsaveable" article))
10386 ;; This is a real article.
10387 (save-window-excursion
10388 (let ((gnus-display-mime-function nil)
10389 (gnus-article-prepare-hook nil))
10390 (gnus-summary-select-article t nil nil article)))
10392 (set-buffer save-buffer)
10394 (insert-buffer-substring gnus-original-article-buffer))
10395 (setq file (gnus-article-save save-buffer file num))
10396 (gnus-summary-remove-process-mark article)
10398 (gnus-summary-set-saved-mark article))))
10399 (gnus-kill-buffer save-buffer)
10400 (gnus-summary-position-point)
10401 (gnus-set-mode-line 'summary)
10404 (defun gnus-summary-pipe-output (&optional arg)
10405 "Pipe the current article to a subprocess.
10406 If N is a positive number, pipe the N next articles.
10407 If N is a negative number, pipe the N previous articles.
10408 If N is nil and any articles have been marked with the process mark,
10409 pipe those articles instead."
10411 (require 'gnus-art)
10412 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10413 (gnus-summary-save-article arg t))
10414 (let ((buffer (get-buffer "*Shell Command Output*")))
10416 (with-current-buffer buffer (> (point-max) (point-min))))
10417 (gnus-configure-windows 'pipe))))
10419 (defun gnus-summary-save-article-mail (&optional arg)
10420 "Append the current article to an mail file.
10421 If N is a positive number, save the N next articles.
10422 If N is a negative number, save the N previous articles.
10423 If N is nil and any articles have been marked with the process mark,
10424 save those articles instead."
10426 (require 'gnus-art)
10427 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10428 (gnus-summary-save-article arg)))
10430 (defun gnus-summary-save-article-rmail (&optional arg)
10431 "Append the current article to an rmail file.
10432 If N is a positive number, save the N next articles.
10433 If N is a negative number, save the N previous articles.
10434 If N is nil and any articles have been marked with the process mark,
10435 save those articles instead."
10437 (require 'gnus-art)
10438 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10439 (gnus-summary-save-article arg)))
10441 (defun gnus-summary-save-article-file (&optional arg)
10442 "Append the current article to a file.
10443 If N is a positive number, save the N next articles.
10444 If N is a negative number, save the N previous articles.
10445 If N is nil and any articles have been marked with the process mark,
10446 save those articles instead."
10448 (require 'gnus-art)
10449 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10450 (gnus-summary-save-article arg)))
10452 (defun gnus-summary-write-article-file (&optional arg)
10453 "Write the current article to a file, deleting the previous file.
10454 If N is a positive number, save the N next articles.
10455 If N is a negative number, save the N previous articles.
10456 If N is nil and any articles have been marked with the process mark,
10457 save those articles instead."
10459 (require 'gnus-art)
10460 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10461 (gnus-summary-save-article arg)))
10463 (defun gnus-summary-save-article-body-file (&optional arg)
10464 "Append the current article body to a file.
10465 If N is a positive number, save the N next articles.
10466 If N is a negative number, save the N previous articles.
10467 If N is nil and any articles have been marked with the process mark,
10468 save those articles instead."
10470 (require 'gnus-art)
10471 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10472 (gnus-summary-save-article arg)))
10474 (defun gnus-summary-muttprint (&optional arg)
10475 "Print the current article using Muttprint.
10476 If N is a positive number, save the N next articles.
10477 If N is a negative number, save the N previous articles.
10478 If N is nil and any articles have been marked with the process mark,
10479 save those articles instead."
10481 (require 'gnus-art)
10482 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10483 (gnus-summary-save-article arg t)))
10485 (defun gnus-summary-pipe-message (program)
10486 "Pipe the current article through PROGRAM."
10487 (interactive "sProgram: ")
10488 (gnus-summary-select-article)
10489 (let ((mail-header-separator ""))
10490 (gnus-eval-in-buffer-window gnus-article-buffer
10493 (let ((start (window-start))
10495 (message-pipe-buffer-body program)
10496 (set-window-start (get-buffer-window (current-buffer)) start))))))
10498 (defun gnus-get-split-value (methods)
10499 "Return a value based on the split METHODS."
10500 (let (split-name method result match)
10503 (set-buffer gnus-original-article-buffer)
10505 (nnheader-narrow-to-headers)
10506 (while (and methods (not split-name))
10507 (goto-char (point-min))
10508 (setq method (pop methods))
10509 (setq match (car method))
10512 ;; Regular expression.
10514 (re-search-forward match nil t)))
10515 ((gnus-functionp match)
10519 (setq result (funcall match gnus-newsgroup-name))))
10524 (setq result (eval match)))))
10525 (setq split-name (cdr method))
10526 (cond ((stringp result)
10527 (push (expand-file-name
10528 result gnus-article-save-directory)
10531 (setq split-name (append result split-name)))))))))
10532 (nreverse split-name)))
10534 (defun gnus-valid-move-group-p (group)
10535 (and (boundp group)
10536 (symbol-name group)
10537 (symbol-value group)
10538 (gnus-get-function (gnus-find-method-for-group
10539 (symbol-name group)) 'request-accept-article t)))
10541 (defun gnus-read-move-group-name (prompt default articles prefix)
10542 "Read a group name."
10543 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10544 (minibuffer-confirm-incomplete nil) ; XEmacs
10546 (format "%s %s to:"
10548 (if (> (length articles) 1)
10549 (format "these %d articles" (length articles))
10554 (gnus-completing-read-with-default
10557 'gnus-valid-move-group-p
10559 'gnus-group-history))
10560 ((= 1 (length split-name))
10561 (gnus-completing-read-with-default
10562 (car split-name) prom
10564 'gnus-valid-move-group-p
10566 'gnus-group-history))
10568 (gnus-completing-read-with-default
10570 (mapcar (lambda (el) (list el))
10571 (nreverse split-name))
10573 'gnus-group-history))))
10574 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10576 (if (or (string= to-newsgroup "")
10577 (string= to-newsgroup prefix))
10578 (setq to-newsgroup default))
10579 (unless to-newsgroup
10580 (error "No group name entered"))
10581 (or (gnus-active to-newsgroup)
10582 (gnus-activate-group to-newsgroup nil nil to-method)
10583 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10585 (or (and (gnus-request-create-group to-newsgroup to-method)
10586 (gnus-activate-group
10587 to-newsgroup nil nil to-method)
10588 (gnus-subscribe-group to-newsgroup))
10589 (error "Couldn't create group %s" to-newsgroup)))
10590 (error "No such group: %s" to-newsgroup)))
10593 (defun gnus-summary-save-parts (type dir n &optional reverse)
10594 "Save parts matching TYPE to DIR.
10595 If REVERSE, save parts that do not match TYPE."
10597 (list (read-string "Save parts of type: "
10598 (or (car gnus-summary-save-parts-type-history)
10599 gnus-summary-save-parts-default-mime)
10600 'gnus-summary-save-parts-type-history)
10601 (setq gnus-summary-save-parts-last-directory
10602 (read-file-name "Save to directory: "
10603 gnus-summary-save-parts-last-directory
10605 current-prefix-arg))
10606 (gnus-summary-iterate n
10607 (let ((gnus-display-mime-function nil)
10608 (gnus-inhibit-treatment t))
10609 (gnus-summary-select-article))
10611 (set-buffer gnus-article-buffer)
10612 (let ((handles (or gnus-article-mime-handles
10613 (mm-dissect-buffer nil gnus-article-loose-mime)
10616 (gnus-summary-save-parts-1 type dir handles reverse)
10617 (unless gnus-article-mime-handles ;; Don't destroy this case.
10618 (mm-destroy-parts handles)))))))
10620 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10621 (if (stringp (car handle))
10622 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10625 (not (string-match type (mm-handle-media-type handle)))
10626 (string-match type (mm-handle-media-type handle)))
10627 (let ((file (expand-file-name
10628 (file-name-nondirectory
10630 (mail-content-type-get
10631 (mm-handle-disposition handle) 'filename)
10632 (concat gnus-newsgroup-name
10633 "." (number-to-string
10634 (cdr gnus-article-current)))))
10636 (unless (file-exists-p file)
10637 (mm-save-part-to-file handle file))))))
10639 ;; Summary extract commands
10641 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10642 (let ((buffer-read-only nil)
10643 (article (gnus-summary-article-number))
10645 (unless (gnus-summary-goto-subject article)
10646 (error "No such article: %d" article))
10647 (gnus-summary-position-point)
10648 ;; If all commands are to be bunched up on one line, we collect
10650 (unless gnus-view-pseudos-separately
10651 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10654 (setq action (cdr (assq 'action (car ps))))
10655 (setq files (list (cdr (assq 'name (car ps)))))
10656 (while (and ps (cdr ps)
10657 (string= (or action "1")
10658 (or (cdr (assq 'action (cadr ps))) "2")))
10659 (push (cdr (assq 'name (cadr ps))) files)
10660 (setcdr ps (cddr ps)))
10662 (when (not (string-match "%s" action))
10665 (when (assq 'execute (car ps))
10666 (setcdr (assq 'execute (car ps))
10667 (funcall (if (string-match "%s" action)
10676 (setq ps (cdr ps)))))
10677 (if (and gnus-view-pseudos (not not-view))
10679 (when (assq 'execute (car pslist))
10680 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10681 (eq gnus-view-pseudos 'not-confirm)))
10682 (setq pslist (cdr pslist)))
10685 (setq after-article (or (cdr (assq 'article (car pslist)))
10686 (gnus-summary-article-number)))
10687 (gnus-summary-goto-subject after-article)
10690 (insert " " (file-name-nondirectory
10691 (cdr (assq 'name (car pslist))))
10692 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10694 (forward-line -1) ; back to `b'
10695 (gnus-add-text-properties
10696 b (1- e) (list 'gnus-number gnus-reffed-article-number
10697 gnus-mouse-face-prop gnus-mouse-face))
10699 after-article gnus-reffed-article-number
10700 gnus-unread-mark b (car pslist) 0 (- e b))
10701 (setq gnus-newsgroup-unreads
10702 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10703 gnus-reffed-article-number))
10704 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10705 (setq pslist (cdr pslist)))))))
10707 (defun gnus-pseudos< (p1 p2)
10708 (let ((c1 (cdr (assq 'action p1)))
10709 (c2 (cdr (assq 'action p2))))
10710 (and c1 c2 (string< c1 c2))))
10712 (defun gnus-request-pseudo-article (props)
10713 (cond ((assq 'execute props)
10714 (gnus-execute-command (cdr (assq 'execute props)))))
10715 (let ((gnus-current-article (gnus-summary-article-number)))
10716 (gnus-run-hooks 'gnus-mark-article-hook)))
10718 (defun gnus-execute-command (command &optional automatic)
10720 (gnus-article-setup-buffer)
10721 (set-buffer gnus-article-buffer)
10722 (setq buffer-read-only nil)
10723 (let ((command (if automatic command
10724 (read-string "Command: " (cons command 0)))))
10726 (insert "$ " command "\n\n")
10727 (if gnus-view-pseudo-asynchronously
10728 (start-process "gnus-execute" (current-buffer) shell-file-name
10729 shell-command-switch command)
10730 (call-process shell-file-name nil t nil
10731 shell-command-switch command)))))
10733 ;; Summary kill commands.
10735 (defun gnus-summary-edit-global-kill (article)
10736 "Edit the \"global\" kill file."
10737 (interactive (list (gnus-summary-article-number)))
10738 (gnus-group-edit-global-kill article))
10740 (defun gnus-summary-edit-local-kill ()
10741 "Edit a local kill file applied to the current newsgroup."
10743 (setq gnus-current-headers (gnus-summary-article-header))
10744 (gnus-group-edit-local-kill
10745 (gnus-summary-article-number) gnus-newsgroup-name))
10747 ;;; Header reading.
10749 (defun gnus-read-header (id &optional header)
10750 "Read the headers of article ID and enter them into the Gnus system."
10751 (let ((group gnus-newsgroup-name)
10752 (gnus-override-method
10754 gnus-override-method
10755 (and (gnus-news-group-p gnus-newsgroup-name)
10756 (car (gnus-refer-article-methods)))))
10758 ;; First we check to see whether the header in question is already
10761 ;; This is a Message-ID.
10762 (setq header (or header (gnus-id-to-header id)))
10763 ;; This is an article number.
10764 (setq header (or header (gnus-summary-article-header id))))
10766 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10767 ;; We have found the header.
10769 ;; If this is a sparse article, we have to nix out its
10770 ;; previous entry in the thread hashtb.
10772 (gnus-summary-article-sparse-p (mail-header-number header)))
10773 (let* ((parent (gnus-parent-id (mail-header-references header)))
10774 (thread (and parent (gnus-id-to-thread parent))))
10776 (delq (assq header thread) thread))))
10777 ;; We have to really fetch the header to this article.
10779 (set-buffer nntp-server-buffer)
10780 (when (setq where (gnus-request-head id group))
10781 (nnheader-fold-continuation-lines)
10782 (goto-char (point-max))
10784 (goto-char (point-min))
10788 ((cdr where) (cdr where))
10789 (header (mail-header-number header))
10790 (t gnus-reffed-article-number))
10792 (insert " Article retrieved.\n"))
10793 (if (or (not where)
10794 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10795 () ; Malformed head.
10796 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10797 (when (and (stringp id)
10798 (not (string= (gnus-group-real-name group)
10800 ;; If we fetched by Message-ID and the article came
10801 ;; from a different group, we fudge some bogus article
10802 ;; numbers for this article.
10803 (mail-header-set-number header gnus-reffed-article-number))
10805 (set-buffer gnus-summary-buffer)
10806 (decf gnus-reffed-article-number)
10807 (gnus-remove-header (mail-header-number header))
10808 (push header gnus-newsgroup-headers)
10809 (setq gnus-current-headers header)
10810 (push (mail-header-number header) gnus-newsgroup-limit)))
10813 (defun gnus-remove-header (number)
10814 "Remove header NUMBER from `gnus-newsgroup-headers'."
10815 (if (and gnus-newsgroup-headers
10816 (= number (mail-header-number (car gnus-newsgroup-headers))))
10817 (pop gnus-newsgroup-headers)
10818 (let ((headers gnus-newsgroup-headers))
10819 (while (and (cdr headers)
10820 (not (= number (mail-header-number (cadr headers)))))
10822 (when (cdr headers)
10823 (setcdr headers (cddr headers))))))
10826 ;;; summary highlights
10829 (defun gnus-highlight-selected-summary ()
10830 "Highlight selected article in summary buffer."
10831 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10832 (when gnus-summary-selected-face
10834 (let* ((beg (progn (beginning-of-line) (point)))
10835 (end (progn (end-of-line) (point)))
10836 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10837 (from (if (get-text-property beg gnus-mouse-face-prop)
10839 (or (next-single-property-change
10840 beg gnus-mouse-face-prop nil end)
10845 (or (next-single-property-change
10846 from gnus-mouse-face-prop nil end)
10848 ;; If no mouse-face prop on line we will have to = from = end,
10849 ;; so we highlight the entire line instead.
10850 (when (= (+ to 2) from)
10853 (if gnus-newsgroup-selected-overlay
10854 ;; Move old overlay.
10856 gnus-newsgroup-selected-overlay from to (current-buffer))
10857 ;; Create new overlay.
10859 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10860 'face gnus-summary-selected-face))))))
10862 (defvar gnus-summary-highlight-line-cached nil)
10863 (defvar gnus-summary-highlight-line-trigger nil)
10864 (defun gnus-summary-highlight-line-0 ()
10865 (if (and (eq gnus-summary-highlight-line-trigger
10866 gnus-summary-highlight)
10867 gnus-summary-highlight-line-cached)
10868 gnus-summary-highlight-line-cached
10869 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
10870 gnus-summary-highlight-line-cached
10871 (let* ((cond (list 'cond))
10873 (list gnus-summary-highlight))
10875 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
10878 (gnus-byte-compile (list 'lambda nil cond))))))
10880 (defvar gnus-summary-highlight-line-downloaded-alist nil)
10881 (defvar gnus-summary-highlight-line-downloaded-cached nil)
10883 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10884 (defun gnus-summary-highlight-line ()
10885 "Highlight current line according to `gnus-summary-highlight'."
10887 ((list gnus-summary-highlight)
10888 (beg (gnus-point-at-bol))
10889 (article (gnus-summary-article-number))
10890 (score (or (cdr (assq (or article gnus-current-article)
10891 gnus-newsgroup-scored))
10892 gnus-summary-default-score 0))
10893 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10894 (inhibit-read-only t)
10895 (default gnus-summary-default-score)
10896 (default-high gnus-summary-default-high-score)
10897 (default-low gnus-summary-default-low-score)
10898 (gnus-tmp-downloaded
10900 (boundp 'gnus-agent-article-alist)
10901 gnus-agent-article-alist
10902 (gnus-agent-group-covered-p gnus-newsgroup-name)
10903 ;; Optimized for when gnus-summary-highlight-line is
10904 ;; called multiple times for articles in ascending
10905 ;; order (i.e. initial generation of summary buffer).
10908 (eq gnus-summary-highlight-line-downloaded-alist
10909 gnus-agent-article-alist)
10910 (<= (caar gnus-summary-highlight-line-downloaded-cached)
10912 (setq gnus-summary-highlight-line-downloaded-alist
10913 gnus-agent-article-alist)
10914 (setq gnus-summary-highlight-line-downloaded-cached
10915 gnus-agent-article-alist))
10917 (while (and (< (caar gnus-summary-highlight-line-downloaded-cached)
10919 (setq n (cdr gnus-summary-highlight-line-downloaded-cached)))
10920 (setq gnus-summary-highlight-line-downloaded-cached n)))
10921 (and (eq (caar gnus-summary-highlight-line-downloaded-cached)
10923 (cdar gnus-summary-highlight-line-downloaded-cached))))))
10924 (let ((face (funcall (gnus-summary-highlight-line-0))))
10925 (unless (eq face (get-text-property beg 'face))
10926 (gnus-put-text-property-excluding-characters-with-faces
10927 beg (gnus-point-at-eol) 'face
10928 (setq face (if (boundp face) (symbol-value face) face)))
10929 (when gnus-summary-highlight-line-function
10930 (funcall gnus-summary-highlight-line-function article face))))))
10932 (defun gnus-update-read-articles (group unread &optional compute)
10933 "Update the list of read articles in GROUP.
10934 UNREAD is a sorted list."
10935 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10936 (entry (gnus-gethash group gnus-newsrc-hashtb))
10937 (info (nth 2 entry))
10940 (if (or (not info) (not active))
10941 ;; There is no info on this group if it was, in fact,
10942 ;; killed. Gnus stores no information on killed groups, so
10943 ;; there's nothing to be done.
10944 ;; One could store the information somewhere temporarily,
10945 ;; perhaps... Hmmm...
10947 ;; Remove any negative articles numbers.
10948 (while (and unread (< (car unread) 0))
10949 (setq unread (cdr unread)))
10950 ;; Remove any expired article numbers
10951 (while (and unread (< (car unread) (car active)))
10952 (setq unread (cdr unread)))
10953 ;; Compute the ranges of read articles by looking at the list of
10954 ;; unread articles.
10956 (when (/= (car unread) prev)
10957 (push (if (= prev (1- (car unread))) prev
10958 (cons prev (1- (car unread))))
10960 (setq prev (1+ (car unread)))
10961 (setq unread (cdr unread)))
10962 (when (<= prev (cdr active))
10963 (push (cons prev (cdr active)) read))
10964 (setq read (if (> (length read) 1) (nreverse read) read))
10969 ;; Propagate the read marks to the backend.
10970 (when (gnus-check-backend-function 'request-set-mark group)
10971 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10972 (add (gnus-remove-from-range read (gnus-info-read info))))
10974 (unless (gnus-check-group group)
10975 (error "Can't open server for %s" group))
10976 (gnus-request-set-mark
10977 group (delq nil (list (if add (list add 'add '(read)))
10978 (if del (list del 'del '(read))))))
10980 `(gnus-request-set-mark
10983 (if del (list del 'add '(read)))
10984 (if add (list add 'del '(read))))))))))
10985 (set-buffer gnus-group-buffer)
10986 (gnus-undo-register
10988 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10989 (gnus-info-set-read ',info ',(gnus-info-read info))
10990 (gnus-get-unread-articles-in-group ',info
10991 (gnus-active ,group))
10992 (gnus-group-update-group ,group t)
10994 ;; Enter this list into the group info.
10995 (gnus-info-set-read info read)
10996 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10997 (gnus-get-unread-articles-in-group info (gnus-active group))
11000 (defun gnus-offer-save-summaries ()
11001 "Offer to save all active summary buffers."
11003 ;; Go through all buffers and find all summaries.
11004 (dolist (buffer (buffer-list))
11005 (when (and (setq buffer (buffer-name buffer))
11006 (string-match "Summary" buffer)
11008 (set-buffer buffer)
11009 ;; We check that this is, indeed, a summary buffer.
11010 (and (eq major-mode 'gnus-summary-mode)
11011 ;; Also make sure this isn't bogus.
11012 gnus-newsgroup-prepared
11013 ;; Also make sure that this isn't a
11014 ;; dead summary buffer.
11015 (not gnus-dead-summary-mode))))
11016 (push buffer buffers)))
11017 ;; Go through all these summary buffers and offer to save them.
11021 "Update summary buffer %s? "
11023 (switch-to-buffer buf)
11024 (gnus-summary-exit))
11027 (defun gnus-summary-setup-default-charset ()
11028 "Setup newsgroup default charset."
11029 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11030 (setq gnus-newsgroup-charset nil)
11031 (let* ((ignored-charsets
11032 (or gnus-newsgroup-ephemeral-ignored-charsets
11034 (and gnus-newsgroup-name
11035 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11036 gnus-newsgroup-ignored-charsets))))
11037 (setq gnus-newsgroup-charset
11038 (or gnus-newsgroup-ephemeral-charset
11039 (and gnus-newsgroup-name
11040 (gnus-parameter-charset gnus-newsgroup-name))
11041 gnus-default-charset))
11042 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11043 ignored-charsets))))
11049 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11050 "Display the current article buffer fully MIME-buttonized.
11051 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11052 treated as multipart/mixed."
11054 (require 'gnus-art)
11055 (let ((gnus-unbuttonized-mime-types nil)
11056 (gnus-mime-display-multipart-as-mixed show-all-parts))
11057 (gnus-summary-show-article)))
11059 (defun gnus-summary-repair-multipart (article)
11060 "Add a Content-Type header to a multipart article without one."
11061 (interactive (list (gnus-summary-article-number)))
11062 (gnus-with-article article
11063 (message-narrow-to-head)
11064 (message-remove-header "Mime-Version")
11065 (goto-char (point-max))
11066 (insert "Mime-Version: 1.0\n")
11068 (when (search-forward "\n--" nil t)
11069 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11070 (message-narrow-to-head)
11071 (message-remove-header "Content-Type")
11072 (goto-char (point-max))
11073 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11076 (let (gnus-mark-article-hook)
11077 (gnus-summary-select-article t t nil article)))
11079 (defun gnus-summary-toggle-display-buttonized ()
11080 "Toggle the buttonizing of the article buffer."
11082 (require 'gnus-art)
11083 (if (setq gnus-inhibit-mime-unbuttonizing
11084 (not gnus-inhibit-mime-unbuttonizing))
11085 (let ((gnus-unbuttonized-mime-types nil))
11086 (gnus-summary-show-article))
11087 (gnus-summary-show-article)))
11090 ;;; Generic summary marking commands
11093 (defvar gnus-summary-marking-alist
11094 '((read gnus-del-mark "d")
11095 (unread gnus-unread-mark "u")
11096 (ticked gnus-ticked-mark "!")
11097 (dormant gnus-dormant-mark "?")
11098 (expirable gnus-expirable-mark "e"))
11099 "An alist of names/marks/keystrokes.")
11101 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11102 (defvar gnus-summary-mark-map)
11104 (defun gnus-summary-make-all-marking-commands ()
11105 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11106 (dolist (elem gnus-summary-marking-alist)
11107 (apply 'gnus-summary-make-marking-command elem)))
11109 (defun gnus-summary-make-marking-command (name mark keystroke)
11110 (let ((map (make-sparse-keymap)))
11111 (define-key gnus-summary-generic-mark-map keystroke map)
11112 (dolist (lway `((next "next" next nil "n")
11113 (next-unread "next unread" next t "N")
11114 (prev "previous" prev nil "p")
11115 (prev-unread "previous unread" prev t "P")
11116 (nomove "" nil nil ,keystroke)))
11117 (let ((func (gnus-summary-make-marking-command-1
11118 mark (car lway) lway name)))
11119 (setq func (eval func))
11120 (define-key map (nth 4 lway) func)))))
11122 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11124 (format "gnus-summary-put-mark-as-%s%s"
11125 name (if (eq way 'nomove)
11127 (concat "-" (symbol-name way)))))
11130 "Mark the current article as %s%s.
11131 If N, the prefix, then repeat N times.
11132 If N is negative, move in reverse order.
11133 The difference between N and the actual number of articles marked is
11137 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11139 (defun gnus-summary-generic-mark (n mark move unread)
11140 "Mark N articles with MARK."
11141 (unless (eq major-mode 'gnus-summary-mode)
11142 (error "This command can only be used in the summary buffer"))
11143 (gnus-summary-show-thread)
11146 ((eq move 'next) 1)
11147 ((eq move 'prev) -1)
11149 (if (zerop nummove)
11153 nummove (* -1 nummove))))
11154 (while (and (> n 0)
11155 (gnus-summary-mark-article nil mark)
11156 (zerop (gnus-summary-next-subject nummove unread t)))
11159 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11160 (gnus-summary-recenter)
11161 (gnus-summary-position-point)
11162 (gnus-set-mode-line 'summary)
11165 (defun gnus-summary-insert-articles (articles)
11166 (when (setq articles
11167 (gnus-sorted-difference articles
11168 (mapcar (lambda (h)
11169 (mail-header-number h))
11170 gnus-newsgroup-headers)))
11171 (setq gnus-newsgroup-headers
11173 gnus-newsgroup-headers
11174 (gnus-fetch-headers articles)
11175 'gnus-article-sort-by-number))
11176 ;; Suppress duplicates?
11177 (when gnus-suppress-duplicates
11178 (gnus-dup-suppress-articles))
11180 ;; We might want to build some more threads first.
11181 (when (and gnus-fetch-old-headers
11182 (eq gnus-headers-retrieved-by 'nov))
11183 (if (eq gnus-fetch-old-headers 'invisible)
11184 (gnus-build-all-threads)
11185 (gnus-build-old-threads)))
11186 ;; Let the Gnus agent mark articles as read.
11188 (gnus-agent-get-undownloaded-list))
11189 ;; Remove list identifiers from subject
11190 (when gnus-list-identifiers
11191 (gnus-summary-remove-list-identifiers))
11192 ;; First and last article in this newsgroup.
11193 (when gnus-newsgroup-headers
11194 (setq gnus-newsgroup-begin
11195 (mail-header-number (car gnus-newsgroup-headers))
11197 (mail-header-number
11198 (gnus-last-element gnus-newsgroup-headers))))
11199 (when gnus-use-scoring
11200 (gnus-possibly-score-headers))))
11202 (defun gnus-summary-insert-old-articles (&optional all)
11203 "Insert all old articles in this group.
11204 If ALL is non-nil, already read articles become readable.
11205 If ALL is a number, fetch this number of articles."
11208 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11211 ;; Some nntp servers lie about their active range. When this happens, the active
11212 ;; range can be in the millions.
11213 ;; Use a compressed range to avoid creating a huge list.
11214 (gnus-range-difference (list gnus-newsgroup-active) old))
11215 (setq len (gnus-range-length older))
11220 (let ((older-range (nreverse older)))
11224 (let* ((r (pop older-range))
11225 (min (if (numberp r) r (car r)))
11226 (max (if (numberp r) r (cdr r))))
11227 (while (and (<= min max)
11232 (setq older (gnus-uncompress-range older))))
11234 (setq older (gnus-uncompress-range older)))
11236 (when (and (numberp gnus-large-newsgroup)
11237 (> len gnus-large-newsgroup))
11238 (let* ((cursor-in-echo-area nil)
11239 (initial (gnus-parameter-large-newsgroup-initial
11240 gnus-newsgroup-name))
11244 "How many articles from %s (%s %d): "
11246 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11247 (if initial "max" "default")
11250 (cons (number-to-string initial)
11252 (unless (string-match "^[ \t]*$" input)
11253 (setq all (string-to-number input))
11255 (let ((older-range (nreverse older)))
11259 (let* ((r (pop older-range))
11260 (min (if (numberp r) r (car r)))
11261 (max (if (numberp r) r (cdr r))))
11262 (while (and (<= min max)
11266 max (1- max))))))))))
11267 (setq older (gnus-uncompress-range older))))
11269 (message "No old news.")
11270 (gnus-summary-insert-articles older)
11271 (gnus-summary-limit (gnus-sorted-nunion old older))))
11272 (gnus-summary-position-point)))
11274 (defun gnus-summary-insert-new-articles ()
11275 "Insert all new articles in this group."
11278 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11279 (old-active gnus-newsgroup-active)
11280 (nnmail-fetched-sources (list t))
11282 (setq gnus-newsgroup-active
11283 (gnus-activate-group gnus-newsgroup-name 'scan))
11284 (setq i (cdr gnus-newsgroup-active))
11285 (while (> i (cdr old-active))
11289 (message "No gnus is bad news.")
11290 (gnus-summary-insert-articles new)
11291 (setq gnus-newsgroup-unreads
11292 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11293 (gnus-summary-limit (gnus-sorted-nunion old new))))
11294 (gnus-summary-position-point)))
11296 (gnus-summary-make-all-marking-commands)
11298 (gnus-ems-redefine)
11300 (provide 'gnus-sum)
11302 (run-hooks 'gnus-sum-load-hook)
11304 ;;; gnus-sum.el ends here