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-downloaded-mark ?+
510 "*Mark used for articles that were downloaded."
511 :group 'gnus-summary-marks
514 (defcustom gnus-downloadable-mark ?%
515 "*Mark used for articles that are to be downloaded."
516 :group 'gnus-summary-marks
519 (defcustom gnus-unsendable-mark ?=
520 "*Mark used for articles that won't be sent."
521 :group 'gnus-summary-marks
524 (defcustom gnus-score-over-mark ?+
525 "*Score mark used for articles with high scores."
526 :group 'gnus-summary-marks
529 (defcustom gnus-score-below-mark ?-
530 "*Score mark used for articles with low scores."
531 :group 'gnus-summary-marks
534 (defcustom gnus-empty-thread-mark ? ;Whitespace
535 "*There is no thread under the article."
536 :group 'gnus-summary-marks
539 (defcustom gnus-not-empty-thread-mark ?=
540 "*There is a thread under the article."
541 :group 'gnus-summary-marks
544 (defcustom gnus-view-pseudo-asynchronously nil
545 "*If non-nil, Gnus will view pseudo-articles asynchronously."
546 :group 'gnus-extract-view
549 (defcustom gnus-auto-expirable-marks
550 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
551 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
552 gnus-souped-mark gnus-duplicate-mark)
553 "*The list of marks converted into expiration if a group is auto-expirable."
556 :type '(repeat character))
558 (defcustom gnus-inhibit-user-auto-expire t
559 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
564 (defcustom gnus-view-pseudos nil
565 "*If `automatic', pseudo-articles will be viewed automatically.
566 If `not-confirm', pseudos will be viewed automatically, and the user
567 will not be asked to confirm the command."
568 :group 'gnus-extract-view
569 :type '(choice (const :tag "off" nil)
571 (const not-confirm)))
573 (defcustom gnus-view-pseudos-separately t
574 "*If non-nil, one pseudo-article will be created for each file to be viewed.
575 If nil, all files that use the same viewing command will be given as a
576 list of parameters to that command."
577 :group 'gnus-extract-view
580 (defcustom gnus-insert-pseudo-articles t
581 "*If non-nil, insert pseudo-articles when decoding articles."
582 :group 'gnus-extract-view
585 (defcustom gnus-summary-dummy-line-format
587 "*The format specification for the dummy roots in the summary buffer.
588 It works along the same lines as a normal formatting string,
589 with some simple extensions.
593 General format specifiers can also be used.
594 See `(gnus)Formatting Variables'."
595 :link '(custom-manual "(gnus)Formatting Variables")
596 :group 'gnus-threading
599 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
600 "*The format specification for the summary mode line.
601 It works along the same lines as a normal formatting string,
602 with some simple extensions:
605 %p Unprefixed group name
606 %A Current article number
607 %z Current article score
609 %U Number of unread articles in the group
610 %e Number of unselected articles in the group
611 %Z A string with unread/unselected article counts
612 %g Shortish group name
613 %S Subject of the current article
615 %s Current score file name
616 %d Number of dormant articles
617 %r Number of articles that have been marked as read in this session
618 %E Number of articles expunged by the score files"
619 :group 'gnus-summary-format
622 (defcustom gnus-list-identifiers nil
623 "Regexp that matches list identifiers to be removed from subject.
624 This can also be a list of regexps."
626 :group 'gnus-summary-format
627 :group 'gnus-article-hiding
628 :type '(choice (const :tag "none" nil)
630 (repeat :value (".*") regexp)))
632 (defcustom gnus-summary-mark-below 0
633 "*Mark all articles with a score below this variable as read.
634 This variable is local to each summary buffer and usually set by the
636 :group 'gnus-score-default
639 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
640 "*List of functions used for sorting articles in the summary buffer.
642 Each function takes two articles and returns non-nil if the first
643 article should be sorted before the other. If you use more than one
644 function, the primary sort function should be the last. You should
645 probably always include `gnus-article-sort-by-number' in the list of
646 sorting functions -- preferably first. Also note that sorting by date
647 is often much slower than sorting by number, and the sorting order is
648 very similar. (Sorting by date means sorting by the time the message
649 was sent, sorting by number means sorting by arrival time.)
651 Ready-made functions include `gnus-article-sort-by-number',
652 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
653 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
654 and `gnus-article-sort-by-score'.
656 When threading is turned on, the variable `gnus-thread-sort-functions'
657 controls how articles are sorted."
658 :group 'gnus-summary-sort
659 :type '(repeat (choice (function-item gnus-article-sort-by-number)
660 (function-item gnus-article-sort-by-author)
661 (function-item gnus-article-sort-by-subject)
662 (function-item gnus-article-sort-by-date)
663 (function-item gnus-article-sort-by-score)
664 (function-item gnus-article-sort-by-random)
665 (function :tag "other"))))
667 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
668 "*List of functions used for sorting threads in the summary buffer.
669 By default, threads are sorted by article number.
671 Each function takes two threads and returns non-nil if the first
672 thread should be sorted before the other. If you use more than one
673 function, the primary sort function should be the last. You should
674 probably always include `gnus-thread-sort-by-number' in the list of
675 sorting functions -- preferably first. Also note that sorting by date
676 is often much slower than sorting by number, and the sorting order is
677 very similar. (Sorting by date means sorting by the time the message
678 was sent, sorting by number means sorting by arrival time.)
680 Ready-made functions include `gnus-thread-sort-by-number',
681 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
682 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
683 `gnus-thread-sort-by-most-recent-number',
684 `gnus-thread-sort-by-most-recent-date',
685 `gnus-thread-sort-by-random', and
686 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
688 When threading is turned off, the variable
689 `gnus-article-sort-functions' controls how articles are sorted."
690 :group 'gnus-summary-sort
691 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
692 (function-item gnus-thread-sort-by-author)
693 (function-item gnus-thread-sort-by-subject)
694 (function-item gnus-thread-sort-by-date)
695 (function-item gnus-thread-sort-by-score)
696 (function-item gnus-thread-sort-by-total-score)
697 (function-item gnus-thread-sort-by-random)
698 (function :tag "other"))))
700 (defcustom gnus-thread-score-function '+
701 "*Function used for calculating the total score of a thread.
703 The function is called with the scores of the article and each
704 subthread and should then return the score of the thread.
706 Some functions you can use are `+', `max', or `min'."
707 :group 'gnus-summary-sort
710 (defcustom gnus-summary-expunge-below nil
711 "All articles that have a score less than this variable will be expunged.
712 This variable is local to the summary buffers."
713 :group 'gnus-score-default
714 :type '(choice (const :tag "off" nil)
717 (defcustom gnus-thread-expunge-below nil
718 "All threads that have a total score less than this variable will be expunged.
719 See `gnus-thread-score-function' for en explanation of what a
722 This variable is local to the summary buffers."
723 :group 'gnus-threading
724 :group 'gnus-score-default
725 :type '(choice (const :tag "off" nil)
728 (defcustom gnus-summary-mode-hook nil
729 "*A hook for Gnus summary mode.
730 This hook is run before any variables are set in the summary buffer."
731 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
732 :group 'gnus-summary-various
735 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
736 (when (featurep 'xemacs)
737 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
738 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
739 (add-hook 'gnus-summary-mode-hook
740 'gnus-xmas-switch-horizontal-scrollbar-off))
742 (defcustom gnus-summary-menu-hook nil
743 "*Hook run after the creation of the summary mode menu."
744 :group 'gnus-summary-visual
747 (defcustom gnus-summary-exit-hook nil
748 "*A hook called on exit from the summary buffer.
749 It will be called with point in the group buffer."
750 :group 'gnus-summary-exit
753 (defcustom gnus-summary-prepare-hook nil
754 "*A hook called after the summary buffer has been generated.
755 If you want to modify the summary buffer, you can use this hook."
756 :group 'gnus-summary-various
759 (defcustom gnus-summary-prepared-hook nil
760 "*A hook called as the last thing after the summary buffer has been generated."
761 :group 'gnus-summary-various
764 (defcustom gnus-summary-generate-hook nil
765 "*A hook run just before generating the summary buffer.
766 This hook is commonly used to customize threading variables and the
768 :group 'gnus-summary-various
771 (defcustom gnus-select-group-hook nil
772 "*A hook called when a newsgroup is selected.
774 If you'd like to simplify subjects like the
775 `gnus-summary-next-same-subject' command does, you can use the
778 (add-hook gnus-select-group-hook
780 (mapcar (lambda (header)
781 (mail-header-set-subject
783 (gnus-simplify-subject
784 (mail-header-subject header) 're-only)))
785 gnus-newsgroup-headers)))"
786 :group 'gnus-group-select
789 (defcustom gnus-select-article-hook nil
790 "*A hook called when an article is selected."
791 :group 'gnus-summary-choose
794 (defcustom gnus-visual-mark-article-hook
795 (list 'gnus-highlight-selected-summary)
796 "*Hook run after selecting an article in the summary buffer.
797 It is meant to be used for highlighting the article in some way. It
798 is not run if `gnus-visual' is nil."
799 :group 'gnus-summary-visual
802 (defcustom gnus-parse-headers-hook nil
803 "*A hook called before parsing the headers."
807 (defcustom gnus-exit-group-hook nil
808 "*A hook called when exiting summary mode.
809 This hook is not called from the non-updating exit commands like `Q'."
813 (defcustom gnus-summary-update-hook
814 (list 'gnus-summary-highlight-line)
815 "*A hook called when a summary line is changed.
816 The hook will not be called if `gnus-visual' is nil.
818 The default function `gnus-summary-highlight-line' will
819 highlight the line according to the `gnus-summary-highlight'
821 :group 'gnus-summary-visual
824 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
825 "*A hook called when an article is selected for the first time.
826 The hook is intended to mark an article as read (or unread)
827 automatically when it is selected."
828 :group 'gnus-summary-choose
831 (defcustom gnus-group-no-more-groups-hook nil
832 "*A hook run when returning to group mode having no more (unread) groups."
833 :group 'gnus-group-select
836 (defcustom gnus-ps-print-hook nil
837 "*A hook run before ps-printing something from Gnus."
841 (defcustom gnus-summary-display-arrow
842 (and (fboundp 'display-graphic-p)
844 "*If non-nil, display an arrow highlighting the current article."
849 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
850 "Face used for highlighting the current article in the summary buffer."
851 :group 'gnus-summary-visual
854 (defvar gnus-tmp-downloaded nil)
856 (defcustom gnus-summary-highlight
857 '(((eq mark gnus-canceled-mark)
858 . gnus-summary-cancelled-face)
859 ((and uncached (> score default-high))
860 . gnus-summary-high-uncached-face)
861 ((and uncached (< score default-low))
862 . gnus-summary-low-uncached-face)
864 . gnus-summary-normal-uncached-face)
865 ((and (> score default-high)
866 (or (eq mark gnus-dormant-mark)
867 (eq mark gnus-ticked-mark)))
868 . gnus-summary-high-ticked-face)
869 ((and (< score default-low)
870 (or (eq mark gnus-dormant-mark)
871 (eq mark gnus-ticked-mark)))
872 . gnus-summary-low-ticked-face)
873 ((or (eq mark gnus-dormant-mark)
874 (eq mark gnus-ticked-mark))
875 . gnus-summary-normal-ticked-face)
876 ((and (> score default-high) (eq mark gnus-ancient-mark))
877 . gnus-summary-high-ancient-face)
878 ((and (< score default-low) (eq mark gnus-ancient-mark))
879 . gnus-summary-low-ancient-face)
880 ((eq mark gnus-ancient-mark)
881 . gnus-summary-normal-ancient-face)
882 ((and (> score default-high) (eq mark gnus-unread-mark))
883 . gnus-summary-high-unread-face)
884 ((and (< score default-low) (eq mark gnus-unread-mark))
885 . gnus-summary-low-unread-face)
886 ((eq mark gnus-unread-mark)
887 . gnus-summary-normal-unread-face)
888 ((> score default-high)
889 . gnus-summary-high-read-face)
890 ((< score default-low)
891 . gnus-summary-low-read-face)
893 . gnus-summary-normal-read-face))
894 "*Controls the highlighting of summary buffer lines.
896 A list of (FORM . FACE) pairs. When deciding how a a particular
897 summary line should be displayed, each form is evaluated. The content
898 of the face field after the first true form is used. You can change
899 how those summary lines are displayed, by editing the face field.
901 You can use the following variables in the FORM field.
903 score: The article's score
904 default: The default article score.
905 default-high: The default score for high scored articles.
906 default-low: The default score for low scored articles.
907 below: The score below which articles are automatically marked as read.
908 mark: The articles mark."
909 :group 'gnus-summary-visual
910 :type '(repeat (cons (sexp :tag "Form" nil)
913 (defcustom gnus-alter-header-function nil
914 "Function called to allow alteration of article header structures.
915 The function is called with one parameter, the article header vector,
916 which it may alter in any way.")
918 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
919 "Variable that says which function should be used to decode a string with encoded words.")
921 (defcustom gnus-extra-headers '(To Newsgroups)
922 "*Extra headers to parse."
925 :type '(repeat symbol))
927 (defcustom gnus-ignored-from-addresses
928 (and user-mail-address (regexp-quote user-mail-address))
929 "*Regexp of From headers that may be suppressed in favor of To headers."
934 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
935 "List of charsets that should be ignored.
936 When these charsets are used in the \"charset\" parameter, the
937 default charset will be used instead."
939 :type '(repeat symbol)
940 :group 'gnus-charset)
942 (gnus-define-group-parameter
946 "Return the ignored charsets of GROUP."
947 :variable gnus-group-ignored-charsets-alist
949 '(("alt\\.chinese\\.text" iso-8859-1))
951 "Alist of regexps (to match group names) and charsets that should be ignored.
952 When these charsets are used in the \"charset\" parameter, the
953 default charset will be used instead."
954 :variable-group gnus-charset
955 :variable-type '(repeat (cons (regexp :tag "Group")
957 :parameter-type '(choice :tag "Ignored charsets"
960 :parameter-document "\
961 List of charsets that should be ignored.
963 When these charsets are used in the \"charset\" parameter, the
964 default charset will be used instead.")
966 (defcustom gnus-group-highlight-words-alist nil
967 "Alist of group regexps and highlight regexps.
968 This variable uses the same syntax as `gnus-emphasis-alist'."
970 :type '(repeat (cons (regexp :tag "Group")
971 (repeat (list (regexp :tag "Highlight regexp")
972 (number :tag "Group for entire word" 0)
973 (number :tag "Group for displayed part" 0)
975 gnus-emphasis-highlight-words)))))
976 :group 'gnus-summary-visual)
978 (defcustom gnus-summary-show-article-charset-alist
980 "Alist of number and charset.
981 The article will be shown with the charset corresponding to the
983 For example: ((1 . cn-gb-2312) (2 . big5))."
985 :type '(repeat (cons (number :tag "Argument" 1)
986 (symbol :tag "Charset")))
987 :group 'gnus-charset)
989 (defcustom gnus-preserve-marks t
990 "Whether marks are preserved when moving, copying and respooling messages."
993 :group 'gnus-summary-marks)
995 (defcustom gnus-alter-articles-to-read-function nil
996 "Function to be called to alter the list of articles to be selected."
997 :type '(choice (const nil) function)
998 :group 'gnus-summary)
1000 (defcustom gnus-orphan-score nil
1001 "*All orphans get this score added. Set in the score file."
1002 :group 'gnus-score-default
1003 :type '(choice (const nil)
1006 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1007 "*A regexp to match MIME parts when saving multiple parts of a message
1008 with gnus-summary-save-parts (X m). This regexp will be used by default
1009 when prompting the user for which type of files to save."
1010 :group 'gnus-summary
1013 (defcustom gnus-read-all-available-headers nil
1014 "Whether Gnus should parse all headers made available to it.
1015 This is mostly relevant for slow backends where the user may
1016 wish to widen the summary buffer to include all headers
1017 that were fetched. Say, for nnultimate groups."
1018 :group 'gnus-summary
1019 :type '(choice boolean regexp))
1021 (defcustom gnus-summary-muttprint-program "muttprint"
1022 "Command (and optional arguments) used to run Muttprint."
1024 :group 'gnus-summary
1027 (defcustom gnus-article-loose-mime nil
1028 "If non-nil, don't require MIME-Version header.
1029 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1030 supply the MIME-Version header or deliberately strip it From the mail.
1031 Set it to non-nil, Gnus will treat some articles as MIME even if
1032 the MIME-Version header is missed."
1035 :group 'gnus-article)
1037 ;;; Internal variables
1039 (defvar gnus-summary-display-cache nil)
1040 (defvar gnus-article-mime-handles nil)
1041 (defvar gnus-article-decoded-p nil)
1042 (defvar gnus-article-charset nil)
1043 (defvar gnus-article-ignored-charsets nil)
1044 (defvar gnus-scores-exclude-files nil)
1045 (defvar gnus-page-broken nil)
1047 (defvar gnus-original-article nil)
1048 (defvar gnus-article-internal-prepare-hook nil)
1049 (defvar gnus-newsgroup-process-stack nil)
1051 (defvar gnus-thread-indent-array nil)
1052 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1053 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1054 "Function called to sort the articles within a thread after it has been gathered together.")
1056 (defvar gnus-summary-save-parts-type-history nil)
1057 (defvar gnus-summary-save-parts-last-directory nil)
1059 ;; Avoid highlighting in kill files.
1060 (defvar gnus-summary-inhibit-highlight nil)
1061 (defvar gnus-newsgroup-selected-overlay nil)
1062 (defvar gnus-inhibit-limiting nil)
1063 (defvar gnus-newsgroup-adaptive-score-file nil)
1064 (defvar gnus-current-score-file nil)
1065 (defvar gnus-current-move-group nil)
1066 (defvar gnus-current-copy-group nil)
1067 (defvar gnus-current-crosspost-group nil)
1068 (defvar gnus-newsgroup-display nil)
1070 (defvar gnus-newsgroup-dependencies nil)
1071 (defvar gnus-newsgroup-adaptive nil)
1072 (defvar gnus-summary-display-article-function nil)
1073 (defvar gnus-summary-highlight-line-function nil
1074 "Function called after highlighting a summary line.")
1076 (defvar gnus-summary-line-format-alist
1077 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1078 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1079 (?s gnus-tmp-subject-or-nil ?s)
1080 (?n gnus-tmp-name ?s)
1081 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1083 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1085 (?F gnus-tmp-from ?s)
1086 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1087 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1088 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1089 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1090 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1091 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1092 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1093 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1094 (?L gnus-tmp-lines ?s)
1095 (?O gnus-tmp-downloaded ?c)
1096 (?I gnus-tmp-indentation ?s)
1097 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1098 (?R gnus-tmp-replied ?c)
1099 (?\[ gnus-tmp-opening-bracket ?c)
1100 (?\] gnus-tmp-closing-bracket ?c)
1101 (?\> (make-string gnus-tmp-level ? ) ?s)
1102 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1103 (?i gnus-tmp-score ?d)
1104 (?z gnus-tmp-score-char ?c)
1105 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1106 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1107 (?U gnus-tmp-unread ?c)
1108 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1110 (?t (gnus-summary-number-of-articles-in-thread
1111 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1113 (?e (gnus-summary-number-of-articles-in-thread
1114 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1116 (?u gnus-tmp-user-defined ?s)
1117 (?P (gnus-pick-line-number) ?d)
1118 (?B gnus-tmp-thread-tree-header-string ?s)
1119 (user-date (gnus-user-date
1120 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1121 "An alist of format specifications that can appear in summary lines.
1122 These are paired with what variables they correspond with, along with
1123 the type of the variable (string, integer, character, etc).")
1125 (defvar gnus-summary-dummy-line-format-alist
1126 `((?S gnus-tmp-subject ?s)
1127 (?N gnus-tmp-number ?d)
1128 (?u gnus-tmp-user-defined ?s)))
1130 (defvar gnus-summary-mode-line-format-alist
1131 `((?G gnus-tmp-group-name ?s)
1132 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1133 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1134 (?A gnus-tmp-article-number ?d)
1135 (?Z gnus-tmp-unread-and-unselected ?s)
1136 (?V gnus-version ?s)
1137 (?U gnus-tmp-unread-and-unticked ?d)
1138 (?S gnus-tmp-subject ?s)
1139 (?e gnus-tmp-unselected ?d)
1140 (?u gnus-tmp-user-defined ?s)
1141 (?d (length gnus-newsgroup-dormant) ?d)
1142 (?t (length gnus-newsgroup-marked) ?d)
1143 (?h (length gnus-newsgroup-spam-marked) ?d)
1144 (?r (length gnus-newsgroup-reads) ?d)
1145 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1146 (?E gnus-newsgroup-expunged-tally ?d)
1147 (?s (gnus-current-score-file-nondirectory) ?s)))
1149 (defvar gnus-last-search-regexp nil
1150 "Default regexp for article search command.")
1152 (defvar gnus-last-shell-command nil
1153 "Default shell command on article.")
1155 (defvar gnus-newsgroup-agentized nil
1156 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1157 (defvar gnus-newsgroup-begin nil)
1158 (defvar gnus-newsgroup-end nil)
1159 (defvar gnus-newsgroup-last-rmail nil)
1160 (defvar gnus-newsgroup-last-mail nil)
1161 (defvar gnus-newsgroup-last-folder nil)
1162 (defvar gnus-newsgroup-last-file nil)
1163 (defvar gnus-newsgroup-auto-expire nil)
1164 (defvar gnus-newsgroup-active nil)
1166 (defvar gnus-newsgroup-data nil)
1167 (defvar gnus-newsgroup-data-reverse nil)
1168 (defvar gnus-newsgroup-limit nil)
1169 (defvar gnus-newsgroup-limits nil)
1171 (defvar gnus-newsgroup-unreads nil
1172 "Sorted list of unread articles in the current newsgroup.")
1174 (defvar gnus-newsgroup-unselected nil
1175 "Sorted list of unselected unread articles in the current newsgroup.")
1177 (defvar gnus-newsgroup-reads nil
1178 "Alist of read articles and article marks in the current newsgroup.")
1180 (defvar gnus-newsgroup-expunged-tally nil)
1182 (defvar gnus-newsgroup-marked nil
1183 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1185 (defvar gnus-newsgroup-spam-marked nil
1186 "List of ranges of articles that have been marked as spam.")
1188 (defvar gnus-newsgroup-killed nil
1189 "List of ranges of articles that have been through the scoring process.")
1191 (defvar gnus-newsgroup-cached nil
1192 "Sorted list of articles that come from the article cache.")
1194 (defvar gnus-newsgroup-saved nil
1195 "List of articles that have been saved.")
1197 (defvar gnus-newsgroup-kill-headers nil)
1199 (defvar gnus-newsgroup-replied nil
1200 "List of articles that have been replied to in the current newsgroup.")
1202 (defvar gnus-newsgroup-forwarded nil
1203 "List of articles that have been forwarded in the current newsgroup.")
1205 (defvar gnus-newsgroup-recent nil
1206 "List of articles that have are recent in the current newsgroup.")
1208 (defvar gnus-newsgroup-expirable nil
1209 "Sorted list of articles in the current newsgroup that can be expired.")
1211 (defvar gnus-newsgroup-processable nil
1212 "List of articles in the current newsgroup that can be processed.")
1214 (defvar gnus-newsgroup-downloadable nil
1215 "Sorted list of articles in the current newsgroup that can be processed.")
1217 (defvar gnus-newsgroup-undownloaded nil
1218 "List of articles in the current newsgroup that haven't been downloaded..")
1220 (defvar gnus-newsgroup-unsendable nil
1221 "List of articles in the current newsgroup that won't be sent.")
1223 (defvar gnus-newsgroup-bookmarks nil
1224 "List of articles in the current newsgroup that have bookmarks.")
1226 (defvar gnus-newsgroup-dormant nil
1227 "Sorted list of dormant articles in the current newsgroup.")
1229 (defvar gnus-newsgroup-unseen nil
1230 "List of unseen articles in the current newsgroup.")
1232 (defvar gnus-newsgroup-seen nil
1233 "Range of seen articles in the current newsgroup.")
1235 (defvar gnus-newsgroup-articles nil
1236 "List of articles in the current newsgroup.")
1238 (defvar gnus-newsgroup-scored nil
1239 "List of scored articles in the current newsgroup.")
1241 (defvar gnus-newsgroup-headers nil
1242 "List of article headers in the current newsgroup.")
1244 (defvar gnus-newsgroup-threads nil)
1246 (defvar gnus-newsgroup-prepared nil
1247 "Whether the current group has been prepared properly.")
1249 (defvar gnus-newsgroup-ancient nil
1250 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-sparse nil)
1254 (defvar gnus-current-article nil)
1255 (defvar gnus-article-current nil)
1256 (defvar gnus-current-headers nil)
1257 (defvar gnus-have-all-headers nil)
1258 (defvar gnus-last-article nil)
1259 (defvar gnus-newsgroup-history nil)
1260 (defvar gnus-newsgroup-charset nil)
1261 (defvar gnus-newsgroup-ephemeral-charset nil)
1262 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1264 (defvar gnus-article-before-search nil)
1266 (defconst gnus-summary-local-variables
1267 '(gnus-newsgroup-name
1268 gnus-newsgroup-begin gnus-newsgroup-end
1269 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1270 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1271 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1272 gnus-newsgroup-unselected gnus-newsgroup-marked
1273 gnus-newsgroup-spam-marked
1274 gnus-newsgroup-reads gnus-newsgroup-saved
1275 gnus-newsgroup-replied gnus-newsgroup-forwarded
1276 gnus-newsgroup-recent
1277 gnus-newsgroup-expirable
1278 gnus-newsgroup-processable gnus-newsgroup-killed
1279 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1280 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1281 gnus-newsgroup-seen gnus-newsgroup-articles
1282 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1283 gnus-newsgroup-headers gnus-newsgroup-threads
1284 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1285 gnus-current-article gnus-current-headers gnus-have-all-headers
1286 gnus-last-article gnus-article-internal-prepare-hook
1287 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1288 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1289 gnus-thread-expunge-below
1290 gnus-score-alist gnus-current-score-file
1291 (gnus-summary-expunge-below . global)
1292 (gnus-summary-mark-below . global)
1293 (gnus-orphan-score . global)
1294 gnus-newsgroup-active gnus-scores-exclude-files
1295 gnus-newsgroup-history gnus-newsgroup-ancient
1296 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1297 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1298 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1299 (gnus-newsgroup-expunged-tally . 0)
1300 gnus-cache-removable-articles gnus-newsgroup-cached
1301 gnus-newsgroup-data gnus-newsgroup-data-reverse
1302 gnus-newsgroup-limit gnus-newsgroup-limits
1303 gnus-newsgroup-charset gnus-newsgroup-display)
1304 "Variables that are buffer-local to the summary buffers.")
1306 (defvar gnus-newsgroup-variables nil
1307 "A list of variables that have separate values in different newsgroups.
1308 A list of newsgroup (summary buffer) local variables, or cons of
1309 variables and their default values (when the default values are not
1310 nil), that should be made global while the summary buffer is active.
1311 These variables can be used to set variables in the group parameters
1312 while still allowing them to affect operations done in other
1313 buffers. For example:
1315 \(setq gnus-newsgroup-variables
1316 '(message-use-followup-to
1317 (gnus-visible-headers .
1318 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1321 ;; Byte-compiler warning.
1322 (eval-when-compile (defvar gnus-article-mode-map))
1326 (defvar gnus-decode-encoded-word-methods
1327 '(mail-decode-encoded-word-string)
1328 "List of methods used to decode encoded words.
1330 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1331 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1332 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1333 whose names match REGEXP.
1336 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1337 mail-decode-encoded-word-string
1338 (\"chinese\" . rfc1843-decode-string))")
1340 (defvar gnus-decode-encoded-word-methods-cache nil)
1342 (defun gnus-multi-decode-encoded-word-string (string)
1343 "Apply the functions from `gnus-encoded-word-methods' that match."
1344 (unless (and gnus-decode-encoded-word-methods-cache
1345 (eq gnus-newsgroup-name
1346 (car gnus-decode-encoded-word-methods-cache)))
1347 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1350 (nconc gnus-decode-encoded-word-methods-cache (list x))
1351 (if (and gnus-newsgroup-name
1352 (string-match (car x) gnus-newsgroup-name))
1353 (nconc gnus-decode-encoded-word-methods-cache
1355 gnus-decode-encoded-word-methods))
1356 (let ((xlist gnus-decode-encoded-word-methods-cache))
1359 (setq string (funcall (pop xlist) string))))
1362 ;; Subject simplification.
1364 (defun gnus-simplify-whitespace (str)
1365 "Remove excessive whitespace from STR."
1368 (while (string-match "[ \t][ \t]+" mystr)
1369 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1371 (substring mystr (match-end 0)))))
1373 (when (string-match "^[ \t]+" mystr)
1374 (setq mystr (substring mystr (match-end 0))))
1376 (when (string-match "[ \t]+$" mystr)
1377 (setq mystr (substring mystr 0 (match-beginning 0))))
1380 (defun gnus-simplify-all-whitespace (str)
1381 "Remove all whitespace from STR."
1383 (while (string-match "[ \t\n]+" mystr)
1384 (setq mystr (replace-match "" nil nil mystr)))
1387 (defsubst gnus-simplify-subject-re (subject)
1388 "Remove \"Re:\" from subject lines."
1389 (if (string-match message-subject-re-regexp subject)
1390 (substring subject (match-end 0))
1393 (defun gnus-simplify-subject (subject &optional re-only)
1394 "Remove `Re:' and words in parentheses.
1395 If RE-ONLY is non-nil, strip leading `Re:'s only."
1396 (let ((case-fold-search t)) ;Ignore case.
1397 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1398 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1399 (setq subject (substring subject (match-end 0))))
1400 ;; Remove uninteresting prefixes.
1401 (when (and (not re-only)
1402 gnus-simplify-ignored-prefixes
1403 (string-match gnus-simplify-ignored-prefixes subject))
1404 (setq subject (substring subject (match-end 0))))
1405 ;; Remove words in parentheses from end.
1407 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1408 (setq subject (substring subject 0 (match-beginning 0)))))
1409 ;; Return subject string.
1412 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1414 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1415 (goto-char (point-min))
1416 (while (re-search-forward regexp nil t)
1417 (replace-match (or newtext ""))))
1419 (defun gnus-simplify-buffer-fuzzy ()
1420 "Simplify string in the buffer fuzzily.
1421 The string in the accessible portion of the current buffer is simplified.
1422 It is assumed to be a single-line subject.
1423 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1424 matter is removed. Additional things can be deleted by setting
1425 `gnus-simplify-subject-fuzzy-regexp'."
1426 (let ((case-fold-search t)
1428 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1430 (while (not (eq modified-tick (buffer-modified-tick)))
1431 (setq modified-tick (buffer-modified-tick))
1433 ((listp gnus-simplify-subject-fuzzy-regexp)
1434 (mapcar 'gnus-simplify-buffer-fuzzy-step
1435 gnus-simplify-subject-fuzzy-regexp))
1436 (gnus-simplify-subject-fuzzy-regexp
1437 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1438 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1439 (gnus-simplify-buffer-fuzzy-step
1440 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1441 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1443 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1444 (gnus-simplify-buffer-fuzzy-step " +" " ")
1445 (gnus-simplify-buffer-fuzzy-step " $")
1446 (gnus-simplify-buffer-fuzzy-step "^ +")))
1448 (defun gnus-simplify-subject-fuzzy (subject)
1449 "Simplify a subject string fuzzily.
1450 See `gnus-simplify-buffer-fuzzy' for details."
1452 (gnus-set-work-buffer)
1453 (let ((case-fold-search t))
1454 ;; Remove uninteresting prefixes.
1455 (when (and gnus-simplify-ignored-prefixes
1456 (string-match gnus-simplify-ignored-prefixes subject))
1457 (setq subject (substring subject (match-end 0))))
1459 (inline (gnus-simplify-buffer-fuzzy))
1462 (defsubst gnus-simplify-subject-fully (subject)
1463 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1465 (gnus-simplify-subject-functions
1466 (gnus-map-function gnus-simplify-subject-functions subject))
1467 ((null gnus-summary-gather-subject-limit)
1468 (gnus-simplify-subject-re subject))
1469 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1470 (gnus-simplify-subject-fuzzy subject))
1471 ((numberp gnus-summary-gather-subject-limit)
1472 (gnus-limit-string (gnus-simplify-subject-re subject)
1473 gnus-summary-gather-subject-limit))
1477 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1478 "Check whether two subjects are equal.
1479 If optional argument simple-first is t, first argument is already
1482 ((null simple-first)
1483 (equal (gnus-simplify-subject-fully s1)
1484 (gnus-simplify-subject-fully s2)))
1487 (gnus-simplify-subject-fully s2)))))
1489 (defun gnus-summary-bubble-group ()
1490 "Increase the score of the current group.
1491 This is a handy function to add to `gnus-summary-exit-hook' to
1492 increase the score of each group you read."
1493 (gnus-group-add-score gnus-newsgroup-name))
1497 ;;; Gnus summary mode
1500 (put 'gnus-summary-mode 'mode-class 'special)
1502 (defvar gnus-article-commands-menu)
1505 ;; Non-orthogonal keys
1507 (gnus-define-keys gnus-summary-mode-map
1508 " " gnus-summary-next-page
1509 "\177" gnus-summary-prev-page
1510 [delete] gnus-summary-prev-page
1511 [backspace] gnus-summary-prev-page
1512 "\r" gnus-summary-scroll-up
1513 "\M-\r" gnus-summary-scroll-down
1514 "n" gnus-summary-next-unread-article
1515 "p" gnus-summary-prev-unread-article
1516 "N" gnus-summary-next-article
1517 "P" gnus-summary-prev-article
1518 "\M-\C-n" gnus-summary-next-same-subject
1519 "\M-\C-p" gnus-summary-prev-same-subject
1520 "\M-n" gnus-summary-next-unread-subject
1521 "\M-p" gnus-summary-prev-unread-subject
1522 "." gnus-summary-first-unread-article
1523 "," gnus-summary-best-unread-article
1524 "\M-s" gnus-summary-search-article-forward
1525 "\M-r" gnus-summary-search-article-backward
1526 "<" gnus-summary-beginning-of-article
1527 ">" gnus-summary-end-of-article
1528 "j" gnus-summary-goto-article
1529 "^" gnus-summary-refer-parent-article
1530 "\M-^" gnus-summary-refer-article
1531 "u" gnus-summary-tick-article-forward
1532 "!" gnus-summary-tick-article-forward
1533 "U" gnus-summary-tick-article-backward
1534 "d" gnus-summary-mark-as-read-forward
1535 "D" gnus-summary-mark-as-read-backward
1536 "E" gnus-summary-mark-as-expirable
1537 "\M-u" gnus-summary-clear-mark-forward
1538 "\M-U" gnus-summary-clear-mark-backward
1539 "k" gnus-summary-kill-same-subject-and-select
1540 "\C-k" gnus-summary-kill-same-subject
1541 "\M-\C-k" gnus-summary-kill-thread
1542 "\M-\C-l" gnus-summary-lower-thread
1543 "e" gnus-summary-edit-article
1544 "#" gnus-summary-mark-as-processable
1545 "\M-#" gnus-summary-unmark-as-processable
1546 "\M-\C-t" gnus-summary-toggle-threads
1547 "\M-\C-s" gnus-summary-show-thread
1548 "\M-\C-h" gnus-summary-hide-thread
1549 "\M-\C-f" gnus-summary-next-thread
1550 "\M-\C-b" gnus-summary-prev-thread
1551 [(meta down)] gnus-summary-next-thread
1552 [(meta up)] gnus-summary-prev-thread
1553 "\M-\C-u" gnus-summary-up-thread
1554 "\M-\C-d" gnus-summary-down-thread
1555 "&" gnus-summary-execute-command
1556 "c" gnus-summary-catchup-and-exit
1557 "\C-w" gnus-summary-mark-region-as-read
1558 "\C-t" gnus-summary-toggle-truncation
1559 "?" gnus-summary-mark-as-dormant
1560 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1561 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1562 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1563 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1564 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1565 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1566 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1567 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1568 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1569 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1570 "=" gnus-summary-expand-window
1571 "\C-x\C-s" gnus-summary-reselect-current-group
1572 "\M-g" gnus-summary-rescan-group
1573 "w" gnus-summary-stop-page-breaking
1574 "\C-c\C-r" gnus-summary-caesar-message
1575 "f" gnus-summary-followup
1576 "F" gnus-summary-followup-with-original
1577 "C" gnus-summary-cancel-article
1578 "r" gnus-summary-reply
1579 "R" gnus-summary-reply-with-original
1580 "\C-c\C-f" gnus-summary-mail-forward
1581 "o" gnus-summary-save-article
1582 "\C-o" gnus-summary-save-article-mail
1583 "|" gnus-summary-pipe-output
1584 "\M-k" gnus-summary-edit-local-kill
1585 "\M-K" gnus-summary-edit-global-kill
1587 "\C-c\C-d" gnus-summary-describe-group
1588 "q" gnus-summary-exit
1589 "Q" gnus-summary-exit-no-update
1590 "\C-c\C-i" gnus-info-find-node
1591 gnus-mouse-2 gnus-mouse-pick-article
1592 "m" gnus-summary-mail-other-window
1593 "a" gnus-summary-post-news
1594 "i" gnus-summary-news-other-window
1595 "x" gnus-summary-limit-to-unread
1596 "s" gnus-summary-isearch-article
1597 "t" gnus-summary-toggle-header
1598 "g" gnus-summary-show-article
1599 "l" gnus-summary-goto-last-article
1600 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1601 "\C-d" gnus-summary-enter-digest-group
1602 "\M-\C-d" gnus-summary-read-document
1603 "\M-\C-e" gnus-summary-edit-parameters
1604 "\M-\C-a" gnus-summary-customize-parameters
1606 "*" gnus-cache-enter-article
1607 "\M-*" gnus-cache-remove-article
1608 "\M-&" gnus-summary-universal-argument
1609 "\C-l" gnus-recenter
1610 "I" gnus-summary-increase-score
1611 "L" gnus-summary-lower-score
1612 "\M-i" gnus-symbolic-argument
1613 "h" gnus-summary-select-article-buffer
1615 "b" gnus-article-view-part
1616 "\M-t" gnus-summary-toggle-display-buttonized
1618 "V" gnus-summary-score-map
1619 "X" gnus-uu-extract-map
1620 "S" gnus-summary-send-map)
1622 ;; Sort of orthogonal keymap
1623 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1624 "t" gnus-summary-tick-article-forward
1625 "!" gnus-summary-tick-article-forward
1626 "d" gnus-summary-mark-as-read-forward
1627 "r" gnus-summary-mark-as-read-forward
1628 "c" gnus-summary-clear-mark-forward
1629 " " gnus-summary-clear-mark-forward
1630 "e" gnus-summary-mark-as-expirable
1631 "x" gnus-summary-mark-as-expirable
1632 "?" gnus-summary-mark-as-dormant
1633 "b" gnus-summary-set-bookmark
1634 "B" gnus-summary-remove-bookmark
1635 "#" gnus-summary-mark-as-processable
1636 "\M-#" gnus-summary-unmark-as-processable
1637 "S" gnus-summary-limit-include-expunged
1638 "C" gnus-summary-catchup
1639 "H" gnus-summary-catchup-to-here
1640 "h" gnus-summary-catchup-from-here
1641 "\C-c" gnus-summary-catchup-all
1642 "k" gnus-summary-kill-same-subject-and-select
1643 "K" gnus-summary-kill-same-subject
1644 "P" gnus-uu-mark-map)
1646 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1647 "c" gnus-summary-clear-above
1648 "u" gnus-summary-tick-above
1649 "m" gnus-summary-mark-above
1650 "k" gnus-summary-kill-below)
1652 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1653 "/" gnus-summary-limit-to-subject
1654 "n" gnus-summary-limit-to-articles
1655 "w" gnus-summary-pop-limit
1656 "s" gnus-summary-limit-to-subject
1657 "a" gnus-summary-limit-to-author
1658 "u" gnus-summary-limit-to-unread
1659 "m" gnus-summary-limit-to-marks
1660 "M" gnus-summary-limit-exclude-marks
1661 "v" gnus-summary-limit-to-score
1662 "*" gnus-summary-limit-include-cached
1663 "D" gnus-summary-limit-include-dormant
1664 "T" gnus-summary-limit-include-thread
1665 "d" gnus-summary-limit-exclude-dormant
1666 "t" gnus-summary-limit-to-age
1667 "." gnus-summary-limit-to-unseen
1668 "x" gnus-summary-limit-to-extra
1669 "p" gnus-summary-limit-to-display-predicate
1670 "E" gnus-summary-limit-include-expunged
1671 "c" gnus-summary-limit-exclude-childless-dormant
1672 "C" gnus-summary-limit-mark-excluded-as-read
1673 "o" gnus-summary-insert-old-articles
1674 "N" gnus-summary-insert-new-articles)
1676 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1677 "n" gnus-summary-next-unread-article
1678 "p" gnus-summary-prev-unread-article
1679 "N" gnus-summary-next-article
1680 "P" gnus-summary-prev-article
1681 "\C-n" gnus-summary-next-same-subject
1682 "\C-p" gnus-summary-prev-same-subject
1683 "\M-n" gnus-summary-next-unread-subject
1684 "\M-p" gnus-summary-prev-unread-subject
1685 "f" gnus-summary-first-unread-article
1686 "b" gnus-summary-best-unread-article
1687 "j" gnus-summary-goto-article
1688 "g" gnus-summary-goto-subject
1689 "l" gnus-summary-goto-last-article
1690 "o" gnus-summary-pop-article)
1692 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1693 "k" gnus-summary-kill-thread
1694 "l" gnus-summary-lower-thread
1695 "i" gnus-summary-raise-thread
1696 "T" gnus-summary-toggle-threads
1697 "t" gnus-summary-rethread-current
1698 "^" gnus-summary-reparent-thread
1699 "s" gnus-summary-show-thread
1700 "S" gnus-summary-show-all-threads
1701 "h" gnus-summary-hide-thread
1702 "H" gnus-summary-hide-all-threads
1703 "n" gnus-summary-next-thread
1704 "p" gnus-summary-prev-thread
1705 "u" gnus-summary-up-thread
1706 "o" gnus-summary-top-thread
1707 "d" gnus-summary-down-thread
1708 "#" gnus-uu-mark-thread
1709 "\M-#" gnus-uu-unmark-thread)
1711 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1712 "g" gnus-summary-prepare
1713 "c" gnus-summary-insert-cached-articles)
1715 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1716 "c" gnus-summary-catchup-and-exit
1717 "C" gnus-summary-catchup-all-and-exit
1718 "E" gnus-summary-exit-no-update
1719 "Q" gnus-summary-exit
1720 "Z" gnus-summary-exit
1721 "n" gnus-summary-catchup-and-goto-next-group
1722 "R" gnus-summary-reselect-current-group
1723 "G" gnus-summary-rescan-group
1724 "N" gnus-summary-next-group
1725 "s" gnus-summary-save-newsrc
1726 "P" gnus-summary-prev-group)
1728 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1729 " " gnus-summary-next-page
1730 "n" gnus-summary-next-page
1731 "\177" gnus-summary-prev-page
1732 [delete] gnus-summary-prev-page
1733 "p" gnus-summary-prev-page
1734 "\r" gnus-summary-scroll-up
1735 "\M-\r" gnus-summary-scroll-down
1736 "<" gnus-summary-beginning-of-article
1737 ">" gnus-summary-end-of-article
1738 "b" gnus-summary-beginning-of-article
1739 "e" gnus-summary-end-of-article
1740 "^" gnus-summary-refer-parent-article
1741 "r" gnus-summary-refer-parent-article
1742 "D" gnus-summary-enter-digest-group
1743 "R" gnus-summary-refer-references
1744 "T" gnus-summary-refer-thread
1745 "g" gnus-summary-show-article
1746 "s" gnus-summary-isearch-article
1747 "P" gnus-summary-print-article
1748 "M" gnus-mailing-list-insinuate
1749 "t" gnus-article-babel)
1751 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1752 "b" gnus-article-add-buttons
1753 "B" gnus-article-add-buttons-to-head
1754 "o" gnus-article-treat-overstrike
1755 "e" gnus-article-emphasize
1756 "w" gnus-article-fill-cited-article
1757 "Q" gnus-article-fill-long-lines
1758 "C" gnus-article-capitalize-sentences
1759 "c" gnus-article-remove-cr
1760 "q" gnus-article-de-quoted-unreadable
1761 "6" gnus-article-de-base64-unreadable
1762 "Z" gnus-article-decode-HZ
1763 "h" gnus-article-wash-html
1764 "u" gnus-article-unsplit-urls
1765 "s" gnus-summary-force-verify-and-decrypt
1766 "f" gnus-article-display-x-face
1767 "l" gnus-summary-stop-page-breaking
1768 "r" gnus-summary-caesar-message
1769 "m" gnus-summary-morse-message
1770 "t" gnus-summary-toggle-header
1771 "g" gnus-treat-smiley
1772 "v" gnus-summary-verbose-headers
1773 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1774 "p" gnus-article-verify-x-pgp-sig
1775 "d" gnus-article-treat-dumbquotes
1776 "k" gnus-article-outlook-deuglify-article)
1778 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1779 "a" gnus-article-hide
1780 "h" gnus-article-hide-headers
1781 "b" gnus-article-hide-boring-headers
1782 "s" gnus-article-hide-signature
1783 "c" gnus-article-hide-citation
1784 "C" gnus-article-hide-citation-in-followups
1785 "l" gnus-article-hide-list-identifiers
1786 "p" gnus-article-hide-pgp
1787 "B" gnus-article-strip-banner
1788 "P" gnus-article-hide-pem
1789 "\C-c" gnus-article-hide-citation-maybe)
1791 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1792 "a" gnus-article-highlight
1793 "h" gnus-article-highlight-headers
1794 "c" gnus-article-highlight-citation
1795 "s" gnus-article-highlight-signature)
1797 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1798 "f" gnus-article-treat-fold-headers
1799 "u" gnus-article-treat-unfold-headers
1800 "n" gnus-article-treat-fold-newsgroups)
1802 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1803 "x" gnus-article-display-x-face
1804 "s" gnus-treat-smiley
1805 "D" gnus-article-remove-images
1806 "f" gnus-treat-from-picon
1807 "m" gnus-treat-mail-picon
1808 "n" gnus-treat-newsgroups-picon)
1810 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1811 "w" gnus-article-decode-mime-words
1812 "c" gnus-article-decode-charset
1813 "v" gnus-mime-view-all-parts
1814 "b" gnus-article-view-part)
1816 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1817 "z" gnus-article-date-ut
1818 "u" gnus-article-date-ut
1819 "l" gnus-article-date-local
1820 "p" gnus-article-date-english
1821 "e" gnus-article-date-lapsed
1822 "o" gnus-article-date-original
1823 "i" gnus-article-date-iso8601
1824 "s" gnus-article-date-user)
1826 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1827 "t" gnus-article-remove-trailing-blank-lines
1828 "l" gnus-article-strip-leading-blank-lines
1829 "m" gnus-article-strip-multiple-blank-lines
1830 "a" gnus-article-strip-blank-lines
1831 "A" gnus-article-strip-all-blank-lines
1832 "s" gnus-article-strip-leading-space
1833 "e" gnus-article-strip-trailing-space
1834 "w" gnus-article-remove-leading-whitespace)
1836 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1838 "f" gnus-summary-fetch-faq
1839 "d" gnus-summary-describe-group
1840 "h" gnus-summary-describe-briefly
1841 "i" gnus-info-find-node
1842 "c" gnus-group-fetch-charter
1843 "C" gnus-group-fetch-control)
1845 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1846 "e" gnus-summary-expire-articles
1847 "\M-\C-e" gnus-summary-expire-articles-now
1848 "\177" gnus-summary-delete-article
1849 [delete] gnus-summary-delete-article
1850 [backspace] gnus-summary-delete-article
1851 "m" gnus-summary-move-article
1852 "r" gnus-summary-respool-article
1853 "w" gnus-summary-edit-article
1854 "c" gnus-summary-copy-article
1855 "B" gnus-summary-crosspost-article
1856 "q" gnus-summary-respool-query
1857 "t" gnus-summary-respool-trace
1858 "i" gnus-summary-import-article
1859 "I" gnus-summary-create-article
1860 "p" gnus-summary-article-posted-p)
1862 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1863 "o" gnus-summary-save-article
1864 "m" gnus-summary-save-article-mail
1865 "F" gnus-summary-write-article-file
1866 "r" gnus-summary-save-article-rmail
1867 "f" gnus-summary-save-article-file
1868 "b" gnus-summary-save-article-body-file
1869 "h" gnus-summary-save-article-folder
1870 "v" gnus-summary-save-article-vm
1871 "p" gnus-summary-pipe-output
1872 "P" gnus-summary-muttprint
1873 "s" gnus-soup-add-article)
1875 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1876 "b" gnus-summary-display-buttonized
1877 "m" gnus-summary-repair-multipart
1878 "v" gnus-article-view-part
1879 "o" gnus-article-save-part
1880 "c" gnus-article-copy-part
1881 "C" gnus-article-view-part-as-charset
1882 "e" gnus-article-view-part-externally
1883 "E" gnus-article-encrypt-body
1884 "i" gnus-article-inline-part
1885 "|" gnus-article-pipe-part)
1887 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1888 "p" gnus-summary-mark-as-processable
1889 "u" gnus-summary-unmark-as-processable
1890 "U" gnus-summary-unmark-all-processable
1891 "v" gnus-uu-mark-over
1892 "s" gnus-uu-mark-series
1893 "r" gnus-uu-mark-region
1894 "g" gnus-uu-unmark-region
1895 "R" gnus-uu-mark-by-regexp
1896 "G" gnus-uu-unmark-by-regexp
1897 "t" gnus-uu-mark-thread
1898 "T" gnus-uu-unmark-thread
1899 "a" gnus-uu-mark-all
1900 "b" gnus-uu-mark-buffer
1901 "S" gnus-uu-mark-sparse
1902 "k" gnus-summary-kill-process-mark
1903 "y" gnus-summary-yank-process-mark
1904 "w" gnus-summary-save-process-mark
1905 "i" gnus-uu-invert-processable)
1907 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1908 ;;"x" gnus-uu-extract-any
1909 "m" gnus-summary-save-parts
1910 "u" gnus-uu-decode-uu
1911 "U" gnus-uu-decode-uu-and-save
1912 "s" gnus-uu-decode-unshar
1913 "S" gnus-uu-decode-unshar-and-save
1914 "o" gnus-uu-decode-save
1915 "O" gnus-uu-decode-save
1916 "b" gnus-uu-decode-binhex
1917 "B" gnus-uu-decode-binhex
1918 "p" gnus-uu-decode-postscript
1919 "P" gnus-uu-decode-postscript-and-save)
1922 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1923 "u" gnus-uu-decode-uu-view
1924 "U" gnus-uu-decode-uu-and-save-view
1925 "s" gnus-uu-decode-unshar-view
1926 "S" gnus-uu-decode-unshar-and-save-view
1927 "o" gnus-uu-decode-save-view
1928 "O" gnus-uu-decode-save-view
1929 "b" gnus-uu-decode-binhex-view
1930 "B" gnus-uu-decode-binhex-view
1931 "p" gnus-uu-decode-postscript-view
1932 "P" gnus-uu-decode-postscript-and-save-view))
1934 (defvar gnus-article-post-menu nil)
1936 (defconst gnus-summary-menu-maxlen 20)
1938 (defun gnus-summary-menu-split (menu)
1939 ;; If we have lots of elements, divide them into groups of 20
1940 ;; and make a pane (or submenu) for each one.
1941 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1942 (let ((menu menu) sublists next
1945 ;; Pull off the next gnus-summary-menu-maxlen elements
1946 ;; and make them the next element of sublist.
1947 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1949 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1951 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1952 (aref (car (last menu)) 0)) menu)
1956 (nreverse sublists))
1957 ;; Few elements--put them all in one pane.
1960 (defun gnus-summary-make-menu-bar ()
1961 (gnus-turn-off-edit-menu 'summary)
1963 (unless (boundp 'gnus-summary-misc-menu)
1966 gnus-summary-kill-menu gnus-summary-mode-map ""
1971 ["Customize" gnus-score-customize t])
1972 (gnus-make-score-map 'increase)
1973 (gnus-make-score-map 'lower)
1975 ["Kill below" gnus-summary-kill-below t]
1976 ["Mark above" gnus-summary-mark-above t]
1977 ["Tick above" gnus-summary-tick-above t]
1978 ["Clear above" gnus-summary-clear-above t])
1979 ["Current score" gnus-summary-current-score t]
1980 ["Set score" gnus-summary-set-score t]
1981 ["Switch current score file..." gnus-score-change-score-file t]
1982 ["Set mark below..." gnus-score-set-mark-below t]
1983 ["Set expunge below..." gnus-score-set-expunge-below t]
1984 ["Edit current score file" gnus-score-edit-current-scores t]
1985 ["Edit score file" gnus-score-edit-file t]
1986 ["Trace score" gnus-score-find-trace t]
1987 ["Find words" gnus-score-find-favourite-words t]
1988 ["Rescore buffer" gnus-summary-rescore t]
1989 ["Increase score..." gnus-summary-increase-score t]
1990 ["Lower score..." gnus-summary-lower-score t]))))
1992 ;; Define both the Article menu in the summary buffer and the
1993 ;; equivalent Commands menu in the article buffer here for
1997 ["All" gnus-article-hide t]
1998 ["Headers" gnus-article-hide-headers t]
1999 ["Signature" gnus-article-hide-signature t]
2000 ["Citation" gnus-article-hide-citation t]
2001 ["List identifiers" gnus-article-hide-list-identifiers t]
2002 ["PGP" gnus-article-hide-pgp t]
2003 ["Banner" gnus-article-strip-banner t]
2004 ["Boring headers" gnus-article-hide-boring-headers t])
2006 ["All" gnus-article-highlight t]
2007 ["Headers" gnus-article-highlight-headers t]
2008 ["Signature" gnus-article-highlight-signature t]
2009 ["Citation" gnus-article-highlight-citation t])
2011 ["Words" gnus-article-decode-mime-words t]
2012 ["Charset" gnus-article-decode-charset t]
2013 ["QP" gnus-article-de-quoted-unreadable t]
2014 ["Base64" gnus-article-de-base64-unreadable t]
2015 ["View MIME buttons" gnus-summary-display-buttonized t]
2016 ["View all" gnus-mime-view-all-parts t]
2017 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2018 ["Encrypt body" gnus-article-encrypt-body t]
2019 ["Extract all parts" gnus-summary-save-parts t])
2021 ["Local" gnus-article-date-local t]
2022 ["ISO8601" gnus-article-date-iso8601 t]
2023 ["UT" gnus-article-date-ut t]
2024 ["Original" gnus-article-date-original t]
2025 ["Lapsed" gnus-article-date-lapsed t]
2026 ["User-defined" gnus-article-date-user t])
2028 ["Remove images" gnus-article-remove-images t]
2029 ["Toggle smiley" gnus-treat-smiley t]
2030 ["Show X-Face" gnus-article-display-x-face t]
2031 ["Show picons in From" gnus-treat-from-picon t]
2032 ["Show picons in mail headers" gnus-treat-mail-picon t]
2033 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2034 ("View as different encoding"
2035 ,@(gnus-summary-menu-split
2038 ;; Since easymenu under FSF Emacs doesn't allow lambda
2039 ;; forms for menu commands, we should provide intern'ed
2040 ;; function symbols.
2041 (let ((command (intern (format "\
2042 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2046 (let ((gnus-summary-show-article-charset-alist
2048 (gnus-summary-show-article 1))))
2049 `[,(symbol-name cs) ,command t]))
2050 (sort (if (fboundp 'coding-system-list)
2051 (coding-system-list)
2052 (mapcar 'car mm-mime-mule-charset-alist))
2056 ["Leading" gnus-article-strip-leading-blank-lines t]
2057 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2058 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2059 ["All of the above" gnus-article-strip-blank-lines t]
2060 ["All" gnus-article-strip-all-blank-lines t]
2061 ["Leading space" gnus-article-strip-leading-space t]
2062 ["Trailing space" gnus-article-strip-trailing-space t]
2063 ["Leading space in headers"
2064 gnus-article-remove-leading-whitespace t])
2065 ["Overstrike" gnus-article-treat-overstrike t]
2066 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2067 ["Emphasis" gnus-article-emphasize t]
2068 ["Word wrap" gnus-article-fill-cited-article t]
2069 ["Fill long lines" gnus-article-fill-long-lines t]
2070 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2071 ["CR" gnus-article-remove-cr t]
2072 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2073 ["Base64" gnus-article-de-base64-unreadable t]
2074 ["Rot 13" gnus-summary-caesar-message
2075 ,@(if (featurep 'xemacs) '(t)
2076 '(:help "\"Caesar rotate\" article by 13"))]
2077 ["Morse decode" gnus-summary-morse-message t]
2078 ["Unix pipe..." gnus-summary-pipe-message t]
2079 ["Add buttons" gnus-article-add-buttons t]
2080 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2081 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2082 ["Verbose header" gnus-summary-verbose-headers t]
2083 ["Toggle header" gnus-summary-toggle-header t]
2084 ["Unfold headers" gnus-article-treat-unfold-headers t]
2085 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2086 ["Html" gnus-article-wash-html t]
2087 ["URLs" gnus-article-unsplit-urls t]
2088 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2089 ["HZ" gnus-article-decode-HZ t]
2090 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2093 ["Save in default format" gnus-summary-save-article
2094 ,@(if (featurep 'xemacs) '(t)
2095 '(:help "Save article using default method"))]
2096 ["Save in file" gnus-summary-save-article-file
2097 ,@(if (featurep 'xemacs) '(t)
2098 '(:help "Save article in file"))]
2099 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2100 ["Save in MH folder" gnus-summary-save-article-folder t]
2101 ["Save in VM folder" gnus-summary-save-article-vm t]
2102 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2103 ["Save body in file" gnus-summary-save-article-body-file t]
2104 ["Pipe through a filter" gnus-summary-pipe-output t]
2105 ["Add to SOUP packet" gnus-soup-add-article t]
2106 ["Print with Muttprint" gnus-summary-muttprint t]
2107 ["Print" gnus-summary-print-article t])
2109 ["Respool article..." gnus-summary-respool-article t]
2110 ["Move article..." gnus-summary-move-article
2111 (gnus-check-backend-function
2112 'request-move-article gnus-newsgroup-name)]
2113 ["Copy article..." gnus-summary-copy-article t]
2114 ["Crosspost article..." gnus-summary-crosspost-article
2115 (gnus-check-backend-function
2116 'request-replace-article gnus-newsgroup-name)]
2117 ["Import file..." gnus-summary-import-article t]
2118 ["Create article..." gnus-summary-create-article t]
2119 ["Check if posted" gnus-summary-article-posted-p t]
2120 ["Edit article" gnus-summary-edit-article
2121 (not (gnus-group-read-only-p))]
2122 ["Delete article" gnus-summary-delete-article
2123 (gnus-check-backend-function
2124 'request-expire-articles gnus-newsgroup-name)]
2125 ["Query respool" gnus-summary-respool-query t]
2126 ["Trace respool" gnus-summary-respool-trace t]
2127 ["Delete expirable articles" gnus-summary-expire-articles-now
2128 (gnus-check-backend-function
2129 'request-expire-articles gnus-newsgroup-name)])
2131 ["Uudecode" gnus-uu-decode-uu
2132 ,@(if (featurep 'xemacs) '(t)
2133 '(:help "Decode uuencoded article(s)"))]
2134 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2135 ["Unshar" gnus-uu-decode-unshar t]
2136 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2137 ["Save" gnus-uu-decode-save t]
2138 ["Binhex" gnus-uu-decode-binhex t]
2139 ["Postscript" gnus-uu-decode-postscript t]
2140 ["All MIME parts" gnus-summary-save-parts t])
2142 ["Enter article" gnus-cache-enter-article t]
2143 ["Remove article" gnus-cache-remove-article t])
2144 ["Translate" gnus-article-babel t]
2145 ["Select article buffer" gnus-summary-select-article-buffer t]
2146 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2147 ["Isearch article..." gnus-summary-isearch-article t]
2148 ["Beginning of the article" gnus-summary-beginning-of-article t]
2149 ["End of the article" gnus-summary-end-of-article t]
2150 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2151 ["Fetch referenced articles" gnus-summary-refer-references t]
2152 ["Fetch current thread" gnus-summary-refer-thread t]
2153 ["Fetch article with id..." gnus-summary-refer-article t]
2154 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2155 ["Redisplay" gnus-summary-show-article t]
2156 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2158 gnus-summary-article-menu gnus-summary-mode-map ""
2159 (cons "Article" innards))
2161 (if (not (keymapp gnus-summary-article-menu))
2163 gnus-article-commands-menu gnus-article-mode-map ""
2164 (cons "Commands" innards))
2165 ;; in Emacs, don't share menu.
2166 (setq gnus-article-commands-menu
2167 (copy-keymap gnus-summary-article-menu))
2168 (define-key gnus-article-mode-map [menu-bar commands]
2169 (cons "Commands" gnus-article-commands-menu))))
2172 gnus-summary-thread-menu gnus-summary-mode-map ""
2174 ["Toggle threading" gnus-summary-toggle-threads t]
2175 ["Hide threads" gnus-summary-hide-all-threads t]
2176 ["Show threads" gnus-summary-show-all-threads t]
2177 ["Hide thread" gnus-summary-hide-thread t]
2178 ["Show thread" gnus-summary-show-thread t]
2179 ["Go to next thread" gnus-summary-next-thread t]
2180 ["Go to previous thread" gnus-summary-prev-thread t]
2181 ["Go down thread" gnus-summary-down-thread t]
2182 ["Go up thread" gnus-summary-up-thread t]
2183 ["Top of thread" gnus-summary-top-thread t]
2184 ["Mark thread as read" gnus-summary-kill-thread t]
2185 ["Lower thread score" gnus-summary-lower-thread t]
2186 ["Raise thread score" gnus-summary-raise-thread t]
2187 ["Rethread current" gnus-summary-rethread-current t]))
2190 gnus-summary-post-menu gnus-summary-mode-map ""
2192 ["Send a message (mail or news)" gnus-summary-post-news
2193 ,@(if (featurep 'xemacs) '(t)
2194 '(:help "Post an article"))]
2195 ["Followup" gnus-summary-followup
2196 ,@(if (featurep 'xemacs) '(t)
2197 '(:help "Post followup to this article"))]
2198 ["Followup and yank" gnus-summary-followup-with-original
2199 ,@(if (featurep 'xemacs) '(t)
2200 '(:help "Post followup to this article, quoting its contents"))]
2201 ["Supersede article" gnus-summary-supersede-article t]
2202 ["Cancel article" gnus-summary-cancel-article
2203 ,@(if (featurep 'xemacs) '(t)
2204 '(:help "Cancel an article you posted"))]
2205 ["Reply" gnus-summary-reply t]
2206 ["Reply and yank" gnus-summary-reply-with-original t]
2207 ["Wide reply" gnus-summary-wide-reply t]
2208 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2209 ,@(if (featurep 'xemacs) '(t)
2210 '(:help "Mail a reply, quoting this article"))]
2211 ["Very wide reply" gnus-summary-very-wide-reply t]
2212 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2213 ,@(if (featurep 'xemacs) '(t)
2214 '(:help "Mail a very wide reply, quoting this article"))]
2215 ["Mail forward" gnus-summary-mail-forward t]
2216 ["Post forward" gnus-summary-post-forward t]
2217 ["Digest and mail" gnus-uu-digest-mail-forward t]
2218 ["Digest and post" gnus-uu-digest-post-forward t]
2219 ["Resend message" gnus-summary-resend-message t]
2220 ["Resend message edit" gnus-summary-resend-message-edit t]
2221 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2222 ["Send a mail" gnus-summary-mail-other-window t]
2223 ["Create a local message" gnus-summary-news-other-window t]
2224 ["Uuencode and post" gnus-uu-post-news
2225 ,@(if (featurep 'xemacs) '(t)
2226 '(:help "Post a uuencoded article"))]
2227 ["Followup via news" gnus-summary-followup-to-mail t]
2228 ["Followup via news and yank"
2229 gnus-summary-followup-to-mail-with-original t]
2231 ;;["Send" gnus-summary-send-draft t]
2232 ;;["Send bounced" gnus-resend-bounced-mail t])
2236 ((not (keymapp gnus-summary-post-menu))
2237 (setq gnus-article-post-menu gnus-summary-post-menu))
2238 ((not gnus-article-post-menu)
2239 ;; Don't share post menu.
2240 (setq gnus-article-post-menu
2241 (copy-keymap gnus-summary-post-menu))))
2242 (define-key gnus-article-mode-map [menu-bar post]
2243 (cons "Post" gnus-article-post-menu))
2246 gnus-summary-misc-menu gnus-summary-mode-map ""
2249 ["Mark as read" gnus-summary-mark-as-read-forward t]
2250 ["Mark same subject and select"
2251 gnus-summary-kill-same-subject-and-select t]
2252 ["Mark same subject" gnus-summary-kill-same-subject t]
2253 ["Catchup" gnus-summary-catchup
2254 ,@(if (featurep 'xemacs) '(t)
2255 '(:help "Mark unread articles in this group as read"))]
2256 ["Catchup all" gnus-summary-catchup-all t]
2257 ["Catchup to here" gnus-summary-catchup-to-here t]
2258 ["Catchup from here" gnus-summary-catchup-from-here t]
2259 ["Catchup region" gnus-summary-mark-region-as-read t]
2260 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2262 ["Tick" gnus-summary-tick-article-forward t]
2263 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2264 ["Remove marks" gnus-summary-clear-mark-forward t]
2265 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2266 ["Set bookmark" gnus-summary-set-bookmark t]
2267 ["Remove bookmark" gnus-summary-remove-bookmark t])
2269 ["Marks..." gnus-summary-limit-to-marks t]
2270 ["Subject..." gnus-summary-limit-to-subject t]
2271 ["Author..." gnus-summary-limit-to-author t]
2272 ["Age..." gnus-summary-limit-to-age t]
2273 ["Extra..." gnus-summary-limit-to-extra t]
2274 ["Score..." gnus-summary-limit-to-score t]
2275 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2276 ["Unread" gnus-summary-limit-to-unread t]
2277 ["Unseen" gnus-summary-limit-to-unseen t]
2278 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2279 ["Articles" gnus-summary-limit-to-articles t]
2280 ["Pop limit" gnus-summary-pop-limit t]
2281 ["Show dormant" gnus-summary-limit-include-dormant t]
2282 ["Hide childless dormant"
2283 gnus-summary-limit-exclude-childless-dormant t]
2284 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2285 ["Hide marked" gnus-summary-limit-exclude-marks t]
2286 ["Show expunged" gnus-summary-limit-include-expunged t])
2288 ["Set mark" gnus-summary-mark-as-processable t]
2289 ["Remove mark" gnus-summary-unmark-as-processable t]
2290 ["Remove all marks" gnus-summary-unmark-all-processable t]
2291 ["Mark above" gnus-uu-mark-over t]
2292 ["Mark series" gnus-uu-mark-series t]
2293 ["Mark region" gnus-uu-mark-region t]
2294 ["Unmark region" gnus-uu-unmark-region t]
2295 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2296 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2297 ["Mark all" gnus-uu-mark-all t]
2298 ["Mark buffer" gnus-uu-mark-buffer t]
2299 ["Mark sparse" gnus-uu-mark-sparse t]
2300 ["Mark thread" gnus-uu-mark-thread t]
2301 ["Unmark thread" gnus-uu-unmark-thread t]
2302 ("Process Mark Sets"
2303 ["Kill" gnus-summary-kill-process-mark t]
2304 ["Yank" gnus-summary-yank-process-mark
2305 gnus-newsgroup-process-stack]
2306 ["Save" gnus-summary-save-process-mark t]))
2308 ["Page forward" gnus-summary-next-page
2309 ,@(if (featurep 'xemacs) '(t)
2310 '(:help "Show next page of article"))]
2311 ["Page backward" gnus-summary-prev-page
2312 ,@(if (featurep 'xemacs) '(t)
2313 '(:help "Show previous page of article"))]
2314 ["Line forward" gnus-summary-scroll-up t])
2316 ["Next unread article" gnus-summary-next-unread-article t]
2317 ["Previous unread article" gnus-summary-prev-unread-article t]
2318 ["Next article" gnus-summary-next-article t]
2319 ["Previous article" gnus-summary-prev-article t]
2320 ["Next unread subject" gnus-summary-next-unread-subject t]
2321 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2322 ["Next article same subject" gnus-summary-next-same-subject t]
2323 ["Previous article same subject" gnus-summary-prev-same-subject t]
2324 ["First unread article" gnus-summary-first-unread-article t]
2325 ["Best unread article" gnus-summary-best-unread-article t]
2326 ["Go to subject number..." gnus-summary-goto-subject t]
2327 ["Go to article number..." gnus-summary-goto-article t]
2328 ["Go to the last article" gnus-summary-goto-last-article t]
2329 ["Pop article off history" gnus-summary-pop-article t])
2331 ["Sort by number" gnus-summary-sort-by-number t]
2332 ["Sort by author" gnus-summary-sort-by-author t]
2333 ["Sort by subject" gnus-summary-sort-by-subject t]
2334 ["Sort by date" gnus-summary-sort-by-date t]
2335 ["Sort by score" gnus-summary-sort-by-score t]
2336 ["Sort by lines" gnus-summary-sort-by-lines t]
2337 ["Sort by characters" gnus-summary-sort-by-chars t]
2338 ["Randomize" gnus-summary-sort-by-random t]
2339 ["Original sort" gnus-summary-sort-by-original t])
2341 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2342 ["Describe group" gnus-summary-describe-group t]
2343 ["Fetch charter" gnus-group-fetch-charter
2344 ,@(if (featurep 'xemacs) nil
2345 '(:help "Display the charter of the current group"))]
2346 ["Fetch control message" gnus-group-fetch-control
2347 ,@(if (featurep 'xemacs) nil
2348 '(:help "Display the archived control message for the current group"))]
2349 ["Read manual" gnus-info-find-node t])
2351 ["Pick and read" gnus-pick-mode t]
2352 ["Binary" gnus-binary-mode t])
2354 ["Regenerate" gnus-summary-prepare t]
2355 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2356 ["Toggle threading" gnus-summary-toggle-threads t])
2357 ["See old articles" gnus-summary-insert-old-articles t]
2358 ["See new articles" gnus-summary-insert-new-articles t]
2359 ["Filter articles..." gnus-summary-execute-command t]
2360 ["Run command on subjects..." gnus-summary-universal-argument t]
2361 ["Search articles forward..." gnus-summary-search-article-forward t]
2362 ["Search articles backward..." gnus-summary-search-article-backward t]
2363 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2364 ["Expand window" gnus-summary-expand-window t]
2365 ["Expire expirable articles" gnus-summary-expire-articles
2366 (gnus-check-backend-function
2367 'request-expire-articles gnus-newsgroup-name)]
2368 ["Edit local kill file" gnus-summary-edit-local-kill t]
2369 ["Edit main kill file" gnus-summary-edit-global-kill t]
2370 ["Edit group parameters" gnus-summary-edit-parameters t]
2371 ["Customize group parameters" gnus-summary-customize-parameters t]
2372 ["Send a bug report" gnus-bug t]
2374 ["Catchup and exit" gnus-summary-catchup-and-exit
2375 ,@(if (featurep 'xemacs) '(t)
2376 '(:help "Mark unread articles in this group as read, then exit"))]
2377 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2378 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2379 ["Exit group" gnus-summary-exit
2380 ,@(if (featurep 'xemacs) '(t)
2381 '(:help "Exit current group, return to group selection mode"))]
2382 ["Exit group without updating" gnus-summary-exit-no-update t]
2383 ["Exit and goto next group" gnus-summary-next-group t]
2384 ["Exit and goto prev group" gnus-summary-prev-group t]
2385 ["Reselect group" gnus-summary-reselect-current-group t]
2386 ["Rescan group" gnus-summary-rescan-group t]
2387 ["Update dribble" gnus-summary-save-newsrc t])))
2389 (gnus-run-hooks 'gnus-summary-menu-hook)))
2391 (defvar gnus-summary-tool-bar-map nil)
2393 ;; Emacs 21 tool bar. Should be no-op otherwise.
2394 (defun gnus-summary-make-tool-bar ()
2395 (if (and (fboundp 'tool-bar-add-item-from-menu)
2396 (default-value 'tool-bar-mode)
2397 (not gnus-summary-tool-bar-map))
2398 (setq gnus-summary-tool-bar-map
2399 (let ((tool-bar-map (make-sparse-keymap))
2400 (load-path (mm-image-load-path)))
2401 (tool-bar-add-item-from-menu
2402 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2403 (tool-bar-add-item-from-menu
2404 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2405 (tool-bar-add-item-from-menu
2406 'gnus-summary-post-news "post" gnus-summary-mode-map)
2407 (tool-bar-add-item-from-menu
2408 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2409 (tool-bar-add-item-from-menu
2410 'gnus-summary-followup "followup" gnus-summary-mode-map)
2411 (tool-bar-add-item-from-menu
2412 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2413 (tool-bar-add-item-from-menu
2414 'gnus-summary-reply "reply" gnus-summary-mode-map)
2415 (tool-bar-add-item-from-menu
2416 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2417 (tool-bar-add-item-from-menu
2418 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2419 (tool-bar-add-item-from-menu
2420 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2421 (tool-bar-add-item-from-menu
2422 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2423 (tool-bar-add-item-from-menu
2424 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2425 (tool-bar-add-item-from-menu
2426 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2427 (tool-bar-add-item-from-menu
2428 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2429 (tool-bar-add-item-from-menu
2430 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2432 (if gnus-summary-tool-bar-map
2433 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2435 (defun gnus-score-set-default (var value)
2436 "A version of set that updates the GNU Emacs menu-bar."
2438 ;; It is the message that forces the active status to be updated.
2441 (defun gnus-make-score-map (type)
2442 "Make a summary score map of type TYPE."
2445 (let ((headers '(("author" "from" string)
2446 ("subject" "subject" string)
2447 ("article body" "body" string)
2448 ("article head" "head" string)
2449 ("xref" "xref" string)
2450 ("extra header" "extra" string)
2451 ("lines" "lines" number)
2452 ("followups to author" "followup" string)))
2453 (types '((number ("less than" <)
2456 (string ("substring" s)
2460 (perms '(("temporary" (current-time-string))
2468 (if (eq type 'lower)
2473 (setq header (car headers))
2479 (let ((ts (cdr (assoc (nth 2 header) types)))
2495 'gnus-summary-score-entry
2497 (if (or (string= (nth 1 header)
2499 (string= (nth 1 header)
2502 (list 'gnus-summary-header
2504 (list 'quote (nth 1 (car ts)))
2505 (list 'gnus-score-delta-default
2512 (list (nreverse outp))))
2515 (list (nreverse outt))))
2517 (setq headers (cdr headers)))
2518 (list (nreverse outh))))))))
2522 (defun gnus-summary-mode (&optional group)
2523 "Major mode for reading articles.
2525 All normal editing commands are switched off.
2526 \\<gnus-summary-mode-map>
2527 Each line in this buffer represents one article. To read an
2528 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2529 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2532 You can also post articles and send mail from this buffer. To
2533 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2534 of an article, type `\\[gnus-summary-reply]'.
2536 There are approx. one gazillion commands you can execute in this
2537 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2539 The following commands are available:
2541 \\{gnus-summary-mode-map}"
2543 (kill-all-local-variables)
2544 (when (gnus-visual-p 'summary-menu 'menu)
2545 (gnus-summary-make-menu-bar)
2546 (gnus-summary-make-tool-bar))
2547 (gnus-summary-make-local-variables)
2548 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2549 (gnus-summary-make-local-variables))
2550 (gnus-make-thread-indent-array)
2551 (gnus-simplify-mode-line)
2552 (setq major-mode 'gnus-summary-mode)
2553 (setq mode-name "Summary")
2554 (make-local-variable 'minor-mode-alist)
2555 (use-local-map gnus-summary-mode-map)
2556 (buffer-disable-undo)
2557 (setq buffer-read-only t) ;Disable modification
2558 (setq truncate-lines t)
2559 (setq selective-display t)
2560 (setq selective-display-ellipses t) ;Display `...'
2561 (gnus-summary-set-display-table)
2562 (gnus-set-default-directory)
2563 (setq gnus-newsgroup-name group)
2564 (make-local-variable 'gnus-summary-line-format)
2565 (make-local-variable 'gnus-summary-line-format-spec)
2566 (make-local-variable 'gnus-summary-dummy-line-format)
2567 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2568 (make-local-variable 'gnus-summary-mark-positions)
2569 (make-local-hook 'pre-command-hook)
2570 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2571 (gnus-run-hooks 'gnus-summary-mode-hook)
2572 (turn-on-gnus-mailing-list-mode)
2573 (mm-enable-multibyte)
2574 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2575 (gnus-update-summary-mark-positions))
2577 (defun gnus-summary-make-local-variables ()
2578 "Make all the local summary buffer variables."
2580 (dolist (local gnus-summary-local-variables)
2583 (if (eq (cdr local) 'global)
2584 ;; Copy the global value of the variable.
2585 (setq global (symbol-value (car local)))
2586 ;; Use the value from the list.
2587 (setq global (eval (cdr local))))
2588 (set (make-local-variable (car local)) global))
2589 ;; Simple nil-valued local variable.
2590 (set (make-local-variable local) nil)))))
2592 (defun gnus-summary-clear-local-variables ()
2593 (let ((locals gnus-summary-local-variables))
2595 (if (consp (car locals))
2596 (and (vectorp (caar locals))
2597 (set (caar locals) nil))
2598 (and (vectorp (car locals))
2599 (set (car locals) nil)))
2600 (setq locals (cdr locals)))))
2602 ;; Summary data functions.
2604 (defmacro gnus-data-number (data)
2607 (defmacro gnus-data-set-number (data number)
2608 `(setcar ,data ,number))
2610 (defmacro gnus-data-mark (data)
2613 (defmacro gnus-data-set-mark (data mark)
2614 `(setcar (nthcdr 1 ,data) ,mark))
2616 (defmacro gnus-data-pos (data)
2619 (defmacro gnus-data-set-pos (data pos)
2620 `(setcar (nthcdr 2 ,data) ,pos))
2622 (defmacro gnus-data-header (data)
2625 (defmacro gnus-data-set-header (data header)
2626 `(setf (nth 3 ,data) ,header))
2628 (defmacro gnus-data-level (data)
2631 (defmacro gnus-data-unread-p (data)
2632 `(= (nth 1 ,data) gnus-unread-mark))
2634 (defmacro gnus-data-read-p (data)
2635 `(/= (nth 1 ,data) gnus-unread-mark))
2637 (defmacro gnus-data-pseudo-p (data)
2638 `(consp (nth 3 ,data)))
2640 (defmacro gnus-data-find (number)
2641 `(assq ,number gnus-newsgroup-data))
2643 (defmacro gnus-data-find-list (number &optional data)
2644 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2645 (memq (assq ,number bdata)
2648 (defmacro gnus-data-make (number mark pos header level)
2649 `(list ,number ,mark ,pos ,header ,level))
2651 (defun gnus-data-enter (after-article number mark pos header level offset)
2652 (let ((data (gnus-data-find-list after-article)))
2654 (error "No such article: %d" after-article))
2655 (setcdr data (cons (gnus-data-make number mark pos header level)
2657 (setq gnus-newsgroup-data-reverse nil)
2658 (gnus-data-update-list (cddr data) offset)))
2660 (defun gnus-data-enter-list (after-article list &optional offset)
2662 (let ((data (and after-article (gnus-data-find-list after-article)))
2666 (let ((odata gnus-newsgroup-data))
2667 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2669 (gnus-data-update-list odata offset)))
2670 ;; Find the last element in the list to be spliced into the main
2673 (setq list (cdr list)))
2676 (setcdr list gnus-newsgroup-data)
2677 (setq gnus-newsgroup-data ilist)
2679 (gnus-data-update-list (cdr list) offset)))
2680 (setcdr list (cdr data))
2683 (gnus-data-update-list (cdr list) offset))))
2684 (setq gnus-newsgroup-data-reverse nil))))
2686 (defun gnus-data-remove (article &optional offset)
2687 (let ((data gnus-newsgroup-data))
2688 (if (= (gnus-data-number (car data)) article)
2690 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2691 gnus-newsgroup-data-reverse nil)
2693 (gnus-data-update-list gnus-newsgroup-data offset)))
2695 (when (= (gnus-data-number (cadr data)) article)
2696 (setcdr data (cddr data))
2698 (gnus-data-update-list (cdr data) offset))
2700 gnus-newsgroup-data-reverse nil))
2701 (setq data (cdr data))))))
2703 (defmacro gnus-data-list (backward)
2705 (or gnus-newsgroup-data-reverse
2706 (setq gnus-newsgroup-data-reverse
2707 (reverse gnus-newsgroup-data)))
2708 gnus-newsgroup-data))
2710 (defun gnus-data-update-list (data offset)
2711 "Add OFFSET to the POS of all data entries in DATA."
2712 (setq gnus-newsgroup-data-reverse nil)
2714 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2715 (setq data (cdr data))))
2717 (defun gnus-summary-article-pseudo-p (article)
2718 "Say whether this article is a pseudo article or not."
2719 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2721 (defmacro gnus-summary-article-sparse-p (article)
2722 "Say whether this article is a sparse article or not."
2723 `(memq ,article gnus-newsgroup-sparse))
2725 (defmacro gnus-summary-article-ancient-p (article)
2726 "Say whether this article is a sparse article or not."
2727 `(memq ,article gnus-newsgroup-ancient))
2729 (defun gnus-article-parent-p (number)
2730 "Say whether this article is a parent or not."
2731 (let ((data (gnus-data-find-list number)))
2732 (and (cdr data) ; There has to be an article after...
2733 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2734 (gnus-data-level (nth 1 data))))))
2736 (defun gnus-article-children (number)
2737 "Return a list of all children to NUMBER."
2738 (let* ((data (gnus-data-find-list number))
2739 (level (gnus-data-level (car data)))
2741 (setq data (cdr data))
2743 (= (gnus-data-level (car data)) (1+ level)))
2744 (push (gnus-data-number (car data)) children)
2745 (setq data (cdr data)))
2748 (defmacro gnus-summary-skip-intangible ()
2749 "If the current article is intangible, then jump to a different article."
2750 '(let ((to (get-text-property (point) 'gnus-intangible)))
2751 (and to (gnus-summary-goto-subject to))))
2753 (defmacro gnus-summary-article-intangible-p ()
2754 "Say whether this article is intangible or not."
2755 '(get-text-property (point) 'gnus-intangible))
2757 (defun gnus-article-read-p (article)
2758 "Say whether ARTICLE is read or not."
2759 (not (or (memq article gnus-newsgroup-marked)
2760 (memq article gnus-newsgroup-spam-marked)
2761 (memq article gnus-newsgroup-unreads)
2762 (memq article gnus-newsgroup-unselected)
2763 (memq article gnus-newsgroup-dormant))))
2765 ;; Some summary mode macros.
2767 (defmacro gnus-summary-article-number ()
2768 "The article number of the article on the current line.
2769 If there isn't an article number here, then we return the current
2772 (gnus-summary-skip-intangible)
2773 (or (get-text-property (point) 'gnus-number)
2774 (gnus-summary-last-subject))))
2776 (defmacro gnus-summary-article-header (&optional number)
2777 "Return the header of article NUMBER."
2778 `(gnus-data-header (gnus-data-find
2779 ,(or number '(gnus-summary-article-number)))))
2781 (defmacro gnus-summary-thread-level (&optional number)
2782 "Return the level of thread that starts with article NUMBER."
2783 `(if (and (eq gnus-summary-make-false-root 'dummy)
2784 (get-text-property (point) 'gnus-intangible))
2786 (gnus-data-level (gnus-data-find
2787 ,(or number '(gnus-summary-article-number))))))
2789 (defmacro gnus-summary-article-mark (&optional number)
2790 "Return the mark of article NUMBER."
2791 `(gnus-data-mark (gnus-data-find
2792 ,(or number '(gnus-summary-article-number)))))
2794 (defmacro gnus-summary-article-pos (&optional number)
2795 "Return the position of the line of article NUMBER."
2796 `(gnus-data-pos (gnus-data-find
2797 ,(or number '(gnus-summary-article-number)))))
2799 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2800 (defmacro gnus-summary-article-subject (&optional number)
2801 "Return current subject string or nil if nothing."
2804 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2805 '(gnus-data-header (assq (gnus-summary-article-number)
2806 gnus-newsgroup-data)))))
2809 (mail-header-subject headers))))
2811 (defmacro gnus-summary-article-score (&optional number)
2812 "Return current article score."
2813 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2814 gnus-newsgroup-scored))
2815 gnus-summary-default-score 0))
2817 (defun gnus-summary-article-children (&optional number)
2818 "Return a list of article numbers that are children of article NUMBER."
2819 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2820 (level (gnus-data-level (car data)))
2822 (while (and (setq data (cdr data))
2823 (> (setq l (gnus-data-level (car data))) level))
2824 (and (= (1+ level) l)
2825 (push (gnus-data-number (car data))
2827 (nreverse children)))
2829 (defun gnus-summary-article-parent (&optional number)
2830 "Return the article number of the parent of article NUMBER."
2831 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2832 (gnus-data-list t)))
2833 (level (gnus-data-level (car data))))
2835 () ; This is a root.
2836 ;; We search until we find an article with a level less than
2837 ;; this one. That function has to be the parent.
2838 (while (and (setq data (cdr data))
2839 (not (< (gnus-data-level (car data)) level))))
2840 (and data (gnus-data-number (car data))))))
2842 (defun gnus-unread-mark-p (mark)
2843 "Say whether MARK is the unread mark."
2844 (= mark gnus-unread-mark))
2846 (defun gnus-read-mark-p (mark)
2847 "Say whether MARK is one of the marks that mark as read.
2848 This is all marks except unread, ticked, dormant, and expirable."
2849 (not (or (= mark gnus-unread-mark)
2850 (= mark gnus-ticked-mark)
2851 (= mark gnus-dormant-mark)
2852 (= mark gnus-expirable-mark))))
2854 (defmacro gnus-article-mark (number)
2855 "Return the MARK of article NUMBER.
2856 This macro should only be used when computing the mark the \"first\"
2857 time; i.e., when generating the summary lines. After that,
2858 `gnus-summary-article-mark' should be used to examine the
2861 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-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-downloaded-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)))
3094 (gnus-summary-insert-line
3095 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3096 0 nil 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 undownloaded 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-downloaded
3182 gnus-undownloaded-mark)
3183 (gnus-newsgroup-agentized
3184 gnus-downloaded-mark)
3187 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3190 ((string-match "<[^>]+> *$" gnus-tmp-from)
3191 (let ((beg (match-beginning 0)))
3192 (or (and (string-match "^\".+\"" gnus-tmp-from)
3193 (substring gnus-tmp-from 1 (1- (match-end 0))))
3194 (substring gnus-tmp-from 0 beg))))
3195 ((string-match "(.+)" gnus-tmp-from)
3196 (substring gnus-tmp-from
3197 (1+ (match-beginning 0)) (1- (match-end 0))))
3199 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3200 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3201 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3202 (buffer-read-only nil))
3203 (when (string= gnus-tmp-name "")
3204 (setq gnus-tmp-name gnus-tmp-from))
3205 (unless (numberp gnus-tmp-lines)
3206 (setq gnus-tmp-lines -1))
3207 (if (= gnus-tmp-lines -1)
3208 (setq gnus-tmp-lines "?")
3209 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3210 (gnus-put-text-property
3212 (progn (eval gnus-summary-line-format-spec) (point))
3213 'gnus-number gnus-tmp-number)
3214 (when (gnus-visual-p 'summary-highlight 'highlight)
3216 (gnus-run-hooks 'gnus-summary-update-hook)
3219 (defun gnus-summary-update-line (&optional dont-update)
3220 "Update summary line after change."
3221 (when (and gnus-summary-default-score
3222 (not gnus-summary-inhibit-highlight))
3223 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3224 (article (gnus-summary-article-number))
3225 (score (gnus-summary-article-score article)))
3227 (if (and gnus-summary-mark-below
3228 (< (gnus-summary-article-score)
3229 gnus-summary-mark-below))
3230 ;; This article has a low score, so we mark it as read.
3231 (when (memq article gnus-newsgroup-unreads)
3232 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3233 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3234 ;; This article was previously marked as read on account
3235 ;; of a low score, but now it has risen, so we mark it as
3237 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3238 (gnus-summary-update-mark
3239 (if (or (null gnus-summary-default-score)
3240 (<= (abs (- score gnus-summary-default-score))
3241 gnus-summary-zcore-fuzz))
3243 (if (< score gnus-summary-default-score)
3244 gnus-score-below-mark gnus-score-over-mark))
3246 ;; Do visual highlighting.
3247 (when (gnus-visual-p 'summary-highlight 'highlight)
3248 (gnus-run-hooks 'gnus-summary-update-hook)))))
3250 (defvar gnus-tmp-new-adopts nil)
3252 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3253 "Return the number of articles in THREAD.
3254 This may be 0 in some cases -- if none of the articles in
3255 the thread are to be displayed."
3257 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3259 ((not (listp thread))
3261 ((and (consp thread) (cdr thread))
3264 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3267 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3270 (when (and level (zerop level) gnus-tmp-new-adopts)
3273 'gnus-summary-number-of-articles-in-thread
3274 gnus-tmp-new-adopts))))
3276 (if (> number 1) gnus-not-empty-thread-mark
3277 gnus-empty-thread-mark)
3280 (defsubst gnus-summary-line-message-size (head)
3281 "Return pretty-printed version of message size.
3282 This function is intended to be used in
3283 `gnus-summary-line-format-alist', which see."
3284 (let ((c (or (mail-header-chars head) -1)))
3285 (cond ((< c 0) "n/a") ; chars not available
3286 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3287 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3288 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3289 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3292 (defun gnus-summary-set-local-parameters (group)
3293 "Go through the local params of GROUP and set all variable specs in that list."
3294 (let ((params (gnus-group-find-parameter group))
3295 (vars '(quit-config)) ; Ignore quit-config.
3298 (setq elem (car params)
3299 params (cdr params))
3300 (and (consp elem) ; Has to be a cons.
3301 (consp (cdr elem)) ; The cdr has to be a list.
3302 (symbolp (car elem)) ; Has to be a symbol in there.
3303 (not (memq (car elem) vars))
3304 (ignore-errors ; So we set it.
3305 (push (car elem) vars)
3306 (make-local-variable (car elem))
3307 (set (car elem) (eval (nth 1 elem))))))))
3309 (defun gnus-summary-read-group (group &optional show-all no-article
3310 kill-buffer no-display backward
3312 "Start reading news in newsgroup GROUP.
3313 If SHOW-ALL is non-nil, already read articles are also listed.
3314 If NO-ARTICLE is non-nil, no article is selected initially.
3315 If NO-DISPLAY, don't generate a summary buffer."
3319 (let ((gnus-auto-select-next nil))
3320 (or (gnus-summary-read-group-1
3321 group show-all no-article
3322 kill-buffer no-display
3325 select-articles nil)))))
3326 (eq gnus-auto-select-next 'quietly))
3327 (set-buffer gnus-group-buffer)
3328 ;; The entry function called above goes to the next
3329 ;; group automatically, so we go two groups back
3330 ;; if we are searching for the previous group.
3332 (gnus-group-prev-unread-group 2))
3333 (if (not (equal group (gnus-group-group-name)))
3334 (setq group (gnus-group-group-name))
3338 (defun gnus-summary-read-group-1 (group show-all no-article
3339 kill-buffer no-display
3340 &optional select-articles)
3341 ;; Killed foreign groups can't be entered.
3342 ;; (when (and (not (gnus-group-native-p group))
3343 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3344 ;; (error "Dead non-native groups can't be entered"))
3345 (gnus-message 5 "Retrieving newsgroup: %s..."
3346 (gnus-group-decoded-name group))
3347 (let* ((new-group (gnus-summary-setup-buffer group))
3348 (quit-config (gnus-group-quit-config group))
3349 (did-select (and new-group (gnus-select-newsgroup
3350 group show-all select-articles))))
3352 ;; This summary buffer exists already, so we just select it.
3354 (gnus-set-global-variables)
3356 (gnus-kill-or-deaden-summary kill-buffer))
3357 (gnus-configure-windows 'summary 'force)
3358 (gnus-set-mode-line 'summary)
3359 (gnus-summary-position-point)
3362 ;; We couldn't select this group.
3364 (when (and (eq major-mode 'gnus-summary-mode)
3365 (not (equal (current-buffer) kill-buffer)))
3366 (kill-buffer (current-buffer))
3367 (if (not quit-config)
3369 ;; Update the info -- marks might need to be removed,
3371 (gnus-summary-update-info)
3372 (set-buffer gnus-group-buffer)
3373 (gnus-group-jump-to-group group)
3374 (gnus-group-next-unread-group 1))
3375 (gnus-handle-ephemeral-exit quit-config)))
3376 (let ((grpinfo (gnus-get-info group)))
3377 (if (null (gnus-info-read grpinfo))
3378 (gnus-message 3 "Group %s contains no messages"
3379 (gnus-group-decoded-name group))
3380 (gnus-message 3 "Can't select group")))
3382 ;; The user did a `C-g' while prompting for number of articles,
3383 ;; so we exit this group.
3384 ((eq did-select 'quit)
3385 (and (eq major-mode 'gnus-summary-mode)
3386 (not (equal (current-buffer) kill-buffer))
3387 (kill-buffer (current-buffer)))
3389 (gnus-kill-or-deaden-summary kill-buffer))
3390 (if (not quit-config)
3392 (set-buffer gnus-group-buffer)
3393 (gnus-group-jump-to-group group)
3394 (gnus-group-next-unread-group 1)
3395 (gnus-configure-windows 'group 'force))
3396 (gnus-handle-ephemeral-exit quit-config))
3397 ;; Finally signal the quit.
3399 ;; The group was successfully selected.
3401 (gnus-set-global-variables)
3402 ;; Save the active value in effect when the group was entered.
3403 (setq gnus-newsgroup-active
3405 (gnus-active gnus-newsgroup-name)))
3406 ;; You can change the summary buffer in some way with this hook.
3407 (gnus-run-hooks 'gnus-select-group-hook)
3408 (gnus-update-format-specifications
3409 nil 'summary 'summary-mode 'summary-dummy)
3410 (gnus-update-summary-mark-positions)
3411 ;; Do score processing.
3412 (when gnus-use-scoring
3413 (gnus-possibly-score-headers))
3414 ;; Check whether to fill in the gaps in the threads.
3415 (when gnus-build-sparse-threads
3416 (gnus-build-sparse-threads))
3417 ;; Find the initial limit.
3418 (if gnus-show-threads
3420 (let ((gnus-newsgroup-dormant nil))
3421 (gnus-summary-initial-limit show-all))
3422 (gnus-summary-initial-limit show-all))
3423 ;; When unthreaded, all articles are always shown.
3424 (setq gnus-newsgroup-limit
3426 (lambda (header) (mail-header-number header))
3427 gnus-newsgroup-headers)))
3428 ;; Generate the summary buffer.
3430 (gnus-summary-prepare))
3431 (when gnus-use-trees
3432 (gnus-tree-open group)
3433 (setq gnus-summary-highlight-line-function
3434 'gnus-tree-highlight-article))
3435 ;; If the summary buffer is empty, but there are some low-scored
3436 ;; articles or some excluded dormants, we include these in the
3438 (when (and (zerop (buffer-size))
3440 (cond (gnus-newsgroup-dormant
3441 (gnus-summary-limit-include-dormant))
3442 ((and gnus-newsgroup-scored show-all)
3443 (gnus-summary-limit-include-expunged t))))
3444 ;; Function `gnus-apply-kill-file' must be called in this hook.
3445 (gnus-run-hooks 'gnus-apply-kill-hook)
3446 (if (and (zerop (buffer-size))
3449 ;; This newsgroup is empty.
3450 (gnus-summary-catchup-and-exit nil t)
3451 (gnus-message 6 "No unread news")
3453 (gnus-kill-or-deaden-summary kill-buffer))
3454 ;; Return nil from this function.
3456 ;; Hide conversation thread subtrees. We cannot do this in
3457 ;; gnus-summary-prepare-hook since kill processing may not
3458 ;; work with hidden articles.
3459 (gnus-summary-maybe-hide-threads)
3461 (gnus-kill-or-deaden-summary kill-buffer))
3462 (gnus-summary-auto-select-subject)
3463 ;; Show first unread article if requested.
3464 (if (and (not no-article)
3466 gnus-newsgroup-unreads
3467 gnus-auto-select-first)
3469 (gnus-configure-windows 'summary)
3470 (let ((art (gnus-summary-article-number)))
3471 (unless (or (memq art gnus-newsgroup-undownloaded)
3472 (memq art gnus-newsgroup-downloadable))
3473 (gnus-summary-goto-article art))))
3474 ;; Don't select any articles.
3475 (gnus-summary-position-point)
3476 (gnus-configure-windows 'summary 'force)
3477 (gnus-set-mode-line 'summary))
3478 (when (get-buffer-window gnus-group-buffer t)
3479 ;; Gotta use windows, because recenter does weird stuff if
3480 ;; the current buffer ain't the displayed window.
3481 (let ((owin (selected-window)))
3482 (select-window (get-buffer-window gnus-group-buffer t))
3483 (when (gnus-group-goto-group group)
3485 (select-window owin)))
3486 ;; Mark this buffer as "prepared".
3487 (setq gnus-newsgroup-prepared t)
3488 (gnus-run-hooks 'gnus-summary-prepared-hook)
3491 (defun gnus-summary-auto-select-subject ()
3492 "Select the subject line on initial group entry."
3493 (goto-char (point-min))
3495 ((eq gnus-auto-select-subject 'best)
3496 (gnus-summary-best-unread-subject))
3497 ((eq gnus-auto-select-subject 'unread)
3498 (gnus-summary-first-unread-subject))
3499 ((eq gnus-auto-select-subject 'unseen)
3500 (gnus-summary-first-unseen-subject))
3501 ((eq gnus-auto-select-subject 'unseen-or-unread)
3502 (gnus-summary-first-unseen-or-unread-subject))
3503 ((eq gnus-auto-select-subject 'first)
3506 ((gnus-functionp gnus-auto-select-subject)
3507 (funcall gnus-auto-select-subject))))
3509 (defun gnus-summary-prepare ()
3510 "Generate the summary buffer."
3512 (let ((buffer-read-only nil))
3514 (setq gnus-newsgroup-data nil
3515 gnus-newsgroup-data-reverse nil)
3516 (gnus-run-hooks 'gnus-summary-generate-hook)
3517 ;; Generate the buffer, either with threads or without.
3518 (when gnus-newsgroup-headers
3519 (gnus-summary-prepare-threads
3520 (if gnus-show-threads
3521 (gnus-sort-gathered-threads
3522 (funcall gnus-summary-thread-gathering-function
3524 (gnus-cut-threads (gnus-make-threads)))))
3525 ;; Unthreaded display.
3526 (gnus-sort-articles gnus-newsgroup-headers))))
3527 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3528 ;; Call hooks for modifying summary buffer.
3529 (goto-char (point-min))
3530 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3532 (defsubst gnus-general-simplify-subject (subject)
3533 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3536 ;; Truncate the subject.
3537 (gnus-simplify-subject-functions
3538 (gnus-map-function gnus-simplify-subject-functions subject))
3539 ((numberp gnus-summary-gather-subject-limit)
3540 (setq subject (gnus-simplify-subject-re subject))
3541 (if (> (length subject) gnus-summary-gather-subject-limit)
3542 (substring subject 0 gnus-summary-gather-subject-limit)
3544 ;; Fuzzily simplify it.
3545 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3546 (gnus-simplify-subject-fuzzy subject))
3547 ;; Just remove the leading "Re:".
3549 (gnus-simplify-subject-re subject))))
3551 (if (and gnus-summary-gather-exclude-subject
3552 (string-match gnus-summary-gather-exclude-subject subject))
3553 nil ; This article shouldn't be gathered
3556 (defun gnus-summary-simplify-subject-query ()
3557 "Query where the respool algorithm would put this article."
3559 (gnus-summary-select-article)
3560 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3562 (defun gnus-gather-threads-by-subject (threads)
3563 "Gather threads by looking at Subject headers."
3564 (if (not gnus-summary-make-false-root)
3566 (let ((hashtb (gnus-make-hashtable 1024))
3569 subject hthread whole-subject)
3571 (setq subject (gnus-general-simplify-subject
3572 (setq whole-subject (mail-header-subject
3575 (if (setq hthread (gnus-gethash subject hashtb))
3577 ;; We enter a dummy root into the thread, if we
3578 ;; haven't done that already.
3579 (unless (stringp (caar hthread))
3580 (setcar hthread (list whole-subject (car hthread))))
3581 ;; We add this new gathered thread to this gathered
3583 (setcdr (car hthread)
3584 (nconc (cdar hthread) (list (car threads))))
3585 ;; Remove it from the list of threads.
3586 (setcdr prev (cdr threads))
3587 (setq threads prev))
3588 ;; Enter this thread into the hash table.
3589 (gnus-sethash subject threads hashtb)))
3591 (setq threads (cdr threads)))
3594 (defun gnus-gather-threads-by-references (threads)
3595 "Gather threads by looking at References headers."
3596 (let ((idhashtb (gnus-make-hashtable 1024))
3597 (thhashtb (gnus-make-hashtable 1024))
3600 ids references id gthread gid entered ref)
3602 (when (setq references (mail-header-references (caar threads)))
3603 (setq id (mail-header-id (caar threads))
3604 ids (inline (gnus-split-references references))
3606 (while (setq ref (pop ids))
3607 (setq ids (delete ref ids))
3608 (if (not (setq gid (gnus-gethash ref idhashtb)))
3610 (gnus-sethash ref id idhashtb)
3611 (gnus-sethash id threads thhashtb))
3612 (setq gthread (gnus-gethash gid thhashtb))
3614 ;; We enter a dummy root into the thread, if we
3615 ;; haven't done that already.
3616 (unless (stringp (caar gthread))
3617 (setcar gthread (list (mail-header-subject (caar gthread))
3619 ;; We add this new gathered thread to this gathered
3621 (setcdr (car gthread)
3622 (nconc (cdar gthread) (list (car threads)))))
3623 ;; Add it into the thread hash table.
3624 (gnus-sethash id gthread thhashtb)
3626 ;; Remove it from the list of threads.
3627 (setcdr prev (cdr threads))
3628 (setq threads prev))))
3630 (setq threads (cdr threads)))
3633 (defun gnus-sort-gathered-threads (threads)
3634 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3635 (let ((result threads))
3637 (when (stringp (caar threads))
3638 (setcdr (car threads)
3639 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3640 (setq threads (cdr threads)))
3643 (defun gnus-thread-loop-p (root thread)
3644 "Say whether ROOT is in THREAD."
3645 (let ((stack (list thread))
3648 (while (setq thread (pop stack))
3649 (setq th (cdr thread))
3651 (not (eq (caar th) root)))
3654 ;; We have found a loop.
3656 (setcdr thread (delq (car th) (cdr thread)))
3657 (if (boundp (setq ref-dep (intern "none"
3658 gnus-newsgroup-dependencies)))
3659 (setcdr (symbol-value ref-dep)
3660 (nconc (cdr (symbol-value ref-dep))
3662 (set ref-dep (list nil (car th))))
3665 ;; Push all the subthreads onto the stack.
3666 (push (cdr thread) stack)))
3669 (defun gnus-make-threads ()
3670 "Go through the dependency hashtb and find the roots. Return all threads."
3672 (while (catch 'infloop
3675 ;; Deal with self-referencing References loops.
3676 (when (and (car (symbol-value refs))
3683 (car (symbol-value refs)) thread))
3684 (cdr (symbol-value refs)))))))
3687 (unless (car (symbol-value refs))
3688 ;; These threads do not refer back to any other
3689 ;; articles, so they're roots.
3690 (setq threads (append (cdr (symbol-value refs)) threads))))
3691 gnus-newsgroup-dependencies)))
3694 ;; Build the thread tree.
3695 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3696 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3698 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3699 if it was already present.
3701 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3702 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3703 Message-IDs will be renamed to a unique Message-ID before being
3706 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3707 (let* ((id (mail-header-id header))
3708 (id-dep (and id (intern id dependencies)))
3709 parent-id ref ref-dep ref-header replaced)
3710 ;; Enter this `header' in the `dependencies' table.
3714 ;; The first two cases do the normal part: enter a new `header'
3715 ;; in the `dependencies' table.
3716 ((not (boundp id-dep))
3717 (set id-dep (list header)))
3718 ((null (car (symbol-value id-dep)))
3719 (setcar (symbol-value id-dep) header))
3721 ;; From here the `header' was already present in the
3722 ;; `dependencies' table.
3724 ;; Overrides an existing entry;
3725 ;; just set the header part of the entry.
3726 (setcar (symbol-value id-dep) header)
3729 ;; Renames the existing `header' to a unique Message-ID.
3730 ((not gnus-summary-ignore-duplicates)
3731 ;; An article with this Message-ID has already been seen.
3732 ;; We rename the Message-ID.
3733 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3735 (mail-header-set-id header id))
3737 ;; The last case ignores an existing entry, except it adds any
3738 ;; additional Xrefs (in case the two articles came from different
3740 ;; Also sets `header' to `nil' meaning that the `dependencies'
3741 ;; table was *not* modified.
3743 (mail-header-set-xref
3744 (car (symbol-value id-dep))
3745 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3747 (or (mail-header-xref header) "")))
3750 (when (and header (not replaced))
3751 ;; First check that we are not creating a References loop.
3752 (setq parent-id (gnus-parent-id (mail-header-references header)))
3753 (setq ref parent-id)
3755 (setq ref-dep (intern-soft ref dependencies))
3757 (setq ref-header (car (symbol-value ref-dep))))
3758 (if (string= id ref)
3759 ;; Yuk! This is a reference loop. Make the article be a
3762 (mail-header-set-references (car (symbol-value id-dep)) "none")
3764 (setq parent-id nil))
3765 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3766 (setq ref-dep (intern (or parent-id "none") dependencies))
3767 (if (boundp ref-dep)
3768 (setcdr (symbol-value ref-dep)
3769 (nconc (cdr (symbol-value ref-dep))
3770 (list (symbol-value id-dep))))
3771 (set ref-dep (list nil (symbol-value id-dep)))))
3774 (defun gnus-extract-message-id-from-in-reply-to (string)
3775 (if (string-match "<[^>]+>" string)
3776 (substring string (match-beginning 0) (match-end 0))
3779 (defun gnus-build-sparse-threads ()
3780 (let ((headers gnus-newsgroup-headers)
3781 (mail-parse-charset gnus-newsgroup-charset)
3782 (gnus-summary-ignore-duplicates t)
3783 header references generation relations
3784 subject child end new-child date)
3785 ;; First we create an alist of generations/relations, where
3786 ;; generations is how much we trust the relation, and the relation
3788 (gnus-message 7 "Making sparse threads...")
3790 (nnheader-set-temp-buffer " *gnus sparse threads*")
3791 (while (setq header (pop headers))
3792 (when (and (setq references (mail-header-references header))
3793 (not (string= references "")))
3795 (setq child (mail-header-id header)
3796 subject (mail-header-subject header)
3797 date (mail-header-date header)
3799 (while (search-backward ">" nil t)
3800 (setq end (1+ (point)))
3801 (when (search-backward "<" nil t)
3802 (setq new-child (buffer-substring (point) end))
3803 (push (list (incf generation)
3804 child (setq child new-child)
3808 (push (list (1+ generation) child nil subject) relations))
3810 (kill-buffer (current-buffer)))
3811 ;; Sort over trustworthiness.
3814 (when (gnus-dependencies-add-header
3815 (make-full-mail-header
3816 gnus-reffed-article-number
3817 (nth 3 relation) "" (or (nth 4 relation) "")
3819 (or (nth 2 relation) "") 0 0 "")
3820 gnus-newsgroup-dependencies nil)
3821 (push gnus-reffed-article-number gnus-newsgroup-limit)
3822 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3823 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3824 gnus-newsgroup-reads)
3825 (decf gnus-reffed-article-number)))
3826 (sort relations 'car-less-than-car))
3827 (gnus-message 7 "Making sparse threads...done")))
3829 (defun gnus-build-old-threads ()
3830 ;; Look at all the articles that refer back to old articles, and
3831 ;; fetch the headers for the articles that aren't there. This will
3832 ;; build complete threads - if the roots haven't been expired by the
3834 (let ((mail-parse-charset gnus-newsgroup-charset)
3838 (when (not (car (symbol-value refs)))
3839 (setq heads (cdr (symbol-value refs)))
3841 (if (memq (mail-header-number (caar heads))
3842 gnus-newsgroup-dormant)
3843 (setq heads (cdr heads))
3844 (setq id (symbol-name refs))
3845 (while (and (setq id (gnus-build-get-header id))
3846 (not (car (gnus-id-to-thread id)))))
3847 (setq heads nil)))))
3848 gnus-newsgroup-dependencies)))
3850 ;; This function has to be called with point after the article number
3851 ;; on the beginning of the line.
3852 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3853 (let ((eol (gnus-point-at-eol))
3854 (buffer (current-buffer))
3855 header references in-reply-to)
3857 ;; overview: [num subject from date id refs chars lines misc]
3860 (narrow-to-region (point) eol)
3865 (make-full-mail-header
3867 (condition-case () ; subject
3868 (funcall gnus-decode-encoded-word-function
3869 (setq x (nnheader-nov-field)))
3871 (condition-case () ; from
3872 (funcall gnus-decode-encoded-word-function
3873 (setq x (nnheader-nov-field)))
3875 (nnheader-nov-field) ; date
3876 (nnheader-nov-read-message-id) ; id
3877 (setq references (nnheader-nov-field)) ; refs
3878 (nnheader-nov-read-integer) ; chars
3879 (nnheader-nov-read-integer) ; lines
3881 (if (looking-at "Xref: ")
3882 (goto-char (match-end 0)))
3883 (nnheader-nov-field)) ; Xref
3884 (nnheader-nov-parse-extra)))) ; extra
3888 (when (and (string= references "")
3889 (setq in-reply-to (mail-header-extra header))
3890 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3891 (mail-header-set-references
3892 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3894 (when gnus-alter-header-function
3895 (funcall gnus-alter-header-function header))
3896 (gnus-dependencies-add-header header dependencies force-new)))
3898 (defun gnus-build-get-header (id)
3899 "Look through the buffer of NOV lines and find the header to ID.
3900 Enter this line into the dependencies hash table, and return
3901 the id of the parent article (if any)."
3902 (let ((deps gnus-newsgroup-dependencies)
3906 (set-buffer nntp-server-buffer)
3907 (let ((case-fold-search nil))
3908 (goto-char (point-min))
3909 (while (and (not found)
3910 (search-forward id nil t))
3912 (setq found (looking-at
3913 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3914 (regexp-quote id))))
3915 (or found (beginning-of-line 2)))
3919 (setq header (gnus-nov-parse-line
3920 (read (current-buffer)) deps))
3921 (gnus-parent-id (mail-header-references header))))))
3923 (let ((number (mail-header-number header)))
3924 (push number gnus-newsgroup-limit)
3925 (push header gnus-newsgroup-headers)
3926 (if (memq number gnus-newsgroup-unselected)
3928 (setq gnus-newsgroup-unreads
3929 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3931 (setq gnus-newsgroup-unselected
3932 (delq number gnus-newsgroup-unselected)))
3933 (push number gnus-newsgroup-ancient)))))))
3935 (defun gnus-build-all-threads ()
3936 "Read all the headers."
3937 (let ((gnus-summary-ignore-duplicates t)
3938 (mail-parse-charset gnus-newsgroup-charset)
3939 (dependencies gnus-newsgroup-dependencies)
3942 (set-buffer nntp-server-buffer)
3943 (let ((case-fold-search nil))
3944 (goto-char (point-min))
3947 (setq article (read (current-buffer))
3948 header (gnus-nov-parse-line article dependencies)))
3951 (set-buffer gnus-summary-buffer)
3952 (push header gnus-newsgroup-headers)
3953 (if (memq (setq article (mail-header-number header))
3954 gnus-newsgroup-unselected)
3956 (setq gnus-newsgroup-unreads
3957 (gnus-add-to-sorted-list
3958 gnus-newsgroup-unreads article))
3959 (setq gnus-newsgroup-unselected
3960 (delq article gnus-newsgroup-unselected)))
3961 (push article gnus-newsgroup-ancient)))
3962 (forward-line 1)))))))
3964 (defun gnus-summary-update-article-line (article header)
3965 "Update the line for ARTICLE using HEADERS."
3966 (let* ((id (mail-header-id header))
3967 (thread (gnus-id-to-thread id)))
3969 (error "Article in no thread"))
3970 ;; Update the thread.
3971 (setcar thread header)
3972 (gnus-summary-goto-subject article)
3973 (let* ((datal (gnus-data-find-list article))
3975 (length (when (cdr datal)
3976 (- (gnus-data-pos data)
3977 (gnus-data-pos (cadr datal)))))
3978 (buffer-read-only nil)
3979 (level (gnus-summary-thread-level)))
3981 (gnus-summary-insert-line
3983 (memq article gnus-newsgroup-undownloaded)
3984 (gnus-article-mark article)
3985 (memq article gnus-newsgroup-replied)
3986 (memq article gnus-newsgroup-expirable)
3987 ;; Only insert the Subject string when it's different
3988 ;; from the previous Subject string.
3993 (mail-header-subject
3996 (gnus-data-find-list
3998 (gnus-data-list t)))))
3999 ;; Error on the side of excessive subjects.
4001 (mail-header-subject header)))
4003 (mail-header-subject header))
4004 nil (cdr (assq article gnus-newsgroup-scored))
4005 (memq article gnus-newsgroup-processable))
4007 (gnus-data-update-list
4008 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4010 (defun gnus-summary-update-article (article &optional iheader)
4011 "Update ARTICLE in the summary buffer."
4012 (set-buffer gnus-summary-buffer)
4013 (let* ((header (gnus-summary-article-header article))
4014 (id (mail-header-id header))
4015 (data (gnus-data-find article))
4016 (thread (gnus-id-to-thread id))
4017 (references (mail-header-references header))
4021 (when (and references
4022 (not (equal "" references)))
4025 (buffer-read-only nil)
4031 (delq thread parent)))
4032 (if (gnus-summary-insert-subject id header)
4033 ;; Set the (possibly) new article number in the data structure.
4034 (gnus-data-set-number data (gnus-id-to-article id))
4038 (defun gnus-rebuild-thread (id &optional line)
4039 "Rebuild the thread containing ID.
4040 If LINE, insert the rebuilt thread starting on line LINE."
4041 (let ((buffer-read-only nil)
4042 old-pos current thread data)
4043 (if (not gnus-show-threads)
4044 (setq thread (list (car (gnus-id-to-thread id))))
4045 ;; Get the thread this article is part of.
4046 (setq thread (gnus-remove-thread id)))
4047 (setq old-pos (gnus-point-at-bol))
4048 (setq current (save-excursion
4049 (and (re-search-backward "[\r\n]" nil t)
4050 (gnus-summary-article-number))))
4051 ;; If this is a gathered thread, we have to go some re-gathering.
4052 (when (stringp (car thread))
4053 (let ((subject (car thread))
4055 (setq thread (cdr thread))
4057 (unless (memq (setq thr (gnus-id-to-thread
4059 (mail-header-id (caar thread)))))
4062 (setq thread (cdr thread)))
4063 ;; We now have all (unique) roots.
4064 (if (= (length roots) 1)
4065 ;; All the loose roots are now one solid root.
4066 (setq thread (car roots))
4067 (setq thread (cons subject (gnus-sort-threads roots))))))
4069 ;; We then insert this thread into the summary buffer.
4071 (goto-char (point-min))
4072 (forward-line (1- line)))
4073 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4074 (if gnus-show-threads
4075 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4076 (gnus-summary-prepare-unthreaded thread))
4077 (setq data (nreverse gnus-newsgroup-data))
4078 (setq threads gnus-newsgroup-threads))
4079 ;; We splice the new data into the data structure.
4080 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4081 ;;!!! then we want to insert at the beginning of the buffer.
4082 ;;!!! That happens to be true with Gnus now, but that may
4083 ;;!!! change in the future. Perhaps.
4084 (gnus-data-enter-list
4085 (if line nil current) data (- (point) old-pos))
4086 (setq gnus-newsgroup-threads
4087 (nconc threads gnus-newsgroup-threads))
4088 (gnus-data-compute-positions))))
4090 (defun gnus-number-to-header (number)
4091 "Return the header for article NUMBER."
4092 (let ((headers gnus-newsgroup-headers))
4094 (not (= number (mail-header-number (car headers)))))
4099 (defun gnus-parent-headers (in-headers &optional generation)
4100 "Return the headers of the GENERATIONeth parent of HEADERS."
4102 (setq generation 1))
4104 (headers in-headers)
4107 (not (zerop generation))
4108 (setq references (mail-header-references headers)))
4109 (setq headers (if (and references
4110 (setq parent (gnus-parent-id references)))
4111 (car (gnus-id-to-thread parent))
4114 (and (not (eq headers in-headers))
4117 (defun gnus-id-to-thread (id)
4118 "Return the (sub-)thread where ID appears."
4119 (gnus-gethash id gnus-newsgroup-dependencies))
4121 (defun gnus-id-to-article (id)
4122 "Return the article number of ID."
4123 (let ((thread (gnus-id-to-thread id)))
4126 (mail-header-number (car thread)))))
4128 (defun gnus-id-to-header (id)
4129 "Return the article headers of ID."
4130 (car (gnus-id-to-thread id)))
4132 (defun gnus-article-displayed-root-p (article)
4133 "Say whether ARTICLE is a root(ish) article."
4134 (let ((level (gnus-summary-thread-level article))
4135 (refs (mail-header-references (gnus-summary-article-header article)))
4141 ((null (gnus-parent-id refs)) t)
4143 (null (setq particle (gnus-id-to-article
4144 (gnus-parent-id refs))))
4145 (null (gnus-summary-thread-level particle)))))))
4147 (defun gnus-root-id (id)
4148 "Return the id of the root of the thread where ID appears."
4150 (while (and id (setq prev (car (gnus-id-to-thread id))))
4152 id (gnus-parent-id (mail-header-references prev))))
4155 (defun gnus-articles-in-thread (thread)
4156 "Return the list of articles in THREAD."
4157 (cons (mail-header-number (car thread))
4158 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4160 (defun gnus-remove-thread (id &optional dont-remove)
4161 "Remove the thread that has ID in it."
4162 (let (headers thread last-id)
4163 ;; First go up in this thread until we find the root.
4164 (setq last-id (gnus-root-id id)
4165 headers (message-flatten-list (gnus-id-to-thread last-id)))
4166 ;; We have now found the real root of this thread. It might have
4167 ;; been gathered into some loose thread, so we have to search
4168 ;; through the threads to find the thread we wanted.
4169 (let ((threads gnus-newsgroup-threads)
4172 (setq sub (car threads))
4173 (if (stringp (car sub))
4174 ;; This is a gathered thread, so we look at the roots
4175 ;; below it to find whether this article is in this
4178 (setq sub (cdr sub))
4180 (when (member (caar sub) headers)
4181 (setq thread (car threads)
4184 (setq sub (cdr sub))))
4185 ;; It's an ordinary thread, so we check it.
4186 (when (eq (car sub) (car headers))
4189 (setq threads (cdr threads)))
4190 ;; If this article is in no thread, then it's a root.
4193 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4194 (setq thread (gnus-id-to-thread last-id)))
4197 thread ; We return this thread.
4199 (if (stringp (car thread))
4201 ;; If we use dummy roots, then we have to remove the
4202 ;; dummy root as well.
4203 (when (eq gnus-summary-make-false-root 'dummy)
4204 ;; We go to the dummy root by going to
4205 ;; the first sub-"thread", and then one line up.
4206 (gnus-summary-goto-article
4207 (mail-header-number (caadr thread)))
4210 (gnus-data-compute-positions))
4211 (setq thread (cdr thread))
4213 (gnus-remove-thread-1 (car thread))
4214 (setq thread (cdr thread))))
4215 (gnus-remove-thread-1 thread))))))))
4217 (defun gnus-remove-thread-1 (thread)
4218 "Remove the thread THREAD recursively."
4219 (let ((number (mail-header-number (pop thread)))
4221 (setq thread (reverse thread))
4223 (gnus-remove-thread-1 (pop thread)))
4224 (when (setq d (gnus-data-find number))
4225 (goto-char (gnus-data-pos d))
4226 (gnus-summary-show-thread)
4229 (- (gnus-point-at-bol)
4231 (1+ (gnus-point-at-eol))
4232 (gnus-delete-line)))))))
4234 (defun gnus-sort-threads-1 (threads func)
4235 (sort (mapcar (lambda (thread)
4238 (gnus-sort-threads-1 (cdr thread) func))))
4241 (defun gnus-sort-threads (threads)
4243 (if (not gnus-thread-sort-functions)
4245 (gnus-message 8 "Sorting threads...")
4246 (let ((max-lisp-eval-depth 5000))
4247 (prog1 (gnus-sort-threads-1
4249 (gnus-make-sort-function gnus-thread-sort-functions))
4250 (gnus-message 8 "Sorting threads...done")))))
4252 (defun gnus-sort-articles (articles)
4254 (when gnus-article-sort-functions
4255 (gnus-message 7 "Sorting articles...")
4257 (setq gnus-newsgroup-headers
4258 (sort articles (gnus-make-sort-function
4259 gnus-article-sort-functions)))
4260 (gnus-message 7 "Sorting articles...done"))))
4262 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4263 (defmacro gnus-thread-header (thread)
4264 "Return header of first article in THREAD.
4265 Note that THREAD must never, ever be anything else than a variable -
4266 using some other form will lead to serious barfage."
4267 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4268 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4269 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4272 (defsubst gnus-article-sort-by-number (h1 h2)
4273 "Sort articles by article number."
4274 (< (mail-header-number h1)
4275 (mail-header-number h2)))
4277 (defun gnus-thread-sort-by-number (h1 h2)
4278 "Sort threads by root article number."
4279 (gnus-article-sort-by-number
4280 (gnus-thread-header h1) (gnus-thread-header h2)))
4282 (defsubst gnus-article-sort-by-random (h1 h2)
4283 "Sort articles by article number."
4286 (defun gnus-thread-sort-by-random (h1 h2)
4287 "Sort threads by root article number."
4288 (gnus-article-sort-by-random
4289 (gnus-thread-header h1) (gnus-thread-header h2)))
4291 (defsubst gnus-article-sort-by-lines (h1 h2)
4292 "Sort articles by article Lines header."
4293 (< (mail-header-lines h1)
4294 (mail-header-lines h2)))
4296 (defun gnus-thread-sort-by-lines (h1 h2)
4297 "Sort threads by root article Lines header."
4298 (gnus-article-sort-by-lines
4299 (gnus-thread-header h1) (gnus-thread-header h2)))
4301 (defsubst gnus-article-sort-by-chars (h1 h2)
4302 "Sort articles by octet length."
4303 (< (mail-header-chars h1)
4304 (mail-header-chars h2)))
4306 (defun gnus-thread-sort-by-chars (h1 h2)
4307 "Sort threads by root article octet length."
4308 (gnus-article-sort-by-chars
4309 (gnus-thread-header h1) (gnus-thread-header h2)))
4311 (defsubst gnus-article-sort-by-author (h1 h2)
4312 "Sort articles by root author."
4314 (let ((extract (funcall
4315 gnus-extract-address-components
4316 (mail-header-from h1))))
4317 (or (car extract) (cadr extract) ""))
4318 (let ((extract (funcall
4319 gnus-extract-address-components
4320 (mail-header-from h2))))
4321 (or (car extract) (cadr extract) ""))))
4323 (defun gnus-thread-sort-by-author (h1 h2)
4324 "Sort threads by root author."
4325 (gnus-article-sort-by-author
4326 (gnus-thread-header h1) (gnus-thread-header h2)))
4328 (defsubst gnus-article-sort-by-subject (h1 h2)
4329 "Sort articles by root subject."
4331 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4332 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4334 (defun gnus-thread-sort-by-subject (h1 h2)
4335 "Sort threads by root subject."
4336 (gnus-article-sort-by-subject
4337 (gnus-thread-header h1) (gnus-thread-header h2)))
4339 (defsubst gnus-article-sort-by-date (h1 h2)
4340 "Sort articles by root article date."
4342 (gnus-date-get-time (mail-header-date h1))
4343 (gnus-date-get-time (mail-header-date h2))))
4345 (defun gnus-thread-sort-by-date (h1 h2)
4346 "Sort threads by root article date."
4347 (gnus-article-sort-by-date
4348 (gnus-thread-header h1) (gnus-thread-header h2)))
4350 (defsubst gnus-article-sort-by-score (h1 h2)
4351 "Sort articles by root article score.
4352 Unscored articles will be counted as having a score of zero."
4353 (> (or (cdr (assq (mail-header-number h1)
4354 gnus-newsgroup-scored))
4355 gnus-summary-default-score 0)
4356 (or (cdr (assq (mail-header-number h2)
4357 gnus-newsgroup-scored))
4358 gnus-summary-default-score 0)))
4360 (defun gnus-thread-sort-by-score (h1 h2)
4361 "Sort threads by root article score."
4362 (gnus-article-sort-by-score
4363 (gnus-thread-header h1) (gnus-thread-header h2)))
4365 (defun gnus-thread-sort-by-total-score (h1 h2)
4366 "Sort threads by the sum of all scores in the thread.
4367 Unscored articles will be counted as having a score of zero."
4368 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4370 (defun gnus-thread-total-score (thread)
4371 ;; This function find the total score of THREAD.
4376 (if (stringp (car thread))
4377 (apply gnus-thread-score-function 0
4378 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4379 (gnus-thread-total-score-1 thread)))
4381 (gnus-thread-total-score-1 (list thread)))))
4383 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4384 "Sort threads such that the thread with the most recently arrived article comes first."
4385 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4387 (defun gnus-thread-highest-number (thread)
4388 "Return the highest article number in THREAD."
4389 (apply 'max (mapcar (lambda (header)
4390 (mail-header-number header))
4391 (message-flatten-list thread))))
4393 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4394 "Sort threads such that the thread with the most recently dated article comes first."
4395 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4397 (defun gnus-thread-latest-date (thread)
4398 "Return the highest article date in THREAD."
4399 (let ((previous-time 0))
4404 (mail-header-parse-date
4406 (mail-header-date header)
4407 (error previous-time))))))
4409 (message-flatten-list thread)
4411 (< (mail-header-number h1)
4412 (mail-header-number h2))))))))
4414 (defun gnus-thread-total-score-1 (root)
4415 ;; This function find the total score of the thread below ROOT.
4416 (setq root (car root))
4417 (apply gnus-thread-score-function
4419 (mapcar 'gnus-thread-total-score
4420 (cdr (gnus-id-to-thread (mail-header-id root))))
4421 (when (> (mail-header-number root) 0)
4422 (list (or (cdr (assq (mail-header-number root)
4423 gnus-newsgroup-scored))
4424 gnus-summary-default-score 0))))
4425 (list gnus-summary-default-score)
4428 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4429 (defvar gnus-tmp-prev-subject nil)
4430 (defvar gnus-tmp-false-parent nil)
4431 (defvar gnus-tmp-root-expunged nil)
4432 (defvar gnus-tmp-dummy-line nil)
4434 (eval-when-compile (defvar gnus-tmp-header))
4435 (defun gnus-extra-header (type &optional header)
4436 "Return the extra header of TYPE."
4437 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4440 (defvar gnus-tmp-thread-tree-header-string "")
4442 (defcustom gnus-sum-thread-tree-root "> "
4443 "With %B spec, used for the root of a thread.
4444 If nil, use subject instead."
4446 :group 'gnus-thread)
4447 (defcustom gnus-sum-thread-tree-single-indent ""
4448 "With %B spec, used for a thread with just one message.
4449 If nil, use subject instead."
4451 :group 'gnus-thread)
4452 (defcustom gnus-sum-thread-tree-vertical "| "
4453 "With %B spec, used for drawing a vertical line."
4455 :group 'gnus-thread)
4456 (defcustom gnus-sum-thread-tree-indent " "
4457 "With %B spec, used for indenting."
4459 :group 'gnus-thread)
4460 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4461 "With %B spec, used for a leaf with brothers."
4463 :group 'gnus-thread)
4464 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4465 "With %B spec, used for a leaf without brothers."
4467 :group 'gnus-thread)
4469 (defun gnus-summary-prepare-threads (threads)
4470 "Prepare summary buffer from THREADS and indentation LEVEL.
4471 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4472 or a straight list of headers."
4473 (gnus-message 7 "Generating summary...")
4475 (setq gnus-newsgroup-threads threads)
4478 (let ((gnus-tmp-level 0)
4479 (default-score (or gnus-summary-default-score 0))
4480 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4481 thread number subject stack state gnus-tmp-gathered beg-match
4482 new-roots gnus-tmp-new-adopts thread-end simp-subject
4483 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4484 gnus-tmp-replied gnus-tmp-subject-or-nil
4485 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4486 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4487 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4490 (setq gnus-tmp-prev-subject nil)
4492 (if (vectorp (car threads))
4493 ;; If this is a straight (sic) list of headers, then a
4494 ;; threaded summary display isn't required, so we just create
4495 ;; an unthreaded one.
4496 (gnus-summary-prepare-unthreaded threads)
4498 ;; Do the threaded display.
4500 (while (or threads stack gnus-tmp-new-adopts new-roots)
4502 (if (and (= gnus-tmp-level 0)
4505 (not gnus-tmp-false-parent)
4506 (or gnus-tmp-new-adopts new-roots))
4507 (if gnus-tmp-new-adopts
4508 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4509 thread (list (car gnus-tmp-new-adopts))
4510 gnus-tmp-header (caar thread)
4511 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4513 (setq thread (list (car new-roots))
4514 gnus-tmp-header (caar thread)
4515 new-roots (cdr new-roots))))
4518 ;; If there are some threads, we do them before the
4519 ;; threads on the stack.
4520 (setq thread threads
4521 gnus-tmp-header (caar thread))
4522 ;; There were no current threads, so we pop something off
4524 (setq state (car stack)
4525 gnus-tmp-level (car state)
4526 tree-stack (cadr state)
4527 thread (caddr state)
4529 gnus-tmp-header (caar thread))))
4531 (setq gnus-tmp-false-parent nil)
4532 (setq gnus-tmp-root-expunged nil)
4533 (setq thread-end nil)
4535 (if (stringp gnus-tmp-header)
4536 ;; The header is a dummy root.
4538 ((eq gnus-summary-make-false-root 'adopt)
4539 ;; We let the first article adopt the rest.
4540 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4542 (setq gnus-tmp-gathered
4544 (lambda (h) (mail-header-number (car h)))
4547 (setq thread (cons (list (caar thread)
4550 (setq gnus-tmp-level -1
4551 gnus-tmp-false-parent t))
4552 ((eq gnus-summary-make-false-root 'empty)
4553 ;; We print adopted articles with empty subject fields.
4554 (setq gnus-tmp-gathered
4556 (lambda (h) (mail-header-number (car h)))
4559 (setq gnus-tmp-level -1))
4560 ((eq gnus-summary-make-false-root 'dummy)
4561 ;; We remember that we probably want to output a dummy
4563 (setq gnus-tmp-dummy-line gnus-tmp-header)
4564 (setq gnus-tmp-prev-subject gnus-tmp-header))
4566 ;; We do not make a root for the gathered
4567 ;; sub-threads at all.
4568 (setq gnus-tmp-level -1)))
4570 (setq number (mail-header-number gnus-tmp-header)
4571 subject (mail-header-subject gnus-tmp-header)
4572 simp-subject (gnus-simplify-subject-fully subject))
4575 ;; If the thread has changed subject, we might want to make
4576 ;; this subthread into a root.
4577 ((and (null gnus-thread-ignore-subject)
4578 (not (zerop gnus-tmp-level))
4579 gnus-tmp-prev-subject
4580 (not (string= gnus-tmp-prev-subject simp-subject)))
4581 (setq new-roots (nconc new-roots (list (car thread)))
4583 gnus-tmp-header nil))
4584 ;; If the article lies outside the current limit,
4585 ;; then we do not display it.
4586 ((not (memq number gnus-newsgroup-limit))
4587 (setq gnus-tmp-gathered
4589 (lambda (h) (mail-header-number (car h)))
4592 (setq gnus-tmp-new-adopts (if (cdar thread)
4593 (append gnus-tmp-new-adopts
4595 gnus-tmp-new-adopts)
4597 gnus-tmp-header nil)
4598 (when (zerop gnus-tmp-level)
4599 (setq gnus-tmp-root-expunged t)))
4600 ;; Perhaps this article is to be marked as read?
4601 ((and gnus-summary-mark-below
4602 (< (or (cdr (assq number gnus-newsgroup-scored))
4604 gnus-summary-mark-below)
4605 ;; Don't touch sparse articles.
4606 (not (gnus-summary-article-sparse-p number))
4607 (not (gnus-summary-article-ancient-p number)))
4608 (setq gnus-newsgroup-unreads
4609 (delq number gnus-newsgroup-unreads))
4610 (if gnus-newsgroup-auto-expire
4611 (setq gnus-newsgroup-expirable
4612 (gnus-add-to-sorted-list
4613 gnus-newsgroup-expirable number))
4614 (push (cons number gnus-low-score-mark)
4615 gnus-newsgroup-reads))))
4617 (when gnus-tmp-header
4618 ;; We may have an old dummy line to output before this
4620 (when (and gnus-tmp-dummy-line
4623 (mail-header-subject gnus-tmp-header)))
4624 (gnus-summary-insert-dummy-line
4625 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4626 (setq gnus-tmp-dummy-line nil))
4628 ;; Compute the mark.
4629 (setq gnus-tmp-unread (gnus-article-mark number))
4631 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4632 gnus-tmp-header gnus-tmp-level)
4633 gnus-newsgroup-data)
4635 ;; Actually insert the line.
4637 gnus-tmp-subject-or-nil
4639 ((and gnus-thread-ignore-subject
4640 gnus-tmp-prev-subject
4641 (not (string= gnus-tmp-prev-subject simp-subject)))
4643 ((zerop gnus-tmp-level)
4644 (if (and (eq gnus-summary-make-false-root 'empty)
4645 (memq number gnus-tmp-gathered)
4646 gnus-tmp-prev-subject
4647 (string= gnus-tmp-prev-subject simp-subject))
4648 gnus-summary-same-subject
4650 (t gnus-summary-same-subject)))
4651 (if (and (eq gnus-summary-make-false-root 'adopt)
4652 (= gnus-tmp-level 1)
4653 (memq number gnus-tmp-gathered))
4654 (setq gnus-tmp-opening-bracket ?\<
4655 gnus-tmp-closing-bracket ?\>)
4656 (setq gnus-tmp-opening-bracket ?\[
4657 gnus-tmp-closing-bracket ?\]))
4659 gnus-tmp-indentation
4660 (aref gnus-thread-indent-array gnus-tmp-level)
4661 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4662 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4663 gnus-summary-default-score 0)
4665 (if (or (null gnus-summary-default-score)
4666 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4667 gnus-summary-zcore-fuzz))
4669 (if (< gnus-tmp-score gnus-summary-default-score)
4670 gnus-score-below-mark gnus-score-over-mark))
4672 (cond ((memq number gnus-newsgroup-processable)
4674 ((memq number gnus-newsgroup-cached)
4676 ((memq number gnus-newsgroup-replied)
4678 ((memq number gnus-newsgroup-forwarded)
4679 gnus-forwarded-mark)
4680 ((memq number gnus-newsgroup-saved)
4682 ((memq number gnus-newsgroup-recent)
4684 ((memq number gnus-newsgroup-unseen)
4688 (cond ((memq number gnus-newsgroup-undownloaded)
4689 gnus-undownloaded-mark)
4690 (gnus-newsgroup-agentized
4691 gnus-downloaded-mark)
4694 gnus-tmp-from (mail-header-from gnus-tmp-header)
4697 ((string-match "<[^>]+> *$" gnus-tmp-from)
4698 (setq beg-match (match-beginning 0))
4699 (or (and (string-match "^\".+\"" gnus-tmp-from)
4700 (substring gnus-tmp-from 1 (1- (match-end 0))))
4701 (substring gnus-tmp-from 0 beg-match)))
4702 ((string-match "(.+)" gnus-tmp-from)
4703 (substring gnus-tmp-from
4704 (1+ (match-beginning 0)) (1- (match-end 0))))
4706 gnus-tmp-thread-tree-header-string
4708 ((not gnus-show-threads) "")
4709 ((zerop gnus-tmp-level)
4711 (or gnus-sum-thread-tree-root subject)
4712 (or gnus-sum-thread-tree-single-indent subject)))
4714 (concat (apply 'concat
4715 (mapcar (lambda (item)
4717 gnus-sum-thread-tree-vertical
4718 gnus-sum-thread-tree-indent))
4719 (cdr (reverse tree-stack))))
4721 gnus-sum-thread-tree-leaf-with-other
4722 gnus-sum-thread-tree-single-leaf)))))
4723 (when (string= gnus-tmp-name "")
4724 (setq gnus-tmp-name gnus-tmp-from))
4725 (unless (numberp gnus-tmp-lines)
4726 (setq gnus-tmp-lines -1))
4727 (if (= gnus-tmp-lines -1)
4728 (setq gnus-tmp-lines "?")
4729 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4730 (gnus-put-text-property
4732 (progn (eval gnus-summary-line-format-spec) (point))
4733 'gnus-number number)
4736 (gnus-run-hooks 'gnus-summary-update-hook)
4739 (setq gnus-tmp-prev-subject simp-subject)))
4741 (when (nth 1 thread)
4742 (push (list (max 0 gnus-tmp-level)
4743 (copy-list tree-stack)
4746 (push (if (nth 1 thread) 1 0) tree-stack)
4747 (incf gnus-tmp-level)
4748 (setq threads (if thread-end nil (cdar thread)))
4750 (setq gnus-tmp-level 0)))))
4751 (gnus-message 7 "Generating summary...done"))
4753 (defun gnus-summary-prepare-unthreaded (headers)
4754 "Generate an unthreaded summary buffer based on HEADERS."
4755 (let (header number mark)
4760 ;; We may have to root out some bad articles...
4761 (when (memq (setq number (mail-header-number
4762 (setq header (pop headers))))
4763 gnus-newsgroup-limit)
4764 ;; Mark article as read when it has a low score.
4765 (when (and gnus-summary-mark-below
4766 (< (or (cdr (assq number gnus-newsgroup-scored))
4767 gnus-summary-default-score 0)
4768 gnus-summary-mark-below)
4769 (not (gnus-summary-article-ancient-p number)))
4770 (setq gnus-newsgroup-unreads
4771 (delq number gnus-newsgroup-unreads))
4772 (if gnus-newsgroup-auto-expire
4773 (push number gnus-newsgroup-expirable)
4774 (push (cons number gnus-low-score-mark)
4775 gnus-newsgroup-reads)))
4777 (setq mark (gnus-article-mark number))
4778 (push (gnus-data-make number mark (1+ (point)) header 0)
4779 gnus-newsgroup-data)
4780 (gnus-summary-insert-line
4782 (memq number gnus-newsgroup-undownloaded)
4783 mark (memq number gnus-newsgroup-replied)
4784 (memq number gnus-newsgroup-expirable)
4785 (mail-header-subject header) nil
4786 (cdr (assq number gnus-newsgroup-scored))
4787 (memq number gnus-newsgroup-processable))))))
4789 (defun gnus-summary-remove-list-identifiers ()
4790 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4791 (let ((regexp (if (consp gnus-list-identifiers)
4792 (mapconcat 'identity gnus-list-identifiers " *\\|")
4793 gnus-list-identifiers))
4796 (dolist (header gnus-newsgroup-headers)
4797 (setq subject (mail-header-subject header)
4799 (while (string-match
4800 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4803 (concat (substring subject 0 (match-beginning 2))
4804 (substring subject (match-end 0)))
4808 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4810 (concat (substring subject 0 (match-beginning 1))
4811 (substring subject (match-end 1)))))
4813 (mail-header-set-subject header subject))))))
4815 (defun gnus-fetch-headers (articles)
4816 "Fetch headers of ARTICLES."
4817 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4818 (gnus-message 5 "Fetching headers for %s..." name)
4821 (setq gnus-headers-retrieved-by
4822 (gnus-retrieve-headers
4823 articles gnus-newsgroup-name
4824 ;; We might want to fetch old headers, but
4825 ;; not if there is only 1 article.
4827 (not (eq gnus-fetch-old-headers 'some))
4828 (not (numberp gnus-fetch-old-headers)))
4829 (> (length articles) 1))
4830 gnus-fetch-old-headers))))
4831 (gnus-get-newsgroup-headers-xover
4832 articles nil nil gnus-newsgroup-name t)
4833 (gnus-get-newsgroup-headers))
4834 (gnus-message 5 "Fetching headers for %s...done" name))))
4836 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4837 "Select newsgroup GROUP.
4838 If READ-ALL is non-nil, all articles in the group are selected.
4839 If SELECT-ARTICLES, only select those articles from GROUP."
4840 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4841 ;;!!! Dirty hack; should be removed.
4842 (gnus-summary-ignore-duplicates
4843 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4845 gnus-summary-ignore-duplicates))
4846 (info (nth 2 entry))
4847 articles fetched-articles cached)
4849 (unless (gnus-check-server
4850 (set (make-local-variable 'gnus-current-select-method)
4851 (gnus-find-method-for-group group)))
4852 (error "Couldn't open server"))
4854 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4855 (gnus-activate-group group) ; Or we can activate it...
4856 (progn ; Or we bug out.
4857 (when (equal major-mode 'gnus-summary-mode)
4858 (kill-buffer (current-buffer)))
4859 (error "Couldn't activate group %s: %s"
4860 group (gnus-status-message group))))
4862 (unless (gnus-request-group group t)
4863 (when (equal major-mode 'gnus-summary-mode)
4864 (kill-buffer (current-buffer)))
4865 (error "Couldn't request group %s: %s"
4866 group (gnus-status-message group)))
4868 (setq gnus-newsgroup-name group
4869 gnus-newsgroup-unselected nil
4870 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4872 (let ((display (gnus-group-find-parameter group 'display)))
4873 (setq gnus-newsgroup-display
4875 ((not (zerop (or (car-safe read-all) 0)))
4876 ;; The user entered the group with C-u SPC/RET, let's show
4882 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4884 ;; The following is probably the "correct" solution, but
4885 ;; it makes Gnus fetch all headers and then limit the
4886 ;; articles (which is slow), so instead we hack the
4887 ;; select-articles parameter instead. -- Simon Josefsson
4890 ;; (gnus-byte-compile
4891 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4893 (setq select-articles
4894 (gnus-uncompress-range
4895 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4899 (cdr (gnus-active group)))))
4904 (gnus-summary-setup-default-charset)
4906 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4907 (when (gnus-virtual-group-p group)
4908 (setq cached gnus-newsgroup-cached))
4910 (setq gnus-newsgroup-unreads
4911 (gnus-sorted-ndifference
4912 (gnus-sorted-ndifference gnus-newsgroup-unreads
4913 gnus-newsgroup-marked)
4914 gnus-newsgroup-dormant))
4916 (setq gnus-newsgroup-processable nil)
4918 (gnus-update-read-articles group gnus-newsgroup-unreads)
4920 ;; Adjust and set lists of article marks.
4922 (gnus-adjust-marked-articles info))
4923 (if (setq articles select-articles)
4924 (setq gnus-newsgroup-unselected
4925 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4926 (setq articles (gnus-articles-to-read group read-all)))
4930 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4932 ((eq articles 0) nil)
4934 ;; Init the dependencies hash table.
4935 (setq gnus-newsgroup-dependencies
4936 (gnus-make-hashtable (length articles)))
4937 (gnus-set-global-variables)
4938 ;; Retrieve the headers and read them in.
4940 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4942 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4944 (setq gnus-newsgroup-cached cached))
4946 ;; Suppress duplicates?
4947 (when gnus-suppress-duplicates
4948 (gnus-dup-suppress-articles))
4950 ;; Set the initial limit.
4951 (setq gnus-newsgroup-limit (copy-sequence articles))
4952 ;; Remove canceled articles from the list of unread articles.
4953 (setq fetched-articles
4954 (mapcar (lambda (headers) (mail-header-number headers))
4955 gnus-newsgroup-headers))
4956 (setq gnus-newsgroup-articles fetched-articles)
4957 (setq gnus-newsgroup-unreads
4958 (gnus-sorted-nintersection
4959 gnus-newsgroup-unreads fetched-articles))
4960 (gnus-compute-unseen-list)
4962 ;; Removed marked articles that do not exist.
4963 (gnus-update-missing-marks
4964 (gnus-sorted-difference articles fetched-articles))
4965 ;; We might want to build some more threads first.
4966 (when (and gnus-fetch-old-headers
4967 (eq gnus-headers-retrieved-by 'nov))
4968 (if (eq gnus-fetch-old-headers 'invisible)
4969 (gnus-build-all-threads)
4970 (gnus-build-old-threads)))
4971 ;; Let the Gnus agent mark articles as read.
4973 (gnus-agent-get-undownloaded-list))
4974 ;; Remove list identifiers from subject
4975 (when gnus-list-identifiers
4976 (gnus-summary-remove-list-identifiers))
4977 ;; Check whether auto-expire is to be done in this group.
4978 (setq gnus-newsgroup-auto-expire
4979 (gnus-group-auto-expirable-p group))
4980 ;; Set up the article buffer now, if necessary.
4981 (unless gnus-single-article-buffer
4982 (gnus-article-setup-buffer))
4983 ;; First and last article in this newsgroup.
4984 (when gnus-newsgroup-headers
4985 (setq gnus-newsgroup-begin
4986 (mail-header-number (car gnus-newsgroup-headers))
4989 (gnus-last-element gnus-newsgroup-headers))))
4990 ;; GROUP is successfully selected.
4991 (or gnus-newsgroup-headers t)))))
4993 (defun gnus-compute-unseen-list ()
4994 ;; The `seen' marks are treated specially.
4995 (if (not gnus-newsgroup-seen)
4996 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4997 (setq gnus-newsgroup-unseen
4998 (gnus-inverse-list-range-intersection
4999 gnus-newsgroup-articles gnus-newsgroup-seen))))
5001 (defun gnus-summary-display-make-predicate (display)
5002 (require 'gnus-agent)
5003 (when (= (length display) 1)
5004 (setq display (car display)))
5005 (unless gnus-summary-display-cache
5006 (dolist (elem (append '((unread . unread)
5009 gnus-article-mark-lists))
5010 (push (cons (cdr elem)
5012 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5013 gnus-summary-display-cache)))
5014 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5015 (gnus-category-predicate-cache gnus-summary-display-cache))
5016 (gnus-get-predicate display)))
5018 ;; Uses the dynamically bound `number' variable.
5021 (defun gnus-article-marked-p (type &optional article)
5022 (let ((article (or article number)))
5025 (memq article gnus-newsgroup-marked))
5027 (memq article gnus-newsgroup-spam-marked))
5029 (memq article gnus-newsgroup-unsendable))
5030 ((eq type 'undownload)
5031 (memq article gnus-newsgroup-undownloaded))
5032 ((eq type 'download)
5033 (memq article gnus-newsgroup-downloadable))
5035 (memq article gnus-newsgroup-unreads))
5037 (memq article gnus-newsgroup-reads))
5039 (memq article gnus-newsgroup-dormant) )
5041 (memq article gnus-newsgroup-expirable))
5043 (memq article gnus-newsgroup-replied))
5045 (memq article gnus-newsgroup-killed))
5046 ((eq type 'bookmark)
5047 (assq article gnus-newsgroup-bookmarks))
5049 (assq article gnus-newsgroup-scored))
5051 (memq article gnus-newsgroup-saved))
5053 (memq article gnus-newsgroup-cached))
5055 (memq article gnus-newsgroup-forwarded))
5057 (not (memq article gnus-newsgroup-unseen)))
5059 (memq article gnus-newsgroup-recent))
5062 (defun gnus-articles-to-read (group &optional read-all)
5063 "Find out what articles the user wants to read."
5065 ;; Select all articles if `read-all' is non-nil, or if there
5066 ;; are no unread articles.
5068 (and (zerop (length gnus-newsgroup-marked))
5069 (zerop (length gnus-newsgroup-unreads)))
5070 ;; Fetch all if the predicate is non-nil.
5071 gnus-newsgroup-display)
5072 ;; We want to select the headers for all the articles in
5073 ;; the group, so we select either all the active
5074 ;; articles in the group, or (if that's nil), the
5075 ;; articles in the cache.
5077 (gnus-uncompress-range (gnus-active group))
5078 (gnus-cache-articles-in-group group))
5079 ;; Select only the "normal" subset of articles.
5081 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5082 gnus-newsgroup-unreads)))
5083 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5084 (scored (length scored-list))
5085 (number (length articles))
5086 (marked (+ (length gnus-newsgroup-marked)
5087 (length gnus-newsgroup-dormant)))
5092 ((numberp gnus-newsgroup-display)
5093 gnus-newsgroup-display)
5097 ((and (or (<= scored marked) (= scored number))
5098 (numberp gnus-large-newsgroup)
5099 (> number gnus-large-newsgroup))
5100 (let* ((cursor-in-echo-area nil)
5101 (initial (gnus-parameter-large-newsgroup-initial
5102 gnus-newsgroup-name))
5106 "How many articles from %s (%s %d): "
5108 (gnus-group-decoded-name gnus-newsgroup-name)
5110 (if initial "max" "default")
5113 (cons (number-to-string initial)
5115 (if (string-match "^[ \t]*$" input) number input)))
5116 ((and (> scored marked) (< scored number)
5117 (> (- scored number) 20))
5120 (format "%s %s (%d scored, %d total): "
5121 "How many articles from"
5122 (gnus-group-decoded-name group)
5124 (if (string-match "^[ \t]*$" input)
5128 (message "Quit getting the articles to read")
5130 (setq select (if (stringp select) (string-to-number select) select))
5131 (if (or (null select) (zerop select))
5133 (if (and (not (zerop scored)) (<= (abs select) scored))
5135 (setq articles (sort scored-list '<))
5136 (setq number (length articles)))
5137 (setq articles (copy-sequence articles)))
5139 (when (< (abs select) number)
5141 ;; Select the N oldest articles.
5142 (setcdr (nthcdr (1- (abs select)) articles) nil)
5143 ;; Select the N most recent articles.
5144 (setq articles (nthcdr (- number select) articles))))
5145 (setq gnus-newsgroup-unselected
5146 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5147 (when gnus-alter-articles-to-read-function
5148 (setq gnus-newsgroup-unreads
5150 (funcall gnus-alter-articles-to-read-function
5151 gnus-newsgroup-name gnus-newsgroup-unreads)
5155 (defun gnus-killed-articles (killed articles)
5158 (when (inline (gnus-member-of-range (car articles) killed))
5159 (push (car articles) out))
5160 (setq articles (cdr articles)))
5163 (defun gnus-uncompress-marks (marks)
5164 "Uncompress the mark ranges in MARKS."
5165 (let ((uncompressed '(score bookmark))
5168 (if (memq (caar marks) uncompressed)
5169 (push (car marks) out)
5170 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5171 (setq marks (cdr marks)))
5174 (defun gnus-article-mark-to-type (mark)
5175 "Return the type of MARK."
5176 (or (cadr (assq mark gnus-article-special-mark-lists))
5179 (defun gnus-article-unpropagatable-p (mark)
5180 "Return whether MARK should be propagated to backend."
5181 (memq mark gnus-article-unpropagated-mark-lists))
5183 (defun gnus-adjust-marked-articles (info)
5184 "Set all article lists and remove all marks that are no longer valid."
5185 (let* ((marked-lists (gnus-info-marks info))
5186 (active (gnus-active (gnus-info-group info)))
5189 (types gnus-article-mark-lists)
5190 marks var articles article mark mark-type)
5192 (dolist (marks marked-lists)
5193 (setq mark (car marks)
5194 mark-type (gnus-article-mark-to-type mark)
5195 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5197 ;; We set the variable according to the type of the marks list,
5198 ;; and then adjust the marks to a subset of the active articles.
5200 ;; Adjust "simple" lists.
5201 ((eq mark-type 'list)
5202 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5203 (when (memq mark '(tick dormant expire reply save))
5205 (when (or (< (setq article (pop articles)) min) (> article max))
5206 (set var (delq article (symbol-value var)))))))
5208 ((eq mark-type 'tuple)
5209 (set var (setq articles (cdr marks)))
5210 (when (not (listp (cdr (symbol-value var))))
5211 (set var (list (symbol-value var))))
5212 (when (not (listp (cdr articles)))
5213 (setq articles (list articles)))
5215 (when (or (not (consp (setq article (pop articles))))
5216 (< (car article) min)
5217 (> (car article) max))
5218 (set var (delq article (symbol-value var))))))
5219 ;; Adjust ranges (sloppily).
5220 ((eq mark-type 'range)
5223 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5224 ;; It should be (seen (NUM1 . NUM2)).
5225 (when (numberp (cddr marks))
5226 (setcdr marks (list (cdr marks))))
5227 (setq articles (cdr marks))
5228 (while (and articles
5229 (or (and (consp (car articles))
5230 (> min (cdar articles)))
5231 (and (numberp (car articles))
5232 (> min (car articles)))))
5234 (set var articles))))))))
5236 (defun gnus-update-missing-marks (missing)
5237 "Go through the list of MISSING articles and remove them from the mark lists."
5240 ;; Go through all types.
5241 (dolist (elem gnus-article-mark-lists)
5242 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5243 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5244 (when (symbol-value var)
5245 ;; This list has articles. So we delete all missing
5246 ;; articles from it.
5249 (set var (delq (pop m) (symbol-value var))))))))))
5251 (defun gnus-update-marks ()
5252 "Enter the various lists of marked articles into the newsgroup info list."
5253 (let ((types gnus-article-mark-lists)
5254 (info (gnus-get-info gnus-newsgroup-name))
5255 type list newmarked symbol delta-marks)
5257 ;; Add all marks lists to the list of marks lists.
5258 (while (setq type (pop types))
5259 (setq list (symbol-value
5261 (intern (format "gnus-newsgroup-%s" (car type))))))
5264 ;; Get rid of the entries of the articles that have the
5266 (when (and (eq (cdr type) 'score)
5270 (prev (cons nil list))
5273 (if (or (not (consp (car arts)))
5274 (= (cdar arts) gnus-summary-default-score))
5275 (setcdr prev (cdr arts))
5277 (setq arts (cdr arts)))
5278 (setq list (cdr all)))))
5280 (when (eq (cdr type) 'seen)
5281 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5283 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5284 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5286 (when (and (gnus-check-backend-function
5287 'request-set-mark gnus-newsgroup-name)
5288 (not (gnus-article-unpropagatable-p (cdr type))))
5289 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5290 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5291 (add (gnus-remove-from-range
5292 (gnus-copy-sequence list) old)))
5294 (push (list add 'add (list (cdr type))) delta-marks))
5296 (push (list del 'del (list (cdr type))) delta-marks))))
5299 (push (cons (cdr type) list) newmarked)))
5302 (unless (gnus-check-group gnus-newsgroup-name)
5303 (error "Can't open server for %s" gnus-newsgroup-name))
5304 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5306 ;; Enter these new marks into the info of the group.
5308 (setcar (nthcdr 3 info) newmarked)
5309 ;; Add the marks lists to the end of the info.
5311 (setcdr (nthcdr 2 info) (list newmarked))))
5313 ;; Cut off the end of the info if there's nothing else there.
5317 (when (nthcdr (decf i) info)
5318 (setcdr (nthcdr i info) nil)))))))
5320 (defun gnus-set-mode-line (where)
5321 "Set the mode line of the article or summary buffers.
5322 If WHERE is `summary', the summary mode line format will be used."
5323 ;; Is this mode line one we keep updated?
5324 (when (and (memq where gnus-updated-mode-lines)
5326 (intern (format "gnus-%s-mode-line-format-spec" where))))
5329 ;; We evaluate this in the summary buffer since these
5330 ;; variables are buffer-local to that buffer.
5331 (set-buffer gnus-summary-buffer)
5332 ;; We bind all these variables that are used in the `eval' form
5334 (let* ((mformat (symbol-value
5336 (format "gnus-%s-mode-line-format-spec" where))))
5337 (gnus-tmp-group-name (gnus-group-decoded-name
5338 gnus-newsgroup-name))
5339 (gnus-tmp-article-number (or gnus-current-article 0))
5340 (gnus-tmp-unread gnus-newsgroup-unreads)
5341 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5342 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5343 (gnus-tmp-unread-and-unselected
5344 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5345 (zerop gnus-tmp-unselected))
5347 ((zerop gnus-tmp-unselected)
5348 (format "{%d more}" gnus-tmp-unread-and-unticked))
5349 (t (format "{%d(+%d) more}"
5350 gnus-tmp-unread-and-unticked
5351 gnus-tmp-unselected))))
5353 (if (and gnus-current-headers
5354 (vectorp gnus-current-headers))
5355 (gnus-mode-string-quote
5356 (mail-header-subject gnus-current-headers))
5358 bufname-length max-len
5359 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5360 (setq mode-string (eval mformat))
5361 (setq bufname-length (if (string-match "%b" mode-string)
5364 (if (eq where 'summary)
5366 (get-buffer gnus-article-buffer))))
5369 (setq max-len (max 4 (if gnus-mode-non-string-length
5371 gnus-mode-non-string-length
5373 (length mode-string))))
5374 ;; We might have to chop a bit of the string off...
5375 (when (> (length mode-string) max-len)
5377 (concat (truncate-string-to-width mode-string (- max-len 3))
5379 ;; Pad the mode string a bit.
5380 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5381 ;; Update the mode line.
5382 (setq mode-line-buffer-identification
5383 (gnus-mode-line-buffer-identification (list mode-string)))
5384 (set-buffer-modified-p t))))
5386 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5387 "Go through the HEADERS list and add all Xrefs to a hash table.
5388 The resulting hash table is returned, or nil if no Xrefs were found."
5389 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5390 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5391 (xref-hashtb (gnus-make-hashtable))
5392 start group entry number xrefs header)
5394 (setq header (pop headers))
5395 (when (and (setq xrefs (mail-header-xref header))
5396 (not (memq (setq number (mail-header-number header))
5399 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5400 (setq start (match-end 0))
5401 (setq group (if prefix
5402 (concat prefix (substring xrefs (match-beginning 1)
5404 (substring xrefs (match-beginning 1) (match-end 1))))
5406 (string-to-int (substring xrefs (match-beginning 2)
5408 (if (setq entry (gnus-gethash group xref-hashtb))
5409 (setcdr entry (cons number (cdr entry)))
5410 (gnus-sethash group (cons number nil) xref-hashtb)))))
5411 (and start xref-hashtb)))
5413 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5414 "Look through all the headers and mark the Xrefs as read."
5415 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5416 name entry info xref-hashtb idlist method nth4)
5418 (set-buffer gnus-group-buffer)
5419 (when (setq xref-hashtb
5420 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5423 (unless (string= from-newsgroup (setq name (symbol-name group)))
5424 (setq idlist (symbol-value group))
5425 ;; Dead groups are not updated.
5427 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5429 (when (stringp (setq nth4 (gnus-info-method info)))
5430 (setq nth4 (gnus-server-to-method nth4))))
5431 ;; Only do the xrefs if the group has the same
5432 ;; select method as the group we have just read.
5433 (or (gnus-methods-equal-p
5434 nth4 (gnus-find-method-for-group from-newsgroup))
5436 (equal nth4 (setq method (gnus-find-method-for-group
5438 (and (equal (car nth4) (car method))
5439 (equal (nth 1 nth4) (nth 1 method))))
5440 gnus-use-cross-reference
5441 (or (not (eq gnus-use-cross-reference t))
5443 ;; Only do cross-references on subscribed
5444 ;; groups, if that is what is wanted.
5445 (<= (gnus-info-level info) gnus-level-subscribed))
5446 (gnus-group-make-articles-read name idlist))))
5449 (defun gnus-compute-read-articles (group articles)
5450 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5451 (info (nth 2 entry))
5452 (active (gnus-active group))
5455 ;; First peel off all invalid article numbers.
5457 (let ((ids articles)
5459 (while (setq id (pop ids))
5460 (when (and first (> id (cdr active)))
5461 ;; We'll end up in this situation in one particular
5462 ;; obscure situation. If you re-scan a group and get
5463 ;; a new article that is cross-posted to a different
5464 ;; group that has not been re-scanned, you might get
5465 ;; crossposted article that has a higher number than
5466 ;; Gnus believes possible. So we re-activate this
5467 ;; group as well. This might mean doing the
5468 ;; crossposting thingy will *increase* the number
5469 ;; of articles in some groups. Tsk, tsk.
5470 (setq active (or (gnus-activate-group group) active)))
5471 (when (or (> id (cdr active))
5472 (< id (car active)))
5473 (setq articles (delq id articles))))))
5474 ;; If the read list is nil, we init it.
5476 (null (gnus-info-read info))
5478 (setq ninfo (cons 1 (1- (car active))))
5479 (setq ninfo (gnus-info-read info)))
5480 ;; Then we add the read articles to the range.
5482 ninfo (setq articles (sort articles '<))))))
5484 (defun gnus-group-make-articles-read (group articles)
5485 "Update the info of GROUP to say that ARTICLES are read."
5487 (entry (gnus-gethash group gnus-newsrc-hashtb))
5488 (info (nth 2 entry))
5489 (active (gnus-active group))
5492 (setq range (gnus-compute-read-articles group articles))
5494 (set-buffer gnus-group-buffer)
5497 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5498 (gnus-info-set-read ',info ',(gnus-info-read info))
5499 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5500 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5501 (gnus-group-update-group ,group t))))
5502 ;; Add the read articles to the range.
5503 (gnus-info-set-read info range)
5504 (gnus-request-set-mark group (list (list range 'add '(read))))
5505 ;; Then we have to re-compute how many unread
5506 ;; articles there are in this group.
5510 (setq num (- (1+ (cdr active)) (car active))))
5511 ((not (listp (cdr range)))
5512 (setq num (- (cdr active) (- (1+ (cdr range))
5516 (if (numberp (car range))
5518 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5519 (setq range (cdr range)))
5520 (setq num (- (cdr active) num))))
5521 ;; Update the number of unread articles.
5523 ;; Update the group buffer.
5524 (gnus-group-update-group group t)))))
5526 (defvar gnus-newsgroup-none-id 0)
5528 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5529 (let ((cur nntp-server-buffer)
5532 (save-excursion (set-buffer gnus-summary-buffer)
5533 gnus-newsgroup-dependencies)))
5535 (mail-parse-charset gnus-newsgroup-charset)
5536 (mail-parse-ignored-charsets
5537 (save-excursion (condition-case nil
5538 (set-buffer gnus-summary-buffer)
5540 gnus-newsgroup-ignored-charsets)))
5542 (set-buffer nntp-server-buffer)
5543 ;; Translate all TAB characters into SPACE characters.
5544 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5545 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5546 (gnus-run-hooks 'gnus-parse-headers-hook)
5547 (let ((case-fold-search t)
5548 in-reply-to header p lines chars)
5549 (goto-char (point-min))
5550 ;; Search to the beginning of the next header. Error messages
5551 ;; do not begin with 2 or 3.
5552 (while (re-search-forward "^[23][0-9]+ " nil t)
5555 ;; This implementation of this function, with nine
5556 ;; search-forwards instead of the one re-search-forward and
5557 ;; a case (which basically was the old function) is actually
5558 ;; about twice as fast, even though it looks messier. You
5559 ;; can't have everything, I guess. Speed and elegance
5560 ;; doesn't always go hand in hand.
5569 (narrow-to-region (point)
5570 (or (and (search-forward "\n.\n" nil t)
5576 (if (search-forward "\nsubject:" nil t)
5577 (funcall gnus-decode-encoded-word-function
5578 (nnheader-header-value))
5583 (if (search-forward "\nfrom:" nil t)
5584 (funcall gnus-decode-encoded-word-function
5585 (nnheader-header-value))
5590 (if (search-forward "\ndate:" nil t)
5591 (nnheader-header-value) ""))
5595 (setq id (if (re-search-forward
5596 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5597 ;; We do it this way to make sure the Message-ID
5598 ;; is (somewhat) syntactically valid.
5599 (buffer-substring (match-beginning 1)
5601 ;; If there was no message-id, we just fake one
5602 ;; to make subsequent routines simpler.
5603 (nnheader-generate-fake-message-id))))
5607 (if (search-forward "\nreferences:" nil t)
5611 (nnheader-header-value)
5616 (search-backward ">" end t)
5619 (search-backward "<" end t)
5621 ;; Get the references from the in-reply-to header if there
5622 ;; were no references and the in-reply-to header looks
5624 (if (and (search-forward "\nin-reply-to:" nil t)
5625 (setq in-reply-to (nnheader-header-value))
5626 (string-match "<[^>]+>" in-reply-to))
5628 (setq ref (substring in-reply-to (match-beginning 0)
5630 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5631 (setq ref2 (substring in-reply-to (match-beginning 0)
5633 (when (> (length ref2) (length ref))
5640 (if (search-forward "\nchars: " nil t)
5641 (if (numberp (setq chars (ignore-errors (read cur))))
5647 (if (search-forward "\nlines: " nil t)
5648 (if (numberp (setq lines (ignore-errors (read cur))))
5654 (and (search-forward "\nxref:" nil t)
5655 (nnheader-header-value)))
5657 (when gnus-extra-headers
5658 (let ((extra gnus-extra-headers)
5662 (when (search-forward
5663 (concat "\n" (symbol-name (car extra)) ":") nil t)
5664 (push (cons (car extra) (nnheader-header-value))
5668 (when (equal id ref)
5671 (when gnus-alter-header-function
5672 (funcall gnus-alter-header-function header)
5673 (setq id (mail-header-id header)
5674 ref (gnus-parent-id (mail-header-references header))))
5677 (gnus-dependencies-add-header
5678 header dependencies force-new))
5679 (push header headers))
5680 (goto-char (point-max))
5682 (nreverse headers)))))
5684 ;; Goes through the xover lines and returns a list of vectors
5685 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5686 force-new dependencies
5687 group also-fetch-heads)
5688 "Parse the news overview data in the server buffer.
5689 Return a list of headers that match SEQUENCE (see
5690 `nntp-retrieve-headers')."
5691 ;; Get the Xref when the users reads the articles since most/some
5692 ;; NNTP servers do not include Xrefs when using XOVER.
5693 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5694 (let ((mail-parse-charset gnus-newsgroup-charset)
5695 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5696 (cur nntp-server-buffer)
5697 (dependencies (or dependencies gnus-newsgroup-dependencies))
5699 ((eq gnus-read-all-available-headers t)
5701 ((stringp gnus-read-all-available-headers)
5702 (string-match gnus-read-all-available-headers group))
5705 number headers header)
5707 (set-buffer nntp-server-buffer)
5708 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5709 ;; Allow the user to mangle the headers before parsing them.
5710 (gnus-run-hooks 'gnus-parse-headers-hook)
5711 (goto-char (point-min))
5712 (gnus-parse-without-error
5713 (while (and (or sequence allp)
5715 (setq number (read cur))
5717 (while (and sequence
5718 (< (car sequence) number))
5719 (setq sequence (cdr sequence))))
5722 (eq number (car sequence))))
5724 (setq sequence (cdr sequence))
5725 (setq header (inline
5726 (gnus-nov-parse-line
5727 number dependencies force-new)))))
5728 (push header headers))
5730 ;; A common bug in inn is that if you have posted an article and
5731 ;; then retrieves the active file, it will answer correctly --
5732 ;; the new article is included. However, a NOV entry for the
5733 ;; article may not have been generated yet, so this may fail.
5734 ;; We work around this problem by retrieving the last few
5735 ;; headers using HEAD.
5736 (if (or (not also-fetch-heads)
5738 ;; We (probably) got all the headers.
5740 (let ((gnus-nov-is-evil t))
5743 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5744 (gnus-get-newsgroup-headers))))))))
5746 (defun gnus-article-get-xrefs ()
5747 "Fill in the Xref value in `gnus-current-headers', if necessary.
5748 This is meant to be called in `gnus-article-internal-prepare-hook'."
5749 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5750 gnus-current-headers)))
5751 (or (not gnus-use-cross-reference)
5753 (and (mail-header-xref headers)
5754 (not (string= (mail-header-xref headers) "")))
5755 (let ((case-fold-search t)
5758 (nnheader-narrow-to-headers)
5759 (goto-char (point-min))
5760 (when (or (and (not (eobp))
5761 (eq (downcase (char-after)) ?x)
5762 (looking-at "Xref:"))
5763 (search-forward "\nXref:" nil t))
5764 (goto-char (1+ (match-end 0)))
5765 (setq xref (buffer-substring (point)
5766 (progn (end-of-line) (point))))
5767 (mail-header-set-xref headers xref)))))))
5769 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5770 "Find article ID and insert the summary line for that article.
5771 OLD-HEADER can either be a header or a line number to insert
5772 the subject line on."
5773 (let* ((line (and (numberp old-header) old-header))
5774 (old-header (and (vectorp old-header) old-header))
5775 (header (cond ((and old-header use-old-header)
5778 (gnus-number-to-header id))
5779 (gnus-number-to-header id))
5781 (gnus-read-header id))))
5782 (number (and (numberp id) id))
5785 ;; Rebuild the thread that this article is part of and go to the
5786 ;; article we have fetched.
5787 (when (and (not gnus-show-threads)
5790 (setq d (gnus-data-find (mail-header-number old-header))))
5791 (goto-char (gnus-data-pos d))
5794 (- (gnus-point-at-bol)
5796 (1+ (gnus-point-at-eol))
5797 (gnus-delete-line))))))
5799 (mail-header-set-number header (mail-header-number old-header)))
5800 (setq gnus-newsgroup-sparse
5801 (delq (setq number (mail-header-number header))
5802 gnus-newsgroup-sparse))
5803 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5804 (push number gnus-newsgroup-limit)
5805 (gnus-rebuild-thread (mail-header-id header) line)
5806 (gnus-summary-goto-subject number nil t))
5807 (when (and (numberp number)
5809 ;; We have to update the boundaries even if we can't fetch the
5810 ;; article if ID is a number -- so that the next `P' or `N'
5811 ;; command will fetch the previous (or next) article even
5812 ;; if the one we tried to fetch this time has been canceled.
5813 (when (> number gnus-newsgroup-end)
5814 (setq gnus-newsgroup-end number))
5815 (when (< number gnus-newsgroup-begin)
5816 (setq gnus-newsgroup-begin number))
5817 (setq gnus-newsgroup-unselected
5818 (delq number gnus-newsgroup-unselected)))
5819 ;; Report back a success?
5820 (and header (mail-header-number header))))
5822 ;;; Process/prefix in the summary buffer
5824 (defun gnus-summary-work-articles (n)
5825 "Return a list of articles to be worked upon.
5826 The prefix argument, the list of process marked articles, and the
5827 current article will be taken into consideration."
5829 (set-buffer gnus-summary-buffer)
5832 ;; A numerical prefix has been given.
5833 (setq n (prefix-numeric-value n))
5834 (let ((backward (< n 0))
5835 (n (abs (prefix-numeric-value n)))
5840 (push (setq article (gnus-summary-article-number))
5843 (gnus-summary-find-prev nil article)
5844 (gnus-summary-find-next nil article)))
5846 (nreverse articles)))
5847 ((and (gnus-region-active-p) (mark))
5848 (message "region active")
5849 ;; Work on the region between point and mark.
5850 (let ((max (max (point) (mark)))
5853 (goto-char (min (min (point) (mark))))
5856 (push (setq article (gnus-summary-article-number)) articles)
5857 (gnus-summary-find-next nil article)
5859 (nreverse articles))))
5860 (gnus-newsgroup-processable
5861 ;; There are process-marked articles present.
5862 ;; Save current state.
5863 (gnus-summary-save-process-mark)
5865 (reverse gnus-newsgroup-processable))
5867 ;; Just return the current article.
5868 (list (gnus-summary-article-number))))))
5870 (defmacro gnus-summary-iterate (arg &rest forms)
5871 "Iterate over the process/prefixed articles and do FORMS.
5872 ARG is the interactive prefix given to the command. FORMS will be
5873 executed with point over the summary line of the articles."
5874 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5875 `(let ((,articles (gnus-summary-work-articles ,arg)))
5877 (gnus-summary-goto-subject (car ,articles))
5881 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5882 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5884 (defun gnus-summary-save-process-mark ()
5885 "Push the current set of process marked articles on the stack."
5887 (push (copy-sequence gnus-newsgroup-processable)
5888 gnus-newsgroup-process-stack))
5890 (defun gnus-summary-kill-process-mark ()
5891 "Push the current set of process marked articles on the stack and unmark."
5893 (gnus-summary-save-process-mark)
5894 (gnus-summary-unmark-all-processable))
5896 (defun gnus-summary-yank-process-mark ()
5897 "Pop the last process mark state off the stack and restore it."
5899 (unless gnus-newsgroup-process-stack
5900 (error "Empty mark stack"))
5901 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5903 (defun gnus-summary-process-mark-set (set)
5904 "Make SET into the current process marked articles."
5905 (gnus-summary-unmark-all-processable)
5907 (gnus-summary-set-process-mark (pop set))))
5909 ;;; Searching and stuff
5911 (defun gnus-summary-search-group (&optional backward use-level)
5912 "Search for next unread newsgroup.
5913 If optional argument BACKWARD is non-nil, search backward instead."
5915 (set-buffer gnus-group-buffer)
5916 (when (gnus-group-search-forward
5917 backward nil (if use-level (gnus-group-group-level) nil))
5918 (gnus-group-group-name))))
5920 (defun gnus-summary-best-group (&optional exclude-group)
5921 "Find the name of the best unread group.
5922 If EXCLUDE-GROUP, do not go to this group."
5924 (set-buffer gnus-group-buffer)
5926 (gnus-group-best-unread-group exclude-group))))
5928 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5929 (if backward (gnus-summary-find-prev)
5930 (let* ((dummy (gnus-summary-article-intangible-p))
5931 (article (or article (gnus-summary-article-number)))
5932 (arts (gnus-data-find-list article))
5934 (when (and (not dummy)
5935 (or (not gnus-summary-check-current)
5937 (not (gnus-data-unread-p (car arts)))))
5938 (setq arts (cdr arts)))
5943 (when (or (and undownloaded
5944 (memq (car arts) gnus-newsgroup-undownloaded))
5945 (gnus-data-unread-p (car arts)))
5946 (setq result (car arts)
5948 (setq arts (cdr arts)))
5951 (goto-char (gnus-data-pos result))
5952 (gnus-data-number result)))))
5954 (defun gnus-summary-find-prev (&optional unread article)
5955 (let* ((eobp (eobp))
5956 (article (or article (gnus-summary-article-number)))
5957 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5959 (when (and (not eobp)
5960 (or (not gnus-summary-check-current)
5962 (not (gnus-data-unread-p (car arts)))))
5963 (setq arts (cdr arts)))
5968 (when (gnus-data-unread-p (car arts))
5969 (setq result (car arts)
5971 (setq arts (cdr arts)))
5974 (goto-char (gnus-data-pos result))
5975 (gnus-data-number result))))
5977 (defun gnus-summary-find-subject (subject &optional unread backward article)
5978 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5979 (article (or article (gnus-summary-article-number)))
5980 (articles (gnus-data-list backward))
5981 (arts (gnus-data-find-list article articles))
5983 (when (or (not gnus-summary-check-current)
5985 (not (gnus-data-unread-p (car arts))))
5986 (setq arts (cdr arts)))
5988 (and (or (not unread)
5989 (gnus-data-unread-p (car arts)))
5990 (vectorp (gnus-data-header (car arts)))
5992 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5993 (setq result (car arts)
5995 (setq arts (cdr arts)))
5997 (goto-char (gnus-data-pos result))
5998 (gnus-data-number result))))
6000 (defun gnus-summary-search-forward (&optional unread subject backward)
6001 "Search forward for an article.
6002 If UNREAD, look for unread articles. If SUBJECT, look for
6003 articles with that subject. If BACKWARD, search backward instead."
6004 (cond (subject (gnus-summary-find-subject subject unread backward))
6005 (backward (gnus-summary-find-prev unread))
6006 (t (gnus-summary-find-next unread))))
6008 (defun gnus-recenter (&optional n)
6009 "Center point in window and redisplay frame.
6010 Also do horizontal recentering."
6012 (when (and gnus-auto-center-summary
6013 (not (eq gnus-auto-center-summary 'vertical)))
6014 (gnus-horizontal-recenter))
6017 (defun gnus-summary-recenter ()
6018 "Center point in the summary window.
6019 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6020 displayed, no centering will be performed."
6021 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6022 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6024 (let* ((top (cond ((< (window-height) 4) 0)
6025 ((< (window-height) 7) 1)
6026 (t (if (numberp gnus-auto-center-summary)
6027 gnus-auto-center-summary
6029 (height (1- (window-height)))
6030 (bottom (save-excursion (goto-char (point-max))
6031 (forward-line (- height))
6033 (window (get-buffer-window (current-buffer))))
6034 ;; The user has to want it.
6035 (when gnus-auto-center-summary
6036 (when (get-buffer-window gnus-article-buffer)
6037 ;; Only do recentering when the article buffer is displayed,
6038 ;; Set the window start to either `bottom', which is the biggest
6039 ;; possible valid number, or the second line from the top,
6040 ;; whichever is the least.
6041 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6042 (if (> bottom top-pos)
6043 ;; Keep the second line from the top visible
6044 (set-window-start window top-pos t)
6045 ;; Try to keep the bottom line visible; if it's partially
6046 ;; obscured, either scroll one more line to make it fully
6047 ;; visible, or revert to using TOP-POS.
6049 (goto-char (point-max))
6051 (let ((last-line-start (point)))
6053 (set-window-start window (point) t)
6054 (when (not (pos-visible-in-window-p last-line-start window))
6056 (set-window-start window (min (point) top-pos) t)))))))
6057 ;; Do horizontal recentering while we're at it.
6058 (when (and (get-buffer-window (current-buffer) t)
6059 (not (eq gnus-auto-center-summary 'vertical)))
6060 (let ((selected (selected-window)))
6061 (select-window (get-buffer-window (current-buffer) t))
6062 (gnus-summary-position-point)
6063 (gnus-horizontal-recenter)
6064 (select-window selected))))))
6066 (defun gnus-summary-jump-to-group (newsgroup)
6067 "Move point to NEWSGROUP in group mode buffer."
6068 ;; Keep update point of group mode buffer if visible.
6069 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6070 (save-window-excursion
6071 ;; Take care of tree window mode.
6072 (when (get-buffer-window gnus-group-buffer)
6073 (pop-to-buffer gnus-group-buffer))
6074 (gnus-group-jump-to-group newsgroup))
6076 ;; Take care of tree window mode.
6077 (if (get-buffer-window gnus-group-buffer)
6078 (pop-to-buffer gnus-group-buffer)
6079 (set-buffer gnus-group-buffer))
6080 (gnus-group-jump-to-group newsgroup))))
6082 ;; This function returns a list of article numbers based on the
6083 ;; difference between the ranges of read articles in this group and
6084 ;; the range of active articles.
6085 (defun gnus-list-of-unread-articles (group)
6086 (let* ((read (gnus-info-read (gnus-get-info group)))
6087 (active (or (gnus-active group) (gnus-activate-group group)))
6090 ;; If none are read, then all are unread.
6092 (setq first (car active))
6093 ;; If the range of read articles is a single range, then the
6094 ;; first unread article is the article after the last read
6095 ;; article. Sounds logical, doesn't it?
6096 (if (and (not (listp (cdr read)))
6097 (or (< (car read) (car active))
6098 (progn (setq read (list read))
6100 (setq first (max (car active) (1+ (cdr read))))
6101 ;; `read' is a list of ranges.
6102 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6105 (setq first (car active)))
6108 (while (< first nlast)
6110 (setq first (1+ first))))
6111 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6112 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6113 (setq read (cdr read)))))
6114 ;; And add the last unread articles.
6115 (while (<= first last)
6117 (setq first (1+ first)))
6118 ;; Return the list of unread articles.
6119 (delq 0 (nreverse unread))))
6121 (defun gnus-list-of-read-articles (group)
6122 "Return a list of unread, unticked and non-dormant articles."
6123 (let* ((info (gnus-get-info group))
6124 (marked (gnus-info-marks info))
6125 (active (gnus-active group)))
6127 (gnus-list-range-difference
6128 (gnus-list-range-difference
6129 (gnus-sorted-complement
6130 (gnus-uncompress-range active)
6131 (gnus-list-of-unread-articles group))
6132 (cdr (assq 'dormant marked)))
6133 (cdr (assq 'tick marked))))))
6135 ;; Various summary commands
6137 (defun gnus-summary-select-article-buffer ()
6138 "Reconfigure windows to show article buffer."
6140 (if (not (gnus-buffer-live-p gnus-article-buffer))
6141 (error "There is no article buffer for this summary buffer")
6142 (gnus-configure-windows 'article)
6143 (select-window (get-buffer-window gnus-article-buffer))))
6145 (defun gnus-summary-universal-argument (arg)
6146 "Perform any operation on all articles that are process/prefixed."
6148 (let ((articles (gnus-summary-work-articles arg))
6155 (substitute-command-keys
6156 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6158 (gnus-error 1 "Undefined key")
6161 (gnus-summary-goto-subject (setq article (pop articles)))
6162 (let (gnus-newsgroup-processable)
6163 (command-execute func))
6164 (gnus-summary-remove-process-mark article)))))
6165 (gnus-summary-position-point))
6167 (defun gnus-summary-toggle-truncation (&optional arg)
6168 "Toggle truncation of summary lines.
6169 With arg, turn line truncation on if arg is positive."
6171 (setq truncate-lines
6172 (if (null arg) (not truncate-lines)
6173 (> (prefix-numeric-value arg) 0)))
6176 (defun gnus-summary-find-uncancelled ()
6177 "Return the number of an uncancelled article.
6178 The current article is considered, then following articles, then previous
6179 articles. If all articles are cancelled then return a dummy 0."
6181 (dolist (rev '(nil t))
6182 (unless found ; don't demand the reverse list if we don't need it
6183 (let ((data (gnus-data-find-list
6184 (gnus-summary-article-number) (gnus-data-list rev))))
6185 (while (and data (not found))
6186 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6187 (setq found (gnus-data-number (car data))))
6188 (setq data (cdr data))))))
6191 (defun gnus-summary-reselect-current-group (&optional all rescan)
6192 "Exit and then reselect the current newsgroup.
6193 The prefix argument ALL means to select all articles."
6195 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6196 (error "Ephemeral groups can't be reselected"))
6197 (let ((current-subject (gnus-summary-find-uncancelled))
6198 (group gnus-newsgroup-name))
6199 (setq gnus-newsgroup-begin nil)
6201 ;; We have to adjust the point of group mode buffer because
6202 ;; point was moved to the next unread newsgroup by exiting.
6203 (gnus-summary-jump-to-group group)
6206 (gnus-group-get-new-news-this-group 1)))
6207 (gnus-group-read-group all t)
6208 (gnus-summary-goto-subject current-subject nil t)))
6210 (defun gnus-summary-rescan-group (&optional all)
6211 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6213 (gnus-summary-reselect-current-group all t))
6215 (defun gnus-summary-update-info (&optional non-destructive)
6217 (let ((group gnus-newsgroup-name))
6219 (when gnus-newsgroup-kill-headers
6220 (setq gnus-newsgroup-killed
6221 (gnus-compress-sequence
6223 (gnus-list-range-intersection
6224 gnus-newsgroup-unselected gnus-newsgroup-killed)
6225 gnus-newsgroup-unreads)
6227 (unless (listp (cdr gnus-newsgroup-killed))
6228 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6229 (let ((headers gnus-newsgroup-headers))
6230 ;; Set the new ranges of read articles.
6232 (set-buffer gnus-group-buffer)
6233 (gnus-undo-force-boundary))
6234 (gnus-update-read-articles
6235 group (gnus-sorted-union
6236 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6237 ;; Set the current article marks.
6238 (let ((gnus-newsgroup-scored
6239 (if (and (not gnus-save-score)
6240 (not non-destructive))
6242 gnus-newsgroup-scored)))
6244 (gnus-update-marks)))
6245 ;; Do the cross-ref thing.
6246 (when gnus-use-cross-reference
6247 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6248 ;; Do not switch windows but change the buffer to work.
6249 (set-buffer gnus-group-buffer)
6250 (unless (gnus-ephemeral-group-p group)
6251 (gnus-group-update-group group)))))))
6253 (defun gnus-summary-save-newsrc (&optional force)
6254 "Save the current number of read/marked articles in the dribble buffer.
6255 The dribble buffer will then be saved.
6256 If FORCE (the prefix), also save the .newsrc file(s)."
6258 (gnus-summary-update-info t)
6260 (gnus-save-newsrc-file)
6261 (gnus-dribble-save)))
6263 (defun gnus-summary-exit (&optional temporary)
6264 "Exit reading current newsgroup, and then return to group selection mode.
6265 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6267 (gnus-set-global-variables)
6268 (when (gnus-buffer-live-p gnus-article-buffer)
6270 (set-buffer gnus-article-buffer)
6271 (mm-destroy-parts gnus-article-mime-handles)
6272 ;; Set it to nil for safety reason.
6273 (setq gnus-article-mime-handle-alist nil)
6274 (setq gnus-article-mime-handles nil)))
6275 (gnus-kill-save-kill-buffer)
6276 (gnus-async-halt-prefetch)
6277 (let* ((group gnus-newsgroup-name)
6278 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6281 (buf (current-buffer)))
6283 ;; Do adaptive scoring, and possibly save score files.
6284 (when gnus-newsgroup-adaptive
6285 (gnus-score-adaptive))
6286 (when gnus-use-scoring
6288 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6289 ;; If we have several article buffers, we kill them at exit.
6290 (unless gnus-single-article-buffer
6291 (gnus-kill-buffer gnus-original-article-buffer)
6292 (setq gnus-article-current nil))
6293 (when gnus-use-cache
6294 (gnus-cache-possibly-remove-articles)
6295 (gnus-cache-save-buffers))
6296 (gnus-async-prefetch-remove-group group)
6297 (when gnus-suppress-duplicates
6298 (gnus-dup-enter-articles))
6299 (when gnus-use-trees
6300 (gnus-tree-close group))
6301 (when gnus-use-cache
6302 (gnus-cache-write-active))
6303 ;; Remove entries for this group.
6304 (nnmail-purge-split-history (gnus-group-real-name group))
6305 ;; Make all changes in this group permanent.
6307 (gnus-run-hooks 'gnus-exit-group-hook)
6308 (gnus-summary-update-info))
6309 (gnus-close-group group)
6310 ;; Make sure where we were, and go to next newsgroup.
6311 (set-buffer gnus-group-buffer)
6313 (gnus-group-jump-to-group group))
6314 (gnus-run-hooks 'gnus-summary-exit-hook)
6315 (unless (or quit-config
6316 ;; If this group has disappeared from the summary
6317 ;; buffer, don't skip forwards.
6318 (not (string= group (gnus-group-group-name))))
6319 (gnus-group-next-unread-group 1))
6320 (setq group-point (point))
6323 ;; If we have several article buffers, we kill them at exit.
6324 (unless gnus-single-article-buffer
6325 (gnus-kill-buffer gnus-article-buffer)
6326 (gnus-kill-buffer gnus-original-article-buffer)
6327 (setq gnus-article-current nil))
6329 (if (not gnus-kill-summary-on-exit)
6331 (gnus-deaden-summary)
6333 ;; We set all buffer-local variables to nil. It is unclear why
6334 ;; this is needed, but if we don't, buffer-local variables are
6335 ;; not garbage-collected, it seems. This would the lead to en
6336 ;; ever-growing Emacs.
6337 (gnus-summary-clear-local-variables)
6338 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6339 (gnus-summary-clear-local-variables))
6340 (when (get-buffer gnus-article-buffer)
6341 (bury-buffer gnus-article-buffer))
6342 ;; We clear the global counterparts of the buffer-local
6343 ;; variables as well, just to be on the safe side.
6344 (set-buffer gnus-group-buffer)
6345 (gnus-summary-clear-local-variables)
6346 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6347 (gnus-summary-clear-local-variables)))
6348 (setq gnus-current-select-method gnus-select-method)
6349 (pop-to-buffer gnus-group-buffer)
6350 (if (not quit-config)
6352 (goto-char group-point)
6353 (gnus-configure-windows 'group 'force))
6354 (gnus-handle-ephemeral-exit quit-config))
6355 ;; Return to group mode buffer.
6356 (when (eq mode 'gnus-summary-mode)
6357 (gnus-kill-buffer buf))
6358 ;; Clear the current group name.
6360 (setq gnus-newsgroup-name nil)))))
6362 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6363 (defun gnus-summary-exit-no-update (&optional no-questions)
6364 "Quit reading current newsgroup without updating read article info."
6366 (let* ((group gnus-newsgroup-name)
6367 (quit-config (gnus-group-quit-config group)))
6368 (when (or no-questions
6370 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6371 (gnus-async-halt-prefetch)
6373 (delq 'gnus-summary-expire-articles
6374 (copy-sequence gnus-summary-prepare-exit-hook)))
6375 (when (gnus-buffer-live-p gnus-article-buffer)
6377 (set-buffer gnus-article-buffer)
6378 (mm-destroy-parts gnus-article-mime-handles)
6379 ;; Set it to nil for safety reason.
6380 (setq gnus-article-mime-handle-alist nil)
6381 (setq gnus-article-mime-handles nil)))
6382 ;; If we have several article buffers, we kill them at exit.
6383 (unless gnus-single-article-buffer
6384 (gnus-kill-buffer gnus-article-buffer)
6385 (gnus-kill-buffer gnus-original-article-buffer)
6386 (setq gnus-article-current nil))
6387 (if (not gnus-kill-summary-on-exit)
6388 (gnus-deaden-summary)
6389 (gnus-close-group group)
6390 (gnus-summary-clear-local-variables)
6391 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6392 (gnus-summary-clear-local-variables))
6393 (set-buffer gnus-group-buffer)
6394 (gnus-summary-clear-local-variables)
6395 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6396 (gnus-summary-clear-local-variables))
6397 (when (get-buffer gnus-summary-buffer)
6398 (kill-buffer gnus-summary-buffer)))
6399 (unless gnus-single-article-buffer
6400 (setq gnus-article-current nil))
6401 (when gnus-use-trees
6402 (gnus-tree-close group))
6403 (gnus-async-prefetch-remove-group group)
6404 (when (get-buffer gnus-article-buffer)
6405 (bury-buffer gnus-article-buffer))
6406 ;; Return to the group buffer.
6407 (gnus-configure-windows 'group 'force)
6408 ;; Clear the current group name.
6409 (setq gnus-newsgroup-name nil)
6410 (when (equal (gnus-group-group-name) group)
6411 (gnus-group-next-unread-group 1))
6413 (gnus-handle-ephemeral-exit quit-config)))))
6415 (defun gnus-handle-ephemeral-exit (quit-config)
6416 "Handle movement when leaving an ephemeral group.
6417 The state which existed when entering the ephemeral is reset."
6418 (if (not (buffer-name (car quit-config)))
6419 (gnus-configure-windows 'group 'force)
6420 (set-buffer (car quit-config))
6421 (cond ((eq major-mode 'gnus-summary-mode)
6422 (gnus-set-global-variables))
6423 ((eq major-mode 'gnus-article-mode)
6425 ;; The `gnus-summary-buffer' variable may point
6426 ;; to the old summary buffer when using a single
6428 (unless (gnus-buffer-live-p gnus-summary-buffer)
6429 (set-buffer gnus-group-buffer))
6430 (set-buffer gnus-summary-buffer)
6431 (gnus-set-global-variables))))
6432 (if (or (eq (cdr quit-config) 'article)
6433 (eq (cdr quit-config) 'pick))
6435 ;; The current article may be from the ephemeral group
6436 ;; thus it is best that we reload this article
6437 (gnus-summary-show-article)
6438 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6439 (gnus-configure-windows 'pick 'force)
6440 (gnus-configure-windows (cdr quit-config) 'force)))
6441 (gnus-configure-windows (cdr quit-config) 'force))
6442 (when (eq major-mode 'gnus-summary-mode)
6443 (gnus-summary-next-subject 1 nil t)
6444 (gnus-summary-recenter)
6445 (gnus-summary-position-point))))
6449 (defvar gnus-dead-summary-mode-map nil)
6451 (unless gnus-dead-summary-mode-map
6452 (setq gnus-dead-summary-mode-map (make-keymap))
6453 (suppress-keymap gnus-dead-summary-mode-map)
6454 (substitute-key-definition
6455 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6456 (dolist (key '("\C-d" "\r" "\177" [delete]))
6457 (define-key gnus-dead-summary-mode-map
6458 key 'gnus-summary-wake-up-the-dead))
6459 (dolist (key '("q" "Q"))
6460 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6462 (defvar gnus-dead-summary-mode nil
6463 "Minor mode for Gnus summary buffers.")
6465 (defun gnus-dead-summary-mode (&optional arg)
6466 "Minor mode for Gnus summary buffers."
6468 (when (eq major-mode 'gnus-summary-mode)
6469 (make-local-variable 'gnus-dead-summary-mode)
6470 (setq gnus-dead-summary-mode
6471 (if (null arg) (not gnus-dead-summary-mode)
6472 (> (prefix-numeric-value arg) 0)))
6473 (when gnus-dead-summary-mode
6474 (gnus-add-minor-mode
6475 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6477 (defun gnus-deaden-summary ()
6478 "Make the current summary buffer into a dead summary buffer."
6479 ;; Kill any previous dead summary buffer.
6480 (when (and gnus-dead-summary
6481 (buffer-name gnus-dead-summary))
6483 (set-buffer gnus-dead-summary)
6484 (when gnus-dead-summary-mode
6485 (kill-buffer (current-buffer)))))
6486 ;; Make this the current dead summary.
6487 (setq gnus-dead-summary (current-buffer))
6488 (gnus-dead-summary-mode 1)
6489 (let ((name (buffer-name)))
6490 (when (string-match "Summary" name)
6492 (concat (substring name 0 (match-beginning 0)) "Dead "
6493 (substring name (match-beginning 0)))
6497 (defun gnus-kill-or-deaden-summary (buffer)
6498 "Kill or deaden the summary BUFFER."
6500 (when (and (buffer-name buffer)
6501 (not gnus-single-article-buffer))
6504 (gnus-kill-buffer gnus-article-buffer)
6505 (gnus-kill-buffer gnus-original-article-buffer)))
6508 (gnus-kill-summary-on-exit
6509 (when (and gnus-use-trees
6510 (gnus-buffer-exists-p buffer))
6513 (gnus-tree-close gnus-newsgroup-name)))
6514 (gnus-kill-buffer buffer))
6515 ;; Deaden the buffer.
6516 ((gnus-buffer-exists-p buffer)
6519 (gnus-deaden-summary))))))
6521 (defun gnus-summary-wake-up-the-dead (&rest args)
6522 "Wake up the dead summary buffer."
6524 (gnus-dead-summary-mode -1)
6525 (let ((name (buffer-name)))
6526 (when (string-match "Dead " name)
6528 (concat (substring name 0 (match-beginning 0))
6529 (substring name (match-end 0)))
6531 (gnus-message 3 "This dead summary is now alive again"))
6533 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6534 (defun gnus-summary-fetch-faq (&optional faq-dir)
6535 "Fetch the FAQ for the current group.
6536 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6540 (when current-prefix-arg
6542 "FAQ dir: " (and (listp gnus-group-faq-directory)
6543 (mapcar (lambda (file) (list file))
6544 gnus-group-faq-directory))))))
6545 (let (gnus-faq-buffer)
6546 (when (setq gnus-faq-buffer
6547 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6548 (gnus-configure-windows 'summary-faq))))
6550 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6551 (defun gnus-summary-describe-group (&optional force)
6552 "Describe the current newsgroup."
6554 (gnus-group-describe-group force gnus-newsgroup-name))
6556 (defun gnus-summary-describe-briefly ()
6557 "Describe summary mode commands briefly."
6559 (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")))
6561 ;; Walking around group mode buffer from summary mode.
6563 (defun gnus-summary-next-group (&optional no-article target-group backward)
6564 "Exit current newsgroup and then select next unread newsgroup.
6565 If prefix argument NO-ARTICLE is non-nil, no article is selected
6566 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6567 previous group instead."
6569 ;; Stop pre-fetching.
6570 (gnus-async-halt-prefetch)
6571 (let ((current-group gnus-newsgroup-name)
6572 (current-buffer (current-buffer))
6574 (while (not entered)
6575 ;; Then we find what group we are supposed to enter.
6576 (set-buffer gnus-group-buffer)
6577 (gnus-group-jump-to-group current-group)
6580 (if (eq gnus-keep-same-level 'best)
6581 (gnus-summary-best-group gnus-newsgroup-name)
6582 (gnus-summary-search-group backward gnus-keep-same-level))))
6583 (if (not target-group)
6584 ;; There are no further groups, so we return to the group
6587 (gnus-message 5 "Returning to the group buffer")
6589 (when (gnus-buffer-live-p current-buffer)
6590 (set-buffer current-buffer)
6591 (gnus-summary-exit))
6592 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6593 ;; We try to enter the target group.
6594 (gnus-group-jump-to-group target-group)
6595 (let ((unreads (gnus-group-group-unread)))
6596 (if (and (or (eq t unreads)
6597 (and unreads (not (zerop unreads))))
6599 ;; Now we semi-exit this group to update Xrefs
6600 ;; and all variables. We can't do a real exit,
6601 ;; because the window conf must remain the same
6602 ;; in case the user is prompted for info, and we
6603 ;; don't want the window conf to change before
6605 (when (gnus-buffer-live-p current-buffer)
6606 (set-buffer current-buffer)
6607 (gnus-summary-exit t))
6608 (gnus-summary-read-group
6609 target-group nil no-article
6610 (and (buffer-name current-buffer) current-buffer)
6613 (setq current-group target-group
6614 target-group nil)))))))
6616 (defun gnus-summary-prev-group (&optional no-article)
6617 "Exit current newsgroup and then select previous unread newsgroup.
6618 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6620 (gnus-summary-next-group no-article nil t))
6622 ;; Walking around summary lines.
6624 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6625 "Go to the first unread subject.
6626 If UNREAD is non-nil, go to the first unread article.
6627 Returns the article selected or nil if there are no unread articles."
6632 ((null gnus-newsgroup-data)
6633 (gnus-message 3 "No articles in the group")
6635 ;; Pick the first article.
6637 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6638 (gnus-data-number (car gnus-newsgroup-data)))
6639 ;; No unread articles.
6640 ((null gnus-newsgroup-unreads)
6641 (gnus-message 3 "No more unread articles")
6643 ;; Find the first unread article.
6645 (let ((data gnus-newsgroup-data))
6647 (and (not (and undownloaded
6648 (memq (car data) gnus-newsgroup-undownloaded)))
6651 (gnus-data-number (car data))
6652 gnus-newsgroup-unseen))
6653 (not (gnus-data-unread-p (car data))))
6654 (not (gnus-data-unread-p (car data))))))
6655 (setq data (cdr data)))
6657 (goto-char (gnus-data-pos (car data)))
6658 (gnus-data-number (car data))))))
6659 (gnus-summary-position-point)))
6661 (defun gnus-summary-next-subject (n &optional unread dont-display)
6662 "Go to next N'th summary line.
6663 If N is negative, go to the previous N'th subject line.
6664 If UNREAD is non-nil, only unread articles are selected.
6665 The difference between N and the actual number of steps taken is
6668 (let ((backward (< n 0))
6672 (gnus-summary-find-prev unread)
6673 (gnus-summary-find-next unread)))
6674 (unless (zerop (setq n (1- n)))
6675 (gnus-summary-show-thread)))
6677 (gnus-message 7 "No more%s articles"
6678 (if unread " unread" "")))
6679 (unless dont-display
6680 (gnus-summary-recenter)
6681 (gnus-summary-position-point))
6684 (defun gnus-summary-next-unread-subject (n)
6685 "Go to next N'th unread summary line."
6687 (gnus-summary-next-subject n t))
6689 (defun gnus-summary-prev-subject (n &optional unread)
6690 "Go to previous N'th summary line.
6691 If optional argument UNREAD is non-nil, only unread article is selected."
6693 (gnus-summary-next-subject (- n) unread))
6695 (defun gnus-summary-prev-unread-subject (n)
6696 "Go to previous N'th unread summary line."
6698 (gnus-summary-next-subject (- n) t))
6700 (defun gnus-summary-goto-subject (article &optional force silent)
6701 "Go the subject line of ARTICLE.
6702 If FORCE, also allow jumping to articles not currently shown."
6703 (interactive "nArticle number: ")
6704 (unless (numberp article)
6705 (error "Article %s is not a number" article))
6707 (data (gnus-data-find article)))
6708 ;; We read in the article if we have to.
6711 (gnus-summary-insert-subject
6713 (if (or (numberp force) (vectorp force)) force)
6715 (setq data (gnus-data-find article)))
6720 (gnus-message 3 "Can't find article %d" article))
6722 (let ((pt (gnus-data-pos data)))
6724 (gnus-summary-set-article-display-arrow pt))
6725 (gnus-summary-position-point)
6728 ;; Walking around summary lines with displaying articles.
6730 (defun gnus-summary-expand-window (&optional arg)
6731 "Make the summary buffer take up the entire Emacs frame.
6732 Given a prefix, will force an `article' buffer configuration."
6735 (gnus-configure-windows 'article 'force)
6736 (gnus-configure-windows 'summary 'force)))
6738 (defun gnus-summary-display-article (article &optional all-header)
6739 "Display ARTICLE in article buffer."
6740 (when (gnus-buffer-live-p gnus-article-buffer)
6741 (with-current-buffer gnus-article-buffer
6742 (mm-enable-multibyte)))
6743 (gnus-set-global-variables)
6744 (when (gnus-buffer-live-p gnus-article-buffer)
6745 (with-current-buffer gnus-article-buffer
6746 (setq gnus-article-charset gnus-newsgroup-charset)
6747 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6748 (mm-enable-multibyte)))
6752 (if gnus-summary-display-article-function
6753 (funcall gnus-summary-display-article-function article all-header)
6754 (gnus-article-prepare article all-header))
6755 (gnus-run-hooks 'gnus-select-article-hook)
6756 (when (and gnus-current-article
6757 (not (zerop gnus-current-article)))
6758 (gnus-summary-goto-subject gnus-current-article))
6759 (gnus-summary-recenter)
6760 (when (and gnus-use-trees gnus-show-threads)
6761 (gnus-possibly-generate-tree article)
6762 (gnus-highlight-selected-tree article))
6763 ;; Successfully display article.
6764 (gnus-article-set-window-start
6765 (cdr (assq article gnus-newsgroup-bookmarks))))))
6767 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6768 "Select the current article.
6769 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6770 non-nil, the article will be re-fetched even if it already present in
6771 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6773 ;; Make sure we are in the summary buffer to work around bbdb bug.
6774 (unless (eq major-mode 'gnus-summary-mode)
6775 (set-buffer gnus-summary-buffer))
6776 (let ((article (or article (gnus-summary-article-number)))
6777 (all-headers (not (not all-headers))) ;Must be t or nil.
6778 gnus-summary-display-article-function)
6780 (gnus-summary-article-pseudo-p article)
6781 (error "This is a pseudo-article"))
6783 (set-buffer gnus-summary-buffer)
6784 (if (or (and gnus-single-article-buffer
6785 (or (null gnus-current-article)
6786 (null gnus-article-current)
6787 (null (get-buffer gnus-article-buffer))
6788 (not (eq article (cdr gnus-article-current)))
6789 (not (equal (car gnus-article-current)
6790 gnus-newsgroup-name))))
6791 (and (not gnus-single-article-buffer)
6792 (or (null gnus-current-article)
6793 (not (eq gnus-current-article article))))
6795 ;; The requested article is different from the current article.
6797 (gnus-summary-display-article article all-headers)
6798 (when (gnus-buffer-live-p gnus-article-buffer)
6799 (with-current-buffer gnus-article-buffer
6800 (if (not gnus-article-decoded-p) ;; a local variable
6801 (mm-disable-multibyte))))
6802 (gnus-article-set-window-start
6803 (cdr (assq article gnus-newsgroup-bookmarks)))
6807 (defun gnus-summary-force-verify-and-decrypt ()
6809 (let ((mm-verify-option 'known)
6810 (mm-decrypt-option 'known)
6811 (gnus-buttonized-mime-types (append (list "multipart/signed"
6812 "multipart/encrypted")
6813 gnus-buttonized-mime-types)))
6814 (gnus-summary-select-article nil 'force)))
6816 (defun gnus-summary-set-current-mark (&optional current-mark)
6817 "Obsolete function."
6820 (defun gnus-summary-next-article (&optional unread subject backward push)
6821 "Select the next article.
6822 If UNREAD, only unread articles are selected.
6823 If SUBJECT, only articles with SUBJECT are selected.
6824 If BACKWARD, the previous article is selected instead of the next."
6827 ;; Is there such an article?
6828 ((and (gnus-summary-search-forward unread subject backward)
6829 (or (gnus-summary-display-article (gnus-summary-article-number))
6830 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6831 (gnus-summary-position-point))
6832 ;; If not, we try the first unread, if that is wanted.
6834 gnus-auto-select-same
6835 (gnus-summary-first-unread-article))
6836 (gnus-summary-position-point)
6837 (gnus-message 6 "Wrapped"))
6838 ;; Try to get next/previous article not displayed in this group.
6839 ((and gnus-auto-extend-newsgroup
6840 (not unread) (not subject))
6841 (gnus-summary-goto-article
6842 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6843 nil (count-lines (point-min) (point))))
6844 ;; Go to next/previous group.
6846 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6847 (gnus-summary-jump-to-group gnus-newsgroup-name))
6848 (let ((cmd last-command-char)
6851 (set-buffer gnus-group-buffer)
6854 (if (eq gnus-keep-same-level 'best)
6855 (gnus-summary-best-group gnus-newsgroup-name)
6856 (gnus-summary-search-group backward gnus-keep-same-level))))
6857 ;; For some reason, the group window gets selected. We change
6859 (select-window (get-buffer-window (current-buffer)))
6860 ;; Select next unread newsgroup automagically.
6862 ((or (not gnus-auto-select-next)
6864 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6865 ((or (eq gnus-auto-select-next 'quietly)
6866 (and (eq gnus-auto-select-next 'slightly-quietly)
6868 (and (eq gnus-auto-select-next 'almost-quietly)
6869 (gnus-summary-last-article-p)))
6871 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6873 (gnus-message 7 "No more%s articles (%s)..."
6874 (if unread " unread" "")
6875 (if group (concat "selecting " group)
6877 (gnus-summary-next-group nil group backward)))
6879 (when (gnus-key-press-event-p last-input-event)
6880 (gnus-summary-walk-group-buffer
6881 gnus-newsgroup-name cmd unread backward point))))))))
6883 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6884 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6885 (?\C-p (gnus-group-prev-unread-group 1))))
6886 (cursor-in-echo-area t)
6887 keve key group ended)
6889 (set-buffer gnus-group-buffer)
6892 (if (eq gnus-keep-same-level 'best)
6893 (gnus-summary-best-group gnus-newsgroup-name)
6894 (gnus-summary-search-group backward gnus-keep-same-level))))
6897 5 "No more%s articles%s" (if unread " unread" "")
6899 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6900 (format " (Type %s for %s [%s])"
6901 (single-key-description cmd) group
6902 (car (gnus-gethash group gnus-newsrc-hashtb)))
6903 (format " (Type %s to exit %s)"
6904 (single-key-description cmd)
6905 gnus-newsgroup-name)))
6906 ;; Confirm auto selection.
6907 (setq key (car (setq keve (gnus-read-event-char))))
6910 ((assq key keystrokes)
6911 (let ((obuf (current-buffer)))
6912 (switch-to-buffer gnus-group-buffer)
6914 (gnus-group-jump-to-group group))
6915 (eval (cadr (assq key keystrokes)))
6916 (setq group (gnus-group-group-name))
6917 (switch-to-buffer obuf))
6921 (gnus-ephemeral-group-p gnus-newsgroup-name))
6923 (gnus-summary-next-group nil group backward)))
6925 (push (cdr keve) unread-command-events))))))
6927 (defun gnus-summary-next-unread-article ()
6928 "Select unread article after current one."
6930 (gnus-summary-next-article
6931 (or (not (eq gnus-summary-goto-unread 'never))
6932 (gnus-summary-last-article-p (gnus-summary-article-number)))
6933 (and gnus-auto-select-same
6934 (gnus-summary-article-subject))))
6936 (defun gnus-summary-prev-article (&optional unread subject)
6937 "Select the article after the current one.
6938 If UNREAD is non-nil, only unread articles are selected."
6940 (gnus-summary-next-article unread subject t))
6942 (defun gnus-summary-prev-unread-article ()
6943 "Select unread article before current one."
6945 (gnus-summary-prev-article
6946 (or (not (eq gnus-summary-goto-unread 'never))
6947 (gnus-summary-first-article-p (gnus-summary-article-number)))
6948 (and gnus-auto-select-same
6949 (gnus-summary-article-subject))))
6951 (defun gnus-summary-next-page (&optional lines circular)
6952 "Show next page of the selected article.
6953 If at the end of the current article, select the next article.
6954 LINES says how many lines should be scrolled up.
6956 If CIRCULAR is non-nil, go to the start of the article instead of
6957 selecting the next article when reaching the end of the current
6960 (setq gnus-summary-buffer (current-buffer))
6961 (gnus-set-global-variables)
6962 (let ((article (gnus-summary-article-number))
6963 (article-window (get-buffer-window gnus-article-buffer t))
6965 ;; If the buffer is empty, we have no article.
6967 (error "No article to select"))
6968 (gnus-configure-windows 'article)
6969 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6970 (if (and (eq gnus-summary-goto-unread 'never)
6971 (not (gnus-summary-last-article-p article)))
6972 (gnus-summary-next-article)
6973 (gnus-summary-next-unread-article))
6974 (if (or (null gnus-current-article)
6975 (null gnus-article-current)
6976 (/= article (cdr gnus-article-current))
6977 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6978 ;; Selected subject is different from current article's.
6979 (gnus-summary-display-article article)
6980 (when article-window
6981 (gnus-eval-in-buffer-window gnus-article-buffer
6982 (setq endp (gnus-article-next-page lines)))
6985 (gnus-summary-beginning-of-article))
6987 (gnus-message 3 "End of message"))
6989 (if (and (eq gnus-summary-goto-unread 'never)
6990 (not (gnus-summary-last-article-p article)))
6991 (gnus-summary-next-article)
6992 (gnus-summary-next-unread-article))))))))
6993 (gnus-summary-recenter)
6994 (gnus-summary-position-point)))
6996 (defun gnus-summary-prev-page (&optional lines move)
6997 "Show previous page of selected article.
6998 Argument LINES specifies lines to be scrolled down.
6999 If MOVE, move to the previous unread article if point is at
7000 the beginning of the buffer."
7002 (let ((article (gnus-summary-article-number))
7003 (article-window (get-buffer-window gnus-article-buffer t))
7005 (gnus-configure-windows 'article)
7006 (if (or (null gnus-current-article)
7007 (null gnus-article-current)
7008 (/= article (cdr gnus-article-current))
7009 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7010 ;; Selected subject is different from current article's.
7011 (gnus-summary-display-article article)
7012 (gnus-summary-recenter)
7013 (when article-window
7014 (gnus-eval-in-buffer-window gnus-article-buffer
7015 (setq endp (gnus-article-prev-page lines)))
7016 (when (and move endp)
7018 (gnus-message 3 "Beginning of message"))
7020 (if (and (eq gnus-summary-goto-unread 'never)
7021 (not (gnus-summary-first-article-p article)))
7022 (gnus-summary-prev-article)
7023 (gnus-summary-prev-unread-article))))))))
7024 (gnus-summary-position-point))
7026 (defun gnus-summary-prev-page-or-article (&optional lines)
7027 "Show previous page of selected article.
7028 Argument LINES specifies lines to be scrolled down.
7029 If at the beginning of the article, go to the next article."
7031 (gnus-summary-prev-page lines t))
7033 (defun gnus-summary-scroll-up (lines)
7034 "Scroll up (or down) one line current article.
7035 Argument LINES specifies lines to be scrolled up (or down if negative)."
7037 (gnus-configure-windows 'article)
7038 (gnus-summary-show-thread)
7039 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7040 (gnus-eval-in-buffer-window gnus-article-buffer
7042 (when (gnus-article-next-page lines)
7043 (gnus-message 3 "End of message")))
7045 (gnus-article-prev-page (- lines))))))
7046 (gnus-summary-recenter)
7047 (gnus-summary-position-point))
7049 (defun gnus-summary-scroll-down (lines)
7050 "Scroll down (or up) one line current article.
7051 Argument LINES specifies lines to be scrolled down (or up if negative)."
7053 (gnus-summary-scroll-up (- lines)))
7055 (defun gnus-summary-next-same-subject ()
7056 "Select next article which has the same subject as current one."
7058 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7060 (defun gnus-summary-prev-same-subject ()
7061 "Select previous article which has the same subject as current one."
7063 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7065 (defun gnus-summary-next-unread-same-subject ()
7066 "Select next unread article which has the same subject as current one."
7068 (gnus-summary-next-article t (gnus-summary-article-subject)))
7070 (defun gnus-summary-prev-unread-same-subject ()
7071 "Select previous unread article which has the same subject as current one."
7073 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7075 (defun gnus-summary-first-unread-article ()
7076 "Select the first unread article.
7077 Return nil if there are no unread articles."
7080 (when (gnus-summary-first-subject t)
7081 (gnus-summary-show-thread)
7082 (gnus-summary-first-subject t)
7083 (gnus-summary-display-article (gnus-summary-article-number)))
7084 (gnus-summary-position-point)))
7086 (defun gnus-summary-first-unread-subject ()
7087 "Place the point on the subject line of the first unread article.
7088 Return nil if there are no unread articles."
7091 (when (gnus-summary-first-subject t)
7092 (gnus-summary-show-thread)
7093 (gnus-summary-first-subject t))
7094 (gnus-summary-position-point)))
7096 (defun gnus-summary-first-unseen-subject ()
7097 "Place the point on the subject line of the first unseen article.
7098 Return nil if there are no unseen articles."
7101 (when (gnus-summary-first-subject t t t)
7102 (gnus-summary-show-thread)
7103 (gnus-summary-first-subject t t t))
7104 (gnus-summary-position-point)))
7106 (defun gnus-summary-first-unseen-or-unread-subject ()
7107 "Place the point on the subject line of the first unseen article.
7108 Return nil if there are no unseen articles."
7111 (unless (when (gnus-summary-first-subject t t t)
7112 (gnus-summary-show-thread)
7113 (gnus-summary-first-subject t t t))
7114 (when (gnus-summary-first-subject t)
7115 (gnus-summary-show-thread)
7116 (gnus-summary-first-subject t)))
7117 (gnus-summary-position-point)))
7119 (defun gnus-summary-first-article ()
7120 "Select the first article.
7121 Return nil if there are no articles."
7124 (when (gnus-summary-first-subject)
7125 (gnus-summary-show-thread)
7126 (gnus-summary-first-subject)
7127 (gnus-summary-display-article (gnus-summary-article-number)))
7128 (gnus-summary-position-point)))
7130 (defun gnus-summary-best-unread-article (&optional arg)
7131 "Select the unread article with the highest score.
7132 If given a prefix argument, select the next unread article that has a
7133 score higher than the default score."
7135 (let ((article (if arg
7136 (gnus-summary-better-unread-subject)
7137 (gnus-summary-best-unread-subject))))
7139 (gnus-summary-goto-article article)
7140 (error "No unread articles"))))
7142 (defun gnus-summary-best-unread-subject ()
7143 "Select the unread subject with the highest score."
7145 (let ((best -1000000)
7146 (data gnus-newsgroup-data)
7149 (and (gnus-data-unread-p (car data))
7151 (gnus-summary-article-score (gnus-data-number (car data))))
7154 article (gnus-data-number (car data))))
7155 (setq data (cdr data)))
7157 (gnus-summary-goto-subject article))
7158 (gnus-summary-position-point)
7161 (defun gnus-summary-better-unread-subject ()
7162 "Select the first unread subject that has a score over the default score."
7164 (let ((data gnus-newsgroup-data)
7166 (while (and (setq article (gnus-data-number (car data)))
7167 (or (gnus-data-read-p (car data))
7168 (not (> (gnus-summary-article-score article)
7169 gnus-summary-default-score))))
7170 (setq data (cdr data)))
7172 (gnus-summary-goto-subject article))
7173 (gnus-summary-position-point)
7176 (defun gnus-summary-last-subject ()
7177 "Go to the last displayed subject line in the group."
7178 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7180 (gnus-summary-goto-subject article))))
7182 (defun gnus-summary-goto-article (article &optional all-headers force)
7183 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7184 If ALL-HEADERS is non-nil, no header lines are hidden.
7185 If FORCE, go to the article even if it isn't displayed. If FORCE
7186 is a number, it is the line the article is to be displayed on."
7190 "Article number or Message-ID: "
7191 (mapcar (lambda (number) (list (int-to-string number)))
7192 gnus-newsgroup-limit))
7196 (if (and (stringp article)
7197 (string-match "@" article))
7198 (gnus-summary-refer-article article)
7199 (when (stringp article)
7200 (setq article (string-to-number article)))
7201 (if (gnus-summary-goto-subject article force)
7202 (gnus-summary-display-article article all-headers)
7203 (gnus-message 4 "Couldn't go to article %s" article) nil))
7204 (gnus-summary-position-point)))
7206 (defun gnus-summary-goto-last-article ()
7207 "Go to the previously read article."
7210 (when gnus-last-article
7211 (gnus-summary-goto-article gnus-last-article nil t))
7212 (gnus-summary-position-point)))
7214 (defun gnus-summary-pop-article (number)
7215 "Pop one article off the history and go to the previous.
7216 NUMBER articles will be popped off."
7219 (setq gnus-newsgroup-history
7220 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7222 (gnus-summary-goto-article (car to) nil t)
7223 (error "Article history empty")))
7224 (gnus-summary-position-point))
7226 ;; Summary commands and functions for limiting the summary buffer.
7228 (defun gnus-summary-limit-to-articles (n)
7229 "Limit the summary buffer to the next N articles.
7230 If not given a prefix, use the process marked articles instead."
7233 (let ((articles (gnus-summary-work-articles n)))
7234 (setq gnus-newsgroup-processable nil)
7235 (gnus-summary-limit articles))
7236 (gnus-summary-position-point)))
7238 (defun gnus-summary-pop-limit (&optional total)
7239 "Restore the previous limit.
7240 If given a prefix, remove all limits."
7243 (setq gnus-newsgroup-limits
7244 (list (mapcar (lambda (h) (mail-header-number h))
7245 gnus-newsgroup-headers))))
7246 (unless gnus-newsgroup-limits
7247 (error "No limit to pop"))
7249 (gnus-summary-limit nil 'pop)
7250 (gnus-summary-position-point)))
7252 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7253 "Limit the summary buffer to articles that have subjects that match a regexp.
7254 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7256 (list (read-string (if current-prefix-arg
7257 "Exclude subject (regexp): "
7258 "Limit to subject (regexp): "))
7259 nil current-prefix-arg))
7261 (setq header "subject"))
7262 (when (not (equal "" subject))
7264 (let ((articles (gnus-summary-find-matching
7265 (or header "subject") subject 'all nil nil
7268 (error "Found no matches for \"%s\"" subject))
7269 (gnus-summary-limit articles))
7270 (gnus-summary-position-point))))
7272 (defun gnus-summary-limit-to-author (from &optional not-matching)
7273 "Limit the summary buffer to articles that have authors that match a regexp.
7274 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7276 (list (read-string (if current-prefix-arg
7277 "Exclude author (regexp): "
7278 "Limit to author (regexp): "))
7279 current-prefix-arg))
7280 (gnus-summary-limit-to-subject from "from" not-matching))
7282 (defun gnus-summary-limit-to-age (age &optional younger-p)
7283 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7284 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7285 articles that are younger than AGE days."
7287 (let ((younger current-prefix-arg)
7290 (while (not days-got)
7291 (setq days (if younger
7292 (read-string "Limit to articles within (in days): ")
7293 (read-string "Limit to articles older than (in days): ")))
7294 (when (> (length days) 0)
7295 (setq days (read days)))
7301 (setq younger (not younger))
7302 (setq days (* days -1)))))
7303 (message "Please enter a number.")
7305 (list days younger)))
7307 (let ((data gnus-newsgroup-data)
7308 (cutoff (days-to-time age))
7309 articles d date is-younger)
7310 (while (setq d (pop data))
7311 (when (and (vectorp (gnus-data-header d))
7312 (setq date (mail-header-date (gnus-data-header d))))
7313 (setq is-younger (time-less-p
7314 (time-since (condition-case ()
7321 (push (gnus-data-number d) articles))))
7322 (gnus-summary-limit (nreverse articles)))
7323 (gnus-summary-position-point)))
7325 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7326 "Limit the summary buffer to articles that match an 'extra' header."
7330 (gnus-completing-read-with-default
7331 (symbol-name (car gnus-extra-headers))
7332 (if current-prefix-arg
7333 "Exclude extra header:"
7334 "Limit extra header:")
7336 (cons (symbol-name x) x))
7341 (read-string (format "%s header %s (regexp): "
7342 (if current-prefix-arg "Exclude" "Limit to")
7344 current-prefix-arg)))
7345 (when (not (equal "" regexp))
7347 (let ((articles (gnus-summary-find-matching
7348 (cons 'extra header) regexp 'all nil nil
7351 (error "Found no matches for \"%s\"" regexp))
7352 (gnus-summary-limit articles))
7353 (gnus-summary-position-point))))
7355 (defun gnus-summary-limit-to-display-predicate ()
7356 "Limit the summary buffer to the predicated in the `display' group parameter."
7358 (unless gnus-newsgroup-display
7359 (error "There is no `display' group parameter"))
7361 (dolist (number gnus-newsgroup-articles)
7362 (when (funcall gnus-newsgroup-display)
7363 (push number articles)))
7364 (gnus-summary-limit articles))
7365 (gnus-summary-position-point))
7367 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7369 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7371 (defun gnus-summary-limit-to-unread (&optional all)
7372 "Limit the summary buffer to articles that are not marked as read.
7373 If ALL is non-nil, limit strictly to unread articles."
7376 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7377 (gnus-summary-limit-to-marks
7378 ;; Concat all the marks that say that an article is read and have
7380 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7381 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7382 gnus-low-score-mark gnus-expirable-mark
7383 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7384 gnus-duplicate-mark gnus-souped-mark)
7387 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7388 (make-obsolete 'gnus-summary-delete-marked-with
7389 'gnus-summary-limit-exclude-marks)
7391 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7392 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7393 If REVERSE, limit the summary buffer to articles that are marked
7394 with MARKS. MARKS can either be a string of marks or a list of marks.
7395 Returns how many articles were removed."
7396 (interactive "sMarks: ")
7397 (gnus-summary-limit-to-marks marks t))
7399 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7400 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7401 If REVERSE (the prefix), limit the summary buffer to articles that are
7402 not marked with MARKS. MARKS can either be a string of marks or a
7404 Returns how many articles were removed."
7405 (interactive "sMarks: \nP")
7407 (let ((data gnus-newsgroup-data)
7408 (marks (if (listp marks) marks
7409 (append marks nil))) ; Transform to list.
7412 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7413 (memq (gnus-data-mark (car data)) marks))
7414 (push (gnus-data-number (car data)) articles))
7415 (setq data (cdr data)))
7416 (gnus-summary-limit articles))
7417 (gnus-summary-position-point)))
7419 (defun gnus-summary-limit-to-score (score)
7420 "Limit to articles with score at or above SCORE."
7421 (interactive "NLimit to articles with score of at least: ")
7422 (let ((data gnus-newsgroup-data)
7425 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7427 (push (gnus-data-number (car data)) articles))
7428 (setq data (cdr data)))
7430 (gnus-summary-limit articles)
7431 (gnus-summary-position-point))))
7433 (defun gnus-summary-limit-to-unseen ()
7434 "Limit to unseen articles."
7437 (gnus-summary-limit gnus-newsgroup-unseen)
7438 (gnus-summary-position-point)))
7440 (defun gnus-summary-limit-include-thread (id)
7441 "Display all the hidden articles that is in the thread with ID in it.
7442 When called interactively, ID is the Message-ID of the current
7444 (interactive (list (mail-header-id (gnus-summary-article-header))))
7445 (let ((articles (gnus-articles-in-thread
7446 (gnus-id-to-thread (gnus-root-id id)))))
7448 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7449 (gnus-summary-limit-include-matching-articles
7451 (regexp-quote (gnus-simplify-subject-re
7452 (mail-header-subject (gnus-id-to-header id)))))
7453 (gnus-summary-position-point))))
7455 (defun gnus-summary-limit-include-matching-articles (header regexp)
7456 "Display all the hidden articles that have HEADERs that match REGEXP."
7457 (interactive (list (read-string "Match on header: ")
7458 (read-string "Regexp: ")))
7459 (let ((articles (gnus-find-matching-articles header regexp)))
7461 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7462 (gnus-summary-position-point))))
7464 (defun gnus-summary-limit-include-dormant ()
7465 "Display all the hidden articles that are marked as dormant.
7466 Note that this command only works on a subset of the articles currently
7467 fetched for this group."
7469 (unless gnus-newsgroup-dormant
7470 (error "There are no dormant articles in this group"))
7472 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7473 (gnus-summary-position-point)))
7475 (defun gnus-summary-limit-exclude-dormant ()
7476 "Hide all dormant articles."
7479 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7480 (gnus-summary-position-point)))
7482 (defun gnus-summary-limit-exclude-childless-dormant ()
7483 "Hide all dormant articles that have no children."
7485 (let ((data (gnus-data-list t))
7486 articles d children)
7487 ;; Find all articles that are either not dormant or have
7489 (while (setq d (pop data))
7490 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7492 (gnus-article-children (gnus-data-number d)))
7495 (when (memq (car children) articles)
7500 (push (gnus-data-number d) articles)))
7503 (gnus-summary-limit articles)
7504 (gnus-summary-position-point))))
7506 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7507 "Mark all unread excluded articles as read.
7508 If ALL, mark even excluded ticked and dormants as read."
7510 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7511 (let ((articles (gnus-sorted-ndifference
7513 (mapcar (lambda (h) (mail-header-number h))
7514 gnus-newsgroup-headers)
7516 gnus-newsgroup-limit))
7518 (setq gnus-newsgroup-unreads
7519 (gnus-sorted-intersection gnus-newsgroup-unreads
7520 gnus-newsgroup-limit))
7522 (setq gnus-newsgroup-dormant nil
7523 gnus-newsgroup-marked nil
7524 gnus-newsgroup-reads
7526 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7527 gnus-newsgroup-reads))
7528 (while (setq article (pop articles))
7529 (unless (or (memq article gnus-newsgroup-dormant)
7530 (memq article gnus-newsgroup-marked))
7531 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7533 (defun gnus-summary-limit (articles &optional pop)
7535 ;; We pop the previous limit off the stack and use that.
7536 (setq articles (car gnus-newsgroup-limits)
7537 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7538 ;; We use the new limit, so we push the old limit on the stack.
7539 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7541 (setq gnus-newsgroup-limit articles)
7542 (let ((total (length gnus-newsgroup-data))
7543 (data (gnus-data-find-list (gnus-summary-article-number)))
7544 (gnus-summary-mark-below nil) ; Inhibit this.
7546 ;; This will do all the work of generating the new summary buffer
7547 ;; according to the new limit.
7548 (gnus-summary-prepare)
7549 ;; Hide any threads, possibly.
7550 (gnus-summary-maybe-hide-threads)
7551 ;; Try to return to the article you were at, or one in the
7554 ;; We try to find some article after the current one.
7556 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7559 (setq data (cdr data))))
7561 ;; If there is no data, that means that we were after the last
7562 ;; article. The same goes when we can't find any articles
7563 ;; after the current one.
7564 (goto-char (point-max))
7565 (gnus-summary-find-prev))
7566 (gnus-set-mode-line 'summary)
7567 ;; We return how many articles were removed from the summary
7568 ;; buffer as a result of the new limit.
7569 (- total (length gnus-newsgroup-data))))
7571 (defsubst gnus-invisible-cut-children (threads)
7574 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7579 (defsubst gnus-cut-thread (thread)
7580 "Go forwards in the thread until we find an article that we want to display."
7581 (when (or (eq gnus-fetch-old-headers 'some)
7582 (eq gnus-fetch-old-headers 'invisible)
7583 (numberp gnus-fetch-old-headers)
7584 (eq gnus-build-sparse-threads 'some)
7585 (eq gnus-build-sparse-threads 'more))
7586 ;; Deal with old-fetched headers and sparse threads.
7590 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7591 (gnus-summary-article-ancient-p
7592 (mail-header-number (car thread))))
7593 (if (or (<= (length (cdr thread)) 1)
7594 (eq gnus-fetch-old-headers 'invisible))
7595 (setq gnus-newsgroup-limit
7596 (delq (mail-header-number (car thread))
7597 gnus-newsgroup-limit)
7598 thread (cadr thread))
7599 (when (gnus-invisible-cut-children (cdr thread))
7600 (let ((th (cdr thread)))
7602 (if (memq (mail-header-number (caar th))
7603 gnus-newsgroup-limit)
7604 (setq thread (car th)
7606 (setq th (cdr th))))))))))
7609 (defun gnus-cut-threads (threads)
7610 "Cut off all uninteresting articles from the beginning of threads."
7611 (when (or (eq gnus-fetch-old-headers 'some)
7612 (eq gnus-fetch-old-headers 'invisible)
7613 (numberp gnus-fetch-old-headers)
7614 (eq gnus-build-sparse-threads 'some)
7615 (eq gnus-build-sparse-threads 'more))
7618 (setcar th (gnus-cut-thread (car th)))
7619 (setq th (cdr th)))))
7620 ;; Remove nixed out threads.
7623 (defun gnus-summary-initial-limit (&optional show-if-empty)
7624 "Figure out what the initial limit is supposed to be on group entry.
7625 This entails weeding out unwanted dormants, low-scored articles,
7626 fetch-old-headers verbiage, and so on."
7627 ;; Most groups have nothing to remove.
7628 (if (or gnus-inhibit-limiting
7629 (and (null gnus-newsgroup-dormant)
7630 (eq gnus-newsgroup-display 'gnus-not-ignore)
7631 (not (eq gnus-fetch-old-headers 'some))
7632 (not (numberp gnus-fetch-old-headers))
7633 (not (eq gnus-fetch-old-headers 'invisible))
7634 (null gnus-summary-expunge-below)
7635 (not (eq gnus-build-sparse-threads 'some))
7636 (not (eq gnus-build-sparse-threads 'more))
7637 (null gnus-thread-expunge-below)
7638 (not gnus-use-nocem)))
7640 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7641 (setq gnus-newsgroup-limit nil)
7644 (unless (car (symbol-value node))
7645 ;; These threads have no parents -- they are roots.
7646 (let ((nodes (cdr (symbol-value node)))
7649 (if (and gnus-thread-expunge-below
7650 (< (gnus-thread-total-score (car nodes))
7651 gnus-thread-expunge-below))
7652 (gnus-expunge-thread (pop nodes))
7653 (setq thread (pop nodes))
7654 (gnus-summary-limit-children thread))))))
7655 gnus-newsgroup-dependencies)
7656 ;; If this limitation resulted in an empty group, we might
7657 ;; pop the previous limit and use it instead.
7658 (when (and (not gnus-newsgroup-limit)
7660 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7661 gnus-newsgroup-limit))
7663 (defun gnus-summary-limit-children (thread)
7664 "Return 1 if this subthread is visible and 0 if it is not."
7665 ;; First we get the number of visible children to this thread. This
7666 ;; is done by recursing down the thread using this function, so this
7667 ;; will really go down to a leaf article first, before slowly
7668 ;; working its way up towards the root.
7670 (let* ((max-lisp-eval-depth 5000)
7673 (apply '+ (mapcar 'gnus-summary-limit-children
7676 (number (mail-header-number (car thread)))
7679 (not (memq number gnus-newsgroup-marked))
7681 ;; If this article is dormant and has absolutely no visible
7682 ;; children, then this article isn't visible.
7683 (and (memq number gnus-newsgroup-dormant)
7685 ;; If this is "fetch-old-headered" and there is no
7686 ;; visible children, then we don't want this article.
7687 (and (or (eq gnus-fetch-old-headers 'some)
7688 (numberp gnus-fetch-old-headers))
7689 (gnus-summary-article-ancient-p number)
7691 ;; If this is "fetch-old-headered" and `invisible', then
7692 ;; we don't want this article.
7693 (and (eq gnus-fetch-old-headers 'invisible)
7694 (gnus-summary-article-ancient-p number))
7695 ;; If this is a sparsely inserted article with no children,
7696 ;; we don't want it.
7697 (and (eq gnus-build-sparse-threads 'some)
7698 (gnus-summary-article-sparse-p number)
7700 ;; If we use expunging, and this article is really
7701 ;; low-scored, then we don't want this article.
7702 (when (and gnus-summary-expunge-below
7704 (or (cdr (assq number gnus-newsgroup-scored))
7705 gnus-summary-default-score))
7706 gnus-summary-expunge-below))
7707 ;; We increase the expunge-tally here, but that has
7708 ;; nothing to do with the limits, really.
7709 (incf gnus-newsgroup-expunged-tally)
7710 ;; We also mark as read here, if that's wanted.
7711 (when (and gnus-summary-mark-below
7712 (< score gnus-summary-mark-below))
7713 (setq gnus-newsgroup-unreads
7714 (delq number gnus-newsgroup-unreads))
7715 (if gnus-newsgroup-auto-expire
7716 (push number gnus-newsgroup-expirable)
7717 (push (cons number gnus-low-score-mark)
7718 gnus-newsgroup-reads)))
7720 ;; Do the `display' group parameter.
7721 (and gnus-newsgroup-display
7722 (not (funcall gnus-newsgroup-display)))
7723 ;; Check NoCeM things.
7724 (if (and gnus-use-nocem
7725 (gnus-nocem-unwanted-article-p
7726 (mail-header-id (car thread))))
7728 (setq gnus-newsgroup-unreads
7729 (delq number gnus-newsgroup-unreads))
7731 ;; Nope, invisible article.
7733 ;; Ok, this article is to be visible, so we add it to the limit
7735 (push number gnus-newsgroup-limit)
7738 (defun gnus-expunge-thread (thread)
7739 "Mark all articles in THREAD as read."
7740 (let* ((number (mail-header-number (car thread))))
7741 (incf gnus-newsgroup-expunged-tally)
7742 ;; We also mark as read here, if that's wanted.
7743 (setq gnus-newsgroup-unreads
7744 (delq number gnus-newsgroup-unreads))
7745 (if gnus-newsgroup-auto-expire
7746 (push number gnus-newsgroup-expirable)
7747 (push (cons number gnus-low-score-mark)
7748 gnus-newsgroup-reads)))
7749 ;; Go recursively through all subthreads.
7750 (mapcar 'gnus-expunge-thread (cdr thread)))
7752 ;; Summary article oriented commands
7754 (defun gnus-summary-refer-parent-article (n)
7755 "Refer parent article N times.
7756 If N is negative, go to ancestor -N instead.
7757 The difference between N and the number of articles fetched is returned."
7761 (when (not (natnump n))
7766 (setq header (gnus-summary-article-header))
7767 (if (and (eq (mail-header-number header)
7768 (cdr gnus-article-current))
7769 (equal gnus-newsgroup-name
7770 (car gnus-article-current)))
7771 ;; If we try to find the parent of the currently
7772 ;; displayed article, then we take a look at the actual
7773 ;; References header, since this is slightly more
7774 ;; reliable than the References field we got from the
7777 (set-buffer gnus-original-article-buffer)
7778 (nnheader-narrow-to-headers)
7779 (unless (setq ref (message-fetch-field "references"))
7780 (setq ref (message-fetch-field "in-reply-to")))
7783 ;; It's not the current article, so we take a bet on
7784 ;; the value we got from the server.
7785 (mail-header-references header)))
7787 (not (equal ref "")))
7788 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7789 (gnus-message 1 "Couldn't find parent"))
7790 (gnus-message 1 "No references in article %d"
7791 (gnus-summary-article-number))
7794 (gnus-summary-position-point)
7797 (defun gnus-summary-refer-references ()
7798 "Fetch all articles mentioned in the References header.
7799 Return the number of articles fetched."
7801 (let ((ref (mail-header-references (gnus-summary-article-header)))
7802 (current (gnus-summary-article-number))
7806 (error "No References in the current article")
7807 ;; For each Message-ID in the References header...
7808 (while (string-match "<[^>]*>" ref)
7810 ;; ... fetch that article.
7811 (gnus-summary-refer-article
7812 (prog1 (match-string 0 ref)
7813 (setq ref (substring ref (match-end 0))))))
7814 (gnus-summary-goto-subject current)
7815 (gnus-summary-position-point)
7818 (defun gnus-summary-refer-thread (&optional limit)
7819 "Fetch all articles in the current thread.
7820 If LIMIT (the numerical prefix), fetch that many old headers instead
7821 of what's specified by the `gnus-refer-thread-limit' variable."
7823 (let ((id (mail-header-id (gnus-summary-article-header)))
7824 (limit (if limit (prefix-numeric-value limit)
7825 gnus-refer-thread-limit)))
7826 ;; We want to fetch LIMIT *old* headers, but we also have to
7827 ;; re-fetch all the headers in the current buffer, because many of
7828 ;; them may be undisplayed. So we adjust LIMIT.
7829 (when (numberp limit)
7830 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7831 (unless (eq gnus-fetch-old-headers 'invisible)
7832 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7833 ;; Retrieve the headers and read them in.
7834 (if (eq (gnus-retrieve-headers
7835 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7837 (gnus-build-all-threads)
7838 (error "Can't fetch thread from backends that don't support NOV"))
7839 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7840 (gnus-summary-limit-include-thread id)))
7842 (defun gnus-summary-refer-article (message-id)
7843 "Fetch an article specified by MESSAGE-ID."
7844 (interactive "sMessage-ID: ")
7845 (when (and (stringp message-id)
7846 (not (zerop (length message-id))))
7847 ;; Construct the correct Message-ID if necessary.
7848 ;; Suggested by tale@pawl.rpi.edu.
7849 (unless (string-match "^<" message-id)
7850 (setq message-id (concat "<" message-id)))
7851 (unless (string-match ">$" message-id)
7852 (setq message-id (concat message-id ">")))
7853 (let* ((header (gnus-id-to-header message-id))
7855 (gnus-summary-article-sparse-p
7856 (mail-header-number header))
7857 (memq (mail-header-number header)
7858 gnus-newsgroup-limit)))
7861 ;; If the article is present in the buffer we just go to it.
7863 (or (not (gnus-summary-article-sparse-p
7864 (mail-header-number header)))
7867 (gnus-summary-goto-article
7868 (mail-header-number header) nil t)
7870 (gnus-summary-update-article (mail-header-number header)))))
7872 ;; We fetch the article.
7874 (dolist (gnus-override-method (gnus-refer-article-methods))
7875 (gnus-check-server gnus-override-method)
7876 ;; Fetch the header, and display the article.
7877 (when (setq number (gnus-summary-insert-subject message-id))
7878 (gnus-summary-select-article nil nil nil number)
7880 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7882 (defun gnus-refer-article-methods ()
7883 "Return a list of referable methods."
7885 ;; No method, so we default to current and native.
7886 ((null gnus-refer-article-method)
7887 (list gnus-current-select-method gnus-select-method))
7889 ((eq 'current gnus-refer-article-method)
7890 (list gnus-current-select-method))
7891 ;; List of select methods.
7892 ((not (and (symbolp (car gnus-refer-article-method))
7893 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7895 (dolist (method gnus-refer-article-method)
7896 (push (if (eq 'current method)
7897 gnus-current-select-method
7901 ;; One single select method.
7903 (list gnus-refer-article-method))))
7905 (defun gnus-summary-edit-parameters ()
7906 "Edit the group parameters of the current group."
7908 (gnus-group-edit-group gnus-newsgroup-name 'params))
7910 (defun gnus-summary-customize-parameters ()
7911 "Customize the group parameters of the current group."
7913 (gnus-group-customize gnus-newsgroup-name))
7915 (defun gnus-summary-enter-digest-group (&optional force)
7916 "Enter an nndoc group based on the current article.
7917 If FORCE, force a digest interpretation. If not, try
7918 to guess what the document format is."
7920 (let ((conf gnus-current-window-configuration))
7922 (gnus-summary-select-article))
7923 (setq gnus-current-window-configuration conf)
7924 (let* ((name (format "%s-%d"
7925 (gnus-group-prefixed-name
7926 gnus-newsgroup-name (list 'nndoc ""))
7928 (set-buffer gnus-summary-buffer)
7929 gnus-current-article)))
7930 (ogroup gnus-newsgroup-name)
7931 (params (append (gnus-info-params (gnus-get-info ogroup))
7932 (list (cons 'to-group ogroup))
7933 (list (cons 'save-article-group ogroup))))
7934 (case-fold-search t)
7935 (buf (current-buffer))
7938 (set-buffer gnus-original-article-buffer)
7939 ;; Have the digest group inherit the main mail address of
7940 ;; the parent article.
7941 (when (setq to-address (or (gnus-fetch-field "reply-to")
7942 (gnus-fetch-field "from")))
7943 (setq params (append
7944 (list (cons 'to-address
7945 (funcall gnus-decode-encoded-word-function
7947 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7948 (insert-buffer-substring gnus-original-article-buffer)
7949 ;; Remove lines that may lead nndoc to misinterpret the
7952 (goto-char (point-min))
7953 (or (search-forward "\n\n" nil t) (point)))
7954 (goto-char (point-min))
7955 (delete-matching-lines "^Path:\\|^From ")
7958 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7959 (gnus-newsgroup-ephemeral-ignored-charsets
7960 gnus-newsgroup-ignored-charsets))
7961 (gnus-group-read-ephemeral-group
7962 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7964 ,(if force 'mbox 'guess)))
7966 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7968 ;; Make all postings to this group go to the parent group.
7969 (nconc (gnus-info-params (gnus-get-info name))
7971 ;; Couldn't select this doc group.
7972 (switch-to-buffer buf)
7973 (gnus-set-global-variables)
7974 (gnus-configure-windows 'summary)
7975 (gnus-message 3 "Article couldn't be entered?"))
7976 (kill-buffer dig)))))
7978 (defun gnus-summary-read-document (n)
7979 "Open a new group based on the current article(s).
7980 This will allow you to read digests and other similar
7981 documents as newsgroups.
7982 Obeys the standard process/prefix convention."
7984 (let* ((articles (gnus-summary-work-articles n))
7985 (ogroup gnus-newsgroup-name)
7986 (params (append (gnus-info-params (gnus-get-info ogroup))
7987 (list (cons 'to-group ogroup))))
7988 article group egroup groups vgroup)
7989 (while (setq article (pop articles))
7990 (setq group (format "%s-%d" gnus-newsgroup-name article))
7991 (gnus-summary-remove-process-mark article)
7992 (when (gnus-summary-display-article article)
7995 (insert-buffer-substring gnus-original-article-buffer)
7996 ;; Remove some headers that may lead nndoc to make
7998 (message-narrow-to-head)
7999 (goto-char (point-min))
8000 (delete-matching-lines "^\\(Path\\):\\|^From ")
8003 (gnus-group-read-ephemeral-group
8004 group `(nndoc ,group (nndoc-address ,(current-buffer))
8005 (nndoc-article-type guess))
8008 ;; Make all postings to this group go to the parent group.
8009 (nconc (gnus-info-params (gnus-get-info egroup))
8011 (push egroup groups))
8012 ;; Couldn't select this doc group.
8013 (gnus-error 3 "Article couldn't be entered"))))))
8014 ;; Now we have selected all the documents.
8017 (error "None of the articles could be interpreted as documents"))
8018 ((gnus-group-read-ephemeral-group
8019 (setq vgroup (format
8020 "nnvirtual:%s-%s" gnus-newsgroup-name
8021 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8022 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8024 (cons (current-buffer) 'summary)))
8026 (error "Couldn't select virtual nndoc group")))))
8028 (defun gnus-summary-isearch-article (&optional regexp-p)
8029 "Do incremental search forward on the current article.
8030 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8032 (gnus-summary-select-article)
8033 (gnus-configure-windows 'article)
8034 (gnus-eval-in-buffer-window gnus-article-buffer
8037 (isearch-forward regexp-p))))
8039 (defun gnus-summary-search-article-forward (regexp &optional backward)
8040 "Search for an article containing REGEXP forward.
8041 If BACKWARD, search backward instead."
8044 (format "Search article %s (regexp%s): "
8045 (if current-prefix-arg "backward" "forward")
8046 (if gnus-last-search-regexp
8047 (concat ", default " gnus-last-search-regexp)
8049 current-prefix-arg))
8050 (if (string-equal regexp "")
8051 (setq regexp (or gnus-last-search-regexp ""))
8052 (setq gnus-last-search-regexp regexp)
8053 (setq gnus-article-before-search gnus-current-article))
8054 ;; Intentionally set gnus-last-article.
8055 (setq gnus-last-article gnus-article-before-search)
8056 (let ((gnus-last-article gnus-last-article))
8057 (if (gnus-summary-search-article regexp backward)
8058 (gnus-summary-show-thread)
8059 (error "Search failed: \"%s\"" regexp))))
8061 (defun gnus-summary-search-article-backward (regexp)
8062 "Search for an article containing REGEXP backward."
8065 (format "Search article backward (regexp%s): "
8066 (if gnus-last-search-regexp
8067 (concat ", default " gnus-last-search-regexp)
8069 (gnus-summary-search-article-forward regexp 'backward))
8071 (defun gnus-summary-search-article (regexp &optional backward)
8072 "Search for an article containing REGEXP.
8073 Optional argument BACKWARD means do search for backward.
8074 `gnus-select-article-hook' is not called during the search."
8075 ;; We have to require this here to make sure that the following
8076 ;; dynamic binding isn't shadowed by autoloading.
8077 (require 'gnus-async)
8079 (let ((gnus-select-article-hook nil) ;Disable hook.
8080 (gnus-article-prepare-hook nil)
8081 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8082 (gnus-use-article-prefetch nil)
8083 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8084 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8085 (sum (current-buffer))
8086 (gnus-display-mime-function nil)
8089 (gnus-save-hidden-threads
8090 (gnus-summary-select-article)
8091 (set-buffer gnus-article-buffer)
8092 (goto-char (window-point (get-buffer-window (current-buffer))))
8096 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8098 (re-search-backward regexp nil t)
8099 (re-search-forward regexp nil t))
8100 ;; We found the regexp.
8105 (get-buffer-window (current-buffer))
8109 (get-buffer-window (current-buffer))
8112 (setq point (point)))
8113 ;; We didn't find it, so we go to the next article.
8116 (while (eq found 'not)
8117 (if (not (if backward (gnus-summary-find-prev)
8118 (gnus-summary-find-next)))
8119 ;; No more articles.
8121 ;; Select the next article and adjust point.
8122 (unless (gnus-summary-article-sparse-p
8123 (gnus-summary-article-number))
8125 (gnus-summary-select-article)
8126 (set-buffer gnus-article-buffer)
8128 (goto-char (if backward (point-max) (point-min))))))))
8129 (gnus-message 7 ""))
8130 ;; Return whether we found the regexp.
8131 (when (eq found 'found)
8133 (gnus-summary-show-thread)
8134 (gnus-summary-goto-subject gnus-current-article)
8135 (gnus-summary-position-point)
8138 (defun gnus-find-matching-articles (header regexp)
8139 "Return a list of all articles that match REGEXP on HEADER.
8140 This search includes all articles in the current group that Gnus has
8141 fetched headers for, whether they are displayed or not."
8142 (let ((articles nil)
8143 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8144 (case-fold-search t))
8145 (dolist (header gnus-newsgroup-headers)
8146 (when (string-match regexp (funcall func header))
8147 (push (mail-header-number header) articles)))
8148 (nreverse articles)))
8150 (defun gnus-summary-find-matching (header regexp &optional backward unread
8151 not-case-fold not-matching)
8152 "Return a list of all articles that match REGEXP on HEADER.
8153 The search stars on the current article and goes forwards unless
8154 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8155 If UNREAD is non-nil, only unread articles will
8156 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8157 in the comparisons. If NOT-MATCHING, return a list of all articles that
8158 not match REGEXP on HEADER."
8159 (let ((case-fold-search (not not-case-fold))
8162 (if (eq (car header) 'extra)
8165 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8167 (error "%s is an invalid header" header))
8168 (unless (fboundp (intern (concat "mail-header-" header)))
8169 (error "%s is not a valid header" header))
8170 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8171 (dolist (d (if (eq backward 'all)
8173 (gnus-data-find-list
8174 (gnus-summary-article-number)
8175 (gnus-data-list backward))))
8176 (when (and (or (not unread) ; We want all articles...
8177 (gnus-data-unread-p d)) ; Or just unreads.
8178 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8182 (funcall func (gnus-data-header d))))
8183 (string-match regexp
8184 (funcall func (gnus-data-header d)))))
8185 (push (gnus-data-number d) articles))) ; Success!
8186 (nreverse articles)))
8188 (defun gnus-summary-execute-command (header regexp command &optional backward)
8189 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8190 If HEADER is an empty string (or nil), the match is done on the entire
8191 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8193 (list (let ((completion-ignore-case t))
8196 (mapcar (lambda (header) (list (format "%s" header)))
8198 '("Number" "Subject" "From" "Lines" "Date"
8199 "Message-ID" "Xref" "References" "Body")
8200 gnus-extra-headers))
8201 nil 'require-match))
8202 (read-string "Regexp: ")
8203 (read-key-sequence "Command: ")
8204 current-prefix-arg))
8205 (when (equal header "Body")
8207 ;; Hidden thread subtrees must be searched as well.
8208 (gnus-summary-show-all-threads)
8209 ;; We don't want to change current point nor window configuration.
8211 (save-window-excursion
8213 gnus-treat-strip-trailing-blank-lines
8214 gnus-treat-strip-leading-blank-lines
8215 gnus-treat-strip-multiple-blank-lines
8216 gnus-treat-hide-boring-headers
8217 gnus-treat-fold-newsgroups
8218 gnus-article-prepare-hook)
8219 (gnus-message 6 "Executing %s..." (key-description command))
8220 ;; We'd like to execute COMMAND interactively so as to give arguments.
8221 (gnus-execute header regexp
8222 `(call-interactively ',(key-binding command))
8224 (gnus-message 6 "Executing %s...done" (key-description command))))))
8226 (defun gnus-summary-beginning-of-article ()
8227 "Scroll the article back to the beginning."
8229 (gnus-summary-select-article)
8230 (gnus-configure-windows 'article)
8231 (gnus-eval-in-buffer-window gnus-article-buffer
8233 (goto-char (point-min))
8234 (when gnus-page-broken
8235 (gnus-narrow-to-page))))
8237 (defun gnus-summary-end-of-article ()
8238 "Scroll to the end of the article."
8240 (gnus-summary-select-article)
8241 (gnus-configure-windows 'article)
8242 (gnus-eval-in-buffer-window gnus-article-buffer
8244 (goto-char (point-max))
8246 (when gnus-page-broken
8247 (gnus-narrow-to-page))))
8249 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8250 "Truncate to LEN and quote all \"(\"'s in STRING."
8251 (gnus-replace-in-string (if (and len (> (length string) len))
8252 (substring string 0 len)
8256 (defun gnus-summary-print-article (&optional filename n)
8257 "Generate and print a PostScript image of the N next (mail) articles.
8259 If N is negative, print the N previous articles. If N is nil and articles
8260 have been marked with the process mark, print these instead.
8262 If the optional first argument FILENAME is nil, send the image to the
8263 printer. If FILENAME is a string, save the PostScript image in a file with
8264 that name. If FILENAME is a number, prompt the user for the name of the file
8266 (interactive (list (ps-print-preprint current-prefix-arg)))
8267 (dolist (article (gnus-summary-work-articles n))
8268 (gnus-summary-select-article nil nil 'pseudo article)
8269 (gnus-eval-in-buffer-window gnus-article-buffer
8270 (gnus-print-buffer))
8271 (gnus-summary-remove-process-mark article))
8272 (ps-despool filename))
8274 (defun gnus-print-buffer ()
8275 (let ((buffer (generate-new-buffer " *print*")))
8278 (copy-to-buffer buffer (point-min) (point-max))
8280 (gnus-article-delete-invisible-text)
8281 (gnus-remove-text-with-property 'gnus-decoration)
8282 (when (gnus-visual-p 'article-highlight 'highlight)
8283 ;; Copy-to-buffer doesn't copy overlay. So redo
8285 (let ((gnus-article-buffer buffer))
8286 (gnus-article-highlight-citation t)
8287 (gnus-article-highlight-signature)))
8288 (let ((ps-left-header
8291 (gnus-summary-print-truncate-and-quote
8292 (mail-header-subject gnus-current-headers)
8295 (gnus-summary-print-truncate-and-quote
8296 (mail-header-from gnus-current-headers)
8300 "/pagenumberstring load"
8302 (mail-header-date gnus-current-headers) ")"))))
8303 (gnus-run-hooks 'gnus-ps-print-hook)
8306 (ps-spool-buffer-with-faces)
8307 (ps-spool-buffer)))))
8308 (kill-buffer buffer))))
8310 (defun gnus-summary-show-article (&optional arg)
8311 "Force redisplaying of the current article.
8312 If ARG (the prefix) is a number, show the article with the charset
8313 defined in `gnus-summary-show-article-charset-alist', or the charset
8315 If ARG (the prefix) is non-nil and not a number, show the raw article
8316 without any article massaging functions being run. Normally, the key strokes
8321 (gnus-summary-show-article t)
8322 (let ((gnus-newsgroup-charset
8323 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8324 (mm-read-coding-system
8325 "View as charset: " ;; actually it is coding system.
8327 (set-buffer gnus-article-buffer)
8328 (mm-detect-coding-region (point) (point-max))))))
8329 (gnus-newsgroup-ignored-charsets 'gnus-all))
8330 (gnus-summary-select-article nil 'force)
8331 (let ((deps gnus-newsgroup-dependencies)
8334 (set-buffer gnus-original-article-buffer)
8336 (message-narrow-to-head)
8337 (setq head (buffer-string))
8338 (goto-char (point-min))
8339 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8340 (goto-char (point-max))
8342 (setq lines (1- (count-lines (point) (point-max))))))
8344 (insert (format "211 %d Article retrieved.\n"
8345 (cdr gnus-article-current)))
8347 (if lines (insert (format "Lines: %d\n" lines)))
8349 (let ((nntp-server-buffer (current-buffer)))
8350 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8351 (gnus-data-set-header
8352 (gnus-data-find (cdr gnus-article-current))
8354 (gnus-summary-update-article-line
8355 (cdr gnus-article-current) header)
8356 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8357 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8359 ;; Select the article the normal way.
8360 (gnus-summary-select-article nil 'force))
8362 ;; We have to require this here to make sure that the following
8363 ;; dynamic binding isn't shadowed by autoloading.
8364 (require 'gnus-async)
8366 ;; Bind the article treatment functions to nil.
8367 (let ((gnus-have-all-headers t)
8368 gnus-article-prepare-hook
8369 gnus-article-decode-hook
8370 gnus-display-mime-function
8372 ;; Destroy any MIME parts.
8373 (when (gnus-buffer-live-p gnus-article-buffer)
8375 (set-buffer gnus-article-buffer)
8376 (mm-destroy-parts gnus-article-mime-handles)
8377 ;; Set it to nil for safety reason.
8378 (setq gnus-article-mime-handle-alist nil)
8379 (setq gnus-article-mime-handles nil)))
8380 (gnus-summary-select-article nil 'force))))
8381 (gnus-summary-goto-subject gnus-current-article)
8382 (gnus-summary-position-point))
8384 (defun gnus-summary-show-raw-article ()
8385 "Show the raw article without any article massaging functions being run."
8387 (gnus-summary-show-article t))
8389 (defun gnus-summary-verbose-headers (&optional arg)
8390 "Toggle permanent full header display.
8391 If ARG is a positive number, turn header display on.
8392 If ARG is a negative number, turn header display off."
8394 (setq gnus-show-all-headers
8395 (cond ((or (not (numberp arg))
8397 (not gnus-show-all-headers))
8400 (gnus-summary-show-article))
8402 (defun gnus-summary-toggle-header (&optional arg)
8403 "Show the headers if they are hidden, or hide them if they are shown.
8404 If ARG is a positive number, show the entire header.
8405 If ARG is a negative number, hide the unwanted header lines."
8407 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8408 (get-buffer-window gnus-article-buffer t))))
8409 (with-current-buffer gnus-article-buffer
8411 (article-narrow-to-head)
8412 (let* ((buffer-read-only nil)
8413 (inhibit-point-motion-hooks t)
8414 (hidden (if (numberp arg)
8416 (gnus-article-hidden-text-p 'headers)))
8418 (delete-region (point-min) (point-max))
8419 (with-current-buffer gnus-original-article-buffer
8420 (goto-char (setq s (point-min)))
8421 (setq e (if (search-forward "\n\n" nil t)
8424 (insert-buffer-substring gnus-original-article-buffer s e)
8425 (article-decode-encoded-words)
8427 (let ((gnus-treat-hide-headers nil)
8428 (gnus-treat-hide-boring-headers nil))
8429 (gnus-delete-wash-type 'headers)
8430 (gnus-treat-article 'head))
8431 (gnus-treat-article 'head))
8434 (set-window-start window (goto-char (point-min))))
8435 (setq gnus-page-broken
8436 (when gnus-break-pages
8437 (gnus-narrow-to-page)
8439 (gnus-set-mode-line 'article)))))
8441 (defun gnus-summary-show-all-headers ()
8442 "Make all header lines visible."
8444 (gnus-summary-toggle-header 1))
8446 (defun gnus-summary-caesar-message (&optional arg)
8447 "Caesar rotate the current article by 13.
8448 The numerical prefix specifies how many places to rotate each letter
8451 (gnus-summary-select-article)
8452 (let ((mail-header-separator ""))
8453 (gnus-eval-in-buffer-window gnus-article-buffer
8456 (let ((start (window-start))
8458 (message-caesar-buffer-body arg)
8459 (set-window-start (get-buffer-window (current-buffer)) start))))))
8461 (autoload 'unmorse-region "morse"
8462 "Convert morse coded text in region to ordinary ASCII text."
8465 (defun gnus-summary-morse-message (&optional arg)
8466 "Morse decode the current article."
8468 (gnus-summary-select-article)
8469 (let ((mail-header-separator ""))
8470 (gnus-eval-in-buffer-window gnus-article-buffer
8474 (let ((pos (window-start))
8476 (goto-char (point-min))
8477 (when (message-goto-body)
8478 (gnus-narrow-to-body))
8479 (goto-char (point-min))
8480 (while (re-search-forward "·" (point-max) t)
8481 (replace-match "."))
8482 (unmorse-region (point-min) (point-max))
8484 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8486 (defun gnus-summary-stop-page-breaking ()
8487 "Stop page breaking in the current article."
8489 (gnus-summary-select-article)
8490 (gnus-eval-in-buffer-window gnus-article-buffer
8492 (when (gnus-visual-p 'page-marker)
8493 (let ((buffer-read-only nil))
8494 (gnus-remove-text-with-property 'gnus-prev)
8495 (gnus-remove-text-with-property 'gnus-next))
8496 (setq gnus-page-broken nil))))
8498 (defun gnus-summary-move-article (&optional n to-newsgroup
8499 select-method action)
8500 "Move the current article to a different newsgroup.
8501 If N is a positive number, move the N next articles.
8502 If N is a negative number, move the N previous articles.
8503 If N is nil and any articles have been marked with the process mark,
8504 move those articles instead.
8505 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8506 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8507 re-spool using this method.
8509 When called interactively with TO-NEWSGROUP being nil, the value of
8510 the variable `gnus-move-split-methods' is used for finding a default
8511 for the target newsgroup.
8513 For this function to work, both the current newsgroup and the
8514 newsgroup that you want to move to have to support the `request-move'
8515 and `request-accept' functions.
8517 ACTION can be either `move' (the default), `crosspost' or `copy'."
8520 (setq action 'move))
8521 ;; Check whether the source group supports the required functions.
8522 (cond ((and (eq action 'move)
8523 (not (gnus-check-backend-function
8524 'request-move-article gnus-newsgroup-name)))
8525 (error "The current group does not support article moving"))
8526 ((and (eq action 'crosspost)
8527 (not (gnus-check-backend-function
8528 'request-replace-article gnus-newsgroup-name)))
8529 (error "The current group does not support article editing")))
8530 (let ((articles (gnus-summary-work-articles n))
8531 (prefix (if (gnus-check-backend-function
8532 'request-move-article gnus-newsgroup-name)
8533 (gnus-group-real-prefix gnus-newsgroup-name)
8535 (names '((move "Move" "Moving")
8536 (copy "Copy" "Copying")
8537 (crosspost "Crosspost" "Crossposting")))
8538 (copy-buf (save-excursion
8539 (nnheader-set-temp-buffer " *copy article*")))
8540 art-group to-method new-xref article to-groups)
8541 (unless (assq action names)
8542 (error "Unknown action %s" action))
8543 ;; Read the newsgroup name.
8544 (when (and (not to-newsgroup)
8545 (not select-method))
8546 (if (and gnus-move-split-methods
8548 (and (memq gnus-current-article articles)
8549 (gnus-buffer-live-p gnus-original-article-buffer))))
8550 ;; When `gnus-move-split-methods' is non-nil, we have to
8551 ;; select an article to give `gnus-read-move-group-name' an
8552 ;; opportunity to suggest an appropriate default. However,
8553 ;; we needn't render or mark the article.
8554 (let ((gnus-display-mime-function nil)
8555 (gnus-article-prepare-hook nil)
8556 (gnus-mark-article-hook nil))
8557 (gnus-summary-select-article nil nil nil (car articles))))
8559 (gnus-read-move-group-name
8560 (cadr (assq action names))
8561 (symbol-value (intern (format "gnus-current-%s-group" action)))
8563 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8564 (setq to-method (or select-method
8565 (gnus-server-to-method
8566 (gnus-group-method to-newsgroup))))
8567 ;; Check the method we are to move this article to...
8568 (unless (gnus-check-backend-function
8569 'request-accept-article (car to-method))
8570 (error "%s does not support article copying" (car to-method)))
8571 (unless (gnus-check-server to-method)
8572 (error "Can't open server %s" (car to-method)))
8573 (gnus-message 6 "%s to %s: %s..."
8574 (caddr (assq action names))
8575 (or (car select-method) to-newsgroup) articles)
8577 (setq article (pop articles))
8581 ;; Move the article.
8583 ;; Remove this article from future suppression.
8584 (gnus-dup-unsuppress-article article)
8585 (gnus-request-move-article
8586 article ; Article to move
8587 gnus-newsgroup-name ; From newsgroup
8588 (nth 1 (gnus-find-method-for-group
8589 gnus-newsgroup-name)) ; Server
8590 (list 'gnus-request-accept-article
8591 to-newsgroup (list 'quote select-method)
8592 (not articles) t) ; Accept form
8593 (not articles))) ; Only save nov last time
8594 ;; Copy the article.
8597 (set-buffer copy-buf)
8598 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8599 (gnus-request-accept-article
8600 to-newsgroup select-method (not articles) t))))
8601 ;; Crosspost the article.
8602 ((eq action 'crosspost)
8603 (let ((xref (message-tokenize-header
8604 (mail-header-xref (gnus-summary-article-header article))
8606 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8607 ":" (number-to-string article)))
8609 (setq xref (list (system-name))))
8612 (mapconcat 'identity
8613 (delete "Xref:" (delete new-xref xref))
8617 (set-buffer copy-buf)
8618 ;; First put the article in the destination group.
8619 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8620 (when (consp (setq art-group
8621 (gnus-request-accept-article
8622 to-newsgroup select-method (not articles))))
8623 (setq new-xref (concat new-xref " " (car art-group)
8625 (number-to-string (cdr art-group))))
8626 ;; Now we have the new Xrefs header, so we insert
8627 ;; it and replace the new article.
8628 (nnheader-replace-header "Xref" new-xref)
8629 (gnus-request-replace-article
8630 (cdr art-group) to-newsgroup (current-buffer))
8634 (gnus-message 1 "Couldn't %s article %s: %s"
8635 (cadr (assq action names)) article
8636 (nnheader-get-report (car to-method))))
8637 ((eq art-group 'junk)
8638 (when (eq action 'move)
8639 (gnus-summary-mark-article article gnus-canceled-mark)
8640 (gnus-message 4 "Deleted article %s" article)))
8642 (let* ((pto-group (gnus-group-prefixed-name
8643 (car art-group) to-method))
8645 (gnus-gethash pto-group gnus-newsrc-hashtb))
8646 (info (nth 2 entry))
8647 (to-group (gnus-info-group info))
8649 ;; Update the group that has been moved to.
8651 (memq action '(move copy)))
8652 (unless (member to-group to-groups)
8653 (push to-group to-groups))
8655 (unless (memq article gnus-newsgroup-unreads)
8656 (push 'read to-marks)
8658 info (gnus-add-to-range (gnus-info-read info)
8659 (list (cdr art-group)))))
8661 ;; See whether the article is to be put in the cache.
8662 (let ((marks gnus-article-mark-lists)
8663 (to-article (cdr art-group)))
8665 ;; Enter the article into the cache in the new group,
8666 ;; if that is required.
8667 (when gnus-use-cache
8668 (gnus-cache-possibly-enter-article
8670 (memq article gnus-newsgroup-marked)
8671 (memq article gnus-newsgroup-dormant)
8672 (memq article gnus-newsgroup-unreads)))
8674 (when gnus-preserve-marks
8675 ;; Copy any marks over to the new group.
8676 (when (and (equal to-group gnus-newsgroup-name)
8677 (not (memq article gnus-newsgroup-unreads)))
8678 ;; Mark this article as read in this group.
8679 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8680 (setcdr (gnus-active to-group) to-article)
8681 (setcdr gnus-newsgroup-active to-article))
8684 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8685 (when (memq article (symbol-value
8686 (intern (format "gnus-newsgroup-%s"
8688 (push (cdar marks) to-marks)
8689 ;; If the other group is the same as this group,
8690 ;; then we have to add the mark to the list.
8691 (when (equal to-group gnus-newsgroup-name)
8692 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8695 (intern (format "gnus-newsgroup-%s"
8697 ;; Copy the marks to other group.
8698 (gnus-add-marked-articles
8699 to-group (cdar marks) (list to-article) info)))
8700 (setq marks (cdr marks)))
8702 (gnus-request-set-mark to-group (list (list (list to-article)
8707 (concat "(gnus-group-set-info '"
8708 (gnus-prin1-to-string (gnus-get-info to-group))
8711 ;; Update the Xref header in this article to point to
8712 ;; the new crossposted article we have just created.
8713 (when (eq action 'crosspost)
8715 (set-buffer copy-buf)
8716 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8717 (nnheader-replace-header "Xref" new-xref)
8718 (gnus-request-replace-article
8719 article gnus-newsgroup-name (current-buffer)))))
8721 ;;;!!!Why is this necessary?
8722 (set-buffer gnus-summary-buffer)
8724 (gnus-summary-goto-subject article)
8725 (when (eq action 'move)
8726 (gnus-summary-mark-article article gnus-canceled-mark))))
8727 (gnus-summary-remove-process-mark article))
8728 ;; Re-activate all groups that have been moved to.
8730 (set-buffer gnus-group-buffer)
8731 (let ((gnus-group-marked to-groups))
8732 (gnus-group-get-new-news-this-group nil t)))
8734 (gnus-kill-buffer copy-buf)
8735 (gnus-summary-position-point)
8736 (gnus-set-mode-line 'summary)))
8738 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8739 "Move the current article to a different newsgroup.
8740 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8741 When called interactively, if TO-NEWSGROUP is nil, use the value of
8742 the variable `gnus-move-split-methods' for finding a default target
8744 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8745 re-spool using this method."
8747 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8749 (defun gnus-summary-crosspost-article (&optional n)
8750 "Crosspost the current article to some other group."
8752 (gnus-summary-move-article n nil nil 'crosspost))
8754 (defcustom gnus-summary-respool-default-method nil
8755 "Default method type for respooling an article.
8756 If nil, use to the current newsgroup method."
8758 :group 'gnus-summary-mail)
8760 (defun gnus-summary-respool-article (&optional n method)
8761 "Respool the current article.
8762 The article will be squeezed through the mail spooling process again,
8763 which means that it will be put in some mail newsgroup or other
8764 depending on `nnmail-split-methods'.
8765 If N is a positive number, respool the N next articles.
8766 If N is a negative number, respool the N previous articles.
8767 If N is nil and any articles have been marked with the process mark,
8768 respool those articles instead.
8770 Respooling can be done both from mail groups and \"real\" newsgroups.
8771 In the former case, the articles in question will be moved from the
8772 current group into whatever groups they are destined to. In the
8773 latter case, they will be copied into the relevant groups."
8775 (list current-prefix-arg
8776 (let* ((methods (gnus-methods-using 'respool))
8778 (symbol-name (or gnus-summary-respool-default-method
8779 (car (gnus-find-method-for-group
8780 gnus-newsgroup-name)))))
8782 (gnus-completing-read-with-default
8783 methname "What backend do you want to use when respooling?"
8784 methods nil t nil 'gnus-mail-method-history))
8787 ((zerop (length (setq ms (gnus-servers-using-backend
8789 (list (intern method) ""))
8793 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8794 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8797 (error "No method given for respooling"))
8798 (if (assoc (symbol-name
8799 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8800 (gnus-methods-using 'respool))
8801 (gnus-summary-move-article n nil method)
8802 (gnus-summary-copy-article n nil method)))
8804 (defun gnus-summary-import-article (file &optional edit)
8805 "Import an arbitrary file into a mail newsgroup."
8806 (interactive "fImport file: \nP")
8807 (let ((group gnus-newsgroup-name)
8808 (now (current-time))
8809 atts lines group-art)
8810 (unless (gnus-check-backend-function 'request-accept-article group)
8811 (error "%s does not support article importing" group))
8812 (or (file-readable-p file)
8813 (not (file-regular-p file))
8814 (error "Can't read %s" file))
8816 (set-buffer (gnus-get-buffer-create " *import file*"))
8818 (nnheader-insert-file-contents file)
8819 (goto-char (point-min))
8820 (if (nnheader-article-p)
8822 (goto-char (point-min))
8823 (search-forward "\n\n" nil t)
8824 (narrow-to-region (point-min) (1- (point)))
8825 (goto-char (point-min))
8826 (unless (re-search-forward "^date:" nil t)
8827 (goto-char (point-max))
8828 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8829 ;; This doesn't look like an article, so we fudge some headers.
8830 (setq atts (file-attributes file)
8831 lines (count-lines (point-min) (point-max)))
8832 (insert "From: " (read-string "From: ") "\n"
8833 "Subject: " (read-string "Subject: ") "\n"
8834 "Date: " (message-make-date (nth 5 atts)) "\n"
8835 "Message-ID: " (message-make-message-id) "\n"
8836 "Lines: " (int-to-string lines) "\n"
8837 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8838 (setq group-art (gnus-request-accept-article group nil t))
8839 (kill-buffer (current-buffer)))
8840 (setq gnus-newsgroup-active (gnus-activate-group group))
8842 (gnus-summary-goto-article (cdr group-art) nil t)
8844 (gnus-summary-edit-article))))
8846 (defun gnus-summary-create-article ()
8847 "Create an article in a mail newsgroup."
8849 (let ((group gnus-newsgroup-name)
8850 (now (current-time))
8852 (unless (gnus-check-backend-function 'request-accept-article group)
8853 (error "%s does not support article importing" group))
8855 (set-buffer (gnus-get-buffer-create " *import file*"))
8857 (goto-char (point-min))
8858 ;; This doesn't look like an article, so we fudge some headers.
8859 (insert "From: " (read-string "From: ") "\n"
8860 "Subject: " (read-string "Subject: ") "\n"
8861 "Date: " (message-make-date now) "\n"
8862 "Message-ID: " (message-make-message-id) "\n")
8863 (setq group-art (gnus-request-accept-article group nil t))
8864 (kill-buffer (current-buffer)))
8865 (setq gnus-newsgroup-active (gnus-activate-group group))
8867 (gnus-summary-goto-article (cdr group-art) nil t)
8868 (gnus-summary-edit-article)))
8870 (defun gnus-summary-article-posted-p ()
8871 "Say whether the current (mail) article is available from news as well.
8872 This will be the case if the article has both been mailed and posted."
8874 (let ((id (mail-header-references (gnus-summary-article-header)))
8875 (gnus-override-method (car (gnus-refer-article-methods))))
8876 (if (gnus-request-head id "")
8877 (gnus-message 2 "The current message was found on %s"
8878 gnus-override-method)
8879 (gnus-message 2 "The current message couldn't be found on %s"
8880 gnus-override-method)
8883 (defun gnus-summary-expire-articles (&optional now)
8884 "Expire all articles that are marked as expirable in the current group."
8886 (when (gnus-check-backend-function
8887 'request-expire-articles gnus-newsgroup-name)
8888 ;; This backend supports expiry.
8889 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8890 (expirable (if total
8892 ;; We need to update the info for
8893 ;; this group for `gnus-list-of-read-articles'
8894 ;; to give us the right answer.
8895 (gnus-run-hooks 'gnus-exit-group-hook)
8896 (gnus-summary-update-info)
8897 (gnus-list-of-read-articles gnus-newsgroup-name))
8898 (setq gnus-newsgroup-expirable
8899 (sort gnus-newsgroup-expirable '<))))
8900 (expiry-wait (if now 'immediate
8901 (gnus-group-find-parameter
8902 gnus-newsgroup-name 'expiry-wait)))
8903 (nnmail-expiry-target
8904 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8905 nnmail-expiry-target))
8908 ;; There are expirable articles in this group, so we run them
8909 ;; through the expiry process.
8910 (gnus-message 6 "Expiring articles...")
8911 (unless (gnus-check-group gnus-newsgroup-name)
8912 (error "Can't open server for %s" gnus-newsgroup-name))
8913 ;; The list of articles that weren't expired is returned.
8916 (let ((nnmail-expiry-wait-function nil)
8917 (nnmail-expiry-wait expiry-wait))
8918 (setq es (gnus-request-expire-articles
8919 expirable gnus-newsgroup-name)))
8920 (setq es (gnus-request-expire-articles
8921 expirable gnus-newsgroup-name)))
8923 (setq gnus-newsgroup-expirable es))
8924 ;; We go through the old list of expirable, and mark all
8925 ;; really expired articles as nonexistent.
8926 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8927 (let ((gnus-use-cache nil))
8928 (dolist (article expirable)
8929 (when (and (not (memq article es))
8930 (gnus-data-find article))
8931 (gnus-summary-mark-article article gnus-canceled-mark))))))
8932 (gnus-message 6 "Expiring articles...done")))))
8934 (defun gnus-summary-expire-articles-now ()
8935 "Expunge all expirable articles in the current group.
8936 This means that *all* articles that are marked as expirable will be
8937 deleted forever, right now."
8939 (or gnus-expert-user
8941 "Are you really, really, really sure you want to delete all these messages? ")
8943 (gnus-summary-expire-articles t))
8945 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8946 (defun gnus-summary-delete-article (&optional n)
8947 "Delete the N next (mail) articles.
8948 This command actually deletes articles. This is not a marking
8949 command. The article will disappear forever from your life, never to
8951 If N is negative, delete backwards.
8952 If N is nil and articles have been marked with the process mark,
8953 delete these instead."
8955 (unless (gnus-check-backend-function 'request-expire-articles
8956 gnus-newsgroup-name)
8957 (error "The current newsgroup does not support article deletion"))
8958 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8959 (error "Couldn't open server"))
8960 ;; Compute the list of articles to delete.
8961 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8962 (nnmail-expiry-target 'delete)
8964 (if (and gnus-novice-user
8965 (not (gnus-yes-or-no-p
8966 (format "Do you really want to delete %s forever? "
8967 (if (> (length articles) 1)
8968 (format "these %s articles" (length articles))
8971 ;; Delete the articles.
8972 (setq not-deleted (gnus-request-expire-articles
8973 articles gnus-newsgroup-name 'force))
8975 (gnus-summary-remove-process-mark (car articles))
8976 ;; The backend might not have been able to delete the article
8978 (unless (memq (car articles) not-deleted)
8979 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8980 (setq articles (cdr articles)))
8982 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8983 (gnus-summary-position-point)
8984 (gnus-set-mode-line 'summary)
8987 (defun gnus-summary-edit-article (&optional arg)
8988 "Edit the current article.
8989 This will have permanent effect only in mail groups.
8990 If ARG is nil, edit the decoded articles.
8991 If ARG is 1, edit the raw articles.
8992 If ARG is 2, edit the raw articles even in read-only groups.
8993 If ARG is 3, edit the articles with the current handles.
8994 Otherwise, allow editing of articles even in read-only
8997 (let (force raw current-handles)
9006 (setq current-handles
9007 (and (gnus-buffer-live-p gnus-article-buffer)
9008 (with-current-buffer gnus-article-buffer
9010 gnus-article-mime-handles
9011 (setq gnus-article-mime-handles nil))))))
9014 (when (and raw (not force)
9015 (member gnus-newsgroup-name '("nndraft:delayed"
9018 (error "Can't edit the raw article in group %s"
9019 gnus-newsgroup-name))
9021 (set-buffer gnus-summary-buffer)
9022 (let ((mail-parse-charset gnus-newsgroup-charset)
9023 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9024 (gnus-set-global-variables)
9025 (when (and (not force)
9026 (gnus-group-read-only-p))
9027 (error "The current newsgroup does not support article editing"))
9028 (gnus-summary-show-article t)
9029 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9030 (with-current-buffer gnus-article-buffer
9031 (mm-enable-multibyte)))
9032 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9034 (gnus-article-edit-article
9037 (let ((mbl mml-buffer-list))
9038 (setq mml-buffer-list nil)
9039 (mime-to-mml ,'current-handles)
9040 (let ((mbl1 mml-buffer-list))
9041 (setq mml-buffer-list mbl)
9042 (set (make-local-variable 'mml-buffer-list) mbl1))
9043 (make-local-hook 'kill-buffer-hook)
9044 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9045 `(lambda (no-highlight)
9046 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9047 (message-options message-options)
9048 (message-options-set-recipient)
9049 (mail-parse-ignored-charsets
9050 ',gnus-newsgroup-ignored-charsets))
9051 ,(if (not raw) '(progn
9053 (mml-destroy-buffers)
9054 (remove-hook 'kill-buffer-hook
9055 'mml-destroy-buffers t)
9056 (kill-local-variable 'mml-buffer-list)))
9057 (gnus-summary-edit-article-done
9058 ,(or (mail-header-references gnus-current-headers) "")
9059 ,(gnus-group-read-only-p)
9060 ,gnus-summary-buffer no-highlight))))))))
9062 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9064 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9066 "Make edits to the current article permanent."
9069 ;; The buffer restriction contains the entire article if it exists.
9070 (when (article-goto-body)
9071 (let ((lines (count-lines (point) (point-max)))
9072 (length (- (point-max) (point)))
9073 (case-fold-search t)
9074 (body (copy-marker (point))))
9075 (goto-char (point-min))
9076 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9077 (delete-region (match-beginning 1) (match-end 1))
9078 (insert (number-to-string length)))
9079 (goto-char (point-min))
9080 (when (re-search-forward
9081 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9082 (delete-region (match-beginning 1) (match-end 1))
9083 (insert (number-to-string length)))
9084 (goto-char (point-min))
9085 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9086 (delete-region (match-beginning 1) (match-end 1))
9087 (insert (number-to-string lines))))))
9088 ;; Replace the article.
9089 (let ((buf (current-buffer)))
9091 (insert-buffer-substring buf)
9093 (if (and (not read-only)
9094 (not (gnus-request-replace-article
9095 (cdr gnus-article-current) (car gnus-article-current)
9096 (current-buffer) t)))
9097 (error "Couldn't replace article")
9098 ;; Update the summary buffer.
9100 (equal (message-tokenize-header references " ")
9101 (message-tokenize-header
9102 (or (message-fetch-field "references") "") " ")))
9103 ;; We only have to update this line.
9106 (message-narrow-to-head)
9107 (let ((head (buffer-string))
9110 (insert (format "211 %d Article retrieved.\n"
9111 (cdr gnus-article-current)))
9114 (let ((nntp-server-buffer (current-buffer)))
9115 (setq header (car (gnus-get-newsgroup-headers
9118 (set-buffer gnus-summary-buffer)
9119 (gnus-data-set-header
9120 (gnus-data-find (cdr gnus-article-current))
9122 (gnus-summary-update-article-line
9123 (cdr gnus-article-current) header)
9124 (if (gnus-summary-goto-subject
9125 (cdr gnus-article-current) nil t)
9126 (gnus-summary-update-secondary-mark
9127 (cdr gnus-article-current))))))))
9129 (set-buffer (or buffer gnus-summary-buffer))
9130 (gnus-summary-update-article (cdr gnus-article-current))
9131 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9132 (gnus-summary-update-secondary-mark
9133 (cdr gnus-article-current))))
9134 ;; Prettify the article buffer again.
9135 (unless no-highlight
9137 (set-buffer gnus-article-buffer)
9138 ;;;!!! Fix this -- article should be rehighlighted.
9139 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9140 (set-buffer gnus-original-article-buffer)
9141 (gnus-request-article
9142 (cdr gnus-article-current)
9143 (car gnus-article-current) (current-buffer))))
9144 ;; Prettify the summary buffer line.
9145 (when (gnus-visual-p 'summary-highlight 'highlight)
9146 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9148 (defun gnus-summary-edit-wash (key)
9149 "Perform editing command KEY in the article buffer."
9153 (message "%s" (concat (this-command-keys) "- "))
9156 (gnus-summary-edit-article)
9157 (execute-kbd-macro (concat (this-command-keys) key))
9158 (gnus-article-edit-done))
9162 (defun gnus-summary-respool-query (&optional silent trace)
9163 "Query where the respool algorithm would put this article."
9165 (let (gnus-mark-article-hook)
9166 (gnus-summary-select-article)
9168 (set-buffer gnus-original-article-buffer)
9170 (message-narrow-to-head)
9171 (let ((groups (nnmail-article-group 'identity trace)))
9174 (message "This message would go to %s"
9175 (mapconcat 'car groups ", "))
9176 (message "This message would go to no groups"))
9179 (defun gnus-summary-respool-trace ()
9180 "Trace where the respool algorithm would put this article.
9181 Display a buffer showing all fancy splitting patterns which matched."
9183 (gnus-summary-respool-query nil t))
9185 ;; Summary marking commands.
9187 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9188 "Mark articles which has the same subject as read, and then select the next.
9189 If UNMARK is positive, remove any kind of mark.
9190 If UNMARK is negative, tick articles."
9193 (setq unmark (prefix-numeric-value unmark)))
9195 (gnus-summary-mark-same-subject
9196 (gnus-summary-article-subject) unmark)))
9197 ;; Select next unread article. If auto-select-same mode, should
9198 ;; select the first unread article.
9199 (gnus-summary-next-article t (and gnus-auto-select-same
9200 (gnus-summary-article-subject)))
9201 (gnus-message 7 "%d article%s marked as %s"
9202 count (if (= count 1) " is" "s are")
9203 (if unmark "unread" "read"))))
9205 (defun gnus-summary-kill-same-subject (&optional unmark)
9206 "Mark articles which has the same subject as read.
9207 If UNMARK is positive, remove any kind of mark.
9208 If UNMARK is negative, tick articles."
9211 (setq unmark (prefix-numeric-value unmark)))
9213 (gnus-summary-mark-same-subject
9214 (gnus-summary-article-subject) unmark)))
9215 ;; If marked as read, go to next unread subject.
9217 ;; Go to next unread subject.
9218 (gnus-summary-next-subject 1 t))
9219 (gnus-message 7 "%d articles are marked as %s"
9220 count (if unmark "unread" "read"))))
9222 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9223 "Mark articles with same SUBJECT as read, and return marked number.
9224 If optional argument UNMARK is positive, remove any kinds of marks.
9225 If optional argument UNMARK is negative, mark articles as unread instead."
9229 ((null unmark) ; Mark as read.
9232 (gnus-summary-mark-article-as-read gnus-killed-mark)
9233 (gnus-summary-show-thread) t)
9234 (gnus-summary-find-subject subject))
9235 (setq count (1+ count))))
9236 ((> unmark 0) ; Tick.
9239 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9240 (gnus-summary-show-thread) t)
9241 (gnus-summary-find-subject subject))
9242 (setq count (1+ count))))
9243 (t ; Mark as unread.
9246 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9247 (gnus-summary-show-thread) t)
9248 (gnus-summary-find-subject subject))
9249 (setq count (1+ count)))))
9250 (gnus-set-mode-line 'summary)
9251 ;; Return the number of marked articles.
9254 (defun gnus-summary-mark-as-processable (n &optional unmark)
9255 "Set the process mark on the next N articles.
9256 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9257 the process mark instead. The difference between N and the actual
9258 number of articles marked is returned."
9260 (if (and (null n) (gnus-region-active-p))
9261 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9262 (setq n (prefix-numeric-value n))
9263 (let ((backward (< n 0))
9268 (gnus-summary-remove-process-mark
9269 (gnus-summary-article-number))
9270 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9271 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9274 (gnus-message 7 "No more articles"))
9275 (gnus-summary-recenter)
9276 (gnus-summary-position-point)
9279 (defun gnus-summary-unmark-as-processable (n)
9280 "Remove the process mark from the next N articles.
9281 If N is negative, unmark backward instead. The difference between N and
9282 the actual number of articles unmarked is returned."
9284 (gnus-summary-mark-as-processable n t))
9286 (defun gnus-summary-unmark-all-processable ()
9287 "Remove the process mark from all articles."
9290 (while gnus-newsgroup-processable
9291 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9292 (gnus-summary-position-point))
9294 (defun gnus-summary-add-mark (article type)
9295 "Mark ARTICLE with a mark of TYPE."
9296 (let ((vtype (car (assq type gnus-article-mark-lists)))
9299 (error "No such mark type: %s" type)
9300 (setq var (intern (format "gnus-newsgroup-%s" type)))
9301 (set var (cons article (symbol-value var)))
9302 (if (memq type '(processable cached replied forwarded recent saved))
9303 (gnus-summary-update-secondary-mark article)
9304 ;;; !!! This is bogus. We should find out what primary
9305 ;;; !!! mark we want to set.
9306 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9308 (defun gnus-summary-mark-as-expirable (n)
9309 "Mark N articles forward as expirable.
9310 If N is negative, mark backward instead. The difference between N and
9311 the actual number of articles marked is returned."
9313 (gnus-summary-mark-forward n gnus-expirable-mark))
9315 (defun gnus-summary-mark-as-spam (n)
9316 "Mark N articles forward as spam.
9317 If N is negative, mark backward instead. The difference between N and
9318 the actual number of articles marked is returned."
9320 (gnus-summary-mark-forward n gnus-spam-mark))
9322 (defun gnus-summary-mark-article-as-replied (article)
9323 "Mark ARTICLE as replied to and update the summary line.
9324 ARTICLE can also be a list of articles."
9325 (interactive (list (gnus-summary-article-number)))
9326 (let ((articles (if (listp article) article (list article))))
9327 (dolist (article articles)
9328 (push article gnus-newsgroup-replied)
9329 (let ((buffer-read-only nil))
9330 (when (gnus-summary-goto-subject article nil t)
9331 (gnus-summary-update-secondary-mark article))))))
9333 (defun gnus-summary-mark-article-as-forwarded (article)
9334 "Mark ARTICLE as forwarded and update the summary line.
9335 ARTICLE can also be a list of articles."
9336 (let ((articles (if (listp article) article (list article))))
9337 (dolist (article articles)
9338 (push article gnus-newsgroup-forwarded)
9339 (let ((buffer-read-only nil))
9340 (when (gnus-summary-goto-subject article nil t)
9341 (gnus-summary-update-secondary-mark article))))))
9343 (defun gnus-summary-set-bookmark (article)
9344 "Set a bookmark in current article."
9345 (interactive (list (gnus-summary-article-number)))
9346 (when (or (not (get-buffer gnus-article-buffer))
9347 (not gnus-current-article)
9348 (not gnus-article-current)
9349 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9350 (error "No current article selected"))
9351 ;; Remove old bookmark, if one exists.
9352 (let ((old (assq article gnus-newsgroup-bookmarks)))
9354 (setq gnus-newsgroup-bookmarks
9355 (delq old gnus-newsgroup-bookmarks))))
9356 ;; Set the new bookmark, which is on the form
9357 ;; (article-number . line-number-in-body).
9361 (set-buffer gnus-article-buffer)
9365 (goto-char (point-min))
9366 (search-forward "\n\n" nil t)
9369 gnus-newsgroup-bookmarks)
9370 (gnus-message 6 "A bookmark has been added to the current article."))
9372 (defun gnus-summary-remove-bookmark (article)
9373 "Remove the bookmark from the current article."
9374 (interactive (list (gnus-summary-article-number)))
9375 ;; Remove old bookmark, if one exists.
9376 (let ((old (assq article gnus-newsgroup-bookmarks)))
9379 (setq gnus-newsgroup-bookmarks
9380 (delq old gnus-newsgroup-bookmarks))
9381 (gnus-message 6 "Removed bookmark."))
9382 (gnus-message 6 "No bookmark in current article."))))
9384 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9385 (defun gnus-summary-mark-as-dormant (n)
9386 "Mark N articles forward as dormant.
9387 If N is negative, mark backward instead. The difference between N and
9388 the actual number of articles marked is returned."
9390 (gnus-summary-mark-forward n gnus-dormant-mark))
9392 (defun gnus-summary-set-process-mark (article)
9393 "Set the process mark on ARTICLE and update the summary line."
9394 (setq gnus-newsgroup-processable
9396 (delq article gnus-newsgroup-processable)))
9397 (when (gnus-summary-goto-subject article)
9398 (gnus-summary-show-thread)
9399 (gnus-summary-goto-subject article)
9400 (gnus-summary-update-secondary-mark article)))
9402 (defun gnus-summary-remove-process-mark (article)
9403 "Remove the process mark from ARTICLE and update the summary line."
9404 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9405 (when (gnus-summary-goto-subject article)
9406 (gnus-summary-show-thread)
9407 (gnus-summary-goto-subject article)
9408 (gnus-summary-update-secondary-mark article)))
9410 (defun gnus-summary-set-saved-mark (article)
9411 "Set the process mark on ARTICLE and update the summary line."
9412 (push article gnus-newsgroup-saved)
9413 (when (gnus-summary-goto-subject article)
9414 (gnus-summary-update-secondary-mark article)))
9416 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9417 "Mark N articles as read forwards.
9418 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9419 The difference between N and the actual number of articles marked is
9421 If NO-EXPIRE, auto-expiry will be inhibited."
9423 (gnus-summary-show-thread)
9424 (let ((backward (< n 0))
9425 (gnus-summary-goto-unread
9426 (and gnus-summary-goto-unread
9427 (not (eq gnus-summary-goto-unread 'never))
9428 (not (memq mark (list gnus-unread-mark
9429 gnus-ticked-mark gnus-dormant-mark)))))
9431 (mark (or mark gnus-del-mark)))
9433 (gnus-summary-mark-article nil mark no-expire)
9434 (zerop (gnus-summary-next-subject
9436 (and gnus-summary-goto-unread
9437 (not (eq gnus-summary-goto-unread 'never)))
9441 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9442 (gnus-summary-recenter)
9443 (gnus-summary-position-point)
9444 (gnus-set-mode-line 'summary)
9447 (defun gnus-summary-mark-article-as-read (mark)
9448 "Mark the current article quickly as read with MARK."
9449 (let ((article (gnus-summary-article-number)))
9450 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9451 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9452 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9453 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9454 (push (cons article mark) gnus-newsgroup-reads)
9455 ;; Possibly remove from cache, if that is used.
9456 (when gnus-use-cache
9457 (gnus-cache-enter-remove-article article))
9458 ;; Allow the backend to change the mark.
9459 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9460 ;; Check for auto-expiry.
9461 (when (and gnus-newsgroup-auto-expire
9462 (memq mark gnus-auto-expirable-marks))
9463 (setq mark gnus-expirable-mark)
9464 ;; Let the backend know about the mark change.
9465 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9466 (push article gnus-newsgroup-expirable))
9467 ;; Set the mark in the buffer.
9468 (gnus-summary-update-mark mark 'unread)
9471 (defun gnus-summary-mark-article-as-unread (mark)
9472 "Mark the current article quickly as unread with MARK."
9473 (let* ((article (gnus-summary-article-number))
9474 (old-mark (gnus-summary-article-mark article)))
9475 ;; Allow the backend to change the mark.
9476 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9477 (if (eq mark old-mark)
9481 (gnus-error 1 "Can't mark negative article numbers")
9483 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9484 (setq gnus-newsgroup-spam-marked
9485 (delq article gnus-newsgroup-spam-marked))
9486 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9487 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9488 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9489 (cond ((= mark gnus-ticked-mark)
9490 (setq gnus-newsgroup-marked
9491 (gnus-add-to-sorted-list gnus-newsgroup-marked
9493 ((= mark gnus-spam-mark)
9494 (setq gnus-newsgroup-spam-marked
9495 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9497 ((= mark gnus-dormant-mark)
9498 (setq gnus-newsgroup-dormant
9499 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9502 (setq gnus-newsgroup-unreads
9503 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9505 (gnus-pull article gnus-newsgroup-reads)
9507 ;; See whether the article is to be put in the cache.
9509 (vectorp (gnus-summary-article-header article))
9511 (gnus-cache-possibly-enter-article
9512 gnus-newsgroup-name article
9513 (= mark gnus-ticked-mark)
9514 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9517 (gnus-summary-update-mark mark 'unread)
9520 (defun gnus-summary-mark-article (&optional article mark no-expire)
9521 "Mark ARTICLE with MARK. MARK can be any character.
9522 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9523 `??' (dormant) and `?E' (expirable).
9524 If MARK is nil, then the default character `?r' is used.
9525 If ARTICLE is nil, then the article on the current line will be
9527 If NO-EXPIRE, auto-expiry will be inhibited."
9528 ;; The mark might be a string.
9529 (when (stringp mark)
9530 (setq mark (aref mark 0)))
9531 ;; If no mark is given, then we check auto-expiring.
9533 (setq mark gnus-del-mark))
9534 (when (and (not no-expire)
9535 gnus-newsgroup-auto-expire
9536 (memq mark gnus-auto-expirable-marks))
9537 (setq mark gnus-expirable-mark))
9538 (let ((article (or article (gnus-summary-article-number)))
9539 (old-mark (gnus-summary-article-mark article)))
9540 ;; Allow the backend to change the mark.
9541 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9542 (if (eq mark old-mark)
9545 (error "No article on current line"))
9546 (if (not (if (or (= mark gnus-unread-mark)
9547 (= mark gnus-ticked-mark)
9548 (= mark gnus-spam-mark)
9549 (= mark gnus-dormant-mark))
9550 (gnus-mark-article-as-unread article mark)
9551 (gnus-mark-article-as-read article mark)))
9553 ;; See whether the article is to be put in the cache.
9555 (not (= mark gnus-canceled-mark))
9556 (vectorp (gnus-summary-article-header article))
9558 (gnus-cache-possibly-enter-article
9559 gnus-newsgroup-name article
9560 (= mark gnus-ticked-mark)
9561 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9563 (when (gnus-summary-goto-subject article nil t)
9564 (let ((buffer-read-only nil))
9565 (gnus-summary-show-thread)
9567 (gnus-summary-update-mark mark 'unread)
9570 (defun gnus-summary-update-secondary-mark (article)
9571 "Update the secondary (read, process, cache) mark."
9572 (gnus-summary-update-mark
9573 (cond ((memq article gnus-newsgroup-processable)
9575 ((memq article gnus-newsgroup-cached)
9577 ((memq article gnus-newsgroup-replied)
9579 ((memq article gnus-newsgroup-forwarded)
9580 gnus-forwarded-mark)
9581 ((memq article gnus-newsgroup-saved)
9583 ((memq article gnus-newsgroup-recent)
9585 ((memq article gnus-newsgroup-unseen)
9589 (when (gnus-visual-p 'summary-highlight 'highlight)
9590 (gnus-run-hooks 'gnus-summary-update-hook))
9593 (defun gnus-summary-update-download-mark (article)
9594 "Update the secondary (read, process, cache) mark."
9595 (gnus-summary-update-mark
9596 (cond ((memq article gnus-newsgroup-undownloaded)
9597 gnus-undownloaded-mark)
9598 (gnus-newsgroup-agentized
9599 gnus-downloaded-mark)
9603 (gnus-summary-update-line t)
9606 (defun gnus-summary-update-mark (mark type)
9607 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9608 (buffer-read-only nil))
9609 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9611 (when (looking-at "\r")
9613 (when (<= (+ forward (point)) (point-max))
9614 ;; Go to the right position on the line.
9615 (goto-char (+ forward (point)))
9616 ;; Replace the old mark with the new mark.
9617 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9618 ;; Optionally update the marks by some user rule.
9619 (when (eq type 'unread)
9621 (gnus-data-find (gnus-summary-article-number)) mark)
9622 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9624 (defun gnus-mark-article-as-read (article &optional mark)
9625 "Enter ARTICLE in the pertinent lists and remove it from others."
9626 ;; Make the article expirable.
9627 (let ((mark (or mark gnus-del-mark)))
9628 (setq gnus-newsgroup-expirable
9629 (if (= mark gnus-expirable-mark)
9630 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9631 (delq article gnus-newsgroup-expirable)))
9632 ;; Remove from unread and marked lists.
9633 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9634 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9635 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9636 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9637 (push (cons article mark) gnus-newsgroup-reads)
9638 ;; Possibly remove from cache, if that is used.
9639 (when gnus-use-cache
9640 (gnus-cache-enter-remove-article article))
9643 (defun gnus-mark-article-as-unread (article &optional mark)
9644 "Enter ARTICLE in the pertinent lists and remove it from others."
9645 (let ((mark (or mark gnus-ticked-mark)))
9648 (gnus-error 1 "Can't mark negative article numbers")
9650 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9651 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9652 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9653 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9654 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9656 ;; Unsuppress duplicates?
9657 (when gnus-suppress-duplicates
9658 (gnus-dup-unsuppress-article article))
9660 (cond ((= mark gnus-ticked-mark)
9661 (setq gnus-newsgroup-marked
9662 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9663 ((= mark gnus-spam-mark)
9664 (setq gnus-newsgroup-spam-marked
9665 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9667 ((= mark gnus-dormant-mark)
9668 (setq gnus-newsgroup-dormant
9669 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9671 (setq gnus-newsgroup-unreads
9672 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9673 (gnus-pull article gnus-newsgroup-reads)
9676 (defalias 'gnus-summary-mark-as-unread-forward
9677 'gnus-summary-tick-article-forward)
9678 (make-obsolete 'gnus-summary-mark-as-unread-forward
9679 'gnus-summary-tick-article-forward)
9680 (defun gnus-summary-tick-article-forward (n)
9681 "Tick N articles forwards.
9682 If N is negative, tick backwards instead.
9683 The difference between N and the number of articles ticked is returned."
9685 (gnus-summary-mark-forward n gnus-ticked-mark))
9687 (defalias 'gnus-summary-mark-as-unread-backward
9688 'gnus-summary-tick-article-backward)
9689 (make-obsolete 'gnus-summary-mark-as-unread-backward
9690 'gnus-summary-tick-article-backward)
9691 (defun gnus-summary-tick-article-backward (n)
9692 "Tick N articles backwards.
9693 The difference between N and the number of articles ticked is returned."
9695 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9697 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9698 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9699 (defun gnus-summary-tick-article (&optional article clear-mark)
9700 "Mark current article as unread.
9701 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9702 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9704 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9707 (defun gnus-summary-mark-as-read-forward (n)
9708 "Mark N articles as read forwards.
9709 If N is negative, mark backwards instead.
9710 The difference between N and the actual number of articles marked is
9713 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9715 (defun gnus-summary-mark-as-read-backward (n)
9716 "Mark the N articles as read backwards.
9717 The difference between N and the actual number of articles marked is
9720 (gnus-summary-mark-forward
9721 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9723 (defun gnus-summary-mark-as-read (&optional article mark)
9724 "Mark current article as read.
9725 ARTICLE specifies the article to be marked as read.
9726 MARK specifies a string to be inserted at the beginning of the line."
9727 (gnus-summary-mark-article article mark))
9729 (defun gnus-summary-clear-mark-forward (n)
9730 "Clear marks from N articles forward.
9731 If N is negative, clear backward instead.
9732 The difference between N and the number of marks cleared is returned."
9734 (gnus-summary-mark-forward n gnus-unread-mark))
9736 (defun gnus-summary-clear-mark-backward (n)
9737 "Clear marks from N articles backward.
9738 The difference between N and the number of marks cleared is returned."
9740 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9742 (defun gnus-summary-mark-unread-as-read ()
9743 "Intended to be used by `gnus-summary-mark-article-hook'."
9744 (when (memq gnus-current-article gnus-newsgroup-unreads)
9745 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9747 (defun gnus-summary-mark-read-and-unread-as-read ()
9748 "Intended to be used by `gnus-summary-mark-article-hook'."
9749 (let ((mark (gnus-summary-article-mark)))
9750 (when (or (gnus-unread-mark-p mark)
9751 (gnus-read-mark-p mark))
9752 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9754 (defun gnus-summary-mark-unread-as-ticked ()
9755 "Intended to be used by `gnus-summary-mark-article-hook'."
9756 (when (memq gnus-current-article gnus-newsgroup-unreads)
9757 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9759 (defun gnus-summary-mark-region-as-read (point mark all)
9760 "Mark all unread articles between point and mark as read.
9761 If given a prefix, mark all articles between point and mark as read,
9762 even ticked and dormant ones."
9763 (interactive "r\nP")
9772 (memq (setq article (gnus-summary-article-number))
9773 gnus-newsgroup-unreads))
9774 (gnus-summary-mark-article article gnus-del-mark))
9776 (gnus-summary-find-next))))))
9778 (defun gnus-summary-mark-below (score mark)
9779 "Mark articles with score less than 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))
9789 (and (< (gnus-summary-article-score) score)
9790 (gnus-summary-mark-article nil mark))
9791 (gnus-summary-find-next)))))
9793 (defun gnus-summary-kill-below (&optional score)
9794 "Mark articles with score below SCORE as read."
9796 (gnus-summary-mark-below score gnus-killed-mark))
9798 (defun gnus-summary-clear-above (&optional score)
9799 "Clear all marks from articles with score above SCORE."
9801 (gnus-summary-mark-above score gnus-unread-mark))
9803 (defun gnus-summary-tick-above (&optional score)
9804 "Tick all articles with score above SCORE."
9806 (gnus-summary-mark-above score gnus-ticked-mark))
9808 (defun gnus-summary-mark-above (score mark)
9809 "Mark articles with score over SCORE with MARK."
9810 (interactive "P\ncMark: ")
9811 (setq score (if score
9812 (prefix-numeric-value score)
9813 (or gnus-summary-default-score 0)))
9815 (set-buffer gnus-summary-buffer)
9816 (goto-char (point-min))
9818 (when (> (gnus-summary-article-score) score)
9819 (gnus-summary-mark-article nil mark))
9821 (gnus-summary-find-next)))))
9823 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9824 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9825 (defun gnus-summary-limit-include-expunged (&optional no-error)
9826 "Display all the hidden articles that were expunged for low scores."
9828 (let ((buffer-read-only nil))
9829 (let ((scored gnus-newsgroup-scored)
9832 (unless (gnus-summary-article-header (caar scored))
9833 (and (setq h (gnus-number-to-header (caar scored)))
9834 (< (cdar scored) gnus-summary-expunge-below)
9836 (setq scored (cdr scored)))
9838 (when (not no-error)
9839 (error "No expunged articles hidden"))
9840 (goto-char (point-min))
9841 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9842 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9843 (mapcar (lambda (x) (push (mail-header-number x)
9844 gnus-newsgroup-limit))
9846 (gnus-summary-prepare-unthreaded (nreverse headers))
9847 (goto-char (point-min))
9848 (gnus-summary-position-point)
9851 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9852 "Mark all unread articles in this newsgroup as read.
9853 If prefix argument ALL is non-nil, ticked and dormant articles will
9854 also be marked as read.
9855 If QUIETLY is non-nil, no questions will be asked.
9856 If TO-HERE is non-nil, it should be a point in the buffer. All
9857 articles before (after, if REVERSE is set) this point will be marked as read.
9858 Note that this function will only catch up the unread article
9859 in the current summary buffer limitation.
9860 The number of articles marked as read is returned."
9865 (not gnus-interactive-catchup) ;Without confirmation?
9869 "Mark absolutely all articles as read? "
9870 "Mark all unread articles as read? ")))
9872 (not gnus-newsgroup-adaptive)
9873 (not gnus-newsgroup-auto-expire)
9874 (not gnus-suppress-duplicates)
9875 (or (not gnus-use-cache)
9876 (eq gnus-use-cache 'passive)))
9879 (setq gnus-newsgroup-marked nil
9880 gnus-newsgroup-spam-marked nil
9881 gnus-newsgroup-dormant nil))
9882 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9883 ;; We actually mark all articles as canceled, which we
9884 ;; have to do when using auto-expiry or adaptive scoring.
9885 (gnus-summary-show-all-threads)
9886 (if (and to-here reverse)
9890 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9891 (gnus-summary-find-next (not all) nil nil t))))
9892 (when (gnus-summary-first-subject (not all) t)
9894 (if to-here (< (point) to-here) t)
9895 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9896 (gnus-summary-find-next (not all) nil nil t)))))
9897 (gnus-set-mode-line 'summary))
9899 (gnus-summary-position-point)))
9901 (defun gnus-summary-catchup-to-here (&optional all)
9902 "Mark all unticked articles before the current one as read.
9903 If ALL is non-nil, also mark ticked and dormant articles as read."
9906 (gnus-save-hidden-threads
9907 (let ((beg (point)))
9908 ;; We check that there are unread articles.
9909 (when (or all (gnus-summary-find-prev))
9910 (gnus-summary-catchup all t beg)))))
9911 (gnus-summary-position-point))
9913 (defun gnus-summary-catchup-from-here (&optional all)
9914 "Mark all unticked articles after the current one as read.
9915 If ALL is non-nil, also mark ticked and dormant articles as read."
9918 (gnus-save-hidden-threads
9919 (let ((beg (point)))
9920 ;; We check that there are unread articles.
9921 (when (or all (gnus-summary-find-next))
9922 (gnus-summary-catchup all t beg nil t)))))
9924 (gnus-summary-position-point))
9925 (defun gnus-summary-catchup-all (&optional quietly)
9926 "Mark all articles in this newsgroup as read.
9927 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
9928 instead, which marks only unread articles as read."
9930 (gnus-summary-catchup t quietly))
9932 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9933 "Mark all unread articles in this group as read, then exit.
9934 If prefix argument ALL is non-nil, all articles are marked as read.
9935 If QUIETLY is non-nil, no questions will be asked."
9937 (when (gnus-summary-catchup all quietly nil 'fast)
9938 ;; Select next newsgroup or exit.
9939 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9940 (eq gnus-auto-select-next 'quietly))
9941 (gnus-summary-next-group nil)
9942 (gnus-summary-exit))))
9944 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9945 "Mark all articles in this newsgroup as read, and then exit.
9946 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
9947 instead, which marks only unread articles as read."
9949 (gnus-summary-catchup-and-exit t quietly))
9951 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9952 "Mark all articles in this group as read and select the next group.
9953 If given a prefix, mark all articles, unread as well as ticked, as
9957 (gnus-summary-catchup all))
9958 (gnus-summary-next-group))
9964 (defmacro gnus-with-article (article &rest forms)
9965 "Select ARTICLE and perform FORMS in the original article buffer.
9966 Then replace the article with the result."
9968 ;; We don't want the article to be marked as read.
9969 (let (gnus-mark-article-hook)
9970 (gnus-summary-select-article t t nil ,article))
9971 (set-buffer gnus-original-article-buffer)
9973 (if (not (gnus-check-backend-function
9974 'request-replace-article (car gnus-article-current)))
9975 (gnus-message 5 "Read-only group; not replacing")
9976 (unless (gnus-request-replace-article
9977 ,article (car gnus-article-current)
9979 (error "Couldn't replace article")))
9980 ;; The cache and backlog have to be flushed somewhat.
9981 (when gnus-keep-backlog
9982 (gnus-backlog-remove-article
9983 (car gnus-article-current) (cdr gnus-article-current)))
9984 (when gnus-use-cache
9985 (gnus-cache-update-article
9986 (car gnus-article-current) (cdr gnus-article-current)))))
9988 (put 'gnus-with-article 'lisp-indent-function 1)
9989 (put 'gnus-with-article 'edebug-form-spec '(form body))
9991 ;; Thread-based commands.
9993 (defun gnus-summary-articles-in-thread (&optional article)
9994 "Return a list of all articles in the current thread.
9995 If ARTICLE is non-nil, return all articles in the thread that starts
9997 (let* ((article (or article (gnus-summary-article-number)))
9998 (data (gnus-data-find-list article))
9999 (top-level (gnus-data-level (car data)))
10001 (cond ((null gnus-thread-operation-ignore-subject)
10002 (gnus-simplify-subject-re
10003 (mail-header-subject (gnus-data-header (car data)))))
10004 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10005 (gnus-simplify-subject-fuzzy
10006 (mail-header-subject (gnus-data-header (car data)))))
10008 (end-point (save-excursion
10009 (if (gnus-summary-go-to-next-thread)
10010 (point) (point-max))))
10013 (< (gnus-data-pos (car data)) end-point))
10014 (when (or (not top-subject)
10015 (string= top-subject
10016 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10017 (gnus-simplify-subject-fuzzy
10018 (mail-header-subject
10019 (gnus-data-header (car data))))
10020 (gnus-simplify-subject-re
10021 (mail-header-subject
10022 (gnus-data-header (car data)))))))
10023 (push (gnus-data-number (car data)) articles))
10024 (unless (and (setq data (cdr data))
10025 (> (gnus-data-level (car data)) top-level))
10027 ;; Return the list of articles.
10028 (nreverse articles)))
10030 (defun gnus-summary-rethread-current ()
10031 "Rethread the thread the current article is part of."
10033 (let* ((gnus-show-threads t)
10034 (article (gnus-summary-article-number))
10035 (id (mail-header-id (gnus-summary-article-header)))
10036 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10038 (error "No article on the current line"))
10039 (gnus-rebuild-thread id)
10040 (gnus-summary-goto-subject article)))
10042 (defun gnus-summary-reparent-thread ()
10043 "Make the current article child of the marked (or previous) article.
10045 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10046 is non-nil or the Subject: of both articles are the same."
10048 (unless (not (gnus-group-read-only-p))
10049 (error "The current newsgroup does not support article editing"))
10050 (unless (<= (length gnus-newsgroup-processable) 1)
10051 (error "No more than one article may be marked"))
10052 (save-window-excursion
10053 (let ((gnus-article-buffer " *reparent*")
10054 (current-article (gnus-summary-article-number))
10055 ;; First grab the marked article, otherwise one line up.
10056 (parent-article (if (not (null gnus-newsgroup-processable))
10057 (car gnus-newsgroup-processable)
10059 (if (eq (forward-line -1) 0)
10060 (gnus-summary-article-number)
10061 (error "Beginning of summary buffer"))))))
10062 (unless (not (eq current-article parent-article))
10063 (error "An article may not be self-referential"))
10064 (let ((message-id (mail-header-id
10065 (gnus-summary-article-header parent-article))))
10066 (unless (and message-id (not (equal message-id "")))
10067 (error "No message-id in desired parent"))
10068 (gnus-with-article current-article
10070 (goto-char (point-min))
10071 (message-narrow-to-head)
10072 (if (re-search-forward "^References: " nil t)
10074 (re-search-forward "^[^ \t]" nil t)
10077 (insert " " message-id))
10078 (insert "References: " message-id "\n"))))
10079 (set-buffer gnus-summary-buffer)
10080 (gnus-summary-unmark-all-processable)
10081 (gnus-summary-update-article current-article)
10082 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10083 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10084 (gnus-summary-rethread-current)
10085 (gnus-message 3 "Article %d is now the child of article %d"
10086 current-article parent-article)))))
10088 (defun gnus-summary-toggle-threads (&optional arg)
10089 "Toggle showing conversation threads.
10090 If ARG is positive number, turn showing conversation threads on."
10092 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10093 (setq gnus-show-threads
10094 (if (null arg) (not gnus-show-threads)
10095 (> (prefix-numeric-value arg) 0)))
10096 (gnus-summary-prepare)
10097 (gnus-summary-goto-subject current)
10098 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10099 (gnus-summary-position-point)))
10101 (defun gnus-summary-show-all-threads ()
10102 "Show all threads."
10105 (let ((buffer-read-only nil))
10106 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10107 (gnus-summary-position-point))
10109 (defun gnus-summary-show-thread ()
10110 "Show thread subtrees.
10111 Returns nil if no thread was there to be shown."
10113 (let ((buffer-read-only nil)
10115 ;; first goto end then to beg, to have point at beg after let
10116 (end (progn (end-of-line) (point)))
10117 (beg (progn (beginning-of-line) (point))))
10119 ;; Any hidden lines here?
10120 (search-forward "\r" end t)
10121 (subst-char-in-region beg end ?\^M ?\n t)
10123 (gnus-summary-position-point))))
10125 (defun gnus-summary-maybe-hide-threads ()
10126 "If requested, hide the threads that should be hidden."
10127 (when (and gnus-show-threads
10128 gnus-thread-hide-subtree)
10129 (gnus-summary-hide-all-threads
10130 (if (or (consp gnus-thread-hide-subtree)
10131 (gnus-functionp gnus-thread-hide-subtree))
10132 (gnus-make-predicate gnus-thread-hide-subtree)
10135 ;;; Hiding predicates.
10137 (defun gnus-article-unread-p (header)
10138 (memq (mail-header-number header) gnus-newsgroup-unreads))
10140 (defun gnus-article-unseen-p (header)
10141 (memq (mail-header-number header) gnus-newsgroup-unseen))
10143 (defun gnus-map-articles (predicate articles)
10144 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10145 (apply 'gnus-or (mapcar predicate
10146 (mapcar 'gnus-summary-article-header articles))))
10148 (defun gnus-summary-hide-all-threads (&optional predicate)
10149 "Hide all thread subtrees.
10150 If PREDICATE is supplied, threads that satisfy this predicate
10151 will not be hidden."
10154 (goto-char (point-min))
10157 (when (or (not predicate)
10159 predicate (gnus-summary-article-children)))
10160 (gnus-summary-hide-thread))
10161 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10162 (gnus-summary-position-point))
10164 (defun gnus-summary-hide-thread ()
10165 "Hide thread subtrees.
10166 If PREDICATE is supplied, threads that satisfy this predicate
10167 will not be hidden.
10168 Returns nil if no threads were there to be hidden."
10170 (let ((buffer-read-only nil)
10172 (article (gnus-summary-article-number)))
10174 ;; Go forward until either the buffer ends or the subthread
10176 (when (and (not (eobp))
10177 (or (zerop (gnus-summary-next-thread 1 t))
10178 (goto-char (point-max))))
10180 (if (and (> (point) start)
10181 (search-backward "\n" start t))
10183 (subst-char-in-region start (point) ?\n ?\^M)
10184 (gnus-summary-goto-subject article))
10188 (defun gnus-summary-go-to-next-thread (&optional previous)
10189 "Go to the same level (or less) next thread.
10190 If PREVIOUS is non-nil, go to previous thread instead.
10191 Return the article number moved to, or nil if moving was impossible."
10192 (let ((level (gnus-summary-thread-level))
10193 (way (if previous -1 1))
10196 (while (and (not (eobp))
10197 (< level (gnus-summary-thread-level)))
10198 (forward-line way))
10205 (gnus-summary-article-number)
10206 (goto-char beg)))))
10208 (defun gnus-summary-next-thread (n &optional silent)
10209 "Go to the same level next N'th thread.
10210 If N is negative, search backward instead.
10211 Returns the difference between N and the number of skips actually
10214 If SILENT, don't output messages."
10216 (let ((backward (< n 0))
10218 (while (and (> n 0)
10219 (gnus-summary-go-to-next-thread backward))
10222 (gnus-summary-position-point))
10223 (when (and (not silent) (/= 0 n))
10224 (gnus-message 7 "No more threads"))
10227 (defun gnus-summary-prev-thread (n)
10228 "Go to the same level previous N'th thread.
10229 Returns the difference between N and the number of skips actually
10232 (gnus-summary-next-thread (- n)))
10234 (defun gnus-summary-go-down-thread ()
10235 "Go down one level in the current thread."
10236 (let ((children (gnus-summary-article-children)))
10238 (gnus-summary-goto-subject (car children)))))
10240 (defun gnus-summary-go-up-thread ()
10241 "Go up one level in the current thread."
10242 (let ((parent (gnus-summary-article-parent)))
10244 (gnus-summary-goto-subject parent))))
10246 (defun gnus-summary-down-thread (n)
10247 "Go down thread N steps.
10248 If N is negative, go up instead.
10249 Returns the difference between N and how many steps down that were
10254 (while (and (> n 0)
10255 (if up (gnus-summary-go-up-thread)
10256 (gnus-summary-go-down-thread)))
10258 (gnus-summary-position-point)
10260 (gnus-message 7 "Can't go further"))
10263 (defun gnus-summary-up-thread (n)
10264 "Go up thread N steps.
10265 If N is negative, go down instead.
10266 Returns the difference between N and how many steps down that were
10269 (gnus-summary-down-thread (- n)))
10271 (defun gnus-summary-top-thread ()
10272 "Go to the top of the thread."
10274 (while (gnus-summary-go-up-thread))
10275 (gnus-summary-article-number))
10277 (defun gnus-summary-kill-thread (&optional unmark)
10278 "Mark articles under current thread as read.
10279 If the prefix argument is positive, remove any kinds of marks.
10280 If the prefix argument is negative, tick articles instead."
10283 (setq unmark (prefix-numeric-value unmark)))
10284 (let ((articles (gnus-summary-articles-in-thread)))
10286 ;; Expand the thread.
10287 (gnus-summary-show-thread)
10288 ;; Mark all the articles.
10290 (gnus-summary-goto-subject (car articles))
10291 (cond ((null unmark)
10292 (gnus-summary-mark-article-as-read gnus-killed-mark))
10294 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10296 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10297 (setq articles (cdr articles))))
10298 ;; Hide killed subtrees.
10300 gnus-thread-hide-killed
10301 (gnus-summary-hide-thread))
10302 ;; If marked as read, go to next unread subject.
10303 (when (null unmark)
10304 ;; Go to next unread subject.
10305 (gnus-summary-next-subject 1 t)))
10306 (gnus-set-mode-line 'summary))
10308 ;; Summary sorting commands
10310 (defun gnus-summary-sort-by-number (&optional reverse)
10311 "Sort the summary buffer by article number.
10312 Argument REVERSE means reverse order."
10314 (gnus-summary-sort 'number reverse))
10316 (defun gnus-summary-sort-by-random (&optional reverse)
10317 "Randomize the order in the summary buffer.
10318 Argument REVERSE means to randomize in reverse order."
10320 (gnus-summary-sort 'random reverse))
10322 (defun gnus-summary-sort-by-author (&optional reverse)
10323 "Sort the summary buffer by author name alphabetically.
10324 If `case-fold-search' is non-nil, case of letters is ignored.
10325 Argument REVERSE means reverse order."
10327 (gnus-summary-sort 'author reverse))
10329 (defun gnus-summary-sort-by-subject (&optional reverse)
10330 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10331 If `case-fold-search' is non-nil, case of letters is ignored.
10332 Argument REVERSE means reverse order."
10334 (gnus-summary-sort 'subject reverse))
10336 (defun gnus-summary-sort-by-date (&optional reverse)
10337 "Sort the summary buffer by date.
10338 Argument REVERSE means reverse order."
10340 (gnus-summary-sort 'date reverse))
10342 (defun gnus-summary-sort-by-score (&optional reverse)
10343 "Sort the summary buffer by score.
10344 Argument REVERSE means reverse order."
10346 (gnus-summary-sort 'score reverse))
10348 (defun gnus-summary-sort-by-lines (&optional reverse)
10349 "Sort the summary buffer by the number of lines.
10350 Argument REVERSE means reverse order."
10352 (gnus-summary-sort 'lines reverse))
10354 (defun gnus-summary-sort-by-chars (&optional reverse)
10355 "Sort the summary buffer by article length.
10356 Argument REVERSE means reverse order."
10358 (gnus-summary-sort 'chars reverse))
10360 (defun gnus-summary-sort-by-original (&optional reverse)
10361 "Sort the summary buffer using the default sorting method.
10362 Argument REVERSE means reverse order."
10364 (let* ((buffer-read-only)
10365 (gnus-summary-prepare-hook nil))
10366 ;; We do the sorting by regenerating the threads.
10367 (gnus-summary-prepare)
10368 ;; Hide subthreads if needed.
10369 (gnus-summary-maybe-hide-threads)))
10371 (defun gnus-summary-sort (predicate reverse)
10372 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10373 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10374 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10375 (gnus-thread-sort-functions
10380 (gnus-sort-gathered-threads-function
10381 gnus-thread-sort-functions)
10382 (gnus-article-sort-functions
10386 (,article t2 t1))))
10388 (gnus-summary-prepare-hook nil))
10389 ;; We do the sorting by regenerating the threads.
10390 (gnus-summary-prepare)
10391 ;; Hide subthreads if needed.
10392 (gnus-summary-maybe-hide-threads)))
10394 ;; Summary saving commands.
10396 (defun gnus-summary-save-article (&optional n not-saved)
10397 "Save the current article using the default saver function.
10398 If N is a positive number, save the N next articles.
10399 If N is a negative number, save the N previous articles.
10400 If N is nil and any articles have been marked with the process mark,
10401 save those articles instead.
10402 The variable `gnus-default-article-saver' specifies the saver function."
10404 (let* ((articles (gnus-summary-work-articles n))
10405 (save-buffer (save-excursion
10406 (nnheader-set-temp-buffer " *Gnus Save*")))
10407 (num (length articles))
10409 (dolist (article articles)
10410 (setq header (gnus-summary-article-header article))
10411 (if (not (vectorp header))
10412 ;; This is a pseudo-article.
10413 (if (assq 'name header)
10414 (gnus-copy-file (cdr (assq 'name header)))
10415 (gnus-message 1 "Article %d is unsaveable" article))
10416 ;; This is a real article.
10417 (save-window-excursion
10418 (let ((gnus-display-mime-function nil)
10419 (gnus-article-prepare-hook nil))
10420 (gnus-summary-select-article t nil nil article)))
10422 (set-buffer save-buffer)
10424 (insert-buffer-substring gnus-original-article-buffer))
10425 (setq file (gnus-article-save save-buffer file num))
10426 (gnus-summary-remove-process-mark article)
10428 (gnus-summary-set-saved-mark article))))
10429 (gnus-kill-buffer save-buffer)
10430 (gnus-summary-position-point)
10431 (gnus-set-mode-line 'summary)
10434 (defun gnus-summary-pipe-output (&optional arg)
10435 "Pipe the current article to a subprocess.
10436 If N is a positive number, pipe the N next articles.
10437 If N is a negative number, pipe the N previous articles.
10438 If N is nil and any articles have been marked with the process mark,
10439 pipe those articles instead."
10441 (require 'gnus-art)
10442 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10443 (gnus-summary-save-article arg t))
10444 (let ((buffer (get-buffer "*Shell Command Output*")))
10446 (with-current-buffer buffer (> (point-max) (point-min))))
10447 (gnus-configure-windows 'pipe))))
10449 (defun gnus-summary-save-article-mail (&optional arg)
10450 "Append the current article to an mail file.
10451 If N is a positive number, save the N next articles.
10452 If N is a negative number, save the N previous articles.
10453 If N is nil and any articles have been marked with the process mark,
10454 save those articles instead."
10456 (require 'gnus-art)
10457 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10458 (gnus-summary-save-article arg)))
10460 (defun gnus-summary-save-article-rmail (&optional arg)
10461 "Append the current article to an rmail file.
10462 If N is a positive number, save the N next articles.
10463 If N is a negative number, save the N previous articles.
10464 If N is nil and any articles have been marked with the process mark,
10465 save those articles instead."
10467 (require 'gnus-art)
10468 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10469 (gnus-summary-save-article arg)))
10471 (defun gnus-summary-save-article-file (&optional arg)
10472 "Append the current article to a file.
10473 If N is a positive number, save the N next articles.
10474 If N is a negative number, save the N previous articles.
10475 If N is nil and any articles have been marked with the process mark,
10476 save those articles instead."
10478 (require 'gnus-art)
10479 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10480 (gnus-summary-save-article arg)))
10482 (defun gnus-summary-write-article-file (&optional arg)
10483 "Write the current article to a file, deleting the previous file.
10484 If N is a positive number, save the N next articles.
10485 If N is a negative number, save the N previous articles.
10486 If N is nil and any articles have been marked with the process mark,
10487 save those articles instead."
10489 (require 'gnus-art)
10490 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10491 (gnus-summary-save-article arg)))
10493 (defun gnus-summary-save-article-body-file (&optional arg)
10494 "Append the current article body to a file.
10495 If N is a positive number, save the N next articles.
10496 If N is a negative number, save the N previous articles.
10497 If N is nil and any articles have been marked with the process mark,
10498 save those articles instead."
10500 (require 'gnus-art)
10501 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10502 (gnus-summary-save-article arg)))
10504 (defun gnus-summary-muttprint (&optional arg)
10505 "Print the current article using Muttprint.
10506 If N is a positive number, save the N next articles.
10507 If N is a negative number, save the N previous articles.
10508 If N is nil and any articles have been marked with the process mark,
10509 save those articles instead."
10511 (require 'gnus-art)
10512 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10513 (gnus-summary-save-article arg t)))
10515 (defun gnus-summary-pipe-message (program)
10516 "Pipe the current article through PROGRAM."
10517 (interactive "sProgram: ")
10518 (gnus-summary-select-article)
10519 (let ((mail-header-separator ""))
10520 (gnus-eval-in-buffer-window gnus-article-buffer
10523 (let ((start (window-start))
10525 (message-pipe-buffer-body program)
10526 (set-window-start (get-buffer-window (current-buffer)) start))))))
10528 (defun gnus-get-split-value (methods)
10529 "Return a value based on the split METHODS."
10530 (let (split-name method result match)
10533 (set-buffer gnus-original-article-buffer)
10535 (nnheader-narrow-to-headers)
10536 (while (and methods (not split-name))
10537 (goto-char (point-min))
10538 (setq method (pop methods))
10539 (setq match (car method))
10542 ;; Regular expression.
10544 (re-search-forward match nil t)))
10545 ((gnus-functionp match)
10549 (setq result (funcall match gnus-newsgroup-name))))
10554 (setq result (eval match)))))
10555 (setq split-name (cdr method))
10556 (cond ((stringp result)
10557 (push (expand-file-name
10558 result gnus-article-save-directory)
10561 (setq split-name (append result split-name)))))))))
10562 (nreverse split-name)))
10564 (defun gnus-valid-move-group-p (group)
10565 (and (boundp group)
10566 (symbol-name group)
10567 (symbol-value group)
10568 (gnus-get-function (gnus-find-method-for-group
10569 (symbol-name group)) 'request-accept-article t)))
10571 (defun gnus-read-move-group-name (prompt default articles prefix)
10572 "Read a group name."
10573 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10574 (minibuffer-confirm-incomplete nil) ; XEmacs
10576 (format "%s %s to:"
10578 (if (> (length articles) 1)
10579 (format "these %d articles" (length articles))
10584 (gnus-completing-read-with-default
10587 'gnus-valid-move-group-p
10589 'gnus-group-history))
10590 ((= 1 (length split-name))
10591 (gnus-completing-read-with-default
10592 (car split-name) prom
10594 'gnus-valid-move-group-p
10596 'gnus-group-history))
10598 (gnus-completing-read-with-default
10600 (mapcar (lambda (el) (list el))
10601 (nreverse split-name))
10603 'gnus-group-history))))
10604 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10606 (if (or (string= to-newsgroup "")
10607 (string= to-newsgroup prefix))
10608 (setq to-newsgroup default))
10609 (unless to-newsgroup
10610 (error "No group name entered"))
10611 (or (gnus-active to-newsgroup)
10612 (gnus-activate-group to-newsgroup nil nil to-method)
10613 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10615 (or (and (gnus-request-create-group to-newsgroup to-method)
10616 (gnus-activate-group
10617 to-newsgroup nil nil to-method)
10618 (gnus-subscribe-group to-newsgroup))
10619 (error "Couldn't create group %s" to-newsgroup)))
10620 (error "No such group: %s" to-newsgroup)))
10623 (defun gnus-summary-save-parts (type dir n &optional reverse)
10624 "Save parts matching TYPE to DIR.
10625 If REVERSE, save parts that do not match TYPE."
10627 (list (read-string "Save parts of type: "
10628 (or (car gnus-summary-save-parts-type-history)
10629 gnus-summary-save-parts-default-mime)
10630 'gnus-summary-save-parts-type-history)
10631 (setq gnus-summary-save-parts-last-directory
10632 (read-file-name "Save to directory: "
10633 gnus-summary-save-parts-last-directory
10635 current-prefix-arg))
10636 (gnus-summary-iterate n
10637 (let ((gnus-display-mime-function nil)
10638 (gnus-inhibit-treatment t))
10639 (gnus-summary-select-article))
10641 (set-buffer gnus-article-buffer)
10642 (let ((handles (or gnus-article-mime-handles
10643 (mm-dissect-buffer nil gnus-article-loose-mime)
10646 (gnus-summary-save-parts-1 type dir handles reverse)
10647 (unless gnus-article-mime-handles ;; Don't destroy this case.
10648 (mm-destroy-parts handles)))))))
10650 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10651 (if (stringp (car handle))
10652 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10655 (not (string-match type (mm-handle-media-type handle)))
10656 (string-match type (mm-handle-media-type handle)))
10657 (let ((file (expand-file-name
10658 (file-name-nondirectory
10660 (mail-content-type-get
10661 (mm-handle-disposition handle) 'filename)
10662 (concat gnus-newsgroup-name
10663 "." (number-to-string
10664 (cdr gnus-article-current)))))
10666 (unless (file-exists-p file)
10667 (mm-save-part-to-file handle file))))))
10669 ;; Summary extract commands
10671 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10672 (let ((buffer-read-only nil)
10673 (article (gnus-summary-article-number))
10675 (unless (gnus-summary-goto-subject article)
10676 (error "No such article: %d" article))
10677 (gnus-summary-position-point)
10678 ;; If all commands are to be bunched up on one line, we collect
10680 (unless gnus-view-pseudos-separately
10681 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10684 (setq action (cdr (assq 'action (car ps))))
10685 (setq files (list (cdr (assq 'name (car ps)))))
10686 (while (and ps (cdr ps)
10687 (string= (or action "1")
10688 (or (cdr (assq 'action (cadr ps))) "2")))
10689 (push (cdr (assq 'name (cadr ps))) files)
10690 (setcdr ps (cddr ps)))
10692 (when (not (string-match "%s" action))
10695 (when (assq 'execute (car ps))
10696 (setcdr (assq 'execute (car ps))
10697 (funcall (if (string-match "%s" action)
10706 (setq ps (cdr ps)))))
10707 (if (and gnus-view-pseudos (not not-view))
10709 (when (assq 'execute (car pslist))
10710 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10711 (eq gnus-view-pseudos 'not-confirm)))
10712 (setq pslist (cdr pslist)))
10715 (setq after-article (or (cdr (assq 'article (car pslist)))
10716 (gnus-summary-article-number)))
10717 (gnus-summary-goto-subject after-article)
10720 (insert " " (file-name-nondirectory
10721 (cdr (assq 'name (car pslist))))
10722 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10724 (forward-line -1) ; back to `b'
10725 (gnus-add-text-properties
10726 b (1- e) (list 'gnus-number gnus-reffed-article-number
10727 gnus-mouse-face-prop gnus-mouse-face))
10729 after-article gnus-reffed-article-number
10730 gnus-unread-mark b (car pslist) 0 (- e b))
10731 (setq gnus-newsgroup-unreads
10732 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10733 gnus-reffed-article-number))
10734 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10735 (setq pslist (cdr pslist)))))))
10737 (defun gnus-pseudos< (p1 p2)
10738 (let ((c1 (cdr (assq 'action p1)))
10739 (c2 (cdr (assq 'action p2))))
10740 (and c1 c2 (string< c1 c2))))
10742 (defun gnus-request-pseudo-article (props)
10743 (cond ((assq 'execute props)
10744 (gnus-execute-command (cdr (assq 'execute props)))))
10745 (let ((gnus-current-article (gnus-summary-article-number)))
10746 (gnus-run-hooks 'gnus-mark-article-hook)))
10748 (defun gnus-execute-command (command &optional automatic)
10750 (gnus-article-setup-buffer)
10751 (set-buffer gnus-article-buffer)
10752 (setq buffer-read-only nil)
10753 (let ((command (if automatic command
10754 (read-string "Command: " (cons command 0)))))
10756 (insert "$ " command "\n\n")
10757 (if gnus-view-pseudo-asynchronously
10758 (start-process "gnus-execute" (current-buffer) shell-file-name
10759 shell-command-switch command)
10760 (call-process shell-file-name nil t nil
10761 shell-command-switch command)))))
10763 ;; Summary kill commands.
10765 (defun gnus-summary-edit-global-kill (article)
10766 "Edit the \"global\" kill file."
10767 (interactive (list (gnus-summary-article-number)))
10768 (gnus-group-edit-global-kill article))
10770 (defun gnus-summary-edit-local-kill ()
10771 "Edit a local kill file applied to the current newsgroup."
10773 (setq gnus-current-headers (gnus-summary-article-header))
10774 (gnus-group-edit-local-kill
10775 (gnus-summary-article-number) gnus-newsgroup-name))
10777 ;;; Header reading.
10779 (defun gnus-read-header (id &optional header)
10780 "Read the headers of article ID and enter them into the Gnus system."
10781 (let ((group gnus-newsgroup-name)
10782 (gnus-override-method
10784 gnus-override-method
10785 (and (gnus-news-group-p gnus-newsgroup-name)
10786 (car (gnus-refer-article-methods)))))
10788 ;; First we check to see whether the header in question is already
10791 ;; This is a Message-ID.
10792 (setq header (or header (gnus-id-to-header id)))
10793 ;; This is an article number.
10794 (setq header (or header (gnus-summary-article-header id))))
10796 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10797 ;; We have found the header.
10799 ;; If this is a sparse article, we have to nix out its
10800 ;; previous entry in the thread hashtb.
10802 (gnus-summary-article-sparse-p (mail-header-number header)))
10803 (let* ((parent (gnus-parent-id (mail-header-references header)))
10804 (thread (and parent (gnus-id-to-thread parent))))
10806 (delq (assq header thread) thread))))
10807 ;; We have to really fetch the header to this article.
10809 (set-buffer nntp-server-buffer)
10810 (when (setq where (gnus-request-head id group))
10811 (nnheader-fold-continuation-lines)
10812 (goto-char (point-max))
10814 (goto-char (point-min))
10818 ((cdr where) (cdr where))
10819 (header (mail-header-number header))
10820 (t gnus-reffed-article-number))
10822 (insert " Article retrieved.\n"))
10823 (if (or (not where)
10824 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10825 () ; Malformed head.
10826 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10827 (when (and (stringp id)
10828 (not (string= (gnus-group-real-name group)
10830 ;; If we fetched by Message-ID and the article came
10831 ;; from a different group, we fudge some bogus article
10832 ;; numbers for this article.
10833 (mail-header-set-number header gnus-reffed-article-number))
10835 (set-buffer gnus-summary-buffer)
10836 (decf gnus-reffed-article-number)
10837 (gnus-remove-header (mail-header-number header))
10838 (push header gnus-newsgroup-headers)
10839 (setq gnus-current-headers header)
10840 (push (mail-header-number header) gnus-newsgroup-limit)))
10843 (defun gnus-remove-header (number)
10844 "Remove header NUMBER from `gnus-newsgroup-headers'."
10845 (if (and gnus-newsgroup-headers
10846 (= number (mail-header-number (car gnus-newsgroup-headers))))
10847 (pop gnus-newsgroup-headers)
10848 (let ((headers gnus-newsgroup-headers))
10849 (while (and (cdr headers)
10850 (not (= number (mail-header-number (cadr headers)))))
10852 (when (cdr headers)
10853 (setcdr headers (cddr headers))))))
10856 ;;; summary highlights
10859 (defun gnus-highlight-selected-summary ()
10860 "Highlight selected article in summary buffer."
10861 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10862 (when gnus-summary-selected-face
10864 (let* ((beg (progn (beginning-of-line) (point)))
10865 (end (progn (end-of-line) (point)))
10866 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10867 (from (if (get-text-property beg gnus-mouse-face-prop)
10869 (or (next-single-property-change
10870 beg gnus-mouse-face-prop nil end)
10875 (or (next-single-property-change
10876 from gnus-mouse-face-prop nil end)
10878 ;; If no mouse-face prop on line we will have to = from = end,
10879 ;; so we highlight the entire line instead.
10880 (when (= (+ to 2) from)
10883 (if gnus-newsgroup-selected-overlay
10884 ;; Move old overlay.
10886 gnus-newsgroup-selected-overlay from to (current-buffer))
10887 ;; Create new overlay.
10889 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10890 'face gnus-summary-selected-face))))))
10892 (defvar gnus-summary-highlight-line-cached nil)
10893 (defvar gnus-summary-highlight-line-trigger nil)
10895 (defun gnus-summary-highlight-line-0 ()
10896 (if (and (eq gnus-summary-highlight-line-trigger
10897 gnus-summary-highlight)
10898 gnus-summary-highlight-line-cached)
10899 gnus-summary-highlight-line-cached
10900 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
10901 gnus-summary-highlight-line-cached
10902 (let* ((cond (list 'cond))
10904 (list gnus-summary-highlight))
10906 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
10909 (gnus-byte-compile (list 'lambda nil cond))))))
10911 (defun gnus-summary-highlight-line ()
10912 "Highlight current line according to `gnus-summary-highlight'."
10913 (let* ((beg (gnus-point-at-bol))
10914 (article (or (gnus-summary-article-number) gnus-current-article))
10915 (score (or (cdr (assq article
10916 gnus-newsgroup-scored))
10917 gnus-summary-default-score 0))
10918 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10919 (inhibit-read-only t)
10920 (default gnus-summary-default-score)
10921 (default-high gnus-summary-default-high-score)
10922 (default-low gnus-summary-default-low-score)
10923 (uncached (memq article gnus-newsgroup-undownloaded))
10924 (downloaded (not uncached)))
10925 (let ((face (funcall (gnus-summary-highlight-line-0))))
10926 (unless (eq face (get-text-property beg 'face))
10927 (gnus-put-text-property-excluding-characters-with-faces
10928 beg (gnus-point-at-eol) 'face
10929 (setq face (if (boundp face) (symbol-value face) face)))
10930 (when gnus-summary-highlight-line-function
10931 (funcall gnus-summary-highlight-line-function article face))))))
10933 (defun gnus-update-read-articles (group unread &optional compute)
10934 "Update the list of read articles in GROUP.
10935 UNREAD is a sorted list."
10936 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10937 (entry (gnus-gethash group gnus-newsrc-hashtb))
10938 (info (nth 2 entry))
10941 (if (or (not info) (not active))
10942 ;; There is no info on this group if it was, in fact,
10943 ;; killed. Gnus stores no information on killed groups, so
10944 ;; there's nothing to be done.
10945 ;; One could store the information somewhere temporarily,
10946 ;; perhaps... Hmmm...
10948 ;; Remove any negative articles numbers.
10949 (while (and unread (< (car unread) 0))
10950 (setq unread (cdr unread)))
10951 ;; Remove any expired article numbers
10952 (while (and unread (< (car unread) (car active)))
10953 (setq unread (cdr unread)))
10954 ;; Compute the ranges of read articles by looking at the list of
10955 ;; unread articles.
10957 (when (/= (car unread) prev)
10958 (push (if (= prev (1- (car unread))) prev
10959 (cons prev (1- (car unread))))
10961 (setq prev (1+ (car unread)))
10962 (setq unread (cdr unread)))
10963 (when (<= prev (cdr active))
10964 (push (cons prev (cdr active)) read))
10965 (setq read (if (> (length read) 1) (nreverse read) read))
10970 ;; Propagate the read marks to the backend.
10971 (when (gnus-check-backend-function 'request-set-mark group)
10972 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10973 (add (gnus-remove-from-range read (gnus-info-read info))))
10975 (unless (gnus-check-group group)
10976 (error "Can't open server for %s" group))
10977 (gnus-request-set-mark
10978 group (delq nil (list (if add (list add 'add '(read)))
10979 (if del (list del 'del '(read))))))
10981 `(gnus-request-set-mark
10984 (if del (list del 'add '(read)))
10985 (if add (list add 'del '(read))))))))))
10986 (set-buffer gnus-group-buffer)
10987 (gnus-undo-register
10989 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10990 (gnus-info-set-read ',info ',(gnus-info-read info))
10991 (gnus-get-unread-articles-in-group ',info
10992 (gnus-active ,group))
10993 (gnus-group-update-group ,group t)
10995 ;; Enter this list into the group info.
10996 (gnus-info-set-read info read)
10997 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10998 (gnus-get-unread-articles-in-group info (gnus-active group))
11001 (defun gnus-offer-save-summaries ()
11002 "Offer to save all active summary buffers."
11004 ;; Go through all buffers and find all summaries.
11005 (dolist (buffer (buffer-list))
11006 (when (and (setq buffer (buffer-name buffer))
11007 (string-match "Summary" buffer)
11009 (set-buffer buffer)
11010 ;; We check that this is, indeed, a summary buffer.
11011 (and (eq major-mode 'gnus-summary-mode)
11012 ;; Also make sure this isn't bogus.
11013 gnus-newsgroup-prepared
11014 ;; Also make sure that this isn't a
11015 ;; dead summary buffer.
11016 (not gnus-dead-summary-mode))))
11017 (push buffer buffers)))
11018 ;; Go through all these summary buffers and offer to save them.
11022 "Update summary buffer %s? "
11024 (switch-to-buffer buf)
11025 (gnus-summary-exit))
11028 (defun gnus-summary-setup-default-charset ()
11029 "Setup newsgroup default charset."
11030 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11031 (setq gnus-newsgroup-charset nil)
11032 (let* ((ignored-charsets
11033 (or gnus-newsgroup-ephemeral-ignored-charsets
11035 (and gnus-newsgroup-name
11036 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11037 gnus-newsgroup-ignored-charsets))))
11038 (setq gnus-newsgroup-charset
11039 (or gnus-newsgroup-ephemeral-charset
11040 (and gnus-newsgroup-name
11041 (gnus-parameter-charset gnus-newsgroup-name))
11042 gnus-default-charset))
11043 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11044 ignored-charsets))))
11050 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11051 "Display the current article buffer fully MIME-buttonized.
11052 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11053 treated as multipart/mixed."
11055 (require 'gnus-art)
11056 (let ((gnus-unbuttonized-mime-types nil)
11057 (gnus-mime-display-multipart-as-mixed show-all-parts))
11058 (gnus-summary-show-article)))
11060 (defun gnus-summary-repair-multipart (article)
11061 "Add a Content-Type header to a multipart article without one."
11062 (interactive (list (gnus-summary-article-number)))
11063 (gnus-with-article article
11064 (message-narrow-to-head)
11065 (message-remove-header "Mime-Version")
11066 (goto-char (point-max))
11067 (insert "Mime-Version: 1.0\n")
11069 (when (search-forward "\n--" nil t)
11070 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11071 (message-narrow-to-head)
11072 (message-remove-header "Content-Type")
11073 (goto-char (point-max))
11074 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11077 (let (gnus-mark-article-hook)
11078 (gnus-summary-select-article t t nil article)))
11080 (defun gnus-summary-toggle-display-buttonized ()
11081 "Toggle the buttonizing of the article buffer."
11083 (require 'gnus-art)
11084 (if (setq gnus-inhibit-mime-unbuttonizing
11085 (not gnus-inhibit-mime-unbuttonizing))
11086 (let ((gnus-unbuttonized-mime-types nil))
11087 (gnus-summary-show-article))
11088 (gnus-summary-show-article)))
11091 ;;; Generic summary marking commands
11094 (defvar gnus-summary-marking-alist
11095 '((read gnus-del-mark "d")
11096 (unread gnus-unread-mark "u")
11097 (ticked gnus-ticked-mark "!")
11098 (dormant gnus-dormant-mark "?")
11099 (expirable gnus-expirable-mark "e"))
11100 "An alist of names/marks/keystrokes.")
11102 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11103 (defvar gnus-summary-mark-map)
11105 (defun gnus-summary-make-all-marking-commands ()
11106 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11107 (dolist (elem gnus-summary-marking-alist)
11108 (apply 'gnus-summary-make-marking-command elem)))
11110 (defun gnus-summary-make-marking-command (name mark keystroke)
11111 (let ((map (make-sparse-keymap)))
11112 (define-key gnus-summary-generic-mark-map keystroke map)
11113 (dolist (lway `((next "next" next nil "n")
11114 (next-unread "next unread" next t "N")
11115 (prev "previous" prev nil "p")
11116 (prev-unread "previous unread" prev t "P")
11117 (nomove "" nil nil ,keystroke)))
11118 (let ((func (gnus-summary-make-marking-command-1
11119 mark (car lway) lway name)))
11120 (setq func (eval func))
11121 (define-key map (nth 4 lway) func)))))
11123 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11125 (format "gnus-summary-put-mark-as-%s%s"
11126 name (if (eq way 'nomove)
11128 (concat "-" (symbol-name way)))))
11131 "Mark the current article as %s%s.
11132 If N, the prefix, then repeat N times.
11133 If N is negative, move in reverse order.
11134 The difference between N and the actual number of articles marked is
11138 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11140 (defun gnus-summary-generic-mark (n mark move unread)
11141 "Mark N articles with MARK."
11142 (unless (eq major-mode 'gnus-summary-mode)
11143 (error "This command can only be used in the summary buffer"))
11144 (gnus-summary-show-thread)
11147 ((eq move 'next) 1)
11148 ((eq move 'prev) -1)
11150 (if (zerop nummove)
11154 nummove (* -1 nummove))))
11155 (while (and (> n 0)
11156 (gnus-summary-mark-article nil mark)
11157 (zerop (gnus-summary-next-subject nummove unread t)))
11160 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11161 (gnus-summary-recenter)
11162 (gnus-summary-position-point)
11163 (gnus-set-mode-line 'summary)
11166 (defun gnus-summary-insert-articles (articles)
11167 (when (setq articles
11168 (gnus-sorted-difference articles
11169 (mapcar (lambda (h)
11170 (mail-header-number h))
11171 gnus-newsgroup-headers)))
11172 (setq gnus-newsgroup-headers
11174 gnus-newsgroup-headers
11175 (gnus-fetch-headers articles)
11176 'gnus-article-sort-by-number))
11177 ;; Suppress duplicates?
11178 (when gnus-suppress-duplicates
11179 (gnus-dup-suppress-articles))
11181 ;; We might want to build some more threads first.
11182 (when (and gnus-fetch-old-headers
11183 (eq gnus-headers-retrieved-by 'nov))
11184 (if (eq gnus-fetch-old-headers 'invisible)
11185 (gnus-build-all-threads)
11186 (gnus-build-old-threads)))
11187 ;; Let the Gnus agent mark articles as read.
11189 (gnus-agent-get-undownloaded-list))
11190 ;; Remove list identifiers from subject
11191 (when gnus-list-identifiers
11192 (gnus-summary-remove-list-identifiers))
11193 ;; First and last article in this newsgroup.
11194 (when gnus-newsgroup-headers
11195 (setq gnus-newsgroup-begin
11196 (mail-header-number (car gnus-newsgroup-headers))
11198 (mail-header-number
11199 (gnus-last-element gnus-newsgroup-headers))))
11200 (when gnus-use-scoring
11201 (gnus-possibly-score-headers))))
11203 (defun gnus-summary-insert-old-articles (&optional all)
11204 "Insert all old articles in this group.
11205 If ALL is non-nil, already read articles become readable.
11206 If ALL is a number, fetch this number of articles."
11209 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11212 ;; Some nntp servers lie about their active range. When
11213 ;; this happens, the active range can be in the millions.
11214 ;; Use a compressed range to avoid creating a huge list.
11215 (gnus-range-difference (list gnus-newsgroup-active) old))
11216 (setq len (gnus-range-length older))
11221 (let ((older-range (nreverse older)))
11225 (let* ((r (pop older-range))
11226 (min (if (numberp r) r (car r)))
11227 (max (if (numberp r) r (cdr r))))
11228 (while (and (<= min max)
11233 (setq older (gnus-uncompress-range older))))
11235 (setq older (gnus-uncompress-range older)))
11237 (when (and (numberp gnus-large-newsgroup)
11238 (> len gnus-large-newsgroup))
11239 (let* ((cursor-in-echo-area nil)
11240 (initial (gnus-parameter-large-newsgroup-initial
11241 gnus-newsgroup-name))
11245 "How many articles from %s (%s %d): "
11247 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11248 (if initial "max" "default")
11251 (cons (number-to-string initial)
11253 (unless (string-match "^[ \t]*$" input)
11254 (setq all (string-to-number input))
11256 (let ((older-range (nreverse older)))
11260 (let* ((r (pop older-range))
11261 (min (if (numberp r) r (car r)))
11262 (max (if (numberp r) r (cdr r))))
11263 (while (and (<= min max)
11267 max (1- max))))))))))
11268 (setq older (gnus-uncompress-range older))))
11270 (message "No old news.")
11271 (gnus-summary-insert-articles older)
11272 (gnus-summary-limit (gnus-sorted-nunion old older))))
11273 (gnus-summary-position-point)))
11275 (defun gnus-summary-insert-new-articles ()
11276 "Insert all new articles in this group."
11279 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11280 (old-active gnus-newsgroup-active)
11281 (nnmail-fetched-sources (list t))
11283 (setq gnus-newsgroup-active
11284 (gnus-activate-group gnus-newsgroup-name 'scan))
11285 (setq i (cdr gnus-newsgroup-active))
11286 (while (> i (cdr old-active))
11290 (message "No gnus is bad news.")
11291 (gnus-summary-insert-articles new)
11292 (setq gnus-newsgroup-unreads
11293 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11294 (gnus-summary-limit (gnus-sorted-nunion old new))))
11295 (gnus-summary-position-point)))
11297 (gnus-summary-make-all-marking-commands)
11299 (gnus-ems-redefine)
11301 (provide 'gnus-sum)
11303 (run-hooks 'gnus-sum-load-hook)
11305 ;;; gnus-sum.el ends here