1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
42 (autoload 'gnus-cache-write-active "gnus-cache")
43 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
44 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
46 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
47 "Deuglify broken Outlook (Express) articles and redisplay."
50 (defcustom gnus-kill-summary-on-exit t
51 "*If non-nil, kill the summary buffer when you exit from it.
52 If nil, the summary will become a \"*Dead Summary*\" buffer, and
53 it will be killed sometime later."
54 :group 'gnus-summary-exit
57 (defcustom gnus-fetch-old-headers nil
58 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
59 If an unread article in the group refers to an older, already read (or
60 just marked as read) article, the old article will not normally be
61 displayed in the Summary buffer. If this variable is non-nil, Gnus
62 will attempt to grab the headers to the old articles, and thereby
63 build complete threads. If it has the value `some', only enough
64 headers to connect otherwise loose threads will be displayed. This
65 variable can also be a number. In that case, no more than that number
66 of old headers will be fetched. If it has the value `invisible', all
67 old headers will be fetched, but none will be displayed.
69 The server has to support NOV for any of this to work."
71 :type '(choice (const :tag "off" nil)
74 (sexp :menu-tag "other" t)))
76 (defcustom gnus-refer-thread-limit 200
77 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
78 If t, fetch all the available old headers."
81 (sexp :menu-tag "other" t)))
83 (defcustom gnus-summary-make-false-root 'adopt
84 "*nil means that Gnus won't gather loose threads.
85 If the root of a thread has expired or been read in a previous
86 session, the information necessary to build a complete thread has been
87 lost. Instead of having many small sub-threads from this original thread
88 scattered all over the summary buffer, Gnus can gather them.
90 If non-nil, Gnus will try to gather all loose sub-threads from an
91 original thread into one large thread.
93 If this variable is non-nil, it should be one of `none', `adopt',
96 If this variable is `none', Gnus will not make a false root, but just
97 present the sub-threads after another.
98 If this variable is `dummy', Gnus will create a dummy root that will
99 have all the sub-threads as children.
100 If this variable is `adopt', Gnus will make one of the \"children\"
101 the parent and mark all the step-children as such.
102 If this variable is `empty', the \"children\" are printed with empty
103 subject fields. (Or rather, they will be printed with a string
104 given by the `gnus-summary-same-subject' variable.)"
106 :type '(choice (const :tag "off" nil)
112 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
113 "*A regexp to match subjects to be excluded from loose thread gathering.
114 As loose thread gathering is done on subjects only, that means that
115 there can be many false gatherings performed. By rooting out certain
116 common subjects, gathering might become saner."
120 (defcustom gnus-summary-gather-subject-limit nil
121 "*Maximum length of subject comparisons when gathering loose threads.
122 Use nil to compare full subjects. Setting this variable to a low
123 number will help gather threads that have been corrupted by
124 newsreaders chopping off subject lines, but it might also mean that
125 unrelated articles that have subject that happen to begin with the
126 same few characters will be incorrectly gathered.
128 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
131 :type '(choice (const :tag "off" nil)
133 (sexp :menu-tag "on" t)))
135 (defcustom gnus-simplify-subject-functions nil
136 "List of functions taking a string argument that simplify subjects.
137 The functions are applied recursively.
139 Useful functions to put in this list include:
140 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
141 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
143 :type '(repeat function))
145 (defcustom gnus-simplify-ignored-prefixes nil
146 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
148 :type '(choice (const :tag "off" nil)
151 (defcustom gnus-build-sparse-threads nil
152 "*If non-nil, fill in the gaps in threads.
153 If `some', only fill in the gaps that are needed to tie loose threads
154 together. If `more', fill in all leaf nodes that Gnus can find. If
155 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
157 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "all" t)))
162 (defcustom gnus-summary-thread-gathering-function
163 'gnus-gather-threads-by-subject
164 "*Function used for gathering loose threads.
165 There are two pre-defined functions: `gnus-gather-threads-by-subject',
166 which only takes Subjects into consideration; and
167 `gnus-gather-threads-by-references', which compared the References
168 headers of the articles to find matches."
170 :type '(radio (function-item gnus-gather-threads-by-subject)
171 (function-item gnus-gather-threads-by-references)
172 (function :tag "other")))
174 (defcustom gnus-summary-same-subject ""
175 "*String indicating that the current article has the same subject as the previous.
176 This variable will only be used if the value of
177 `gnus-summary-make-false-root' is `empty'."
178 :group 'gnus-summary-format
181 (defcustom gnus-summary-goto-unread t
182 "*If t, many commands will go to the next unread article.
183 This applies to marking commands as well as other commands that
184 \"naturally\" select the next article, like, for instance, `SPC' at
185 the end of an article.
187 If nil, the marking commands do NOT go to the next unread article
188 (they go to the next article instead). If `never', commands that
189 usually go to the next unread article, will go to the next article,
190 whether it is read or not."
191 :group 'gnus-summary-marks
192 :link '(custom-manual "(gnus)Setting Marks")
193 :type '(choice (const :tag "off" nil)
195 (sexp :menu-tag "on" t)))
197 (defcustom gnus-summary-default-score 0
198 "*Default article score level.
199 All scores generated by the score files will be added to this score.
200 If this variable is nil, scoring will be disabled."
201 :group 'gnus-score-default
202 :type '(choice (const :tag "disable")
205 (defcustom gnus-summary-default-high-score 0
206 "*Default threshold for a high scored article.
207 An article will be highlighted as high scored if its score is greater
209 :group 'gnus-score-default
212 (defcustom gnus-summary-default-low-score 0
213 "*Default threshold for a low scored article.
214 An article will be highlighted as low scored if its score is smaller
216 :group 'gnus-score-default
219 (defcustom gnus-summary-zcore-fuzz 0
220 "*Fuzziness factor for the zcore in the summary buffer.
221 Articles with scores closer than this to `gnus-summary-default-score'
223 :group 'gnus-summary-format
226 (defcustom gnus-simplify-subject-fuzzy-regexp nil
227 "*Strings to be removed when doing fuzzy matches.
228 This can either be a regular expression or list of regular expressions
229 that will be removed from subject strings if fuzzy subject
230 simplification is selected."
232 :type '(repeat regexp))
234 (defcustom gnus-show-threads t
235 "*If non-nil, display threads in summary mode."
239 (defcustom gnus-thread-hide-subtree nil
240 "*If non-nil, hide all threads initially.
241 This can be a predicate specifier which says which threads to hide.
242 If threads are hidden, you have to run the command
243 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
244 to expose hidden threads."
248 (defcustom gnus-thread-hide-killed t
249 "*If non-nil, hide killed threads automatically."
253 (defcustom gnus-thread-ignore-subject t
254 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
255 If nil, articles that have different subjects from their parents will
256 start separate threads."
260 (defcustom gnus-thread-operation-ignore-subject t
261 "*If non-nil, subjects will be ignored when doing thread commands.
262 This affects commands like `gnus-summary-kill-thread' and
263 `gnus-summary-lower-thread'.
265 If this variable is nil, articles in the same thread with different
266 subjects will not be included in the operation in question. If this
267 variable is `fuzzy', only articles that have subjects that are fuzzily
268 equal will be included."
270 :type '(choice (const :tag "off" nil)
274 (defcustom gnus-thread-indent-level 4
275 "*Number that says how much each sub-thread should be indented."
279 (defcustom gnus-auto-extend-newsgroup t
280 "*If non-nil, extend newsgroup forward and backward when requested."
281 :group 'gnus-summary-choose
284 (defcustom gnus-auto-select-first t
285 "*If non-nil, select the article under point.
286 Which article this is is controlled by the `gnus-auto-select-subject'
289 If you want to prevent automatic selection of articles in some
290 newsgroups, set the variable to nil in `gnus-select-group-hook'."
291 :group 'gnus-group-select
292 :type '(choice (const :tag "none" nil)
293 (sexp :menu-tag "first" t)))
295 (defcustom gnus-auto-select-subject 'unread
296 "*Says what subject to place under point when entering a group.
298 This variable can either be the symbols `first' (place point on the
299 first subject), `unread' (place point on the subject line of the first
300 unread article), `best' (place point on the subject line of the
301 higest-scored article), `unseen' (place point on the subject line of
302 the first unseen article), 'unseen-or-unread' (place point on the subject
303 line of the first unseen article or, if all article have been seen, on the
304 subject line of the first unread article), or a function to be called to
305 place point on some subject line."
306 :group 'gnus-group-select
307 :type '(choice (const best)
311 (const unseen-or-unread)))
313 (defcustom gnus-auto-select-next t
314 "*If non-nil, offer to go to the next group from the end of the previous.
315 If the value is t and the next newsgroup is empty, Gnus will exit
316 summary mode and go back to group mode. If the value is neither nil
317 nor t, Gnus will select the following unread newsgroup. In
318 particular, if the value is the symbol `quietly', the next unread
319 newsgroup will be selected without any confirmation, and if it is
320 `almost-quietly', the next group will be selected without any
321 confirmation if you are located on the last article in the group.
322 Finally, if this variable is `slightly-quietly', the `Z n' command
323 will go to the next group without confirmation."
324 :group 'gnus-summary-maneuvering
325 :type '(choice (const :tag "off" nil)
327 (const almost-quietly)
328 (const slightly-quietly)
329 (sexp :menu-tag "on" t)))
331 (defcustom gnus-auto-select-same nil
332 "*If non-nil, select the next article with the same subject.
333 If there are no more articles with the same subject, go to
334 the first unread article."
335 :group 'gnus-summary-maneuvering
338 (defcustom gnus-summary-check-current nil
339 "*If non-nil, consider the current article when moving.
340 The \"unread\" movement commands will stay on the same line if the
341 current article is unread."
342 :group 'gnus-summary-maneuvering
345 (defcustom gnus-auto-center-summary t
346 "*If non-nil, always center the current summary buffer.
347 In particular, if `vertical' do only vertical recentering. If non-nil
348 and non-`vertical', do both horizontal and vertical recentering."
349 :group 'gnus-summary-maneuvering
350 :type '(choice (const :tag "none" nil)
352 (integer :tag "height")
353 (sexp :menu-tag "both" t)))
355 (defcustom gnus-show-all-headers nil
356 "*If non-nil, don't hide any headers."
357 :group 'gnus-article-hiding
358 :group 'gnus-article-headers
361 (defcustom gnus-summary-ignore-duplicates nil
362 "*If non-nil, ignore articles with identical Message-ID headers."
366 (defcustom gnus-single-article-buffer t
367 "*If non-nil, display all articles in the same buffer.
368 If nil, each group will get its own article buffer."
369 :group 'gnus-article-various
372 (defcustom gnus-break-pages t
373 "*If non-nil, do page breaking on articles.
374 The page delimiter is specified by the `gnus-page-delimiter'
376 :group 'gnus-article-various
379 (defcustom gnus-move-split-methods nil
380 "*Variable used to suggest where articles are to be moved to.
381 It uses the same syntax as the `gnus-split-methods' variable.
382 However, whereas `gnus-split-methods' specifies file names as targets,
383 this variable specifies group names."
384 :group 'gnus-summary-mail
385 :type '(repeat (choice (list :value (fun) function)
386 (cons :value ("" "") regexp (repeat string))
389 (defcustom gnus-unread-mark ? ;Whitespace
390 "*Mark used for unread articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-ticked-mark ?!
395 "*Mark used for ticked articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-dormant-mark ??
400 "*Mark used for dormant articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-del-mark ?r
405 "*Mark used for del'd articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-read-mark ?R
410 "*Mark used for read articles."
411 :group 'gnus-summary-marks
414 (defcustom gnus-expirable-mark ?E
415 "*Mark used for expirable articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-killed-mark ?K
420 "*Mark used for killed articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-spam-mark ?H
425 "*Mark used for spam articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-souped-mark ?F
430 "*Mark used for souped articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-kill-file-mark ?X
435 "*Mark used for articles killed by kill files."
436 :group 'gnus-summary-marks
439 (defcustom gnus-low-score-mark ?Y
440 "*Mark used for articles with a low score."
441 :group 'gnus-summary-marks
444 (defcustom gnus-catchup-mark ?C
445 "*Mark used for articles that are caught up."
446 :group 'gnus-summary-marks
449 (defcustom gnus-replied-mark ?A
450 "*Mark used for articles that have been replied to."
451 :group 'gnus-summary-marks
454 (defcustom gnus-forwarded-mark ?F
455 "*Mark used for articles that have been forwarded."
456 :group 'gnus-summary-marks
459 (defcustom gnus-recent-mark ?N
460 "*Mark used for articles that are recent."
461 :group 'gnus-summary-marks
464 (defcustom gnus-cached-mark ?*
465 "*Mark used for articles that are in the cache."
466 :group 'gnus-summary-marks
469 (defcustom gnus-saved-mark ?S
470 "*Mark used for articles that have been saved."
471 :group 'gnus-summary-marks
474 (defcustom gnus-unseen-mark ?.
475 "*Mark used for articles that haven't been seen."
476 :group 'gnus-summary-marks
479 (defcustom gnus-no-mark ? ;Whitespace
480 "*Mark used for articles that have no other secondary mark."
481 :group 'gnus-summary-marks
484 (defcustom gnus-ancient-mark ?O
485 "*Mark used for ancient articles."
486 :group 'gnus-summary-marks
489 (defcustom gnus-sparse-mark ?Q
490 "*Mark used for sparsely reffed articles."
491 :group 'gnus-summary-marks
494 (defcustom gnus-canceled-mark ?G
495 "*Mark used for canceled articles."
496 :group 'gnus-summary-marks
499 (defcustom gnus-duplicate-mark ?M
500 "*Mark used for duplicate articles."
501 :group 'gnus-summary-marks
504 (defcustom gnus-undownloaded-mark ?@
505 "*Mark used for articles that weren't downloaded."
506 :group 'gnus-summary-marks
509 (defcustom gnus-downloadable-mark ?%
510 "*Mark used for articles that are to be downloaded."
511 :group 'gnus-summary-marks
514 (defcustom gnus-unsendable-mark ?=
515 "*Mark used for articles that won't be sent."
516 :group 'gnus-summary-marks
519 (defcustom gnus-score-over-mark ?+
520 "*Score mark used for articles with high scores."
521 :group 'gnus-summary-marks
524 (defcustom gnus-score-below-mark ?-
525 "*Score mark used for articles with low scores."
526 :group 'gnus-summary-marks
529 (defcustom gnus-empty-thread-mark ? ;Whitespace
530 "*There is no thread under the article."
531 :group 'gnus-summary-marks
534 (defcustom gnus-not-empty-thread-mark ?=
535 "*There is a thread under the article."
536 :group 'gnus-summary-marks
539 (defcustom gnus-view-pseudo-asynchronously nil
540 "*If non-nil, Gnus will view pseudo-articles asynchronously."
541 :group 'gnus-extract-view
544 (defcustom gnus-auto-expirable-marks
545 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
546 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
547 gnus-souped-mark gnus-duplicate-mark)
548 "*The list of marks converted into expiration if a group is auto-expirable."
551 :type '(repeat character))
553 (defcustom gnus-inhibit-user-auto-expire t
554 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
559 (defcustom gnus-view-pseudos nil
560 "*If `automatic', pseudo-articles will be viewed automatically.
561 If `not-confirm', pseudos will be viewed automatically, and the user
562 will not be asked to confirm the command."
563 :group 'gnus-extract-view
564 :type '(choice (const :tag "off" nil)
566 (const not-confirm)))
568 (defcustom gnus-view-pseudos-separately t
569 "*If non-nil, one pseudo-article will be created for each file to be viewed.
570 If nil, all files that use the same viewing command will be given as a
571 list of parameters to that command."
572 :group 'gnus-extract-view
575 (defcustom gnus-insert-pseudo-articles t
576 "*If non-nil, insert pseudo-articles when decoding articles."
577 :group 'gnus-extract-view
580 (defcustom gnus-summary-dummy-line-format
582 "*The format specification for the dummy roots in the summary buffer.
583 It works along the same lines as a normal formatting string,
584 with some simple extensions.
588 General format specifiers can also be used.
589 See `(gnus)Formatting Variables'."
590 :link '(custom-manual "(gnus)Formatting Variables")
591 :group 'gnus-threading
594 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
595 "*The format specification for the summary mode line.
596 It works along the same lines as a normal formatting string,
597 with some simple extensions:
600 %p Unprefixed group name
601 %A Current article number
602 %z Current article score
604 %U Number of unread articles in the group
605 %e Number of unselected articles in the group
606 %Z A string with unread/unselected article counts
607 %g Shortish group name
608 %S Subject of the current article
610 %s Current score file name
611 %d Number of dormant articles
612 %r Number of articles that have been marked as read in this session
613 %E Number of articles expunged by the score files"
614 :group 'gnus-summary-format
617 (defcustom gnus-list-identifiers nil
618 "Regexp that matches list identifiers to be removed from subject.
619 This can also be a list of regexps."
621 :group 'gnus-summary-format
622 :group 'gnus-article-hiding
623 :type '(choice (const :tag "none" nil)
625 (repeat :value (".*") regexp)))
627 (defcustom gnus-summary-mark-below 0
628 "*Mark all articles with a score below this variable as read.
629 This variable is local to each summary buffer and usually set by the
631 :group 'gnus-score-default
634 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
635 "*List of functions used for sorting articles in the summary buffer.
637 Each function takes two articles and returns non-nil if the first
638 article should be sorted before the other. If you use more than one
639 function, the primary sort function should be the last. You should
640 probably always include `gnus-article-sort-by-number' in the list of
641 sorting functions -- preferably first. Also note that sorting by date
642 is often much slower than sorting by number, and the sorting order is
643 very similar. (Sorting by date means sorting by the time the message
644 was sent, sorting by number means sorting by arrival time.)
646 Ready-made functions include `gnus-article-sort-by-number',
647 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
648 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
649 and `gnus-article-sort-by-score'.
651 When threading is turned on, the variable `gnus-thread-sort-functions'
652 controls how articles are sorted."
653 :group 'gnus-summary-sort
654 :type '(repeat (choice (function-item gnus-article-sort-by-number)
655 (function-item gnus-article-sort-by-author)
656 (function-item gnus-article-sort-by-subject)
657 (function-item gnus-article-sort-by-date)
658 (function-item gnus-article-sort-by-score)
659 (function-item gnus-article-sort-by-random)
660 (function :tag "other"))))
662 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
663 "*List of functions used for sorting threads in the summary buffer.
664 By default, threads are sorted by article number.
666 Each function takes two threads and returns non-nil if the first
667 thread should be sorted before the other. If you use more than one
668 function, the primary sort function should be the last. You should
669 probably always include `gnus-thread-sort-by-number' in the list of
670 sorting functions -- preferably first. Also note that sorting by date
671 is often much slower than sorting by number, and the sorting order is
672 very similar. (Sorting by date means sorting by the time the message
673 was sent, sorting by number means sorting by arrival time.)
675 Ready-made functions include `gnus-thread-sort-by-number',
676 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
677 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
678 `gnus-thread-sort-by-most-recent-number',
679 `gnus-thread-sort-by-most-recent-date',
680 `gnus-thread-sort-by-random', and
681 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
683 When threading is turned off, the variable
684 `gnus-article-sort-functions' controls how articles are sorted."
685 :group 'gnus-summary-sort
686 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
687 (function-item gnus-thread-sort-by-author)
688 (function-item gnus-thread-sort-by-subject)
689 (function-item gnus-thread-sort-by-date)
690 (function-item gnus-thread-sort-by-score)
691 (function-item gnus-thread-sort-by-total-score)
692 (function-item gnus-thread-sort-by-random)
693 (function :tag "other"))))
695 (defcustom gnus-thread-score-function '+
696 "*Function used for calculating the total score of a thread.
698 The function is called with the scores of the article and each
699 subthread and should then return the score of the thread.
701 Some functions you can use are `+', `max', or `min'."
702 :group 'gnus-summary-sort
705 (defcustom gnus-summary-expunge-below nil
706 "All articles that have a score less than this variable will be expunged.
707 This variable is local to the summary buffers."
708 :group 'gnus-score-default
709 :type '(choice (const :tag "off" nil)
712 (defcustom gnus-thread-expunge-below nil
713 "All threads that have a total score less than this variable will be expunged.
714 See `gnus-thread-score-function' for en explanation of what a
717 This variable is local to the summary buffers."
718 :group 'gnus-threading
719 :group 'gnus-score-default
720 :type '(choice (const :tag "off" nil)
723 (defcustom gnus-summary-mode-hook nil
724 "*A hook for Gnus summary mode.
725 This hook is run before any variables are set in the summary buffer."
726 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
727 :group 'gnus-summary-various
730 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
731 (when (featurep 'xemacs)
732 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
733 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
734 (add-hook 'gnus-summary-mode-hook
735 'gnus-xmas-switch-horizontal-scrollbar-off))
737 (defcustom gnus-summary-menu-hook nil
738 "*Hook run after the creation of the summary mode menu."
739 :group 'gnus-summary-visual
742 (defcustom gnus-summary-exit-hook nil
743 "*A hook called on exit from the summary buffer.
744 It will be called with point in the group buffer."
745 :group 'gnus-summary-exit
748 (defcustom gnus-summary-prepare-hook nil
749 "*A hook called after the summary buffer has been generated.
750 If you want to modify the summary buffer, you can use this hook."
751 :group 'gnus-summary-various
754 (defcustom gnus-summary-prepared-hook nil
755 "*A hook called as the last thing after the summary buffer has been generated."
756 :group 'gnus-summary-various
759 (defcustom gnus-summary-generate-hook nil
760 "*A hook run just before generating the summary buffer.
761 This hook is commonly used to customize threading variables and the
763 :group 'gnus-summary-various
766 (defcustom gnus-select-group-hook nil
767 "*A hook called when a newsgroup is selected.
769 If you'd like to simplify subjects like the
770 `gnus-summary-next-same-subject' command does, you can use the
773 (add-hook gnus-select-group-hook
775 (mapcar (lambda (header)
776 (mail-header-set-subject
778 (gnus-simplify-subject
779 (mail-header-subject header) 're-only)))
780 gnus-newsgroup-headers)))"
781 :group 'gnus-group-select
784 (defcustom gnus-select-article-hook nil
785 "*A hook called when an article is selected."
786 :group 'gnus-summary-choose
789 (defcustom gnus-visual-mark-article-hook
790 (list 'gnus-highlight-selected-summary)
791 "*Hook run after selecting an article in the summary buffer.
792 It is meant to be used for highlighting the article in some way. It
793 is not run if `gnus-visual' is nil."
794 :group 'gnus-summary-visual
797 (defcustom gnus-parse-headers-hook nil
798 "*A hook called before parsing the headers."
802 (defcustom gnus-exit-group-hook nil
803 "*A hook called when exiting summary mode.
804 This hook is not called from the non-updating exit commands like `Q'."
808 (defcustom gnus-summary-update-hook
809 (list 'gnus-summary-highlight-line)
810 "*A hook called when a summary line is changed.
811 The hook will not be called if `gnus-visual' is nil.
813 The default function `gnus-summary-highlight-line' will
814 highlight the line according to the `gnus-summary-highlight'
816 :group 'gnus-summary-visual
819 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
820 "*A hook called when an article is selected for the first time.
821 The hook is intended to mark an article as read (or unread)
822 automatically when it is selected."
823 :group 'gnus-summary-choose
826 (defcustom gnus-group-no-more-groups-hook nil
827 "*A hook run when returning to group mode having no more (unread) groups."
828 :group 'gnus-group-select
831 (defcustom gnus-ps-print-hook nil
832 "*A hook run before ps-printing something from Gnus."
836 (defcustom gnus-summary-display-arrow
837 (and (fboundp 'display-graphic-p)
839 "*If non-nil, display an arrow highlighting the current article."
844 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
845 "Face used for highlighting the current article in the summary buffer."
846 :group 'gnus-summary-visual
849 (defcustom gnus-summary-highlight
850 '(((eq mark gnus-canceled-mark)
851 . gnus-summary-cancelled-face)
852 ((and (> score default-high)
853 (or (eq mark gnus-dormant-mark)
854 (eq mark gnus-ticked-mark)))
855 . gnus-summary-high-ticked-face)
856 ((and (< score default-low)
857 (or (eq mark gnus-dormant-mark)
858 (eq mark gnus-ticked-mark)))
859 . gnus-summary-low-ticked-face)
860 ((or (eq mark gnus-dormant-mark)
861 (eq mark gnus-ticked-mark))
862 . gnus-summary-normal-ticked-face)
863 ((and (> score default-high) (eq mark gnus-ancient-mark))
864 . gnus-summary-high-ancient-face)
865 ((and (< score default-low) (eq mark gnus-ancient-mark))
866 . gnus-summary-low-ancient-face)
867 ((eq mark gnus-ancient-mark)
868 . gnus-summary-normal-ancient-face)
869 ((and (> score default-high) (eq mark gnus-unread-mark))
870 . gnus-summary-high-unread-face)
871 ((and (< score default-low) (eq mark gnus-unread-mark))
872 . gnus-summary-low-unread-face)
873 ((eq mark gnus-unread-mark)
874 . gnus-summary-normal-unread-face)
875 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
876 gnus-undownloaded-mark)))
877 . gnus-summary-high-unread-face)
878 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
879 gnus-undownloaded-mark)))
880 . gnus-summary-low-unread-face)
881 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
882 (memq article gnus-newsgroup-unreads))
883 . gnus-summary-normal-unread-face)
884 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
885 . gnus-summary-normal-read-face)
886 ((> score default-high)
887 . gnus-summary-high-read-face)
888 ((< score default-low)
889 . gnus-summary-low-read-face)
891 . gnus-summary-normal-read-face))
892 "*Controls the highlighting of summary buffer lines.
894 A list of (FORM . FACE) pairs. When deciding how a a particular
895 summary line should be displayed, each form is evaluated. The content
896 of the face field after the first true form is used. You can change
897 how those summary lines are displayed, by editing the face field.
899 You can use the following variables in the FORM field.
901 score: The article's score
902 default: The default article score.
903 default-high: The default score for high scored articles.
904 default-low: The default score for low scored articles.
905 below: The score below which articles are automatically marked as read.
906 mark: The articles mark."
907 :group 'gnus-summary-visual
908 :type '(repeat (cons (sexp :tag "Form" nil)
911 (defcustom gnus-alter-header-function nil
912 "Function called to allow alteration of article header structures.
913 The function is called with one parameter, the article header vector,
914 which it may alter in any way.")
916 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
917 "Variable that says which function should be used to decode a string with encoded words.")
919 (defcustom gnus-extra-headers '(To Newsgroups)
920 "*Extra headers to parse."
923 :type '(repeat symbol))
925 (defcustom gnus-ignored-from-addresses
926 (and user-mail-address (regexp-quote user-mail-address))
927 "*Regexp of From headers that may be suppressed in favor of To headers."
932 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
933 "List of charsets that should be ignored.
934 When these charsets are used in the \"charset\" parameter, the
935 default charset will be used instead."
937 :type '(repeat symbol)
938 :group 'gnus-charset)
940 (gnus-define-group-parameter
944 "Return the ignored charsets of GROUP."
945 :variable gnus-group-ignored-charsets-alist
947 '(("alt\\.chinese\\.text" iso-8859-1))
949 "Alist of regexps (to match group names) and charsets that should be ignored.
950 When these charsets are used in the \"charset\" parameter, the
951 default charset will be used instead."
952 :variable-group gnus-charset
953 :variable-type '(repeat (cons (regexp :tag "Group")
955 :parameter-type '(choice :tag "Ignored charsets"
958 :parameter-document "\
959 List of charsets that should be ignored.
961 When these charsets are used in the \"charset\" parameter, the
962 default charset will be used instead.")
964 (defcustom gnus-group-highlight-words-alist nil
965 "Alist of group regexps and highlight regexps.
966 This variable uses the same syntax as `gnus-emphasis-alist'."
968 :type '(repeat (cons (regexp :tag "Group")
969 (repeat (list (regexp :tag "Highlight regexp")
970 (number :tag "Group for entire word" 0)
971 (number :tag "Group for displayed part" 0)
973 gnus-emphasis-highlight-words)))))
974 :group 'gnus-summary-visual)
976 (defcustom gnus-summary-show-article-charset-alist
978 "Alist of number and charset.
979 The article will be shown with the charset corresponding to the
981 For example: ((1 . cn-gb-2312) (2 . big5))."
983 :type '(repeat (cons (number :tag "Argument" 1)
984 (symbol :tag "Charset")))
985 :group 'gnus-charset)
987 (defcustom gnus-preserve-marks t
988 "Whether marks are preserved when moving, copying and respooling messages."
991 :group 'gnus-summary-marks)
993 (defcustom gnus-alter-articles-to-read-function nil
994 "Function to be called to alter the list of articles to be selected."
995 :type '(choice (const nil) function)
996 :group 'gnus-summary)
998 (defcustom gnus-orphan-score nil
999 "*All orphans get this score added. Set in the score file."
1000 :group 'gnus-score-default
1001 :type '(choice (const nil)
1004 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1005 "*A regexp to match MIME parts when saving multiple parts of a message
1006 with gnus-summary-save-parts (X m). This regexp will be used by default
1007 when prompting the user for which type of files to save."
1008 :group 'gnus-summary
1011 (defcustom gnus-read-all-available-headers nil
1012 "Whether Gnus should parse all headers made available to it.
1013 This is mostly relevant for slow backends where the user may
1014 wish to widen the summary buffer to include all headers
1015 that were fetched. Say, for nnultimate groups."
1016 :group 'gnus-summary
1017 :type '(choice boolean regexp))
1019 (defcustom gnus-summary-muttprint-program "muttprint"
1020 "Command (and optional arguments) used to run Muttprint."
1022 :group 'gnus-summary
1025 (defcustom gnus-article-loose-mime nil
1026 "If non-nil, don't require MIME-Version header.
1027 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1028 supply the MIME-Version header or deliberately strip it From the mail.
1029 Set it to non-nil, Gnus will treat some articles as MIME even if
1030 the MIME-Version header is missed."
1033 :group 'gnus-article)
1035 ;;; Internal variables
1037 (defvar gnus-summary-display-cache nil)
1038 (defvar gnus-article-mime-handles nil)
1039 (defvar gnus-article-decoded-p nil)
1040 (defvar gnus-article-charset nil)
1041 (defvar gnus-article-ignored-charsets nil)
1042 (defvar gnus-scores-exclude-files nil)
1043 (defvar gnus-page-broken nil)
1044 (defvar gnus-inhibit-mime-unbuttonizing nil)
1046 (defvar gnus-original-article nil)
1047 (defvar gnus-article-internal-prepare-hook nil)
1048 (defvar gnus-newsgroup-process-stack nil)
1050 (defvar gnus-thread-indent-array nil)
1051 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1052 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1053 "Function called to sort the articles within a thread after it has been gathered together.")
1055 (defvar gnus-summary-save-parts-type-history nil)
1056 (defvar gnus-summary-save-parts-last-directory nil)
1058 ;; Avoid highlighting in kill files.
1059 (defvar gnus-summary-inhibit-highlight nil)
1060 (defvar gnus-newsgroup-selected-overlay nil)
1061 (defvar gnus-inhibit-limiting nil)
1062 (defvar gnus-newsgroup-adaptive-score-file nil)
1063 (defvar gnus-current-score-file nil)
1064 (defvar gnus-current-move-group nil)
1065 (defvar gnus-current-copy-group nil)
1066 (defvar gnus-current-crosspost-group nil)
1067 (defvar gnus-newsgroup-display nil)
1069 (defvar gnus-newsgroup-dependencies nil)
1070 (defvar gnus-newsgroup-adaptive nil)
1071 (defvar gnus-summary-display-article-function nil)
1072 (defvar gnus-summary-highlight-line-function nil
1073 "Function called after highlighting a summary line.")
1075 (defvar gnus-summary-line-format-alist
1076 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1077 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1078 (?s gnus-tmp-subject-or-nil ?s)
1079 (?n gnus-tmp-name ?s)
1080 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1082 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1084 (?F gnus-tmp-from ?s)
1085 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1086 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1087 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1088 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1089 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1090 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1091 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1092 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1093 (?L gnus-tmp-lines ?s)
1094 (?I gnus-tmp-indentation ?s)
1095 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1096 (?R gnus-tmp-replied ?c)
1097 (?\[ gnus-tmp-opening-bracket ?c)
1098 (?\] gnus-tmp-closing-bracket ?c)
1099 (?\> (make-string gnus-tmp-level ? ) ?s)
1100 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1101 (?i gnus-tmp-score ?d)
1102 (?z gnus-tmp-score-char ?c)
1103 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1104 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1105 (?U gnus-tmp-unread ?c)
1106 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1108 (?t (gnus-summary-number-of-articles-in-thread
1109 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1111 (?e (gnus-summary-number-of-articles-in-thread
1112 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1114 (?u gnus-tmp-user-defined ?s)
1115 (?P (gnus-pick-line-number) ?d)
1116 (?B gnus-tmp-thread-tree-header-string ?s)
1117 (user-date (gnus-user-date
1118 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1119 "An alist of format specifications that can appear in summary lines.
1120 These are paired with what variables they correspond with, along with
1121 the type of the variable (string, integer, character, etc).")
1123 (defvar gnus-summary-dummy-line-format-alist
1124 `((?S gnus-tmp-subject ?s)
1125 (?N gnus-tmp-number ?d)
1126 (?u gnus-tmp-user-defined ?s)))
1128 (defvar gnus-summary-mode-line-format-alist
1129 `((?G gnus-tmp-group-name ?s)
1130 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1131 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1132 (?A gnus-tmp-article-number ?d)
1133 (?Z gnus-tmp-unread-and-unselected ?s)
1134 (?V gnus-version ?s)
1135 (?U gnus-tmp-unread-and-unticked ?d)
1136 (?S gnus-tmp-subject ?s)
1137 (?e gnus-tmp-unselected ?d)
1138 (?u gnus-tmp-user-defined ?s)
1139 (?d (length gnus-newsgroup-dormant) ?d)
1140 (?t (length gnus-newsgroup-marked) ?d)
1141 (?h (length gnus-newsgroup-spam-marked) ?d)
1142 (?r (length gnus-newsgroup-reads) ?d)
1143 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1144 (?E gnus-newsgroup-expunged-tally ?d)
1145 (?s (gnus-current-score-file-nondirectory) ?s)))
1147 (defvar gnus-last-search-regexp nil
1148 "Default regexp for article search command.")
1150 (defvar gnus-last-shell-command nil
1151 "Default shell command on article.")
1153 (defvar gnus-newsgroup-begin nil)
1154 (defvar gnus-newsgroup-end nil)
1155 (defvar gnus-newsgroup-last-rmail nil)
1156 (defvar gnus-newsgroup-last-mail nil)
1157 (defvar gnus-newsgroup-last-folder nil)
1158 (defvar gnus-newsgroup-last-file nil)
1159 (defvar gnus-newsgroup-auto-expire nil)
1160 (defvar gnus-newsgroup-active nil)
1162 (defvar gnus-newsgroup-data nil)
1163 (defvar gnus-newsgroup-data-reverse nil)
1164 (defvar gnus-newsgroup-limit nil)
1165 (defvar gnus-newsgroup-limits nil)
1167 (defvar gnus-newsgroup-unreads nil
1168 "Sorted list of unread articles in the current newsgroup.")
1170 (defvar gnus-newsgroup-unselected nil
1171 "Sorted list of unselected unread articles in the current newsgroup.")
1173 (defvar gnus-newsgroup-reads nil
1174 "Alist of read articles and article marks in the current newsgroup.")
1176 (defvar gnus-newsgroup-expunged-tally nil)
1178 (defvar gnus-newsgroup-marked nil
1179 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1181 (defvar gnus-newsgroup-spam-marked nil
1182 "List of ranges of articles that have been marked as spam.")
1184 (defvar gnus-newsgroup-killed nil
1185 "List of ranges of articles that have been through the scoring process.")
1187 (defvar gnus-newsgroup-cached nil
1188 "Sorted list of articles that come from the article cache.")
1190 (defvar gnus-newsgroup-saved nil
1191 "List of articles that have been saved.")
1193 (defvar gnus-newsgroup-kill-headers nil)
1195 (defvar gnus-newsgroup-replied nil
1196 "List of articles that have been replied to in the current newsgroup.")
1198 (defvar gnus-newsgroup-forwarded nil
1199 "List of articles that have been forwarded in the current newsgroup.")
1201 (defvar gnus-newsgroup-recent nil
1202 "List of articles that have are recent in the current newsgroup.")
1204 (defvar gnus-newsgroup-expirable nil
1205 "Sorted list of articles in the current newsgroup that can be expired.")
1207 (defvar gnus-newsgroup-processable nil
1208 "List of articles in the current newsgroup that can be processed.")
1210 (defvar gnus-newsgroup-downloadable nil
1211 "Sorted list of articles in the current newsgroup that can be processed.")
1213 (defvar gnus-newsgroup-undownloaded nil
1214 "List of articles in the current newsgroup that haven't been downloaded..")
1216 (defvar gnus-newsgroup-unsendable nil
1217 "List of articles in the current newsgroup that won't be sent.")
1219 (defvar gnus-newsgroup-bookmarks nil
1220 "List of articles in the current newsgroup that have bookmarks.")
1222 (defvar gnus-newsgroup-dormant nil
1223 "Sorted list of dormant articles in the current newsgroup.")
1225 (defvar gnus-newsgroup-unseen nil
1226 "List of unseen articles in the current newsgroup.")
1228 (defvar gnus-newsgroup-seen nil
1229 "Range of seen articles in the current newsgroup.")
1231 (defvar gnus-newsgroup-articles nil
1232 "List of articles in the current newsgroup.")
1234 (defvar gnus-newsgroup-scored nil
1235 "List of scored articles in the current newsgroup.")
1237 (defvar gnus-newsgroup-headers nil
1238 "List of article headers in the current newsgroup.")
1240 (defvar gnus-newsgroup-threads nil)
1242 (defvar gnus-newsgroup-prepared nil
1243 "Whether the current group has been prepared properly.")
1245 (defvar gnus-newsgroup-ancient nil
1246 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1248 (defvar gnus-newsgroup-sparse nil)
1250 (defvar gnus-current-article nil)
1251 (defvar gnus-article-current nil)
1252 (defvar gnus-current-headers nil)
1253 (defvar gnus-have-all-headers nil)
1254 (defvar gnus-last-article nil)
1255 (defvar gnus-newsgroup-history nil)
1256 (defvar gnus-newsgroup-charset nil)
1257 (defvar gnus-newsgroup-ephemeral-charset nil)
1258 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1260 (defvar gnus-article-before-search nil)
1262 (defconst gnus-summary-local-variables
1263 '(gnus-newsgroup-name
1264 gnus-newsgroup-begin gnus-newsgroup-end
1265 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1266 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1267 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1268 gnus-newsgroup-unselected gnus-newsgroup-marked
1269 gnus-newsgroup-spam-marked
1270 gnus-newsgroup-reads gnus-newsgroup-saved
1271 gnus-newsgroup-replied gnus-newsgroup-forwarded
1272 gnus-newsgroup-recent
1273 gnus-newsgroup-expirable
1274 gnus-newsgroup-processable gnus-newsgroup-killed
1275 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1276 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1277 gnus-newsgroup-seen gnus-newsgroup-articles
1278 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1279 gnus-newsgroup-headers gnus-newsgroup-threads
1280 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1281 gnus-current-article gnus-current-headers gnus-have-all-headers
1282 gnus-last-article gnus-article-internal-prepare-hook
1283 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1284 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1285 gnus-thread-expunge-below
1286 gnus-score-alist gnus-current-score-file
1287 (gnus-summary-expunge-below . global)
1288 (gnus-summary-mark-below . global)
1289 (gnus-orphan-score . global)
1290 gnus-newsgroup-active gnus-scores-exclude-files
1291 gnus-newsgroup-history gnus-newsgroup-ancient
1292 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1293 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1294 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1295 (gnus-newsgroup-expunged-tally . 0)
1296 gnus-cache-removable-articles gnus-newsgroup-cached
1297 gnus-newsgroup-data gnus-newsgroup-data-reverse
1298 gnus-newsgroup-limit gnus-newsgroup-limits
1299 gnus-newsgroup-charset gnus-newsgroup-display)
1300 "Variables that are buffer-local to the summary buffers.")
1302 (defvar gnus-newsgroup-variables nil
1303 "A list of variables that have separate values in different newsgroups.
1304 A list of newsgroup (summary buffer) local variables, or cons of
1305 variables and their default values (when the default values are not
1306 nil), that should be made global while the summary buffer is active.
1307 These variables can be used to set variables in the group parameters
1308 while still allowing them to affect operations done in other
1309 buffers. For example:
1311 \(setq gnus-newsgroup-variables
1312 '(message-use-followup-to
1313 (gnus-visible-headers .
1314 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1317 ;; Byte-compiler warning.
1318 (eval-when-compile (defvar gnus-article-mode-map))
1322 (defvar gnus-decode-encoded-word-methods
1323 '(mail-decode-encoded-word-string)
1324 "List of methods used to decode encoded words.
1326 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1327 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1328 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1329 whose names match REGEXP.
1332 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1333 mail-decode-encoded-word-string
1334 (\"chinese\" . rfc1843-decode-string))")
1336 (defvar gnus-decode-encoded-word-methods-cache nil)
1338 (defun gnus-multi-decode-encoded-word-string (string)
1339 "Apply the functions from `gnus-encoded-word-methods' that match."
1340 (unless (and gnus-decode-encoded-word-methods-cache
1341 (eq gnus-newsgroup-name
1342 (car gnus-decode-encoded-word-methods-cache)))
1343 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1346 (nconc gnus-decode-encoded-word-methods-cache (list x))
1347 (if (and gnus-newsgroup-name
1348 (string-match (car x) gnus-newsgroup-name))
1349 (nconc gnus-decode-encoded-word-methods-cache
1351 gnus-decode-encoded-word-methods))
1352 (let ((xlist gnus-decode-encoded-word-methods-cache))
1355 (setq string (funcall (pop xlist) string))))
1358 ;; Subject simplification.
1360 (defun gnus-simplify-whitespace (str)
1361 "Remove excessive whitespace from STR."
1364 (while (string-match "[ \t][ \t]+" mystr)
1365 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1367 (substring mystr (match-end 0)))))
1369 (when (string-match "^[ \t]+" mystr)
1370 (setq mystr (substring mystr (match-end 0))))
1372 (when (string-match "[ \t]+$" mystr)
1373 (setq mystr (substring mystr 0 (match-beginning 0))))
1376 (defun gnus-simplify-all-whitespace (str)
1377 "Remove all whitespace from STR."
1379 (while (string-match "[ \t\n]+" mystr)
1380 (setq mystr (replace-match "" nil nil mystr)))
1383 (defsubst gnus-simplify-subject-re (subject)
1384 "Remove \"Re:\" from subject lines."
1385 (if (string-match message-subject-re-regexp subject)
1386 (substring subject (match-end 0))
1389 (defun gnus-simplify-subject (subject &optional re-only)
1390 "Remove `Re:' and words in parentheses.
1391 If RE-ONLY is non-nil, strip leading `Re:'s only."
1392 (let ((case-fold-search t)) ;Ignore case.
1393 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1394 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1395 (setq subject (substring subject (match-end 0))))
1396 ;; Remove uninteresting prefixes.
1397 (when (and (not re-only)
1398 gnus-simplify-ignored-prefixes
1399 (string-match gnus-simplify-ignored-prefixes subject))
1400 (setq subject (substring subject (match-end 0))))
1401 ;; Remove words in parentheses from end.
1403 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1404 (setq subject (substring subject 0 (match-beginning 0)))))
1405 ;; Return subject string.
1408 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1410 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1411 (goto-char (point-min))
1412 (while (re-search-forward regexp nil t)
1413 (replace-match (or newtext ""))))
1415 (defun gnus-simplify-buffer-fuzzy ()
1416 "Simplify string in the buffer fuzzily.
1417 The string in the accessible portion of the current buffer is simplified.
1418 It is assumed to be a single-line subject.
1419 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1420 matter is removed. Additional things can be deleted by setting
1421 `gnus-simplify-subject-fuzzy-regexp'."
1422 (let ((case-fold-search t)
1424 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1426 (while (not (eq modified-tick (buffer-modified-tick)))
1427 (setq modified-tick (buffer-modified-tick))
1429 ((listp gnus-simplify-subject-fuzzy-regexp)
1430 (mapcar 'gnus-simplify-buffer-fuzzy-step
1431 gnus-simplify-subject-fuzzy-regexp))
1432 (gnus-simplify-subject-fuzzy-regexp
1433 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1434 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1435 (gnus-simplify-buffer-fuzzy-step
1436 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1437 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1439 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1440 (gnus-simplify-buffer-fuzzy-step " +" " ")
1441 (gnus-simplify-buffer-fuzzy-step " $")
1442 (gnus-simplify-buffer-fuzzy-step "^ +")))
1444 (defun gnus-simplify-subject-fuzzy (subject)
1445 "Simplify a subject string fuzzily.
1446 See `gnus-simplify-buffer-fuzzy' for details."
1448 (gnus-set-work-buffer)
1449 (let ((case-fold-search t))
1450 ;; Remove uninteresting prefixes.
1451 (when (and gnus-simplify-ignored-prefixes
1452 (string-match gnus-simplify-ignored-prefixes subject))
1453 (setq subject (substring subject (match-end 0))))
1455 (inline (gnus-simplify-buffer-fuzzy))
1458 (defsubst gnus-simplify-subject-fully (subject)
1459 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1461 (gnus-simplify-subject-functions
1462 (gnus-map-function gnus-simplify-subject-functions subject))
1463 ((null gnus-summary-gather-subject-limit)
1464 (gnus-simplify-subject-re subject))
1465 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1466 (gnus-simplify-subject-fuzzy subject))
1467 ((numberp gnus-summary-gather-subject-limit)
1468 (gnus-limit-string (gnus-simplify-subject-re subject)
1469 gnus-summary-gather-subject-limit))
1473 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1474 "Check whether two subjects are equal.
1475 If optional argument simple-first is t, first argument is already
1478 ((null simple-first)
1479 (equal (gnus-simplify-subject-fully s1)
1480 (gnus-simplify-subject-fully s2)))
1483 (gnus-simplify-subject-fully s2)))))
1485 (defun gnus-summary-bubble-group ()
1486 "Increase the score of the current group.
1487 This is a handy function to add to `gnus-summary-exit-hook' to
1488 increase the score of each group you read."
1489 (gnus-group-add-score gnus-newsgroup-name))
1493 ;;; Gnus summary mode
1496 (put 'gnus-summary-mode 'mode-class 'special)
1498 (defvar gnus-article-commands-menu)
1501 ;; Non-orthogonal keys
1503 (gnus-define-keys gnus-summary-mode-map
1504 " " gnus-summary-next-page
1505 "\177" gnus-summary-prev-page
1506 [delete] gnus-summary-prev-page
1507 [backspace] gnus-summary-prev-page
1508 "\r" gnus-summary-scroll-up
1509 "\M-\r" gnus-summary-scroll-down
1510 "n" gnus-summary-next-unread-article
1511 "p" gnus-summary-prev-unread-article
1512 "N" gnus-summary-next-article
1513 "P" gnus-summary-prev-article
1514 "\M-\C-n" gnus-summary-next-same-subject
1515 "\M-\C-p" gnus-summary-prev-same-subject
1516 "\M-n" gnus-summary-next-unread-subject
1517 "\M-p" gnus-summary-prev-unread-subject
1518 "." gnus-summary-first-unread-article
1519 "," gnus-summary-best-unread-article
1520 "\M-s" gnus-summary-search-article-forward
1521 "\M-r" gnus-summary-search-article-backward
1522 "<" gnus-summary-beginning-of-article
1523 ">" gnus-summary-end-of-article
1524 "j" gnus-summary-goto-article
1525 "^" gnus-summary-refer-parent-article
1526 "\M-^" gnus-summary-refer-article
1527 "u" gnus-summary-tick-article-forward
1528 "!" gnus-summary-tick-article-forward
1529 "U" gnus-summary-tick-article-backward
1530 "d" gnus-summary-mark-as-read-forward
1531 "D" gnus-summary-mark-as-read-backward
1532 "E" gnus-summary-mark-as-expirable
1533 "\M-u" gnus-summary-clear-mark-forward
1534 "\M-U" gnus-summary-clear-mark-backward
1535 "k" gnus-summary-kill-same-subject-and-select
1536 "\C-k" gnus-summary-kill-same-subject
1537 "\M-\C-k" gnus-summary-kill-thread
1538 "\M-\C-l" gnus-summary-lower-thread
1539 "e" gnus-summary-edit-article
1540 "#" gnus-summary-mark-as-processable
1541 "\M-#" gnus-summary-unmark-as-processable
1542 "\M-\C-t" gnus-summary-toggle-threads
1543 "\M-\C-s" gnus-summary-show-thread
1544 "\M-\C-h" gnus-summary-hide-thread
1545 "\M-\C-f" gnus-summary-next-thread
1546 "\M-\C-b" gnus-summary-prev-thread
1547 [(meta down)] gnus-summary-next-thread
1548 [(meta up)] gnus-summary-prev-thread
1549 "\M-\C-u" gnus-summary-up-thread
1550 "\M-\C-d" gnus-summary-down-thread
1551 "&" gnus-summary-execute-command
1552 "c" gnus-summary-catchup-and-exit
1553 "\C-w" gnus-summary-mark-region-as-read
1554 "\C-t" gnus-summary-toggle-truncation
1555 "?" gnus-summary-mark-as-dormant
1556 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1557 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1558 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1559 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1560 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1561 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1562 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1563 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1564 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1565 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1566 "=" gnus-summary-expand-window
1567 "\C-x\C-s" gnus-summary-reselect-current-group
1568 "\M-g" gnus-summary-rescan-group
1569 "w" gnus-summary-stop-page-breaking
1570 "\C-c\C-r" gnus-summary-caesar-message
1571 "f" gnus-summary-followup
1572 "F" gnus-summary-followup-with-original
1573 "C" gnus-summary-cancel-article
1574 "r" gnus-summary-reply
1575 "R" gnus-summary-reply-with-original
1576 "\C-c\C-f" gnus-summary-mail-forward
1577 "o" gnus-summary-save-article
1578 "\C-o" gnus-summary-save-article-mail
1579 "|" gnus-summary-pipe-output
1580 "\M-k" gnus-summary-edit-local-kill
1581 "\M-K" gnus-summary-edit-global-kill
1583 "\C-c\C-d" gnus-summary-describe-group
1584 "q" gnus-summary-exit
1585 "Q" gnus-summary-exit-no-update
1586 "\C-c\C-i" gnus-info-find-node
1587 gnus-mouse-2 gnus-mouse-pick-article
1588 "m" gnus-summary-mail-other-window
1589 "a" gnus-summary-post-news
1590 "i" gnus-summary-news-other-window
1591 "x" gnus-summary-limit-to-unread
1592 "s" gnus-summary-isearch-article
1593 "t" gnus-summary-toggle-header
1594 "g" gnus-summary-show-article
1595 "l" gnus-summary-goto-last-article
1596 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1597 "\C-d" gnus-summary-enter-digest-group
1598 "\M-\C-d" gnus-summary-read-document
1599 "\M-\C-e" gnus-summary-edit-parameters
1600 "\M-\C-a" gnus-summary-customize-parameters
1602 "*" gnus-cache-enter-article
1603 "\M-*" gnus-cache-remove-article
1604 "\M-&" gnus-summary-universal-argument
1605 "\C-l" gnus-recenter
1606 "I" gnus-summary-increase-score
1607 "L" gnus-summary-lower-score
1608 "\M-i" gnus-symbolic-argument
1609 "h" gnus-summary-select-article-buffer
1611 "b" gnus-article-view-part
1612 "\M-t" gnus-summary-toggle-display-buttonized
1614 "V" gnus-summary-score-map
1615 "X" gnus-uu-extract-map
1616 "S" gnus-summary-send-map)
1618 ;; Sort of orthogonal keymap
1619 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1620 "t" gnus-summary-tick-article-forward
1621 "!" gnus-summary-tick-article-forward
1622 "d" gnus-summary-mark-as-read-forward
1623 "r" gnus-summary-mark-as-read-forward
1624 "c" gnus-summary-clear-mark-forward
1625 " " gnus-summary-clear-mark-forward
1626 "e" gnus-summary-mark-as-expirable
1627 "x" gnus-summary-mark-as-expirable
1628 "?" gnus-summary-mark-as-dormant
1629 "b" gnus-summary-set-bookmark
1630 "B" gnus-summary-remove-bookmark
1631 "#" gnus-summary-mark-as-processable
1632 "\M-#" gnus-summary-unmark-as-processable
1633 "S" gnus-summary-limit-include-expunged
1634 "C" gnus-summary-catchup
1635 "H" gnus-summary-catchup-to-here
1636 "h" gnus-summary-catchup-from-here
1637 "\C-c" gnus-summary-catchup-all
1638 "k" gnus-summary-kill-same-subject-and-select
1639 "K" gnus-summary-kill-same-subject
1640 "P" gnus-uu-mark-map)
1642 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1643 "c" gnus-summary-clear-above
1644 "u" gnus-summary-tick-above
1645 "m" gnus-summary-mark-above
1646 "k" gnus-summary-kill-below)
1648 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1649 "/" gnus-summary-limit-to-subject
1650 "n" gnus-summary-limit-to-articles
1651 "w" gnus-summary-pop-limit
1652 "s" gnus-summary-limit-to-subject
1653 "a" gnus-summary-limit-to-author
1654 "u" gnus-summary-limit-to-unread
1655 "m" gnus-summary-limit-to-marks
1656 "M" gnus-summary-limit-exclude-marks
1657 "v" gnus-summary-limit-to-score
1658 "*" gnus-summary-limit-include-cached
1659 "D" gnus-summary-limit-include-dormant
1660 "T" gnus-summary-limit-include-thread
1661 "d" gnus-summary-limit-exclude-dormant
1662 "t" gnus-summary-limit-to-age
1663 "." gnus-summary-limit-to-unseen
1664 "x" gnus-summary-limit-to-extra
1665 "p" gnus-summary-limit-to-display-predicate
1666 "E" gnus-summary-limit-include-expunged
1667 "c" gnus-summary-limit-exclude-childless-dormant
1668 "C" gnus-summary-limit-mark-excluded-as-read
1669 "o" gnus-summary-insert-old-articles
1670 "N" gnus-summary-insert-new-articles)
1672 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1673 "n" gnus-summary-next-unread-article
1674 "p" gnus-summary-prev-unread-article
1675 "N" gnus-summary-next-article
1676 "P" gnus-summary-prev-article
1677 "\C-n" gnus-summary-next-same-subject
1678 "\C-p" gnus-summary-prev-same-subject
1679 "\M-n" gnus-summary-next-unread-subject
1680 "\M-p" gnus-summary-prev-unread-subject
1681 "f" gnus-summary-first-unread-article
1682 "b" gnus-summary-best-unread-article
1683 "j" gnus-summary-goto-article
1684 "g" gnus-summary-goto-subject
1685 "l" gnus-summary-goto-last-article
1686 "o" gnus-summary-pop-article)
1688 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1689 "k" gnus-summary-kill-thread
1690 "l" gnus-summary-lower-thread
1691 "i" gnus-summary-raise-thread
1692 "T" gnus-summary-toggle-threads
1693 "t" gnus-summary-rethread-current
1694 "^" gnus-summary-reparent-thread
1695 "s" gnus-summary-show-thread
1696 "S" gnus-summary-show-all-threads
1697 "h" gnus-summary-hide-thread
1698 "H" gnus-summary-hide-all-threads
1699 "n" gnus-summary-next-thread
1700 "p" gnus-summary-prev-thread
1701 "u" gnus-summary-up-thread
1702 "o" gnus-summary-top-thread
1703 "d" gnus-summary-down-thread
1704 "#" gnus-uu-mark-thread
1705 "\M-#" gnus-uu-unmark-thread)
1707 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1708 "g" gnus-summary-prepare
1709 "c" gnus-summary-insert-cached-articles)
1711 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1712 "c" gnus-summary-catchup-and-exit
1713 "C" gnus-summary-catchup-all-and-exit
1714 "E" gnus-summary-exit-no-update
1715 "Q" gnus-summary-exit
1716 "Z" gnus-summary-exit
1717 "n" gnus-summary-catchup-and-goto-next-group
1718 "R" gnus-summary-reselect-current-group
1719 "G" gnus-summary-rescan-group
1720 "N" gnus-summary-next-group
1721 "s" gnus-summary-save-newsrc
1722 "P" gnus-summary-prev-group)
1724 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1725 " " gnus-summary-next-page
1726 "n" gnus-summary-next-page
1727 "\177" gnus-summary-prev-page
1728 [delete] gnus-summary-prev-page
1729 "p" gnus-summary-prev-page
1730 "\r" gnus-summary-scroll-up
1731 "\M-\r" gnus-summary-scroll-down
1732 "<" gnus-summary-beginning-of-article
1733 ">" gnus-summary-end-of-article
1734 "b" gnus-summary-beginning-of-article
1735 "e" gnus-summary-end-of-article
1736 "^" gnus-summary-refer-parent-article
1737 "r" gnus-summary-refer-parent-article
1738 "D" gnus-summary-enter-digest-group
1739 "R" gnus-summary-refer-references
1740 "T" gnus-summary-refer-thread
1741 "g" gnus-summary-show-article
1742 "s" gnus-summary-isearch-article
1743 "P" gnus-summary-print-article
1744 "M" gnus-mailing-list-insinuate
1745 "t" gnus-article-babel)
1747 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1748 "b" gnus-article-add-buttons
1749 "B" gnus-article-add-buttons-to-head
1750 "o" gnus-article-treat-overstrike
1751 "e" gnus-article-emphasize
1752 "w" gnus-article-fill-cited-article
1753 "Q" gnus-article-fill-long-lines
1754 "C" gnus-article-capitalize-sentences
1755 "c" gnus-article-remove-cr
1756 "q" gnus-article-de-quoted-unreadable
1757 "6" gnus-article-de-base64-unreadable
1758 "Z" gnus-article-decode-HZ
1759 "h" gnus-article-wash-html
1760 "u" gnus-article-unsplit-urls
1761 "s" gnus-summary-force-verify-and-decrypt
1762 "f" gnus-article-display-x-face
1763 "l" gnus-summary-stop-page-breaking
1764 "r" gnus-summary-caesar-message
1765 "t" gnus-summary-toggle-header
1766 "g" gnus-treat-smiley
1767 "v" gnus-summary-verbose-headers
1768 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1769 "p" gnus-article-verify-x-pgp-sig
1770 "d" gnus-article-treat-dumbquotes
1771 "k" gnus-article-outlook-deuglify-article)
1773 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1774 "a" gnus-article-hide
1775 "h" gnus-article-hide-headers
1776 "b" gnus-article-hide-boring-headers
1777 "s" gnus-article-hide-signature
1778 "c" gnus-article-hide-citation
1779 "C" gnus-article-hide-citation-in-followups
1780 "l" gnus-article-hide-list-identifiers
1781 "p" gnus-article-hide-pgp
1782 "B" gnus-article-strip-banner
1783 "P" gnus-article-hide-pem
1784 "\C-c" gnus-article-hide-citation-maybe)
1786 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1787 "a" gnus-article-highlight
1788 "h" gnus-article-highlight-headers
1789 "c" gnus-article-highlight-citation
1790 "s" gnus-article-highlight-signature)
1792 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1793 "f" gnus-article-treat-fold-headers
1794 "u" gnus-article-treat-unfold-headers
1795 "n" gnus-article-treat-fold-newsgroups)
1797 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1798 "x" gnus-article-display-x-face
1799 "s" gnus-treat-smiley
1800 "D" gnus-article-remove-images
1801 "f" gnus-treat-from-picon
1802 "m" gnus-treat-mail-picon
1803 "n" gnus-treat-newsgroups-picon)
1805 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1806 "w" gnus-article-decode-mime-words
1807 "c" gnus-article-decode-charset
1808 "v" gnus-mime-view-all-parts
1809 "b" gnus-article-view-part)
1811 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1812 "z" gnus-article-date-ut
1813 "u" gnus-article-date-ut
1814 "l" gnus-article-date-local
1815 "p" gnus-article-date-english
1816 "e" gnus-article-date-lapsed
1817 "o" gnus-article-date-original
1818 "i" gnus-article-date-iso8601
1819 "s" gnus-article-date-user)
1821 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1822 "t" gnus-article-remove-trailing-blank-lines
1823 "l" gnus-article-strip-leading-blank-lines
1824 "m" gnus-article-strip-multiple-blank-lines
1825 "a" gnus-article-strip-blank-lines
1826 "A" gnus-article-strip-all-blank-lines
1827 "s" gnus-article-strip-leading-space
1828 "e" gnus-article-strip-trailing-space
1829 "w" gnus-article-remove-leading-whitespace)
1831 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1833 "f" gnus-summary-fetch-faq
1834 "d" gnus-summary-describe-group
1835 "h" gnus-summary-describe-briefly
1836 "i" gnus-info-find-node)
1838 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1839 "e" gnus-summary-expire-articles
1840 "\M-\C-e" gnus-summary-expire-articles-now
1841 "\177" gnus-summary-delete-article
1842 [delete] gnus-summary-delete-article
1843 [backspace] gnus-summary-delete-article
1844 "m" gnus-summary-move-article
1845 "r" gnus-summary-respool-article
1846 "w" gnus-summary-edit-article
1847 "c" gnus-summary-copy-article
1848 "B" gnus-summary-crosspost-article
1849 "q" gnus-summary-respool-query
1850 "t" gnus-summary-respool-trace
1851 "i" gnus-summary-import-article
1852 "I" gnus-summary-create-article
1853 "p" gnus-summary-article-posted-p)
1855 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1856 "o" gnus-summary-save-article
1857 "m" gnus-summary-save-article-mail
1858 "F" gnus-summary-write-article-file
1859 "r" gnus-summary-save-article-rmail
1860 "f" gnus-summary-save-article-file
1861 "b" gnus-summary-save-article-body-file
1862 "h" gnus-summary-save-article-folder
1863 "v" gnus-summary-save-article-vm
1864 "p" gnus-summary-pipe-output
1865 "P" gnus-summary-muttprint
1866 "s" gnus-soup-add-article)
1868 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1869 "b" gnus-summary-display-buttonized
1870 "m" gnus-summary-repair-multipart
1871 "v" gnus-article-view-part
1872 "o" gnus-article-save-part
1873 "c" gnus-article-copy-part
1874 "C" gnus-article-view-part-as-charset
1875 "e" gnus-article-view-part-externally
1876 "E" gnus-article-encrypt-body
1877 "i" gnus-article-inline-part
1878 "|" gnus-article-pipe-part)
1880 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1881 "p" gnus-summary-mark-as-processable
1882 "u" gnus-summary-unmark-as-processable
1883 "U" gnus-summary-unmark-all-processable
1884 "v" gnus-uu-mark-over
1885 "s" gnus-uu-mark-series
1886 "r" gnus-uu-mark-region
1887 "g" gnus-uu-unmark-region
1888 "R" gnus-uu-mark-by-regexp
1889 "G" gnus-uu-unmark-by-regexp
1890 "t" gnus-uu-mark-thread
1891 "T" gnus-uu-unmark-thread
1892 "a" gnus-uu-mark-all
1893 "b" gnus-uu-mark-buffer
1894 "S" gnus-uu-mark-sparse
1895 "k" gnus-summary-kill-process-mark
1896 "y" gnus-summary-yank-process-mark
1897 "w" gnus-summary-save-process-mark
1898 "i" gnus-uu-invert-processable)
1900 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1901 ;;"x" gnus-uu-extract-any
1902 "m" gnus-summary-save-parts
1903 "u" gnus-uu-decode-uu
1904 "U" gnus-uu-decode-uu-and-save
1905 "s" gnus-uu-decode-unshar
1906 "S" gnus-uu-decode-unshar-and-save
1907 "o" gnus-uu-decode-save
1908 "O" gnus-uu-decode-save
1909 "b" gnus-uu-decode-binhex
1910 "B" gnus-uu-decode-binhex
1911 "p" gnus-uu-decode-postscript
1912 "P" gnus-uu-decode-postscript-and-save)
1915 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1916 "u" gnus-uu-decode-uu-view
1917 "U" gnus-uu-decode-uu-and-save-view
1918 "s" gnus-uu-decode-unshar-view
1919 "S" gnus-uu-decode-unshar-and-save-view
1920 "o" gnus-uu-decode-save-view
1921 "O" gnus-uu-decode-save-view
1922 "b" gnus-uu-decode-binhex-view
1923 "B" gnus-uu-decode-binhex-view
1924 "p" gnus-uu-decode-postscript-view
1925 "P" gnus-uu-decode-postscript-and-save-view))
1927 (defvar gnus-article-post-menu nil)
1929 (defconst gnus-summary-menu-maxlen 20)
1931 (defun gnus-summary-menu-split (menu)
1932 ;; If we have lots of elements, divide them into groups of 20
1933 ;; and make a pane (or submenu) for each one.
1934 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1935 (let ((menu menu) sublists next
1938 ;; Pull off the next gnus-summary-menu-maxlen elements
1939 ;; and make them the next element of sublist.
1940 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1942 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1944 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1945 (aref (car (last menu)) 0)) menu)
1949 (nreverse sublists))
1950 ;; Few elements--put them all in one pane.
1953 (defun gnus-summary-make-menu-bar ()
1954 (gnus-turn-off-edit-menu 'summary)
1956 (unless (boundp 'gnus-summary-misc-menu)
1959 gnus-summary-kill-menu gnus-summary-mode-map ""
1964 ["Customize" gnus-score-customize t])
1965 (gnus-make-score-map 'increase)
1966 (gnus-make-score-map 'lower)
1968 ["Kill below" gnus-summary-kill-below t]
1969 ["Mark above" gnus-summary-mark-above t]
1970 ["Tick above" gnus-summary-tick-above t]
1971 ["Clear above" gnus-summary-clear-above t])
1972 ["Current score" gnus-summary-current-score t]
1973 ["Set score" gnus-summary-set-score t]
1974 ["Switch current score file..." gnus-score-change-score-file t]
1975 ["Set mark below..." gnus-score-set-mark-below t]
1976 ["Set expunge below..." gnus-score-set-expunge-below t]
1977 ["Edit current score file" gnus-score-edit-current-scores t]
1978 ["Edit score file" gnus-score-edit-file t]
1979 ["Trace score" gnus-score-find-trace t]
1980 ["Find words" gnus-score-find-favourite-words t]
1981 ["Rescore buffer" gnus-summary-rescore t]
1982 ["Increase score..." gnus-summary-increase-score t]
1983 ["Lower score..." gnus-summary-lower-score t]))))
1985 ;; Define both the Article menu in the summary buffer and the
1986 ;; equivalent Commands menu in the article buffer here for
1990 ["All" gnus-article-hide t]
1991 ["Headers" gnus-article-hide-headers t]
1992 ["Signature" gnus-article-hide-signature t]
1993 ["Citation" gnus-article-hide-citation t]
1994 ["List identifiers" gnus-article-hide-list-identifiers t]
1995 ["PGP" gnus-article-hide-pgp t]
1996 ["Banner" gnus-article-strip-banner t]
1997 ["Boring headers" gnus-article-hide-boring-headers t])
1999 ["All" gnus-article-highlight t]
2000 ["Headers" gnus-article-highlight-headers t]
2001 ["Signature" gnus-article-highlight-signature t]
2002 ["Citation" gnus-article-highlight-citation t])
2004 ["Words" gnus-article-decode-mime-words t]
2005 ["Charset" gnus-article-decode-charset t]
2006 ["QP" gnus-article-de-quoted-unreadable t]
2007 ["Base64" gnus-article-de-base64-unreadable t]
2008 ["View MIME buttons" gnus-summary-display-buttonized t]
2009 ["View all" gnus-mime-view-all-parts t]
2010 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2011 ["Encrypt body" gnus-article-encrypt-body t]
2012 ["Extract all parts" gnus-summary-save-parts t])
2014 ["Local" gnus-article-date-local t]
2015 ["ISO8601" gnus-article-date-iso8601 t]
2016 ["UT" gnus-article-date-ut t]
2017 ["Original" gnus-article-date-original t]
2018 ["Lapsed" gnus-article-date-lapsed t]
2019 ["User-defined" gnus-article-date-user t])
2021 ["Remove images" gnus-article-remove-images t]
2022 ["Toggle smiley" gnus-treat-smiley t]
2023 ["Show X-Face" gnus-article-display-x-face t]
2024 ["Show picons in From" gnus-treat-from-picon t]
2025 ["Show picons in mail headers" gnus-treat-mail-picon t]
2026 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2027 ("View as different encoding"
2028 ,@(gnus-summary-menu-split
2031 ;; Since easymenu under FSF Emacs doesn't allow lambda
2032 ;; forms for menu commands, we should provide intern'ed
2033 ;; function symbols.
2034 (let ((command (intern (format "\
2035 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2039 (let ((gnus-summary-show-article-charset-alist
2041 (gnus-summary-show-article 1))))
2042 `[,(symbol-name cs) ,command t]))
2043 (sort (if (fboundp 'coding-system-list)
2044 (coding-system-list)
2045 (mapcar 'car mm-mime-mule-charset-alist))
2047 (string< (symbol-name a)
2048 (symbol-name b))))))))
2051 ["Leading" gnus-article-strip-leading-blank-lines t]
2052 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2053 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2054 ["All of the above" gnus-article-strip-blank-lines t]
2055 ["All" gnus-article-strip-all-blank-lines t]
2056 ["Leading space" gnus-article-strip-leading-space t]
2057 ["Trailing space" gnus-article-strip-trailing-space t]
2058 ["Leading space in headers"
2059 gnus-article-remove-leading-whitespace t])
2060 ["Overstrike" gnus-article-treat-overstrike t]
2061 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2062 ["Emphasis" gnus-article-emphasize t]
2063 ["Word wrap" gnus-article-fill-cited-article t]
2064 ["Fill long lines" gnus-article-fill-long-lines t]
2065 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2066 ["CR" gnus-article-remove-cr t]
2067 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2068 ["Base64" gnus-article-de-base64-unreadable t]
2069 ["Rot 13" gnus-summary-caesar-message
2070 ,@(if (featurep 'xemacs) '(t)
2071 '(:help "\"Caesar rotate\" article by 13"))]
2072 ["Unix pipe..." gnus-summary-pipe-message t]
2073 ["Add buttons" gnus-article-add-buttons t]
2074 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2075 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2076 ["Verbose header" gnus-summary-verbose-headers t]
2077 ["Toggle header" gnus-summary-toggle-header t]
2078 ["Unfold headers" gnus-article-treat-unfold-headers t]
2079 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2080 ["Html" gnus-article-wash-html t]
2081 ["URLs" gnus-article-unsplit-urls t]
2082 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2083 ["HZ" gnus-article-decode-HZ t]
2084 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2087 ["Save in default format" gnus-summary-save-article
2088 ,@(if (featurep 'xemacs) '(t)
2089 '(:help "Save article using default method"))]
2090 ["Save in file" gnus-summary-save-article-file
2091 ,@(if (featurep 'xemacs) '(t)
2092 '(:help "Save article in file"))]
2093 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2094 ["Save in MH folder" gnus-summary-save-article-folder t]
2095 ["Save in VM folder" gnus-summary-save-article-vm t]
2096 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2097 ["Save body in file" gnus-summary-save-article-body-file t]
2098 ["Pipe through a filter" gnus-summary-pipe-output t]
2099 ["Add to SOUP packet" gnus-soup-add-article t]
2100 ["Print with Muttprint" gnus-summary-muttprint t]
2101 ["Print" gnus-summary-print-article t])
2103 ["Respool article..." gnus-summary-respool-article t]
2104 ["Move article..." gnus-summary-move-article
2105 (gnus-check-backend-function
2106 'request-move-article gnus-newsgroup-name)]
2107 ["Copy article..." gnus-summary-copy-article t]
2108 ["Crosspost article..." gnus-summary-crosspost-article
2109 (gnus-check-backend-function
2110 'request-replace-article gnus-newsgroup-name)]
2111 ["Import file..." gnus-summary-import-article t]
2112 ["Create article..." gnus-summary-create-article t]
2113 ["Check if posted" gnus-summary-article-posted-p t]
2114 ["Edit article" gnus-summary-edit-article
2115 (not (gnus-group-read-only-p))]
2116 ["Delete article" gnus-summary-delete-article
2117 (gnus-check-backend-function
2118 'request-expire-articles gnus-newsgroup-name)]
2119 ["Query respool" gnus-summary-respool-query t]
2120 ["Trace respool" gnus-summary-respool-trace t]
2121 ["Delete expirable articles" gnus-summary-expire-articles-now
2122 (gnus-check-backend-function
2123 'request-expire-articles gnus-newsgroup-name)])
2125 ["Uudecode" gnus-uu-decode-uu
2126 ,@(if (featurep 'xemacs) '(t)
2127 '(:help "Decode uuencoded article(s)"))]
2128 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2129 ["Unshar" gnus-uu-decode-unshar t]
2130 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2131 ["Save" gnus-uu-decode-save t]
2132 ["Binhex" gnus-uu-decode-binhex t]
2133 ["Postscript" gnus-uu-decode-postscript t]
2134 ["All MIME parts" gnus-summary-save-parts t])
2136 ["Enter article" gnus-cache-enter-article t]
2137 ["Remove article" gnus-cache-remove-article t])
2138 ["Translate" gnus-article-babel t]
2139 ["Select article buffer" gnus-summary-select-article-buffer t]
2140 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2141 ["Isearch article..." gnus-summary-isearch-article t]
2142 ["Beginning of the article" gnus-summary-beginning-of-article t]
2143 ["End of the article" gnus-summary-end-of-article t]
2144 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2145 ["Fetch referenced articles" gnus-summary-refer-references t]
2146 ["Fetch current thread" gnus-summary-refer-thread t]
2147 ["Fetch article with id..." gnus-summary-refer-article t]
2148 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2149 ["Redisplay" gnus-summary-show-article t]
2150 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2152 gnus-summary-article-menu gnus-summary-mode-map ""
2153 (cons "Article" innards))
2155 (if (not (keymapp gnus-summary-article-menu))
2157 gnus-article-commands-menu gnus-article-mode-map ""
2158 (cons "Commands" innards))
2159 ;; in Emacs, don't share menu.
2160 (setq gnus-article-commands-menu
2161 (copy-keymap gnus-summary-article-menu))
2162 (define-key gnus-article-mode-map [menu-bar commands]
2163 (cons "Commands" gnus-article-commands-menu))))
2166 gnus-summary-thread-menu gnus-summary-mode-map ""
2168 ["Toggle threading" gnus-summary-toggle-threads t]
2169 ["Hide threads" gnus-summary-hide-all-threads t]
2170 ["Show threads" gnus-summary-show-all-threads t]
2171 ["Hide thread" gnus-summary-hide-thread t]
2172 ["Show thread" gnus-summary-show-thread t]
2173 ["Go to next thread" gnus-summary-next-thread t]
2174 ["Go to previous thread" gnus-summary-prev-thread t]
2175 ["Go down thread" gnus-summary-down-thread t]
2176 ["Go up thread" gnus-summary-up-thread t]
2177 ["Top of thread" gnus-summary-top-thread t]
2178 ["Mark thread as read" gnus-summary-kill-thread t]
2179 ["Lower thread score" gnus-summary-lower-thread t]
2180 ["Raise thread score" gnus-summary-raise-thread t]
2181 ["Rethread current" gnus-summary-rethread-current t]))
2184 gnus-summary-post-menu gnus-summary-mode-map ""
2186 ["Send a message (mail or news)" gnus-summary-post-news
2187 ,@(if (featurep 'xemacs) '(t)
2188 '(:help "Post an article"))]
2189 ["Followup" gnus-summary-followup
2190 ,@(if (featurep 'xemacs) '(t)
2191 '(:help "Post followup to this article"))]
2192 ["Followup and yank" gnus-summary-followup-with-original
2193 ,@(if (featurep 'xemacs) '(t)
2194 '(:help "Post followup to this article, quoting its contents"))]
2195 ["Supersede article" gnus-summary-supersede-article t]
2196 ["Cancel article" gnus-summary-cancel-article
2197 ,@(if (featurep 'xemacs) '(t)
2198 '(:help "Cancel an article you posted"))]
2199 ["Reply" gnus-summary-reply t]
2200 ["Reply and yank" gnus-summary-reply-with-original t]
2201 ["Wide reply" gnus-summary-wide-reply t]
2202 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2203 ,@(if (featurep 'xemacs) '(t)
2204 '(:help "Mail a reply, quoting this article"))]
2205 ["Very wide reply" gnus-summary-very-wide-reply t]
2206 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2207 ,@(if (featurep 'xemacs) '(t)
2208 '(:help "Mail a very wide reply, quoting this article"))]
2209 ["Mail forward" gnus-summary-mail-forward t]
2210 ["Post forward" gnus-summary-post-forward t]
2211 ["Digest and mail" gnus-uu-digest-mail-forward t]
2212 ["Digest and post" gnus-uu-digest-post-forward t]
2213 ["Resend message" gnus-summary-resend-message t]
2214 ["Resend message edit" gnus-summary-resend-message-edit t]
2215 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2216 ["Send a mail" gnus-summary-mail-other-window t]
2217 ["Create a local message" gnus-summary-news-other-window t]
2218 ["Uuencode and post" gnus-uu-post-news
2219 ,@(if (featurep 'xemacs) '(t)
2220 '(:help "Post a uuencoded article"))]
2221 ["Followup via news" gnus-summary-followup-to-mail t]
2222 ["Followup via news and yank"
2223 gnus-summary-followup-to-mail-with-original t]
2225 ;;["Send" gnus-summary-send-draft t]
2226 ;;["Send bounced" gnus-resend-bounced-mail t])
2230 ((not (keymapp gnus-summary-post-menu))
2231 (setq gnus-article-post-menu gnus-summary-post-menu))
2232 ((not gnus-article-post-menu)
2233 ;; Don't share post menu.
2234 (setq gnus-article-post-menu
2235 (copy-keymap gnus-summary-post-menu))))
2236 (define-key gnus-article-mode-map [menu-bar post]
2237 (cons "Post" gnus-article-post-menu))
2240 gnus-summary-misc-menu gnus-summary-mode-map ""
2243 ["Mark as read" gnus-summary-mark-as-read-forward t]
2244 ["Mark same subject and select"
2245 gnus-summary-kill-same-subject-and-select t]
2246 ["Mark same subject" gnus-summary-kill-same-subject t]
2247 ["Catchup" gnus-summary-catchup
2248 ,@(if (featurep 'xemacs) '(t)
2249 '(:help "Mark unread articles in this group as read"))]
2250 ["Catchup all" gnus-summary-catchup-all t]
2251 ["Catchup to here" gnus-summary-catchup-to-here t]
2252 ["Catchup from here" gnus-summary-catchup-from-here t]
2253 ["Catchup region" gnus-summary-mark-region-as-read t]
2254 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2256 ["Tick" gnus-summary-tick-article-forward t]
2257 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2258 ["Remove marks" gnus-summary-clear-mark-forward t]
2259 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2260 ["Set bookmark" gnus-summary-set-bookmark t]
2261 ["Remove bookmark" gnus-summary-remove-bookmark t])
2263 ["Marks..." gnus-summary-limit-to-marks t]
2264 ["Subject..." gnus-summary-limit-to-subject t]
2265 ["Author..." gnus-summary-limit-to-author t]
2266 ["Age..." gnus-summary-limit-to-age t]
2267 ["Extra..." gnus-summary-limit-to-extra t]
2268 ["Score..." gnus-summary-limit-to-score t]
2269 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2270 ["Unread" gnus-summary-limit-to-unread t]
2271 ["Unseen" gnus-summary-limit-to-unseen t]
2272 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2273 ["Articles" gnus-summary-limit-to-articles t]
2274 ["Pop limit" gnus-summary-pop-limit t]
2275 ["Show dormant" gnus-summary-limit-include-dormant t]
2276 ["Hide childless dormant"
2277 gnus-summary-limit-exclude-childless-dormant t]
2278 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2279 ["Hide marked" gnus-summary-limit-exclude-marks t]
2280 ["Show expunged" gnus-summary-limit-include-expunged t])
2282 ["Set mark" gnus-summary-mark-as-processable t]
2283 ["Remove mark" gnus-summary-unmark-as-processable t]
2284 ["Remove all marks" gnus-summary-unmark-all-processable t]
2285 ["Mark above" gnus-uu-mark-over t]
2286 ["Mark series" gnus-uu-mark-series t]
2287 ["Mark region" gnus-uu-mark-region t]
2288 ["Unmark region" gnus-uu-unmark-region t]
2289 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2290 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2291 ["Mark all" gnus-uu-mark-all t]
2292 ["Mark buffer" gnus-uu-mark-buffer t]
2293 ["Mark sparse" gnus-uu-mark-sparse t]
2294 ["Mark thread" gnus-uu-mark-thread t]
2295 ["Unmark thread" gnus-uu-unmark-thread t]
2296 ("Process Mark Sets"
2297 ["Kill" gnus-summary-kill-process-mark t]
2298 ["Yank" gnus-summary-yank-process-mark
2299 gnus-newsgroup-process-stack]
2300 ["Save" gnus-summary-save-process-mark t]))
2302 ["Page forward" gnus-summary-next-page
2303 ,@(if (featurep 'xemacs) '(t)
2304 '(:help "Show next page of article"))]
2305 ["Page backward" gnus-summary-prev-page
2306 ,@(if (featurep 'xemacs) '(t)
2307 '(:help "Show previous page of article"))]
2308 ["Line forward" gnus-summary-scroll-up t])
2310 ["Next unread article" gnus-summary-next-unread-article t]
2311 ["Previous unread article" gnus-summary-prev-unread-article t]
2312 ["Next article" gnus-summary-next-article t]
2313 ["Previous article" gnus-summary-prev-article t]
2314 ["Next unread subject" gnus-summary-next-unread-subject t]
2315 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2316 ["Next article same subject" gnus-summary-next-same-subject t]
2317 ["Previous article same subject" gnus-summary-prev-same-subject t]
2318 ["First unread article" gnus-summary-first-unread-article t]
2319 ["Best unread article" gnus-summary-best-unread-article t]
2320 ["Go to subject number..." gnus-summary-goto-subject t]
2321 ["Go to article number..." gnus-summary-goto-article t]
2322 ["Go to the last article" gnus-summary-goto-last-article t]
2323 ["Pop article off history" gnus-summary-pop-article t])
2325 ["Sort by number" gnus-summary-sort-by-number t]
2326 ["Sort by author" gnus-summary-sort-by-author t]
2327 ["Sort by subject" gnus-summary-sort-by-subject t]
2328 ["Sort by date" gnus-summary-sort-by-date t]
2329 ["Sort by score" gnus-summary-sort-by-score t]
2330 ["Sort by lines" gnus-summary-sort-by-lines t]
2331 ["Sort by characters" gnus-summary-sort-by-chars t]
2332 ["Randomize" gnus-summary-sort-by-random t]
2333 ["Original sort" gnus-summary-sort-by-original t])
2335 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2336 ["Describe group" gnus-summary-describe-group t]
2337 ["Read manual" gnus-info-find-node t])
2339 ["Pick and read" gnus-pick-mode t]
2340 ["Binary" gnus-binary-mode t])
2342 ["Regenerate" gnus-summary-prepare t]
2343 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2344 ["Toggle threading" gnus-summary-toggle-threads t])
2345 ["See old articles" gnus-summary-insert-old-articles t]
2346 ["See new articles" gnus-summary-insert-new-articles t]
2347 ["Filter articles..." gnus-summary-execute-command t]
2348 ["Run command on subjects..." gnus-summary-universal-argument t]
2349 ["Search articles forward..." gnus-summary-search-article-forward t]
2350 ["Search articles backward..." gnus-summary-search-article-backward t]
2351 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2352 ["Expand window" gnus-summary-expand-window t]
2353 ["Expire expirable articles" gnus-summary-expire-articles
2354 (gnus-check-backend-function
2355 'request-expire-articles gnus-newsgroup-name)]
2356 ["Edit local kill file" gnus-summary-edit-local-kill t]
2357 ["Edit main kill file" gnus-summary-edit-global-kill t]
2358 ["Edit group parameters" gnus-summary-edit-parameters t]
2359 ["Customize group parameters" gnus-summary-customize-parameters t]
2360 ["Send a bug report" gnus-bug t]
2362 ["Catchup and exit" gnus-summary-catchup-and-exit
2363 ,@(if (featurep 'xemacs) '(t)
2364 '(:help "Mark unread articles in this group as read, then exit"))]
2365 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2366 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2367 ["Exit group" gnus-summary-exit
2368 ,@(if (featurep 'xemacs) '(t)
2369 '(:help "Exit current group, return to group selection mode"))]
2370 ["Exit group without updating" gnus-summary-exit-no-update t]
2371 ["Exit and goto next group" gnus-summary-next-group t]
2372 ["Exit and goto prev group" gnus-summary-prev-group t]
2373 ["Reselect group" gnus-summary-reselect-current-group t]
2374 ["Rescan group" gnus-summary-rescan-group t]
2375 ["Update dribble" gnus-summary-save-newsrc t])))
2377 (gnus-run-hooks 'gnus-summary-menu-hook)))
2379 (defvar gnus-summary-tool-bar-map nil)
2381 ;; Emacs 21 tool bar. Should be no-op otherwise.
2382 (defun gnus-summary-make-tool-bar ()
2383 (if (and (fboundp 'tool-bar-add-item-from-menu)
2384 (default-value 'tool-bar-mode)
2385 (not gnus-summary-tool-bar-map))
2386 (setq gnus-summary-tool-bar-map
2387 (let ((tool-bar-map (make-sparse-keymap))
2388 (load-path (mm-image-load-path)))
2389 (tool-bar-add-item-from-menu
2390 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2391 (tool-bar-add-item-from-menu
2392 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2393 (tool-bar-add-item-from-menu
2394 'gnus-summary-post-news "post" gnus-summary-mode-map)
2395 (tool-bar-add-item-from-menu
2396 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2397 (tool-bar-add-item-from-menu
2398 'gnus-summary-followup "followup" gnus-summary-mode-map)
2399 (tool-bar-add-item-from-menu
2400 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2401 (tool-bar-add-item-from-menu
2402 'gnus-summary-reply "reply" gnus-summary-mode-map)
2403 (tool-bar-add-item-from-menu
2404 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2405 (tool-bar-add-item-from-menu
2406 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2407 (tool-bar-add-item-from-menu
2408 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2409 (tool-bar-add-item-from-menu
2410 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2411 (tool-bar-add-item-from-menu
2412 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2413 (tool-bar-add-item-from-menu
2414 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2415 (tool-bar-add-item-from-menu
2416 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2417 (tool-bar-add-item-from-menu
2418 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2420 (if gnus-summary-tool-bar-map
2421 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2423 (defun gnus-score-set-default (var value)
2424 "A version of set that updates the GNU Emacs menu-bar."
2426 ;; It is the message that forces the active status to be updated.
2429 (defun gnus-make-score-map (type)
2430 "Make a summary score map of type TYPE."
2433 (let ((headers '(("author" "from" string)
2434 ("subject" "subject" string)
2435 ("article body" "body" string)
2436 ("article head" "head" string)
2437 ("xref" "xref" string)
2438 ("extra header" "extra" string)
2439 ("lines" "lines" number)
2440 ("followups to author" "followup" string)))
2441 (types '((number ("less than" <)
2444 (string ("substring" s)
2448 (perms '(("temporary" (current-time-string))
2456 (if (eq type 'lower)
2461 (setq header (car headers))
2467 (let ((ts (cdr (assoc (nth 2 header) types)))
2483 'gnus-summary-score-entry
2485 (if (or (string= (nth 1 header)
2487 (string= (nth 1 header)
2490 (list 'gnus-summary-header
2492 (list 'quote (nth 1 (car ts)))
2493 (list 'gnus-score-delta-default
2500 (list (nreverse outp))))
2503 (list (nreverse outt))))
2505 (setq headers (cdr headers)))
2506 (list (nreverse outh))))))))
2510 (defun gnus-summary-mode (&optional group)
2511 "Major mode for reading articles.
2513 All normal editing commands are switched off.
2514 \\<gnus-summary-mode-map>
2515 Each line in this buffer represents one article. To read an
2516 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2517 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2520 You can also post articles and send mail from this buffer. To
2521 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2522 of an article, type `\\[gnus-summary-reply]'.
2524 There are approx. one gazillion commands you can execute in this
2525 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2527 The following commands are available:
2529 \\{gnus-summary-mode-map}"
2531 (kill-all-local-variables)
2532 (when (gnus-visual-p 'summary-menu 'menu)
2533 (gnus-summary-make-menu-bar)
2534 (gnus-summary-make-tool-bar))
2535 (gnus-summary-make-local-variables)
2536 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2537 (gnus-summary-make-local-variables))
2538 (gnus-make-thread-indent-array)
2539 (gnus-simplify-mode-line)
2540 (setq major-mode 'gnus-summary-mode)
2541 (setq mode-name "Summary")
2542 (make-local-variable 'minor-mode-alist)
2543 (use-local-map gnus-summary-mode-map)
2544 (buffer-disable-undo)
2545 (setq buffer-read-only t) ;Disable modification
2546 (setq truncate-lines t)
2547 (setq selective-display t)
2548 (setq selective-display-ellipses t) ;Display `...'
2549 (gnus-summary-set-display-table)
2550 (gnus-set-default-directory)
2551 (setq gnus-newsgroup-name group)
2552 (make-local-variable 'gnus-summary-line-format)
2553 (make-local-variable 'gnus-summary-line-format-spec)
2554 (make-local-variable 'gnus-summary-dummy-line-format)
2555 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2556 (make-local-variable 'gnus-summary-mark-positions)
2557 (make-local-hook 'pre-command-hook)
2558 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2559 (gnus-run-hooks 'gnus-summary-mode-hook)
2560 (turn-on-gnus-mailing-list-mode)
2561 (mm-enable-multibyte)
2562 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2563 (gnus-update-summary-mark-positions))
2565 (defun gnus-summary-make-local-variables ()
2566 "Make all the local summary buffer variables."
2568 (dolist (local gnus-summary-local-variables)
2571 (if (eq (cdr local) 'global)
2572 ;; Copy the global value of the variable.
2573 (setq global (symbol-value (car local)))
2574 ;; Use the value from the list.
2575 (setq global (eval (cdr local))))
2576 (set (make-local-variable (car local)) global))
2577 ;; Simple nil-valued local variable.
2578 (set (make-local-variable local) nil)))))
2580 (defun gnus-summary-clear-local-variables ()
2581 (let ((locals gnus-summary-local-variables))
2583 (if (consp (car locals))
2584 (and (vectorp (caar locals))
2585 (set (caar locals) nil))
2586 (and (vectorp (car locals))
2587 (set (car locals) nil)))
2588 (setq locals (cdr locals)))))
2590 ;; Summary data functions.
2592 (defmacro gnus-data-number (data)
2595 (defmacro gnus-data-set-number (data number)
2596 `(setcar ,data ,number))
2598 (defmacro gnus-data-mark (data)
2601 (defmacro gnus-data-set-mark (data mark)
2602 `(setcar (nthcdr 1 ,data) ,mark))
2604 (defmacro gnus-data-pos (data)
2607 (defmacro gnus-data-set-pos (data pos)
2608 `(setcar (nthcdr 2 ,data) ,pos))
2610 (defmacro gnus-data-header (data)
2613 (defmacro gnus-data-set-header (data header)
2614 `(setf (nth 3 ,data) ,header))
2616 (defmacro gnus-data-level (data)
2619 (defmacro gnus-data-unread-p (data)
2620 `(= (nth 1 ,data) gnus-unread-mark))
2622 (defmacro gnus-data-read-p (data)
2623 `(/= (nth 1 ,data) gnus-unread-mark))
2625 (defmacro gnus-data-pseudo-p (data)
2626 `(consp (nth 3 ,data)))
2628 (defmacro gnus-data-find (number)
2629 `(assq ,number gnus-newsgroup-data))
2631 (defmacro gnus-data-find-list (number &optional data)
2632 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2633 (memq (assq ,number bdata)
2636 (defmacro gnus-data-make (number mark pos header level)
2637 `(list ,number ,mark ,pos ,header ,level))
2639 (defun gnus-data-enter (after-article number mark pos header level offset)
2640 (let ((data (gnus-data-find-list after-article)))
2642 (error "No such article: %d" after-article))
2643 (setcdr data (cons (gnus-data-make number mark pos header level)
2645 (setq gnus-newsgroup-data-reverse nil)
2646 (gnus-data-update-list (cddr data) offset)))
2648 (defun gnus-data-enter-list (after-article list &optional offset)
2650 (let ((data (and after-article (gnus-data-find-list after-article)))
2654 (let ((odata gnus-newsgroup-data))
2655 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2657 (gnus-data-update-list odata offset)))
2658 ;; Find the last element in the list to be spliced into the main
2661 (setq list (cdr list)))
2664 (setcdr list gnus-newsgroup-data)
2665 (setq gnus-newsgroup-data ilist)
2667 (gnus-data-update-list (cdr list) offset)))
2668 (setcdr list (cdr data))
2671 (gnus-data-update-list (cdr list) offset))))
2672 (setq gnus-newsgroup-data-reverse nil))))
2674 (defun gnus-data-remove (article &optional offset)
2675 (let ((data gnus-newsgroup-data))
2676 (if (= (gnus-data-number (car data)) article)
2678 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2679 gnus-newsgroup-data-reverse nil)
2681 (gnus-data-update-list gnus-newsgroup-data offset)))
2683 (when (= (gnus-data-number (cadr data)) article)
2684 (setcdr data (cddr data))
2686 (gnus-data-update-list (cdr data) offset))
2688 gnus-newsgroup-data-reverse nil))
2689 (setq data (cdr data))))))
2691 (defmacro gnus-data-list (backward)
2693 (or gnus-newsgroup-data-reverse
2694 (setq gnus-newsgroup-data-reverse
2695 (reverse gnus-newsgroup-data)))
2696 gnus-newsgroup-data))
2698 (defun gnus-data-update-list (data offset)
2699 "Add OFFSET to the POS of all data entries in DATA."
2700 (setq gnus-newsgroup-data-reverse nil)
2702 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2703 (setq data (cdr data))))
2705 (defun gnus-summary-article-pseudo-p (article)
2706 "Say whether this article is a pseudo article or not."
2707 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2709 (defmacro gnus-summary-article-sparse-p (article)
2710 "Say whether this article is a sparse article or not."
2711 `(memq ,article gnus-newsgroup-sparse))
2713 (defmacro gnus-summary-article-ancient-p (article)
2714 "Say whether this article is a sparse article or not."
2715 `(memq ,article gnus-newsgroup-ancient))
2717 (defun gnus-article-parent-p (number)
2718 "Say whether this article is a parent or not."
2719 (let ((data (gnus-data-find-list number)))
2720 (and (cdr data) ; There has to be an article after...
2721 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2722 (gnus-data-level (nth 1 data))))))
2724 (defun gnus-article-children (number)
2725 "Return a list of all children to NUMBER."
2726 (let* ((data (gnus-data-find-list number))
2727 (level (gnus-data-level (car data)))
2729 (setq data (cdr data))
2731 (= (gnus-data-level (car data)) (1+ level)))
2732 (push (gnus-data-number (car data)) children)
2733 (setq data (cdr data)))
2736 (defmacro gnus-summary-skip-intangible ()
2737 "If the current article is intangible, then jump to a different article."
2738 '(let ((to (get-text-property (point) 'gnus-intangible)))
2739 (and to (gnus-summary-goto-subject to))))
2741 (defmacro gnus-summary-article-intangible-p ()
2742 "Say whether this article is intangible or not."
2743 '(get-text-property (point) 'gnus-intangible))
2745 (defun gnus-article-read-p (article)
2746 "Say whether ARTICLE is read or not."
2747 (not (or (memq article gnus-newsgroup-marked)
2748 (memq article gnus-newsgroup-spam-marked)
2749 (memq article gnus-newsgroup-unreads)
2750 (memq article gnus-newsgroup-unselected)
2751 (memq article gnus-newsgroup-dormant))))
2753 ;; Some summary mode macros.
2755 (defmacro gnus-summary-article-number ()
2756 "The article number of the article on the current line.
2757 If there isn's an article number here, then we return the current
2760 (gnus-summary-skip-intangible)
2761 (or (get-text-property (point) 'gnus-number)
2762 (gnus-summary-last-subject))))
2764 (defmacro gnus-summary-article-header (&optional number)
2765 "Return the header of article NUMBER."
2766 `(gnus-data-header (gnus-data-find
2767 ,(or number '(gnus-summary-article-number)))))
2769 (defmacro gnus-summary-thread-level (&optional number)
2770 "Return the level of thread that starts with article NUMBER."
2771 `(if (and (eq gnus-summary-make-false-root 'dummy)
2772 (get-text-property (point) 'gnus-intangible))
2774 (gnus-data-level (gnus-data-find
2775 ,(or number '(gnus-summary-article-number))))))
2777 (defmacro gnus-summary-article-mark (&optional number)
2778 "Return the mark of article NUMBER."
2779 `(gnus-data-mark (gnus-data-find
2780 ,(or number '(gnus-summary-article-number)))))
2782 (defmacro gnus-summary-article-pos (&optional number)
2783 "Return the position of the line of article NUMBER."
2784 `(gnus-data-pos (gnus-data-find
2785 ,(or number '(gnus-summary-article-number)))))
2787 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2788 (defmacro gnus-summary-article-subject (&optional number)
2789 "Return current subject string or nil if nothing."
2792 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2793 '(gnus-data-header (assq (gnus-summary-article-number)
2794 gnus-newsgroup-data)))))
2797 (mail-header-subject headers))))
2799 (defmacro gnus-summary-article-score (&optional number)
2800 "Return current article score."
2801 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2802 gnus-newsgroup-scored))
2803 gnus-summary-default-score 0))
2805 (defun gnus-summary-article-children (&optional number)
2806 "Return a list of article numbers that are children of article NUMBER."
2807 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2808 (level (gnus-data-level (car data)))
2810 (while (and (setq data (cdr data))
2811 (> (setq l (gnus-data-level (car data))) level))
2812 (and (= (1+ level) l)
2813 (push (gnus-data-number (car data))
2815 (nreverse children)))
2817 (defun gnus-summary-article-parent (&optional number)
2818 "Return the article number of the parent of article NUMBER."
2819 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2820 (gnus-data-list t)))
2821 (level (gnus-data-level (car data))))
2823 () ; This is a root.
2824 ;; We search until we find an article with a level less than
2825 ;; this one. That function has to be the parent.
2826 (while (and (setq data (cdr data))
2827 (not (< (gnus-data-level (car data)) level))))
2828 (and data (gnus-data-number (car data))))))
2830 (defun gnus-unread-mark-p (mark)
2831 "Say whether MARK is the unread mark."
2832 (= mark gnus-unread-mark))
2834 (defun gnus-read-mark-p (mark)
2835 "Say whether MARK is one of the marks that mark as read.
2836 This is all marks except unread, ticked, dormant, and expirable."
2837 (not (or (= mark gnus-unread-mark)
2838 (= mark gnus-ticked-mark)
2839 (= mark gnus-dormant-mark)
2840 (= mark gnus-expirable-mark))))
2842 (defmacro gnus-article-mark (number)
2843 "Return the MARK of article NUMBER.
2844 This macro should only be used when computing the mark the \"first\"
2845 time; i.e., when generating the summary lines. After that,
2846 `gnus-summary-article-mark' should be used to examine the
2849 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2850 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2851 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2852 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2853 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2854 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2855 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2856 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2857 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2858 gnus-ancient-mark))))
2860 ;; Saving hidden threads.
2862 (defmacro gnus-save-hidden-threads (&rest forms)
2863 "Save hidden threads, eval FORMS, and restore the hidden threads."
2864 (let ((config (make-symbol "config")))
2865 `(let ((,config (gnus-hidden-threads-configuration)))
2869 (gnus-restore-hidden-threads-configuration ,config)))))
2870 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2871 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2873 (defun gnus-data-compute-positions ()
2874 "Compute the positions of all articles."
2875 (setq gnus-newsgroup-data-reverse nil)
2876 (let ((data gnus-newsgroup-data))
2878 (gnus-save-hidden-threads
2879 (gnus-summary-show-all-threads)
2880 (goto-char (point-min))
2882 (while (get-text-property (point) 'gnus-intangible)
2884 (gnus-data-set-pos (car data) (+ (point) 3))
2885 (setq data (cdr data))
2886 (forward-line 1))))))
2888 (defun gnus-hidden-threads-configuration ()
2889 "Return the current hidden threads configuration."
2892 (goto-char (point-min))
2893 (while (search-forward "\r" nil t)
2894 (push (1- (point)) config))
2897 (defun gnus-restore-hidden-threads-configuration (config)
2898 "Restore hidden threads configuration from CONFIG."
2900 (let (point buffer-read-only)
2901 (while (setq point (pop config))
2902 (when (and (< point (point-max))
2904 (eq (char-after) ?\n))
2905 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2907 ;; Various summary mode internalish functions.
2909 (defun gnus-mouse-pick-article (e)
2912 (gnus-summary-next-page nil t))
2914 (defun gnus-summary-set-display-table ()
2915 "Change the display table.
2916 Odd characters have a tendency to mess
2917 up nicely formatted displays - we make all possible glyphs
2918 display only a single character."
2920 ;; We start from the standard display table, if any.
2921 (let ((table (or (copy-sequence standard-display-table)
2922 (make-display-table)))
2924 ;; Nix out all the control chars...
2925 (while (>= (setq i (1- i)) 0)
2926 (aset table i [??]))
2927 ;; ... but not newline and cr, of course. (cr is necessary for the
2928 ;; selective display).
2929 (aset table ?\n nil)
2930 (aset table ?\r nil)
2931 ;; We keep TAB as well.
2932 (aset table ?\t nil)
2933 ;; We nix out any glyphs over 126 that are not set already.
2935 (while (>= (setq i (1- i)) 127)
2936 ;; Only modify if the entry is nil.
2937 (unless (aref table i)
2938 (aset table i [??]))))
2939 (setq buffer-display-table table)))
2941 (defun gnus-summary-set-article-display-arrow (pos)
2942 "Update the overlay arrow to point to line at position POS."
2943 (when (and gnus-summary-display-arrow
2944 (boundp 'overlay-arrow-position)
2945 (boundp 'overlay-arrow-string))
2949 (unless overlay-arrow-position
2950 (setq overlay-arrow-position (make-marker)))
2951 (setq overlay-arrow-string "=>"
2952 overlay-arrow-position (set-marker overlay-arrow-position
2954 (current-buffer))))))
2956 (defun gnus-summary-buffer-name (group)
2957 "Return the summary buffer name of GROUP."
2958 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2960 (defun gnus-summary-setup-buffer (group)
2961 "Initialize summary buffer."
2962 (let ((buffer (gnus-summary-buffer-name group))
2963 (dead-name (concat "*Dead Summary "
2964 (gnus-group-decoded-name group) "*")))
2965 ;; If a dead summary buffer exists, we kill it.
2966 (when (gnus-buffer-live-p dead-name)
2967 (gnus-kill-buffer dead-name))
2968 (if (get-buffer buffer)
2971 (setq gnus-summary-buffer (current-buffer))
2972 (not gnus-newsgroup-prepared))
2973 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2974 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2975 (gnus-summary-mode group)
2977 (gnus-carpal-setup-buffer 'summary))
2978 (unless gnus-single-article-buffer
2979 (make-local-variable 'gnus-article-buffer)
2980 (make-local-variable 'gnus-article-current)
2981 (make-local-variable 'gnus-original-article-buffer))
2982 (setq gnus-newsgroup-name group)
2983 ;; Set any local variables in the group parameters.
2984 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2987 (defun gnus-set-global-variables ()
2988 "Set the global equivalents of the buffer-local variables.
2989 They are set to the latest values they had. These reflect the summary
2990 buffer that was in action when the last article was fetched."
2991 (when (eq major-mode 'gnus-summary-mode)
2992 (setq gnus-summary-buffer (current-buffer))
2993 (let ((name gnus-newsgroup-name)
2994 (marked gnus-newsgroup-marked)
2995 (spam gnus-newsgroup-spam-marked)
2996 (unread gnus-newsgroup-unreads)
2997 (headers gnus-current-headers)
2998 (data gnus-newsgroup-data)
2999 (summary gnus-summary-buffer)
3000 (article-buffer gnus-article-buffer)
3001 (original gnus-original-article-buffer)
3002 (gac gnus-article-current)
3003 (reffed gnus-reffed-article-number)
3004 (score-file gnus-current-score-file)
3005 (default-charset gnus-newsgroup-charset)
3007 (let ((locals gnus-newsgroup-variables))
3009 (if (consp (car locals))
3010 (push (eval (caar locals)) vlist)
3011 (push (eval (car locals)) vlist))
3012 (setq locals (cdr locals)))
3013 (setq vlist (nreverse vlist)))
3015 (set-buffer gnus-group-buffer)
3016 (setq gnus-newsgroup-name name
3017 gnus-newsgroup-marked marked
3018 gnus-newsgroup-spam-marked spam
3019 gnus-newsgroup-unreads unread
3020 gnus-current-headers headers
3021 gnus-newsgroup-data data
3022 gnus-article-current gac
3023 gnus-summary-buffer summary
3024 gnus-article-buffer article-buffer
3025 gnus-original-article-buffer original
3026 gnus-reffed-article-number reffed
3027 gnus-current-score-file score-file
3028 gnus-newsgroup-charset default-charset)
3029 (let ((locals gnus-newsgroup-variables))
3031 (if (consp (car locals))
3032 (set (caar locals) (pop vlist))
3033 (set (car locals) (pop vlist)))
3034 (setq locals (cdr locals))))
3035 ;; The article buffer also has local variables.
3036 (when (gnus-buffer-live-p gnus-article-buffer)
3037 (set-buffer gnus-article-buffer)
3038 (setq gnus-summary-buffer summary))))))
3040 (defun gnus-summary-article-unread-p (article)
3041 "Say whether ARTICLE is unread or not."
3042 (memq article gnus-newsgroup-unreads))
3044 (defun gnus-summary-first-article-p (&optional article)
3045 "Return whether ARTICLE is the first article in the buffer."
3046 (if (not (setq article (or article (gnus-summary-article-number))))
3048 (eq article (caar gnus-newsgroup-data))))
3050 (defun gnus-summary-last-article-p (&optional article)
3051 "Return whether ARTICLE is the last article in the buffer."
3052 (if (not (setq article (or article (gnus-summary-article-number))))
3053 ;; All non-existent numbers are the last article. :-)
3055 (not (cdr (gnus-data-find-list article)))))
3057 (defun gnus-make-thread-indent-array ()
3059 (unless (and gnus-thread-indent-array
3060 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3061 (setq gnus-thread-indent-array (make-vector 201 "")
3062 gnus-thread-indent-array-level gnus-thread-indent-level)
3064 (aset gnus-thread-indent-array n
3065 (make-string (* n gnus-thread-indent-level) ? ))
3068 (defun gnus-update-summary-mark-positions ()
3069 "Compute where the summary marks are to go."
3071 (when (gnus-buffer-exists-p gnus-summary-buffer)
3072 (set-buffer gnus-summary-buffer))
3073 (let ((gnus-replied-mark 129)
3074 (gnus-score-below-mark 130)
3075 (gnus-score-over-mark 130)
3076 (gnus-download-mark 131)
3077 (spec gnus-summary-line-format-spec)
3080 (gnus-set-work-buffer)
3081 (let ((gnus-summary-line-format-spec spec)
3082 (gnus-newsgroup-downloadable '((0 . t))))
3083 (gnus-summary-insert-line
3084 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3085 0 nil 128 t nil "" nil 1)
3086 (goto-char (point-min))
3087 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3088 (- (point) (point-min) 1)))))
3089 (goto-char (point-min))
3090 (push (cons 'replied (and (search-forward "\201" nil t)
3091 (- (point) (point-min) 1)))
3093 (goto-char (point-min))
3094 (push (cons 'score (and (search-forward "\202" nil t)
3095 (- (point) (point-min) 1)))
3097 (goto-char (point-min))
3098 (push (cons 'download
3099 (and (search-forward "\203" nil t)
3100 (- (point) (point-min) 1)))
3102 (setq gnus-summary-mark-positions pos))))
3104 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3105 "Insert a dummy root in the summary buffer."
3107 (gnus-add-text-properties
3108 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3109 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3111 (defun gnus-summary-extract-address-component (from)
3112 (or (car (funcall gnus-extract-address-components from))
3115 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3116 (let ((mail-parse-charset gnus-newsgroup-charset)
3117 ; Is it really necessary to do this next part for each summary line?
3118 ; Luckily, doesn't seem to slow things down much.
3119 (mail-parse-ignored-charsets
3120 (save-excursion (set-buffer gnus-summary-buffer)
3121 gnus-newsgroup-ignored-charsets)))
3123 (and gnus-ignored-from-addresses
3124 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3125 (let ((extra-headers (mail-header-extra header))
3129 ((setq to (cdr (assq 'To extra-headers)))
3132 (gnus-summary-extract-address-component
3133 (funcall gnus-decode-encoded-word-function to)))))
3134 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3135 (concat "=> " newsgroups)))))
3136 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3138 (defun gnus-summary-insert-line (gnus-tmp-header
3139 gnus-tmp-level gnus-tmp-current
3140 gnus-tmp-unread gnus-tmp-replied
3141 gnus-tmp-expirable gnus-tmp-subject-or-nil
3142 &optional gnus-tmp-dummy gnus-tmp-score
3144 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3145 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3146 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3147 (gnus-tmp-score-char
3148 (if (or (null gnus-summary-default-score)
3149 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3150 gnus-summary-zcore-fuzz))
3152 (if (< gnus-tmp-score gnus-summary-default-score)
3153 gnus-score-below-mark gnus-score-over-mark)))
3154 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3156 (cond (gnus-tmp-process gnus-process-mark)
3157 ((memq gnus-tmp-current gnus-newsgroup-cached)
3159 (gnus-tmp-replied gnus-replied-mark)
3160 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3161 gnus-forwarded-mark)
3162 ((memq gnus-tmp-current gnus-newsgroup-saved)
3164 ((memq gnus-tmp-number gnus-newsgroup-recent)
3166 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3169 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3172 ((string-match "<[^>]+> *$" gnus-tmp-from)
3173 (let ((beg (match-beginning 0)))
3174 (or (and (string-match "^\".+\"" gnus-tmp-from)
3175 (substring gnus-tmp-from 1 (1- (match-end 0))))
3176 (substring gnus-tmp-from 0 beg))))
3177 ((string-match "(.+)" gnus-tmp-from)
3178 (substring gnus-tmp-from
3179 (1+ (match-beginning 0)) (1- (match-end 0))))
3181 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3182 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3183 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3184 (buffer-read-only nil))
3185 (when (string= gnus-tmp-name "")
3186 (setq gnus-tmp-name gnus-tmp-from))
3187 (unless (numberp gnus-tmp-lines)
3188 (setq gnus-tmp-lines -1))
3189 (if (= gnus-tmp-lines -1)
3190 (setq gnus-tmp-lines "?")
3191 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3192 (gnus-put-text-property
3194 (progn (eval gnus-summary-line-format-spec) (point))
3195 'gnus-number gnus-tmp-number)
3196 (when (gnus-visual-p 'summary-highlight 'highlight)
3198 (gnus-run-hooks 'gnus-summary-update-hook)
3201 (defun gnus-summary-update-line (&optional dont-update)
3202 "Update summary line after change."
3203 (when (and gnus-summary-default-score
3204 (not gnus-summary-inhibit-highlight))
3205 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3206 (article (gnus-summary-article-number))
3207 (score (gnus-summary-article-score article)))
3209 (if (and gnus-summary-mark-below
3210 (< (gnus-summary-article-score)
3211 gnus-summary-mark-below))
3212 ;; This article has a low score, so we mark it as read.
3213 (when (memq article gnus-newsgroup-unreads)
3214 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3215 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3216 ;; This article was previously marked as read on account
3217 ;; of a low score, but now it has risen, so we mark it as
3219 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3220 (gnus-summary-update-mark
3221 (if (or (null gnus-summary-default-score)
3222 (<= (abs (- score gnus-summary-default-score))
3223 gnus-summary-zcore-fuzz))
3225 (if (< score gnus-summary-default-score)
3226 gnus-score-below-mark gnus-score-over-mark))
3228 ;; Do visual highlighting.
3229 (when (gnus-visual-p 'summary-highlight 'highlight)
3230 (gnus-run-hooks 'gnus-summary-update-hook)))))
3232 (defvar gnus-tmp-new-adopts nil)
3234 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3235 "Return the number of articles in THREAD.
3236 This may be 0 in some cases -- if none of the articles in
3237 the thread are to be displayed."
3239 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3241 ((not (listp thread))
3243 ((and (consp thread) (cdr thread))
3246 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3249 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3252 (when (and level (zerop level) gnus-tmp-new-adopts)
3255 'gnus-summary-number-of-articles-in-thread
3256 gnus-tmp-new-adopts))))
3258 (if (> number 1) gnus-not-empty-thread-mark
3259 gnus-empty-thread-mark)
3262 (defsubst gnus-summary-line-message-size (head)
3263 "Return pretty-printed version of message size.
3264 This function is intended to be used in
3265 `gnus-summary-line-format-alist', which see."
3266 (let ((c (or (mail-header-chars head) -1)))
3267 (cond ((< c 0) "n/a") ; chars not available
3268 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3269 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3270 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3271 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3274 (defun gnus-summary-set-local-parameters (group)
3275 "Go through the local params of GROUP and set all variable specs in that list."
3276 (let ((params (gnus-group-find-parameter group))
3277 (vars '(quit-config)) ; Ignore quit-config.
3280 (setq elem (car params)
3281 params (cdr params))
3282 (and (consp elem) ; Has to be a cons.
3283 (consp (cdr elem)) ; The cdr has to be a list.
3284 (symbolp (car elem)) ; Has to be a symbol in there.
3285 (not (memq (car elem) vars))
3286 (ignore-errors ; So we set it.
3287 (push (car elem) vars)
3288 (make-local-variable (car elem))
3289 (set (car elem) (eval (nth 1 elem))))))))
3291 (defun gnus-summary-read-group (group &optional show-all no-article
3292 kill-buffer no-display backward
3294 "Start reading news in newsgroup GROUP.
3295 If SHOW-ALL is non-nil, already read articles are also listed.
3296 If NO-ARTICLE is non-nil, no article is selected initially.
3297 If NO-DISPLAY, don't generate a summary buffer."
3301 (let ((gnus-auto-select-next nil))
3302 (or (gnus-summary-read-group-1
3303 group show-all no-article
3304 kill-buffer no-display
3307 select-articles nil)))))
3308 (eq gnus-auto-select-next 'quietly))
3309 (set-buffer gnus-group-buffer)
3310 ;; The entry function called above goes to the next
3311 ;; group automatically, so we go two groups back
3312 ;; if we are searching for the previous group.
3314 (gnus-group-prev-unread-group 2))
3315 (if (not (equal group (gnus-group-group-name)))
3316 (setq group (gnus-group-group-name))
3320 (defun gnus-summary-read-group-1 (group show-all no-article
3321 kill-buffer no-display
3322 &optional select-articles)
3323 ;; Killed foreign groups can't be entered.
3324 ;; (when (and (not (gnus-group-native-p group))
3325 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3326 ;; (error "Dead non-native groups can't be entered"))
3327 (gnus-message 5 "Retrieving newsgroup: %s..."
3328 (gnus-group-decoded-name group))
3329 (let* ((new-group (gnus-summary-setup-buffer group))
3330 (quit-config (gnus-group-quit-config group))
3331 (did-select (and new-group (gnus-select-newsgroup
3332 group show-all select-articles))))
3334 ;; This summary buffer exists already, so we just select it.
3336 (gnus-set-global-variables)
3338 (gnus-kill-or-deaden-summary kill-buffer))
3339 (gnus-configure-windows 'summary 'force)
3340 (gnus-set-mode-line 'summary)
3341 (gnus-summary-position-point)
3344 ;; We couldn't select this group.
3346 (when (and (eq major-mode 'gnus-summary-mode)
3347 (not (equal (current-buffer) kill-buffer)))
3348 (kill-buffer (current-buffer))
3349 (if (not quit-config)
3351 ;; Update the info -- marks might need to be removed,
3353 (gnus-summary-update-info)
3354 (set-buffer gnus-group-buffer)
3355 (gnus-group-jump-to-group group)
3356 (gnus-group-next-unread-group 1))
3357 (gnus-handle-ephemeral-exit quit-config)))
3358 (let ((grpinfo (gnus-get-info group)))
3359 (if (null (gnus-info-read grpinfo))
3360 (gnus-message 3 "Group %s contains no messages"
3361 (gnus-group-decoded-name group))
3362 (gnus-message 3 "Can't select group")))
3364 ;; The user did a `C-g' while prompting for number of articles,
3365 ;; so we exit this group.
3366 ((eq did-select 'quit)
3367 (and (eq major-mode 'gnus-summary-mode)
3368 (not (equal (current-buffer) kill-buffer))
3369 (kill-buffer (current-buffer)))
3371 (gnus-kill-or-deaden-summary kill-buffer))
3372 (if (not quit-config)
3374 (set-buffer gnus-group-buffer)
3375 (gnus-group-jump-to-group group)
3376 (gnus-group-next-unread-group 1)
3377 (gnus-configure-windows 'group 'force))
3378 (gnus-handle-ephemeral-exit quit-config))
3379 ;; Finally signal the quit.
3381 ;; The group was successfully selected.
3383 (gnus-set-global-variables)
3384 ;; Save the active value in effect when the group was entered.
3385 (setq gnus-newsgroup-active
3387 (gnus-active gnus-newsgroup-name)))
3388 ;; You can change the summary buffer in some way with this hook.
3389 (gnus-run-hooks 'gnus-select-group-hook)
3390 (gnus-update-format-specifications
3391 nil 'summary 'summary-mode 'summary-dummy)
3392 (gnus-update-summary-mark-positions)
3393 ;; Do score processing.
3394 (when gnus-use-scoring
3395 (gnus-possibly-score-headers))
3396 ;; Check whether to fill in the gaps in the threads.
3397 (when gnus-build-sparse-threads
3398 (gnus-build-sparse-threads))
3399 ;; Find the initial limit.
3400 (if gnus-show-threads
3402 (let ((gnus-newsgroup-dormant nil))
3403 (gnus-summary-initial-limit show-all))
3404 (gnus-summary-initial-limit show-all))
3405 ;; When untreaded, all articles are always shown.
3406 (setq gnus-newsgroup-limit
3408 (lambda (header) (mail-header-number header))
3409 gnus-newsgroup-headers)))
3410 ;; Generate the summary buffer.
3412 (gnus-summary-prepare))
3413 (when gnus-use-trees
3414 (gnus-tree-open group)
3415 (setq gnus-summary-highlight-line-function
3416 'gnus-tree-highlight-article))
3417 ;; If the summary buffer is empty, but there are some low-scored
3418 ;; articles or some excluded dormants, we include these in the
3420 (when (and (zerop (buffer-size))
3422 (cond (gnus-newsgroup-dormant
3423 (gnus-summary-limit-include-dormant))
3424 ((and gnus-newsgroup-scored show-all)
3425 (gnus-summary-limit-include-expunged t))))
3426 ;; Function `gnus-apply-kill-file' must be called in this hook.
3427 (gnus-run-hooks 'gnus-apply-kill-hook)
3428 (if (and (zerop (buffer-size))
3431 ;; This newsgroup is empty.
3432 (gnus-summary-catchup-and-exit nil t)
3433 (gnus-message 6 "No unread news")
3435 (gnus-kill-or-deaden-summary kill-buffer))
3436 ;; Return nil from this function.
3438 ;; Hide conversation thread subtrees. We cannot do this in
3439 ;; gnus-summary-prepare-hook since kill processing may not
3440 ;; work with hidden articles.
3441 (gnus-summary-maybe-hide-threads)
3443 (gnus-kill-or-deaden-summary kill-buffer))
3444 (gnus-summary-auto-select-subject)
3445 ;; Show first unread article if requested.
3446 (if (and (not no-article)
3448 gnus-newsgroup-unreads
3449 gnus-auto-select-first)
3451 (gnus-configure-windows 'summary)
3452 (let ((art (gnus-summary-article-number)))
3453 (unless (or (memq art gnus-newsgroup-undownloaded)
3454 (memq art gnus-newsgroup-downloadable))
3455 (gnus-summary-goto-article art))))
3456 ;; Don't select any articles.
3457 (gnus-summary-position-point)
3458 (gnus-configure-windows 'summary 'force)
3459 (gnus-set-mode-line 'summary))
3460 (when (get-buffer-window gnus-group-buffer t)
3461 ;; Gotta use windows, because recenter does weird stuff if
3462 ;; the current buffer ain't the displayed window.
3463 (let ((owin (selected-window)))
3464 (select-window (get-buffer-window gnus-group-buffer t))
3465 (when (gnus-group-goto-group group)
3467 (select-window owin)))
3468 ;; Mark this buffer as "prepared".
3469 (setq gnus-newsgroup-prepared t)
3470 (gnus-run-hooks 'gnus-summary-prepared-hook)
3473 (defun gnus-summary-auto-select-subject ()
3474 "Select the subject line on initial group entry."
3475 (goto-char (point-min))
3477 ((eq gnus-auto-select-subject 'best)
3478 (gnus-summary-best-unread-subject))
3479 ((eq gnus-auto-select-subject 'unread)
3480 (gnus-summary-first-unread-subject))
3481 ((eq gnus-auto-select-subject 'unseen)
3482 (gnus-summary-first-unseen-subject))
3483 ((eq gnus-auto-select-subject 'unseen-or-unread)
3484 (gnus-summary-first-unseen-or-unread-subject))
3485 ((eq gnus-auto-select-subject 'first)
3488 ((gnus-functionp gnus-auto-select-subject)
3489 (funcall gnus-auto-select-subject))))
3491 (defun gnus-summary-prepare ()
3492 "Generate the summary buffer."
3494 (let ((buffer-read-only nil))
3496 (setq gnus-newsgroup-data nil
3497 gnus-newsgroup-data-reverse nil)
3498 (gnus-run-hooks 'gnus-summary-generate-hook)
3499 ;; Generate the buffer, either with threads or without.
3500 (when gnus-newsgroup-headers
3501 (gnus-summary-prepare-threads
3502 (if gnus-show-threads
3503 (gnus-sort-gathered-threads
3504 (funcall gnus-summary-thread-gathering-function
3506 (gnus-cut-threads (gnus-make-threads)))))
3507 ;; Unthreaded display.
3508 (gnus-sort-articles gnus-newsgroup-headers))))
3509 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3510 ;; Call hooks for modifying summary buffer.
3511 (goto-char (point-min))
3512 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3514 (defsubst gnus-general-simplify-subject (subject)
3515 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3518 ;; Truncate the subject.
3519 (gnus-simplify-subject-functions
3520 (gnus-map-function gnus-simplify-subject-functions subject))
3521 ((numberp gnus-summary-gather-subject-limit)
3522 (setq subject (gnus-simplify-subject-re subject))
3523 (if (> (length subject) gnus-summary-gather-subject-limit)
3524 (substring subject 0 gnus-summary-gather-subject-limit)
3526 ;; Fuzzily simplify it.
3527 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3528 (gnus-simplify-subject-fuzzy subject))
3529 ;; Just remove the leading "Re:".
3531 (gnus-simplify-subject-re subject))))
3533 (if (and gnus-summary-gather-exclude-subject
3534 (string-match gnus-summary-gather-exclude-subject subject))
3535 nil ; This article shouldn't be gathered
3538 (defun gnus-summary-simplify-subject-query ()
3539 "Query where the respool algorithm would put this article."
3541 (gnus-summary-select-article)
3542 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3544 (defun gnus-gather-threads-by-subject (threads)
3545 "Gather threads by looking at Subject headers."
3546 (if (not gnus-summary-make-false-root)
3548 (let ((hashtb (gnus-make-hashtable 1024))
3551 subject hthread whole-subject)
3553 (setq subject (gnus-general-simplify-subject
3554 (setq whole-subject (mail-header-subject
3557 (if (setq hthread (gnus-gethash subject hashtb))
3559 ;; We enter a dummy root into the thread, if we
3560 ;; haven't done that already.
3561 (unless (stringp (caar hthread))
3562 (setcar hthread (list whole-subject (car hthread))))
3563 ;; We add this new gathered thread to this gathered
3565 (setcdr (car hthread)
3566 (nconc (cdar hthread) (list (car threads))))
3567 ;; Remove it from the list of threads.
3568 (setcdr prev (cdr threads))
3569 (setq threads prev))
3570 ;; Enter this thread into the hash table.
3571 (gnus-sethash subject threads hashtb)))
3573 (setq threads (cdr threads)))
3576 (defun gnus-gather-threads-by-references (threads)
3577 "Gather threads by looking at References headers."
3578 (let ((idhashtb (gnus-make-hashtable 1024))
3579 (thhashtb (gnus-make-hashtable 1024))
3582 ids references id gthread gid entered ref)
3584 (when (setq references (mail-header-references (caar threads)))
3585 (setq id (mail-header-id (caar threads))
3586 ids (inline (gnus-split-references references))
3588 (while (setq ref (pop ids))
3589 (setq ids (delete ref ids))
3590 (if (not (setq gid (gnus-gethash ref idhashtb)))
3592 (gnus-sethash ref id idhashtb)
3593 (gnus-sethash id threads thhashtb))
3594 (setq gthread (gnus-gethash gid thhashtb))
3596 ;; We enter a dummy root into the thread, if we
3597 ;; haven't done that already.
3598 (unless (stringp (caar gthread))
3599 (setcar gthread (list (mail-header-subject (caar gthread))
3601 ;; We add this new gathered thread to this gathered
3603 (setcdr (car gthread)
3604 (nconc (cdar gthread) (list (car threads)))))
3605 ;; Add it into the thread hash table.
3606 (gnus-sethash id gthread thhashtb)
3608 ;; Remove it from the list of threads.
3609 (setcdr prev (cdr threads))
3610 (setq threads prev))))
3612 (setq threads (cdr threads)))
3615 (defun gnus-sort-gathered-threads (threads)
3616 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3617 (let ((result threads))
3619 (when (stringp (caar threads))
3620 (setcdr (car threads)
3621 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3622 (setq threads (cdr threads)))
3625 (defun gnus-thread-loop-p (root thread)
3626 "Say whether ROOT is in THREAD."
3627 (let ((stack (list thread))
3630 (while (setq thread (pop stack))
3631 (setq th (cdr thread))
3633 (not (eq (caar th) root)))
3636 ;; We have found a loop.
3638 (setcdr thread (delq (car th) (cdr thread)))
3639 (if (boundp (setq ref-dep (intern "none"
3640 gnus-newsgroup-dependencies)))
3641 (setcdr (symbol-value ref-dep)
3642 (nconc (cdr (symbol-value ref-dep))
3644 (set ref-dep (list nil (car th))))
3647 ;; Push all the subthreads onto the stack.
3648 (push (cdr thread) stack)))
3651 (defun gnus-make-threads ()
3652 "Go through the dependency hashtb and find the roots. Return all threads."
3654 (while (catch 'infloop
3657 ;; Deal with self-referencing References loops.
3658 (when (and (car (symbol-value refs))
3665 (car (symbol-value refs)) thread))
3666 (cdr (symbol-value refs)))))))
3669 (unless (car (symbol-value refs))
3670 ;; These threads do not refer back to any other
3671 ;; articles, so they're roots.
3672 (setq threads (append (cdr (symbol-value refs)) threads))))
3673 gnus-newsgroup-dependencies)))
3676 ;; Build the thread tree.
3677 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3678 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3680 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3681 if it was already present.
3683 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3684 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3685 Message-IDs will be renamed to a unique Message-ID before being
3688 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3689 (let* ((id (mail-header-id header))
3690 (id-dep (and id (intern id dependencies)))
3691 parent-id ref ref-dep ref-header replaced)
3692 ;; Enter this `header' in the `dependencies' table.
3696 ;; The first two cases do the normal part: enter a new `header'
3697 ;; in the `dependencies' table.
3698 ((not (boundp id-dep))
3699 (set id-dep (list header)))
3700 ((null (car (symbol-value id-dep)))
3701 (setcar (symbol-value id-dep) header))
3703 ;; From here the `header' was already present in the
3704 ;; `dependencies' table.
3706 ;; Overrides an existing entry;
3707 ;; just set the header part of the entry.
3708 (setcar (symbol-value id-dep) header)
3711 ;; Renames the existing `header' to a unique Message-ID.
3712 ((not gnus-summary-ignore-duplicates)
3713 ;; An article with this Message-ID has already been seen.
3714 ;; We rename the Message-ID.
3715 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3717 (mail-header-set-id header id))
3719 ;; The last case ignores an existing entry, except it adds any
3720 ;; additional Xrefs (in case the two articles came from different
3722 ;; Also sets `header' to `nil' meaning that the `dependencies'
3723 ;; table was *not* modified.
3725 (mail-header-set-xref
3726 (car (symbol-value id-dep))
3727 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3729 (or (mail-header-xref header) "")))
3732 (when (and header (not replaced))
3733 ;; First check that we are not creating a References loop.
3734 (setq parent-id (gnus-parent-id (mail-header-references header)))
3735 (setq ref parent-id)
3737 (setq ref-dep (intern-soft ref dependencies))
3739 (setq ref-header (car (symbol-value ref-dep))))
3740 (if (string= id ref)
3741 ;; Yuk! This is a reference loop. Make the article be a
3744 (mail-header-set-references (car (symbol-value id-dep)) "none")
3746 (setq parent-id nil))
3747 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3748 (setq ref-dep (intern (or parent-id "none") dependencies))
3749 (if (boundp ref-dep)
3750 (setcdr (symbol-value ref-dep)
3751 (nconc (cdr (symbol-value ref-dep))
3752 (list (symbol-value id-dep))))
3753 (set ref-dep (list nil (symbol-value id-dep)))))
3756 (defun gnus-extract-message-id-from-in-reply-to (string)
3757 (if (string-match "<[^>]+>" string)
3758 (substring string (match-beginning 0) (match-end 0))
3761 (defun gnus-build-sparse-threads ()
3762 (let ((headers gnus-newsgroup-headers)
3763 (mail-parse-charset gnus-newsgroup-charset)
3764 (gnus-summary-ignore-duplicates t)
3765 header references generation relations
3766 subject child end new-child date)
3767 ;; First we create an alist of generations/relations, where
3768 ;; generations is how much we trust the relation, and the relation
3770 (gnus-message 7 "Making sparse threads...")
3772 (nnheader-set-temp-buffer " *gnus sparse threads*")
3773 (while (setq header (pop headers))
3774 (when (and (setq references (mail-header-references header))
3775 (not (string= references "")))
3777 (setq child (mail-header-id header)
3778 subject (mail-header-subject header)
3779 date (mail-header-date header)
3781 (while (search-backward ">" nil t)
3782 (setq end (1+ (point)))
3783 (when (search-backward "<" nil t)
3784 (setq new-child (buffer-substring (point) end))
3785 (push (list (incf generation)
3786 child (setq child new-child)
3790 (push (list (1+ generation) child nil subject) relations))
3792 (kill-buffer (current-buffer)))
3793 ;; Sort over trustworthiness.
3796 (when (gnus-dependencies-add-header
3797 (make-full-mail-header
3798 gnus-reffed-article-number
3799 (nth 3 relation) "" (or (nth 4 relation) "")
3801 (or (nth 2 relation) "") 0 0 "")
3802 gnus-newsgroup-dependencies nil)
3803 (push gnus-reffed-article-number gnus-newsgroup-limit)
3804 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3805 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3806 gnus-newsgroup-reads)
3807 (decf gnus-reffed-article-number)))
3808 (sort relations 'car-less-than-car))
3809 (gnus-message 7 "Making sparse threads...done")))
3811 (defun gnus-build-old-threads ()
3812 ;; Look at all the articles that refer back to old articles, and
3813 ;; fetch the headers for the articles that aren't there. This will
3814 ;; build complete threads - if the roots haven't been expired by the
3816 (let ((mail-parse-charset gnus-newsgroup-charset)
3820 (when (not (car (symbol-value refs)))
3821 (setq heads (cdr (symbol-value refs)))
3823 (if (memq (mail-header-number (caar heads))
3824 gnus-newsgroup-dormant)
3825 (setq heads (cdr heads))
3826 (setq id (symbol-name refs))
3827 (while (and (setq id (gnus-build-get-header id))
3828 (not (car (gnus-id-to-thread id)))))
3829 (setq heads nil)))))
3830 gnus-newsgroup-dependencies)))
3832 ;; This function has to be called with point after the article number
3833 ;; on the beginning of the line.
3834 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3835 (let ((eol (gnus-point-at-eol))
3836 (buffer (current-buffer))
3837 header references in-reply-to)
3839 ;; overview: [num subject from date id refs chars lines misc]
3842 (narrow-to-region (point) eol)
3847 (make-full-mail-header
3849 (funcall gnus-decode-encoded-word-function
3850 (nnheader-nov-field)) ; subject
3851 (funcall gnus-decode-encoded-word-function
3852 (nnheader-nov-field)) ; from
3853 (nnheader-nov-field) ; date
3854 (nnheader-nov-read-message-id) ; id
3855 (setq references (nnheader-nov-field)) ; refs
3856 (nnheader-nov-read-integer) ; chars
3857 (nnheader-nov-read-integer) ; lines
3859 (if (looking-at "Xref: ")
3860 (goto-char (match-end 0)))
3861 (nnheader-nov-field)) ; Xref
3862 (nnheader-nov-parse-extra)))) ; extra
3866 (when (and (string= references "")
3867 (setq in-reply-to (mail-header-extra header))
3868 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3869 (mail-header-set-references
3870 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3872 (when gnus-alter-header-function
3873 (funcall gnus-alter-header-function header))
3874 (gnus-dependencies-add-header header dependencies force-new)))
3876 (defun gnus-build-get-header (id)
3877 "Look through the buffer of NOV lines and find the header to ID.
3878 Enter this line into the dependencies hash table, and return
3879 the id of the parent article (if any)."
3880 (let ((deps gnus-newsgroup-dependencies)
3884 (set-buffer nntp-server-buffer)
3885 (let ((case-fold-search nil))
3886 (goto-char (point-min))
3887 (while (and (not found)
3888 (search-forward id nil t))
3890 (setq found (looking-at
3891 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3892 (regexp-quote id))))
3893 (or found (beginning-of-line 2)))
3897 (setq header (gnus-nov-parse-line
3898 (read (current-buffer)) deps))
3899 (gnus-parent-id (mail-header-references header))))))
3901 (let ((number (mail-header-number header)))
3902 (push number gnus-newsgroup-limit)
3903 (push header gnus-newsgroup-headers)
3904 (if (memq number gnus-newsgroup-unselected)
3906 (setq gnus-newsgroup-unreads
3907 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3909 (setq gnus-newsgroup-unselected
3910 (delq number gnus-newsgroup-unselected)))
3911 (push number gnus-newsgroup-ancient)))))))
3913 (defun gnus-build-all-threads ()
3914 "Read all the headers."
3915 (let ((gnus-summary-ignore-duplicates t)
3916 (mail-parse-charset gnus-newsgroup-charset)
3917 (dependencies gnus-newsgroup-dependencies)
3920 (set-buffer nntp-server-buffer)
3921 (let ((case-fold-search nil))
3922 (goto-char (point-min))
3925 (setq article (read (current-buffer))
3926 header (gnus-nov-parse-line article dependencies)))
3929 (set-buffer gnus-summary-buffer)
3930 (push header gnus-newsgroup-headers)
3931 (if (memq (setq article (mail-header-number header))
3932 gnus-newsgroup-unselected)
3934 (setq gnus-newsgroup-unreads
3935 (gnus-add-to-sorted-list
3936 gnus-newsgroup-unreads article))
3937 (setq gnus-newsgroup-unselected
3938 (delq article gnus-newsgroup-unselected)))
3939 (push article gnus-newsgroup-ancient)))
3940 (forward-line 1)))))))
3942 (defun gnus-summary-update-article-line (article header)
3943 "Update the line for ARTICLE using HEADERS."
3944 (let* ((id (mail-header-id header))
3945 (thread (gnus-id-to-thread id)))
3947 (error "Article in no thread"))
3948 ;; Update the thread.
3949 (setcar thread header)
3950 (gnus-summary-goto-subject article)
3951 (let* ((datal (gnus-data-find-list article))
3953 (length (when (cdr datal)
3954 (- (gnus-data-pos data)
3955 (gnus-data-pos (cadr datal)))))
3956 (buffer-read-only nil)
3957 (level (gnus-summary-thread-level)))
3959 (gnus-summary-insert-line
3960 header level nil (gnus-article-mark article)
3961 (memq article gnus-newsgroup-replied)
3962 (memq article gnus-newsgroup-expirable)
3963 ;; Only insert the Subject string when it's different
3964 ;; from the previous Subject string.
3969 (mail-header-subject
3972 (gnus-data-find-list
3974 (gnus-data-list t)))))
3975 ;; Error on the side of excessive subjects.
3977 (mail-header-subject header)))
3979 (mail-header-subject header))
3980 nil (cdr (assq article gnus-newsgroup-scored))
3981 (memq article gnus-newsgroup-processable))
3983 (gnus-data-update-list
3984 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3986 (defun gnus-summary-update-article (article &optional iheader)
3987 "Update ARTICLE in the summary buffer."
3988 (set-buffer gnus-summary-buffer)
3989 (let* ((header (gnus-summary-article-header article))
3990 (id (mail-header-id header))
3991 (data (gnus-data-find article))
3992 (thread (gnus-id-to-thread id))
3993 (references (mail-header-references header))
3997 (when (and references
3998 (not (equal "" references)))
4001 (buffer-read-only nil)
4007 (delq thread parent)))
4008 (if (gnus-summary-insert-subject id header)
4009 ;; Set the (possibly) new article number in the data structure.
4010 (gnus-data-set-number data (gnus-id-to-article id))
4014 (defun gnus-rebuild-thread (id &optional line)
4015 "Rebuild the thread containing ID.
4016 If LINE, insert the rebuilt thread starting on line LINE."
4017 (let ((buffer-read-only nil)
4018 old-pos current thread data)
4019 (if (not gnus-show-threads)
4020 (setq thread (list (car (gnus-id-to-thread id))))
4021 ;; Get the thread this article is part of.
4022 (setq thread (gnus-remove-thread id)))
4023 (setq old-pos (gnus-point-at-bol))
4024 (setq current (save-excursion
4025 (and (re-search-backward "[\r\n]" nil t)
4026 (gnus-summary-article-number))))
4027 ;; If this is a gathered thread, we have to go some re-gathering.
4028 (when (stringp (car thread))
4029 (let ((subject (car thread))
4031 (setq thread (cdr thread))
4033 (unless (memq (setq thr (gnus-id-to-thread
4035 (mail-header-id (caar thread)))))
4038 (setq thread (cdr thread)))
4039 ;; We now have all (unique) roots.
4040 (if (= (length roots) 1)
4041 ;; All the loose roots are now one solid root.
4042 (setq thread (car roots))
4043 (setq thread (cons subject (gnus-sort-threads roots))))))
4045 ;; We then insert this thread into the summary buffer.
4047 (goto-char (point-min))
4048 (forward-line (1- line)))
4049 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4050 (if gnus-show-threads
4051 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4052 (gnus-summary-prepare-unthreaded thread))
4053 (setq data (nreverse gnus-newsgroup-data))
4054 (setq threads gnus-newsgroup-threads))
4055 ;; We splice the new data into the data structure.
4056 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4057 ;;!!! then we want to insert at the beginning of the buffer.
4058 ;;!!! That happens to be true with Gnus now, but that may
4059 ;;!!! change in the future. Perhaps.
4060 (gnus-data-enter-list
4061 (if line nil current) data (- (point) old-pos))
4062 (setq gnus-newsgroup-threads
4063 (nconc threads gnus-newsgroup-threads))
4064 (gnus-data-compute-positions))))
4066 (defun gnus-number-to-header (number)
4067 "Return the header for article NUMBER."
4068 (let ((headers gnus-newsgroup-headers))
4070 (not (= number (mail-header-number (car headers)))))
4075 (defun gnus-parent-headers (in-headers &optional generation)
4076 "Return the headers of the GENERATIONeth parent of HEADERS."
4078 (setq generation 1))
4080 (headers in-headers)
4083 (not (zerop generation))
4084 (setq references (mail-header-references headers)))
4085 (setq headers (if (and references
4086 (setq parent (gnus-parent-id references)))
4087 (car (gnus-id-to-thread parent))
4090 (and (not (eq headers in-headers))
4093 (defun gnus-id-to-thread (id)
4094 "Return the (sub-)thread where ID appears."
4095 (gnus-gethash id gnus-newsgroup-dependencies))
4097 (defun gnus-id-to-article (id)
4098 "Return the article number of ID."
4099 (let ((thread (gnus-id-to-thread id)))
4102 (mail-header-number (car thread)))))
4104 (defun gnus-id-to-header (id)
4105 "Return the article headers of ID."
4106 (car (gnus-id-to-thread id)))
4108 (defun gnus-article-displayed-root-p (article)
4109 "Say whether ARTICLE is a root(ish) article."
4110 (let ((level (gnus-summary-thread-level article))
4111 (refs (mail-header-references (gnus-summary-article-header article)))
4117 ((null (gnus-parent-id refs)) t)
4119 (null (setq particle (gnus-id-to-article
4120 (gnus-parent-id refs))))
4121 (null (gnus-summary-thread-level particle)))))))
4123 (defun gnus-root-id (id)
4124 "Return the id of the root of the thread where ID appears."
4126 (while (and id (setq prev (car (gnus-id-to-thread id))))
4128 id (gnus-parent-id (mail-header-references prev))))
4131 (defun gnus-articles-in-thread (thread)
4132 "Return the list of articles in THREAD."
4133 (cons (mail-header-number (car thread))
4134 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4136 (defun gnus-remove-thread (id &optional dont-remove)
4137 "Remove the thread that has ID in it."
4138 (let (headers thread last-id)
4139 ;; First go up in this thread until we find the root.
4140 (setq last-id (gnus-root-id id)
4141 headers (message-flatten-list (gnus-id-to-thread last-id)))
4142 ;; We have now found the real root of this thread. It might have
4143 ;; been gathered into some loose thread, so we have to search
4144 ;; through the threads to find the thread we wanted.
4145 (let ((threads gnus-newsgroup-threads)
4148 (setq sub (car threads))
4149 (if (stringp (car sub))
4150 ;; This is a gathered thread, so we look at the roots
4151 ;; below it to find whether this article is in this
4154 (setq sub (cdr sub))
4156 (when (member (caar sub) headers)
4157 (setq thread (car threads)
4160 (setq sub (cdr sub))))
4161 ;; It's an ordinary thread, so we check it.
4162 (when (eq (car sub) (car headers))
4165 (setq threads (cdr threads)))
4166 ;; If this article is in no thread, then it's a root.
4169 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4170 (setq thread (gnus-id-to-thread last-id)))
4173 thread ; We return this thread.
4175 (if (stringp (car thread))
4177 ;; If we use dummy roots, then we have to remove the
4178 ;; dummy root as well.
4179 (when (eq gnus-summary-make-false-root 'dummy)
4180 ;; We go to the dummy root by going to
4181 ;; the first sub-"thread", and then one line up.
4182 (gnus-summary-goto-article
4183 (mail-header-number (caadr thread)))
4186 (gnus-data-compute-positions))
4187 (setq thread (cdr thread))
4189 (gnus-remove-thread-1 (car thread))
4190 (setq thread (cdr thread))))
4191 (gnus-remove-thread-1 thread))))))))
4193 (defun gnus-remove-thread-1 (thread)
4194 "Remove the thread THREAD recursively."
4195 (let ((number (mail-header-number (pop thread)))
4197 (setq thread (reverse thread))
4199 (gnus-remove-thread-1 (pop thread)))
4200 (when (setq d (gnus-data-find number))
4201 (goto-char (gnus-data-pos d))
4202 (gnus-summary-show-thread)
4205 (- (gnus-point-at-bol)
4207 (1+ (gnus-point-at-eol))
4208 (gnus-delete-line)))))))
4210 (defun gnus-sort-threads-1 (threads func)
4211 (sort (mapcar (lambda (thread)
4214 (gnus-sort-threads-1 (cdr thread) func))))
4217 (defun gnus-sort-threads (threads)
4219 (if (not gnus-thread-sort-functions)
4221 (gnus-message 8 "Sorting threads...")
4223 (gnus-sort-threads-1
4225 (gnus-make-sort-function gnus-thread-sort-functions))
4226 (gnus-message 8 "Sorting threads...done"))))
4228 (defun gnus-sort-articles (articles)
4230 (when gnus-article-sort-functions
4231 (gnus-message 7 "Sorting articles...")
4233 (setq gnus-newsgroup-headers
4234 (sort articles (gnus-make-sort-function
4235 gnus-article-sort-functions)))
4236 (gnus-message 7 "Sorting articles...done"))))
4238 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4239 (defmacro gnus-thread-header (thread)
4240 "Return header of first article in THREAD.
4241 Note that THREAD must never, ever be anything else than a variable -
4242 using some other form will lead to serious barfage."
4243 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4244 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4245 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4248 (defsubst gnus-article-sort-by-number (h1 h2)
4249 "Sort articles by article number."
4250 (< (mail-header-number h1)
4251 (mail-header-number h2)))
4253 (defun gnus-thread-sort-by-number (h1 h2)
4254 "Sort threads by root article number."
4255 (gnus-article-sort-by-number
4256 (gnus-thread-header h1) (gnus-thread-header h2)))
4258 (defsubst gnus-article-sort-by-random (h1 h2)
4259 "Sort articles by article number."
4262 (defun gnus-thread-sort-by-random (h1 h2)
4263 "Sort threads by root article number."
4264 (gnus-article-sort-by-random
4265 (gnus-thread-header h1) (gnus-thread-header h2)))
4267 (defsubst gnus-article-sort-by-lines (h1 h2)
4268 "Sort articles by article Lines header."
4269 (< (mail-header-lines h1)
4270 (mail-header-lines h2)))
4272 (defun gnus-thread-sort-by-lines (h1 h2)
4273 "Sort threads by root article Lines header."
4274 (gnus-article-sort-by-lines
4275 (gnus-thread-header h1) (gnus-thread-header h2)))
4277 (defsubst gnus-article-sort-by-chars (h1 h2)
4278 "Sort articles by octet length."
4279 (< (mail-header-chars h1)
4280 (mail-header-chars h2)))
4282 (defun gnus-thread-sort-by-chars (h1 h2)
4283 "Sort threads by root article octet length."
4284 (gnus-article-sort-by-chars
4285 (gnus-thread-header h1) (gnus-thread-header h2)))
4287 (defsubst gnus-article-sort-by-author (h1 h2)
4288 "Sort articles by root author."
4290 (let ((extract (funcall
4291 gnus-extract-address-components
4292 (mail-header-from h1))))
4293 (or (car extract) (cadr extract) ""))
4294 (let ((extract (funcall
4295 gnus-extract-address-components
4296 (mail-header-from h2))))
4297 (or (car extract) (cadr extract) ""))))
4299 (defun gnus-thread-sort-by-author (h1 h2)
4300 "Sort threads by root author."
4301 (gnus-article-sort-by-author
4302 (gnus-thread-header h1) (gnus-thread-header h2)))
4304 (defsubst gnus-article-sort-by-subject (h1 h2)
4305 "Sort articles by root subject."
4307 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4308 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4310 (defun gnus-thread-sort-by-subject (h1 h2)
4311 "Sort threads by root subject."
4312 (gnus-article-sort-by-subject
4313 (gnus-thread-header h1) (gnus-thread-header h2)))
4315 (defsubst gnus-article-sort-by-date (h1 h2)
4316 "Sort articles by root article date."
4318 (gnus-date-get-time (mail-header-date h1))
4319 (gnus-date-get-time (mail-header-date h2))))
4321 (defun gnus-thread-sort-by-date (h1 h2)
4322 "Sort threads by root article date."
4323 (gnus-article-sort-by-date
4324 (gnus-thread-header h1) (gnus-thread-header h2)))
4326 (defsubst gnus-article-sort-by-score (h1 h2)
4327 "Sort articles by root article score.
4328 Unscored articles will be counted as having a score of zero."
4329 (> (or (cdr (assq (mail-header-number h1)
4330 gnus-newsgroup-scored))
4331 gnus-summary-default-score 0)
4332 (or (cdr (assq (mail-header-number h2)
4333 gnus-newsgroup-scored))
4334 gnus-summary-default-score 0)))
4336 (defun gnus-thread-sort-by-score (h1 h2)
4337 "Sort threads by root article score."
4338 (gnus-article-sort-by-score
4339 (gnus-thread-header h1) (gnus-thread-header h2)))
4341 (defun gnus-thread-sort-by-total-score (h1 h2)
4342 "Sort threads by the sum of all scores in the thread.
4343 Unscored articles will be counted as having a score of zero."
4344 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4346 (defun gnus-thread-total-score (thread)
4347 ;; This function find the total score of THREAD.
4352 (if (stringp (car thread))
4353 (apply gnus-thread-score-function 0
4354 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4355 (gnus-thread-total-score-1 thread)))
4357 (gnus-thread-total-score-1 (list thread)))))
4359 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4360 "Sort threads such that the thread with the most recently arrived article comes first."
4361 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4363 (defun gnus-thread-highest-number (thread)
4364 "Return the highest article number in THREAD."
4365 (apply 'max (mapcar (lambda (header)
4366 (mail-header-number header))
4367 (message-flatten-list thread))))
4369 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4370 "Sort threads such that the thread with the most recently dated article comes first."
4371 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4373 (defun gnus-thread-latest-date (thread)
4374 "Return the highest article date in THREAD."
4375 (let ((previous-time 0))
4380 (mail-header-parse-date
4382 (mail-header-date header)
4383 (error previous-time))))))
4385 (message-flatten-list thread)
4387 (< (mail-header-number h1)
4388 (mail-header-number h2))))))))
4390 (defun gnus-thread-total-score-1 (root)
4391 ;; This function find the total score of the thread below ROOT.
4392 (setq root (car root))
4393 (apply gnus-thread-score-function
4395 (mapcar 'gnus-thread-total-score
4396 (cdr (gnus-id-to-thread (mail-header-id root))))
4397 (when (> (mail-header-number root) 0)
4398 (list (or (cdr (assq (mail-header-number root)
4399 gnus-newsgroup-scored))
4400 gnus-summary-default-score 0))))
4401 (list gnus-summary-default-score)
4404 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4405 (defvar gnus-tmp-prev-subject nil)
4406 (defvar gnus-tmp-false-parent nil)
4407 (defvar gnus-tmp-root-expunged nil)
4408 (defvar gnus-tmp-dummy-line nil)
4410 (eval-when-compile (defvar gnus-tmp-header))
4411 (defun gnus-extra-header (type &optional header)
4412 "Return the extra header of TYPE."
4413 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4416 (defvar gnus-tmp-thread-tree-header-string "")
4418 (defcustom gnus-sum-thread-tree-root "> "
4419 "With %B spec, used for the root of a thread.
4420 If nil, use subject instead."
4422 :group 'gnus-thread)
4423 (defcustom gnus-sum-thread-tree-single-indent ""
4424 "With %B spec, used for a thread with just one message.
4425 If nil, use subject instead."
4427 :group 'gnus-thread)
4428 (defcustom gnus-sum-thread-tree-vertical "| "
4429 "With %B spec, used for drawing a vertical line."
4431 :group 'gnus-thread)
4432 (defcustom gnus-sum-thread-tree-indent " "
4433 "With %B spec, used for indenting."
4435 :group 'gnus-thread)
4436 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4437 "With %B spec, used for a leaf with brothers."
4439 :group 'gnus-thread)
4440 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4441 "With %B spec, used for a leaf without brothers."
4443 :group 'gnus-thread)
4445 (defun gnus-summary-prepare-threads (threads)
4446 "Prepare summary buffer from THREADS and indentation LEVEL.
4447 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4448 or a straight list of headers."
4449 (gnus-message 7 "Generating summary...")
4451 (setq gnus-newsgroup-threads threads)
4454 (let ((gnus-tmp-level 0)
4455 (default-score (or gnus-summary-default-score 0))
4456 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4457 thread number subject stack state gnus-tmp-gathered beg-match
4458 new-roots gnus-tmp-new-adopts thread-end simp-subject
4459 gnus-tmp-header gnus-tmp-unread
4460 gnus-tmp-replied gnus-tmp-subject-or-nil
4461 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4462 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4463 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4466 (setq gnus-tmp-prev-subject nil)
4468 (if (vectorp (car threads))
4469 ;; If this is a straight (sic) list of headers, then a
4470 ;; threaded summary display isn't required, so we just create
4471 ;; an unthreaded one.
4472 (gnus-summary-prepare-unthreaded threads)
4474 ;; Do the threaded display.
4476 (while (or threads stack gnus-tmp-new-adopts new-roots)
4478 (if (and (= gnus-tmp-level 0)
4481 (not gnus-tmp-false-parent)
4482 (or gnus-tmp-new-adopts new-roots))
4483 (if gnus-tmp-new-adopts
4484 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4485 thread (list (car gnus-tmp-new-adopts))
4486 gnus-tmp-header (caar thread)
4487 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4489 (setq thread (list (car new-roots))
4490 gnus-tmp-header (caar thread)
4491 new-roots (cdr new-roots))))
4494 ;; If there are some threads, we do them before the
4495 ;; threads on the stack.
4496 (setq thread threads
4497 gnus-tmp-header (caar thread))
4498 ;; There were no current threads, so we pop something off
4500 (setq state (car stack)
4501 gnus-tmp-level (car state)
4502 tree-stack (cadr state)
4503 thread (caddr state)
4505 gnus-tmp-header (caar thread))))
4507 (setq gnus-tmp-false-parent nil)
4508 (setq gnus-tmp-root-expunged nil)
4509 (setq thread-end nil)
4511 (if (stringp gnus-tmp-header)
4512 ;; The header is a dummy root.
4514 ((eq gnus-summary-make-false-root 'adopt)
4515 ;; We let the first article adopt the rest.
4516 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4518 (setq gnus-tmp-gathered
4520 (lambda (h) (mail-header-number (car h)))
4523 (setq thread (cons (list (caar thread)
4526 (setq gnus-tmp-level -1
4527 gnus-tmp-false-parent t))
4528 ((eq gnus-summary-make-false-root 'empty)
4529 ;; We print adopted articles with empty subject fields.
4530 (setq gnus-tmp-gathered
4532 (lambda (h) (mail-header-number (car h)))
4535 (setq gnus-tmp-level -1))
4536 ((eq gnus-summary-make-false-root 'dummy)
4537 ;; We remember that we probably want to output a dummy
4539 (setq gnus-tmp-dummy-line gnus-tmp-header)
4540 (setq gnus-tmp-prev-subject gnus-tmp-header))
4542 ;; We do not make a root for the gathered
4543 ;; sub-threads at all.
4544 (setq gnus-tmp-level -1)))
4546 (setq number (mail-header-number gnus-tmp-header)
4547 subject (mail-header-subject gnus-tmp-header)
4548 simp-subject (gnus-simplify-subject-fully subject))
4551 ;; If the thread has changed subject, we might want to make
4552 ;; this subthread into a root.
4553 ((and (null gnus-thread-ignore-subject)
4554 (not (zerop gnus-tmp-level))
4555 gnus-tmp-prev-subject
4556 (not (string= gnus-tmp-prev-subject simp-subject)))
4557 (setq new-roots (nconc new-roots (list (car thread)))
4559 gnus-tmp-header nil))
4560 ;; If the article lies outside the current limit,
4561 ;; then we do not display it.
4562 ((not (memq number gnus-newsgroup-limit))
4563 (setq gnus-tmp-gathered
4565 (lambda (h) (mail-header-number (car h)))
4568 (setq gnus-tmp-new-adopts (if (cdar thread)
4569 (append gnus-tmp-new-adopts
4571 gnus-tmp-new-adopts)
4573 gnus-tmp-header nil)
4574 (when (zerop gnus-tmp-level)
4575 (setq gnus-tmp-root-expunged t)))
4576 ;; Perhaps this article is to be marked as read?
4577 ((and gnus-summary-mark-below
4578 (< (or (cdr (assq number gnus-newsgroup-scored))
4580 gnus-summary-mark-below)
4581 ;; Don't touch sparse articles.
4582 (not (gnus-summary-article-sparse-p number))
4583 (not (gnus-summary-article-ancient-p number)))
4584 (setq gnus-newsgroup-unreads
4585 (delq number gnus-newsgroup-unreads))
4586 (if gnus-newsgroup-auto-expire
4587 (setq gnus-newsgroup-expirable
4588 (gnus-add-to-sorted-list
4589 gnus-newsgroup-expirable number))
4590 (push (cons number gnus-low-score-mark)
4591 gnus-newsgroup-reads))))
4593 (when gnus-tmp-header
4594 ;; We may have an old dummy line to output before this
4596 (when (and gnus-tmp-dummy-line
4599 (mail-header-subject gnus-tmp-header)))
4600 (gnus-summary-insert-dummy-line
4601 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4602 (setq gnus-tmp-dummy-line nil))
4604 ;; Compute the mark.
4605 (setq gnus-tmp-unread (gnus-article-mark number))
4607 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4608 gnus-tmp-header gnus-tmp-level)
4609 gnus-newsgroup-data)
4611 ;; Actually insert the line.
4613 gnus-tmp-subject-or-nil
4615 ((and gnus-thread-ignore-subject
4616 gnus-tmp-prev-subject
4617 (not (string= gnus-tmp-prev-subject simp-subject)))
4619 ((zerop gnus-tmp-level)
4620 (if (and (eq gnus-summary-make-false-root 'empty)
4621 (memq number gnus-tmp-gathered)
4622 gnus-tmp-prev-subject
4623 (string= gnus-tmp-prev-subject simp-subject))
4624 gnus-summary-same-subject
4626 (t gnus-summary-same-subject)))
4627 (if (and (eq gnus-summary-make-false-root 'adopt)
4628 (= gnus-tmp-level 1)
4629 (memq number gnus-tmp-gathered))
4630 (setq gnus-tmp-opening-bracket ?\<
4631 gnus-tmp-closing-bracket ?\>)
4632 (setq gnus-tmp-opening-bracket ?\[
4633 gnus-tmp-closing-bracket ?\]))
4635 gnus-tmp-indentation
4636 (aref gnus-thread-indent-array gnus-tmp-level)
4637 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4638 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4639 gnus-summary-default-score 0)
4641 (if (or (null gnus-summary-default-score)
4642 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4643 gnus-summary-zcore-fuzz))
4645 (if (< gnus-tmp-score gnus-summary-default-score)
4646 gnus-score-below-mark gnus-score-over-mark))
4648 (cond ((memq number gnus-newsgroup-processable)
4650 ((memq number gnus-newsgroup-cached)
4652 ((memq number gnus-newsgroup-replied)
4654 ((memq number gnus-newsgroup-forwarded)
4655 gnus-forwarded-mark)
4656 ((memq number gnus-newsgroup-saved)
4658 ((memq number gnus-newsgroup-recent)
4660 ((memq number gnus-newsgroup-unseen)
4663 gnus-tmp-from (mail-header-from gnus-tmp-header)
4666 ((string-match "<[^>]+> *$" gnus-tmp-from)
4667 (setq beg-match (match-beginning 0))
4668 (or (and (string-match "^\".+\"" gnus-tmp-from)
4669 (substring gnus-tmp-from 1 (1- (match-end 0))))
4670 (substring gnus-tmp-from 0 beg-match)))
4671 ((string-match "(.+)" gnus-tmp-from)
4672 (substring gnus-tmp-from
4673 (1+ (match-beginning 0)) (1- (match-end 0))))
4675 gnus-tmp-thread-tree-header-string
4677 ((not gnus-show-threads) "")
4678 ((zerop gnus-tmp-level)
4680 (or gnus-sum-thread-tree-root subject)
4681 (or gnus-sum-thread-tree-single-indent subject)))
4683 (concat (apply 'concat
4684 (mapcar (lambda (item)
4686 gnus-sum-thread-tree-vertical
4687 gnus-sum-thread-tree-indent))
4688 (cdr (reverse tree-stack))))
4690 gnus-sum-thread-tree-leaf-with-other
4691 gnus-sum-thread-tree-single-leaf)))))
4692 (when (string= gnus-tmp-name "")
4693 (setq gnus-tmp-name gnus-tmp-from))
4694 (unless (numberp gnus-tmp-lines)
4695 (setq gnus-tmp-lines -1))
4696 (if (= gnus-tmp-lines -1)
4697 (setq gnus-tmp-lines "?")
4698 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4699 (gnus-put-text-property
4701 (progn (eval gnus-summary-line-format-spec) (point))
4702 'gnus-number number)
4705 (gnus-run-hooks 'gnus-summary-update-hook)
4708 (setq gnus-tmp-prev-subject simp-subject)))
4710 (when (nth 1 thread)
4711 (push (list (max 0 gnus-tmp-level)
4712 (copy-list tree-stack)
4715 (push (if (nth 1 thread) 1 0) tree-stack)
4716 (incf gnus-tmp-level)
4717 (setq threads (if thread-end nil (cdar thread)))
4719 (setq gnus-tmp-level 0)))))
4720 (gnus-message 7 "Generating summary...done"))
4722 (defun gnus-summary-prepare-unthreaded (headers)
4723 "Generate an unthreaded summary buffer based on HEADERS."
4724 (let (header number mark)
4729 ;; We may have to root out some bad articles...
4730 (when (memq (setq number (mail-header-number
4731 (setq header (pop headers))))
4732 gnus-newsgroup-limit)
4733 ;; Mark article as read when it has a low score.
4734 (when (and gnus-summary-mark-below
4735 (< (or (cdr (assq number gnus-newsgroup-scored))
4736 gnus-summary-default-score 0)
4737 gnus-summary-mark-below)
4738 (not (gnus-summary-article-ancient-p number)))
4739 (setq gnus-newsgroup-unreads
4740 (delq number gnus-newsgroup-unreads))
4741 (if gnus-newsgroup-auto-expire
4742 (push number gnus-newsgroup-expirable)
4743 (push (cons number gnus-low-score-mark)
4744 gnus-newsgroup-reads)))
4746 (setq mark (gnus-article-mark number))
4747 (push (gnus-data-make number mark (1+ (point)) header 0)
4748 gnus-newsgroup-data)
4749 (gnus-summary-insert-line
4751 mark (memq number gnus-newsgroup-replied)
4752 (memq number gnus-newsgroup-expirable)
4753 (mail-header-subject header) nil
4754 (cdr (assq number gnus-newsgroup-scored))
4755 (memq number gnus-newsgroup-processable))))))
4757 (defun gnus-summary-remove-list-identifiers ()
4758 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4759 (let ((regexp (if (consp gnus-list-identifiers)
4760 (mapconcat 'identity gnus-list-identifiers " *\\|")
4761 gnus-list-identifiers))
4764 (dolist (header gnus-newsgroup-headers)
4765 (setq subject (mail-header-subject header)
4767 (while (string-match
4768 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4771 (concat (substring subject 0 (match-beginning 2))
4772 (substring subject (match-end 0)))
4776 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4778 (concat (substring subject 0 (match-beginning 1))
4779 (substring subject (match-end 1)))))
4781 (mail-header-set-subject header subject))))))
4783 (defun gnus-fetch-headers (articles)
4784 "Fetch headers of ARTICLES."
4785 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4786 (gnus-message 5 "Fetching headers for %s..." name)
4789 (setq gnus-headers-retrieved-by
4790 (gnus-retrieve-headers
4791 articles gnus-newsgroup-name
4792 ;; We might want to fetch old headers, but
4793 ;; not if there is only 1 article.
4795 (not (eq gnus-fetch-old-headers 'some))
4796 (not (numberp gnus-fetch-old-headers)))
4797 (> (length articles) 1))
4798 gnus-fetch-old-headers))))
4799 (gnus-get-newsgroup-headers-xover
4800 articles nil nil gnus-newsgroup-name t)
4801 (gnus-get-newsgroup-headers))
4802 (gnus-message 5 "Fetching headers for %s...done" name))))
4804 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4805 "Select newsgroup GROUP.
4806 If READ-ALL is non-nil, all articles in the group are selected.
4807 If SELECT-ARTICLES, only select those articles from GROUP."
4808 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4809 ;;!!! Dirty hack; should be removed.
4810 (gnus-summary-ignore-duplicates
4811 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4813 gnus-summary-ignore-duplicates))
4814 (info (nth 2 entry))
4815 articles fetched-articles cached)
4817 (unless (gnus-check-server
4818 (set (make-local-variable 'gnus-current-select-method)
4819 (gnus-find-method-for-group group)))
4820 (error "Couldn't open server"))
4822 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4823 (gnus-activate-group group) ; Or we can activate it...
4824 (progn ; Or we bug out.
4825 (when (equal major-mode 'gnus-summary-mode)
4826 (kill-buffer (current-buffer)))
4827 (error "Couldn't activate group %s: %s"
4828 group (gnus-status-message group))))
4830 (unless (gnus-request-group group t)
4831 (when (equal major-mode 'gnus-summary-mode)
4832 (kill-buffer (current-buffer)))
4833 (error "Couldn't request group %s: %s"
4834 group (gnus-status-message group)))
4836 (setq gnus-newsgroup-name group
4837 gnus-newsgroup-unselected nil
4838 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4840 (let ((display (gnus-group-find-parameter group 'display)))
4841 (setq gnus-newsgroup-display
4843 ((not (zerop (or (car-safe read-all) 0)))
4844 ;; The user entered the group with C-u SPC/RET, let's show
4850 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4852 ;; The following is probably the "correct" solution, but
4853 ;; it makes Gnus fetch all headers and then limit the
4854 ;; articles (which is slow), so instead we hack the
4855 ;; select-articles parameter instead. -- Simon Josefsson
4858 ;; (gnus-byte-compile
4859 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4861 (setq select-articles
4862 (gnus-uncompress-range
4863 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4867 (cdr (gnus-active group)))))
4872 (gnus-summary-setup-default-charset)
4874 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4875 (when (gnus-virtual-group-p group)
4876 (setq cached gnus-newsgroup-cached))
4878 (setq gnus-newsgroup-unreads
4879 (gnus-sorted-ndifference
4880 (gnus-sorted-ndifference gnus-newsgroup-unreads
4881 gnus-newsgroup-marked)
4882 gnus-newsgroup-dormant))
4884 (setq gnus-newsgroup-processable nil)
4886 (gnus-update-read-articles group gnus-newsgroup-unreads)
4888 ;; Adjust and set lists of article marks.
4890 (gnus-adjust-marked-articles info))
4892 (if (setq articles select-articles)
4893 (setq gnus-newsgroup-unselected
4894 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4895 (setq articles (gnus-articles-to-read group read-all)))
4899 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4901 ((eq articles 0) nil)
4903 ;; Init the dependencies hash table.
4904 (setq gnus-newsgroup-dependencies
4905 (gnus-make-hashtable (length articles)))
4906 (gnus-set-global-variables)
4907 ;; Retrieve the headers and read them in.
4908 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4910 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4912 (setq gnus-newsgroup-cached cached))
4914 ;; Suppress duplicates?
4915 (when gnus-suppress-duplicates
4916 (gnus-dup-suppress-articles))
4918 ;; Set the initial limit.
4919 (setq gnus-newsgroup-limit (copy-sequence articles))
4920 ;; Remove canceled articles from the list of unread articles.
4921 (setq fetched-articles
4922 (mapcar (lambda (headers) (mail-header-number headers))
4923 gnus-newsgroup-headers))
4924 (setq gnus-newsgroup-articles fetched-articles)
4925 (setq gnus-newsgroup-unreads
4926 (gnus-sorted-nintersection
4927 gnus-newsgroup-unreads fetched-articles))
4928 (gnus-compute-unseen-list)
4930 ;; Removed marked articles that do not exist.
4931 (gnus-update-missing-marks
4932 (gnus-sorted-difference articles fetched-articles))
4933 ;; We might want to build some more threads first.
4934 (when (and gnus-fetch-old-headers
4935 (eq gnus-headers-retrieved-by 'nov))
4936 (if (eq gnus-fetch-old-headers 'invisible)
4937 (gnus-build-all-threads)
4938 (gnus-build-old-threads)))
4939 ;; Let the Gnus agent mark articles as read.
4941 (gnus-agent-get-undownloaded-list))
4942 ;; Remove list identifiers from subject
4943 (when gnus-list-identifiers
4944 (gnus-summary-remove-list-identifiers))
4945 ;; Check whether auto-expire is to be done in this group.
4946 (setq gnus-newsgroup-auto-expire
4947 (gnus-group-auto-expirable-p group))
4948 ;; Set up the article buffer now, if necessary.
4949 (unless gnus-single-article-buffer
4950 (gnus-article-setup-buffer))
4951 ;; First and last article in this newsgroup.
4952 (when gnus-newsgroup-headers
4953 (setq gnus-newsgroup-begin
4954 (mail-header-number (car gnus-newsgroup-headers))
4957 (gnus-last-element gnus-newsgroup-headers))))
4958 ;; GROUP is successfully selected.
4959 (or gnus-newsgroup-headers t)))))
4961 (defun gnus-compute-unseen-list ()
4962 ;; The `seen' marks are treated specially.
4963 (if (not gnus-newsgroup-seen)
4964 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4965 (setq gnus-newsgroup-unseen
4966 (gnus-inverse-list-range-intersection
4967 gnus-newsgroup-articles gnus-newsgroup-seen))))
4969 (defun gnus-summary-display-make-predicate (display)
4970 (require 'gnus-agent)
4971 (when (= (length display) 1)
4972 (setq display (car display)))
4973 (unless gnus-summary-display-cache
4974 (dolist (elem (append '((unread . unread)
4977 gnus-article-mark-lists))
4978 (push (cons (cdr elem)
4980 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4981 gnus-summary-display-cache)))
4982 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
4983 (gnus-category-predicate-cache gnus-summary-display-cache))
4984 (gnus-get-predicate display)))
4986 ;; Uses the dynamically bound `number' variable.
4988 (defun gnus-article-marked-p (type &optional article)
4989 (let ((article (or article number)))
4992 (memq article gnus-newsgroup-marked))
4994 (memq article gnus-newsgroup-spam-marked))
4996 (memq article gnus-newsgroup-unsendable))
4997 ((eq type 'undownload)
4998 (memq article gnus-newsgroup-undownloaded))
4999 ((eq type 'download)
5000 (memq article gnus-newsgroup-downloadable))
5002 (memq article gnus-newsgroup-unreads))
5004 (memq article gnus-newsgroup-reads))
5006 (memq article gnus-newsgroup-dormant) )
5008 (memq article gnus-newsgroup-expirable))
5010 (memq article gnus-newsgroup-replied))
5012 (memq article gnus-newsgroup-killed))
5013 ((eq type 'bookmark)
5014 (assq article gnus-newsgroup-bookmarks))
5016 (assq article gnus-newsgroup-scored))
5018 (memq article gnus-newsgroup-saved))
5020 (memq article gnus-newsgroup-cached))
5022 (memq article gnus-newsgroup-forwarded))
5024 (not (memq article gnus-newsgroup-unseen)))
5026 (memq article gnus-newsgroup-recent))
5029 (defun gnus-articles-to-read (group &optional read-all)
5030 "Find out what articles the user wants to read."
5032 ;; Select all articles if `read-all' is non-nil, or if there
5033 ;; are no unread articles.
5035 (and (zerop (length gnus-newsgroup-marked))
5036 (zerop (length gnus-newsgroup-unreads)))
5037 ;; Fetch all if the predicate is non-nil.
5038 gnus-newsgroup-display)
5039 ;; We want to select the headers for all the articles in
5040 ;; the group, so we select either all the active
5041 ;; articles in the group, or (if that's nil), the
5042 ;; articles in the cache.
5044 (gnus-uncompress-range (gnus-active group))
5045 (gnus-cache-articles-in-group group))
5046 ;; Select only the "normal" subset of articles.
5048 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5049 gnus-newsgroup-unreads)))
5050 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5051 (scored (length scored-list))
5052 (number (length articles))
5053 (marked (+ (length gnus-newsgroup-marked)
5054 (length gnus-newsgroup-dormant)))
5059 ((numberp gnus-newsgroup-display)
5060 gnus-newsgroup-display)
5064 ((and (or (<= scored marked) (= scored number))
5065 (numberp gnus-large-newsgroup)
5066 (> number gnus-large-newsgroup))
5067 (let* ((cursor-in-echo-area nil)
5068 (initial (gnus-parameter-large-newsgroup-initial
5069 gnus-newsgroup-name))
5073 "How many articles from %s (%s %d): "
5075 (gnus-group-decoded-name gnus-newsgroup-name)
5077 (if initial "max" "default")
5080 (cons (number-to-string initial)
5082 (if (string-match "^[ \t]*$" input) number input)))
5083 ((and (> scored marked) (< scored number)
5084 (> (- scored number) 20))
5087 (format "%s %s (%d scored, %d total): "
5088 "How many articles from"
5089 (gnus-group-decoded-name group)
5091 (if (string-match "^[ \t]*$" input)
5095 (message "Quit getting the articles to read")
5097 (setq select (if (stringp select) (string-to-number select) select))
5098 (if (or (null select) (zerop select))
5100 (if (and (not (zerop scored)) (<= (abs select) scored))
5102 (setq articles (sort scored-list '<))
5103 (setq number (length articles)))
5104 (setq articles (copy-sequence articles)))
5106 (when (< (abs select) number)
5108 ;; Select the N oldest articles.
5109 (setcdr (nthcdr (1- (abs select)) articles) nil)
5110 ;; Select the N most recent articles.
5111 (setq articles (nthcdr (- number select) articles))))
5112 (setq gnus-newsgroup-unselected
5113 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5114 (when gnus-alter-articles-to-read-function
5115 (setq gnus-newsgroup-unreads
5117 (funcall gnus-alter-articles-to-read-function
5118 gnus-newsgroup-name gnus-newsgroup-unreads)
5122 (defun gnus-killed-articles (killed articles)
5125 (when (inline (gnus-member-of-range (car articles) killed))
5126 (push (car articles) out))
5127 (setq articles (cdr articles)))
5130 (defun gnus-uncompress-marks (marks)
5131 "Uncompress the mark ranges in MARKS."
5132 (let ((uncompressed '(score bookmark))
5135 (if (memq (caar marks) uncompressed)
5136 (push (car marks) out)
5137 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5138 (setq marks (cdr marks)))
5141 (defun gnus-article-mark-to-type (mark)
5142 "Return the type of MARK."
5143 (or (cadr (assq mark gnus-article-special-mark-lists))
5146 (defun gnus-article-unpropagatable-p (mark)
5147 "Return whether MARK should be propagated to backend."
5148 (memq mark gnus-article-unpropagated-mark-lists))
5150 (defun gnus-adjust-marked-articles (info)
5151 "Set all article lists and remove all marks that are no longer valid."
5152 (let* ((marked-lists (gnus-info-marks info))
5153 (active (gnus-active (gnus-info-group info)))
5156 (types gnus-article-mark-lists)
5157 marks var articles article mark mark-type)
5159 (dolist (marks marked-lists)
5160 (setq mark (car marks)
5161 mark-type (gnus-article-mark-to-type mark)
5162 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5164 ;; We set the variable according to the type of the marks list,
5165 ;; and then adjust the marks to a subset of the active articles.
5167 ;; Adjust "simple" lists.
5168 ((eq mark-type 'list)
5169 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5170 (when (memq mark '(tick dormant expire reply save))
5172 (when (or (< (setq article (pop articles)) min) (> article max))
5173 (set var (delq article (symbol-value var)))))))
5175 ((eq mark-type 'tuple)
5176 (set var (setq articles (cdr marks)))
5177 (when (not (listp (cdr (symbol-value var))))
5178 (set var (list (symbol-value var))))
5179 (when (not (listp (cdr articles)))
5180 (setq articles (list articles)))
5182 (when (or (not (consp (setq article (pop articles))))
5183 (< (car article) min)
5184 (> (car article) max))
5185 (set var (delq article (symbol-value var))))))
5186 ;; Adjust ranges (sloppily).
5187 ((eq mark-type 'range)
5190 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5191 ;; It should be (seen (NUM1 . NUM2)).
5192 (when (numberp (cddr marks))
5193 (setcdr marks (list (cdr marks))))
5194 (setq articles (cdr marks))
5195 (while (and articles
5196 (or (and (consp (car articles))
5197 (> min (cdar articles)))
5198 (and (numberp (car articles))
5199 (> min (car articles)))))
5201 (set var articles))))))))
5203 (defun gnus-update-missing-marks (missing)
5204 "Go through the list of MISSING articles and remove them from the mark lists."
5207 ;; Go through all types.
5208 (dolist (elem gnus-article-mark-lists)
5209 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5210 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5211 (when (symbol-value var)
5212 ;; This list has articles. So we delete all missing
5213 ;; articles from it.
5216 (set var (delq (pop m) (symbol-value var))))))))))
5218 (defun gnus-update-marks ()
5219 "Enter the various lists of marked articles into the newsgroup info list."
5220 (let ((types gnus-article-mark-lists)
5221 (info (gnus-get-info gnus-newsgroup-name))
5222 type list newmarked symbol delta-marks)
5224 ;; Add all marks lists to the list of marks lists.
5225 (while (setq type (pop types))
5226 (setq list (symbol-value
5228 (intern (format "gnus-newsgroup-%s" (car type))))))
5231 ;; Get rid of the entries of the articles that have the
5233 (when (and (eq (cdr type) 'score)
5237 (prev (cons nil list))
5240 (if (or (not (consp (car arts)))
5241 (= (cdar arts) gnus-summary-default-score))
5242 (setcdr prev (cdr arts))
5244 (setq arts (cdr arts)))
5245 (setq list (cdr all)))))
5247 (when (eq (cdr type) 'seen)
5248 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5250 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5251 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5253 (when (and (gnus-check-backend-function
5254 'request-set-mark gnus-newsgroup-name)
5255 (not (gnus-article-unpropagatable-p (cdr type))))
5256 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5257 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5258 (add (gnus-remove-from-range
5259 (gnus-copy-sequence list) old)))
5261 (push (list add 'add (list (cdr type))) delta-marks))
5263 (push (list del 'del (list (cdr type))) delta-marks))))
5266 (push (cons (cdr type) list) newmarked)))
5269 (unless (gnus-check-group gnus-newsgroup-name)
5270 (error "Can't open server for %s" gnus-newsgroup-name))
5271 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5273 ;; Enter these new marks into the info of the group.
5275 (setcar (nthcdr 3 info) newmarked)
5276 ;; Add the marks lists to the end of the info.
5278 (setcdr (nthcdr 2 info) (list newmarked))))
5280 ;; Cut off the end of the info if there's nothing else there.
5284 (when (nthcdr (decf i) info)
5285 (setcdr (nthcdr i info) nil)))))))
5287 (defun gnus-set-mode-line (where)
5288 "Set the mode line of the article or summary buffers.
5289 If WHERE is `summary', the summary mode line format will be used."
5290 ;; Is this mode line one we keep updated?
5291 (when (and (memq where gnus-updated-mode-lines)
5293 (intern (format "gnus-%s-mode-line-format-spec" where))))
5296 ;; We evaluate this in the summary buffer since these
5297 ;; variables are buffer-local to that buffer.
5298 (set-buffer gnus-summary-buffer)
5299 ;; We bind all these variables that are used in the `eval' form
5301 (let* ((mformat (symbol-value
5303 (format "gnus-%s-mode-line-format-spec" where))))
5304 (gnus-tmp-group-name (gnus-group-decoded-name
5305 gnus-newsgroup-name))
5306 (gnus-tmp-article-number (or gnus-current-article 0))
5307 (gnus-tmp-unread gnus-newsgroup-unreads)
5308 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5309 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5310 (gnus-tmp-unread-and-unselected
5311 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5312 (zerop gnus-tmp-unselected))
5314 ((zerop gnus-tmp-unselected)
5315 (format "{%d more}" gnus-tmp-unread-and-unticked))
5316 (t (format "{%d(+%d) more}"
5317 gnus-tmp-unread-and-unticked
5318 gnus-tmp-unselected))))
5320 (if (and gnus-current-headers
5321 (vectorp gnus-current-headers))
5322 (gnus-mode-string-quote
5323 (mail-header-subject gnus-current-headers))
5325 bufname-length max-len
5326 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5327 (setq mode-string (eval mformat))
5328 (setq bufname-length (if (string-match "%b" mode-string)
5331 (if (eq where 'summary)
5333 (get-buffer gnus-article-buffer))))
5336 (setq max-len (max 4 (if gnus-mode-non-string-length
5338 gnus-mode-non-string-length
5340 (length mode-string))))
5341 ;; We might have to chop a bit of the string off...
5342 (when (> (length mode-string) max-len)
5344 (concat (truncate-string-to-width mode-string (- max-len 3))
5346 ;; Pad the mode string a bit.
5347 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5348 ;; Update the mode line.
5349 (setq mode-line-buffer-identification
5350 (gnus-mode-line-buffer-identification (list mode-string)))
5351 (set-buffer-modified-p t))))
5353 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5354 "Go through the HEADERS list and add all Xrefs to a hash table.
5355 The resulting hash table is returned, or nil if no Xrefs were found."
5356 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5357 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5358 (xref-hashtb (gnus-make-hashtable))
5359 start group entry number xrefs header)
5361 (setq header (pop headers))
5362 (when (and (setq xrefs (mail-header-xref header))
5363 (not (memq (setq number (mail-header-number header))
5366 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5367 (setq start (match-end 0))
5368 (setq group (if prefix
5369 (concat prefix (substring xrefs (match-beginning 1)
5371 (substring xrefs (match-beginning 1) (match-end 1))))
5373 (string-to-int (substring xrefs (match-beginning 2)
5375 (if (setq entry (gnus-gethash group xref-hashtb))
5376 (setcdr entry (cons number (cdr entry)))
5377 (gnus-sethash group (cons number nil) xref-hashtb)))))
5378 (and start xref-hashtb)))
5380 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5381 "Look through all the headers and mark the Xrefs as read."
5382 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5383 name entry info xref-hashtb idlist method nth4)
5385 (set-buffer gnus-group-buffer)
5386 (when (setq xref-hashtb
5387 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5390 (unless (string= from-newsgroup (setq name (symbol-name group)))
5391 (setq idlist (symbol-value group))
5392 ;; Dead groups are not updated.
5394 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5396 (when (stringp (setq nth4 (gnus-info-method info)))
5397 (setq nth4 (gnus-server-to-method nth4))))
5398 ;; Only do the xrefs if the group has the same
5399 ;; select method as the group we have just read.
5400 (or (gnus-methods-equal-p
5401 nth4 (gnus-find-method-for-group from-newsgroup))
5403 (equal nth4 (setq method (gnus-find-method-for-group
5405 (and (equal (car nth4) (car method))
5406 (equal (nth 1 nth4) (nth 1 method))))
5407 gnus-use-cross-reference
5408 (or (not (eq gnus-use-cross-reference t))
5410 ;; Only do cross-references on subscribed
5411 ;; groups, if that is what is wanted.
5412 (<= (gnus-info-level info) gnus-level-subscribed))
5413 (gnus-group-make-articles-read name idlist))))
5416 (defun gnus-compute-read-articles (group articles)
5417 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5418 (info (nth 2 entry))
5419 (active (gnus-active group))
5422 ;; First peel off all invalid article numbers.
5424 (let ((ids articles)
5426 (while (setq id (pop ids))
5427 (when (and first (> id (cdr active)))
5428 ;; We'll end up in this situation in one particular
5429 ;; obscure situation. If you re-scan a group and get
5430 ;; a new article that is cross-posted to a different
5431 ;; group that has not been re-scanned, you might get
5432 ;; crossposted article that has a higher number than
5433 ;; Gnus believes possible. So we re-activate this
5434 ;; group as well. This might mean doing the
5435 ;; crossposting thingy will *increase* the number
5436 ;; of articles in some groups. Tsk, tsk.
5437 (setq active (or (gnus-activate-group group) active)))
5438 (when (or (> id (cdr active))
5439 (< id (car active)))
5440 (setq articles (delq id articles))))))
5441 ;; If the read list is nil, we init it.
5443 (null (gnus-info-read info))
5445 (setq ninfo (cons 1 (1- (car active))))
5446 (setq ninfo (gnus-info-read info)))
5447 ;; Then we add the read articles to the range.
5449 ninfo (setq articles (sort articles '<))))))
5451 (defun gnus-group-make-articles-read (group articles)
5452 "Update the info of GROUP to say that ARTICLES are read."
5454 (entry (gnus-gethash group gnus-newsrc-hashtb))
5455 (info (nth 2 entry))
5456 (active (gnus-active group))
5459 (setq range (gnus-compute-read-articles group articles))
5461 (set-buffer gnus-group-buffer)
5464 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5465 (gnus-info-set-read ',info ',(gnus-info-read info))
5466 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5467 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5468 (gnus-group-update-group ,group t))))
5469 ;; Add the read articles to the range.
5470 (gnus-info-set-read info range)
5471 (gnus-request-set-mark group (list (list range 'add '(read))))
5472 ;; Then we have to re-compute how many unread
5473 ;; articles there are in this group.
5477 (setq num (- (1+ (cdr active)) (car active))))
5478 ((not (listp (cdr range)))
5479 (setq num (- (cdr active) (- (1+ (cdr range))
5483 (if (numberp (car range))
5485 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5486 (setq range (cdr range)))
5487 (setq num (- (cdr active) num))))
5488 ;; Update the number of unread articles.
5490 ;; Update the group buffer.
5491 (gnus-group-update-group group t)))))
5493 (defvar gnus-newsgroup-none-id 0)
5495 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5496 (let ((cur nntp-server-buffer)
5499 (save-excursion (set-buffer gnus-summary-buffer)
5500 gnus-newsgroup-dependencies)))
5502 (mail-parse-charset gnus-newsgroup-charset)
5503 (mail-parse-ignored-charsets
5504 (save-excursion (condition-case nil
5505 (set-buffer gnus-summary-buffer)
5507 gnus-newsgroup-ignored-charsets)))
5509 (set-buffer nntp-server-buffer)
5510 ;; Translate all TAB characters into SPACE characters.
5511 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5512 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5513 (gnus-run-hooks 'gnus-parse-headers-hook)
5514 (let ((case-fold-search t)
5515 in-reply-to header p lines chars)
5516 (goto-char (point-min))
5517 ;; Search to the beginning of the next header. Error messages
5518 ;; do not begin with 2 or 3.
5519 (while (re-search-forward "^[23][0-9]+ " nil t)
5522 ;; This implementation of this function, with nine
5523 ;; search-forwards instead of the one re-search-forward and
5524 ;; a case (which basically was the old function) is actually
5525 ;; about twice as fast, even though it looks messier. You
5526 ;; can't have everything, I guess. Speed and elegance
5527 ;; doesn't always go hand in hand.
5536 (narrow-to-region (point)
5537 (or (and (search-forward "\n.\n" nil t)
5543 (if (search-forward "\nsubject:" nil t)
5544 (funcall gnus-decode-encoded-word-function
5545 (nnheader-header-value))
5550 (if (search-forward "\nfrom:" nil t)
5551 (funcall gnus-decode-encoded-word-function
5552 (nnheader-header-value))
5557 (if (search-forward "\ndate:" nil t)
5558 (nnheader-header-value) ""))
5562 (setq id (if (re-search-forward
5563 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5564 ;; We do it this way to make sure the Message-ID
5565 ;; is (somewhat) syntactically valid.
5566 (buffer-substring (match-beginning 1)
5568 ;; If there was no message-id, we just fake one
5569 ;; to make subsequent routines simpler.
5570 (nnheader-generate-fake-message-id))))
5574 (if (search-forward "\nreferences:" nil t)
5578 (nnheader-header-value)
5583 (search-backward ">" end t)
5586 (search-backward "<" end t)
5588 ;; Get the references from the in-reply-to header if there
5589 ;; were no references and the in-reply-to header looks
5591 (if (and (search-forward "\nin-reply-to:" nil t)
5592 (setq in-reply-to (nnheader-header-value))
5593 (string-match "<[^>]+>" in-reply-to))
5595 (setq ref (substring in-reply-to (match-beginning 0)
5597 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5598 (setq ref2 (substring in-reply-to (match-beginning 0)
5600 (when (> (length ref2) (length ref))
5607 (if (search-forward "\nchars: " nil t)
5608 (if (numberp (setq chars (ignore-errors (read cur))))
5614 (if (search-forward "\nlines: " nil t)
5615 (if (numberp (setq lines (ignore-errors (read cur))))
5621 (and (search-forward "\nxref:" nil t)
5622 (nnheader-header-value)))
5624 (when gnus-extra-headers
5625 (let ((extra gnus-extra-headers)
5629 (when (search-forward
5630 (concat "\n" (symbol-name (car extra)) ":") nil t)
5631 (push (cons (car extra) (nnheader-header-value))
5635 (when (equal id ref)
5638 (when gnus-alter-header-function
5639 (funcall gnus-alter-header-function header)
5640 (setq id (mail-header-id header)
5641 ref (gnus-parent-id (mail-header-references header))))
5644 (gnus-dependencies-add-header
5645 header dependencies force-new))
5646 (push header headers))
5647 (goto-char (point-max))
5649 (nreverse headers)))))
5651 ;; Goes through the xover lines and returns a list of vectors
5652 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5653 force-new dependencies
5654 group also-fetch-heads)
5655 "Parse the news overview data in the server buffer.
5656 Return a list of headers that match SEQUENCE (see
5657 `nntp-retrieve-headers')."
5658 ;; Get the Xref when the users reads the articles since most/some
5659 ;; NNTP servers do not include Xrefs when using XOVER.
5660 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5661 (let ((mail-parse-charset gnus-newsgroup-charset)
5662 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5663 (cur nntp-server-buffer)
5664 (dependencies (or dependencies gnus-newsgroup-dependencies))
5666 ((eq gnus-read-all-available-headers t)
5668 ((stringp gnus-read-all-available-headers)
5669 (string-match gnus-read-all-available-headers group))
5672 number headers header)
5674 (set-buffer nntp-server-buffer)
5675 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5676 ;; Allow the user to mangle the headers before parsing them.
5677 (gnus-run-hooks 'gnus-parse-headers-hook)
5678 (goto-char (point-min))
5679 (gnus-parse-without-error
5680 (while (and (or sequence allp)
5682 (setq number (read cur))
5684 (while (and sequence
5685 (< (car sequence) number))
5686 (setq sequence (cdr sequence))))
5689 (eq number (car sequence))))
5691 (setq sequence (cdr sequence))
5692 (setq header (inline
5693 (gnus-nov-parse-line
5694 number dependencies force-new)))))
5695 (push header headers))
5697 ;; A common bug in inn is that if you have posted an article and
5698 ;; then retrieves the active file, it will answer correctly --
5699 ;; the new article is included. However, a NOV entry for the
5700 ;; article may not have been generated yet, so this may fail.
5701 ;; We work around this problem by retrieving the last few
5702 ;; headers using HEAD.
5703 (if (or (not also-fetch-heads)
5705 ;; We (probably) got all the headers.
5707 (let ((gnus-nov-is-evil t))
5710 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5711 (gnus-get-newsgroup-headers))))))))
5713 (defun gnus-article-get-xrefs ()
5714 "Fill in the Xref value in `gnus-current-headers', if necessary.
5715 This is meant to be called in `gnus-article-internal-prepare-hook'."
5716 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5717 gnus-current-headers)))
5718 (or (not gnus-use-cross-reference)
5720 (and (mail-header-xref headers)
5721 (not (string= (mail-header-xref headers) "")))
5722 (let ((case-fold-search t)
5725 (nnheader-narrow-to-headers)
5726 (goto-char (point-min))
5727 (when (or (and (not (eobp))
5728 (eq (downcase (char-after)) ?x)
5729 (looking-at "Xref:"))
5730 (search-forward "\nXref:" nil t))
5731 (goto-char (1+ (match-end 0)))
5732 (setq xref (buffer-substring (point)
5733 (progn (end-of-line) (point))))
5734 (mail-header-set-xref headers xref)))))))
5736 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5737 "Find article ID and insert the summary line for that article.
5738 OLD-HEADER can either be a header or a line number to insert
5739 the subject line on."
5740 (let* ((line (and (numberp old-header) old-header))
5741 (old-header (and (vectorp old-header) old-header))
5742 (header (cond ((and old-header use-old-header)
5745 (gnus-number-to-header id))
5746 (gnus-number-to-header id))
5748 (gnus-read-header id))))
5749 (number (and (numberp id) id))
5752 ;; Rebuild the thread that this article is part of and go to the
5753 ;; article we have fetched.
5754 (when (and (not gnus-show-threads)
5757 (setq d (gnus-data-find (mail-header-number old-header))))
5758 (goto-char (gnus-data-pos d))
5761 (- (gnus-point-at-bol)
5763 (1+ (gnus-point-at-eol))
5764 (gnus-delete-line))))))
5766 (mail-header-set-number header (mail-header-number old-header)))
5767 (setq gnus-newsgroup-sparse
5768 (delq (setq number (mail-header-number header))
5769 gnus-newsgroup-sparse))
5770 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5771 (push number gnus-newsgroup-limit)
5772 (gnus-rebuild-thread (mail-header-id header) line)
5773 (gnus-summary-goto-subject number nil t))
5774 (when (and (numberp number)
5776 ;; We have to update the boundaries even if we can't fetch the
5777 ;; article if ID is a number -- so that the next `P' or `N'
5778 ;; command will fetch the previous (or next) article even
5779 ;; if the one we tried to fetch this time has been canceled.
5780 (when (> number gnus-newsgroup-end)
5781 (setq gnus-newsgroup-end number))
5782 (when (< number gnus-newsgroup-begin)
5783 (setq gnus-newsgroup-begin number))
5784 (setq gnus-newsgroup-unselected
5785 (delq number gnus-newsgroup-unselected)))
5786 ;; Report back a success?
5787 (and header (mail-header-number header))))
5789 ;;; Process/prefix in the summary buffer
5791 (defun gnus-summary-work-articles (n)
5792 "Return a list of articles to be worked upon.
5793 The prefix argument, the list of process marked articles, and the
5794 current article will be taken into consideration."
5796 (set-buffer gnus-summary-buffer)
5799 ;; A numerical prefix has been given.
5800 (setq n (prefix-numeric-value n))
5801 (let ((backward (< n 0))
5802 (n (abs (prefix-numeric-value n)))
5807 (push (setq article (gnus-summary-article-number))
5810 (gnus-summary-find-prev nil article)
5811 (gnus-summary-find-next nil article)))
5813 (nreverse articles)))
5814 ((and (gnus-region-active-p) (mark))
5815 (message "region active")
5816 ;; Work on the region between point and mark.
5817 (let ((max (max (point) (mark)))
5820 (goto-char (min (min (point) (mark))))
5823 (push (setq article (gnus-summary-article-number)) articles)
5824 (gnus-summary-find-next nil article)
5826 (nreverse articles))))
5827 (gnus-newsgroup-processable
5828 ;; There are process-marked articles present.
5829 ;; Save current state.
5830 (gnus-summary-save-process-mark)
5832 (reverse gnus-newsgroup-processable))
5834 ;; Just return the current article.
5835 (list (gnus-summary-article-number))))))
5837 (defmacro gnus-summary-iterate (arg &rest forms)
5838 "Iterate over the process/prefixed articles and do FORMS.
5839 ARG is the interactive prefix given to the command. FORMS will be
5840 executed with point over the summary line of the articles."
5841 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5842 `(let ((,articles (gnus-summary-work-articles ,arg)))
5844 (gnus-summary-goto-subject (car ,articles))
5848 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5849 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5851 (defun gnus-summary-save-process-mark ()
5852 "Push the current set of process marked articles on the stack."
5854 (push (copy-sequence gnus-newsgroup-processable)
5855 gnus-newsgroup-process-stack))
5857 (defun gnus-summary-kill-process-mark ()
5858 "Push the current set of process marked articles on the stack and unmark."
5860 (gnus-summary-save-process-mark)
5861 (gnus-summary-unmark-all-processable))
5863 (defun gnus-summary-yank-process-mark ()
5864 "Pop the last process mark state off the stack and restore it."
5866 (unless gnus-newsgroup-process-stack
5867 (error "Empty mark stack"))
5868 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5870 (defun gnus-summary-process-mark-set (set)
5871 "Make SET into the current process marked articles."
5872 (gnus-summary-unmark-all-processable)
5874 (gnus-summary-set-process-mark (pop set))))
5876 ;;; Searching and stuff
5878 (defun gnus-summary-search-group (&optional backward use-level)
5879 "Search for next unread newsgroup.
5880 If optional argument BACKWARD is non-nil, search backward instead."
5882 (set-buffer gnus-group-buffer)
5883 (when (gnus-group-search-forward
5884 backward nil (if use-level (gnus-group-group-level) nil))
5885 (gnus-group-group-name))))
5887 (defun gnus-summary-best-group (&optional exclude-group)
5888 "Find the name of the best unread group.
5889 If EXCLUDE-GROUP, do not go to this group."
5891 (set-buffer gnus-group-buffer)
5893 (gnus-group-best-unread-group exclude-group))))
5895 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5896 (if backward (gnus-summary-find-prev)
5897 (let* ((dummy (gnus-summary-article-intangible-p))
5898 (article (or article (gnus-summary-article-number)))
5899 (arts (gnus-data-find-list article))
5901 (when (and (not dummy)
5902 (or (not gnus-summary-check-current)
5904 (not (gnus-data-unread-p (car arts)))))
5905 (setq arts (cdr arts)))
5910 (when (or (and undownloaded
5911 (eq gnus-undownloaded-mark
5912 (gnus-data-mark (car arts))))
5913 (gnus-data-unread-p (car arts)))
5914 (setq result (car arts)
5916 (setq arts (cdr arts)))
5919 (goto-char (gnus-data-pos result))
5920 (gnus-data-number result)))))
5922 (defun gnus-summary-find-prev (&optional unread article)
5923 (let* ((eobp (eobp))
5924 (article (or article (gnus-summary-article-number)))
5925 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5927 (when (and (not eobp)
5928 (or (not gnus-summary-check-current)
5930 (not (gnus-data-unread-p (car arts)))))
5931 (setq arts (cdr arts)))
5936 (when (gnus-data-unread-p (car arts))
5937 (setq result (car arts)
5939 (setq arts (cdr arts)))
5942 (goto-char (gnus-data-pos result))
5943 (gnus-data-number result))))
5945 (defun gnus-summary-find-subject (subject &optional unread backward article)
5946 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5947 (article (or article (gnus-summary-article-number)))
5948 (articles (gnus-data-list backward))
5949 (arts (gnus-data-find-list article articles))
5951 (when (or (not gnus-summary-check-current)
5953 (not (gnus-data-unread-p (car arts))))
5954 (setq arts (cdr arts)))
5956 (and (or (not unread)
5957 (gnus-data-unread-p (car arts)))
5958 (vectorp (gnus-data-header (car arts)))
5960 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5961 (setq result (car arts)
5963 (setq arts (cdr arts)))
5965 (goto-char (gnus-data-pos result))
5966 (gnus-data-number result))))
5968 (defun gnus-summary-search-forward (&optional unread subject backward)
5969 "Search forward for an article.
5970 If UNREAD, look for unread articles. If SUBJECT, look for
5971 articles with that subject. If BACKWARD, search backward instead."
5972 (cond (subject (gnus-summary-find-subject subject unread backward))
5973 (backward (gnus-summary-find-prev unread))
5974 (t (gnus-summary-find-next unread))))
5976 (defun gnus-recenter (&optional n)
5977 "Center point in window and redisplay frame.
5978 Also do horizontal recentering."
5980 (when (and gnus-auto-center-summary
5981 (not (eq gnus-auto-center-summary 'vertical)))
5982 (gnus-horizontal-recenter))
5985 (defun gnus-summary-recenter ()
5986 "Center point in the summary window.
5987 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5988 displayed, no centering will be performed."
5989 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5990 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5992 (let* ((top (cond ((< (window-height) 4) 0)
5993 ((< (window-height) 7) 1)
5994 (t (if (numberp gnus-auto-center-summary)
5995 gnus-auto-center-summary
5997 (height (1- (window-height)))
5998 (bottom (save-excursion (goto-char (point-max))
5999 (forward-line (- height))
6001 (window (get-buffer-window (current-buffer))))
6002 ;; The user has to want it.
6003 (when gnus-auto-center-summary
6004 (when (get-buffer-window gnus-article-buffer)
6005 ;; Only do recentering when the article buffer is displayed,
6006 ;; Set the window start to either `bottom', which is the biggest
6007 ;; possible valid number, or the second line from the top,
6008 ;; whichever is the least.
6009 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6010 (if (> bottom top-pos)
6011 ;; Keep the second line from the top visible
6012 (set-window-start window top-pos t)
6013 ;; Try to keep the bottom line visible; if it's partially
6014 ;; obscured, either scroll one more line to make it fully
6015 ;; visible, or revert to using TOP-POS.
6017 (goto-char (point-max))
6019 (let ((last-line-start (point)))
6021 (set-window-start window (point) t)
6022 (when (not (pos-visible-in-window-p last-line-start window))
6024 (set-window-start window (min (point) top-pos) t)))))))
6025 ;; Do horizontal recentering while we're at it.
6026 (when (and (get-buffer-window (current-buffer) t)
6027 (not (eq gnus-auto-center-summary 'vertical)))
6028 (let ((selected (selected-window)))
6029 (select-window (get-buffer-window (current-buffer) t))
6030 (gnus-summary-position-point)
6031 (gnus-horizontal-recenter)
6032 (select-window selected))))))
6034 (defun gnus-summary-jump-to-group (newsgroup)
6035 "Move point to NEWSGROUP in group mode buffer."
6036 ;; Keep update point of group mode buffer if visible.
6037 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6038 (save-window-excursion
6039 ;; Take care of tree window mode.
6040 (when (get-buffer-window gnus-group-buffer)
6041 (pop-to-buffer gnus-group-buffer))
6042 (gnus-group-jump-to-group newsgroup))
6044 ;; Take care of tree window mode.
6045 (if (get-buffer-window gnus-group-buffer)
6046 (pop-to-buffer gnus-group-buffer)
6047 (set-buffer gnus-group-buffer))
6048 (gnus-group-jump-to-group newsgroup))))
6050 ;; This function returns a list of article numbers based on the
6051 ;; difference between the ranges of read articles in this group and
6052 ;; the range of active articles.
6053 (defun gnus-list-of-unread-articles (group)
6054 (let* ((read (gnus-info-read (gnus-get-info group)))
6055 (active (or (gnus-active group) (gnus-activate-group group)))
6058 ;; If none are read, then all are unread.
6060 (setq first (car active))
6061 ;; If the range of read articles is a single range, then the
6062 ;; first unread article is the article after the last read
6063 ;; article. Sounds logical, doesn't it?
6064 (if (and (not (listp (cdr read)))
6065 (or (< (car read) (car active))
6066 (progn (setq read (list read))
6068 (setq first (max (car active) (1+ (cdr read))))
6069 ;; `read' is a list of ranges.
6070 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6073 (setq first (car active)))
6076 (while (< first nlast)
6078 (setq first (1+ first))))
6079 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6080 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6081 (setq read (cdr read)))))
6082 ;; And add the last unread articles.
6083 (while (<= first last)
6085 (setq first (1+ first)))
6086 ;; Return the list of unread articles.
6087 (delq 0 (nreverse unread))))
6089 (defun gnus-list-of-read-articles (group)
6090 "Return a list of unread, unticked and non-dormant articles."
6091 (let* ((info (gnus-get-info group))
6092 (marked (gnus-info-marks info))
6093 (active (gnus-active group)))
6095 (gnus-list-range-difference
6096 (gnus-list-range-difference
6097 (gnus-sorted-complement
6098 (gnus-uncompress-range active)
6099 (gnus-list-of-unread-articles group))
6100 (cdr (assq 'dormant marked)))
6101 (cdr (assq 'tick marked))))))
6103 ;; Various summary commands
6105 (defun gnus-summary-select-article-buffer ()
6106 "Reconfigure windows to show article buffer."
6108 (if (not (gnus-buffer-live-p gnus-article-buffer))
6109 (error "There is no article buffer for this summary buffer")
6110 (gnus-configure-windows 'article)
6111 (select-window (get-buffer-window gnus-article-buffer))))
6113 (defun gnus-summary-universal-argument (arg)
6114 "Perform any operation on all articles that are process/prefixed."
6116 (let ((articles (gnus-summary-work-articles arg))
6123 (substitute-command-keys
6124 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6126 (gnus-error 1 "Undefined key")
6129 (gnus-summary-goto-subject (setq article (pop articles)))
6130 (let (gnus-newsgroup-processable)
6131 (command-execute func))
6132 (gnus-summary-remove-process-mark article)))))
6133 (gnus-summary-position-point))
6135 (defun gnus-summary-toggle-truncation (&optional arg)
6136 "Toggle truncation of summary lines.
6137 With arg, turn line truncation on iff arg is positive."
6139 (setq truncate-lines
6140 (if (null arg) (not truncate-lines)
6141 (> (prefix-numeric-value arg) 0)))
6144 (defun gnus-summary-reselect-current-group (&optional all rescan)
6145 "Exit and then reselect the current newsgroup.
6146 The prefix argument ALL means to select all articles."
6148 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6149 (error "Ephemeral groups can't be reselected"))
6150 (let ((current-subject (gnus-summary-article-number))
6151 (group gnus-newsgroup-name))
6152 (setq gnus-newsgroup-begin nil)
6154 ;; We have to adjust the point of group mode buffer because
6155 ;; point was moved to the next unread newsgroup by exiting.
6156 (gnus-summary-jump-to-group group)
6159 (gnus-group-get-new-news-this-group 1)))
6160 (gnus-group-read-group all t)
6161 (gnus-summary-goto-subject current-subject nil t)))
6163 (defun gnus-summary-rescan-group (&optional all)
6164 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6166 (gnus-summary-reselect-current-group all t))
6168 (defun gnus-summary-update-info (&optional non-destructive)
6170 (let ((group gnus-newsgroup-name))
6172 (when gnus-newsgroup-kill-headers
6173 (setq gnus-newsgroup-killed
6174 (gnus-compress-sequence
6176 (gnus-list-range-intersection
6177 gnus-newsgroup-unselected gnus-newsgroup-killed)
6178 gnus-newsgroup-unreads)
6180 (unless (listp (cdr gnus-newsgroup-killed))
6181 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6182 (let ((headers gnus-newsgroup-headers))
6183 ;; Set the new ranges of read articles.
6185 (set-buffer gnus-group-buffer)
6186 (gnus-undo-force-boundary))
6187 (gnus-update-read-articles
6188 group (gnus-sorted-union
6189 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6190 ;; Set the current article marks.
6191 (let ((gnus-newsgroup-scored
6192 (if (and (not gnus-save-score)
6193 (not non-destructive))
6195 gnus-newsgroup-scored)))
6197 (gnus-update-marks)))
6198 ;; Do the cross-ref thing.
6199 (when gnus-use-cross-reference
6200 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6201 ;; Do not switch windows but change the buffer to work.
6202 (set-buffer gnus-group-buffer)
6203 (unless (gnus-ephemeral-group-p group)
6204 (gnus-group-update-group group)))))))
6206 (defun gnus-summary-save-newsrc (&optional force)
6207 "Save the current number of read/marked articles in the dribble buffer.
6208 The dribble buffer will then be saved.
6209 If FORCE (the prefix), also save the .newsrc file(s)."
6211 (gnus-summary-update-info t)
6213 (gnus-save-newsrc-file)
6214 (gnus-dribble-save)))
6216 (defun gnus-summary-exit (&optional temporary)
6217 "Exit reading current newsgroup, and then return to group selection mode.
6218 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6220 (gnus-set-global-variables)
6221 (when (gnus-buffer-live-p gnus-article-buffer)
6223 (set-buffer gnus-article-buffer)
6224 (mm-destroy-parts gnus-article-mime-handles)
6225 ;; Set it to nil for safety reason.
6226 (setq gnus-article-mime-handle-alist nil)
6227 (setq gnus-article-mime-handles nil)))
6228 (gnus-kill-save-kill-buffer)
6229 (gnus-async-halt-prefetch)
6230 (let* ((group gnus-newsgroup-name)
6231 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6234 (buf (current-buffer)))
6236 ;; Do adaptive scoring, and possibly save score files.
6237 (when gnus-newsgroup-adaptive
6238 (gnus-score-adaptive))
6239 (when gnus-use-scoring
6241 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6242 ;; If we have several article buffers, we kill them at exit.
6243 (unless gnus-single-article-buffer
6244 (gnus-kill-buffer gnus-original-article-buffer)
6245 (setq gnus-article-current nil))
6246 (when gnus-use-cache
6247 (gnus-cache-possibly-remove-articles)
6248 (gnus-cache-save-buffers))
6249 (gnus-async-prefetch-remove-group group)
6250 (when gnus-suppress-duplicates
6251 (gnus-dup-enter-articles))
6252 (when gnus-use-trees
6253 (gnus-tree-close group))
6254 (when gnus-use-cache
6255 (gnus-cache-write-active))
6256 ;; Remove entries for this group.
6257 (nnmail-purge-split-history (gnus-group-real-name group))
6258 ;; Make all changes in this group permanent.
6260 (gnus-run-hooks 'gnus-exit-group-hook)
6261 (gnus-summary-update-info))
6262 (gnus-close-group group)
6263 ;; Make sure where we were, and go to next newsgroup.
6264 (set-buffer gnus-group-buffer)
6266 (gnus-group-jump-to-group group))
6267 (gnus-run-hooks 'gnus-summary-exit-hook)
6268 (unless (or quit-config
6269 ;; If this group has disappeared from the summary
6270 ;; buffer, don't skip forwards.
6271 (not (string= group (gnus-group-group-name))))
6272 (gnus-group-next-unread-group 1))
6273 (setq group-point (point))
6276 ;; If we have several article buffers, we kill them at exit.
6277 (unless gnus-single-article-buffer
6278 (gnus-kill-buffer gnus-article-buffer)
6279 (gnus-kill-buffer gnus-original-article-buffer)
6280 (setq gnus-article-current nil))
6282 (if (not gnus-kill-summary-on-exit)
6284 (gnus-deaden-summary)
6286 ;; We set all buffer-local variables to nil. It is unclear why
6287 ;; this is needed, but if we don't, buffer-local variables are
6288 ;; not garbage-collected, it seems. This would the lead to en
6289 ;; ever-growing Emacs.
6290 (gnus-summary-clear-local-variables)
6291 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6292 (gnus-summary-clear-local-variables))
6293 (when (get-buffer gnus-article-buffer)
6294 (bury-buffer gnus-article-buffer))
6295 ;; We clear the global counterparts of the buffer-local
6296 ;; variables as well, just to be on the safe side.
6297 (set-buffer gnus-group-buffer)
6298 (gnus-summary-clear-local-variables)
6299 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6300 (gnus-summary-clear-local-variables)))
6301 (setq gnus-current-select-method gnus-select-method)
6302 (pop-to-buffer gnus-group-buffer)
6303 (if (not quit-config)
6305 (goto-char group-point)
6306 (gnus-configure-windows 'group 'force))
6307 (gnus-handle-ephemeral-exit quit-config))
6308 ;; Return to group mode buffer.
6309 (when (eq mode 'gnus-summary-mode)
6310 (gnus-kill-buffer buf))
6311 ;; Clear the current group name.
6313 (setq gnus-newsgroup-name nil)))))
6315 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6316 (defun gnus-summary-exit-no-update (&optional no-questions)
6317 "Quit reading current newsgroup without updating read article info."
6319 (let* ((group gnus-newsgroup-name)
6320 (quit-config (gnus-group-quit-config group)))
6321 (when (or no-questions
6323 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6324 (gnus-async-halt-prefetch)
6326 (delq 'gnus-summary-expire-articles
6327 (copy-sequence gnus-summary-prepare-exit-hook)))
6328 (when (gnus-buffer-live-p gnus-article-buffer)
6330 (set-buffer gnus-article-buffer)
6331 (mm-destroy-parts gnus-article-mime-handles)
6332 ;; Set it to nil for safety reason.
6333 (setq gnus-article-mime-handle-alist nil)
6334 (setq gnus-article-mime-handles nil)))
6335 ;; If we have several article buffers, we kill them at exit.
6336 (unless gnus-single-article-buffer
6337 (gnus-kill-buffer gnus-article-buffer)
6338 (gnus-kill-buffer gnus-original-article-buffer)
6339 (setq gnus-article-current nil))
6340 (if (not gnus-kill-summary-on-exit)
6341 (gnus-deaden-summary)
6342 (gnus-close-group group)
6343 (gnus-summary-clear-local-variables)
6344 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6345 (gnus-summary-clear-local-variables))
6346 (set-buffer gnus-group-buffer)
6347 (gnus-summary-clear-local-variables)
6348 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6349 (gnus-summary-clear-local-variables))
6350 (when (get-buffer gnus-summary-buffer)
6351 (kill-buffer gnus-summary-buffer)))
6352 (unless gnus-single-article-buffer
6353 (setq gnus-article-current nil))
6354 (when gnus-use-trees
6355 (gnus-tree-close group))
6356 (gnus-async-prefetch-remove-group group)
6357 (when (get-buffer gnus-article-buffer)
6358 (bury-buffer gnus-article-buffer))
6359 ;; Return to the group buffer.
6360 (gnus-configure-windows 'group 'force)
6361 ;; Clear the current group name.
6362 (setq gnus-newsgroup-name nil)
6363 (when (equal (gnus-group-group-name) group)
6364 (gnus-group-next-unread-group 1))
6366 (gnus-handle-ephemeral-exit quit-config)))))
6368 (defun gnus-handle-ephemeral-exit (quit-config)
6369 "Handle movement when leaving an ephemeral group.
6370 The state which existed when entering the ephemeral is reset."
6371 (if (not (buffer-name (car quit-config)))
6372 (gnus-configure-windows 'group 'force)
6373 (set-buffer (car quit-config))
6374 (cond ((eq major-mode 'gnus-summary-mode)
6375 (gnus-set-global-variables))
6376 ((eq major-mode 'gnus-article-mode)
6378 ;; The `gnus-summary-buffer' variable may point
6379 ;; to the old summary buffer when using a single
6381 (unless (gnus-buffer-live-p gnus-summary-buffer)
6382 (set-buffer gnus-group-buffer))
6383 (set-buffer gnus-summary-buffer)
6384 (gnus-set-global-variables))))
6385 (if (or (eq (cdr quit-config) 'article)
6386 (eq (cdr quit-config) 'pick))
6388 ;; The current article may be from the ephemeral group
6389 ;; thus it is best that we reload this article
6390 (gnus-summary-show-article)
6391 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6392 (gnus-configure-windows 'pick 'force)
6393 (gnus-configure-windows (cdr quit-config) 'force)))
6394 (gnus-configure-windows (cdr quit-config) 'force))
6395 (when (eq major-mode 'gnus-summary-mode)
6396 (gnus-summary-next-subject 1 nil t)
6397 (gnus-summary-recenter)
6398 (gnus-summary-position-point))))
6402 (defvar gnus-dead-summary-mode-map nil)
6404 (unless gnus-dead-summary-mode-map
6405 (setq gnus-dead-summary-mode-map (make-keymap))
6406 (suppress-keymap gnus-dead-summary-mode-map)
6407 (substitute-key-definition
6408 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6409 (dolist (key '("\C-d" "\r" "\177" [delete]))
6410 (define-key gnus-dead-summary-mode-map
6411 key 'gnus-summary-wake-up-the-dead))
6412 (dolist (key '("q" "Q"))
6413 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6415 (defvar gnus-dead-summary-mode nil
6416 "Minor mode for Gnus summary buffers.")
6418 (defun gnus-dead-summary-mode (&optional arg)
6419 "Minor mode for Gnus summary buffers."
6421 (when (eq major-mode 'gnus-summary-mode)
6422 (make-local-variable 'gnus-dead-summary-mode)
6423 (setq gnus-dead-summary-mode
6424 (if (null arg) (not gnus-dead-summary-mode)
6425 (> (prefix-numeric-value arg) 0)))
6426 (when gnus-dead-summary-mode
6427 (gnus-add-minor-mode
6428 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6430 (defun gnus-deaden-summary ()
6431 "Make the current summary buffer into a dead summary buffer."
6432 ;; Kill any previous dead summary buffer.
6433 (when (and gnus-dead-summary
6434 (buffer-name gnus-dead-summary))
6436 (set-buffer gnus-dead-summary)
6437 (when gnus-dead-summary-mode
6438 (kill-buffer (current-buffer)))))
6439 ;; Make this the current dead summary.
6440 (setq gnus-dead-summary (current-buffer))
6441 (gnus-dead-summary-mode 1)
6442 (let ((name (buffer-name)))
6443 (when (string-match "Summary" name)
6445 (concat (substring name 0 (match-beginning 0)) "Dead "
6446 (substring name (match-beginning 0)))
6450 (defun gnus-kill-or-deaden-summary (buffer)
6451 "Kill or deaden the summary BUFFER."
6453 (when (and (buffer-name buffer)
6454 (not gnus-single-article-buffer))
6457 (gnus-kill-buffer gnus-article-buffer)
6458 (gnus-kill-buffer gnus-original-article-buffer)))
6461 (gnus-kill-summary-on-exit
6462 (when (and gnus-use-trees
6463 (gnus-buffer-exists-p buffer))
6466 (gnus-tree-close gnus-newsgroup-name)))
6467 (gnus-kill-buffer buffer))
6468 ;; Deaden the buffer.
6469 ((gnus-buffer-exists-p buffer)
6472 (gnus-deaden-summary))))))
6474 (defun gnus-summary-wake-up-the-dead (&rest args)
6475 "Wake up the dead summary buffer."
6477 (gnus-dead-summary-mode -1)
6478 (let ((name (buffer-name)))
6479 (when (string-match "Dead " name)
6481 (concat (substring name 0 (match-beginning 0))
6482 (substring name (match-end 0)))
6484 (gnus-message 3 "This dead summary is now alive again"))
6486 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6487 (defun gnus-summary-fetch-faq (&optional faq-dir)
6488 "Fetch the FAQ for the current group.
6489 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6493 (when current-prefix-arg
6495 "Faq dir: " (and (listp gnus-group-faq-directory)
6496 (mapcar (lambda (file) (list file))
6497 gnus-group-faq-directory))))))
6498 (let (gnus-faq-buffer)
6499 (when (setq gnus-faq-buffer
6500 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6501 (gnus-configure-windows 'summary-faq))))
6503 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6504 (defun gnus-summary-describe-group (&optional force)
6505 "Describe the current newsgroup."
6507 (gnus-group-describe-group force gnus-newsgroup-name))
6509 (defun gnus-summary-describe-briefly ()
6510 "Describe summary mode commands briefly."
6512 (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")))
6514 ;; Walking around group mode buffer from summary mode.
6516 (defun gnus-summary-next-group (&optional no-article target-group backward)
6517 "Exit current newsgroup and then select next unread newsgroup.
6518 If prefix argument NO-ARTICLE is non-nil, no article is selected
6519 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6520 previous group instead."
6522 ;; Stop pre-fetching.
6523 (gnus-async-halt-prefetch)
6524 (let ((current-group gnus-newsgroup-name)
6525 (current-buffer (current-buffer))
6527 ;; First we semi-exit this group to update Xrefs and all variables.
6528 ;; We can't do a real exit, because the window conf must remain
6529 ;; the same in case the user is prompted for info, and we don't
6530 ;; want the window conf to change before that...
6531 (gnus-summary-exit t)
6532 (while (not entered)
6533 ;; Then we find what group we are supposed to enter.
6534 (set-buffer gnus-group-buffer)
6535 (gnus-group-jump-to-group current-group)
6538 (if (eq gnus-keep-same-level 'best)
6539 (gnus-summary-best-group gnus-newsgroup-name)
6540 (gnus-summary-search-group backward gnus-keep-same-level))))
6541 (if (not target-group)
6542 ;; There are no further groups, so we return to the group
6545 (gnus-message 5 "Returning to the group buffer")
6547 (when (gnus-buffer-live-p current-buffer)
6548 (set-buffer current-buffer)
6549 (gnus-summary-exit))
6550 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6551 ;; We try to enter the target group.
6552 (gnus-group-jump-to-group target-group)
6553 (let ((unreads (gnus-group-group-unread)))
6554 (if (and (or (eq t unreads)
6555 (and unreads (not (zerop unreads))))
6556 (gnus-summary-read-group
6557 target-group nil no-article
6558 (and (buffer-name current-buffer) current-buffer)
6561 (setq current-group target-group
6562 target-group nil)))))))
6564 (defun gnus-summary-prev-group (&optional no-article)
6565 "Exit current newsgroup and then select previous unread newsgroup.
6566 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6568 (gnus-summary-next-group no-article nil t))
6570 ;; Walking around summary lines.
6572 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6573 "Go to the first unread subject.
6574 If UNREAD is non-nil, go to the first unread article.
6575 Returns the article selected or nil if there are no unread articles."
6580 ((null gnus-newsgroup-data)
6581 (gnus-message 3 "No articles in the group")
6583 ;; Pick the first article.
6585 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6586 (gnus-data-number (car gnus-newsgroup-data)))
6587 ;; No unread articles.
6588 ((null gnus-newsgroup-unreads)
6589 (gnus-message 3 "No more unread articles")
6591 ;; Find the first unread article.
6593 (let ((data gnus-newsgroup-data))
6595 (and (not (and undownloaded
6596 (eq gnus-undownloaded-mark
6597 (gnus-data-mark (car data)))))
6600 (gnus-data-number (car data))
6601 gnus-newsgroup-unseen))
6602 (not (gnus-data-unread-p (car data))))
6603 (not (gnus-data-unread-p (car data))))))
6604 (setq data (cdr data)))
6606 (goto-char (gnus-data-pos (car data)))
6607 (gnus-data-number (car data))))))
6608 (gnus-summary-position-point)))
6610 (defun gnus-summary-next-subject (n &optional unread dont-display)
6611 "Go to next N'th summary line.
6612 If N is negative, go to the previous N'th subject line.
6613 If UNREAD is non-nil, only unread articles are selected.
6614 The difference between N and the actual number of steps taken is
6617 (let ((backward (< n 0))
6621 (gnus-summary-find-prev unread)
6622 (gnus-summary-find-next unread)))
6623 (unless (zerop (setq n (1- n)))
6624 (gnus-summary-show-thread)))
6626 (gnus-message 7 "No more%s articles"
6627 (if unread " unread" "")))
6628 (unless dont-display
6629 (gnus-summary-recenter)
6630 (gnus-summary-position-point))
6633 (defun gnus-summary-next-unread-subject (n)
6634 "Go to next N'th unread summary line."
6636 (gnus-summary-next-subject n t))
6638 (defun gnus-summary-prev-subject (n &optional unread)
6639 "Go to previous N'th summary line.
6640 If optional argument UNREAD is non-nil, only unread article is selected."
6642 (gnus-summary-next-subject (- n) unread))
6644 (defun gnus-summary-prev-unread-subject (n)
6645 "Go to previous N'th unread summary line."
6647 (gnus-summary-next-subject (- n) t))
6649 (defun gnus-summary-goto-subject (article &optional force silent)
6650 "Go the subject line of ARTICLE.
6651 If FORCE, also allow jumping to articles not currently shown."
6652 (interactive "nArticle number: ")
6653 (unless (numberp article)
6654 (error "Article %s is not a number" article))
6656 (data (gnus-data-find article)))
6657 ;; We read in the article if we have to.
6660 (gnus-summary-insert-subject
6662 (if (or (numberp force) (vectorp force)) force)
6664 (setq data (gnus-data-find article)))
6669 (gnus-message 3 "Can't find article %d" article))
6671 (let ((pt (gnus-data-pos data)))
6673 (gnus-summary-set-article-display-arrow pt))
6674 (gnus-summary-position-point)
6677 ;; Walking around summary lines with displaying articles.
6679 (defun gnus-summary-expand-window (&optional arg)
6680 "Make the summary buffer take up the entire Emacs frame.
6681 Given a prefix, will force an `article' buffer configuration."
6684 (gnus-configure-windows 'article 'force)
6685 (gnus-configure-windows 'summary 'force)))
6687 (defun gnus-summary-display-article (article &optional all-header)
6688 "Display ARTICLE in article buffer."
6689 (when (gnus-buffer-live-p gnus-article-buffer)
6690 (with-current-buffer gnus-article-buffer
6691 (mm-enable-multibyte)))
6692 (gnus-set-global-variables)
6693 (when (gnus-buffer-live-p gnus-article-buffer)
6694 (with-current-buffer gnus-article-buffer
6695 (setq gnus-article-charset gnus-newsgroup-charset)
6696 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6697 (mm-enable-multibyte)))
6701 (if gnus-summary-display-article-function
6702 (funcall gnus-summary-display-article-function article all-header)
6703 (gnus-article-prepare article all-header))
6704 (gnus-run-hooks 'gnus-select-article-hook)
6705 (when (and gnus-current-article
6706 (not (zerop gnus-current-article)))
6707 (gnus-summary-goto-subject gnus-current-article))
6708 (gnus-summary-recenter)
6709 (when (and gnus-use-trees gnus-show-threads)
6710 (gnus-possibly-generate-tree article)
6711 (gnus-highlight-selected-tree article))
6712 ;; Successfully display article.
6713 (gnus-article-set-window-start
6714 (cdr (assq article gnus-newsgroup-bookmarks))))))
6716 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6717 "Select the current article.
6718 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6719 non-nil, the article will be re-fetched even if it already present in
6720 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6722 ;; Make sure we are in the summary buffer to work around bbdb bug.
6723 (unless (eq major-mode 'gnus-summary-mode)
6724 (set-buffer gnus-summary-buffer))
6725 (let ((article (or article (gnus-summary-article-number)))
6726 (all-headers (not (not all-headers))) ;Must be t or nil.
6727 gnus-summary-display-article-function)
6729 (gnus-summary-article-pseudo-p article)
6730 (error "This is a pseudo-article"))
6732 (set-buffer gnus-summary-buffer)
6733 (if (or (and gnus-single-article-buffer
6734 (or (null gnus-current-article)
6735 (null gnus-article-current)
6736 (null (get-buffer gnus-article-buffer))
6737 (not (eq article (cdr gnus-article-current)))
6738 (not (equal (car gnus-article-current)
6739 gnus-newsgroup-name))))
6740 (and (not gnus-single-article-buffer)
6741 (or (null gnus-current-article)
6742 (not (eq gnus-current-article article))))
6744 ;; The requested article is different from the current article.
6746 (gnus-summary-display-article article all-headers)
6747 (when (gnus-buffer-live-p gnus-article-buffer)
6748 (with-current-buffer gnus-article-buffer
6749 (if (not gnus-article-decoded-p) ;; a local variable
6750 (mm-disable-multibyte))))
6751 (gnus-article-set-window-start
6752 (cdr (assq article gnus-newsgroup-bookmarks)))
6756 (defun gnus-summary-force-verify-and-decrypt ()
6758 (let ((mm-verify-option 'known)
6759 (mm-decrypt-option 'known)
6760 (gnus-buttonized-mime-types (append (list "multipart/signed"
6761 "multipart/encrypted")
6762 gnus-buttonized-mime-types)))
6763 (gnus-summary-select-article nil 'force)))
6765 (defun gnus-summary-set-current-mark (&optional current-mark)
6766 "Obsolete function."
6769 (defun gnus-summary-next-article (&optional unread subject backward push)
6770 "Select the next article.
6771 If UNREAD, only unread articles are selected.
6772 If SUBJECT, only articles with SUBJECT are selected.
6773 If BACKWARD, the previous article is selected instead of the next."
6776 ;; Is there such an article?
6777 ((and (gnus-summary-search-forward unread subject backward)
6778 (or (gnus-summary-display-article (gnus-summary-article-number))
6779 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6780 (gnus-summary-position-point))
6781 ;; If not, we try the first unread, if that is wanted.
6783 gnus-auto-select-same
6784 (gnus-summary-first-unread-article))
6785 (gnus-summary-position-point)
6786 (gnus-message 6 "Wrapped"))
6787 ;; Try to get next/previous article not displayed in this group.
6788 ((and gnus-auto-extend-newsgroup
6789 (not unread) (not subject))
6790 (gnus-summary-goto-article
6791 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6792 nil (count-lines (point-min) (point))))
6793 ;; Go to next/previous group.
6795 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6796 (gnus-summary-jump-to-group gnus-newsgroup-name))
6797 (let ((cmd last-command-char)
6800 (set-buffer gnus-group-buffer)
6803 (if (eq gnus-keep-same-level 'best)
6804 (gnus-summary-best-group gnus-newsgroup-name)
6805 (gnus-summary-search-group backward gnus-keep-same-level))))
6806 ;; For some reason, the group window gets selected. We change
6808 (select-window (get-buffer-window (current-buffer)))
6809 ;; Select next unread newsgroup automagically.
6811 ((or (not gnus-auto-select-next)
6813 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6814 ((or (eq gnus-auto-select-next 'quietly)
6815 (and (eq gnus-auto-select-next 'slightly-quietly)
6817 (and (eq gnus-auto-select-next 'almost-quietly)
6818 (gnus-summary-last-article-p)))
6820 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6822 (gnus-message 7 "No more%s articles (%s)..."
6823 (if unread " unread" "")
6824 (if group (concat "selecting " group)
6826 (gnus-summary-next-group nil group backward)))
6828 (when (gnus-key-press-event-p last-input-event)
6829 (gnus-summary-walk-group-buffer
6830 gnus-newsgroup-name cmd unread backward point))))))))
6832 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6833 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6834 (?\C-p (gnus-group-prev-unread-group 1))))
6835 (cursor-in-echo-area t)
6836 keve key group ended)
6838 (set-buffer gnus-group-buffer)
6841 (if (eq gnus-keep-same-level 'best)
6842 (gnus-summary-best-group gnus-newsgroup-name)
6843 (gnus-summary-search-group backward gnus-keep-same-level))))
6846 5 "No more%s articles%s" (if unread " unread" "")
6848 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6849 (format " (Type %s for %s [%s])"
6850 (single-key-description cmd) group
6851 (car (gnus-gethash group gnus-newsrc-hashtb)))
6852 (format " (Type %s to exit %s)"
6853 (single-key-description cmd)
6854 gnus-newsgroup-name)))
6855 ;; Confirm auto selection.
6856 (setq key (car (setq keve (gnus-read-event-char))))
6859 ((assq key keystrokes)
6860 (let ((obuf (current-buffer)))
6861 (switch-to-buffer gnus-group-buffer)
6863 (gnus-group-jump-to-group group))
6864 (eval (cadr (assq key keystrokes)))
6865 (setq group (gnus-group-group-name))
6866 (switch-to-buffer obuf))
6870 (gnus-ephemeral-group-p gnus-newsgroup-name))
6872 (gnus-summary-next-group nil group backward)))
6874 (push (cdr keve) unread-command-events))))))
6876 (defun gnus-summary-next-unread-article ()
6877 "Select unread article after current one."
6879 (gnus-summary-next-article
6880 (or (not (eq gnus-summary-goto-unread 'never))
6881 (gnus-summary-last-article-p (gnus-summary-article-number)))
6882 (and gnus-auto-select-same
6883 (gnus-summary-article-subject))))
6885 (defun gnus-summary-prev-article (&optional unread subject)
6886 "Select the article after the current one.
6887 If UNREAD is non-nil, only unread articles are selected."
6889 (gnus-summary-next-article unread subject t))
6891 (defun gnus-summary-prev-unread-article ()
6892 "Select unread article before current one."
6894 (gnus-summary-prev-article
6895 (or (not (eq gnus-summary-goto-unread 'never))
6896 (gnus-summary-first-article-p (gnus-summary-article-number)))
6897 (and gnus-auto-select-same
6898 (gnus-summary-article-subject))))
6900 (defun gnus-summary-next-page (&optional lines circular)
6901 "Show next page of the selected article.
6902 If at the end of the current article, select the next article.
6903 LINES says how many lines should be scrolled up.
6905 If CIRCULAR is non-nil, go to the start of the article instead of
6906 selecting the next article when reaching the end of the current
6909 (setq gnus-summary-buffer (current-buffer))
6910 (gnus-set-global-variables)
6911 (let ((article (gnus-summary-article-number))
6912 (article-window (get-buffer-window gnus-article-buffer t))
6914 ;; If the buffer is empty, we have no article.
6916 (error "No article to select"))
6917 (gnus-configure-windows 'article)
6918 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6919 (if (and (eq gnus-summary-goto-unread 'never)
6920 (not (gnus-summary-last-article-p article)))
6921 (gnus-summary-next-article)
6922 (gnus-summary-next-unread-article))
6923 (if (or (null gnus-current-article)
6924 (null gnus-article-current)
6925 (/= article (cdr gnus-article-current))
6926 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6927 ;; Selected subject is different from current article's.
6928 (gnus-summary-display-article article)
6929 (when article-window
6930 (gnus-eval-in-buffer-window gnus-article-buffer
6931 (setq endp (gnus-article-next-page lines)))
6934 (gnus-summary-beginning-of-article))
6936 (gnus-message 3 "End of message"))
6938 (if (and (eq gnus-summary-goto-unread 'never)
6939 (not (gnus-summary-last-article-p article)))
6940 (gnus-summary-next-article)
6941 (gnus-summary-next-unread-article))))))))
6942 (gnus-summary-recenter)
6943 (gnus-summary-position-point)))
6945 (defun gnus-summary-prev-page (&optional lines move)
6946 "Show previous page of selected article.
6947 Argument LINES specifies lines to be scrolled down.
6948 If MOVE, move to the previous unread article if point is at
6949 the beginning of the buffer."
6951 (let ((article (gnus-summary-article-number))
6952 (article-window (get-buffer-window gnus-article-buffer t))
6954 (gnus-configure-windows 'article)
6955 (if (or (null gnus-current-article)
6956 (null gnus-article-current)
6957 (/= article (cdr gnus-article-current))
6958 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6959 ;; Selected subject is different from current article's.
6960 (gnus-summary-display-article article)
6961 (gnus-summary-recenter)
6962 (when article-window
6963 (gnus-eval-in-buffer-window gnus-article-buffer
6964 (setq endp (gnus-article-prev-page lines)))
6965 (when (and move endp)
6967 (gnus-message 3 "Beginning of message"))
6969 (if (and (eq gnus-summary-goto-unread 'never)
6970 (not (gnus-summary-first-article-p article)))
6971 (gnus-summary-prev-article)
6972 (gnus-summary-prev-unread-article))))))))
6973 (gnus-summary-position-point))
6975 (defun gnus-summary-prev-page-or-article (&optional lines)
6976 "Show previous page of selected article.
6977 Argument LINES specifies lines to be scrolled down.
6978 If at the beginning of the article, go to the next article."
6980 (gnus-summary-prev-page lines t))
6982 (defun gnus-summary-scroll-up (lines)
6983 "Scroll up (or down) one line current article.
6984 Argument LINES specifies lines to be scrolled up (or down if negative)."
6986 (gnus-configure-windows 'article)
6987 (gnus-summary-show-thread)
6988 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6989 (gnus-eval-in-buffer-window gnus-article-buffer
6991 (when (gnus-article-next-page lines)
6992 (gnus-message 3 "End of message")))
6994 (gnus-article-prev-page (- lines))))))
6995 (gnus-summary-recenter)
6996 (gnus-summary-position-point))
6998 (defun gnus-summary-scroll-down (lines)
6999 "Scroll down (or up) one line current article.
7000 Argument LINES specifies lines to be scrolled down (or up if negative)."
7002 (gnus-summary-scroll-up (- lines)))
7004 (defun gnus-summary-next-same-subject ()
7005 "Select next article which has the same subject as current one."
7007 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7009 (defun gnus-summary-prev-same-subject ()
7010 "Select previous article which has the same subject as current one."
7012 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7014 (defun gnus-summary-next-unread-same-subject ()
7015 "Select next unread article which has the same subject as current one."
7017 (gnus-summary-next-article t (gnus-summary-article-subject)))
7019 (defun gnus-summary-prev-unread-same-subject ()
7020 "Select previous unread article which has the same subject as current one."
7022 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7024 (defun gnus-summary-first-unread-article ()
7025 "Select the first unread article.
7026 Return nil if there are no unread articles."
7029 (when (gnus-summary-first-subject t)
7030 (gnus-summary-show-thread)
7031 (gnus-summary-first-subject t)
7032 (gnus-summary-display-article (gnus-summary-article-number)))
7033 (gnus-summary-position-point)))
7035 (defun gnus-summary-first-unread-subject ()
7036 "Place the point on the subject line of the first unread article.
7037 Return nil if there are no unread articles."
7040 (when (gnus-summary-first-subject t)
7041 (gnus-summary-show-thread)
7042 (gnus-summary-first-subject t))
7043 (gnus-summary-position-point)))
7045 (defun gnus-summary-first-unseen-subject ()
7046 "Place the point on the subject line of the first unseen article.
7047 Return nil if there are no unseen articles."
7050 (when (gnus-summary-first-subject t t t)
7051 (gnus-summary-show-thread)
7052 (gnus-summary-first-subject t t t))
7053 (gnus-summary-position-point)))
7055 (defun gnus-summary-first-unseen-or-unread-subject ()
7056 "Place the point on the subject line of the first unseen article.
7057 Return nil if there are no unseen articles."
7060 (unless (when (gnus-summary-first-subject t t t)
7061 (gnus-summary-show-thread)
7062 (gnus-summary-first-subject t t t))
7063 (when (gnus-summary-first-subject t)
7064 (gnus-summary-show-thread)
7065 (gnus-summary-first-subject t)))
7066 (gnus-summary-position-point)))
7068 (defun gnus-summary-first-article ()
7069 "Select the first article.
7070 Return nil if there are no articles."
7073 (when (gnus-summary-first-subject)
7074 (gnus-summary-show-thread)
7075 (gnus-summary-first-subject)
7076 (gnus-summary-display-article (gnus-summary-article-number)))
7077 (gnus-summary-position-point)))
7079 (defun gnus-summary-best-unread-article (&optional arg)
7080 "Select the unread article with the highest score.
7081 If given a prefix argument, select the next unread article that has a
7082 score higher than the default score."
7084 (let ((article (if arg
7085 (gnus-summary-better-unread-subject)
7086 (gnus-summary-best-unread-subject))))
7088 (gnus-summary-goto-article article)
7089 (error "No unread articles"))))
7091 (defun gnus-summary-best-unread-subject ()
7092 "Select the unread subject with the highest score."
7094 (let ((best -1000000)
7095 (data gnus-newsgroup-data)
7098 (and (gnus-data-unread-p (car data))
7100 (gnus-summary-article-score (gnus-data-number (car data))))
7103 article (gnus-data-number (car data))))
7104 (setq data (cdr data)))
7106 (gnus-summary-goto-subject article))
7107 (gnus-summary-position-point)
7110 (defun gnus-summary-better-unread-subject ()
7111 "Select the first unread subject that has a score over the default score."
7113 (let ((data gnus-newsgroup-data)
7115 (while (and (setq article (gnus-data-number (car data)))
7116 (or (gnus-data-read-p (car data))
7117 (not (> (gnus-summary-article-score article)
7118 gnus-summary-default-score))))
7119 (setq data (cdr data)))
7121 (gnus-summary-goto-subject article))
7122 (gnus-summary-position-point)
7125 (defun gnus-summary-last-subject ()
7126 "Go to the last displayed subject line in the group."
7127 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7129 (gnus-summary-goto-subject article))))
7131 (defun gnus-summary-goto-article (article &optional all-headers force)
7132 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7133 If ALL-HEADERS is non-nil, no header lines are hidden.
7134 If FORCE, go to the article even if it isn't displayed. If FORCE
7135 is a number, it is the line the article is to be displayed on."
7139 "Article number or Message-ID: "
7140 (mapcar (lambda (number) (list (int-to-string number)))
7141 gnus-newsgroup-limit))
7145 (if (and (stringp article)
7146 (string-match "@" article))
7147 (gnus-summary-refer-article article)
7148 (when (stringp article)
7149 (setq article (string-to-number article)))
7150 (if (gnus-summary-goto-subject article force)
7151 (gnus-summary-display-article article all-headers)
7152 (gnus-message 4 "Couldn't go to article %s" article) nil))
7153 (gnus-summary-position-point)))
7155 (defun gnus-summary-goto-last-article ()
7156 "Go to the previously read article."
7159 (when gnus-last-article
7160 (gnus-summary-goto-article gnus-last-article nil t))
7161 (gnus-summary-position-point)))
7163 (defun gnus-summary-pop-article (number)
7164 "Pop one article off the history and go to the previous.
7165 NUMBER articles will be popped off."
7168 (setq gnus-newsgroup-history
7169 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7171 (gnus-summary-goto-article (car to) nil t)
7172 (error "Article history empty")))
7173 (gnus-summary-position-point))
7175 ;; Summary commands and functions for limiting the summary buffer.
7177 (defun gnus-summary-limit-to-articles (n)
7178 "Limit the summary buffer to the next N articles.
7179 If not given a prefix, use the process marked articles instead."
7182 (let ((articles (gnus-summary-work-articles n)))
7183 (setq gnus-newsgroup-processable nil)
7184 (gnus-summary-limit articles))
7185 (gnus-summary-position-point)))
7187 (defun gnus-summary-pop-limit (&optional total)
7188 "Restore the previous limit.
7189 If given a prefix, remove all limits."
7192 (setq gnus-newsgroup-limits
7193 (list (mapcar (lambda (h) (mail-header-number h))
7194 gnus-newsgroup-headers))))
7195 (unless gnus-newsgroup-limits
7196 (error "No limit to pop"))
7198 (gnus-summary-limit nil 'pop)
7199 (gnus-summary-position-point)))
7201 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7202 "Limit the summary buffer to articles that have subjects that match a regexp.
7203 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7205 (list (read-string (if current-prefix-arg
7206 "Exclude subject (regexp): "
7207 "Limit to subject (regexp): "))
7208 nil current-prefix-arg))
7210 (setq header "subject"))
7211 (when (not (equal "" subject))
7213 (let ((articles (gnus-summary-find-matching
7214 (or header "subject") subject 'all nil nil
7217 (error "Found no matches for \"%s\"" subject))
7218 (gnus-summary-limit articles))
7219 (gnus-summary-position-point))))
7221 (defun gnus-summary-limit-to-author (from &optional not-matching)
7222 "Limit the summary buffer to articles that have authors that match a regexp.
7223 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7225 (list (read-string (if current-prefix-arg
7226 "Exclude author (regexp): "
7227 "Limit to author (regexp): "))
7228 current-prefix-arg))
7229 (gnus-summary-limit-to-subject from "from" not-matching))
7231 (defun gnus-summary-limit-to-age (age &optional younger-p)
7232 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7233 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7234 articles that are younger than AGE days."
7236 (let ((younger current-prefix-arg)
7239 (while (not days-got)
7240 (setq days (if younger
7241 (read-string "Limit to articles within (in days): ")
7242 (read-string "Limit to articles older than (in days): ")))
7243 (when (> (length days) 0)
7244 (setq days (read days)))
7250 (setq younger (not younger))
7251 (setq days (* days -1)))))
7252 (message "Please enter a number.")
7254 (list days younger)))
7256 (let ((data gnus-newsgroup-data)
7257 (cutoff (days-to-time age))
7258 articles d date is-younger)
7259 (while (setq d (pop data))
7260 (when (and (vectorp (gnus-data-header d))
7261 (setq date (mail-header-date (gnus-data-header d))))
7262 (setq is-younger (time-less-p
7263 (time-since (condition-case ()
7270 (push (gnus-data-number d) articles))))
7271 (gnus-summary-limit (nreverse articles)))
7272 (gnus-summary-position-point)))
7274 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7275 "Limit the summary buffer to articles that match an 'extra' header."
7279 (gnus-completing-read-with-default
7280 (symbol-name (car gnus-extra-headers))
7281 (if current-prefix-arg
7282 "Exclude extra header:"
7283 "Limit extra header:")
7285 (cons (symbol-name x) x))
7290 (read-string (format "%s header %s (regexp): "
7291 (if current-prefix-arg "Exclude" "Limit to")
7293 current-prefix-arg)))
7294 (when (not (equal "" regexp))
7296 (let ((articles (gnus-summary-find-matching
7297 (cons 'extra header) regexp 'all nil nil
7300 (error "Found no matches for \"%s\"" regexp))
7301 (gnus-summary-limit articles))
7302 (gnus-summary-position-point))))
7304 (defun gnus-summary-limit-to-display-predicate ()
7305 "Limit the summary buffer to the predicated in the `display' group parameter."
7307 (unless gnus-newsgroup-display
7308 (error "There is no `display' group parameter"))
7310 (dolist (number gnus-newsgroup-articles)
7311 (when (funcall gnus-newsgroup-display)
7312 (push number articles)))
7313 (gnus-summary-limit articles))
7314 (gnus-summary-position-point))
7316 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7318 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7320 (defun gnus-summary-limit-to-unread (&optional all)
7321 "Limit the summary buffer to articles that are not marked as read.
7322 If ALL is non-nil, limit strictly to unread articles."
7325 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7326 (gnus-summary-limit-to-marks
7327 ;; Concat all the marks that say that an article is read and have
7329 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7330 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7331 gnus-low-score-mark gnus-expirable-mark
7332 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7333 gnus-duplicate-mark gnus-souped-mark)
7336 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7337 (make-obsolete 'gnus-summary-delete-marked-with
7338 'gnus-summary-limit-exclude-marks)
7340 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7341 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7342 If REVERSE, limit the summary buffer to articles that are marked
7343 with MARKS. MARKS can either be a string of marks or a list of marks.
7344 Returns how many articles were removed."
7345 (interactive "sMarks: ")
7346 (gnus-summary-limit-to-marks marks t))
7348 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7349 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7350 If REVERSE (the prefix), limit the summary buffer to articles that are
7351 not marked with MARKS. MARKS can either be a string of marks or a
7353 Returns how many articles were removed."
7354 (interactive "sMarks: \nP")
7356 (let ((data gnus-newsgroup-data)
7357 (marks (if (listp marks) marks
7358 (append marks nil))) ; Transform to list.
7361 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7362 (memq (gnus-data-mark (car data)) marks))
7363 (push (gnus-data-number (car data)) articles))
7364 (setq data (cdr data)))
7365 (gnus-summary-limit articles))
7366 (gnus-summary-position-point)))
7368 (defun gnus-summary-limit-to-score (score)
7369 "Limit to articles with score at or above SCORE."
7370 (interactive "NLimit to articles with score of at least: ")
7371 (let ((data gnus-newsgroup-data)
7374 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7376 (push (gnus-data-number (car data)) articles))
7377 (setq data (cdr data)))
7379 (gnus-summary-limit articles)
7380 (gnus-summary-position-point))))
7382 (defun gnus-summary-limit-to-unseen ()
7383 "Limit to unseen articles."
7386 (gnus-summary-limit gnus-newsgroup-unseen)
7387 (gnus-summary-position-point)))
7389 (defun gnus-summary-limit-include-thread (id)
7390 "Display all the hidden articles that is in the thread with ID in it.
7391 When called interactively, ID is the Message-ID of the current
7393 (interactive (list (mail-header-id (gnus-summary-article-header))))
7394 (let ((articles (gnus-articles-in-thread
7395 (gnus-id-to-thread (gnus-root-id id)))))
7397 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7398 (gnus-summary-limit-include-matching-articles
7400 (regexp-quote (gnus-simplify-subject-re
7401 (mail-header-subject (gnus-id-to-header id)))))
7402 (gnus-summary-position-point))))
7404 (defun gnus-summary-limit-include-matching-articles (header regexp)
7405 "Display all the hidden articles that have HEADERs that match REGEXP."
7406 (interactive (list (read-string "Match on header: ")
7407 (read-string "Regexp: ")))
7408 (let ((articles (gnus-find-matching-articles header regexp)))
7410 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7411 (gnus-summary-position-point))))
7413 (defun gnus-summary-limit-include-dormant ()
7414 "Display all the hidden articles that are marked as dormant.
7415 Note that this command only works on a subset of the articles currently
7416 fetched for this group."
7418 (unless gnus-newsgroup-dormant
7419 (error "There are no dormant articles in this group"))
7421 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7422 (gnus-summary-position-point)))
7424 (defun gnus-summary-limit-exclude-dormant ()
7425 "Hide all dormant articles."
7428 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7429 (gnus-summary-position-point)))
7431 (defun gnus-summary-limit-exclude-childless-dormant ()
7432 "Hide all dormant articles that have no children."
7434 (let ((data (gnus-data-list t))
7435 articles d children)
7436 ;; Find all articles that are either not dormant or have
7438 (while (setq d (pop data))
7439 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7441 (gnus-article-children (gnus-data-number d)))
7444 (when (memq (car children) articles)
7449 (push (gnus-data-number d) articles)))
7452 (gnus-summary-limit articles)
7453 (gnus-summary-position-point))))
7455 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7456 "Mark all unread excluded articles as read.
7457 If ALL, mark even excluded ticked and dormants as read."
7459 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7460 (let ((articles (gnus-sorted-ndifference
7462 (mapcar (lambda (h) (mail-header-number h))
7463 gnus-newsgroup-headers)
7465 gnus-newsgroup-limit))
7467 (setq gnus-newsgroup-unreads
7468 (gnus-sorted-intersection gnus-newsgroup-unreads
7469 gnus-newsgroup-limit))
7471 (setq gnus-newsgroup-dormant nil
7472 gnus-newsgroup-marked nil
7473 gnus-newsgroup-reads
7475 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7476 gnus-newsgroup-reads))
7477 (while (setq article (pop articles))
7478 (unless (or (memq article gnus-newsgroup-dormant)
7479 (memq article gnus-newsgroup-marked))
7480 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7482 (defun gnus-summary-limit (articles &optional pop)
7484 ;; We pop the previous limit off the stack and use that.
7485 (setq articles (car gnus-newsgroup-limits)
7486 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7487 ;; We use the new limit, so we push the old limit on the stack.
7488 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7490 (setq gnus-newsgroup-limit articles)
7491 (let ((total (length gnus-newsgroup-data))
7492 (data (gnus-data-find-list (gnus-summary-article-number)))
7493 (gnus-summary-mark-below nil) ; Inhibit this.
7495 ;; This will do all the work of generating the new summary buffer
7496 ;; according to the new limit.
7497 (gnus-summary-prepare)
7498 ;; Hide any threads, possibly.
7499 (gnus-summary-maybe-hide-threads)
7500 ;; Try to return to the article you were at, or one in the
7503 ;; We try to find some article after the current one.
7505 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7508 (setq data (cdr data))))
7510 ;; If there is no data, that means that we were after the last
7511 ;; article. The same goes when we can't find any articles
7512 ;; after the current one.
7513 (goto-char (point-max))
7514 (gnus-summary-find-prev))
7515 (gnus-set-mode-line 'summary)
7516 ;; We return how many articles were removed from the summary
7517 ;; buffer as a result of the new limit.
7518 (- total (length gnus-newsgroup-data))))
7520 (defsubst gnus-invisible-cut-children (threads)
7523 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7528 (defsubst gnus-cut-thread (thread)
7529 "Go forwards in the thread until we find an article that we want to display."
7530 (when (or (eq gnus-fetch-old-headers 'some)
7531 (eq gnus-fetch-old-headers 'invisible)
7532 (numberp gnus-fetch-old-headers)
7533 (eq gnus-build-sparse-threads 'some)
7534 (eq gnus-build-sparse-threads 'more))
7535 ;; Deal with old-fetched headers and sparse threads.
7539 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7540 (gnus-summary-article-ancient-p
7541 (mail-header-number (car thread))))
7542 (if (or (<= (length (cdr thread)) 1)
7543 (eq gnus-fetch-old-headers 'invisible))
7544 (setq gnus-newsgroup-limit
7545 (delq (mail-header-number (car thread))
7546 gnus-newsgroup-limit)
7547 thread (cadr thread))
7548 (when (gnus-invisible-cut-children (cdr thread))
7549 (let ((th (cdr thread)))
7551 (if (memq (mail-header-number (caar th))
7552 gnus-newsgroup-limit)
7553 (setq thread (car th)
7555 (setq th (cdr th))))))))))
7558 (defun gnus-cut-threads (threads)
7559 "Cut off all uninteresting articles from the beginning of threads."
7560 (when (or (eq gnus-fetch-old-headers 'some)
7561 (eq gnus-fetch-old-headers 'invisible)
7562 (numberp gnus-fetch-old-headers)
7563 (eq gnus-build-sparse-threads 'some)
7564 (eq gnus-build-sparse-threads 'more))
7567 (setcar th (gnus-cut-thread (car th)))
7568 (setq th (cdr th)))))
7569 ;; Remove nixed out threads.
7572 (defun gnus-summary-initial-limit (&optional show-if-empty)
7573 "Figure out what the initial limit is supposed to be on group entry.
7574 This entails weeding out unwanted dormants, low-scored articles,
7575 fetch-old-headers verbiage, and so on."
7576 ;; Most groups have nothing to remove.
7577 (if (or gnus-inhibit-limiting
7578 (and (null gnus-newsgroup-dormant)
7579 (eq gnus-newsgroup-display 'gnus-not-ignore)
7580 (not (eq gnus-fetch-old-headers 'some))
7581 (not (numberp gnus-fetch-old-headers))
7582 (not (eq gnus-fetch-old-headers 'invisible))
7583 (null gnus-summary-expunge-below)
7584 (not (eq gnus-build-sparse-threads 'some))
7585 (not (eq gnus-build-sparse-threads 'more))
7586 (null gnus-thread-expunge-below)
7587 (not gnus-use-nocem)))
7589 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7590 (setq gnus-newsgroup-limit nil)
7593 (unless (car (symbol-value node))
7594 ;; These threads have no parents -- they are roots.
7595 (let ((nodes (cdr (symbol-value node)))
7598 (if (and gnus-thread-expunge-below
7599 (< (gnus-thread-total-score (car nodes))
7600 gnus-thread-expunge-below))
7601 (gnus-expunge-thread (pop nodes))
7602 (setq thread (pop nodes))
7603 (gnus-summary-limit-children thread))))))
7604 gnus-newsgroup-dependencies)
7605 ;; If this limitation resulted in an empty group, we might
7606 ;; pop the previous limit and use it instead.
7607 (when (and (not gnus-newsgroup-limit)
7609 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7610 gnus-newsgroup-limit))
7612 (defun gnus-summary-limit-children (thread)
7613 "Return 1 if this subthread is visible and 0 if it is not."
7614 ;; First we get the number of visible children to this thread. This
7615 ;; is done by recursing down the thread using this function, so this
7616 ;; will really go down to a leaf article first, before slowly
7617 ;; working its way up towards the root.
7621 (apply '+ (mapcar 'gnus-summary-limit-children
7624 (number (mail-header-number (car thread)))
7627 (not (memq number gnus-newsgroup-marked))
7629 ;; If this article is dormant and has absolutely no visible
7630 ;; children, then this article isn't visible.
7631 (and (memq number gnus-newsgroup-dormant)
7633 ;; If this is "fetch-old-headered" and there is no
7634 ;; visible children, then we don't want this article.
7635 (and (or (eq gnus-fetch-old-headers 'some)
7636 (numberp gnus-fetch-old-headers))
7637 (gnus-summary-article-ancient-p number)
7639 ;; If this is "fetch-old-headered" and `invisible', then
7640 ;; we don't want this article.
7641 (and (eq gnus-fetch-old-headers 'invisible)
7642 (gnus-summary-article-ancient-p number))
7643 ;; If this is a sparsely inserted article with no children,
7644 ;; we don't want it.
7645 (and (eq gnus-build-sparse-threads 'some)
7646 (gnus-summary-article-sparse-p number)
7648 ;; If we use expunging, and this article is really
7649 ;; low-scored, then we don't want this article.
7650 (when (and gnus-summary-expunge-below
7652 (or (cdr (assq number gnus-newsgroup-scored))
7653 gnus-summary-default-score))
7654 gnus-summary-expunge-below))
7655 ;; We increase the expunge-tally here, but that has
7656 ;; nothing to do with the limits, really.
7657 (incf gnus-newsgroup-expunged-tally)
7658 ;; We also mark as read here, if that's wanted.
7659 (when (and gnus-summary-mark-below
7660 (< score gnus-summary-mark-below))
7661 (setq gnus-newsgroup-unreads
7662 (delq number gnus-newsgroup-unreads))
7663 (if gnus-newsgroup-auto-expire
7664 (push number gnus-newsgroup-expirable)
7665 (push (cons number gnus-low-score-mark)
7666 gnus-newsgroup-reads)))
7668 ;; Do the `display' group parameter.
7669 (and gnus-newsgroup-display
7670 (not (funcall gnus-newsgroup-display)))
7671 ;; Check NoCeM things.
7672 (if (and gnus-use-nocem
7673 (gnus-nocem-unwanted-article-p
7674 (mail-header-id (car thread))))
7676 (setq gnus-newsgroup-unreads
7677 (delq number gnus-newsgroup-unreads))
7679 ;; Nope, invisible article.
7681 ;; Ok, this article is to be visible, so we add it to the limit
7683 (push number gnus-newsgroup-limit)
7686 (defun gnus-expunge-thread (thread)
7687 "Mark all articles in THREAD as read."
7688 (let* ((number (mail-header-number (car thread))))
7689 (incf gnus-newsgroup-expunged-tally)
7690 ;; We also mark as read here, if that's wanted.
7691 (setq gnus-newsgroup-unreads
7692 (delq number gnus-newsgroup-unreads))
7693 (if gnus-newsgroup-auto-expire
7694 (push number gnus-newsgroup-expirable)
7695 (push (cons number gnus-low-score-mark)
7696 gnus-newsgroup-reads)))
7697 ;; Go recursively through all subthreads.
7698 (mapcar 'gnus-expunge-thread (cdr thread)))
7700 ;; Summary article oriented commands
7702 (defun gnus-summary-refer-parent-article (n)
7703 "Refer parent article N times.
7704 If N is negative, go to ancestor -N instead.
7705 The difference between N and the number of articles fetched is returned."
7709 (when (not (natnump n))
7714 (setq header (gnus-summary-article-header))
7715 (if (and (eq (mail-header-number header)
7716 (cdr gnus-article-current))
7717 (equal gnus-newsgroup-name
7718 (car gnus-article-current)))
7719 ;; If we try to find the parent of the currently
7720 ;; displayed article, then we take a look at the actual
7721 ;; References header, since this is slightly more
7722 ;; reliable than the References field we got from the
7725 (set-buffer gnus-original-article-buffer)
7726 (nnheader-narrow-to-headers)
7727 (unless (setq ref (message-fetch-field "references"))
7728 (setq ref (message-fetch-field "in-reply-to")))
7731 ;; It's not the current article, so we take a bet on
7732 ;; the value we got from the server.
7733 (mail-header-references header)))
7735 (not (equal ref "")))
7736 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7737 (gnus-message 1 "Couldn't find parent"))
7738 (gnus-message 1 "No references in article %d"
7739 (gnus-summary-article-number))
7742 (gnus-summary-position-point)
7745 (defun gnus-summary-refer-references ()
7746 "Fetch all articles mentioned in the References header.
7747 Return the number of articles fetched."
7749 (let ((ref (mail-header-references (gnus-summary-article-header)))
7750 (current (gnus-summary-article-number))
7754 (error "No References in the current article")
7755 ;; For each Message-ID in the References header...
7756 (while (string-match "<[^>]*>" ref)
7758 ;; ... fetch that article.
7759 (gnus-summary-refer-article
7760 (prog1 (match-string 0 ref)
7761 (setq ref (substring ref (match-end 0))))))
7762 (gnus-summary-goto-subject current)
7763 (gnus-summary-position-point)
7766 (defun gnus-summary-refer-thread (&optional limit)
7767 "Fetch all articles in the current thread.
7768 If LIMIT (the numerical prefix), fetch that many old headers instead
7769 of what's specified by the `gnus-refer-thread-limit' variable."
7771 (let ((id (mail-header-id (gnus-summary-article-header)))
7772 (limit (if limit (prefix-numeric-value limit)
7773 gnus-refer-thread-limit)))
7774 ;; We want to fetch LIMIT *old* headers, but we also have to
7775 ;; re-fetch all the headers in the current buffer, because many of
7776 ;; them may be undisplayed. So we adjust LIMIT.
7777 (when (numberp limit)
7778 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7779 (unless (eq gnus-fetch-old-headers 'invisible)
7780 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7781 ;; Retrieve the headers and read them in.
7782 (if (eq (gnus-retrieve-headers
7783 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7785 (gnus-build-all-threads)
7786 (error "Can't fetch thread from backends that don't support NOV"))
7787 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7788 (gnus-summary-limit-include-thread id)))
7790 (defun gnus-summary-refer-article (message-id)
7791 "Fetch an article specified by MESSAGE-ID."
7792 (interactive "sMessage-ID: ")
7793 (when (and (stringp message-id)
7794 (not (zerop (length message-id))))
7795 ;; Construct the correct Message-ID if necessary.
7796 ;; Suggested by tale@pawl.rpi.edu.
7797 (unless (string-match "^<" message-id)
7798 (setq message-id (concat "<" message-id)))
7799 (unless (string-match ">$" message-id)
7800 (setq message-id (concat message-id ">")))
7801 (let* ((header (gnus-id-to-header message-id))
7803 (gnus-summary-article-sparse-p
7804 (mail-header-number header))
7805 (memq (mail-header-number header)
7806 gnus-newsgroup-limit)))
7809 ;; If the article is present in the buffer we just go to it.
7811 (or (not (gnus-summary-article-sparse-p
7812 (mail-header-number header)))
7815 (gnus-summary-goto-article
7816 (mail-header-number header) nil t)
7818 (gnus-summary-update-article (mail-header-number header)))))
7820 ;; We fetch the article.
7822 (dolist (gnus-override-method (gnus-refer-article-methods))
7823 (gnus-check-server gnus-override-method)
7824 ;; Fetch the header, and display the article.
7825 (when (setq number (gnus-summary-insert-subject message-id))
7826 (gnus-summary-select-article nil nil nil number)
7828 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7830 (defun gnus-refer-article-methods ()
7831 "Return a list of referrable methods."
7833 ;; No method, so we default to current and native.
7834 ((null gnus-refer-article-method)
7835 (list gnus-current-select-method gnus-select-method))
7837 ((eq 'current gnus-refer-article-method)
7838 (list gnus-current-select-method))
7839 ;; List of select methods.
7840 ((not (and (symbolp (car gnus-refer-article-method))
7841 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7843 (dolist (method gnus-refer-article-method)
7844 (push (if (eq 'current method)
7845 gnus-current-select-method
7849 ;; One single select method.
7851 (list gnus-refer-article-method))))
7853 (defun gnus-summary-edit-parameters ()
7854 "Edit the group parameters of the current group."
7856 (gnus-group-edit-group gnus-newsgroup-name 'params))
7858 (defun gnus-summary-customize-parameters ()
7859 "Customize the group parameters of the current group."
7861 (gnus-group-customize gnus-newsgroup-name))
7863 (defun gnus-summary-enter-digest-group (&optional force)
7864 "Enter an nndoc group based on the current article.
7865 If FORCE, force a digest interpretation. If not, try
7866 to guess what the document format is."
7868 (let ((conf gnus-current-window-configuration))
7870 (gnus-summary-select-article))
7871 (setq gnus-current-window-configuration conf)
7872 (let* ((name (format "%s-%d"
7873 (gnus-group-prefixed-name
7874 gnus-newsgroup-name (list 'nndoc ""))
7876 (set-buffer gnus-summary-buffer)
7877 gnus-current-article)))
7878 (ogroup gnus-newsgroup-name)
7879 (params (append (gnus-info-params (gnus-get-info ogroup))
7880 (list (cons 'to-group ogroup))
7881 (list (cons 'save-article-group ogroup))))
7882 (case-fold-search t)
7883 (buf (current-buffer))
7886 (set-buffer gnus-original-article-buffer)
7887 ;; Have the digest group inherit the main mail address of
7888 ;; the parent article.
7889 (when (setq to-address (or (gnus-fetch-field "reply-to")
7890 (gnus-fetch-field "from")))
7891 (setq params (append
7892 (list (cons 'to-address
7893 (funcall gnus-decode-encoded-word-function
7895 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7896 (insert-buffer-substring gnus-original-article-buffer)
7897 ;; Remove lines that may lead nndoc to misinterpret the
7900 (goto-char (point-min))
7901 (or (search-forward "\n\n" nil t) (point)))
7902 (goto-char (point-min))
7903 (delete-matching-lines "^Path:\\|^From ")
7906 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7907 (gnus-newsgroup-ephemeral-ignored-charsets
7908 gnus-newsgroup-ignored-charsets))
7909 (gnus-group-read-ephemeral-group
7910 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7912 ,(if force 'mbox 'guess)))
7914 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7916 ;; Make all postings to this group go to the parent group.
7917 (nconc (gnus-info-params (gnus-get-info name))
7919 ;; Couldn't select this doc group.
7920 (switch-to-buffer buf)
7921 (gnus-set-global-variables)
7922 (gnus-configure-windows 'summary)
7923 (gnus-message 3 "Article couldn't be entered?"))
7924 (kill-buffer dig)))))
7926 (defun gnus-summary-read-document (n)
7927 "Open a new group based on the current article(s).
7928 This will allow you to read digests and other similar
7929 documents as newsgroups.
7930 Obeys the standard process/prefix convention."
7932 (let* ((articles (gnus-summary-work-articles n))
7933 (ogroup gnus-newsgroup-name)
7934 (params (append (gnus-info-params (gnus-get-info ogroup))
7935 (list (cons 'to-group ogroup))))
7936 article group egroup groups vgroup)
7937 (while (setq article (pop articles))
7938 (setq group (format "%s-%d" gnus-newsgroup-name article))
7939 (gnus-summary-remove-process-mark article)
7940 (when (gnus-summary-display-article article)
7943 (insert-buffer-substring gnus-original-article-buffer)
7944 ;; Remove some headers that may lead nndoc to make
7946 (message-narrow-to-head)
7947 (goto-char (point-min))
7948 (delete-matching-lines "^\\(Path\\):\\|^From ")
7951 (gnus-group-read-ephemeral-group
7952 group `(nndoc ,group (nndoc-address ,(current-buffer))
7953 (nndoc-article-type guess))
7956 ;; Make all postings to this group go to the parent group.
7957 (nconc (gnus-info-params (gnus-get-info egroup))
7959 (push egroup groups))
7960 ;; Couldn't select this doc group.
7961 (gnus-error 3 "Article couldn't be entered"))))))
7962 ;; Now we have selected all the documents.
7965 (error "None of the articles could be interpreted as documents"))
7966 ((gnus-group-read-ephemeral-group
7967 (setq vgroup (format
7968 "nnvirtual:%s-%s" gnus-newsgroup-name
7969 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7970 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7972 (cons (current-buffer) 'summary)))
7974 (error "Couldn't select virtual nndoc group")))))
7976 (defun gnus-summary-isearch-article (&optional regexp-p)
7977 "Do incremental search forward on the current article.
7978 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7980 (gnus-summary-select-article)
7981 (gnus-configure-windows 'article)
7982 (gnus-eval-in-buffer-window gnus-article-buffer
7985 (isearch-forward regexp-p))))
7987 (defun gnus-summary-search-article-forward (regexp &optional backward)
7988 "Search for an article containing REGEXP forward.
7989 If BACKWARD, search backward instead."
7992 (format "Search article %s (regexp%s): "
7993 (if current-prefix-arg "backward" "forward")
7994 (if gnus-last-search-regexp
7995 (concat ", default " gnus-last-search-regexp)
7997 current-prefix-arg))
7998 (if (string-equal regexp "")
7999 (setq regexp (or gnus-last-search-regexp ""))
8000 (setq gnus-last-search-regexp regexp)
8001 (setq gnus-article-before-search gnus-current-article))
8002 ;; Intentionally set gnus-last-article.
8003 (setq gnus-last-article gnus-article-before-search)
8004 (let ((gnus-last-article gnus-last-article))
8005 (if (gnus-summary-search-article regexp backward)
8006 (gnus-summary-show-thread)
8007 (error "Search failed: \"%s\"" regexp))))
8009 (defun gnus-summary-search-article-backward (regexp)
8010 "Search for an article containing REGEXP backward."
8013 (format "Search article backward (regexp%s): "
8014 (if gnus-last-search-regexp
8015 (concat ", default " gnus-last-search-regexp)
8017 (gnus-summary-search-article-forward regexp 'backward))
8019 (defun gnus-summary-search-article (regexp &optional backward)
8020 "Search for an article containing REGEXP.
8021 Optional argument BACKWARD means do search for backward.
8022 `gnus-select-article-hook' is not called during the search."
8023 ;; We have to require this here to make sure that the following
8024 ;; dynamic binding isn't shadowed by autoloading.
8025 (require 'gnus-async)
8027 (let ((gnus-select-article-hook nil) ;Disable hook.
8028 (gnus-article-prepare-hook nil)
8029 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8030 (gnus-use-article-prefetch nil)
8031 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8032 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8033 (sum (current-buffer))
8034 (gnus-display-mime-function nil)
8037 (gnus-save-hidden-threads
8038 (gnus-summary-select-article)
8039 (set-buffer gnus-article-buffer)
8040 (goto-char (window-point (get-buffer-window (current-buffer))))
8044 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8046 (re-search-backward regexp nil t)
8047 (re-search-forward regexp nil t))
8048 ;; We found the regexp.
8053 (get-buffer-window (current-buffer))
8057 (get-buffer-window (current-buffer))
8060 (setq point (point)))
8061 ;; We didn't find it, so we go to the next article.
8064 (while (eq found 'not)
8065 (if (not (if backward (gnus-summary-find-prev)
8066 (gnus-summary-find-next)))
8067 ;; No more articles.
8069 ;; Select the next article and adjust point.
8070 (unless (gnus-summary-article-sparse-p
8071 (gnus-summary-article-number))
8073 (gnus-summary-select-article)
8074 (set-buffer gnus-article-buffer)
8076 (goto-char (if backward (point-max) (point-min))))))))
8077 (gnus-message 7 ""))
8078 ;; Return whether we found the regexp.
8079 (when (eq found 'found)
8081 (gnus-summary-show-thread)
8082 (gnus-summary-goto-subject gnus-current-article)
8083 (gnus-summary-position-point)
8086 (defun gnus-find-matching-articles (header regexp)
8087 "Return a list of all articles that match REGEXP on HEADER.
8088 This search includes all articles in the current group that Gnus has
8089 fetched headers for, whether they are displayed or not."
8090 (let ((articles nil)
8091 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8092 (case-fold-search t))
8093 (dolist (header gnus-newsgroup-headers)
8094 (when (string-match regexp (funcall func header))
8095 (push (mail-header-number header) articles)))
8096 (nreverse articles)))
8098 (defun gnus-summary-find-matching (header regexp &optional backward unread
8099 not-case-fold not-matching)
8100 "Return a list of all articles that match REGEXP on HEADER.
8101 The search stars on the current article and goes forwards unless
8102 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8103 If UNREAD is non-nil, only unread articles will
8104 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8105 in the comparisons. If NOT-MATCHING, return a list of all articles that
8106 not match REGEXP on HEADER."
8107 (let ((case-fold-search (not not-case-fold))
8110 (if (eq (car header) 'extra)
8113 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8115 (error "%s is an invalid header" header))
8116 (unless (fboundp (intern (concat "mail-header-" header)))
8117 (error "%s is not a valid header" header))
8118 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8119 (dolist (d (if (eq backward 'all)
8121 (gnus-data-find-list
8122 (gnus-summary-article-number)
8123 (gnus-data-list backward))))
8124 (when (and (or (not unread) ; We want all articles...
8125 (gnus-data-unread-p d)) ; Or just unreads.
8126 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8130 (funcall func (gnus-data-header d))))
8131 (string-match regexp
8132 (funcall func (gnus-data-header d)))))
8133 (push (gnus-data-number d) articles))) ; Success!
8134 (nreverse articles)))
8136 (defun gnus-summary-execute-command (header regexp command &optional backward)
8137 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8138 If HEADER is an empty string (or nil), the match is done on the entire
8139 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8141 (list (let ((completion-ignore-case t))
8144 (mapcar (lambda (header) (list (format "%s" header)))
8146 '("Number" "Subject" "From" "Lines" "Date"
8147 "Message-ID" "Xref" "References" "Body")
8148 gnus-extra-headers))
8149 nil 'require-match))
8150 (read-string "Regexp: ")
8151 (read-key-sequence "Command: ")
8152 current-prefix-arg))
8153 (when (equal header "Body")
8155 ;; Hidden thread subtrees must be searched as well.
8156 (gnus-summary-show-all-threads)
8157 ;; We don't want to change current point nor window configuration.
8159 (save-window-excursion
8160 (gnus-message 6 "Executing %s..." (key-description command))
8161 ;; We'd like to execute COMMAND interactively so as to give arguments.
8162 (gnus-execute header regexp
8163 `(call-interactively ',(key-binding command))
8165 (gnus-message 6 "Executing %s...done" (key-description command)))))
8167 (defun gnus-summary-beginning-of-article ()
8168 "Scroll the article back to the beginning."
8170 (gnus-summary-select-article)
8171 (gnus-configure-windows 'article)
8172 (gnus-eval-in-buffer-window gnus-article-buffer
8174 (goto-char (point-min))
8175 (when gnus-page-broken
8176 (gnus-narrow-to-page))))
8178 (defun gnus-summary-end-of-article ()
8179 "Scroll to the end of the article."
8181 (gnus-summary-select-article)
8182 (gnus-configure-windows 'article)
8183 (gnus-eval-in-buffer-window gnus-article-buffer
8185 (goto-char (point-max))
8187 (when gnus-page-broken
8188 (gnus-narrow-to-page))))
8190 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8191 "Truncate to LEN and quote all \"(\"'s in STRING."
8192 (gnus-replace-in-string (if (and len (> (length string) len))
8193 (substring string 0 len)
8197 (defun gnus-summary-print-article (&optional filename n)
8198 "Generate and print a PostScript image of the N next (mail) articles.
8200 If N is negative, print the N previous articles. If N is nil and articles
8201 have been marked with the process mark, print these instead.
8203 If the optional first argument FILENAME is nil, send the image to the
8204 printer. If FILENAME is a string, save the PostScript image in a file with
8205 that name. If FILENAME is a number, prompt the user for the name of the file
8207 (interactive (list (ps-print-preprint current-prefix-arg)))
8208 (dolist (article (gnus-summary-work-articles n))
8209 (gnus-summary-select-article nil nil 'pseudo article)
8210 (gnus-eval-in-buffer-window gnus-article-buffer
8211 (gnus-print-buffer))
8212 (gnus-summary-remove-process-mark article))
8213 (ps-despool filename))
8215 (defun gnus-print-buffer ()
8216 (let ((buffer (generate-new-buffer " *print*")))
8219 (copy-to-buffer buffer (point-min) (point-max))
8221 (gnus-article-delete-invisible-text)
8222 (gnus-remove-text-with-property 'gnus-decoration)
8223 (when (gnus-visual-p 'article-highlight 'highlight)
8224 ;; Copy-to-buffer doesn't copy overlay. So redo
8226 (let ((gnus-article-buffer buffer))
8227 (gnus-article-highlight-citation t)
8228 (gnus-article-highlight-signature)))
8229 (let ((ps-left-header
8232 (gnus-summary-print-truncate-and-quote
8233 (mail-header-subject gnus-current-headers)
8236 (gnus-summary-print-truncate-and-quote
8237 (mail-header-from gnus-current-headers)
8241 "/pagenumberstring load"
8243 (mail-header-date gnus-current-headers) ")"))))
8244 (gnus-run-hooks 'gnus-ps-print-hook)
8247 (ps-spool-buffer-with-faces)
8248 (ps-spool-buffer)))))
8249 (kill-buffer buffer))))
8251 (defun gnus-summary-show-article (&optional arg)
8252 "Force redisplaying of the current article.
8253 If ARG (the prefix) is a number, show the article with the charset
8254 defined in `gnus-summary-show-article-charset-alist', or the charset
8256 If ARG (the prefix) is non-nil and not a number, show the raw article
8257 without any article massaging functions being run. Normally, the key strokes
8262 (gnus-summary-show-article t)
8263 (let ((gnus-newsgroup-charset
8264 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8265 (mm-read-coding-system
8266 "View as charset: " ;; actually it is coding system.
8268 (set-buffer gnus-article-buffer)
8269 (mm-detect-coding-region (point) (point-max))))))
8270 (gnus-newsgroup-ignored-charsets 'gnus-all))
8271 (gnus-summary-select-article nil 'force)
8272 (let ((deps gnus-newsgroup-dependencies)
8275 (set-buffer gnus-original-article-buffer)
8277 (message-narrow-to-head)
8278 (setq head (buffer-string))
8279 (goto-char (point-min))
8280 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8281 (goto-char (point-max))
8283 (setq lines (1- (count-lines (point) (point-max))))))
8285 (insert (format "211 %d Article retrieved.\n"
8286 (cdr gnus-article-current)))
8288 (if lines (insert (format "Lines: %d\n" lines)))
8290 (let ((nntp-server-buffer (current-buffer)))
8291 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8292 (gnus-data-set-header
8293 (gnus-data-find (cdr gnus-article-current))
8295 (gnus-summary-update-article-line
8296 (cdr gnus-article-current) header)
8297 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8298 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8300 ;; Select the article the normal way.
8301 (gnus-summary-select-article nil 'force))
8303 ;; We have to require this here to make sure that the following
8304 ;; dynamic binding isn't shadowed by autoloading.
8305 (require 'gnus-async)
8307 ;; Bind the article treatment functions to nil.
8308 (let ((gnus-have-all-headers t)
8309 gnus-article-prepare-hook
8310 gnus-article-decode-hook
8311 gnus-display-mime-function
8313 ;; Destroy any MIME parts.
8314 (when (gnus-buffer-live-p gnus-article-buffer)
8316 (set-buffer gnus-article-buffer)
8317 (mm-destroy-parts gnus-article-mime-handles)
8318 ;; Set it to nil for safety reason.
8319 (setq gnus-article-mime-handle-alist nil)
8320 (setq gnus-article-mime-handles nil)))
8321 (gnus-summary-select-article nil 'force))))
8322 (gnus-summary-goto-subject gnus-current-article)
8323 (gnus-summary-position-point))
8325 (defun gnus-summary-show-raw-article ()
8326 "Show the raw article without any article massaging functions being run."
8328 (gnus-summary-show-article t))
8330 (defun gnus-summary-verbose-headers (&optional arg)
8331 "Toggle permanent full header display.
8332 If ARG is a positive number, turn header display on.
8333 If ARG is a negative number, turn header display off."
8335 (setq gnus-show-all-headers
8336 (cond ((or (not (numberp arg))
8338 (not gnus-show-all-headers))
8341 (gnus-summary-show-article))
8343 (defun gnus-summary-toggle-header (&optional arg)
8344 "Show the headers if they are hidden, or hide them if they are shown.
8345 If ARG is a positive number, show the entire header.
8346 If ARG is a negative number, hide the unwanted header lines."
8348 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8349 (get-buffer-window gnus-article-buffer t))))
8351 (with-current-buffer gnus-article-buffer
8353 (article-narrow-to-head)
8354 (let* ((buffer-read-only nil)
8355 (inhibit-point-motion-hooks t)
8356 (hidden (if (numberp arg)
8358 (gnus-article-hidden-text-p 'headers)))
8360 (delete-region (point-min) (point-max))
8361 (with-current-buffer gnus-original-article-buffer
8362 (goto-char (setq s (point-min)))
8363 (setq e (if (search-forward "\n\n" nil t)
8366 (insert-buffer-substring gnus-original-article-buffer s e)
8367 (article-decode-encoded-words)
8369 (let ((gnus-treat-hide-headers nil)
8370 (gnus-treat-hide-boring-headers nil))
8371 (gnus-delete-wash-type 'headers)
8372 (gnus-treat-article 'head))
8373 (gnus-treat-article 'head))
8375 (set-window-start window (goto-char (point-min)))
8376 (setq gnus-page-broken
8377 (when gnus-break-pages
8378 (gnus-narrow-to-page)
8380 (gnus-set-mode-line 'article))))))
8382 (defun gnus-summary-show-all-headers ()
8383 "Make all header lines visible."
8385 (gnus-summary-toggle-header 1))
8387 (defun gnus-summary-caesar-message (&optional arg)
8388 "Caesar rotate the current article by 13.
8389 The numerical prefix specifies how many places to rotate each letter
8392 (gnus-summary-select-article)
8393 (let ((mail-header-separator ""))
8394 (gnus-eval-in-buffer-window gnus-article-buffer
8397 (let ((start (window-start))
8399 (message-caesar-buffer-body arg)
8400 (set-window-start (get-buffer-window (current-buffer)) start))))))
8402 (defun gnus-summary-stop-page-breaking ()
8403 "Stop page breaking in the current article."
8405 (gnus-summary-select-article)
8406 (gnus-eval-in-buffer-window gnus-article-buffer
8408 (when (gnus-visual-p 'page-marker)
8409 (let ((buffer-read-only nil))
8410 (gnus-remove-text-with-property 'gnus-prev)
8411 (gnus-remove-text-with-property 'gnus-next))
8412 (setq gnus-page-broken nil))))
8414 (defun gnus-summary-move-article (&optional n to-newsgroup
8415 select-method action)
8416 "Move the current article to a different newsgroup.
8417 If N is a positive number, move the N next articles.
8418 If N is a negative number, move the N previous articles.
8419 If N is nil and any articles have been marked with the process mark,
8420 move those articles instead.
8421 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8422 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8423 re-spool using this method.
8425 When called interactively with TO-NEWSGROUP being nil, the value of
8426 the variable `gnus-move-split-methods' is used for finding a default
8427 for the target newsgroup.
8429 For this function to work, both the current newsgroup and the
8430 newsgroup that you want to move to have to support the `request-move'
8431 and `request-accept' functions.
8433 ACTION can be either `move' (the default), `crosspost' or `copy'."
8436 (setq action 'move))
8437 ;; Check whether the source group supports the required functions.
8438 (cond ((and (eq action 'move)
8439 (not (gnus-check-backend-function
8440 'request-move-article gnus-newsgroup-name)))
8441 (error "The current group does not support article moving"))
8442 ((and (eq action 'crosspost)
8443 (not (gnus-check-backend-function
8444 'request-replace-article gnus-newsgroup-name)))
8445 (error "The current group does not support article editing")))
8446 (let ((articles (gnus-summary-work-articles n))
8447 (prefix (if (gnus-check-backend-function
8448 'request-move-article gnus-newsgroup-name)
8449 (gnus-group-real-prefix gnus-newsgroup-name)
8451 (names '((move "Move" "Moving")
8452 (copy "Copy" "Copying")
8453 (crosspost "Crosspost" "Crossposting")))
8454 (copy-buf (save-excursion
8455 (nnheader-set-temp-buffer " *copy article*")))
8456 art-group to-method new-xref article to-groups)
8457 (unless (assq action names)
8458 (error "Unknown action %s" action))
8459 ;; Read the newsgroup name.
8460 (when (and (not to-newsgroup)
8461 (not select-method))
8462 (if (and gnus-move-split-methods
8464 (and (memq gnus-current-article articles)
8465 (gnus-buffer-live-p gnus-original-article-buffer))))
8466 ;; When `gnus-move-split-methods' is non-nil, we have to
8467 ;; select an article to give `gnus-read-move-group-name' an
8468 ;; opportunity to suggest an appropriate default. However,
8469 ;; we needn't render or mark the article.
8470 (let ((gnus-display-mime-function nil)
8471 (gnus-article-prepare-hook nil)
8472 (gnus-mark-article-hook nil))
8473 (gnus-summary-select-article nil nil nil (car articles))))
8475 (gnus-read-move-group-name
8476 (cadr (assq action names))
8477 (symbol-value (intern (format "gnus-current-%s-group" action)))
8479 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8480 (setq to-method (or select-method
8481 (gnus-server-to-method
8482 (gnus-group-method to-newsgroup))))
8483 ;; Check the method we are to move this article to...
8484 (unless (gnus-check-backend-function
8485 'request-accept-article (car to-method))
8486 (error "%s does not support article copying" (car to-method)))
8487 (unless (gnus-check-server to-method)
8488 (error "Can't open server %s" (car to-method)))
8489 (gnus-message 6 "%s to %s: %s..."
8490 (caddr (assq action names))
8491 (or (car select-method) to-newsgroup) articles)
8493 (setq article (pop articles))
8497 ;; Move the article.
8499 ;; Remove this article from future suppression.
8500 (gnus-dup-unsuppress-article article)
8501 (gnus-request-move-article
8502 article ; Article to move
8503 gnus-newsgroup-name ; From newsgroup
8504 (nth 1 (gnus-find-method-for-group
8505 gnus-newsgroup-name)) ; Server
8506 (list 'gnus-request-accept-article
8507 to-newsgroup (list 'quote select-method)
8508 (not articles) t) ; Accept form
8509 (not articles))) ; Only save nov last time
8510 ;; Copy the article.
8513 (set-buffer copy-buf)
8514 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8515 (gnus-request-accept-article
8516 to-newsgroup select-method (not articles) t))))
8517 ;; Crosspost the article.
8518 ((eq action 'crosspost)
8519 (let ((xref (message-tokenize-header
8520 (mail-header-xref (gnus-summary-article-header article))
8522 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8523 ":" (number-to-string article)))
8525 (setq xref (list (system-name))))
8528 (mapconcat 'identity
8529 (delete "Xref:" (delete new-xref xref))
8533 (set-buffer copy-buf)
8534 ;; First put the article in the destination group.
8535 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8536 (when (consp (setq art-group
8537 (gnus-request-accept-article
8538 to-newsgroup select-method (not articles))))
8539 (setq new-xref (concat new-xref " " (car art-group)
8541 (number-to-string (cdr art-group))))
8542 ;; Now we have the new Xrefs header, so we insert
8543 ;; it and replace the new article.
8544 (nnheader-replace-header "Xref" new-xref)
8545 (gnus-request-replace-article
8546 (cdr art-group) to-newsgroup (current-buffer))
8550 (gnus-message 1 "Couldn't %s article %s: %s"
8551 (cadr (assq action names)) article
8552 (nnheader-get-report (car to-method))))
8553 ((eq art-group 'junk)
8554 (when (eq action 'move)
8555 (gnus-summary-mark-article article gnus-canceled-mark)
8556 (gnus-message 4 "Deleted article %s" article)))
8558 (let* ((pto-group (gnus-group-prefixed-name
8559 (car art-group) to-method))
8561 (gnus-gethash pto-group gnus-newsrc-hashtb))
8562 (info (nth 2 entry))
8563 (to-group (gnus-info-group info))
8565 ;; Update the group that has been moved to.
8567 (memq action '(move copy)))
8568 (unless (member to-group to-groups)
8569 (push to-group to-groups))
8571 (unless (memq article gnus-newsgroup-unreads)
8572 (push 'read to-marks)
8574 info (gnus-add-to-range (gnus-info-read info)
8575 (list (cdr art-group)))))
8577 ;; See whether the article is to be put in the cache.
8578 (let ((marks gnus-article-mark-lists)
8579 (to-article (cdr art-group)))
8581 ;; Enter the article into the cache in the new group,
8582 ;; if that is required.
8583 (when gnus-use-cache
8584 (gnus-cache-possibly-enter-article
8586 (memq article gnus-newsgroup-marked)
8587 (memq article gnus-newsgroup-dormant)
8588 (memq article gnus-newsgroup-unreads)))
8590 (when gnus-preserve-marks
8591 ;; Copy any marks over to the new group.
8592 (when (and (equal to-group gnus-newsgroup-name)
8593 (not (memq article gnus-newsgroup-unreads)))
8594 ;; Mark this article as read in this group.
8595 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8596 (setcdr (gnus-active to-group) to-article)
8597 (setcdr gnus-newsgroup-active to-article))
8600 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8601 (when (memq article (symbol-value
8602 (intern (format "gnus-newsgroup-%s"
8604 (push (cdar marks) to-marks)
8605 ;; If the other group is the same as this group,
8606 ;; then we have to add the mark to the list.
8607 (when (equal to-group gnus-newsgroup-name)
8608 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8611 (intern (format "gnus-newsgroup-%s"
8613 ;; Copy the marks to other group.
8614 (gnus-add-marked-articles
8615 to-group (cdar marks) (list to-article) info)))
8616 (setq marks (cdr marks)))
8618 (gnus-request-set-mark to-group (list (list (list to-article)
8623 (concat "(gnus-group-set-info '"
8624 (gnus-prin1-to-string (gnus-get-info to-group))
8627 ;; Update the Xref header in this article to point to
8628 ;; the new crossposted article we have just created.
8629 (when (eq action 'crosspost)
8631 (set-buffer copy-buf)
8632 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8633 (nnheader-replace-header "Xref" new-xref)
8634 (gnus-request-replace-article
8635 article gnus-newsgroup-name (current-buffer)))))
8637 ;;;!!!Why is this necessary?
8638 (set-buffer gnus-summary-buffer)
8640 (gnus-summary-goto-subject article)
8641 (when (eq action 'move)
8642 (gnus-summary-mark-article article gnus-canceled-mark))))
8643 (gnus-summary-remove-process-mark article))
8644 ;; Re-activate all groups that have been moved to.
8646 (set-buffer gnus-group-buffer)
8647 (let ((gnus-group-marked to-groups))
8648 (gnus-group-get-new-news-this-group nil t)))
8650 (gnus-kill-buffer copy-buf)
8651 (gnus-summary-position-point)
8652 (gnus-set-mode-line 'summary)))
8654 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8655 "Move the current article to a different newsgroup.
8656 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8657 When called interactively, if TO-NEWSGROUP is nil, use the value of
8658 the variable `gnus-move-split-methods' for finding a default target
8660 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8661 re-spool using this method."
8663 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8665 (defun gnus-summary-crosspost-article (&optional n)
8666 "Crosspost the current article to some other group."
8668 (gnus-summary-move-article n nil nil 'crosspost))
8670 (defcustom gnus-summary-respool-default-method nil
8671 "Default method type for respooling an article.
8672 If nil, use to the current newsgroup method."
8674 :group 'gnus-summary-mail)
8676 (defun gnus-summary-respool-article (&optional n method)
8677 "Respool the current article.
8678 The article will be squeezed through the mail spooling process again,
8679 which means that it will be put in some mail newsgroup or other
8680 depending on `nnmail-split-methods'.
8681 If N is a positive number, respool the N next articles.
8682 If N is a negative number, respool the N previous articles.
8683 If N is nil and any articles have been marked with the process mark,
8684 respool those articles instead.
8686 Respooling can be done both from mail groups and \"real\" newsgroups.
8687 In the former case, the articles in question will be moved from the
8688 current group into whatever groups they are destined to. In the
8689 latter case, they will be copied into the relevant groups."
8691 (list current-prefix-arg
8692 (let* ((methods (gnus-methods-using 'respool))
8694 (symbol-name (or gnus-summary-respool-default-method
8695 (car (gnus-find-method-for-group
8696 gnus-newsgroup-name)))))
8698 (gnus-completing-read-with-default
8699 methname "What backend do you want to use when respooling?"
8700 methods nil t nil 'gnus-mail-method-history))
8703 ((zerop (length (setq ms (gnus-servers-using-backend
8705 (list (intern method) ""))
8709 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8710 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8713 (error "No method given for respooling"))
8714 (if (assoc (symbol-name
8715 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8716 (gnus-methods-using 'respool))
8717 (gnus-summary-move-article n nil method)
8718 (gnus-summary-copy-article n nil method)))
8720 (defun gnus-summary-import-article (file &optional edit)
8721 "Import an arbitrary file into a mail newsgroup."
8722 (interactive "fImport file: \nP")
8723 (let ((group gnus-newsgroup-name)
8724 (now (current-time))
8725 atts lines group-art)
8726 (unless (gnus-check-backend-function 'request-accept-article group)
8727 (error "%s does not support article importing" group))
8728 (or (file-readable-p file)
8729 (not (file-regular-p file))
8730 (error "Can't read %s" file))
8732 (set-buffer (gnus-get-buffer-create " *import file*"))
8734 (nnheader-insert-file-contents file)
8735 (goto-char (point-min))
8736 (if (nnheader-article-p)
8738 (goto-char (point-min))
8739 (search-forward "\n\n" nil t)
8740 (narrow-to-region (point-min) (1- (point)))
8741 (goto-char (point-min))
8742 (unless (re-search-forward "^date:" nil t)
8743 (goto-char (point-max))
8744 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8745 ;; This doesn't look like an article, so we fudge some headers.
8746 (setq atts (file-attributes file)
8747 lines (count-lines (point-min) (point-max)))
8748 (insert "From: " (read-string "From: ") "\n"
8749 "Subject: " (read-string "Subject: ") "\n"
8750 "Date: " (message-make-date (nth 5 atts)) "\n"
8751 "Message-ID: " (message-make-message-id) "\n"
8752 "Lines: " (int-to-string lines) "\n"
8753 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8754 (setq group-art (gnus-request-accept-article group nil t))
8755 (kill-buffer (current-buffer)))
8756 (setq gnus-newsgroup-active (gnus-activate-group group))
8758 (gnus-summary-goto-article (cdr group-art) nil t)
8760 (gnus-summary-edit-article))))
8762 (defun gnus-summary-create-article ()
8763 "Create an article in a mail newsgroup."
8765 (let ((group gnus-newsgroup-name)
8766 (now (current-time))
8768 (unless (gnus-check-backend-function 'request-accept-article group)
8769 (error "%s does not support article importing" group))
8771 (set-buffer (gnus-get-buffer-create " *import file*"))
8773 (goto-char (point-min))
8774 ;; This doesn't look like an article, so we fudge some headers.
8775 (insert "From: " (read-string "From: ") "\n"
8776 "Subject: " (read-string "Subject: ") "\n"
8777 "Date: " (message-make-date now) "\n"
8778 "Message-ID: " (message-make-message-id) "\n")
8779 (setq group-art (gnus-request-accept-article group nil t))
8780 (kill-buffer (current-buffer)))
8781 (setq gnus-newsgroup-active (gnus-activate-group group))
8783 (gnus-summary-goto-article (cdr group-art) nil t)
8784 (gnus-summary-edit-article)))
8786 (defun gnus-summary-article-posted-p ()
8787 "Say whether the current (mail) article is available from news as well.
8788 This will be the case if the article has both been mailed and posted."
8790 (let ((id (mail-header-references (gnus-summary-article-header)))
8791 (gnus-override-method (car (gnus-refer-article-methods))))
8792 (if (gnus-request-head id "")
8793 (gnus-message 2 "The current message was found on %s"
8794 gnus-override-method)
8795 (gnus-message 2 "The current message couldn't be found on %s"
8796 gnus-override-method)
8799 (defun gnus-summary-expire-articles (&optional now)
8800 "Expire all articles that are marked as expirable in the current group."
8802 (when (gnus-check-backend-function
8803 'request-expire-articles gnus-newsgroup-name)
8804 ;; This backend supports expiry.
8805 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8806 (expirable (if total
8808 ;; We need to update the info for
8809 ;; this group for `gnus-list-of-read-articles'
8810 ;; to give us the right answer.
8811 (gnus-run-hooks 'gnus-exit-group-hook)
8812 (gnus-summary-update-info)
8813 (gnus-list-of-read-articles gnus-newsgroup-name))
8814 (setq gnus-newsgroup-expirable
8815 (sort gnus-newsgroup-expirable '<))))
8816 (expiry-wait (if now 'immediate
8817 (gnus-group-find-parameter
8818 gnus-newsgroup-name 'expiry-wait)))
8819 (nnmail-expiry-target
8820 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8821 nnmail-expiry-target))
8824 ;; There are expirable articles in this group, so we run them
8825 ;; through the expiry process.
8826 (gnus-message 6 "Expiring articles...")
8827 (unless (gnus-check-group gnus-newsgroup-name)
8828 (error "Can't open server for %s" gnus-newsgroup-name))
8829 ;; The list of articles that weren't expired is returned.
8832 (let ((nnmail-expiry-wait-function nil)
8833 (nnmail-expiry-wait expiry-wait))
8834 (setq es (gnus-request-expire-articles
8835 expirable gnus-newsgroup-name)))
8836 (setq es (gnus-request-expire-articles
8837 expirable gnus-newsgroup-name)))
8839 (setq gnus-newsgroup-expirable es))
8840 ;; We go through the old list of expirable, and mark all
8841 ;; really expired articles as nonexistent.
8842 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8843 (let ((gnus-use-cache nil))
8844 (dolist (article expirable)
8845 (when (and (not (memq article es))
8846 (gnus-data-find article))
8847 (gnus-summary-mark-article article gnus-canceled-mark))))))
8848 (gnus-message 6 "Expiring articles...done")))))
8850 (defun gnus-summary-expire-articles-now ()
8851 "Expunge all expirable articles in the current group.
8852 This means that *all* articles that are marked as expirable will be
8853 deleted forever, right now."
8855 (or gnus-expert-user
8857 "Are you really, really, really sure you want to delete all these messages? ")
8859 (gnus-summary-expire-articles t))
8861 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8862 (defun gnus-summary-delete-article (&optional n)
8863 "Delete the N next (mail) articles.
8864 This command actually deletes articles. This is not a marking
8865 command. The article will disappear forever from your life, never to
8867 If N is negative, delete backwards.
8868 If N is nil and articles have been marked with the process mark,
8869 delete these instead."
8871 (unless (gnus-check-backend-function 'request-expire-articles
8872 gnus-newsgroup-name)
8873 (error "The current newsgroup does not support article deletion"))
8874 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8875 (error "Couldn't open server"))
8876 ;; Compute the list of articles to delete.
8877 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8878 (nnmail-expiry-target 'delete)
8880 (if (and gnus-novice-user
8881 (not (gnus-yes-or-no-p
8882 (format "Do you really want to delete %s forever? "
8883 (if (> (length articles) 1)
8884 (format "these %s articles" (length articles))
8887 ;; Delete the articles.
8888 (setq not-deleted (gnus-request-expire-articles
8889 articles gnus-newsgroup-name 'force))
8891 (gnus-summary-remove-process-mark (car articles))
8892 ;; The backend might not have been able to delete the article
8894 (unless (memq (car articles) not-deleted)
8895 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8896 (setq articles (cdr articles)))
8898 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8899 (gnus-summary-position-point)
8900 (gnus-set-mode-line 'summary)
8903 (defun gnus-summary-edit-article (&optional arg)
8904 "Edit the current article.
8905 This will have permanent effect only in mail groups.
8906 If ARG is nil, edit the decoded articles.
8907 If ARG is 1, edit the raw articles.
8908 If ARG is 2, edit the raw articles even in read-only groups.
8909 If ARG is 3, edit the articles with the current handles.
8910 Otherwise, allow editing of articles even in read-only
8913 (let (force raw current-handles)
8922 (setq current-handles
8923 (and (gnus-buffer-live-p gnus-article-buffer)
8924 (with-current-buffer gnus-article-buffer
8926 gnus-article-mime-handles
8927 (setq gnus-article-mime-handles nil))))))
8930 (when (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8931 (error "Can't edit the raw article in group nndraft:drafts"))
8933 (set-buffer gnus-summary-buffer)
8934 (let ((mail-parse-charset gnus-newsgroup-charset)
8935 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8936 (gnus-set-global-variables)
8937 (when (and (not force)
8938 (gnus-group-read-only-p))
8939 (error "The current newsgroup does not support article editing"))
8940 (gnus-summary-show-article t)
8941 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8942 (with-current-buffer gnus-article-buffer
8943 (mm-enable-multibyte)))
8944 (if (equal gnus-newsgroup-name "nndraft:drafts")
8946 (gnus-article-edit-article
8949 (let ((mbl mml-buffer-list))
8950 (setq mml-buffer-list nil)
8951 (mime-to-mml ,'current-handles)
8952 (let ((mbl1 mml-buffer-list))
8953 (setq mml-buffer-list mbl)
8954 (set (make-local-variable 'mml-buffer-list) mbl1))
8955 (make-local-hook 'kill-buffer-hook)
8956 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8957 `(lambda (no-highlight)
8958 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8959 (message-options message-options)
8960 (message-options-set-recipient)
8961 (mail-parse-ignored-charsets
8962 ',gnus-newsgroup-ignored-charsets))
8963 ,(if (not raw) '(progn
8965 (mml-destroy-buffers)
8966 (remove-hook 'kill-buffer-hook
8967 'mml-destroy-buffers t)
8968 (kill-local-variable 'mml-buffer-list)))
8969 (gnus-summary-edit-article-done
8970 ,(or (mail-header-references gnus-current-headers) "")
8971 ,(gnus-group-read-only-p)
8972 ,gnus-summary-buffer no-highlight))))))))
8974 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8976 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8978 "Make edits to the current article permanent."
8981 ;; The buffer restriction contains the entire article if it exists.
8982 (when (article-goto-body)
8983 (let ((lines (count-lines (point) (point-max)))
8984 (length (- (point-max) (point)))
8985 (case-fold-search t)
8986 (body (copy-marker (point))))
8987 (goto-char (point-min))
8988 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8989 (delete-region (match-beginning 1) (match-end 1))
8990 (insert (number-to-string length)))
8991 (goto-char (point-min))
8992 (when (re-search-forward
8993 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8994 (delete-region (match-beginning 1) (match-end 1))
8995 (insert (number-to-string length)))
8996 (goto-char (point-min))
8997 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8998 (delete-region (match-beginning 1) (match-end 1))
8999 (insert (number-to-string lines))))))
9000 ;; Replace the article.
9001 (let ((buf (current-buffer)))
9003 (insert-buffer-substring buf)
9005 (if (and (not read-only)
9006 (not (gnus-request-replace-article
9007 (cdr gnus-article-current) (car gnus-article-current)
9008 (current-buffer) t)))
9009 (error "Couldn't replace article")
9010 ;; Update the summary buffer.
9012 (equal (message-tokenize-header references " ")
9013 (message-tokenize-header
9014 (or (message-fetch-field "references") "") " ")))
9015 ;; We only have to update this line.
9018 (message-narrow-to-head)
9019 (let ((head (buffer-string))
9022 (insert (format "211 %d Article retrieved.\n"
9023 (cdr gnus-article-current)))
9026 (let ((nntp-server-buffer (current-buffer)))
9027 (setq header (car (gnus-get-newsgroup-headers
9030 (set-buffer gnus-summary-buffer)
9031 (gnus-data-set-header
9032 (gnus-data-find (cdr gnus-article-current))
9034 (gnus-summary-update-article-line
9035 (cdr gnus-article-current) header)
9036 (if (gnus-summary-goto-subject
9037 (cdr gnus-article-current) nil t)
9038 (gnus-summary-update-secondary-mark
9039 (cdr gnus-article-current))))))))
9041 (set-buffer (or buffer gnus-summary-buffer))
9042 (gnus-summary-update-article (cdr gnus-article-current))
9043 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9044 (gnus-summary-update-secondary-mark
9045 (cdr gnus-article-current))))
9046 ;; Prettify the article buffer again.
9047 (unless no-highlight
9049 (set-buffer gnus-article-buffer)
9050 ;;;!!! Fix this -- article should be rehighlighted.
9051 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9052 (set-buffer gnus-original-article-buffer)
9053 (gnus-request-article
9054 (cdr gnus-article-current)
9055 (car gnus-article-current) (current-buffer))))
9056 ;; Prettify the summary buffer line.
9057 (when (gnus-visual-p 'summary-highlight 'highlight)
9058 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9060 (defun gnus-summary-edit-wash (key)
9061 "Perform editing command KEY in the article buffer."
9065 (message "%s" (concat (this-command-keys) "- "))
9068 (gnus-summary-edit-article)
9069 (execute-kbd-macro (concat (this-command-keys) key))
9070 (gnus-article-edit-done))
9074 (defun gnus-summary-respool-query (&optional silent trace)
9075 "Query where the respool algorithm would put this article."
9077 (let (gnus-mark-article-hook)
9078 (gnus-summary-select-article)
9080 (set-buffer gnus-original-article-buffer)
9082 (message-narrow-to-head)
9083 (let ((groups (nnmail-article-group 'identity trace)))
9086 (message "This message would go to %s"
9087 (mapconcat 'car groups ", "))
9088 (message "This message would go to no groups"))
9091 (defun gnus-summary-respool-trace ()
9092 "Trace where the respool algorithm would put this article.
9093 Display a buffer showing all fancy splitting patterns which matched."
9095 (gnus-summary-respool-query nil t))
9097 ;; Summary marking commands.
9099 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9100 "Mark articles which has the same subject as read, and then select the next.
9101 If UNMARK is positive, remove any kind of mark.
9102 If UNMARK is negative, tick articles."
9105 (setq unmark (prefix-numeric-value unmark)))
9107 (gnus-summary-mark-same-subject
9108 (gnus-summary-article-subject) unmark)))
9109 ;; Select next unread article. If auto-select-same mode, should
9110 ;; select the first unread article.
9111 (gnus-summary-next-article t (and gnus-auto-select-same
9112 (gnus-summary-article-subject)))
9113 (gnus-message 7 "%d article%s marked as %s"
9114 count (if (= count 1) " is" "s are")
9115 (if unmark "unread" "read"))))
9117 (defun gnus-summary-kill-same-subject (&optional unmark)
9118 "Mark articles which has the same subject as read.
9119 If UNMARK is positive, remove any kind of mark.
9120 If UNMARK is negative, tick articles."
9123 (setq unmark (prefix-numeric-value unmark)))
9125 (gnus-summary-mark-same-subject
9126 (gnus-summary-article-subject) unmark)))
9127 ;; If marked as read, go to next unread subject.
9129 ;; Go to next unread subject.
9130 (gnus-summary-next-subject 1 t))
9131 (gnus-message 7 "%d articles are marked as %s"
9132 count (if unmark "unread" "read"))))
9134 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9135 "Mark articles with same SUBJECT as read, and return marked number.
9136 If optional argument UNMARK is positive, remove any kinds of marks.
9137 If optional argument UNMARK is negative, mark articles as unread instead."
9141 ((null unmark) ; Mark as read.
9144 (gnus-summary-mark-article-as-read gnus-killed-mark)
9145 (gnus-summary-show-thread) t)
9146 (gnus-summary-find-subject subject))
9147 (setq count (1+ count))))
9148 ((> unmark 0) ; Tick.
9151 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9152 (gnus-summary-show-thread) t)
9153 (gnus-summary-find-subject subject))
9154 (setq count (1+ count))))
9155 (t ; Mark as unread.
9158 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9159 (gnus-summary-show-thread) t)
9160 (gnus-summary-find-subject subject))
9161 (setq count (1+ count)))))
9162 (gnus-set-mode-line 'summary)
9163 ;; Return the number of marked articles.
9166 (defun gnus-summary-mark-as-processable (n &optional unmark)
9167 "Set the process mark on the next N articles.
9168 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9169 the process mark instead. The difference between N and the actual
9170 number of articles marked is returned."
9172 (if (and (null n) (gnus-region-active-p))
9173 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9174 (setq n (prefix-numeric-value n))
9175 (let ((backward (< n 0))
9180 (gnus-summary-remove-process-mark
9181 (gnus-summary-article-number))
9182 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9183 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9186 (gnus-message 7 "No more articles"))
9187 (gnus-summary-recenter)
9188 (gnus-summary-position-point)
9191 (defun gnus-summary-unmark-as-processable (n)
9192 "Remove the process mark from the next N articles.
9193 If N is negative, unmark backward instead. The difference between N and
9194 the actual number of articles unmarked is returned."
9196 (gnus-summary-mark-as-processable n t))
9198 (defun gnus-summary-unmark-all-processable ()
9199 "Remove the process mark from all articles."
9202 (while gnus-newsgroup-processable
9203 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9204 (gnus-summary-position-point))
9206 (defun gnus-summary-add-mark (article type)
9207 "Mark ARTICLE with a mark of TYPE."
9208 (let ((vtype (car (assq type gnus-article-mark-lists)))
9211 (error "No such mark type: %s" type)
9212 (setq var (intern (format "gnus-newsgroup-%s" type)))
9213 (set var (cons article (symbol-value var)))
9214 (if (memq type '(processable cached replied forwarded recent saved))
9215 (gnus-summary-update-secondary-mark article)
9216 ;;; !!! This is bogus. We should find out what primary
9217 ;;; !!! mark we want to set.
9218 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9220 (defun gnus-summary-mark-as-expirable (n)
9221 "Mark N articles forward as expirable.
9222 If N is negative, mark backward instead. The difference between N and
9223 the actual number of articles marked is returned."
9225 (gnus-summary-mark-forward n gnus-expirable-mark))
9227 (defun gnus-summary-mark-as-spam (n)
9228 "Mark N articles forward as spam.
9229 If N is negative, mark backward instead. The difference between N and
9230 the actual number of articles marked is returned."
9232 (gnus-summary-mark-forward n gnus-spam-mark))
9234 (defun gnus-summary-mark-article-as-replied (article)
9235 "Mark ARTICLE as replied to and update the summary line.
9236 ARTICLE can also be a list of articles."
9237 (interactive (list (gnus-summary-article-number)))
9238 (let ((articles (if (listp article) article (list article))))
9239 (dolist (article articles)
9240 (push article gnus-newsgroup-replied)
9241 (let ((buffer-read-only nil))
9242 (when (gnus-summary-goto-subject article nil t)
9243 (gnus-summary-update-secondary-mark article))))))
9245 (defun gnus-summary-mark-article-as-forwarded (article)
9246 "Mark ARTICLE as forwarded and update the summary line.
9247 ARTICLE can also be a list of articles."
9248 (let ((articles (if (listp article) article (list article))))
9249 (dolist (article articles)
9250 (push article gnus-newsgroup-forwarded)
9251 (let ((buffer-read-only nil))
9252 (when (gnus-summary-goto-subject article nil t)
9253 (gnus-summary-update-secondary-mark article))))))
9255 (defun gnus-summary-set-bookmark (article)
9256 "Set a bookmark in current article."
9257 (interactive (list (gnus-summary-article-number)))
9258 (when (or (not (get-buffer gnus-article-buffer))
9259 (not gnus-current-article)
9260 (not gnus-article-current)
9261 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9262 (error "No current article selected"))
9263 ;; Remove old bookmark, if one exists.
9264 (let ((old (assq article gnus-newsgroup-bookmarks)))
9266 (setq gnus-newsgroup-bookmarks
9267 (delq old gnus-newsgroup-bookmarks))))
9268 ;; Set the new bookmark, which is on the form
9269 ;; (article-number . line-number-in-body).
9273 (set-buffer gnus-article-buffer)
9277 (goto-char (point-min))
9278 (search-forward "\n\n" nil t)
9281 gnus-newsgroup-bookmarks)
9282 (gnus-message 6 "A bookmark has been added to the current article."))
9284 (defun gnus-summary-remove-bookmark (article)
9285 "Remove the bookmark from the current article."
9286 (interactive (list (gnus-summary-article-number)))
9287 ;; Remove old bookmark, if one exists.
9288 (let ((old (assq article gnus-newsgroup-bookmarks)))
9291 (setq gnus-newsgroup-bookmarks
9292 (delq old gnus-newsgroup-bookmarks))
9293 (gnus-message 6 "Removed bookmark."))
9294 (gnus-message 6 "No bookmark in current article."))))
9296 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9297 (defun gnus-summary-mark-as-dormant (n)
9298 "Mark N articles forward as dormant.
9299 If N is negative, mark backward instead. The difference between N and
9300 the actual number of articles marked is returned."
9302 (gnus-summary-mark-forward n gnus-dormant-mark))
9304 (defun gnus-summary-set-process-mark (article)
9305 "Set the process mark on ARTICLE and update the summary line."
9306 (setq gnus-newsgroup-processable
9308 (delq article gnus-newsgroup-processable)))
9309 (when (gnus-summary-goto-subject article)
9310 (gnus-summary-show-thread)
9311 (gnus-summary-goto-subject article)
9312 (gnus-summary-update-secondary-mark article)))
9314 (defun gnus-summary-remove-process-mark (article)
9315 "Remove the process mark from ARTICLE and update the summary line."
9316 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9317 (when (gnus-summary-goto-subject article)
9318 (gnus-summary-show-thread)
9319 (gnus-summary-goto-subject article)
9320 (gnus-summary-update-secondary-mark article)))
9322 (defun gnus-summary-set-saved-mark (article)
9323 "Set the process mark on ARTICLE and update the summary line."
9324 (push article gnus-newsgroup-saved)
9325 (when (gnus-summary-goto-subject article)
9326 (gnus-summary-update-secondary-mark article)))
9328 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9329 "Mark N articles as read forwards.
9330 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9331 The difference between N and the actual number of articles marked is
9333 Iff NO-EXPIRE, auto-expiry will be inhibited."
9335 (gnus-summary-show-thread)
9336 (let ((backward (< n 0))
9337 (gnus-summary-goto-unread
9338 (and gnus-summary-goto-unread
9339 (not (eq gnus-summary-goto-unread 'never))
9340 (not (memq mark (list gnus-unread-mark
9341 gnus-ticked-mark gnus-dormant-mark)))))
9343 (mark (or mark gnus-del-mark)))
9345 (gnus-summary-mark-article nil mark no-expire)
9346 (zerop (gnus-summary-next-subject
9348 (and gnus-summary-goto-unread
9349 (not (eq gnus-summary-goto-unread 'never)))
9353 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9354 (gnus-summary-recenter)
9355 (gnus-summary-position-point)
9356 (gnus-set-mode-line 'summary)
9359 (defun gnus-summary-mark-article-as-read (mark)
9360 "Mark the current article quickly as read with MARK."
9361 (let ((article (gnus-summary-article-number)))
9362 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9363 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9364 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9365 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9366 (push (cons article mark) gnus-newsgroup-reads)
9367 ;; Possibly remove from cache, if that is used.
9368 (when gnus-use-cache
9369 (gnus-cache-enter-remove-article article))
9370 ;; Allow the backend to change the mark.
9371 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9372 ;; Check for auto-expiry.
9373 (when (and gnus-newsgroup-auto-expire
9374 (memq mark gnus-auto-expirable-marks))
9375 (setq mark gnus-expirable-mark)
9376 ;; Let the backend know about the mark change.
9377 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9378 (push article gnus-newsgroup-expirable))
9379 ;; Set the mark in the buffer.
9380 (gnus-summary-update-mark mark 'unread)
9383 (defun gnus-summary-mark-article-as-unread (mark)
9384 "Mark the current article quickly as unread with MARK."
9385 (let* ((article (gnus-summary-article-number))
9386 (old-mark (gnus-summary-article-mark article)))
9387 ;; Allow the backend to change the mark.
9388 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9389 (if (eq mark old-mark)
9393 (gnus-error 1 "Can't mark negative article numbers")
9395 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9396 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9397 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9398 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9399 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9400 (cond ((= mark gnus-ticked-mark)
9401 (setq gnus-newsgroup-marked
9402 (gnus-add-to-sorted-list gnus-newsgroup-marked
9404 ((= mark gnus-spam-mark)
9405 (setq gnus-newsgroup-spam-marked
9406 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9408 ((= mark gnus-dormant-mark)
9409 (setq gnus-newsgroup-dormant
9410 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9413 (setq gnus-newsgroup-unreads
9414 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9416 (gnus-pull article gnus-newsgroup-reads)
9418 ;; See whether the article is to be put in the cache.
9420 (vectorp (gnus-summary-article-header article))
9422 (gnus-cache-possibly-enter-article
9423 gnus-newsgroup-name article
9424 (= mark gnus-ticked-mark)
9425 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9428 (gnus-summary-update-mark mark 'unread)
9431 (defun gnus-summary-mark-article (&optional article mark no-expire)
9432 "Mark ARTICLE with MARK. MARK can be any character.
9433 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9434 `??' (dormant) and `?E' (expirable).
9435 If MARK is nil, then the default character `?r' is used.
9436 If ARTICLE is nil, then the article on the current line will be
9438 Iff NO-EXPIRE, auto-expiry will be inhibited."
9439 ;; The mark might be a string.
9440 (when (stringp mark)
9441 (setq mark (aref mark 0)))
9442 ;; If no mark is given, then we check auto-expiring.
9444 (setq mark gnus-del-mark))
9445 (when (and (not no-expire)
9446 gnus-newsgroup-auto-expire
9447 (memq mark gnus-auto-expirable-marks))
9448 (setq mark gnus-expirable-mark))
9449 (let ((article (or article (gnus-summary-article-number)))
9450 (old-mark (gnus-summary-article-mark article)))
9451 ;; Allow the backend to change the mark.
9452 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9453 (if (eq mark old-mark)
9456 (error "No article on current line"))
9457 (if (not (if (or (= mark gnus-unread-mark)
9458 (= mark gnus-ticked-mark)
9459 (= mark gnus-spam-mark)
9460 (= mark gnus-dormant-mark))
9461 (gnus-mark-article-as-unread article mark)
9462 (gnus-mark-article-as-read article mark)))
9464 ;; See whether the article is to be put in the cache.
9466 (not (= mark gnus-canceled-mark))
9467 (vectorp (gnus-summary-article-header article))
9469 (gnus-cache-possibly-enter-article
9470 gnus-newsgroup-name article
9471 (= mark gnus-ticked-mark)
9472 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9474 (when (gnus-summary-goto-subject article nil t)
9475 (let ((buffer-read-only nil))
9476 (gnus-summary-show-thread)
9478 (gnus-summary-update-mark mark 'unread)
9481 (defun gnus-summary-update-secondary-mark (article)
9482 "Update the secondary (read, process, cache) mark."
9483 (gnus-summary-update-mark
9484 (cond ((memq article gnus-newsgroup-processable)
9486 ((memq article gnus-newsgroup-cached)
9488 ((memq article gnus-newsgroup-replied)
9490 ((memq article gnus-newsgroup-forwarded)
9491 gnus-forwarded-mark)
9492 ((memq article gnus-newsgroup-saved)
9494 ((memq article gnus-newsgroup-recent)
9496 ((memq article gnus-newsgroup-unseen)
9500 (when (gnus-visual-p 'summary-highlight 'highlight)
9501 (gnus-run-hooks 'gnus-summary-update-hook))
9504 (defun gnus-summary-update-mark (mark type)
9505 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9506 (buffer-read-only nil))
9507 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9509 (when (looking-at "\r")
9511 (when (<= (+ forward (point)) (point-max))
9512 ;; Go to the right position on the line.
9513 (goto-char (+ forward (point)))
9514 ;; Replace the old mark with the new mark.
9515 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9516 ;; Optionally update the marks by some user rule.
9517 (when (eq type 'unread)
9519 (gnus-data-find (gnus-summary-article-number)) mark)
9520 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9522 (defun gnus-mark-article-as-read (article &optional mark)
9523 "Enter ARTICLE in the pertinent lists and remove it from others."
9524 ;; Make the article expirable.
9525 (let ((mark (or mark gnus-del-mark)))
9526 (setq gnus-newsgroup-expirable
9527 (if (= mark gnus-expirable-mark)
9528 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9529 (delq article gnus-newsgroup-expirable)))
9530 ;; Remove from unread and marked lists.
9531 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9532 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9533 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9534 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9535 (push (cons article mark) gnus-newsgroup-reads)
9536 ;; Possibly remove from cache, if that is used.
9537 (when gnus-use-cache
9538 (gnus-cache-enter-remove-article article))
9541 (defun gnus-mark-article-as-unread (article &optional mark)
9542 "Enter ARTICLE in the pertinent lists and remove it from others."
9543 (let ((mark (or mark gnus-ticked-mark)))
9546 (gnus-error 1 "Can't mark negative article numbers")
9548 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9549 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9550 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9551 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9552 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9554 ;; Unsuppress duplicates?
9555 (when gnus-suppress-duplicates
9556 (gnus-dup-unsuppress-article article))
9558 (cond ((= mark gnus-ticked-mark)
9559 (setq gnus-newsgroup-marked
9560 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9561 ((= mark gnus-spam-mark)
9562 (setq gnus-newsgroup-spam-marked
9563 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked article)))
9564 ((= mark gnus-dormant-mark)
9565 (setq gnus-newsgroup-dormant
9566 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9568 (setq gnus-newsgroup-unreads
9569 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9570 (gnus-pull article gnus-newsgroup-reads)
9573 (defalias 'gnus-summary-mark-as-unread-forward
9574 'gnus-summary-tick-article-forward)
9575 (make-obsolete 'gnus-summary-mark-as-unread-forward
9576 'gnus-summary-tick-article-forward)
9577 (defun gnus-summary-tick-article-forward (n)
9578 "Tick N articles forwards.
9579 If N is negative, tick backwards instead.
9580 The difference between N and the number of articles ticked is returned."
9582 (gnus-summary-mark-forward n gnus-ticked-mark))
9584 (defalias 'gnus-summary-mark-as-unread-backward
9585 'gnus-summary-tick-article-backward)
9586 (make-obsolete 'gnus-summary-mark-as-unread-backward
9587 'gnus-summary-tick-article-backward)
9588 (defun gnus-summary-tick-article-backward (n)
9589 "Tick N articles backwards.
9590 The difference between N and the number of articles ticked is returned."
9592 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9594 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9595 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9596 (defun gnus-summary-tick-article (&optional article clear-mark)
9597 "Mark current article as unread.
9598 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9599 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9601 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9604 (defun gnus-summary-mark-as-read-forward (n)
9605 "Mark N articles as read forwards.
9606 If N is negative, mark backwards instead.
9607 The difference between N and the actual number of articles marked is
9610 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9612 (defun gnus-summary-mark-as-read-backward (n)
9613 "Mark the N articles as read backwards.
9614 The difference between N and the actual number of articles marked is
9617 (gnus-summary-mark-forward
9618 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9620 (defun gnus-summary-mark-as-read (&optional article mark)
9621 "Mark current article as read.
9622 ARTICLE specifies the article to be marked as read.
9623 MARK specifies a string to be inserted at the beginning of the line."
9624 (gnus-summary-mark-article article mark))
9626 (defun gnus-summary-clear-mark-forward (n)
9627 "Clear marks from N articles forward.
9628 If N is negative, clear backward instead.
9629 The difference between N and the number of marks cleared is returned."
9631 (gnus-summary-mark-forward n gnus-unread-mark))
9633 (defun gnus-summary-clear-mark-backward (n)
9634 "Clear marks from N articles backward.
9635 The difference between N and the number of marks cleared is returned."
9637 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9639 (defun gnus-summary-mark-unread-as-read ()
9640 "Intended to be used by `gnus-summary-mark-article-hook'."
9641 (when (memq gnus-current-article gnus-newsgroup-unreads)
9642 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9644 (defun gnus-summary-mark-read-and-unread-as-read ()
9645 "Intended to be used by `gnus-summary-mark-article-hook'."
9646 (let ((mark (gnus-summary-article-mark)))
9647 (when (or (gnus-unread-mark-p mark)
9648 (gnus-read-mark-p mark))
9649 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9651 (defun gnus-summary-mark-unread-as-ticked ()
9652 "Intended to be used by `gnus-summary-mark-article-hook'."
9653 (when (memq gnus-current-article gnus-newsgroup-unreads)
9654 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9656 (defun gnus-summary-mark-region-as-read (point mark all)
9657 "Mark all unread articles between point and mark as read.
9658 If given a prefix, mark all articles between point and mark as read,
9659 even ticked and dormant ones."
9660 (interactive "r\nP")
9669 (memq (setq article (gnus-summary-article-number))
9670 gnus-newsgroup-unreads))
9671 (gnus-summary-mark-article article gnus-del-mark))
9673 (gnus-summary-find-next))))))
9675 (defun gnus-summary-mark-below (score mark)
9676 "Mark articles with score less than SCORE with MARK."
9677 (interactive "P\ncMark: ")
9678 (setq score (if score
9679 (prefix-numeric-value score)
9680 (or gnus-summary-default-score 0)))
9682 (set-buffer gnus-summary-buffer)
9683 (goto-char (point-min))
9686 (and (< (gnus-summary-article-score) score)
9687 (gnus-summary-mark-article nil mark))
9688 (gnus-summary-find-next)))))
9690 (defun gnus-summary-kill-below (&optional score)
9691 "Mark articles with score below SCORE as read."
9693 (gnus-summary-mark-below score gnus-killed-mark))
9695 (defun gnus-summary-clear-above (&optional score)
9696 "Clear all marks from articles with score above SCORE."
9698 (gnus-summary-mark-above score gnus-unread-mark))
9700 (defun gnus-summary-tick-above (&optional score)
9701 "Tick all articles with score above SCORE."
9703 (gnus-summary-mark-above score gnus-ticked-mark))
9705 (defun gnus-summary-mark-above (score mark)
9706 "Mark articles with score over SCORE with MARK."
9707 (interactive "P\ncMark: ")
9708 (setq score (if score
9709 (prefix-numeric-value score)
9710 (or gnus-summary-default-score 0)))
9712 (set-buffer gnus-summary-buffer)
9713 (goto-char (point-min))
9715 (when (> (gnus-summary-article-score) score)
9716 (gnus-summary-mark-article nil mark))
9718 (gnus-summary-find-next)))))
9720 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9721 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9722 (defun gnus-summary-limit-include-expunged (&optional no-error)
9723 "Display all the hidden articles that were expunged for low scores."
9725 (let ((buffer-read-only nil))
9726 (let ((scored gnus-newsgroup-scored)
9729 (unless (gnus-summary-article-header (caar scored))
9730 (and (setq h (gnus-number-to-header (caar scored)))
9731 (< (cdar scored) gnus-summary-expunge-below)
9733 (setq scored (cdr scored)))
9735 (when (not no-error)
9736 (error "No expunged articles hidden"))
9737 (goto-char (point-min))
9738 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9739 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9740 (mapcar (lambda (x) (push (mail-header-number x)
9741 gnus-newsgroup-limit))
9743 (gnus-summary-prepare-unthreaded (nreverse headers))
9744 (goto-char (point-min))
9745 (gnus-summary-position-point)
9748 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9749 "Mark all unread articles in this newsgroup as read.
9750 If prefix argument ALL is non-nil, ticked and dormant articles will
9751 also be marked as read.
9752 If QUIETLY is non-nil, no questions will be asked.
9753 If TO-HERE is non-nil, it should be a point in the buffer. All
9754 articles before (after, if REVERSE is set) this point will be marked as read.
9755 Note that this function will only catch up the unread article
9756 in the current summary buffer limitation.
9757 The number of articles marked as read is returned."
9762 (not gnus-interactive-catchup) ;Without confirmation?
9766 "Mark absolutely all articles as read? "
9767 "Mark all unread articles as read? ")))
9769 (not gnus-newsgroup-adaptive)
9770 (not gnus-newsgroup-auto-expire)
9771 (not gnus-suppress-duplicates)
9772 (or (not gnus-use-cache)
9773 (eq gnus-use-cache 'passive)))
9776 (setq gnus-newsgroup-marked nil
9777 gnus-newsgroup-spam-marked nil
9778 gnus-newsgroup-dormant nil))
9779 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9780 ;; We actually mark all articles as canceled, which we
9781 ;; have to do when using auto-expiry or adaptive scoring.
9782 (gnus-summary-show-all-threads)
9783 (if (and to-here reverse)
9787 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9788 (gnus-summary-find-next (not all) nil nil t))))
9789 (when (gnus-summary-first-subject (not all) t)
9791 (if to-here (< (point) to-here) t)
9792 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9793 (gnus-summary-find-next (not all) nil nil t)))))
9794 (gnus-set-mode-line 'summary))
9796 (gnus-summary-position-point)))
9798 (defun gnus-summary-catchup-to-here (&optional all)
9799 "Mark all unticked articles before the current one as read.
9800 If ALL is non-nil, also mark ticked and dormant articles as read."
9803 (gnus-save-hidden-threads
9804 (let ((beg (point)))
9805 ;; We check that there are unread articles.
9806 (when (or all (gnus-summary-find-prev))
9807 (gnus-summary-catchup all t beg)))))
9808 (gnus-summary-position-point))
9810 (defun gnus-summary-catchup-from-here (&optional all)
9811 "Mark all unticked articles after the current one as read.
9812 If ALL is non-nil, also mark ticked and dormant articles as read."
9815 (gnus-save-hidden-threads
9816 (let ((beg (point)))
9817 ;; We check that there are unread articles.
9818 (when (or all (gnus-summary-find-next))
9819 (gnus-summary-catchup all t beg nil t)))))
9821 (gnus-summary-position-point))
9822 (defun gnus-summary-catchup-all (&optional quietly)
9823 "Mark all articles in this newsgroup as read."
9825 (gnus-summary-catchup t quietly))
9827 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9828 "Mark all unread articles in this group as read, then exit.
9829 If prefix argument ALL is non-nil, all articles are marked as read.
9830 If QUIETLY is non-nil, no questions will be asked."
9832 (when (gnus-summary-catchup all quietly nil 'fast)
9833 ;; Select next newsgroup or exit.
9834 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9835 (eq gnus-auto-select-next 'quietly))
9836 (gnus-summary-next-group nil)
9837 (gnus-summary-exit))))
9839 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9840 "Mark all articles in this newsgroup as read, and then exit."
9842 (gnus-summary-catchup-and-exit t quietly))
9844 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9845 "Mark all articles in this group as read and select the next group.
9846 If given a prefix, mark all articles, unread as well as ticked, as
9850 (gnus-summary-catchup all))
9851 (gnus-summary-next-group))
9857 (defmacro gnus-with-article (article &rest forms)
9858 "Select ARTICLE and perform FORMS in the original article buffer.
9859 Then replace the article with the result."
9861 ;; We don't want the article to be marked as read.
9862 (let (gnus-mark-article-hook)
9863 (gnus-summary-select-article t t nil ,article))
9864 (set-buffer gnus-original-article-buffer)
9866 (if (not (gnus-check-backend-function
9867 'request-replace-article (car gnus-article-current)))
9868 (gnus-message 5 "Read-only group; not replacing")
9869 (unless (gnus-request-replace-article
9870 ,article (car gnus-article-current)
9872 (error "Couldn't replace article")))
9873 ;; The cache and backlog have to be flushed somewhat.
9874 (when gnus-keep-backlog
9875 (gnus-backlog-remove-article
9876 (car gnus-article-current) (cdr gnus-article-current)))
9877 (when gnus-use-cache
9878 (gnus-cache-update-article
9879 (car gnus-article-current) (cdr gnus-article-current)))))
9881 (put 'gnus-with-article 'lisp-indent-function 1)
9882 (put 'gnus-with-article 'edebug-form-spec '(form body))
9884 ;; Thread-based commands.
9886 (defun gnus-summary-articles-in-thread (&optional article)
9887 "Return a list of all articles in the current thread.
9888 If ARTICLE is non-nil, return all articles in the thread that starts
9890 (let* ((article (or article (gnus-summary-article-number)))
9891 (data (gnus-data-find-list article))
9892 (top-level (gnus-data-level (car data)))
9894 (cond ((null gnus-thread-operation-ignore-subject)
9895 (gnus-simplify-subject-re
9896 (mail-header-subject (gnus-data-header (car data)))))
9897 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9898 (gnus-simplify-subject-fuzzy
9899 (mail-header-subject (gnus-data-header (car data)))))
9901 (end-point (save-excursion
9902 (if (gnus-summary-go-to-next-thread)
9903 (point) (point-max))))
9906 (< (gnus-data-pos (car data)) end-point))
9907 (when (or (not top-subject)
9908 (string= top-subject
9909 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9910 (gnus-simplify-subject-fuzzy
9911 (mail-header-subject
9912 (gnus-data-header (car data))))
9913 (gnus-simplify-subject-re
9914 (mail-header-subject
9915 (gnus-data-header (car data)))))))
9916 (push (gnus-data-number (car data)) articles))
9917 (unless (and (setq data (cdr data))
9918 (> (gnus-data-level (car data)) top-level))
9920 ;; Return the list of articles.
9921 (nreverse articles)))
9923 (defun gnus-summary-rethread-current ()
9924 "Rethread the thread the current article is part of."
9926 (let* ((gnus-show-threads t)
9927 (article (gnus-summary-article-number))
9928 (id (mail-header-id (gnus-summary-article-header)))
9929 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9931 (error "No article on the current line"))
9932 (gnus-rebuild-thread id)
9933 (gnus-summary-goto-subject article)))
9935 (defun gnus-summary-reparent-thread ()
9936 "Make the current article child of the marked (or previous) article.
9938 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9939 is non-nil or the Subject: of both articles are the same."
9941 (unless (not (gnus-group-read-only-p))
9942 (error "The current newsgroup does not support article editing"))
9943 (unless (<= (length gnus-newsgroup-processable) 1)
9944 (error "No more than one article may be marked"))
9945 (save-window-excursion
9946 (let ((gnus-article-buffer " *reparent*")
9947 (current-article (gnus-summary-article-number))
9948 ;; First grab the marked article, otherwise one line up.
9949 (parent-article (if (not (null gnus-newsgroup-processable))
9950 (car gnus-newsgroup-processable)
9952 (if (eq (forward-line -1) 0)
9953 (gnus-summary-article-number)
9954 (error "Beginning of summary buffer"))))))
9955 (unless (not (eq current-article parent-article))
9956 (error "An article may not be self-referential"))
9957 (let ((message-id (mail-header-id
9958 (gnus-summary-article-header parent-article))))
9959 (unless (and message-id (not (equal message-id "")))
9960 (error "No message-id in desired parent"))
9961 (gnus-with-article current-article
9963 (goto-char (point-min))
9964 (message-narrow-to-head)
9965 (if (re-search-forward "^References: " nil t)
9967 (re-search-forward "^[^ \t]" nil t)
9970 (insert " " message-id))
9971 (insert "References: " message-id "\n"))))
9972 (set-buffer gnus-summary-buffer)
9973 (gnus-summary-unmark-all-processable)
9974 (gnus-summary-update-article current-article)
9975 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9976 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9977 (gnus-summary-rethread-current)
9978 (gnus-message 3 "Article %d is now the child of article %d"
9979 current-article parent-article)))))
9981 (defun gnus-summary-toggle-threads (&optional arg)
9982 "Toggle showing conversation threads.
9983 If ARG is positive number, turn showing conversation threads on."
9985 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9986 (setq gnus-show-threads
9987 (if (null arg) (not gnus-show-threads)
9988 (> (prefix-numeric-value arg) 0)))
9989 (gnus-summary-prepare)
9990 (gnus-summary-goto-subject current)
9991 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9992 (gnus-summary-position-point)))
9994 (defun gnus-summary-show-all-threads ()
9998 (let ((buffer-read-only nil))
9999 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10000 (gnus-summary-position-point))
10002 (defun gnus-summary-show-thread ()
10003 "Show thread subtrees.
10004 Returns nil if no thread was there to be shown."
10006 (let ((buffer-read-only nil)
10008 ;; first goto end then to beg, to have point at beg after let
10009 (end (progn (end-of-line) (point)))
10010 (beg (progn (beginning-of-line) (point))))
10012 ;; Any hidden lines here?
10013 (search-forward "\r" end t)
10014 (subst-char-in-region beg end ?\^M ?\n t)
10016 (gnus-summary-position-point))))
10018 (defun gnus-summary-maybe-hide-threads ()
10019 "If requested, hide the threads that should be hidden."
10020 (when (and gnus-show-threads
10021 gnus-thread-hide-subtree)
10022 (gnus-summary-hide-all-threads
10023 (if (or (consp gnus-thread-hide-subtree)
10024 (gnus-functionp gnus-thread-hide-subtree))
10025 (gnus-make-predicate gnus-thread-hide-subtree)
10028 ;;; Hiding predicates.
10030 (defun gnus-article-unread-p (header)
10031 (memq (mail-header-number header) gnus-newsgroup-unreads))
10033 (defun gnus-article-unseen-p (header)
10034 (memq (mail-header-number header) gnus-newsgroup-unseen))
10036 (defun gnus-map-articles (predicate articles)
10037 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10038 (apply 'gnus-or (mapcar predicate
10039 (mapcar 'gnus-summary-article-header articles))))
10041 (defun gnus-summary-hide-all-threads (&optional predicate)
10042 "Hide all thread subtrees.
10043 If PREDICATE is supplied, threads that satisfy this predicate
10044 will not be hidden."
10047 (goto-char (point-min))
10050 (when (or (not predicate)
10052 predicate (gnus-summary-article-children)))
10053 (gnus-summary-hide-thread))
10054 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10055 (gnus-summary-position-point))
10057 (defun gnus-summary-hide-thread ()
10058 "Hide thread subtrees.
10059 If PREDICATE is supplied, threads that satisfy this predicate
10060 will not be hidden.
10061 Returns nil if no threads were there to be hidden."
10063 (let ((buffer-read-only nil)
10065 (article (gnus-summary-article-number)))
10067 ;; Go forward until either the buffer ends or the subthread
10069 (when (and (not (eobp))
10070 (or (zerop (gnus-summary-next-thread 1 t))
10071 (goto-char (point-max))))
10073 (if (and (> (point) start)
10074 (search-backward "\n" start t))
10076 (subst-char-in-region start (point) ?\n ?\^M)
10077 (gnus-summary-goto-subject article))
10081 (defun gnus-summary-go-to-next-thread (&optional previous)
10082 "Go to the same level (or less) next thread.
10083 If PREVIOUS is non-nil, go to previous thread instead.
10084 Return the article number moved to, or nil if moving was impossible."
10085 (let ((level (gnus-summary-thread-level))
10086 (way (if previous -1 1))
10089 (while (and (not (eobp))
10090 (< level (gnus-summary-thread-level)))
10091 (forward-line way))
10098 (gnus-summary-article-number)
10099 (goto-char beg)))))
10101 (defun gnus-summary-next-thread (n &optional silent)
10102 "Go to the same level next N'th thread.
10103 If N is negative, search backward instead.
10104 Returns the difference between N and the number of skips actually
10107 If SILENT, don't output messages."
10109 (let ((backward (< n 0))
10111 (while (and (> n 0)
10112 (gnus-summary-go-to-next-thread backward))
10115 (gnus-summary-position-point))
10116 (when (and (not silent) (/= 0 n))
10117 (gnus-message 7 "No more threads"))
10120 (defun gnus-summary-prev-thread (n)
10121 "Go to the same level previous N'th thread.
10122 Returns the difference between N and the number of skips actually
10125 (gnus-summary-next-thread (- n)))
10127 (defun gnus-summary-go-down-thread ()
10128 "Go down one level in the current thread."
10129 (let ((children (gnus-summary-article-children)))
10131 (gnus-summary-goto-subject (car children)))))
10133 (defun gnus-summary-go-up-thread ()
10134 "Go up one level in the current thread."
10135 (let ((parent (gnus-summary-article-parent)))
10137 (gnus-summary-goto-subject parent))))
10139 (defun gnus-summary-down-thread (n)
10140 "Go down thread N steps.
10141 If N is negative, go up instead.
10142 Returns the difference between N and how many steps down that were
10147 (while (and (> n 0)
10148 (if up (gnus-summary-go-up-thread)
10149 (gnus-summary-go-down-thread)))
10151 (gnus-summary-position-point)
10153 (gnus-message 7 "Can't go further"))
10156 (defun gnus-summary-up-thread (n)
10157 "Go up thread N steps.
10158 If N is negative, go down instead.
10159 Returns the difference between N and how many steps down that were
10162 (gnus-summary-down-thread (- n)))
10164 (defun gnus-summary-top-thread ()
10165 "Go to the top of the thread."
10167 (while (gnus-summary-go-up-thread))
10168 (gnus-summary-article-number))
10170 (defun gnus-summary-kill-thread (&optional unmark)
10171 "Mark articles under current thread as read.
10172 If the prefix argument is positive, remove any kinds of marks.
10173 If the prefix argument is negative, tick articles instead."
10176 (setq unmark (prefix-numeric-value unmark)))
10177 (let ((articles (gnus-summary-articles-in-thread)))
10179 ;; Expand the thread.
10180 (gnus-summary-show-thread)
10181 ;; Mark all the articles.
10183 (gnus-summary-goto-subject (car articles))
10184 (cond ((null unmark)
10185 (gnus-summary-mark-article-as-read gnus-killed-mark))
10187 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10189 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10190 (setq articles (cdr articles))))
10191 ;; Hide killed subtrees.
10193 gnus-thread-hide-killed
10194 (gnus-summary-hide-thread))
10195 ;; If marked as read, go to next unread subject.
10196 (when (null unmark)
10197 ;; Go to next unread subject.
10198 (gnus-summary-next-subject 1 t)))
10199 (gnus-set-mode-line 'summary))
10201 ;; Summary sorting commands
10203 (defun gnus-summary-sort-by-number (&optional reverse)
10204 "Sort the summary buffer by article number.
10205 Argument REVERSE means reverse order."
10207 (gnus-summary-sort 'number reverse))
10209 (defun gnus-summary-sort-by-random (&optional reverse)
10210 "Randomize the order in the summary buffer.
10211 Argument REVERSE means to randomize in reverse order."
10213 (gnus-summary-sort 'random reverse))
10215 (defun gnus-summary-sort-by-author (&optional reverse)
10216 "Sort the summary buffer by author name alphabetically.
10217 If `case-fold-search' is non-nil, case of letters is ignored.
10218 Argument REVERSE means reverse order."
10220 (gnus-summary-sort 'author reverse))
10222 (defun gnus-summary-sort-by-subject (&optional reverse)
10223 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10224 If `case-fold-search' is non-nil, case of letters is ignored.
10225 Argument REVERSE means reverse order."
10227 (gnus-summary-sort 'subject reverse))
10229 (defun gnus-summary-sort-by-date (&optional reverse)
10230 "Sort the summary buffer by date.
10231 Argument REVERSE means reverse order."
10233 (gnus-summary-sort 'date reverse))
10235 (defun gnus-summary-sort-by-score (&optional reverse)
10236 "Sort the summary buffer by score.
10237 Argument REVERSE means reverse order."
10239 (gnus-summary-sort 'score reverse))
10241 (defun gnus-summary-sort-by-lines (&optional reverse)
10242 "Sort the summary buffer by the number of lines.
10243 Argument REVERSE means reverse order."
10245 (gnus-summary-sort 'lines reverse))
10247 (defun gnus-summary-sort-by-chars (&optional reverse)
10248 "Sort the summary buffer by article length.
10249 Argument REVERSE means reverse order."
10251 (gnus-summary-sort 'chars reverse))
10253 (defun gnus-summary-sort-by-original (&optional reverse)
10254 "Sort the summary buffer using the default sorting method.
10255 Argument REVERSE means reverse order."
10257 (let* ((buffer-read-only)
10258 (gnus-summary-prepare-hook nil))
10259 ;; We do the sorting by regenerating the threads.
10260 (gnus-summary-prepare)
10261 ;; Hide subthreads if needed.
10262 (gnus-summary-maybe-hide-threads)))
10264 (defun gnus-summary-sort (predicate reverse)
10265 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10266 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10267 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10268 (gnus-thread-sort-functions
10273 (gnus-sort-gathered-threads-function
10274 gnus-thread-sort-functions)
10275 (gnus-article-sort-functions
10279 (,article t2 t1))))
10281 (gnus-summary-prepare-hook nil))
10282 ;; We do the sorting by regenerating the threads.
10283 (gnus-summary-prepare)
10284 ;; Hide subthreads if needed.
10285 (gnus-summary-maybe-hide-threads)))
10287 ;; Summary saving commands.
10289 (defun gnus-summary-save-article (&optional n not-saved)
10290 "Save the current article using the default saver function.
10291 If N is a positive number, save the N next articles.
10292 If N is a negative number, save the N previous articles.
10293 If N is nil and any articles have been marked with the process mark,
10294 save those articles instead.
10295 The variable `gnus-default-article-saver' specifies the saver function."
10297 (let* ((articles (gnus-summary-work-articles n))
10298 (save-buffer (save-excursion
10299 (nnheader-set-temp-buffer " *Gnus Save*")))
10300 (num (length articles))
10302 (dolist (article articles)
10303 (setq header (gnus-summary-article-header article))
10304 (if (not (vectorp header))
10305 ;; This is a pseudo-article.
10306 (if (assq 'name header)
10307 (gnus-copy-file (cdr (assq 'name header)))
10308 (gnus-message 1 "Article %d is unsaveable" article))
10309 ;; This is a real article.
10310 (save-window-excursion
10311 (let ((gnus-display-mime-function nil)
10312 (gnus-article-prepare-hook nil))
10313 (gnus-summary-select-article t nil nil article)))
10315 (set-buffer save-buffer)
10317 (insert-buffer-substring gnus-original-article-buffer))
10318 (setq file (gnus-article-save save-buffer file num))
10319 (gnus-summary-remove-process-mark article)
10321 (gnus-summary-set-saved-mark article))))
10322 (gnus-kill-buffer save-buffer)
10323 (gnus-summary-position-point)
10324 (gnus-set-mode-line 'summary)
10327 (defun gnus-summary-pipe-output (&optional arg)
10328 "Pipe the current article to a subprocess.
10329 If N is a positive number, pipe the N next articles.
10330 If N is a negative number, pipe the N previous articles.
10331 If N is nil and any articles have been marked with the process mark,
10332 pipe those articles instead."
10334 (require 'gnus-art)
10335 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10336 (gnus-summary-save-article arg t))
10337 (let ((buffer (get-buffer "*Shell Command Output*")))
10339 (with-current-buffer buffer (> (point-max) (point-min))))
10340 (gnus-configure-windows 'pipe))))
10342 (defun gnus-summary-save-article-mail (&optional arg)
10343 "Append the current article to an mail file.
10344 If N is a positive number, save the N next articles.
10345 If N is a negative number, save the N previous articles.
10346 If N is nil and any articles have been marked with the process mark,
10347 save those articles instead."
10349 (require 'gnus-art)
10350 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10351 (gnus-summary-save-article arg)))
10353 (defun gnus-summary-save-article-rmail (&optional arg)
10354 "Append the current article to an rmail file.
10355 If N is a positive number, save the N next articles.
10356 If N is a negative number, save the N previous articles.
10357 If N is nil and any articles have been marked with the process mark,
10358 save those articles instead."
10360 (require 'gnus-art)
10361 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10362 (gnus-summary-save-article arg)))
10364 (defun gnus-summary-save-article-file (&optional arg)
10365 "Append the current article to a file.
10366 If N is a positive number, save the N next articles.
10367 If N is a negative number, save the N previous articles.
10368 If N is nil and any articles have been marked with the process mark,
10369 save those articles instead."
10371 (require 'gnus-art)
10372 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10373 (gnus-summary-save-article arg)))
10375 (defun gnus-summary-write-article-file (&optional arg)
10376 "Write the current article to a file, deleting the previous file.
10377 If N is a positive number, save the N next articles.
10378 If N is a negative number, save the N previous articles.
10379 If N is nil and any articles have been marked with the process mark,
10380 save those articles instead."
10382 (require 'gnus-art)
10383 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10384 (gnus-summary-save-article arg)))
10386 (defun gnus-summary-save-article-body-file (&optional arg)
10387 "Append the current article body to a file.
10388 If N is a positive number, save the N next articles.
10389 If N is a negative number, save the N previous articles.
10390 If N is nil and any articles have been marked with the process mark,
10391 save those articles instead."
10393 (require 'gnus-art)
10394 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10395 (gnus-summary-save-article arg)))
10397 (defun gnus-summary-muttprint (&optional arg)
10398 "Print the current article using Muttprint.
10399 If N is a positive number, save the N next articles.
10400 If N is a negative number, save the N previous articles.
10401 If N is nil and any articles have been marked with the process mark,
10402 save those articles instead."
10404 (require 'gnus-art)
10405 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10406 (gnus-summary-save-article arg t)))
10408 (defun gnus-summary-pipe-message (program)
10409 "Pipe the current article through PROGRAM."
10410 (interactive "sProgram: ")
10411 (gnus-summary-select-article)
10412 (let ((mail-header-separator ""))
10413 (gnus-eval-in-buffer-window gnus-article-buffer
10416 (let ((start (window-start))
10418 (message-pipe-buffer-body program)
10419 (set-window-start (get-buffer-window (current-buffer)) start))))))
10421 (defun gnus-get-split-value (methods)
10422 "Return a value based on the split METHODS."
10423 (let (split-name method result match)
10426 (set-buffer gnus-original-article-buffer)
10428 (nnheader-narrow-to-headers)
10429 (while (and methods (not split-name))
10430 (goto-char (point-min))
10431 (setq method (pop methods))
10432 (setq match (car method))
10435 ;; Regular expression.
10437 (re-search-forward match nil t)))
10438 ((gnus-functionp match)
10442 (setq result (funcall match gnus-newsgroup-name))))
10447 (setq result (eval match)))))
10448 (setq split-name (cdr method))
10449 (cond ((stringp result)
10450 (push (expand-file-name
10451 result gnus-article-save-directory)
10454 (setq split-name (append result split-name)))))))))
10455 (nreverse split-name)))
10457 (defun gnus-valid-move-group-p (group)
10458 (and (boundp group)
10459 (symbol-name group)
10460 (symbol-value group)
10461 (gnus-get-function (gnus-find-method-for-group
10462 (symbol-name group)) 'request-accept-article t)))
10464 (defun gnus-read-move-group-name (prompt default articles prefix)
10465 "Read a group name."
10466 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10467 (minibuffer-confirm-incomplete nil) ; XEmacs
10469 (format "%s %s to:"
10471 (if (> (length articles) 1)
10472 (format "these %d articles" (length articles))
10477 (gnus-completing-read-with-default
10480 'gnus-valid-move-group-p
10482 'gnus-group-history))
10483 ((= 1 (length split-name))
10484 (gnus-completing-read-with-default
10485 (car split-name) prom
10487 'gnus-valid-move-group-p
10489 'gnus-group-history))
10491 (gnus-completing-read-with-default
10493 (mapcar (lambda (el) (list el))
10494 (nreverse split-name))
10496 'gnus-group-history))))
10497 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10499 (if (or (string= to-newsgroup "")
10500 (string= to-newsgroup prefix))
10501 (setq to-newsgroup default))
10502 (unless to-newsgroup
10503 (error "No group name entered"))
10504 (or (gnus-active to-newsgroup)
10505 (gnus-activate-group to-newsgroup nil nil to-method)
10506 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10508 (or (and (gnus-request-create-group to-newsgroup to-method)
10509 (gnus-activate-group
10510 to-newsgroup nil nil to-method)
10511 (gnus-subscribe-group to-newsgroup))
10512 (error "Couldn't create group %s" to-newsgroup)))
10513 (error "No such group: %s" to-newsgroup)))
10516 (defun gnus-summary-save-parts (type dir n &optional reverse)
10517 "Save parts matching TYPE to DIR.
10518 If REVERSE, save parts that do not match TYPE."
10520 (list (read-string "Save parts of type: "
10521 (or (car gnus-summary-save-parts-type-history)
10522 gnus-summary-save-parts-default-mime)
10523 'gnus-summary-save-parts-type-history)
10524 (setq gnus-summary-save-parts-last-directory
10525 (read-file-name "Save to directory: "
10526 gnus-summary-save-parts-last-directory
10528 current-prefix-arg))
10529 (gnus-summary-iterate n
10530 (let ((gnus-display-mime-function nil)
10531 (gnus-inhibit-treatment t))
10532 (gnus-summary-select-article))
10534 (set-buffer gnus-article-buffer)
10535 (let ((handles (or gnus-article-mime-handles
10536 (mm-dissect-buffer nil gnus-article-loose-mime)
10539 (gnus-summary-save-parts-1 type dir handles reverse)
10540 (unless gnus-article-mime-handles ;; Don't destroy this case.
10541 (mm-destroy-parts handles)))))))
10543 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10544 (if (stringp (car handle))
10545 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10548 (not (string-match type (mm-handle-media-type handle)))
10549 (string-match type (mm-handle-media-type handle)))
10550 (let ((file (expand-file-name
10551 (file-name-nondirectory
10553 (mail-content-type-get
10554 (mm-handle-disposition handle) 'filename)
10555 (concat gnus-newsgroup-name
10556 "." (number-to-string
10557 (cdr gnus-article-current)))))
10559 (unless (file-exists-p file)
10560 (mm-save-part-to-file handle file))))))
10562 ;; Summary extract commands
10564 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10565 (let ((buffer-read-only nil)
10566 (article (gnus-summary-article-number))
10568 (unless (gnus-summary-goto-subject article)
10569 (error "No such article: %d" article))
10570 (gnus-summary-position-point)
10571 ;; If all commands are to be bunched up on one line, we collect
10573 (unless gnus-view-pseudos-separately
10574 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10577 (setq action (cdr (assq 'action (car ps))))
10578 (setq files (list (cdr (assq 'name (car ps)))))
10579 (while (and ps (cdr ps)
10580 (string= (or action "1")
10581 (or (cdr (assq 'action (cadr ps))) "2")))
10582 (push (cdr (assq 'name (cadr ps))) files)
10583 (setcdr ps (cddr ps)))
10585 (when (not (string-match "%s" action))
10588 (when (assq 'execute (car ps))
10589 (setcdr (assq 'execute (car ps))
10590 (funcall (if (string-match "%s" action)
10599 (setq ps (cdr ps)))))
10600 (if (and gnus-view-pseudos (not not-view))
10602 (when (assq 'execute (car pslist))
10603 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10604 (eq gnus-view-pseudos 'not-confirm)))
10605 (setq pslist (cdr pslist)))
10608 (setq after-article (or (cdr (assq 'article (car pslist)))
10609 (gnus-summary-article-number)))
10610 (gnus-summary-goto-subject after-article)
10613 (insert " " (file-name-nondirectory
10614 (cdr (assq 'name (car pslist))))
10615 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10617 (forward-line -1) ; back to `b'
10618 (gnus-add-text-properties
10619 b (1- e) (list 'gnus-number gnus-reffed-article-number
10620 gnus-mouse-face-prop gnus-mouse-face))
10622 after-article gnus-reffed-article-number
10623 gnus-unread-mark b (car pslist) 0 (- e b))
10624 (setq gnus-newsgroup-unreads
10625 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10626 gnus-reffed-article-number))
10627 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10628 (setq pslist (cdr pslist)))))))
10630 (defun gnus-pseudos< (p1 p2)
10631 (let ((c1 (cdr (assq 'action p1)))
10632 (c2 (cdr (assq 'action p2))))
10633 (and c1 c2 (string< c1 c2))))
10635 (defun gnus-request-pseudo-article (props)
10636 (cond ((assq 'execute props)
10637 (gnus-execute-command (cdr (assq 'execute props)))))
10638 (let ((gnus-current-article (gnus-summary-article-number)))
10639 (gnus-run-hooks 'gnus-mark-article-hook)))
10641 (defun gnus-execute-command (command &optional automatic)
10643 (gnus-article-setup-buffer)
10644 (set-buffer gnus-article-buffer)
10645 (setq buffer-read-only nil)
10646 (let ((command (if automatic command
10647 (read-string "Command: " (cons command 0)))))
10649 (insert "$ " command "\n\n")
10650 (if gnus-view-pseudo-asynchronously
10651 (start-process "gnus-execute" (current-buffer) shell-file-name
10652 shell-command-switch command)
10653 (call-process shell-file-name nil t nil
10654 shell-command-switch command)))))
10656 ;; Summary kill commands.
10658 (defun gnus-summary-edit-global-kill (article)
10659 "Edit the \"global\" kill file."
10660 (interactive (list (gnus-summary-article-number)))
10661 (gnus-group-edit-global-kill article))
10663 (defun gnus-summary-edit-local-kill ()
10664 "Edit a local kill file applied to the current newsgroup."
10666 (setq gnus-current-headers (gnus-summary-article-header))
10667 (gnus-group-edit-local-kill
10668 (gnus-summary-article-number) gnus-newsgroup-name))
10670 ;;; Header reading.
10672 (defun gnus-read-header (id &optional header)
10673 "Read the headers of article ID and enter them into the Gnus system."
10674 (let ((group gnus-newsgroup-name)
10675 (gnus-override-method
10677 gnus-override-method
10678 (and (gnus-news-group-p gnus-newsgroup-name)
10679 (car (gnus-refer-article-methods)))))
10681 ;; First we check to see whether the header in question is already
10684 ;; This is a Message-ID.
10685 (setq header (or header (gnus-id-to-header id)))
10686 ;; This is an article number.
10687 (setq header (or header (gnus-summary-article-header id))))
10689 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10690 ;; We have found the header.
10692 ;; If this is a sparse article, we have to nix out its
10693 ;; previous entry in the thread hashtb.
10695 (gnus-summary-article-sparse-p (mail-header-number header)))
10696 (let* ((parent (gnus-parent-id (mail-header-references header)))
10697 (thread (and parent (gnus-id-to-thread parent))))
10699 (delq (assq header thread) thread))))
10700 ;; We have to really fetch the header to this article.
10702 (set-buffer nntp-server-buffer)
10703 (when (setq where (gnus-request-head id group))
10704 (nnheader-fold-continuation-lines)
10705 (goto-char (point-max))
10707 (goto-char (point-min))
10711 ((cdr where) (cdr where))
10712 (header (mail-header-number header))
10713 (t gnus-reffed-article-number))
10715 (insert " Article retrieved.\n"))
10716 (if (or (not where)
10717 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10718 () ; Malformed head.
10719 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10720 (when (and (stringp id)
10721 (not (string= (gnus-group-real-name group)
10723 ;; If we fetched by Message-ID and the article came
10724 ;; from a different group, we fudge some bogus article
10725 ;; numbers for this article.
10726 (mail-header-set-number header gnus-reffed-article-number))
10728 (set-buffer gnus-summary-buffer)
10729 (decf gnus-reffed-article-number)
10730 (gnus-remove-header (mail-header-number header))
10731 (push header gnus-newsgroup-headers)
10732 (setq gnus-current-headers header)
10733 (push (mail-header-number header) gnus-newsgroup-limit)))
10736 (defun gnus-remove-header (number)
10737 "Remove header NUMBER from `gnus-newsgroup-headers'."
10738 (if (and gnus-newsgroup-headers
10739 (= number (mail-header-number (car gnus-newsgroup-headers))))
10740 (pop gnus-newsgroup-headers)
10741 (let ((headers gnus-newsgroup-headers))
10742 (while (and (cdr headers)
10743 (not (= number (mail-header-number (cadr headers)))))
10745 (when (cdr headers)
10746 (setcdr headers (cddr headers))))))
10749 ;;; summary highlights
10752 (defun gnus-highlight-selected-summary ()
10753 "Highlight selected article in summary buffer."
10754 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10755 (when gnus-summary-selected-face
10757 (let* ((beg (progn (beginning-of-line) (point)))
10758 (end (progn (end-of-line) (point)))
10759 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10760 (from (if (get-text-property beg gnus-mouse-face-prop)
10762 (or (next-single-property-change
10763 beg gnus-mouse-face-prop nil end)
10768 (or (next-single-property-change
10769 from gnus-mouse-face-prop nil end)
10771 ;; If no mouse-face prop on line we will have to = from = end,
10772 ;; so we highlight the entire line instead.
10773 (when (= (+ to 2) from)
10776 (if gnus-newsgroup-selected-overlay
10777 ;; Move old overlay.
10779 gnus-newsgroup-selected-overlay from to (current-buffer))
10780 ;; Create new overlay.
10782 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10783 'face gnus-summary-selected-face))))))
10785 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10786 (defun gnus-summary-highlight-line ()
10787 "Highlight current line according to `gnus-summary-highlight'."
10788 (let* ((list gnus-summary-highlight)
10789 (beg (gnus-point-at-bol))
10790 (article (gnus-summary-article-number))
10791 (score (or (cdr (assq (or article gnus-current-article)
10792 gnus-newsgroup-scored))
10793 gnus-summary-default-score 0))
10794 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10795 (inhibit-read-only t)
10796 (default gnus-summary-default-score)
10797 (default-high gnus-summary-default-high-score)
10798 (default-low gnus-summary-default-low-score))
10799 ;; Eval the cars of the lists until we find a match.
10801 (not (eval (caar list))))
10802 (setq list (cdr list)))
10803 (let ((face (cdar list)))
10804 (unless (eq face (get-text-property beg 'face))
10805 (gnus-put-text-property-excluding-characters-with-faces
10806 beg (gnus-point-at-eol) 'face
10807 (setq face (if (boundp face) (symbol-value face) face)))
10808 (when gnus-summary-highlight-line-function
10809 (funcall gnus-summary-highlight-line-function article face))))))
10811 (defun gnus-update-read-articles (group unread &optional compute)
10812 "Update the list of read articles in GROUP.
10813 UNREAD is a sorted list."
10814 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10815 (entry (gnus-gethash group gnus-newsrc-hashtb))
10816 (info (nth 2 entry))
10819 (if (or (not info) (not active))
10820 ;; There is no info on this group if it was, in fact,
10821 ;; killed. Gnus stores no information on killed groups, so
10822 ;; there's nothing to be done.
10823 ;; One could store the information somewhere temporarily,
10824 ;; perhaps... Hmmm...
10826 ;; Remove any negative articles numbers.
10827 (while (and unread (< (car unread) 0))
10828 (setq unread (cdr unread)))
10829 ;; Remove any expired article numbers
10830 (while (and unread (< (car unread) (car active)))
10831 (setq unread (cdr unread)))
10832 ;; Compute the ranges of read articles by looking at the list of
10833 ;; unread articles.
10835 (when (/= (car unread) prev)
10836 (push (if (= prev (1- (car unread))) prev
10837 (cons prev (1- (car unread))))
10839 (setq prev (1+ (car unread)))
10840 (setq unread (cdr unread)))
10841 (when (<= prev (cdr active))
10842 (push (cons prev (cdr active)) read))
10843 (setq read (if (> (length read) 1) (nreverse read) read))
10848 ;; Propagate the read marks to the backend.
10849 (when (gnus-check-backend-function 'request-set-mark group)
10850 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10851 (add (gnus-remove-from-range read (gnus-info-read info))))
10853 (unless (gnus-check-group group)
10854 (error "Can't open server for %s" group))
10855 (gnus-request-set-mark
10856 group (delq nil (list (if add (list add 'add '(read)))
10857 (if del (list del 'del '(read))))))
10859 `(gnus-request-set-mark
10862 (if del (list del 'add '(read)))
10863 (if add (list add 'del '(read))))))))))
10864 (set-buffer gnus-group-buffer)
10865 (gnus-undo-register
10867 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10868 (gnus-info-set-read ',info ',(gnus-info-read info))
10869 (gnus-get-unread-articles-in-group ',info
10870 (gnus-active ,group))
10871 (gnus-group-update-group ,group t)
10873 ;; Enter this list into the group info.
10874 (gnus-info-set-read info read)
10875 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10876 (gnus-get-unread-articles-in-group info (gnus-active group))
10879 (defun gnus-offer-save-summaries ()
10880 "Offer to save all active summary buffers."
10882 ;; Go through all buffers and find all summaries.
10883 (dolist (buffer (buffer-list))
10884 (when (and (setq buffer (buffer-name buffer))
10885 (string-match "Summary" buffer)
10887 (set-buffer buffer)
10888 ;; We check that this is, indeed, a summary buffer.
10889 (and (eq major-mode 'gnus-summary-mode)
10890 ;; Also make sure this isn't bogus.
10891 gnus-newsgroup-prepared
10892 ;; Also make sure that this isn't a
10893 ;; dead summary buffer.
10894 (not gnus-dead-summary-mode))))
10895 (push buffer buffers)))
10896 ;; Go through all these summary buffers and offer to save them.
10900 "Update summary buffer %s? "
10902 (switch-to-buffer buf)
10903 (gnus-summary-exit))
10906 (defun gnus-summary-setup-default-charset ()
10907 "Setup newsgroup default charset."
10908 (if (equal gnus-newsgroup-name "nndraft:drafts")
10909 (setq gnus-newsgroup-charset nil)
10910 (let* ((ignored-charsets
10911 (or gnus-newsgroup-ephemeral-ignored-charsets
10913 (and gnus-newsgroup-name
10914 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10915 gnus-newsgroup-ignored-charsets))))
10916 (setq gnus-newsgroup-charset
10917 (or gnus-newsgroup-ephemeral-charset
10918 (and gnus-newsgroup-name
10919 (gnus-parameter-charset gnus-newsgroup-name))
10920 gnus-default-charset))
10921 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10922 ignored-charsets))))
10928 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10929 "Display the current article buffer fully MIME-buttonized.
10930 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10931 treated as multipart/mixed."
10933 (require 'gnus-art)
10934 (let ((gnus-unbuttonized-mime-types nil)
10935 (gnus-mime-display-multipart-as-mixed show-all-parts))
10936 (gnus-summary-show-article)))
10938 (defun gnus-summary-repair-multipart (article)
10939 "Add a Content-Type header to a multipart article without one."
10940 (interactive (list (gnus-summary-article-number)))
10941 (gnus-with-article article
10942 (message-narrow-to-head)
10943 (message-remove-header "Mime-Version")
10944 (goto-char (point-max))
10945 (insert "Mime-Version: 1.0\n")
10947 (when (search-forward "\n--" nil t)
10948 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10949 (message-narrow-to-head)
10950 (message-remove-header "Content-Type")
10951 (goto-char (point-max))
10952 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10955 (let (gnus-mark-article-hook)
10956 (gnus-summary-select-article t t nil article)))
10958 (defun gnus-summary-toggle-display-buttonized ()
10959 "Toggle the buttonizing of the article buffer."
10961 (require 'gnus-art)
10962 (if (setq gnus-inhibit-mime-unbuttonizing
10963 (not gnus-inhibit-mime-unbuttonizing))
10964 (let ((gnus-unbuttonized-mime-types nil))
10965 (gnus-summary-show-article))
10966 (gnus-summary-show-article)))
10969 ;;; Generic summary marking commands
10972 (defvar gnus-summary-marking-alist
10973 '((read gnus-del-mark "d")
10974 (unread gnus-unread-mark "u")
10975 (ticked gnus-ticked-mark "!")
10976 (dormant gnus-dormant-mark "?")
10977 (expirable gnus-expirable-mark "e"))
10978 "An alist of names/marks/keystrokes.")
10980 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10981 (defvar gnus-summary-mark-map)
10983 (defun gnus-summary-make-all-marking-commands ()
10984 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10985 (dolist (elem gnus-summary-marking-alist)
10986 (apply 'gnus-summary-make-marking-command elem)))
10988 (defun gnus-summary-make-marking-command (name mark keystroke)
10989 (let ((map (make-sparse-keymap)))
10990 (define-key gnus-summary-generic-mark-map keystroke map)
10991 (dolist (lway `((next "next" next nil "n")
10992 (next-unread "next unread" next t "N")
10993 (prev "previous" prev nil "p")
10994 (prev-unread "previous unread" prev t "P")
10995 (nomove "" nil nil ,keystroke)))
10996 (let ((func (gnus-summary-make-marking-command-1
10997 mark (car lway) lway name)))
10998 (setq func (eval func))
10999 (define-key map (nth 4 lway) func)))))
11001 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11003 (format "gnus-summary-put-mark-as-%s%s"
11004 name (if (eq way 'nomove)
11006 (concat "-" (symbol-name way)))))
11009 "Mark the current article as %s%s.
11010 If N, the prefix, then repeat N times.
11011 If N is negative, move in reverse order.
11012 The difference between N and the actual number of articles marked is
11016 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11018 (defun gnus-summary-generic-mark (n mark move unread)
11019 "Mark N articles with MARK."
11020 (unless (eq major-mode 'gnus-summary-mode)
11021 (error "This command can only be used in the summary buffer"))
11022 (gnus-summary-show-thread)
11025 ((eq move 'next) 1)
11026 ((eq move 'prev) -1)
11028 (if (zerop nummove)
11032 nummove (* -1 nummove))))
11033 (while (and (> n 0)
11034 (gnus-summary-mark-article nil mark)
11035 (zerop (gnus-summary-next-subject nummove unread t)))
11038 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11039 (gnus-summary-recenter)
11040 (gnus-summary-position-point)
11041 (gnus-set-mode-line 'summary)
11044 (defun gnus-summary-insert-articles (articles)
11045 (when (setq articles
11046 (gnus-sorted-difference articles
11047 (mapcar (lambda (h)
11048 (mail-header-number h))
11049 gnus-newsgroup-headers)))
11050 (setq gnus-newsgroup-headers
11052 gnus-newsgroup-headers
11053 (gnus-fetch-headers articles)
11054 'gnus-article-sort-by-number))
11055 ;; Suppress duplicates?
11056 (when gnus-suppress-duplicates
11057 (gnus-dup-suppress-articles))
11059 ;; We might want to build some more threads first.
11060 (when (and gnus-fetch-old-headers
11061 (eq gnus-headers-retrieved-by 'nov))
11062 (if (eq gnus-fetch-old-headers 'invisible)
11063 (gnus-build-all-threads)
11064 (gnus-build-old-threads)))
11065 ;; Let the Gnus agent mark articles as read.
11067 (gnus-agent-get-undownloaded-list))
11068 ;; Remove list identifiers from subject
11069 (when gnus-list-identifiers
11070 (gnus-summary-remove-list-identifiers))
11071 ;; First and last article in this newsgroup.
11072 (when gnus-newsgroup-headers
11073 (setq gnus-newsgroup-begin
11074 (mail-header-number (car gnus-newsgroup-headers))
11076 (mail-header-number
11077 (gnus-last-element gnus-newsgroup-headers))))
11078 (when gnus-use-scoring
11079 (gnus-possibly-score-headers))))
11081 (defun gnus-summary-insert-old-articles (&optional all)
11082 "Insert all old articles in this group.
11083 If ALL is non-nil, already read articles become readable.
11084 If ALL is a number, fetch this number of articles."
11087 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11090 (gnus-sorted-difference
11091 (gnus-uncompress-range (list gnus-newsgroup-active))
11093 (setq len (length older))
11098 (setq older (last older all))))
11101 (if (and (numberp gnus-large-newsgroup)
11102 (> len gnus-large-newsgroup))
11103 (let* ((cursor-in-echo-area nil)
11104 (initial (gnus-parameter-large-newsgroup-initial
11105 gnus-newsgroup-name))
11109 "How many articles from %s (%s %d): "
11111 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11112 (if initial "max" "default")
11115 (cons (number-to-string initial)
11117 (unless (string-match "^[ \t]*$" input)
11118 (setq all (string-to-number input))
11120 (setq older (last older all))))))))
11122 (message "No old news.")
11123 (gnus-summary-insert-articles older)
11124 (gnus-summary-limit (gnus-sorted-nunion old older))))
11125 (gnus-summary-position-point)))
11127 (defun gnus-summary-insert-new-articles ()
11128 "Insert all new articles in this group."
11131 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11132 (old-active gnus-newsgroup-active)
11133 (nnmail-fetched-sources (list t))
11135 (setq gnus-newsgroup-active
11136 (gnus-activate-group gnus-newsgroup-name 'scan))
11137 (setq i (cdr gnus-newsgroup-active))
11138 (while (> i (cdr old-active))
11142 (message "No gnus is bad news.")
11143 (gnus-summary-insert-articles new)
11144 (setq gnus-newsgroup-unreads
11145 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11146 (gnus-summary-limit (gnus-sorted-nunion old new))))
11147 (gnus-summary-position-point)))
11149 (gnus-summary-make-all-marking-commands)
11151 (gnus-ems-redefine)
11153 (provide 'gnus-sum)
11155 (run-hooks 'gnus-sum-load-hook)
11157 ;;; gnus-sum.el ends here