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")
47 (defcustom gnus-kill-summary-on-exit t
48 "*If non-nil, kill the summary buffer when you exit from it.
49 If nil, the summary will become a \"*Dead Summary*\" buffer, and
50 it will be killed sometime later."
51 :group 'gnus-summary-exit
54 (defcustom gnus-fetch-old-headers nil
55 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
56 If an unread article in the group refers to an older, already read (or
57 just marked as read) article, the old article will not normally be
58 displayed in the Summary buffer. If this variable is non-nil, Gnus
59 will attempt to grab the headers to the old articles, and thereby
60 build complete threads. If it has the value `some', only enough
61 headers to connect otherwise loose threads will be displayed. This
62 variable can also be a number. In that case, no more than that number
63 of old headers will be fetched. If it has the value `invisible', all
64 old headers will be fetched, but none will be displayed.
66 The server has to support NOV for any of this to work."
68 :type '(choice (const :tag "off" nil)
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-refer-thread-limit 200
74 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
75 If t, fetch all the available old headers."
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-summary-make-false-root 'adopt
81 "*nil means that Gnus won't gather loose threads.
82 If the root of a thread has expired or been read in a previous
83 session, the information necessary to build a complete thread has been
84 lost. Instead of having many small sub-threads from this original thread
85 scattered all over the summary buffer, Gnus can gather them.
87 If non-nil, Gnus will try to gather all loose sub-threads from an
88 original thread into one large thread.
90 If this variable is non-nil, it should be one of `none', `adopt',
93 If this variable is `none', Gnus will not make a false root, but just
94 present the sub-threads after another.
95 If this variable is `dummy', Gnus will create a dummy root that will
96 have all the sub-threads as children.
97 If this variable is `adopt', Gnus will make one of the \"children\"
98 the parent and mark all the step-children as such.
99 If this variable is `empty', the \"children\" are printed with empty
100 subject fields. (Or rather, they will be printed with a string
101 given by the `gnus-summary-same-subject' variable.)"
103 :type '(choice (const :tag "off" nil)
109 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
110 "*A regexp to match subjects to be excluded from loose thread gathering.
111 As loose thread gathering is done on subjects only, that means that
112 there can be many false gatherings performed. By rooting out certain
113 common subjects, gathering might become saner."
117 (defcustom gnus-summary-gather-subject-limit nil
118 "*Maximum length of subject comparisons when gathering loose threads.
119 Use nil to compare full subjects. Setting this variable to a low
120 number will help gather threads that have been corrupted by
121 newsreaders chopping off subject lines, but it might also mean that
122 unrelated articles that have subject that happen to begin with the
123 same few characters will be incorrectly gathered.
125 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
128 :type '(choice (const :tag "off" nil)
130 (sexp :menu-tag "on" t)))
132 (defcustom gnus-simplify-subject-functions nil
133 "List of functions taking a string argument that simplify subjects.
134 The functions are applied recursively.
136 Useful functions to put in this list include: `gnus-simplify-subject-re',
137 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
139 :type '(repeat function))
141 (defcustom gnus-simplify-ignored-prefixes nil
142 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
144 :type '(choice (const :tag "off" nil)
147 (defcustom gnus-build-sparse-threads nil
148 "*If non-nil, fill in the gaps in threads.
149 If `some', only fill in the gaps that are needed to tie loose threads
150 together. If `more', fill in all leaf nodes that Gnus can find. If
151 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
153 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "all" t)))
158 (defcustom gnus-summary-thread-gathering-function
159 'gnus-gather-threads-by-subject
160 "*Function used for gathering loose threads.
161 There are two pre-defined functions: `gnus-gather-threads-by-subject',
162 which only takes Subjects into consideration; and
163 `gnus-gather-threads-by-references', which compared the References
164 headers of the articles to find matches."
166 :type '(radio (function-item gnus-gather-threads-by-subject)
167 (function-item gnus-gather-threads-by-references)
168 (function :tag "other")))
170 (defcustom gnus-summary-same-subject ""
171 "*String indicating that the current article has the same subject as the previous.
172 This variable will only be used if the value of
173 `gnus-summary-make-false-root' is `empty'."
174 :group 'gnus-summary-format
177 (defcustom gnus-summary-goto-unread t
178 "*If t, many commands will go to the next unread article.
179 This applies to marking commands as well as other commands that
180 \"naturally\" select the next article, like, for instance, `SPC' at
181 the end of an article.
183 If nil, the marking commands do NOT go to the next unread article
184 (they go to the next article instead). If `never', commands that
185 usually go to the next unread article, will go to the next article,
186 whether it is read or not."
187 :group 'gnus-summary-marks
188 :link '(custom-manual "(gnus)Setting Marks")
189 :type '(choice (const :tag "off" nil)
191 (sexp :menu-tag "on" t)))
193 (defcustom gnus-summary-default-score 0
194 "*Default article score level.
195 All scores generated by the score files will be added to this score.
196 If this variable is nil, scoring will be disabled."
197 :group 'gnus-score-default
198 :type '(choice (const :tag "disable")
201 (defcustom gnus-summary-default-high-score 0
202 "*Default threshold for a high scored article.
203 An article will be highlighted as high scored if its score is greater
205 :group 'gnus-score-default
208 (defcustom gnus-summary-default-low-score 0
209 "*Default threshold for a low scored article.
210 An article will be highlighted as low scored if its score is smaller
212 :group 'gnus-score-default
215 (defcustom gnus-summary-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 This can be a predicate specifier which says which threads to hide.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If non-nil, select the article under point.
282 Which article this is is controlled by the `gnus-auto-select-subject'
285 If you want to prevent automatic selection of articles in some
286 newsgroups, set the variable to nil in `gnus-select-group-hook'."
287 :group 'gnus-group-select
288 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)))
291 (defcustom gnus-auto-select-subject 'unread
292 "*Says what subject to place under point when entering a group.
294 This variable can either be the symbols `first' (place point on the
295 first subject), `unread' (place point on the subject line of the first
296 unread article), `best' (place point on the subject line of the
297 higest-scored article), `unseen' (place point on the subject line of
298 the first unseen article), or a function to be called to place point on
300 :group 'gnus-group-select
301 :type '(choice (const best)
306 (defcustom gnus-auto-select-next t
307 "*If non-nil, offer to go to the next group from the end of the previous.
308 If the value is t and the next newsgroup is empty, Gnus will exit
309 summary mode and go back to group mode. If the value is neither nil
310 nor t, Gnus will select the following unread newsgroup. In
311 particular, if the value is the symbol `quietly', the next unread
312 newsgroup will be selected without any confirmation, and if it is
313 `almost-quietly', the next group will be selected without any
314 confirmation if you are located on the last article in the group.
315 Finally, if this variable is `slightly-quietly', the `Z n' command
316 will go to the next group without confirmation."
317 :group 'gnus-summary-maneuvering
318 :type '(choice (const :tag "off" nil)
320 (const almost-quietly)
321 (const slightly-quietly)
322 (sexp :menu-tag "on" t)))
324 (defcustom gnus-auto-select-same nil
325 "*If non-nil, select the next article with the same subject.
326 If there are no more articles with the same subject, go to
327 the first unread article."
328 :group 'gnus-summary-maneuvering
331 (defcustom gnus-summary-check-current nil
332 "*If non-nil, consider the current article when moving.
333 The \"unread\" movement commands will stay on the same line if the
334 current article is unread."
335 :group 'gnus-summary-maneuvering
338 (defcustom gnus-auto-center-summary t
339 "*If non-nil, always center the current summary buffer.
340 In particular, if `vertical' do only vertical recentering. If non-nil
341 and non-`vertical', do both horizontal and vertical recentering."
342 :group 'gnus-summary-maneuvering
343 :type '(choice (const :tag "none" nil)
345 (integer :tag "height")
346 (sexp :menu-tag "both" t)))
348 (defcustom gnus-show-all-headers nil
349 "*If non-nil, don't hide any headers."
350 :group 'gnus-article-hiding
351 :group 'gnus-article-headers
354 (defcustom gnus-summary-ignore-duplicates nil
355 "*If non-nil, ignore articles with identical Message-ID headers."
359 (defcustom gnus-single-article-buffer t
360 "*If non-nil, display all articles in the same buffer.
361 If nil, each group will get its own article buffer."
362 :group 'gnus-article-various
365 (defcustom gnus-break-pages t
366 "*If non-nil, do page breaking on articles.
367 The page delimiter is specified by the `gnus-page-delimiter'
369 :group 'gnus-article-various
372 (defcustom gnus-move-split-methods nil
373 "*Variable used to suggest where articles are to be moved to.
374 It uses the same syntax as the `gnus-split-methods' variable.
375 However, whereas `gnus-split-methods' specifies file names as targets,
376 this variable specifies group names."
377 :group 'gnus-summary-mail
378 :type '(repeat (choice (list :value (fun) function)
379 (cons :value ("" "") regexp (repeat string))
382 (defcustom gnus-unread-mark ? ;Whitespace
383 "*Mark used for unread articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-ticked-mark ?!
388 "*Mark used for ticked articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-dormant-mark ??
393 "*Mark used for dormant articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-del-mark ?r
398 "*Mark used for del'd articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-read-mark ?R
403 "*Mark used for read articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-expirable-mark ?E
408 "*Mark used for expirable articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-killed-mark ?K
413 "*Mark used for killed articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-souped-mark ?F
418 "*Mark used for souped articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-kill-file-mark ?X
423 "*Mark used for articles killed by kill files."
424 :group 'gnus-summary-marks
427 (defcustom gnus-low-score-mark ?Y
428 "*Mark used for articles with a low score."
429 :group 'gnus-summary-marks
432 (defcustom gnus-catchup-mark ?C
433 "*Mark used for articles that are caught up."
434 :group 'gnus-summary-marks
437 (defcustom gnus-replied-mark ?A
438 "*Mark used for articles that have been replied to."
439 :group 'gnus-summary-marks
442 (defcustom gnus-forwarded-mark ?F
443 "*Mark used for articles that have been forwarded."
444 :group 'gnus-summary-marks
447 (defcustom gnus-recent-mark ?N
448 "*Mark used for articles that are recent."
449 :group 'gnus-summary-marks
452 (defcustom gnus-cached-mark ?*
453 "*Mark used for articles that are in the cache."
454 :group 'gnus-summary-marks
457 (defcustom gnus-saved-mark ?S
458 "*Mark used for articles that have been saved."
459 :group 'gnus-summary-marks
462 (defcustom gnus-unseen-mark ?.
463 "*Mark used for articles that haven't been seen."
464 :group 'gnus-summary-marks
467 (defcustom gnus-no-mark ? ;Whitespace
468 "*Mark used for articles that have no other secondary mark."
469 :group 'gnus-summary-marks
472 (defcustom gnus-ancient-mark ?O
473 "*Mark used for ancient articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-sparse-mark ?Q
478 "*Mark used for sparsely reffed articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-canceled-mark ?G
483 "*Mark used for canceled articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-duplicate-mark ?M
488 "*Mark used for duplicate articles."
489 :group 'gnus-summary-marks
492 (defcustom gnus-undownloaded-mark ?@
493 "*Mark used for articles that weren't downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-downloadable-mark ?%
498 "*Mark used for articles that are to be downloaded."
499 :group 'gnus-summary-marks
502 (defcustom gnus-unsendable-mark ?=
503 "*Mark used for articles that won't be sent."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-over-mark ?+
508 "*Score mark used for articles with high scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-score-below-mark ?-
513 "*Score mark used for articles with low scores."
514 :group 'gnus-summary-marks
517 (defcustom gnus-empty-thread-mark ? ;Whitespace
518 "*There is no thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-not-empty-thread-mark ?=
523 "*There is a thread under the article."
524 :group 'gnus-summary-marks
527 (defcustom gnus-view-pseudo-asynchronously nil
528 "*If non-nil, Gnus will view pseudo-articles asynchronously."
529 :group 'gnus-extract-view
532 (defcustom gnus-auto-expirable-marks
533 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
534 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
535 gnus-souped-mark gnus-duplicate-mark)
536 "*The list of marks converted into expiration if a group is auto-expirable."
539 :type '(repeat character))
541 (defcustom gnus-inhibit-user-auto-expire t
542 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
547 (defcustom gnus-view-pseudos nil
548 "*If `automatic', pseudo-articles will be viewed automatically.
549 If `not-confirm', pseudos will be viewed automatically, and the user
550 will not be asked to confirm the command."
551 :group 'gnus-extract-view
552 :type '(choice (const :tag "off" nil)
554 (const not-confirm)))
556 (defcustom gnus-view-pseudos-separately t
557 "*If non-nil, one pseudo-article will be created for each file to be viewed.
558 If nil, all files that use the same viewing command will be given as a
559 list of parameters to that command."
560 :group 'gnus-extract-view
563 (defcustom gnus-insert-pseudo-articles t
564 "*If non-nil, insert pseudo-articles when decoding articles."
565 :group 'gnus-extract-view
568 (defcustom gnus-summary-dummy-line-format
570 "*The format specification for the dummy roots in the summary buffer.
571 It works along the same lines as a normal formatting string,
572 with some simple extensions.
576 General format specifiers can also be used.
577 See (gnus)Formatting Variables."
578 :link '(custom-manual "(gnus)Formatting Variables")
579 :group 'gnus-threading
582 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
583 "*The format specification for the summary mode line.
584 It works along the same lines as a normal formatting string,
585 with some simple extensions:
588 %p Unprefixed group name
589 %A Current article number
590 %z Current article score
592 %U Number of unread articles in the group
593 %e Number of unselected articles in the group
594 %Z A string with unread/unselected article counts
595 %g Shortish group name
596 %S Subject of the current article
598 %s Current score file name
599 %d Number of dormant articles
600 %r Number of articles that have been marked as read in this session
601 %E Number of articles expunged by the score files"
602 :group 'gnus-summary-format
605 (defcustom gnus-list-identifiers nil
606 "Regexp that matches list identifiers to be removed from subject.
607 This can also be a list of regexps."
609 :group 'gnus-summary-format
610 :group 'gnus-article-hiding
611 :type '(choice (const :tag "none" nil)
613 (repeat :value (".*") regexp)))
615 (defcustom gnus-summary-mark-below 0
616 "*Mark all articles with a score below this variable as read.
617 This variable is local to each summary buffer and usually set by the
619 :group 'gnus-score-default
622 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
623 "*List of functions used for sorting articles in the summary buffer.
625 Each function takes two articles and returns non-nil if the first
626 article should be sorted before the other. If you use more than one
627 function, the primary sort function should be the last. You should
628 probably always include `gnus-article-sort-by-number' in the list of
629 sorting functions -- preferably first. Also note that sorting by date
630 is often much slower than sorting by number, and the sorting order is
631 very similar. (Sorting by date means sorting by the time the message
632 was sent, sorting by number means sorting by arrival time.)
634 Ready-made functions include `gnus-article-sort-by-number',
635 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
636 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
638 When threading is turned on, the variable `gnus-thread-sort-functions'
639 controls how articles are sorted."
640 :group 'gnus-summary-sort
641 :type '(repeat (choice (function-item gnus-article-sort-by-number)
642 (function-item gnus-article-sort-by-author)
643 (function-item gnus-article-sort-by-subject)
644 (function-item gnus-article-sort-by-date)
645 (function-item gnus-article-sort-by-score)
646 (function :tag "other"))))
648 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
649 "*List of functions used for sorting threads in the summary buffer.
650 By default, threads are sorted by article number.
652 Each function takes two threads and returns non-nil if the first
653 thread should be sorted before the other. If you use more than one
654 function, the primary sort function should be the last. You should
655 probably always include `gnus-thread-sort-by-number' in the list of
656 sorting functions -- preferably first. Also note that sorting by date
657 is often much slower than sorting by number, and the sorting order is
658 very similar. (Sorting by date means sorting by the time the message
659 was sent, sorting by number means sorting by arrival time.)
661 Ready-made functions include `gnus-thread-sort-by-number',
662 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
663 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
664 `gnus-thread-sort-by-most-recent-number',
665 `gnus-thread-sort-by-most-recent-date', and
666 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
668 When threading is turned off, the variable
669 `gnus-article-sort-functions' controls how articles are sorted."
670 :group 'gnus-summary-sort
671 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
672 (function-item gnus-thread-sort-by-author)
673 (function-item gnus-thread-sort-by-subject)
674 (function-item gnus-thread-sort-by-date)
675 (function-item gnus-thread-sort-by-score)
676 (function-item gnus-thread-sort-by-total-score)
677 (function :tag "other"))))
679 (defcustom gnus-thread-score-function '+
680 "*Function used for calculating the total score of a thread.
682 The function is called with the scores of the article and each
683 subthread and should then return the score of the thread.
685 Some functions you can use are `+', `max', or `min'."
686 :group 'gnus-summary-sort
689 (defcustom gnus-summary-expunge-below nil
690 "All articles that have a score less than this variable will be expunged.
691 This variable is local to the summary buffers."
692 :group 'gnus-score-default
693 :type '(choice (const :tag "off" nil)
696 (defcustom gnus-thread-expunge-below nil
697 "All threads that have a total score less than this variable will be expunged.
698 See `gnus-thread-score-function' for en explanation of what a
701 This variable is local to the summary buffers."
702 :group 'gnus-threading
703 :group 'gnus-score-default
704 :type '(choice (const :tag "off" nil)
707 (defcustom gnus-summary-mode-hook nil
708 "*A hook for Gnus summary mode.
709 This hook is run before any variables are set in the summary buffer."
710 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
711 :group 'gnus-summary-various
714 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
715 (when (featurep 'xemacs)
716 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
717 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
718 (add-hook 'gnus-summary-mode-hook
719 'gnus-xmas-switch-horizontal-scrollbar-off))
721 (defcustom gnus-summary-menu-hook nil
722 "*Hook run after the creation of the summary mode menu."
723 :group 'gnus-summary-visual
726 (defcustom gnus-summary-exit-hook nil
727 "*A hook called on exit from the summary buffer.
728 It will be called with point in the group buffer."
729 :group 'gnus-summary-exit
732 (defcustom gnus-summary-prepare-hook nil
733 "*A hook called after the summary buffer has been generated.
734 If you want to modify the summary buffer, you can use this hook."
735 :group 'gnus-summary-various
738 (defcustom gnus-summary-prepared-hook nil
739 "*A hook called as the last thing after the summary buffer has been generated."
740 :group 'gnus-summary-various
743 (defcustom gnus-summary-generate-hook nil
744 "*A hook run just before generating the summary buffer.
745 This hook is commonly used to customize threading variables and the
747 :group 'gnus-summary-various
750 (defcustom gnus-select-group-hook nil
751 "*A hook called when a newsgroup is selected.
753 If you'd like to simplify subjects like the
754 `gnus-summary-next-same-subject' command does, you can use the
757 (add-hook gnus-select-group-hook
759 (mapcar (lambda (header)
760 (mail-header-set-subject
762 (gnus-simplify-subject
763 (mail-header-subject header) 're-only)))
764 gnus-newsgroup-headers)))"
765 :group 'gnus-group-select
768 (defcustom gnus-select-article-hook nil
769 "*A hook called when an article is selected."
770 :group 'gnus-summary-choose
773 (defcustom gnus-visual-mark-article-hook
774 (list 'gnus-highlight-selected-summary)
775 "*Hook run after selecting an article in the summary buffer.
776 It is meant to be used for highlighting the article in some way. It
777 is not run if `gnus-visual' is nil."
778 :group 'gnus-summary-visual
781 (defcustom gnus-parse-headers-hook nil
782 "*A hook called before parsing the headers."
786 (defcustom gnus-exit-group-hook nil
787 "*A hook called when exiting summary mode.
788 This hook is not called from the non-updating exit commands like `Q'."
792 (defcustom gnus-summary-update-hook
793 (list 'gnus-summary-highlight-line)
794 "*A hook called when a summary line is changed.
795 The hook will not be called if `gnus-visual' is nil.
797 The default function `gnus-summary-highlight-line' will
798 highlight the line according to the `gnus-summary-highlight'
800 :group 'gnus-summary-visual
803 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
804 "*A hook called when an article is selected for the first time.
805 The hook is intended to mark an article as read (or unread)
806 automatically when it is selected."
807 :group 'gnus-summary-choose
810 (defcustom gnus-group-no-more-groups-hook nil
811 "*A hook run when returning to group mode having no more (unread) groups."
812 :group 'gnus-group-select
815 (defcustom gnus-ps-print-hook nil
816 "*A hook run before ps-printing something from Gnus."
820 (defcustom gnus-summary-display-arrow
821 (and (fboundp 'display-graphic-p)
823 "*If non-nil, display an arrow highlighting the current article."
828 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
829 "Face used for highlighting the current article in the summary buffer."
830 :group 'gnus-summary-visual
833 (defcustom gnus-summary-highlight
834 '(((= mark gnus-canceled-mark)
835 . gnus-summary-cancelled-face)
836 ((and (> score default-high)
837 (or (= mark gnus-dormant-mark)
838 (= mark gnus-ticked-mark)))
839 . gnus-summary-high-ticked-face)
840 ((and (< score default-low)
841 (or (= mark gnus-dormant-mark)
842 (= mark gnus-ticked-mark)))
843 . gnus-summary-low-ticked-face)
844 ((or (= mark gnus-dormant-mark)
845 (= mark gnus-ticked-mark))
846 . gnus-summary-normal-ticked-face)
847 ((and (> score default-high) (= mark gnus-ancient-mark))
848 . gnus-summary-high-ancient-face)
849 ((and (< score default-low) (= mark gnus-ancient-mark))
850 . gnus-summary-low-ancient-face)
851 ((= mark gnus-ancient-mark)
852 . gnus-summary-normal-ancient-face)
853 ((and (> score default-high) (= mark gnus-unread-mark))
854 . gnus-summary-high-unread-face)
855 ((and (< score default-low) (= mark gnus-unread-mark))
856 . gnus-summary-low-unread-face)
857 ((= mark gnus-unread-mark)
858 . gnus-summary-normal-unread-face)
859 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
860 gnus-undownloaded-mark)))
861 . gnus-summary-high-unread-face)
862 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
863 gnus-undownloaded-mark)))
864 . gnus-summary-low-unread-face)
865 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
866 (memq article gnus-newsgroup-unreads))
867 . gnus-summary-normal-unread-face)
868 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
869 . gnus-summary-normal-read-face)
870 ((> score default-high)
871 . gnus-summary-high-read-face)
872 ((< score default-low)
873 . gnus-summary-low-read-face)
875 . gnus-summary-normal-read-face))
876 "*Controls the highlighting of summary buffer lines.
878 A list of (FORM . FACE) pairs. When deciding how a a particular
879 summary line should be displayed, each form is evaluated. The content
880 of the face field after the first true form is used. You can change
881 how those summary lines are displayed, by editing the face field.
883 You can use the following variables in the FORM field.
885 score: The article's score
886 default: The default article score.
887 default-high: The default score for high scored articles.
888 default-low: The default score for low scored articles.
889 below: The score below which articles are automatically marked as read.
890 mark: The articles mark."
891 :group 'gnus-summary-visual
892 :type '(repeat (cons (sexp :tag "Form" nil)
895 (defcustom gnus-alter-header-function nil
896 "Function called to allow alteration of article header structures.
897 The function is called with one parameter, the article header vector,
898 which it may alter in any way.")
900 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
901 "Variable that says which function should be used to decode a string with encoded words.")
903 (defcustom gnus-extra-headers '(To Newsgroups)
904 "*Extra headers to parse."
907 :type '(repeat symbol))
909 (defcustom gnus-ignored-from-addresses
910 (and user-mail-address (regexp-quote user-mail-address))
911 "*Regexp of From headers that may be suppressed in favor of To headers."
916 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
917 "List of charsets that should be ignored.
918 When these charsets are used in the \"charset\" parameter, the
919 default charset will be used instead."
921 :type '(repeat symbol)
922 :group 'gnus-charset)
924 (gnus-define-group-parameter
928 "Return the ignored charsets of GROUP."
929 :variable gnus-group-ignored-charsets-alist
931 '(("alt\\.chinese\\.text" iso-8859-1))
933 "Alist of regexps (to match group names) and charsets that should be ignored.
934 When these charsets are used in the \"charset\" parameter, the
935 default charset will be used instead."
936 :variable-group gnus-charset
937 :variable-type '(repeat (cons (regexp :tag "Group")
939 :parameter-type '(choice :tag "Ignored charsets"
942 :parameter-document "\
943 List of charsets that should be ignored.
945 When these charsets are used in the \"charset\" parameter, the
946 default charset will be used instead.")
948 (defcustom gnus-group-highlight-words-alist nil
949 "Alist of group regexps and highlight regexps.
950 This variable uses the same syntax as `gnus-emphasis-alist'."
952 :type '(repeat (cons (regexp :tag "Group")
953 (repeat (list (regexp :tag "Highlight regexp")
954 (number :tag "Group for entire word" 0)
955 (number :tag "Group for displayed part" 0)
957 gnus-emphasis-highlight-words)))))
958 :group 'gnus-summary-visual)
960 (defcustom gnus-summary-show-article-charset-alist
962 "Alist of number and charset.
963 The article will be shown with the charset corresponding to the
965 For example: ((1 . cn-gb-2312) (2 . big5))."
967 :type '(repeat (cons (number :tag "Argument" 1)
968 (symbol :tag "Charset")))
969 :group 'gnus-charset)
971 (defcustom gnus-preserve-marks t
972 "Whether marks are preserved when moving, copying and respooling messages."
975 :group 'gnus-summary-marks)
977 (defcustom gnus-alter-articles-to-read-function nil
978 "Function to be called to alter the list of articles to be selected."
979 :type '(choice (const nil) function)
980 :group 'gnus-summary)
982 (defcustom gnus-orphan-score nil
983 "*All orphans get this score added. Set in the score file."
984 :group 'gnus-score-default
985 :type '(choice (const nil)
988 (defcustom gnus-summary-save-parts-default-mime "image/.*"
989 "*A regexp to match MIME parts when saving multiple parts of a message
990 with gnus-summary-save-parts (X m). This regexp will be used by default
991 when prompting the user for which type of files to save."
996 (defcustom gnus-summary-save-parts-default-mime "image/.*"
997 "*A regexp to match MIME parts when saving multiple parts of a message
998 with gnus-summary-save-parts (X m). This regexp will be used by default
999 when prompting the user for which type of files to save."
1000 :group 'gnus-summary
1003 (defcustom gnus-read-all-available-headers nil
1004 "Whether Gnus should parse all headers made available to it.
1005 This is mostly relevant for slow backends where the user may
1006 wish to widen the summary buffer to include all headers
1007 that were fetched. Say, for nnultimate groups."
1008 :group 'gnus-summary
1009 :type '(choice boolean regexp))
1011 (defcustom gnus-summary-muttprint-program "muttprint"
1012 "Command (and optional arguments) used to run Muttprint."
1013 :group 'gnus-summary
1016 ;;; Internal variables
1018 (defvar gnus-summary-display-cache nil)
1019 (defvar gnus-article-mime-handles nil)
1020 (defvar gnus-article-decoded-p nil)
1021 (defvar gnus-article-charset nil)
1022 (defvar gnus-article-ignored-charsets nil)
1023 (defvar gnus-scores-exclude-files nil)
1024 (defvar gnus-page-broken nil)
1025 (defvar gnus-inhibit-mime-unbuttonizing nil)
1027 (defvar gnus-original-article nil)
1028 (defvar gnus-article-internal-prepare-hook nil)
1029 (defvar gnus-newsgroup-process-stack nil)
1031 (defvar gnus-thread-indent-array nil)
1032 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1033 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1034 "Function called to sort the articles within a thread after it has been gathered together.")
1036 (defvar gnus-summary-save-parts-type-history nil)
1037 (defvar gnus-summary-save-parts-last-directory nil)
1039 (defvar gnus-summary-save-parts-type-history nil)
1040 (defvar gnus-summary-save-parts-last-directory nil)
1042 ;; Avoid highlighting in kill files.
1043 (defvar gnus-summary-inhibit-highlight nil)
1044 (defvar gnus-newsgroup-selected-overlay nil)
1045 (defvar gnus-inhibit-limiting nil)
1046 (defvar gnus-newsgroup-adaptive-score-file nil)
1047 (defvar gnus-current-score-file nil)
1048 (defvar gnus-current-move-group nil)
1049 (defvar gnus-current-copy-group nil)
1050 (defvar gnus-current-crosspost-group nil)
1051 (defvar gnus-newsgroup-display nil)
1053 (defvar gnus-newsgroup-dependencies nil)
1054 (defvar gnus-newsgroup-adaptive nil)
1055 (defvar gnus-summary-display-article-function nil)
1056 (defvar gnus-summary-highlight-line-function nil
1057 "Function called after highlighting a summary line.")
1059 (defvar gnus-summary-line-format-alist
1060 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1061 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1062 (?s gnus-tmp-subject-or-nil ?s)
1063 (?n gnus-tmp-name ?s)
1064 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1066 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1068 (?F gnus-tmp-from ?s)
1069 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1070 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1071 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1072 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1073 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1074 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1075 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1076 (?L gnus-tmp-lines ?s)
1077 (?I gnus-tmp-indentation ?s)
1078 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1079 (?R gnus-tmp-replied ?c)
1080 (?\[ gnus-tmp-opening-bracket ?c)
1081 (?\] gnus-tmp-closing-bracket ?c)
1082 (?\> (make-string gnus-tmp-level ? ) ?s)
1083 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1084 (?i gnus-tmp-score ?d)
1085 (?z gnus-tmp-score-char ?c)
1086 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1087 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1088 (?U gnus-tmp-unread ?c)
1089 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1091 (?t (gnus-summary-number-of-articles-in-thread
1092 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1094 (?e (gnus-summary-number-of-articles-in-thread
1095 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1097 (?u gnus-tmp-user-defined ?s)
1098 (?P (gnus-pick-line-number) ?d)
1099 (?B gnus-tmp-thread-tree-header-string ?s)
1100 (user-date (gnus-user-date
1101 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1102 "An alist of format specifications that can appear in summary lines.
1103 These are paired with what variables they correspond with, along with
1104 the type of the variable (string, integer, character, etc).")
1106 (defvar gnus-summary-dummy-line-format-alist
1107 `((?S gnus-tmp-subject ?s)
1108 (?N gnus-tmp-number ?d)
1109 (?u gnus-tmp-user-defined ?s)))
1111 (defvar gnus-summary-mode-line-format-alist
1112 `((?G gnus-tmp-group-name ?s)
1113 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1114 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1115 (?A gnus-tmp-article-number ?d)
1116 (?Z gnus-tmp-unread-and-unselected ?s)
1117 (?V gnus-version ?s)
1118 (?U gnus-tmp-unread-and-unticked ?d)
1119 (?S gnus-tmp-subject ?s)
1120 (?e gnus-tmp-unselected ?d)
1121 (?u gnus-tmp-user-defined ?s)
1122 (?d (length gnus-newsgroup-dormant) ?d)
1123 (?t (length gnus-newsgroup-marked) ?d)
1124 (?r (length gnus-newsgroup-reads) ?d)
1125 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1126 (?E gnus-newsgroup-expunged-tally ?d)
1127 (?s (gnus-current-score-file-nondirectory) ?s)))
1129 (defvar gnus-last-search-regexp nil
1130 "Default regexp for article search command.")
1132 (defvar gnus-last-shell-command nil
1133 "Default shell command on article.")
1135 (defvar gnus-newsgroup-begin nil)
1136 (defvar gnus-newsgroup-end nil)
1137 (defvar gnus-newsgroup-last-rmail nil)
1138 (defvar gnus-newsgroup-last-mail nil)
1139 (defvar gnus-newsgroup-last-folder nil)
1140 (defvar gnus-newsgroup-last-file nil)
1141 (defvar gnus-newsgroup-auto-expire nil)
1142 (defvar gnus-newsgroup-active nil)
1144 (defvar gnus-newsgroup-data nil)
1145 (defvar gnus-newsgroup-data-reverse nil)
1146 (defvar gnus-newsgroup-limit nil)
1147 (defvar gnus-newsgroup-limits nil)
1149 (defvar gnus-newsgroup-unreads nil
1150 "List of unread articles in the current newsgroup.")
1152 (defvar gnus-newsgroup-unselected nil
1153 "List of unselected unread articles in the current newsgroup.")
1155 (defvar gnus-newsgroup-reads nil
1156 "Alist of read articles and article marks in the current newsgroup.")
1158 (defvar gnus-newsgroup-expunged-tally nil)
1160 (defvar gnus-newsgroup-marked nil
1161 "List of ticked articles in the current newsgroup (a subset of unread art).")
1163 (defvar gnus-newsgroup-killed nil
1164 "List of ranges of articles that have been through the scoring process.")
1166 (defvar gnus-newsgroup-cached nil
1167 "List of articles that come from the article cache.")
1169 (defvar gnus-newsgroup-saved nil
1170 "List of articles that have been saved.")
1172 (defvar gnus-newsgroup-kill-headers nil)
1174 (defvar gnus-newsgroup-replied nil
1175 "List of articles that have been replied to in the current newsgroup.")
1177 (defvar gnus-newsgroup-forwarded nil
1178 "List of articles that have been forwarded in the current newsgroup.")
1180 (defvar gnus-newsgroup-recent nil
1181 "List of articles that have are recent in the current newsgroup.")
1183 (defvar gnus-newsgroup-expirable nil
1184 "List of articles in the current newsgroup that can be expired.")
1186 (defvar gnus-newsgroup-processable nil
1187 "List of articles in the current newsgroup that can be processed.")
1189 (defvar gnus-newsgroup-downloadable nil
1190 "List of articles in the current newsgroup that can be processed.")
1192 (defvar gnus-newsgroup-undownloaded nil
1193 "List of articles in the current newsgroup that haven't been downloaded..")
1195 (defvar gnus-newsgroup-unsendable nil
1196 "List of articles in the current newsgroup that won't be sent.")
1198 (defvar gnus-newsgroup-bookmarks nil
1199 "List of articles in the current newsgroup that have bookmarks.")
1201 (defvar gnus-newsgroup-dormant nil
1202 "List of dormant articles in the current newsgroup.")
1204 (defvar gnus-newsgroup-unseen nil
1205 "List of unseen articles in the current newsgroup.")
1207 (defvar gnus-newsgroup-seen nil
1208 "Range of seen articles in the current newsgroup.")
1210 (defvar gnus-newsgroup-articles nil
1211 "List of articles in the current newsgroup.")
1213 (defvar gnus-newsgroup-scored nil
1214 "List of scored articles in the current newsgroup.")
1216 (defvar gnus-newsgroup-headers nil
1217 "List of article headers in the current newsgroup.")
1219 (defvar gnus-newsgroup-threads nil)
1221 (defvar gnus-newsgroup-prepared nil
1222 "Whether the current group has been prepared properly.")
1224 (defvar gnus-newsgroup-ancient nil
1225 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1227 (defvar gnus-newsgroup-sparse nil)
1229 (defvar gnus-current-article nil)
1230 (defvar gnus-article-current nil)
1231 (defvar gnus-current-headers nil)
1232 (defvar gnus-have-all-headers nil)
1233 (defvar gnus-last-article nil)
1234 (defvar gnus-newsgroup-history nil)
1235 (defvar gnus-newsgroup-charset nil)
1236 (defvar gnus-newsgroup-ephemeral-charset nil)
1237 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1239 (defvar gnus-article-before-search nil)
1241 (defconst gnus-summary-local-variables
1242 '(gnus-newsgroup-name
1243 gnus-newsgroup-begin gnus-newsgroup-end
1244 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1245 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1246 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1247 gnus-newsgroup-unselected gnus-newsgroup-marked
1248 gnus-newsgroup-reads gnus-newsgroup-saved
1249 gnus-newsgroup-replied gnus-newsgroup-forwarded
1250 gnus-newsgroup-recent
1251 gnus-newsgroup-expirable
1252 gnus-newsgroup-processable gnus-newsgroup-killed
1253 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1254 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1255 gnus-newsgroup-seen gnus-newsgroup-articles
1256 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1257 gnus-newsgroup-headers gnus-newsgroup-threads
1258 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1259 gnus-current-article gnus-current-headers gnus-have-all-headers
1260 gnus-last-article gnus-article-internal-prepare-hook
1261 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1262 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1263 gnus-thread-expunge-below
1264 gnus-score-alist gnus-current-score-file
1265 (gnus-summary-expunge-below . global)
1266 (gnus-summary-mark-below . global)
1267 (gnus-orphan-score . global)
1268 gnus-newsgroup-active gnus-scores-exclude-files
1269 gnus-newsgroup-history gnus-newsgroup-ancient
1270 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1271 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1272 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1273 (gnus-newsgroup-expunged-tally . 0)
1274 gnus-cache-removable-articles gnus-newsgroup-cached
1275 gnus-newsgroup-data gnus-newsgroup-data-reverse
1276 gnus-newsgroup-limit gnus-newsgroup-limits
1277 gnus-newsgroup-charset gnus-newsgroup-display)
1278 "Variables that are buffer-local to the summary buffers.")
1280 (defvar gnus-newsgroup-variables nil
1281 "A list of variables that have separate values in different newsgroups.
1282 A list of newsgroup (summary buffer) local variables, or cons of
1283 variables and their default values (when the default values are not
1284 nil), that should be made global while the summary buffer is active.
1285 These variables can be used to set variables in the group parameters
1286 while still allowing them to affect operations done in other
1287 buffers. For example:
1289 \(setq gnus-newsgroup-variables
1290 '(message-use-followup-to
1291 (gnus-visible-headers .
1292 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1295 ;; Byte-compiler warning.
1296 (eval-when-compile (defvar gnus-article-mode-map))
1300 (defvar gnus-decode-encoded-word-methods
1301 '(mail-decode-encoded-word-string)
1302 "List of methods used to decode encoded words.
1304 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1305 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1306 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1307 whose names match REGEXP.
1310 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1311 mail-decode-encoded-word-string
1312 (\"chinese\" . rfc1843-decode-string))")
1314 (defvar gnus-decode-encoded-word-methods-cache nil)
1316 (defun gnus-multi-decode-encoded-word-string (string)
1317 "Apply the functions from `gnus-encoded-word-methods' that match."
1318 (unless (and gnus-decode-encoded-word-methods-cache
1319 (eq gnus-newsgroup-name
1320 (car gnus-decode-encoded-word-methods-cache)))
1321 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1324 (nconc gnus-decode-encoded-word-methods-cache (list x))
1325 (if (and gnus-newsgroup-name
1326 (string-match (car x) gnus-newsgroup-name))
1327 (nconc gnus-decode-encoded-word-methods-cache
1329 gnus-decode-encoded-word-methods))
1330 (let ((xlist gnus-decode-encoded-word-methods-cache))
1333 (setq string (funcall (pop xlist) string))))
1336 ;; Subject simplification.
1338 (defun gnus-simplify-whitespace (str)
1339 "Remove excessive whitespace from STR."
1342 (while (string-match "[ \t][ \t]+" mystr)
1343 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1345 (substring mystr (match-end 0)))))
1347 (when (string-match "^[ \t]+" mystr)
1348 (setq mystr (substring mystr (match-end 0))))
1350 (when (string-match "[ \t]+$" mystr)
1351 (setq mystr (substring mystr 0 (match-beginning 0))))
1354 (defsubst gnus-simplify-subject-re (subject)
1355 "Remove \"Re:\" from subject lines."
1356 (if (string-match message-subject-re-regexp subject)
1357 (substring subject (match-end 0))
1360 (defun gnus-simplify-subject (subject &optional re-only)
1361 "Remove `Re:' and words in parentheses.
1362 If RE-ONLY is non-nil, strip leading `Re:'s only."
1363 (let ((case-fold-search t)) ;Ignore case.
1364 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1365 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1366 (setq subject (substring subject (match-end 0))))
1367 ;; Remove uninteresting prefixes.
1368 (when (and (not re-only)
1369 gnus-simplify-ignored-prefixes
1370 (string-match gnus-simplify-ignored-prefixes subject))
1371 (setq subject (substring subject (match-end 0))))
1372 ;; Remove words in parentheses from end.
1374 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1375 (setq subject (substring subject 0 (match-beginning 0)))))
1376 ;; Return subject string.
1379 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1381 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1382 (goto-char (point-min))
1383 (while (re-search-forward regexp nil t)
1384 (replace-match (or newtext ""))))
1386 (defun gnus-simplify-buffer-fuzzy ()
1387 "Simplify string in the buffer fuzzily.
1388 The string in the accessible portion of the current buffer is simplified.
1389 It is assumed to be a single-line subject.
1390 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1391 matter is removed. Additional things can be deleted by setting
1392 `gnus-simplify-subject-fuzzy-regexp'."
1393 (let ((case-fold-search t)
1395 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1397 (while (not (eq modified-tick (buffer-modified-tick)))
1398 (setq modified-tick (buffer-modified-tick))
1400 ((listp gnus-simplify-subject-fuzzy-regexp)
1401 (mapcar 'gnus-simplify-buffer-fuzzy-step
1402 gnus-simplify-subject-fuzzy-regexp))
1403 (gnus-simplify-subject-fuzzy-regexp
1404 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1405 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1406 (gnus-simplify-buffer-fuzzy-step
1407 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1408 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1410 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1411 (gnus-simplify-buffer-fuzzy-step " +" " ")
1412 (gnus-simplify-buffer-fuzzy-step " $")
1413 (gnus-simplify-buffer-fuzzy-step "^ +")))
1415 (defun gnus-simplify-subject-fuzzy (subject)
1416 "Simplify a subject string fuzzily.
1417 See `gnus-simplify-buffer-fuzzy' for details."
1419 (gnus-set-work-buffer)
1420 (let ((case-fold-search t))
1421 ;; Remove uninteresting prefixes.
1422 (when (and gnus-simplify-ignored-prefixes
1423 (string-match gnus-simplify-ignored-prefixes subject))
1424 (setq subject (substring subject (match-end 0))))
1426 (inline (gnus-simplify-buffer-fuzzy))
1429 (defsubst gnus-simplify-subject-fully (subject)
1430 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1432 (gnus-simplify-subject-functions
1433 (gnus-map-function gnus-simplify-subject-functions subject))
1434 ((null gnus-summary-gather-subject-limit)
1435 (gnus-simplify-subject-re subject))
1436 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1437 (gnus-simplify-subject-fuzzy subject))
1438 ((numberp gnus-summary-gather-subject-limit)
1439 (gnus-limit-string (gnus-simplify-subject-re subject)
1440 gnus-summary-gather-subject-limit))
1444 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1445 "Check whether two subjects are equal.
1446 If optional argument simple-first is t, first argument is already
1449 ((null simple-first)
1450 (equal (gnus-simplify-subject-fully s1)
1451 (gnus-simplify-subject-fully s2)))
1454 (gnus-simplify-subject-fully s2)))))
1456 (defun gnus-summary-bubble-group ()
1457 "Increase the score of the current group.
1458 This is a handy function to add to `gnus-summary-exit-hook' to
1459 increase the score of each group you read."
1460 (gnus-group-add-score gnus-newsgroup-name))
1464 ;;; Gnus summary mode
1467 (put 'gnus-summary-mode 'mode-class 'special)
1469 (defvar gnus-article-commands-menu)
1472 ;; Non-orthogonal keys
1474 (gnus-define-keys gnus-summary-mode-map
1475 " " gnus-summary-next-page
1476 "\177" gnus-summary-prev-page
1477 [delete] gnus-summary-prev-page
1478 [backspace] gnus-summary-prev-page
1479 "\r" gnus-summary-scroll-up
1480 "\M-\r" gnus-summary-scroll-down
1481 "n" gnus-summary-next-unread-article
1482 "p" gnus-summary-prev-unread-article
1483 "N" gnus-summary-next-article
1484 "P" gnus-summary-prev-article
1485 "\M-\C-n" gnus-summary-next-same-subject
1486 "\M-\C-p" gnus-summary-prev-same-subject
1487 "\M-n" gnus-summary-next-unread-subject
1488 "\M-p" gnus-summary-prev-unread-subject
1489 "." gnus-summary-first-unread-article
1490 "," gnus-summary-best-unread-article
1491 "\M-s" gnus-summary-search-article-forward
1492 "\M-r" gnus-summary-search-article-backward
1493 "<" gnus-summary-beginning-of-article
1494 ">" gnus-summary-end-of-article
1495 "j" gnus-summary-goto-article
1496 "^" gnus-summary-refer-parent-article
1497 "\M-^" gnus-summary-refer-article
1498 "u" gnus-summary-tick-article-forward
1499 "!" gnus-summary-tick-article-forward
1500 "U" gnus-summary-tick-article-backward
1501 "d" gnus-summary-mark-as-read-forward
1502 "D" gnus-summary-mark-as-read-backward
1503 "E" gnus-summary-mark-as-expirable
1504 "\M-u" gnus-summary-clear-mark-forward
1505 "\M-U" gnus-summary-clear-mark-backward
1506 "k" gnus-summary-kill-same-subject-and-select
1507 "\C-k" gnus-summary-kill-same-subject
1508 "\M-\C-k" gnus-summary-kill-thread
1509 "\M-\C-l" gnus-summary-lower-thread
1510 "e" gnus-summary-edit-article
1511 "#" gnus-summary-mark-as-processable
1512 "\M-#" gnus-summary-unmark-as-processable
1513 "\M-\C-t" gnus-summary-toggle-threads
1514 "\M-\C-s" gnus-summary-show-thread
1515 "\M-\C-h" gnus-summary-hide-thread
1516 "\M-\C-f" gnus-summary-next-thread
1517 "\M-\C-b" gnus-summary-prev-thread
1518 [(meta down)] gnus-summary-next-thread
1519 [(meta up)] gnus-summary-prev-thread
1520 "\M-\C-u" gnus-summary-up-thread
1521 "\M-\C-d" gnus-summary-down-thread
1522 "&" gnus-summary-execute-command
1523 "c" gnus-summary-catchup-and-exit
1524 "\C-w" gnus-summary-mark-region-as-read
1525 "\C-t" gnus-summary-toggle-truncation
1526 "?" gnus-summary-mark-as-dormant
1527 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1528 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1529 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1530 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1531 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1532 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1533 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1534 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1535 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1536 "=" gnus-summary-expand-window
1537 "\C-x\C-s" gnus-summary-reselect-current-group
1538 "\M-g" gnus-summary-rescan-group
1539 "w" gnus-summary-stop-page-breaking
1540 "\C-c\C-r" gnus-summary-caesar-message
1541 "f" gnus-summary-followup
1542 "F" gnus-summary-followup-with-original
1543 "C" gnus-summary-cancel-article
1544 "r" gnus-summary-reply
1545 "R" gnus-summary-reply-with-original
1546 "\C-c\C-f" gnus-summary-mail-forward
1547 "o" gnus-summary-save-article
1548 "\C-o" gnus-summary-save-article-mail
1549 "|" gnus-summary-pipe-output
1550 "\M-k" gnus-summary-edit-local-kill
1551 "\M-K" gnus-summary-edit-global-kill
1553 "\C-c\C-d" gnus-summary-describe-group
1554 "q" gnus-summary-exit
1555 "Q" gnus-summary-exit-no-update
1556 "\C-c\C-i" gnus-info-find-node
1557 gnus-mouse-2 gnus-mouse-pick-article
1558 "m" gnus-summary-mail-other-window
1559 "a" gnus-summary-post-news
1560 "i" gnus-summary-news-other-window
1561 "x" gnus-summary-limit-to-unread
1562 "s" gnus-summary-isearch-article
1563 "t" gnus-summary-toggle-header
1564 "g" gnus-summary-show-article
1565 "l" gnus-summary-goto-last-article
1566 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1567 "\C-d" gnus-summary-enter-digest-group
1568 "\M-\C-d" gnus-summary-read-document
1569 "\M-\C-e" gnus-summary-edit-parameters
1570 "\M-\C-a" gnus-summary-customize-parameters
1572 "*" gnus-cache-enter-article
1573 "\M-*" gnus-cache-remove-article
1574 "\M-&" gnus-summary-universal-argument
1575 "\C-l" gnus-recenter
1576 "I" gnus-summary-increase-score
1577 "L" gnus-summary-lower-score
1578 "\M-i" gnus-symbolic-argument
1579 "h" gnus-summary-select-article-buffer
1581 "b" gnus-article-view-part
1582 "\M-t" gnus-summary-toggle-display-buttonized
1584 "V" gnus-summary-score-map
1585 "X" gnus-uu-extract-map
1586 "S" gnus-summary-send-map)
1588 ;; Sort of orthogonal keymap
1589 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1590 "t" gnus-summary-tick-article-forward
1591 "!" gnus-summary-tick-article-forward
1592 "d" gnus-summary-mark-as-read-forward
1593 "r" gnus-summary-mark-as-read-forward
1594 "c" gnus-summary-clear-mark-forward
1595 " " gnus-summary-clear-mark-forward
1596 "e" gnus-summary-mark-as-expirable
1597 "x" gnus-summary-mark-as-expirable
1598 "?" gnus-summary-mark-as-dormant
1599 "b" gnus-summary-set-bookmark
1600 "B" gnus-summary-remove-bookmark
1601 "#" gnus-summary-mark-as-processable
1602 "\M-#" gnus-summary-unmark-as-processable
1603 "S" gnus-summary-limit-include-expunged
1604 "C" gnus-summary-catchup
1605 "H" gnus-summary-catchup-to-here
1606 "h" gnus-summary-catchup-from-here
1607 "\C-c" gnus-summary-catchup-all
1608 "k" gnus-summary-kill-same-subject-and-select
1609 "K" gnus-summary-kill-same-subject
1610 "P" gnus-uu-mark-map)
1612 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1613 "c" gnus-summary-clear-above
1614 "u" gnus-summary-tick-above
1615 "m" gnus-summary-mark-above
1616 "k" gnus-summary-kill-below)
1618 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1619 "/" gnus-summary-limit-to-subject
1620 "n" gnus-summary-limit-to-articles
1621 "w" gnus-summary-pop-limit
1622 "s" gnus-summary-limit-to-subject
1623 "a" gnus-summary-limit-to-author
1624 "u" gnus-summary-limit-to-unread
1625 "m" gnus-summary-limit-to-marks
1626 "M" gnus-summary-limit-exclude-marks
1627 "v" gnus-summary-limit-to-score
1628 "*" gnus-summary-limit-include-cached
1629 "D" gnus-summary-limit-include-dormant
1630 "T" gnus-summary-limit-include-thread
1631 "d" gnus-summary-limit-exclude-dormant
1632 "t" gnus-summary-limit-to-age
1633 "x" gnus-summary-limit-to-extra
1634 "p" gnus-summary-limit-to-display-predicate
1635 "E" gnus-summary-limit-include-expunged
1636 "c" gnus-summary-limit-exclude-childless-dormant
1637 "C" gnus-summary-limit-mark-excluded-as-read
1638 "o" gnus-summary-insert-old-articles
1639 "N" gnus-summary-insert-new-articles)
1641 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1642 "n" gnus-summary-next-unread-article
1643 "p" gnus-summary-prev-unread-article
1644 "N" gnus-summary-next-article
1645 "P" gnus-summary-prev-article
1646 "\C-n" gnus-summary-next-same-subject
1647 "\C-p" gnus-summary-prev-same-subject
1648 "\M-n" gnus-summary-next-unread-subject
1649 "\M-p" gnus-summary-prev-unread-subject
1650 "f" gnus-summary-first-unread-article
1651 "b" gnus-summary-best-unread-article
1652 "j" gnus-summary-goto-article
1653 "g" gnus-summary-goto-subject
1654 "l" gnus-summary-goto-last-article
1655 "o" gnus-summary-pop-article)
1657 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1658 "k" gnus-summary-kill-thread
1659 "l" gnus-summary-lower-thread
1660 "i" gnus-summary-raise-thread
1661 "T" gnus-summary-toggle-threads
1662 "t" gnus-summary-rethread-current
1663 "^" gnus-summary-reparent-thread
1664 "s" gnus-summary-show-thread
1665 "S" gnus-summary-show-all-threads
1666 "h" gnus-summary-hide-thread
1667 "H" gnus-summary-hide-all-threads
1668 "n" gnus-summary-next-thread
1669 "p" gnus-summary-prev-thread
1670 "u" gnus-summary-up-thread
1671 "o" gnus-summary-top-thread
1672 "d" gnus-summary-down-thread
1673 "#" gnus-uu-mark-thread
1674 "\M-#" gnus-uu-unmark-thread)
1676 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1677 "g" gnus-summary-prepare
1678 "c" gnus-summary-insert-cached-articles)
1680 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1681 "c" gnus-summary-catchup-and-exit
1682 "C" gnus-summary-catchup-all-and-exit
1683 "E" gnus-summary-exit-no-update
1684 "Q" gnus-summary-exit
1685 "Z" gnus-summary-exit
1686 "n" gnus-summary-catchup-and-goto-next-group
1687 "R" gnus-summary-reselect-current-group
1688 "G" gnus-summary-rescan-group
1689 "N" gnus-summary-next-group
1690 "s" gnus-summary-save-newsrc
1691 "P" gnus-summary-prev-group)
1693 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1694 " " gnus-summary-next-page
1695 "n" gnus-summary-next-page
1696 "\177" gnus-summary-prev-page
1697 [delete] gnus-summary-prev-page
1698 "p" gnus-summary-prev-page
1699 "\r" gnus-summary-scroll-up
1700 "\M-\r" gnus-summary-scroll-down
1701 "<" gnus-summary-beginning-of-article
1702 ">" gnus-summary-end-of-article
1703 "b" gnus-summary-beginning-of-article
1704 "e" gnus-summary-end-of-article
1705 "^" gnus-summary-refer-parent-article
1706 "r" gnus-summary-refer-parent-article
1707 "D" gnus-summary-enter-digest-group
1708 "R" gnus-summary-refer-references
1709 "T" gnus-summary-refer-thread
1710 "g" gnus-summary-show-article
1711 "s" gnus-summary-isearch-article
1712 "P" gnus-summary-print-article
1713 "M" gnus-mailing-list-insinuate
1714 "t" gnus-article-babel)
1716 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1717 "b" gnus-article-add-buttons
1718 "B" gnus-article-add-buttons-to-head
1719 "o" gnus-article-treat-overstrike
1720 "e" gnus-article-emphasize
1721 "w" gnus-article-fill-cited-article
1722 "Q" gnus-article-fill-long-lines
1723 "C" gnus-article-capitalize-sentences
1724 "c" gnus-article-remove-cr
1725 "q" gnus-article-de-quoted-unreadable
1726 "6" gnus-article-de-base64-unreadable
1727 "Z" gnus-article-decode-HZ
1728 "h" gnus-article-wash-html
1729 "s" gnus-summary-force-verify-and-decrypt
1730 "f" gnus-article-display-x-face
1731 "l" gnus-summary-stop-page-breaking
1732 "r" gnus-summary-caesar-message
1733 "t" gnus-summary-toggle-header
1734 "g" gnus-treat-smiley
1735 "v" gnus-summary-verbose-headers
1736 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1737 "p" gnus-article-verify-x-pgp-sig
1738 "d" gnus-article-treat-dumbquotes)
1740 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1741 "a" gnus-article-hide
1742 "h" gnus-article-hide-headers
1743 "b" gnus-article-hide-boring-headers
1744 "s" gnus-article-hide-signature
1745 "c" gnus-article-hide-citation
1746 "C" gnus-article-hide-citation-in-followups
1747 "l" gnus-article-hide-list-identifiers
1748 "p" gnus-article-hide-pgp
1749 "B" gnus-article-strip-banner
1750 "P" gnus-article-hide-pem
1751 "\C-c" gnus-article-hide-citation-maybe)
1753 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1754 "a" gnus-article-highlight
1755 "h" gnus-article-highlight-headers
1756 "c" gnus-article-highlight-citation
1757 "s" gnus-article-highlight-signature)
1759 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1760 "f" gnus-article-treat-fold-headers
1761 "u" gnus-article-treat-unfold-headers
1762 "n" gnus-article-treat-fold-newsgroups)
1764 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1765 "x" gnus-article-display-x-face
1766 "s" gnus-treat-smiley
1767 "D" gnus-article-remove-images
1768 "f" gnus-treat-from-picon
1769 "m" gnus-treat-mail-picon
1770 "n" gnus-treat-newsgroups-picon)
1772 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1773 "w" gnus-article-decode-mime-words
1774 "c" gnus-article-decode-charset
1775 "v" gnus-mime-view-all-parts
1776 "b" gnus-article-view-part)
1778 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1779 "z" gnus-article-date-ut
1780 "u" gnus-article-date-ut
1781 "l" gnus-article-date-local
1782 "p" gnus-article-date-english
1783 "e" gnus-article-date-lapsed
1784 "o" gnus-article-date-original
1785 "i" gnus-article-date-iso8601
1786 "s" gnus-article-date-user)
1788 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1789 "t" gnus-article-remove-trailing-blank-lines
1790 "l" gnus-article-strip-leading-blank-lines
1791 "m" gnus-article-strip-multiple-blank-lines
1792 "a" gnus-article-strip-blank-lines
1793 "A" gnus-article-strip-all-blank-lines
1794 "s" gnus-article-strip-leading-space
1795 "e" gnus-article-strip-trailing-space
1796 "w" gnus-article-remove-leading-whitespace)
1798 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1800 "f" gnus-summary-fetch-faq
1801 "d" gnus-summary-describe-group
1802 "h" gnus-summary-describe-briefly
1803 "i" gnus-info-find-node)
1805 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1806 "e" gnus-summary-expire-articles
1807 "\M-\C-e" gnus-summary-expire-articles-now
1808 "\177" gnus-summary-delete-article
1809 [delete] gnus-summary-delete-article
1810 [backspace] gnus-summary-delete-article
1811 "m" gnus-summary-move-article
1812 "r" gnus-summary-respool-article
1813 "w" gnus-summary-edit-article
1814 "c" gnus-summary-copy-article
1815 "B" gnus-summary-crosspost-article
1816 "q" gnus-summary-respool-query
1817 "t" gnus-summary-respool-trace
1818 "i" gnus-summary-import-article
1819 "I" gnus-summary-create-article
1820 "p" gnus-summary-article-posted-p)
1822 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1823 "o" gnus-summary-save-article
1824 "m" gnus-summary-save-article-mail
1825 "F" gnus-summary-write-article-file
1826 "r" gnus-summary-save-article-rmail
1827 "f" gnus-summary-save-article-file
1828 "b" gnus-summary-save-article-body-file
1829 "h" gnus-summary-save-article-folder
1830 "v" gnus-summary-save-article-vm
1831 "p" gnus-summary-pipe-output
1832 "P" gnus-summary-muttprint
1833 "s" gnus-soup-add-article)
1835 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1836 "b" gnus-summary-display-buttonized
1837 "m" gnus-summary-repair-multipart
1838 "v" gnus-article-view-part
1839 "o" gnus-article-save-part
1840 "c" gnus-article-copy-part
1841 "C" gnus-article-view-part-as-charset
1842 "e" gnus-article-externalize-part
1843 "E" gnus-article-encrypt-body
1844 "i" gnus-article-inline-part
1845 "|" gnus-article-pipe-part))
1847 (defvar gnus-article-post-menu nil)
1849 (defun gnus-summary-make-menu-bar ()
1850 (gnus-turn-off-edit-menu 'summary)
1852 (unless (boundp 'gnus-summary-misc-menu)
1855 gnus-summary-kill-menu gnus-summary-mode-map ""
1860 ["Customize" gnus-score-customize t])
1861 (gnus-make-score-map 'increase)
1862 (gnus-make-score-map 'lower)
1864 ["Kill below" gnus-summary-kill-below t]
1865 ["Mark above" gnus-summary-mark-above t]
1866 ["Tick above" gnus-summary-tick-above t]
1867 ["Clear above" gnus-summary-clear-above t])
1868 ["Current score" gnus-summary-current-score t]
1869 ["Set score" gnus-summary-set-score t]
1870 ["Switch current score file..." gnus-score-change-score-file t]
1871 ["Set mark below..." gnus-score-set-mark-below t]
1872 ["Set expunge below..." gnus-score-set-expunge-below t]
1873 ["Edit current score file" gnus-score-edit-current-scores t]
1874 ["Edit score file" gnus-score-edit-file t]
1875 ["Trace score" gnus-score-find-trace t]
1876 ["Find words" gnus-score-find-favourite-words t]
1877 ["Rescore buffer" gnus-summary-rescore t]
1878 ["Increase score..." gnus-summary-increase-score t]
1879 ["Lower score..." gnus-summary-lower-score t]))))
1881 ;; Define both the Article menu in the summary buffer and the
1882 ;; equivalent Commands menu in the article buffer here for
1886 ["All" gnus-article-hide t]
1887 ["Headers" gnus-article-hide-headers t]
1888 ["Signature" gnus-article-hide-signature t]
1889 ["Citation" gnus-article-hide-citation t]
1890 ["List identifiers" gnus-article-hide-list-identifiers t]
1891 ["PGP" gnus-article-hide-pgp t]
1892 ["Banner" gnus-article-strip-banner t]
1893 ["Boring headers" gnus-article-hide-boring-headers t])
1895 ["All" gnus-article-highlight t]
1896 ["Headers" gnus-article-highlight-headers t]
1897 ["Signature" gnus-article-highlight-signature t]
1898 ["Citation" gnus-article-highlight-citation t])
1900 ["Words" gnus-article-decode-mime-words t]
1901 ["Charset" gnus-article-decode-charset t]
1902 ["QP" gnus-article-de-quoted-unreadable t]
1903 ["Base64" gnus-article-de-base64-unreadable t]
1904 ["View all" gnus-mime-view-all-parts t]
1905 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1906 ["Encrypt body" gnus-article-encrypt-body t])
1908 ["Local" gnus-article-date-local t]
1909 ["ISO8601" gnus-article-date-iso8601 t]
1910 ["UT" gnus-article-date-ut t]
1911 ["Original" gnus-article-date-original t]
1912 ["Lapsed" gnus-article-date-lapsed t]
1913 ["User-defined" gnus-article-date-user t])
1915 ["Remove images" gnus-article-remove-images t]
1916 ["Toggle smiley" gnus-treat-smiley t]
1917 ["Show X-Face" gnus-article-display-x-face t]
1918 ["Show picons in From" gnus-treat-from-picon t]
1919 ["Show picons in mail headers" gnus-treat-mail-picon t]
1920 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1923 ["Leading" gnus-article-strip-leading-blank-lines t]
1924 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1925 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1926 ["All of the above" gnus-article-strip-blank-lines t]
1927 ["All" gnus-article-strip-all-blank-lines t]
1928 ["Leading space" gnus-article-strip-leading-space t]
1929 ["Trailing space" gnus-article-strip-trailing-space t]
1930 ["Leading space in headers"
1931 gnus-article-remove-leading-whitespace t])
1932 ["Overstrike" gnus-article-treat-overstrike t]
1933 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1934 ["Emphasis" gnus-article-emphasize t]
1935 ["Word wrap" gnus-article-fill-cited-article t]
1936 ["Fill long lines" gnus-article-fill-long-lines t]
1937 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1938 ["CR" gnus-article-remove-cr t]
1939 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1940 ["Base64" gnus-article-de-base64-unreadable t]
1941 ["Rot 13" gnus-summary-caesar-message
1942 ,@(if (featurep 'xemacs) '(t)
1943 '(:help "\"Caesar rotate\" article by 13"))]
1944 ["Unix pipe" gnus-summary-pipe-message t]
1945 ["Add buttons" gnus-article-add-buttons t]
1946 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1947 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1948 ["Verbose header" gnus-summary-verbose-headers t]
1949 ["Toggle header" gnus-summary-toggle-header t]
1950 ["Unfold headers" gnus-article-treat-unfold-headers t]
1951 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1952 ["Html" gnus-article-wash-html t]
1953 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1954 ["HZ" gnus-article-decode-HZ t])
1956 ["Save in default format" gnus-summary-save-article
1957 ,@(if (featurep 'xemacs) '(t)
1958 '(:help "Save article using default method"))]
1959 ["Save in file" gnus-summary-save-article-file
1960 ,@(if (featurep 'xemacs) '(t)
1961 '(:help "Save article in file"))]
1962 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1963 ["Save in MH folder" gnus-summary-save-article-folder t]
1964 ["Save in VM folder" gnus-summary-save-article-vm t]
1965 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1966 ["Save body in file" gnus-summary-save-article-body-file t]
1967 ["Pipe through a filter" gnus-summary-pipe-output t]
1968 ["Add to SOUP packet" gnus-soup-add-article t]
1969 ["Print with Muttprint" gnus-summary-muttprint t]
1970 ["Print" gnus-summary-print-article t])
1972 ["Respool article..." gnus-summary-respool-article t]
1973 ["Move article..." gnus-summary-move-article
1974 (gnus-check-backend-function
1975 'request-move-article gnus-newsgroup-name)]
1976 ["Copy article..." gnus-summary-copy-article t]
1977 ["Crosspost article..." gnus-summary-crosspost-article
1978 (gnus-check-backend-function
1979 'request-replace-article gnus-newsgroup-name)]
1980 ["Import file..." gnus-summary-import-article t]
1981 ["Create article..." gnus-summary-create-article t]
1982 ["Check if posted" gnus-summary-article-posted-p t]
1983 ["Edit article" gnus-summary-edit-article
1984 (not (gnus-group-read-only-p))]
1985 ["Delete article" gnus-summary-delete-article
1986 (gnus-check-backend-function
1987 'request-expire-articles gnus-newsgroup-name)]
1988 ["Query respool" gnus-summary-respool-query t]
1989 ["Trace respool" gnus-summary-respool-trace t]
1990 ["Delete expirable articles" gnus-summary-expire-articles-now
1991 (gnus-check-backend-function
1992 'request-expire-articles gnus-newsgroup-name)])
1994 ["Uudecode" gnus-uu-decode-uu
1995 ,@(if (featurep 'xemacs) '(t)
1996 '(:help "Decode uuencoded article(s)"))]
1997 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1998 ["Unshar" gnus-uu-decode-unshar t]
1999 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2000 ["Save" gnus-uu-decode-save t]
2001 ["Binhex" gnus-uu-decode-binhex t]
2002 ["Postscript" gnus-uu-decode-postscript t])
2004 ["Enter article" gnus-cache-enter-article t]
2005 ["Remove article" gnus-cache-remove-article t])
2006 ["Translate" gnus-article-babel t]
2007 ["Select article buffer" gnus-summary-select-article-buffer t]
2008 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2009 ["Isearch article..." gnus-summary-isearch-article t]
2010 ["Beginning of the article" gnus-summary-beginning-of-article t]
2011 ["End of the article" gnus-summary-end-of-article t]
2012 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2013 ["Fetch referenced articles" gnus-summary-refer-references t]
2014 ["Fetch current thread" gnus-summary-refer-thread t]
2015 ["Fetch article with id..." gnus-summary-refer-article t]
2016 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2017 ["Redisplay" gnus-summary-show-article t]
2018 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2020 gnus-summary-article-menu gnus-summary-mode-map ""
2021 (cons "Article" innards))
2023 (if (not (keymapp gnus-summary-article-menu))
2025 gnus-article-commands-menu gnus-article-mode-map ""
2026 (cons "Commands" innards))
2027 ;; in Emacs, don't share menu.
2028 (setq gnus-article-commands-menu
2029 (copy-keymap gnus-summary-article-menu))
2030 (define-key gnus-article-mode-map [menu-bar commands]
2031 (cons "Commands" gnus-article-commands-menu))))
2034 gnus-summary-thread-menu gnus-summary-mode-map ""
2036 ["Toggle threading" gnus-summary-toggle-threads t]
2037 ["Hide threads" gnus-summary-hide-all-threads t]
2038 ["Show threads" gnus-summary-show-all-threads t]
2039 ["Hide thread" gnus-summary-hide-thread t]
2040 ["Show thread" gnus-summary-show-thread t]
2041 ["Go to next thread" gnus-summary-next-thread t]
2042 ["Go to previous thread" gnus-summary-prev-thread t]
2043 ["Go down thread" gnus-summary-down-thread t]
2044 ["Go up thread" gnus-summary-up-thread t]
2045 ["Top of thread" gnus-summary-top-thread t]
2046 ["Mark thread as read" gnus-summary-kill-thread t]
2047 ["Lower thread score" gnus-summary-lower-thread t]
2048 ["Raise thread score" gnus-summary-raise-thread t]
2049 ["Rethread current" gnus-summary-rethread-current t]))
2052 gnus-summary-post-menu gnus-summary-mode-map ""
2054 ["Send a message (mail or news)" gnus-summary-post-news
2055 ,@(if (featurep 'xemacs) '(t)
2056 '(:help "Post an article"))]
2057 ["Followup" gnus-summary-followup
2058 ,@(if (featurep 'xemacs) '(t)
2059 '(:help "Post followup to this article"))]
2060 ["Followup and yank" gnus-summary-followup-with-original
2061 ,@(if (featurep 'xemacs) '(t)
2062 '(:help "Post followup to this article, quoting its contents"))]
2063 ["Supersede article" gnus-summary-supersede-article t]
2064 ["Cancel article" gnus-summary-cancel-article
2065 ,@(if (featurep 'xemacs) '(t)
2066 '(:help "Cancel an article you posted"))]
2067 ["Reply" gnus-summary-reply t]
2068 ["Reply and yank" gnus-summary-reply-with-original t]
2069 ["Wide reply" gnus-summary-wide-reply t]
2070 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2071 ,@(if (featurep 'xemacs) '(t)
2072 '(:help "Mail a reply, quoting this article"))]
2073 ["Very wide reply" gnus-summary-very-wide-reply t]
2074 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2075 ,@(if (featurep 'xemacs) '(t)
2076 '(:help "Mail a very wide reply, quoting this article"))]
2077 ["Mail forward" gnus-summary-mail-forward t]
2078 ["Post forward" gnus-summary-post-forward t]
2079 ["Digest and mail" gnus-uu-digest-mail-forward t]
2080 ["Digest and post" gnus-uu-digest-post-forward t]
2081 ["Resend message" gnus-summary-resend-message t]
2082 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2083 ["Send a mail" gnus-summary-mail-other-window t]
2084 ["Create a local message" gnus-summary-news-other-window t]
2085 ["Uuencode and post" gnus-uu-post-news
2086 ,@(if (featurep 'xemacs) '(t)
2087 '(:help "Post a uuencoded article"))]
2088 ["Followup via news" gnus-summary-followup-to-mail t]
2089 ["Followup via news and yank"
2090 gnus-summary-followup-to-mail-with-original t]
2092 ;;["Send" gnus-summary-send-draft t]
2093 ;;["Send bounced" gnus-resend-bounced-mail t])
2097 ((not (keymapp gnus-summary-post-menu))
2098 (setq gnus-article-post-menu gnus-summary-post-menu))
2099 ((not gnus-article-post-menu)
2100 ;; Don't share post menu.
2101 (setq gnus-article-post-menu
2102 (copy-keymap gnus-summary-post-menu))))
2103 (define-key gnus-article-mode-map [menu-bar post]
2104 (cons "Post" gnus-article-post-menu))
2107 gnus-summary-misc-menu gnus-summary-mode-map ""
2110 ["Mark as read" gnus-summary-mark-as-read-forward t]
2111 ["Mark same subject and select"
2112 gnus-summary-kill-same-subject-and-select t]
2113 ["Mark same subject" gnus-summary-kill-same-subject t]
2114 ["Catchup" gnus-summary-catchup
2115 ,@(if (featurep 'xemacs) '(t)
2116 '(:help "Mark unread articles in this group as read"))]
2117 ["Catchup all" gnus-summary-catchup-all t]
2118 ["Catchup to here" gnus-summary-catchup-to-here t]
2119 ["Catchup from here" gnus-summary-catchup-from-here t]
2120 ["Catchup region" gnus-summary-mark-region-as-read t]
2121 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2123 ["Tick" gnus-summary-tick-article-forward t]
2124 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2125 ["Remove marks" gnus-summary-clear-mark-forward t]
2126 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2127 ["Set bookmark" gnus-summary-set-bookmark t]
2128 ["Remove bookmark" gnus-summary-remove-bookmark t])
2130 ["Marks..." gnus-summary-limit-to-marks t]
2131 ["Subject..." gnus-summary-limit-to-subject t]
2132 ["Author..." gnus-summary-limit-to-author t]
2133 ["Age..." gnus-summary-limit-to-age t]
2134 ["Extra..." gnus-summary-limit-to-extra t]
2135 ["Score" gnus-summary-limit-to-score t]
2136 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2137 ["Unread" gnus-summary-limit-to-unread t]
2138 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2139 ["Articles" gnus-summary-limit-to-articles t]
2140 ["Pop limit" gnus-summary-pop-limit t]
2141 ["Show dormant" gnus-summary-limit-include-dormant t]
2142 ["Hide childless dormant"
2143 gnus-summary-limit-exclude-childless-dormant t]
2144 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2145 ["Hide marked" gnus-summary-limit-exclude-marks t]
2146 ["Show expunged" gnus-summary-limit-include-expunged t])
2148 ["Set mark" gnus-summary-mark-as-processable t]
2149 ["Remove mark" gnus-summary-unmark-as-processable t]
2150 ["Remove all marks" gnus-summary-unmark-all-processable t]
2151 ["Mark above" gnus-uu-mark-over t]
2152 ["Mark series" gnus-uu-mark-series t]
2153 ["Mark region" gnus-uu-mark-region t]
2154 ["Unmark region" gnus-uu-unmark-region t]
2155 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2156 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2157 ["Mark all" gnus-uu-mark-all t]
2158 ["Mark buffer" gnus-uu-mark-buffer t]
2159 ["Mark sparse" gnus-uu-mark-sparse t]
2160 ["Mark thread" gnus-uu-mark-thread t]
2161 ["Unmark thread" gnus-uu-unmark-thread t]
2162 ("Process Mark Sets"
2163 ["Kill" gnus-summary-kill-process-mark t]
2164 ["Yank" gnus-summary-yank-process-mark
2165 gnus-newsgroup-process-stack]
2166 ["Save" gnus-summary-save-process-mark t]))
2168 ["Page forward" gnus-summary-next-page
2169 ,@(if (featurep 'xemacs) '(t)
2170 '(:help "Show next page of article"))]
2171 ["Page backward" gnus-summary-prev-page
2172 ,@(if (featurep 'xemacs) '(t)
2173 '(:help "Show previous page of article"))]
2174 ["Line forward" gnus-summary-scroll-up t])
2176 ["Next unread article" gnus-summary-next-unread-article t]
2177 ["Previous unread article" gnus-summary-prev-unread-article t]
2178 ["Next article" gnus-summary-next-article t]
2179 ["Previous article" gnus-summary-prev-article t]
2180 ["Next unread subject" gnus-summary-next-unread-subject t]
2181 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2182 ["Next article same subject" gnus-summary-next-same-subject t]
2183 ["Previous article same subject" gnus-summary-prev-same-subject t]
2184 ["First unread article" gnus-summary-first-unread-article t]
2185 ["Best unread article" gnus-summary-best-unread-article t]
2186 ["Go to subject number..." gnus-summary-goto-subject t]
2187 ["Go to article number..." gnus-summary-goto-article t]
2188 ["Go to the last article" gnus-summary-goto-last-article t]
2189 ["Pop article off history" gnus-summary-pop-article t])
2191 ["Sort by number" gnus-summary-sort-by-number t]
2192 ["Sort by author" gnus-summary-sort-by-author t]
2193 ["Sort by subject" gnus-summary-sort-by-subject t]
2194 ["Sort by date" gnus-summary-sort-by-date t]
2195 ["Sort by score" gnus-summary-sort-by-score t]
2196 ["Sort by lines" gnus-summary-sort-by-lines t]
2197 ["Sort by characters" gnus-summary-sort-by-chars t]
2198 ["Original sort" gnus-summary-sort-by-original t])
2200 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2201 ["Describe group" gnus-summary-describe-group t]
2202 ["Read manual" gnus-info-find-node t])
2204 ["Pick and read" gnus-pick-mode t]
2205 ["Binary" gnus-binary-mode t])
2207 ["Regenerate" gnus-summary-prepare t]
2208 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2209 ["Toggle threading" gnus-summary-toggle-threads t])
2210 ["See old articles" gnus-summary-insert-old-articles t]
2211 ["See new articles" gnus-summary-insert-new-articles t]
2212 ["Filter articles..." gnus-summary-execute-command t]
2213 ["Run command on subjects..." gnus-summary-universal-argument t]
2214 ["Search articles forward..." gnus-summary-search-article-forward t]
2215 ["Search articles backward..." gnus-summary-search-article-backward t]
2216 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2217 ["Expand window" gnus-summary-expand-window t]
2218 ["Expire expirable articles" gnus-summary-expire-articles
2219 (gnus-check-backend-function
2220 'request-expire-articles gnus-newsgroup-name)]
2221 ["Edit local kill file" gnus-summary-edit-local-kill t]
2222 ["Edit main kill file" gnus-summary-edit-global-kill t]
2223 ["Edit group parameters" gnus-summary-edit-parameters t]
2224 ["Customize group parameters" gnus-summary-customize-parameters t]
2225 ["Send a bug report" gnus-bug t]
2227 ["Catchup and exit" gnus-summary-catchup-and-exit
2228 ,@(if (featurep 'xemacs) '(t)
2229 '(:help "Mark unread articles in this group as read, then exit"))]
2230 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2231 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2232 ["Exit group" gnus-summary-exit
2233 ,@(if (featurep 'xemacs) '(t)
2234 '(:help "Exit current group, return to group selection mode"))]
2235 ["Exit group without updating" gnus-summary-exit-no-update t]
2236 ["Exit and goto next group" gnus-summary-next-group t]
2237 ["Exit and goto prev group" gnus-summary-prev-group t]
2238 ["Reselect group" gnus-summary-reselect-current-group t]
2239 ["Rescan group" gnus-summary-rescan-group t]
2240 ["Update dribble" gnus-summary-save-newsrc t])))
2242 (gnus-run-hooks 'gnus-summary-menu-hook)))
2244 (defvar gnus-summary-tool-bar-map nil)
2246 ;; Emacs 21 tool bar. Should be no-op otherwise.
2247 (defun gnus-summary-make-tool-bar ()
2248 (if (and (fboundp 'tool-bar-add-item-from-menu)
2249 (default-value 'tool-bar-mode)
2250 (not gnus-summary-tool-bar-map))
2251 (setq gnus-summary-tool-bar-map
2252 (let ((tool-bar-map (make-sparse-keymap))
2253 (load-path (mm-image-load-path)))
2254 (tool-bar-add-item-from-menu
2255 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2256 (tool-bar-add-item-from-menu
2257 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2258 (tool-bar-add-item-from-menu
2259 'gnus-summary-post-news "post" gnus-summary-mode-map)
2260 (tool-bar-add-item-from-menu
2261 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2262 (tool-bar-add-item-from-menu
2263 'gnus-summary-followup "followup" gnus-summary-mode-map)
2264 (tool-bar-add-item-from-menu
2265 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2266 (tool-bar-add-item-from-menu
2267 'gnus-summary-reply "reply" gnus-summary-mode-map)
2268 (tool-bar-add-item-from-menu
2269 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2270 (tool-bar-add-item-from-menu
2271 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2272 (tool-bar-add-item-from-menu
2273 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2274 (tool-bar-add-item-from-menu
2275 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2276 (tool-bar-add-item-from-menu
2277 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2278 (tool-bar-add-item-from-menu
2279 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2280 (tool-bar-add-item-from-menu
2281 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2282 (tool-bar-add-item-from-menu
2283 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2285 (if gnus-summary-tool-bar-map
2286 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2288 (defun gnus-score-set-default (var value)
2289 "A version of set that updates the GNU Emacs menu-bar."
2291 ;; It is the message that forces the active status to be updated.
2294 (defun gnus-make-score-map (type)
2295 "Make a summary score map of type TYPE."
2298 (let ((headers '(("author" "from" string)
2299 ("subject" "subject" string)
2300 ("article body" "body" string)
2301 ("article head" "head" string)
2302 ("xref" "xref" string)
2303 ("extra header" "extra" string)
2304 ("lines" "lines" number)
2305 ("followups to author" "followup" string)))
2306 (types '((number ("less than" <)
2309 (string ("substring" s)
2313 (perms '(("temporary" (current-time-string))
2321 (if (eq type 'lower)
2326 (setq header (car headers))
2332 (let ((ts (cdr (assoc (nth 2 header) types)))
2348 'gnus-summary-score-entry
2350 (if (or (string= (nth 1 header)
2352 (string= (nth 1 header)
2355 (list 'gnus-summary-header
2357 (list 'quote (nth 1 (car ts)))
2358 (list 'gnus-score-delta-default
2365 (list (nreverse outp))))
2368 (list (nreverse outt))))
2370 (setq headers (cdr headers)))
2371 (list (nreverse outh))))))))
2375 (defun gnus-summary-mode (&optional group)
2376 "Major mode for reading articles.
2378 All normal editing commands are switched off.
2379 \\<gnus-summary-mode-map>
2380 Each line in this buffer represents one article. To read an
2381 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2382 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2385 You can also post articles and send mail from this buffer. To
2386 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2387 of an article, type `\\[gnus-summary-reply]'.
2389 There are approx. one gazillion commands you can execute in this
2390 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2392 The following commands are available:
2394 \\{gnus-summary-mode-map}"
2396 (kill-all-local-variables)
2397 (when (gnus-visual-p 'summary-menu 'menu)
2398 (gnus-summary-make-menu-bar)
2399 (gnus-summary-make-tool-bar))
2400 (gnus-summary-make-local-variables)
2401 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2402 (gnus-summary-make-local-variables))
2403 (gnus-make-thread-indent-array)
2404 (gnus-simplify-mode-line)
2405 (setq major-mode 'gnus-summary-mode)
2406 (setq mode-name "Summary")
2407 (make-local-variable 'minor-mode-alist)
2408 (use-local-map gnus-summary-mode-map)
2409 (buffer-disable-undo)
2410 (setq buffer-read-only t) ;Disable modification
2411 (setq truncate-lines t)
2412 (setq selective-display t)
2413 (setq selective-display-ellipses t) ;Display `...'
2414 (gnus-summary-set-display-table)
2415 (gnus-set-default-directory)
2416 (setq gnus-newsgroup-name group)
2417 (make-local-variable 'gnus-summary-line-format)
2418 (make-local-variable 'gnus-summary-line-format-spec)
2419 (make-local-variable 'gnus-summary-dummy-line-format)
2420 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2421 (make-local-variable 'gnus-summary-mark-positions)
2422 (make-local-hook 'pre-command-hook)
2423 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2424 (gnus-run-hooks 'gnus-summary-mode-hook)
2425 (turn-on-gnus-mailing-list-mode)
2426 (mm-enable-multibyte)
2427 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2428 (gnus-update-summary-mark-positions))
2430 (defun gnus-summary-make-local-variables ()
2431 "Make all the local summary buffer variables."
2433 (dolist (local gnus-summary-local-variables)
2436 (if (eq (cdr local) 'global)
2437 ;; Copy the global value of the variable.
2438 (setq global (symbol-value (car local)))
2439 ;; Use the value from the list.
2440 (setq global (eval (cdr local))))
2441 (set (make-local-variable (car local)) global))
2442 ;; Simple nil-valued local variable.
2443 (set (make-local-variable local) nil)))))
2445 (defun gnus-summary-clear-local-variables ()
2446 (let ((locals gnus-summary-local-variables))
2448 (if (consp (car locals))
2449 (and (vectorp (caar locals))
2450 (set (caar locals) nil))
2451 (and (vectorp (car locals))
2452 (set (car locals) nil)))
2453 (setq locals (cdr locals)))))
2455 ;; Summary data functions.
2457 (defmacro gnus-data-number (data)
2460 (defmacro gnus-data-set-number (data number)
2461 `(setcar ,data ,number))
2463 (defmacro gnus-data-mark (data)
2466 (defmacro gnus-data-set-mark (data mark)
2467 `(setcar (nthcdr 1 ,data) ,mark))
2469 (defmacro gnus-data-pos (data)
2472 (defmacro gnus-data-set-pos (data pos)
2473 `(setcar (nthcdr 2 ,data) ,pos))
2475 (defmacro gnus-data-header (data)
2478 (defmacro gnus-data-set-header (data header)
2479 `(setf (nth 3 ,data) ,header))
2481 (defmacro gnus-data-level (data)
2484 (defmacro gnus-data-unread-p (data)
2485 `(= (nth 1 ,data) gnus-unread-mark))
2487 (defmacro gnus-data-read-p (data)
2488 `(/= (nth 1 ,data) gnus-unread-mark))
2490 (defmacro gnus-data-pseudo-p (data)
2491 `(consp (nth 3 ,data)))
2493 (defmacro gnus-data-find (number)
2494 `(assq ,number gnus-newsgroup-data))
2496 (defmacro gnus-data-find-list (number &optional data)
2497 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2498 (memq (assq ,number bdata)
2501 (defmacro gnus-data-make (number mark pos header level)
2502 `(list ,number ,mark ,pos ,header ,level))
2504 (defun gnus-data-enter (after-article number mark pos header level offset)
2505 (let ((data (gnus-data-find-list after-article)))
2507 (error "No such article: %d" after-article))
2508 (setcdr data (cons (gnus-data-make number mark pos header level)
2510 (setq gnus-newsgroup-data-reverse nil)
2511 (gnus-data-update-list (cddr data) offset)))
2513 (defun gnus-data-enter-list (after-article list &optional offset)
2515 (let ((data (and after-article (gnus-data-find-list after-article)))
2519 (let ((odata gnus-newsgroup-data))
2520 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2522 (gnus-data-update-list odata offset)))
2523 ;; Find the last element in the list to be spliced into the main
2526 (setq list (cdr list)))
2529 (setcdr list gnus-newsgroup-data)
2530 (setq gnus-newsgroup-data ilist)
2532 (gnus-data-update-list (cdr list) offset)))
2533 (setcdr list (cdr data))
2536 (gnus-data-update-list (cdr list) offset))))
2537 (setq gnus-newsgroup-data-reverse nil))))
2539 (defun gnus-data-remove (article &optional offset)
2540 (let ((data gnus-newsgroup-data))
2541 (if (= (gnus-data-number (car data)) article)
2543 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2544 gnus-newsgroup-data-reverse nil)
2546 (gnus-data-update-list gnus-newsgroup-data offset)))
2548 (when (= (gnus-data-number (cadr data)) article)
2549 (setcdr data (cddr data))
2551 (gnus-data-update-list (cdr data) offset))
2553 gnus-newsgroup-data-reverse nil))
2554 (setq data (cdr data))))))
2556 (defmacro gnus-data-list (backward)
2558 (or gnus-newsgroup-data-reverse
2559 (setq gnus-newsgroup-data-reverse
2560 (reverse gnus-newsgroup-data)))
2561 gnus-newsgroup-data))
2563 (defun gnus-data-update-list (data offset)
2564 "Add OFFSET to the POS of all data entries in DATA."
2565 (setq gnus-newsgroup-data-reverse nil)
2567 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2568 (setq data (cdr data))))
2570 (defun gnus-summary-article-pseudo-p (article)
2571 "Say whether this article is a pseudo article or not."
2572 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2574 (defmacro gnus-summary-article-sparse-p (article)
2575 "Say whether this article is a sparse article or not."
2576 `(memq ,article gnus-newsgroup-sparse))
2578 (defmacro gnus-summary-article-ancient-p (article)
2579 "Say whether this article is a sparse article or not."
2580 `(memq ,article gnus-newsgroup-ancient))
2582 (defun gnus-article-parent-p (number)
2583 "Say whether this article is a parent or not."
2584 (let ((data (gnus-data-find-list number)))
2585 (and (cdr data) ; There has to be an article after...
2586 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2587 (gnus-data-level (nth 1 data))))))
2589 (defun gnus-article-children (number)
2590 "Return a list of all children to NUMBER."
2591 (let* ((data (gnus-data-find-list number))
2592 (level (gnus-data-level (car data)))
2594 (setq data (cdr data))
2596 (= (gnus-data-level (car data)) (1+ level)))
2597 (push (gnus-data-number (car data)) children)
2598 (setq data (cdr data)))
2601 (defmacro gnus-summary-skip-intangible ()
2602 "If the current article is intangible, then jump to a different article."
2603 '(let ((to (get-text-property (point) 'gnus-intangible)))
2604 (and to (gnus-summary-goto-subject to))))
2606 (defmacro gnus-summary-article-intangible-p ()
2607 "Say whether this article is intangible or not."
2608 '(get-text-property (point) 'gnus-intangible))
2610 (defun gnus-article-read-p (article)
2611 "Say whether ARTICLE is read or not."
2612 (not (or (memq article gnus-newsgroup-marked)
2613 (memq article gnus-newsgroup-unreads)
2614 (memq article gnus-newsgroup-unselected)
2615 (memq article gnus-newsgroup-dormant))))
2617 ;; Some summary mode macros.
2619 (defmacro gnus-summary-article-number ()
2620 "The article number of the article on the current line.
2621 If there isn's an article number here, then we return the current
2624 (gnus-summary-skip-intangible)
2625 (or (get-text-property (point) 'gnus-number)
2626 (gnus-summary-last-subject))))
2628 (defmacro gnus-summary-article-header (&optional number)
2629 "Return the header of article NUMBER."
2630 `(gnus-data-header (gnus-data-find
2631 ,(or number '(gnus-summary-article-number)))))
2633 (defmacro gnus-summary-thread-level (&optional number)
2634 "Return the level of thread that starts with article NUMBER."
2635 `(if (and (eq gnus-summary-make-false-root 'dummy)
2636 (get-text-property (point) 'gnus-intangible))
2638 (gnus-data-level (gnus-data-find
2639 ,(or number '(gnus-summary-article-number))))))
2641 (defmacro gnus-summary-article-mark (&optional number)
2642 "Return the mark of article NUMBER."
2643 `(gnus-data-mark (gnus-data-find
2644 ,(or number '(gnus-summary-article-number)))))
2646 (defmacro gnus-summary-article-pos (&optional number)
2647 "Return the position of the line of article NUMBER."
2648 `(gnus-data-pos (gnus-data-find
2649 ,(or number '(gnus-summary-article-number)))))
2651 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2652 (defmacro gnus-summary-article-subject (&optional number)
2653 "Return current subject string or nil if nothing."
2656 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2657 '(gnus-data-header (assq (gnus-summary-article-number)
2658 gnus-newsgroup-data)))))
2661 (mail-header-subject headers))))
2663 (defmacro gnus-summary-article-score (&optional number)
2664 "Return current article score."
2665 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2666 gnus-newsgroup-scored))
2667 gnus-summary-default-score 0))
2669 (defun gnus-summary-article-children (&optional number)
2670 "Return a list of article numbers that are children of article NUMBER."
2671 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2672 (level (gnus-data-level (car data)))
2674 (while (and (setq data (cdr data))
2675 (> (setq l (gnus-data-level (car data))) level))
2676 (and (= (1+ level) l)
2677 (push (gnus-data-number (car data))
2679 (nreverse children)))
2681 (defun gnus-summary-article-parent (&optional number)
2682 "Return the article number of the parent of article NUMBER."
2683 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2684 (gnus-data-list t)))
2685 (level (gnus-data-level (car data))))
2687 () ; This is a root.
2688 ;; We search until we find an article with a level less than
2689 ;; this one. That function has to be the parent.
2690 (while (and (setq data (cdr data))
2691 (not (< (gnus-data-level (car data)) level))))
2692 (and data (gnus-data-number (car data))))))
2694 (defun gnus-unread-mark-p (mark)
2695 "Say whether MARK is the unread mark."
2696 (= mark gnus-unread-mark))
2698 (defun gnus-read-mark-p (mark)
2699 "Say whether MARK is one of the marks that mark as read.
2700 This is all marks except unread, ticked, dormant, and expirable."
2701 (not (or (= mark gnus-unread-mark)
2702 (= mark gnus-ticked-mark)
2703 (= mark gnus-dormant-mark)
2704 (= mark gnus-expirable-mark))))
2706 (defmacro gnus-article-mark (number)
2707 "Return the MARK of article NUMBER.
2708 This macro should only be used when computing the mark the \"first\"
2709 time; i.e., when generating the summary lines. After that,
2710 `gnus-summary-article-mark' should be used to examine the
2713 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2714 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2715 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2716 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2717 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2718 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2719 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2720 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2721 gnus-ancient-mark))))
2723 ;; Saving hidden threads.
2725 (defmacro gnus-save-hidden-threads (&rest forms)
2726 "Save hidden threads, eval FORMS, and restore the hidden threads."
2727 (let ((config (make-symbol "config")))
2728 `(let ((,config (gnus-hidden-threads-configuration)))
2732 (gnus-restore-hidden-threads-configuration ,config)))))
2733 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2734 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2736 (defun gnus-data-compute-positions ()
2737 "Compute the positions of all articles."
2738 (setq gnus-newsgroup-data-reverse nil)
2739 (let ((data gnus-newsgroup-data))
2741 (gnus-save-hidden-threads
2742 (gnus-summary-show-all-threads)
2743 (goto-char (point-min))
2745 (while (get-text-property (point) 'gnus-intangible)
2747 (gnus-data-set-pos (car data) (+ (point) 3))
2748 (setq data (cdr data))
2749 (forward-line 1))))))
2751 (defun gnus-hidden-threads-configuration ()
2752 "Return the current hidden threads configuration."
2755 (goto-char (point-min))
2756 (while (search-forward "\r" nil t)
2757 (push (1- (point)) config))
2760 (defun gnus-restore-hidden-threads-configuration (config)
2761 "Restore hidden threads configuration from CONFIG."
2763 (let (point buffer-read-only)
2764 (while (setq point (pop config))
2765 (when (and (< point (point-max))
2767 (eq (char-after) ?\n))
2768 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2770 ;; Various summary mode internalish functions.
2772 (defun gnus-mouse-pick-article (e)
2775 (gnus-summary-next-page nil t))
2777 (defun gnus-summary-set-display-table ()
2778 "Change the display table.
2779 Odd characters have a tendency to mess
2780 up nicely formatted displays - we make all possible glyphs
2781 display only a single character."
2783 ;; We start from the standard display table, if any.
2784 (let ((table (or (copy-sequence standard-display-table)
2785 (make-display-table)))
2787 ;; Nix out all the control chars...
2788 (while (>= (setq i (1- i)) 0)
2789 (aset table i [??]))
2790 ;; ... but not newline and cr, of course. (cr is necessary for the
2791 ;; selective display).
2792 (aset table ?\n nil)
2793 (aset table ?\r nil)
2794 ;; We keep TAB as well.
2795 (aset table ?\t nil)
2796 ;; We nix out any glyphs over 126 that are not set already.
2798 (while (>= (setq i (1- i)) 127)
2799 ;; Only modify if the entry is nil.
2800 (unless (aref table i)
2801 (aset table i [??]))))
2802 (setq buffer-display-table table)))
2804 (defun gnus-summary-set-article-display-arrow (pos)
2805 "Update the overlay arrow to point to line at position POS."
2806 (when (and gnus-summary-display-arrow
2807 (boundp 'overlay-arrow-position)
2808 (boundp 'overlay-arrow-string))
2812 (unless overlay-arrow-position
2813 (setq overlay-arrow-position (make-marker)))
2814 (setq overlay-arrow-string "=>"
2815 overlay-arrow-position (set-marker overlay-arrow-position
2817 (current-buffer))))))
2819 (defun gnus-summary-buffer-name (group)
2820 "Return the summary buffer name of GROUP."
2821 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2823 (defun gnus-summary-setup-buffer (group)
2824 "Initialize summary buffer."
2825 (let ((buffer (gnus-summary-buffer-name group))
2826 (dead-name (concat "*Dead Summary "
2827 (gnus-group-decoded-name group) "*")))
2828 ;; If a dead summary buffer exists, we kill it.
2829 (when (gnus-buffer-live-p dead-name)
2830 (gnus-kill-buffer dead-name))
2831 (if (get-buffer buffer)
2834 (setq gnus-summary-buffer (current-buffer))
2835 (not gnus-newsgroup-prepared))
2836 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2837 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2838 (gnus-summary-mode group)
2840 (gnus-carpal-setup-buffer 'summary))
2841 (unless gnus-single-article-buffer
2842 (make-local-variable 'gnus-article-buffer)
2843 (make-local-variable 'gnus-article-current)
2844 (make-local-variable 'gnus-original-article-buffer))
2845 (setq gnus-newsgroup-name group)
2846 ;; Set any local variables in the group parameters.
2847 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2850 (defun gnus-set-global-variables ()
2851 "Set the global equivalents of the buffer-local variables.
2852 They are set to the latest values they had. These reflect the summary
2853 buffer that was in action when the last article was fetched."
2854 (when (eq major-mode 'gnus-summary-mode)
2855 (setq gnus-summary-buffer (current-buffer))
2856 (let ((name gnus-newsgroup-name)
2857 (marked gnus-newsgroup-marked)
2858 (unread gnus-newsgroup-unreads)
2859 (headers gnus-current-headers)
2860 (data gnus-newsgroup-data)
2861 (summary gnus-summary-buffer)
2862 (article-buffer gnus-article-buffer)
2863 (original gnus-original-article-buffer)
2864 (gac gnus-article-current)
2865 (reffed gnus-reffed-article-number)
2866 (score-file gnus-current-score-file)
2867 (default-charset gnus-newsgroup-charset)
2869 (let ((locals gnus-newsgroup-variables))
2871 (if (consp (car locals))
2872 (push (eval (caar locals)) vlist)
2873 (push (eval (car locals)) vlist))
2874 (setq locals (cdr locals)))
2875 (setq vlist (nreverse vlist)))
2877 (set-buffer gnus-group-buffer)
2878 (setq gnus-newsgroup-name name
2879 gnus-newsgroup-marked marked
2880 gnus-newsgroup-unreads unread
2881 gnus-current-headers headers
2882 gnus-newsgroup-data data
2883 gnus-article-current gac
2884 gnus-summary-buffer summary
2885 gnus-article-buffer article-buffer
2886 gnus-original-article-buffer original
2887 gnus-reffed-article-number reffed
2888 gnus-current-score-file score-file
2889 gnus-newsgroup-charset default-charset)
2890 (let ((locals gnus-newsgroup-variables))
2892 (if (consp (car locals))
2893 (set (caar locals) (pop vlist))
2894 (set (car locals) (pop vlist)))
2895 (setq locals (cdr locals))))
2896 ;; The article buffer also has local variables.
2897 (when (gnus-buffer-live-p gnus-article-buffer)
2898 (set-buffer gnus-article-buffer)
2899 (setq gnus-summary-buffer summary))))))
2901 (defun gnus-summary-article-unread-p (article)
2902 "Say whether ARTICLE is unread or not."
2903 (memq article gnus-newsgroup-unreads))
2905 (defun gnus-summary-first-article-p (&optional article)
2906 "Return whether ARTICLE is the first article in the buffer."
2907 (if (not (setq article (or article (gnus-summary-article-number))))
2909 (eq article (caar gnus-newsgroup-data))))
2911 (defun gnus-summary-last-article-p (&optional article)
2912 "Return whether ARTICLE is the last article in the buffer."
2913 (if (not (setq article (or article (gnus-summary-article-number))))
2914 ;; All non-existent numbers are the last article. :-)
2916 (not (cdr (gnus-data-find-list article)))))
2918 (defun gnus-make-thread-indent-array ()
2920 (unless (and gnus-thread-indent-array
2921 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2922 (setq gnus-thread-indent-array (make-vector 201 "")
2923 gnus-thread-indent-array-level gnus-thread-indent-level)
2925 (aset gnus-thread-indent-array n
2926 (make-string (* n gnus-thread-indent-level) ? ))
2929 (defun gnus-update-summary-mark-positions ()
2930 "Compute where the summary marks are to go."
2932 (when (gnus-buffer-exists-p gnus-summary-buffer)
2933 (set-buffer gnus-summary-buffer))
2934 (let ((gnus-replied-mark 129)
2935 (gnus-score-below-mark 130)
2936 (gnus-score-over-mark 130)
2937 (gnus-download-mark 131)
2938 (spec gnus-summary-line-format-spec)
2941 (gnus-set-work-buffer)
2942 (let ((gnus-summary-line-format-spec spec)
2943 (gnus-newsgroup-downloadable '((0 . t))))
2944 (gnus-summary-insert-line
2945 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2946 0 nil 128 t nil "" nil 1)
2947 (goto-char (point-min))
2948 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2950 (goto-char (point-min))
2951 (push (cons 'replied (and (search-forward "\201" nil t)
2954 (goto-char (point-min))
2955 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2957 (goto-char (point-min))
2958 (push (cons 'download
2959 (and (search-forward "\203" nil t) (- (point) 2)))
2961 (setq gnus-summary-mark-positions pos))))
2963 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2964 "Insert a dummy root in the summary buffer."
2966 (gnus-add-text-properties
2967 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2968 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2970 (defun gnus-summary-extract-address-component (from)
2971 (or (car (funcall gnus-extract-address-components from))
2974 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2975 (let ((mail-parse-charset gnus-newsgroup-charset)
2976 ; Is it really necessary to do this next part for each summary line?
2977 ; Luckily, doesn't seem to slow things down much.
2978 (mail-parse-ignored-charsets
2979 (save-excursion (set-buffer gnus-summary-buffer)
2980 gnus-newsgroup-ignored-charsets)))
2982 (and gnus-ignored-from-addresses
2983 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2984 (let ((extra-headers (mail-header-extra header))
2988 ((setq to (cdr (assq 'To extra-headers)))
2991 (gnus-summary-extract-address-component
2992 (funcall gnus-decode-encoded-word-function to)))))
2993 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2994 (concat "=> " newsgroups)))))
2995 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
2997 (defun gnus-summary-insert-line (gnus-tmp-header
2998 gnus-tmp-level gnus-tmp-current
2999 gnus-tmp-unread gnus-tmp-replied
3000 gnus-tmp-expirable gnus-tmp-subject-or-nil
3001 &optional gnus-tmp-dummy gnus-tmp-score
3003 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3004 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3005 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3006 (gnus-tmp-score-char
3007 (if (or (null gnus-summary-default-score)
3008 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3009 gnus-summary-zcore-fuzz))
3011 (if (< gnus-tmp-score gnus-summary-default-score)
3012 gnus-score-below-mark gnus-score-over-mark)))
3013 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3015 (cond (gnus-tmp-process gnus-process-mark)
3016 ((memq gnus-tmp-current gnus-newsgroup-cached)
3018 (gnus-tmp-replied gnus-replied-mark)
3019 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3020 gnus-forwarded-mark)
3021 ((memq gnus-tmp-current gnus-newsgroup-saved)
3023 ((memq gnus-tmp-number gnus-newsgroup-recent)
3025 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3028 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3031 ((string-match "<[^>]+> *$" gnus-tmp-from)
3032 (let ((beg (match-beginning 0)))
3033 (or (and (string-match "^\".+\"" gnus-tmp-from)
3034 (substring gnus-tmp-from 1 (1- (match-end 0))))
3035 (substring gnus-tmp-from 0 beg))))
3036 ((string-match "(.+)" gnus-tmp-from)
3037 (substring gnus-tmp-from
3038 (1+ (match-beginning 0)) (1- (match-end 0))))
3040 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3041 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3042 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3043 (buffer-read-only nil))
3044 (when (string= gnus-tmp-name "")
3045 (setq gnus-tmp-name gnus-tmp-from))
3046 (unless (numberp gnus-tmp-lines)
3047 (setq gnus-tmp-lines -1))
3048 (if (= gnus-tmp-lines -1)
3049 (setq gnus-tmp-lines "?")
3050 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3051 (gnus-put-text-property
3053 (progn (eval gnus-summary-line-format-spec) (point))
3054 'gnus-number gnus-tmp-number)
3055 (when (gnus-visual-p 'summary-highlight 'highlight)
3057 (gnus-run-hooks 'gnus-summary-update-hook)
3060 (defun gnus-summary-update-line (&optional dont-update)
3061 "Update summary line after change."
3062 (when (and gnus-summary-default-score
3063 (not gnus-summary-inhibit-highlight))
3064 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3065 (article (gnus-summary-article-number))
3066 (score (gnus-summary-article-score article)))
3068 (if (and gnus-summary-mark-below
3069 (< (gnus-summary-article-score)
3070 gnus-summary-mark-below))
3071 ;; This article has a low score, so we mark it as read.
3072 (when (memq article gnus-newsgroup-unreads)
3073 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3074 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3075 ;; This article was previously marked as read on account
3076 ;; of a low score, but now it has risen, so we mark it as
3078 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3079 (gnus-summary-update-mark
3080 (if (or (null gnus-summary-default-score)
3081 (<= (abs (- score gnus-summary-default-score))
3082 gnus-summary-zcore-fuzz))
3084 (if (< score gnus-summary-default-score)
3085 gnus-score-below-mark gnus-score-over-mark))
3087 ;; Do visual highlighting.
3088 (when (gnus-visual-p 'summary-highlight 'highlight)
3089 (gnus-run-hooks 'gnus-summary-update-hook)))))
3091 (defvar gnus-tmp-new-adopts nil)
3093 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3094 "Return the number of articles in THREAD.
3095 This may be 0 in some cases -- if none of the articles in
3096 the thread are to be displayed."
3098 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3100 ((not (listp thread))
3102 ((and (consp thread) (cdr thread))
3105 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3108 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3111 (when (and level (zerop level) gnus-tmp-new-adopts)
3114 'gnus-summary-number-of-articles-in-thread
3115 gnus-tmp-new-adopts))))
3117 (if (> number 1) gnus-not-empty-thread-mark
3118 gnus-empty-thread-mark)
3121 (defun gnus-summary-set-local-parameters (group)
3122 "Go through the local params of GROUP and set all variable specs in that list."
3123 (let ((params (gnus-group-find-parameter group))
3124 (vars '(quit-config)) ; Ignore quit-config.
3127 (setq elem (car params)
3128 params (cdr params))
3129 (and (consp elem) ; Has to be a cons.
3130 (consp (cdr elem)) ; The cdr has to be a list.
3131 (symbolp (car elem)) ; Has to be a symbol in there.
3132 (not (memq (car elem) vars))
3133 (ignore-errors ; So we set it.
3134 (push (car elem) vars)
3135 (make-local-variable (car elem))
3136 (set (car elem) (eval (nth 1 elem))))))))
3138 (defun gnus-summary-read-group (group &optional show-all no-article
3139 kill-buffer no-display backward
3141 "Start reading news in newsgroup GROUP.
3142 If SHOW-ALL is non-nil, already read articles are also listed.
3143 If NO-ARTICLE is non-nil, no article is selected initially.
3144 If NO-DISPLAY, don't generate a summary buffer."
3148 (let ((gnus-auto-select-next nil))
3149 (or (gnus-summary-read-group-1
3150 group show-all no-article
3151 kill-buffer no-display
3154 select-articles nil)))))
3155 (eq gnus-auto-select-next 'quietly))
3156 (set-buffer gnus-group-buffer)
3157 ;; The entry function called above goes to the next
3158 ;; group automatically, so we go two groups back
3159 ;; if we are searching for the previous group.
3161 (gnus-group-prev-unread-group 2))
3162 (if (not (equal group (gnus-group-group-name)))
3163 (setq group (gnus-group-group-name))
3167 (defun gnus-summary-read-group-1 (group show-all no-article
3168 kill-buffer no-display
3169 &optional select-articles)
3170 ;; Killed foreign groups can't be entered.
3171 ;; (when (and (not (gnus-group-native-p group))
3172 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3173 ;; (error "Dead non-native groups can't be entered"))
3174 (gnus-message 5 "Retrieving newsgroup: %s..."
3175 (gnus-group-decoded-name group))
3176 (let* ((new-group (gnus-summary-setup-buffer group))
3177 (quit-config (gnus-group-quit-config group))
3178 (did-select (and new-group (gnus-select-newsgroup
3179 group show-all select-articles))))
3181 ;; This summary buffer exists already, so we just select it.
3183 (gnus-set-global-variables)
3185 (gnus-kill-or-deaden-summary kill-buffer))
3186 (gnus-configure-windows 'summary 'force)
3187 (gnus-set-mode-line 'summary)
3188 (gnus-summary-position-point)
3191 ;; We couldn't select this group.
3193 (when (and (eq major-mode 'gnus-summary-mode)
3194 (not (equal (current-buffer) kill-buffer)))
3195 (kill-buffer (current-buffer))
3196 (if (not quit-config)
3198 ;; Update the info -- marks might need to be removed,
3200 (gnus-summary-update-info)
3201 (set-buffer gnus-group-buffer)
3202 (gnus-group-jump-to-group group)
3203 (gnus-group-next-unread-group 1))
3204 (gnus-handle-ephemeral-exit quit-config)))
3205 (let ((grpinfo (gnus-get-info group)))
3206 (if (null (gnus-info-read grpinfo))
3207 (gnus-message 3 "Group %s contains no messages"
3208 (gnus-group-decoded-name group))
3209 (gnus-message 3 "Can't select group")))
3211 ;; The user did a `C-g' while prompting for number of articles,
3212 ;; so we exit this group.
3213 ((eq did-select 'quit)
3214 (and (eq major-mode 'gnus-summary-mode)
3215 (not (equal (current-buffer) kill-buffer))
3216 (kill-buffer (current-buffer)))
3218 (gnus-kill-or-deaden-summary kill-buffer))
3219 (if (not quit-config)
3221 (set-buffer gnus-group-buffer)
3222 (gnus-group-jump-to-group group)
3223 (gnus-group-next-unread-group 1)
3224 (gnus-configure-windows 'group 'force))
3225 (gnus-handle-ephemeral-exit quit-config))
3226 ;; Finally signal the quit.
3228 ;; The group was successfully selected.
3230 (gnus-set-global-variables)
3231 ;; Save the active value in effect when the group was entered.
3232 (setq gnus-newsgroup-active
3234 (gnus-active gnus-newsgroup-name)))
3235 ;; You can change the summary buffer in some way with this hook.
3236 (gnus-run-hooks 'gnus-select-group-hook)
3237 (gnus-update-format-specifications
3238 nil 'summary 'summary-mode 'summary-dummy)
3239 (gnus-update-summary-mark-positions)
3240 ;; Do score processing.
3241 (when gnus-use-scoring
3242 (gnus-possibly-score-headers))
3243 ;; Check whether to fill in the gaps in the threads.
3244 (when gnus-build-sparse-threads
3245 (gnus-build-sparse-threads))
3246 ;; Find the initial limit.
3247 (if gnus-show-threads
3249 (let ((gnus-newsgroup-dormant nil))
3250 (gnus-summary-initial-limit show-all))
3251 (gnus-summary-initial-limit show-all))
3252 ;; When untreaded, all articles are always shown.
3253 (setq gnus-newsgroup-limit
3255 (lambda (header) (mail-header-number header))
3256 gnus-newsgroup-headers)))
3257 ;; Generate the summary buffer.
3259 (gnus-summary-prepare))
3260 (when gnus-use-trees
3261 (gnus-tree-open group)
3262 (setq gnus-summary-highlight-line-function
3263 'gnus-tree-highlight-article))
3264 ;; If the summary buffer is empty, but there are some low-scored
3265 ;; articles or some excluded dormants, we include these in the
3267 (when (and (zerop (buffer-size))
3269 (cond (gnus-newsgroup-dormant
3270 (gnus-summary-limit-include-dormant))
3271 ((and gnus-newsgroup-scored show-all)
3272 (gnus-summary-limit-include-expunged t))))
3273 ;; Function `gnus-apply-kill-file' must be called in this hook.
3274 (gnus-run-hooks 'gnus-apply-kill-hook)
3275 (if (and (zerop (buffer-size))
3278 ;; This newsgroup is empty.
3279 (gnus-summary-catchup-and-exit nil t)
3280 (gnus-message 6 "No unread news")
3282 (gnus-kill-or-deaden-summary kill-buffer))
3283 ;; Return nil from this function.
3285 ;; Hide conversation thread subtrees. We cannot do this in
3286 ;; gnus-summary-prepare-hook since kill processing may not
3287 ;; work with hidden articles.
3288 (gnus-summary-maybe-hide-threads)
3290 (gnus-kill-or-deaden-summary kill-buffer))
3291 (gnus-summary-auto-select-subject)
3292 ;; Show first unread article if requested.
3293 (if (and (not no-article)
3295 gnus-newsgroup-unreads
3296 gnus-auto-select-first)
3298 (gnus-configure-windows 'summary)
3299 (let ((art (gnus-summary-article-number)))
3300 (unless (or (memq art gnus-newsgroup-undownloaded)
3301 (memq art gnus-newsgroup-downloadable))
3302 (gnus-summary-goto-article art))))
3303 ;; Don't select any articles.
3304 (gnus-summary-position-point)
3305 (gnus-configure-windows 'summary 'force)
3306 (gnus-set-mode-line 'summary))
3307 (when (get-buffer-window gnus-group-buffer t)
3308 ;; Gotta use windows, because recenter does weird stuff if
3309 ;; the current buffer ain't the displayed window.
3310 (let ((owin (selected-window)))
3311 (select-window (get-buffer-window gnus-group-buffer t))
3312 (when (gnus-group-goto-group group)
3314 (select-window owin)))
3315 ;; Mark this buffer as "prepared".
3316 (setq gnus-newsgroup-prepared t)
3317 (gnus-run-hooks 'gnus-summary-prepared-hook)
3320 (defun gnus-summary-auto-select-subject ()
3321 "Select the subject line on initial group entry."
3322 (goto-char (point-min))
3324 ((eq gnus-auto-select-subject 'best)
3325 (gnus-summary-best-unread-subject))
3326 ((eq gnus-auto-select-subject 'unread)
3327 (gnus-summary-first-unread-subject))
3328 ((eq gnus-auto-select-subject 'unseen)
3329 (gnus-summary-first-unseen-subject))
3330 ((eq gnus-auto-select-subject 'first)
3333 ((gnus-functionp gnus-auto-select-subject)
3334 (funcall gnus-auto-select-subject))))
3336 (defun gnus-summary-prepare ()
3337 "Generate the summary buffer."
3339 (let ((buffer-read-only nil))
3341 (setq gnus-newsgroup-data nil
3342 gnus-newsgroup-data-reverse nil)
3343 (gnus-run-hooks 'gnus-summary-generate-hook)
3344 ;; Generate the buffer, either with threads or without.
3345 (when gnus-newsgroup-headers
3346 (gnus-summary-prepare-threads
3347 (if gnus-show-threads
3348 (gnus-sort-gathered-threads
3349 (funcall gnus-summary-thread-gathering-function
3351 (gnus-cut-threads (gnus-make-threads)))))
3352 ;; Unthreaded display.
3353 (gnus-sort-articles gnus-newsgroup-headers))))
3354 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3355 ;; Call hooks for modifying summary buffer.
3356 (goto-char (point-min))
3357 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3359 (defsubst gnus-general-simplify-subject (subject)
3360 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3363 ;; Truncate the subject.
3364 (gnus-simplify-subject-functions
3365 (gnus-map-function gnus-simplify-subject-functions subject))
3366 ((numberp gnus-summary-gather-subject-limit)
3367 (setq subject (gnus-simplify-subject-re subject))
3368 (if (> (length subject) gnus-summary-gather-subject-limit)
3369 (substring subject 0 gnus-summary-gather-subject-limit)
3371 ;; Fuzzily simplify it.
3372 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3373 (gnus-simplify-subject-fuzzy subject))
3374 ;; Just remove the leading "Re:".
3376 (gnus-simplify-subject-re subject))))
3378 (if (and gnus-summary-gather-exclude-subject
3379 (string-match gnus-summary-gather-exclude-subject subject))
3380 nil ; This article shouldn't be gathered
3383 (defun gnus-summary-simplify-subject-query ()
3384 "Query where the respool algorithm would put this article."
3386 (gnus-summary-select-article)
3387 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3389 (defun gnus-gather-threads-by-subject (threads)
3390 "Gather threads by looking at Subject headers."
3391 (if (not gnus-summary-make-false-root)
3393 (let ((hashtb (gnus-make-hashtable 1024))
3396 subject hthread whole-subject)
3398 (setq subject (gnus-general-simplify-subject
3399 (setq whole-subject (mail-header-subject
3402 (if (setq hthread (gnus-gethash subject hashtb))
3404 ;; We enter a dummy root into the thread, if we
3405 ;; haven't done that already.
3406 (unless (stringp (caar hthread))
3407 (setcar hthread (list whole-subject (car hthread))))
3408 ;; We add this new gathered thread to this gathered
3410 (setcdr (car hthread)
3411 (nconc (cdar hthread) (list (car threads))))
3412 ;; Remove it from the list of threads.
3413 (setcdr prev (cdr threads))
3414 (setq threads prev))
3415 ;; Enter this thread into the hash table.
3416 (gnus-sethash subject threads hashtb)))
3418 (setq threads (cdr threads)))
3421 (defun gnus-gather-threads-by-references (threads)
3422 "Gather threads by looking at References headers."
3423 (let ((idhashtb (gnus-make-hashtable 1024))
3424 (thhashtb (gnus-make-hashtable 1024))
3427 ids references id gthread gid entered ref)
3429 (when (setq references (mail-header-references (caar threads)))
3430 (setq id (mail-header-id (caar threads))
3431 ids (inline (gnus-split-references references))
3433 (while (setq ref (pop ids))
3434 (setq ids (delete ref ids))
3435 (if (not (setq gid (gnus-gethash ref idhashtb)))
3437 (gnus-sethash ref id idhashtb)
3438 (gnus-sethash id threads thhashtb))
3439 (setq gthread (gnus-gethash gid thhashtb))
3441 ;; We enter a dummy root into the thread, if we
3442 ;; haven't done that already.
3443 (unless (stringp (caar gthread))
3444 (setcar gthread (list (mail-header-subject (caar gthread))
3446 ;; We add this new gathered thread to this gathered
3448 (setcdr (car gthread)
3449 (nconc (cdar gthread) (list (car threads)))))
3450 ;; Add it into the thread hash table.
3451 (gnus-sethash id gthread thhashtb)
3453 ;; Remove it from the list of threads.
3454 (setcdr prev (cdr threads))
3455 (setq threads prev))))
3457 (setq threads (cdr threads)))
3460 (defun gnus-sort-gathered-threads (threads)
3461 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3462 (let ((result threads))
3464 (when (stringp (caar threads))
3465 (setcdr (car threads)
3466 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3467 (setq threads (cdr threads)))
3470 (defun gnus-thread-loop-p (root thread)
3471 "Say whether ROOT is in THREAD."
3472 (let ((stack (list thread))
3475 (while (setq thread (pop stack))
3476 (setq th (cdr thread))
3478 (not (eq (caar th) root)))
3481 ;; We have found a loop.
3483 (setcdr thread (delq (car th) (cdr thread)))
3484 (if (boundp (setq ref-dep (intern "none"
3485 gnus-newsgroup-dependencies)))
3486 (setcdr (symbol-value ref-dep)
3487 (nconc (cdr (symbol-value ref-dep))
3489 (set ref-dep (list nil (car th))))
3492 ;; Push all the subthreads onto the stack.
3493 (push (cdr thread) stack)))
3496 (defun gnus-make-threads ()
3497 "Go through the dependency hashtb and find the roots. Return all threads."
3499 (while (catch 'infloop
3502 ;; Deal with self-referencing References loops.
3503 (when (and (car (symbol-value refs))
3510 (car (symbol-value refs)) thread))
3511 (cdr (symbol-value refs)))))))
3514 (unless (car (symbol-value refs))
3515 ;; These threads do not refer back to any other articles,
3516 ;; so they're roots.
3517 (setq threads (append (cdr (symbol-value refs)) threads))))
3518 gnus-newsgroup-dependencies)))
3521 ;; Build the thread tree.
3522 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3523 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3525 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3526 if it was already present.
3528 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3529 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3530 Message-IDs will be renamed be renamed to a unique Message-ID before
3533 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3534 (let* ((id (mail-header-id header))
3535 (id-dep (and id (intern id dependencies)))
3536 ref ref-dep ref-header)
3537 ;; Enter this `header' in the `dependencies' table.
3541 ;; The first two cases do the normal part: enter a new `header'
3542 ;; in the `dependencies' table.
3543 ((not (boundp id-dep))
3544 (set id-dep (list header)))
3545 ((null (car (symbol-value id-dep)))
3546 (setcar (symbol-value id-dep) header))
3548 ;; From here the `header' was already present in the
3549 ;; `dependencies' table.
3551 ;; Overrides an existing entry;
3552 ;; just set the header part of the entry.
3553 (setcar (symbol-value id-dep) header))
3555 ;; Renames the existing `header' to a unique Message-ID.
3556 ((not gnus-summary-ignore-duplicates)
3557 ;; An article with this Message-ID has already been seen.
3558 ;; We rename the Message-ID.
3559 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3561 (mail-header-set-id header id))
3563 ;; The last case ignores an existing entry, except it adds any
3564 ;; additional Xrefs (in case the two articles came from different
3566 ;; Also sets `header' to `nil' meaning that the `dependencies'
3567 ;; table was *not* modified.
3569 (mail-header-set-xref
3570 (car (symbol-value id-dep))
3571 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3573 (or (mail-header-xref header) "")))
3577 ;; First check if that we are not creating a References loop.
3578 (setq ref (gnus-parent-id (mail-header-references header)))
3580 (setq ref-dep (intern-soft ref dependencies))
3582 (setq ref-header (car (symbol-value ref-dep))))
3583 (if (string= id ref)
3584 ;; Yuk! This is a reference loop. Make the article be a
3587 (mail-header-set-references (car (symbol-value id-dep)) "none")
3589 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3590 (setq ref (gnus-parent-id (mail-header-references header)))
3591 (setq ref-dep (intern (or ref "none") dependencies))
3592 (if (boundp ref-dep)
3593 (setcdr (symbol-value ref-dep)
3594 (nconc (cdr (symbol-value ref-dep))
3595 (list (symbol-value id-dep))))
3596 (set ref-dep (list nil (symbol-value id-dep)))))
3599 (defun gnus-build-sparse-threads ()
3600 (let ((headers gnus-newsgroup-headers)
3601 (mail-parse-charset gnus-newsgroup-charset)
3602 (gnus-summary-ignore-duplicates t)
3603 header references generation relations
3604 subject child end new-child date)
3605 ;; First we create an alist of generations/relations, where
3606 ;; generations is how much we trust the relation, and the relation
3608 (gnus-message 7 "Making sparse threads...")
3610 (nnheader-set-temp-buffer " *gnus sparse threads*")
3611 (while (setq header (pop headers))
3612 (when (and (setq references (mail-header-references header))
3613 (not (string= references "")))
3615 (setq child (mail-header-id header)
3616 subject (mail-header-subject header)
3617 date (mail-header-date header)
3619 (while (search-backward ">" nil t)
3620 (setq end (1+ (point)))
3621 (when (search-backward "<" nil t)
3622 (setq new-child (buffer-substring (point) end))
3623 (push (list (incf generation)
3624 child (setq child new-child)
3628 (push (list (1+ generation) child nil subject) relations))
3630 (kill-buffer (current-buffer)))
3631 ;; Sort over trustworthiness.
3634 (when (gnus-dependencies-add-header
3635 (make-full-mail-header
3636 gnus-reffed-article-number
3637 (nth 3 relation) "" (or (nth 4 relation) "")
3639 (or (nth 2 relation) "") 0 0 "")
3640 gnus-newsgroup-dependencies nil)
3641 (push gnus-reffed-article-number gnus-newsgroup-limit)
3642 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3643 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3644 gnus-newsgroup-reads)
3645 (decf gnus-reffed-article-number)))
3646 (sort relations 'car-less-than-car))
3647 (gnus-message 7 "Making sparse threads...done")))
3649 (defun gnus-build-old-threads ()
3650 ;; Look at all the articles that refer back to old articles, and
3651 ;; fetch the headers for the articles that aren't there. This will
3652 ;; build complete threads - if the roots haven't been expired by the
3654 (let ((mail-parse-charset gnus-newsgroup-charset)
3658 (when (not (car (symbol-value refs)))
3659 (setq heads (cdr (symbol-value refs)))
3661 (if (memq (mail-header-number (caar heads))
3662 gnus-newsgroup-dormant)
3663 (setq heads (cdr heads))
3664 (setq id (symbol-name refs))
3665 (while (and (setq id (gnus-build-get-header id))
3666 (not (car (gnus-id-to-thread id)))))
3667 (setq heads nil)))))
3668 gnus-newsgroup-dependencies)))
3670 ;; This function has to be called with point after the article number
3671 ;; on the beginning of the line.
3672 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3673 (let ((eol (gnus-point-at-eol))
3674 (buffer (current-buffer))
3677 ;; overview: [num subject from date id refs chars lines misc]
3680 (narrow-to-region (point) eol)
3685 (make-full-mail-header
3687 (funcall gnus-decode-encoded-word-function
3688 (nnheader-nov-field)) ; subject
3689 (funcall gnus-decode-encoded-word-function
3690 (nnheader-nov-field)) ; from
3691 (nnheader-nov-field) ; date
3692 (nnheader-nov-read-message-id) ; id
3693 (nnheader-nov-field) ; refs
3694 (nnheader-nov-read-integer) ; chars
3695 (nnheader-nov-read-integer) ; lines
3697 (if (looking-at "Xref: ")
3698 (goto-char (match-end 0)))
3699 (nnheader-nov-field)) ; Xref
3700 (nnheader-nov-parse-extra)))) ; extra
3704 (when gnus-alter-header-function
3705 (funcall gnus-alter-header-function header))
3706 (gnus-dependencies-add-header header dependencies force-new)))
3708 (defun gnus-build-get-header (id)
3709 "Look through the buffer of NOV lines and find the header to ID.
3710 Enter this line into the dependencies hash table, and return
3711 the id of the parent article (if any)."
3712 (let ((deps gnus-newsgroup-dependencies)
3716 (set-buffer nntp-server-buffer)
3717 (let ((case-fold-search nil))
3718 (goto-char (point-min))
3719 (while (and (not found)
3720 (search-forward id nil t))
3722 (setq found (looking-at
3723 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3724 (regexp-quote id))))
3725 (or found (beginning-of-line 2)))
3729 (setq header (gnus-nov-parse-line
3730 (read (current-buffer)) deps))
3731 (gnus-parent-id (mail-header-references header))))))
3733 (let ((number (mail-header-number header)))
3734 (push number gnus-newsgroup-limit)
3735 (push header gnus-newsgroup-headers)
3736 (if (memq number gnus-newsgroup-unselected)
3738 (push number gnus-newsgroup-unreads)
3739 (setq gnus-newsgroup-unselected
3740 (delq number gnus-newsgroup-unselected)))
3741 (push number gnus-newsgroup-ancient)))))))
3743 (defun gnus-build-all-threads ()
3744 "Read all the headers."
3745 (let ((gnus-summary-ignore-duplicates t)
3746 (mail-parse-charset gnus-newsgroup-charset)
3747 (dependencies gnus-newsgroup-dependencies)
3750 (set-buffer nntp-server-buffer)
3751 (let ((case-fold-search nil))
3752 (goto-char (point-min))
3755 (setq article (read (current-buffer))
3756 header (gnus-nov-parse-line article dependencies)))
3759 (set-buffer gnus-summary-buffer)
3760 (push header gnus-newsgroup-headers)
3761 (if (memq (setq article (mail-header-number header))
3762 gnus-newsgroup-unselected)
3764 (push article gnus-newsgroup-unreads)
3765 (setq gnus-newsgroup-unselected
3766 (delq article gnus-newsgroup-unselected)))
3767 (push article gnus-newsgroup-ancient)))
3768 (forward-line 1)))))))
3770 (defun gnus-summary-update-article-line (article header)
3771 "Update the line for ARTICLE using HEADERS."
3772 (let* ((id (mail-header-id header))
3773 (thread (gnus-id-to-thread id)))
3775 (error "Article in no thread"))
3776 ;; Update the thread.
3777 (setcar thread header)
3778 (gnus-summary-goto-subject article)
3779 (let* ((datal (gnus-data-find-list article))
3781 (length (when (cdr datal)
3782 (- (gnus-data-pos data)
3783 (gnus-data-pos (cadr datal)))))
3784 (buffer-read-only nil)
3785 (level (gnus-summary-thread-level)))
3787 (gnus-summary-insert-line
3788 header level nil (gnus-article-mark article)
3789 (memq article gnus-newsgroup-replied)
3790 (memq article gnus-newsgroup-expirable)
3791 ;; Only insert the Subject string when it's different
3792 ;; from the previous Subject string.
3797 (mail-header-subject
3800 (gnus-data-find-list
3802 (gnus-data-list t)))))
3803 ;; Error on the side of excessive subjects.
3805 (mail-header-subject header)))
3807 (mail-header-subject header))
3808 nil (cdr (assq article gnus-newsgroup-scored))
3809 (memq article gnus-newsgroup-processable))
3811 (gnus-data-update-list
3812 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3814 (defun gnus-summary-update-article (article &optional iheader)
3815 "Update ARTICLE in the summary buffer."
3816 (set-buffer gnus-summary-buffer)
3817 (let* ((header (gnus-summary-article-header article))
3818 (id (mail-header-id header))
3819 (data (gnus-data-find article))
3820 (thread (gnus-id-to-thread id))
3821 (references (mail-header-references header))
3825 (when (and references
3826 (not (equal "" references)))
3829 (buffer-read-only nil)
3835 (delq thread parent)))
3836 (if (gnus-summary-insert-subject id header)
3837 ;; Set the (possibly) new article number in the data structure.
3838 (gnus-data-set-number data (gnus-id-to-article id))
3842 (defun gnus-rebuild-thread (id &optional line)
3843 "Rebuild the thread containing ID.
3844 If LINE, insert the rebuilt thread starting on line LINE."
3845 (let ((buffer-read-only nil)
3846 old-pos current thread data)
3847 (if (not gnus-show-threads)
3848 (setq thread (list (car (gnus-id-to-thread id))))
3849 ;; Get the thread this article is part of.
3850 (setq thread (gnus-remove-thread id)))
3851 (setq old-pos (gnus-point-at-bol))
3852 (setq current (save-excursion
3853 (and (re-search-backward "[\r\n]" nil t)
3854 (gnus-summary-article-number))))
3855 ;; If this is a gathered thread, we have to go some re-gathering.
3856 (when (stringp (car thread))
3857 (let ((subject (car thread))
3859 (setq thread (cdr thread))
3861 (unless (memq (setq thr (gnus-id-to-thread
3863 (mail-header-id (caar thread)))))
3866 (setq thread (cdr thread)))
3867 ;; We now have all (unique) roots.
3868 (if (= (length roots) 1)
3869 ;; All the loose roots are now one solid root.
3870 (setq thread (car roots))
3871 (setq thread (cons subject (gnus-sort-threads roots))))))
3873 ;; We then insert this thread into the summary buffer.
3875 (goto-char (point-min))
3876 (forward-line (1- line)))
3877 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3878 (if gnus-show-threads
3879 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3880 (gnus-summary-prepare-unthreaded thread))
3881 (setq data (nreverse gnus-newsgroup-data))
3882 (setq threads gnus-newsgroup-threads))
3883 ;; We splice the new data into the data structure.
3884 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3885 ;;!!! then we want to insert at the beginning of the buffer.
3886 ;;!!! That happens to be true with Gnus now, but that may
3887 ;;!!! change in the future. Perhaps.
3888 (gnus-data-enter-list
3889 (if line nil current) data (- (point) old-pos))
3890 (setq gnus-newsgroup-threads
3891 (nconc threads gnus-newsgroup-threads))
3892 (gnus-data-compute-positions))))
3894 (defun gnus-number-to-header (number)
3895 "Return the header for article NUMBER."
3896 (let ((headers gnus-newsgroup-headers))
3898 (not (= number (mail-header-number (car headers)))))
3903 (defun gnus-parent-headers (in-headers &optional generation)
3904 "Return the headers of the GENERATIONeth parent of HEADERS."
3906 (setq generation 1))
3908 (headers in-headers)
3911 (not (zerop generation))
3912 (setq references (mail-header-references headers)))
3913 (setq headers (if (and references
3914 (setq parent (gnus-parent-id references)))
3915 (car (gnus-id-to-thread parent))
3918 (and (not (eq headers in-headers))
3921 (defun gnus-id-to-thread (id)
3922 "Return the (sub-)thread where ID appears."
3923 (gnus-gethash id gnus-newsgroup-dependencies))
3925 (defun gnus-id-to-article (id)
3926 "Return the article number of ID."
3927 (let ((thread (gnus-id-to-thread id)))
3930 (mail-header-number (car thread)))))
3932 (defun gnus-id-to-header (id)
3933 "Return the article headers of ID."
3934 (car (gnus-id-to-thread id)))
3936 (defun gnus-article-displayed-root-p (article)
3937 "Say whether ARTICLE is a root(ish) article."
3938 (let ((level (gnus-summary-thread-level article))
3939 (refs (mail-header-references (gnus-summary-article-header article)))
3945 ((null (gnus-parent-id refs)) t)
3947 (null (setq particle (gnus-id-to-article
3948 (gnus-parent-id refs))))
3949 (null (gnus-summary-thread-level particle)))))))
3951 (defun gnus-root-id (id)
3952 "Return the id of the root of the thread where ID appears."
3954 (while (and id (setq prev (car (gnus-id-to-thread id))))
3956 id (gnus-parent-id (mail-header-references prev))))
3959 (defun gnus-articles-in-thread (thread)
3960 "Return the list of articles in THREAD."
3961 (cons (mail-header-number (car thread))
3962 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3964 (defun gnus-remove-thread (id &optional dont-remove)
3965 "Remove the thread that has ID in it."
3966 (let (headers thread last-id)
3967 ;; First go up in this thread until we find the root.
3968 (setq last-id (gnus-root-id id)
3969 headers (message-flatten-list (gnus-id-to-thread last-id)))
3970 ;; We have now found the real root of this thread. It might have
3971 ;; been gathered into some loose thread, so we have to search
3972 ;; through the threads to find the thread we wanted.
3973 (let ((threads gnus-newsgroup-threads)
3976 (setq sub (car threads))
3977 (if (stringp (car sub))
3978 ;; This is a gathered thread, so we look at the roots
3979 ;; below it to find whether this article is in this
3982 (setq sub (cdr sub))
3984 (when (member (caar sub) headers)
3985 (setq thread (car threads)
3988 (setq sub (cdr sub))))
3989 ;; It's an ordinary thread, so we check it.
3990 (when (eq (car sub) (car headers))
3993 (setq threads (cdr threads)))
3994 ;; If this article is in no thread, then it's a root.
3997 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3998 (setq thread (gnus-id-to-thread last-id)))
4001 thread ; We return this thread.
4003 (if (stringp (car thread))
4005 ;; If we use dummy roots, then we have to remove the
4006 ;; dummy root as well.
4007 (when (eq gnus-summary-make-false-root 'dummy)
4008 ;; We go to the dummy root by going to
4009 ;; the first sub-"thread", and then one line up.
4010 (gnus-summary-goto-article
4011 (mail-header-number (caadr thread)))
4014 (gnus-data-compute-positions))
4015 (setq thread (cdr thread))
4017 (gnus-remove-thread-1 (car thread))
4018 (setq thread (cdr thread))))
4019 (gnus-remove-thread-1 thread))))))))
4021 (defun gnus-remove-thread-1 (thread)
4022 "Remove the thread THREAD recursively."
4023 (let ((number (mail-header-number (pop thread)))
4025 (setq thread (reverse thread))
4027 (gnus-remove-thread-1 (pop thread)))
4028 (when (setq d (gnus-data-find number))
4029 (goto-char (gnus-data-pos d))
4030 (gnus-summary-show-thread)
4033 (- (gnus-point-at-bol)
4035 (1+ (gnus-point-at-eol))
4036 (gnus-delete-line)))))))
4038 (defun gnus-sort-threads-1 (threads func)
4039 (sort (mapcar (lambda (thread)
4042 (gnus-sort-threads-1 (cdr thread) func))))
4045 (defun gnus-sort-threads (threads)
4047 (if (not gnus-thread-sort-functions)
4049 (gnus-message 8 "Sorting threads...")
4051 (gnus-sort-threads-1
4053 (gnus-make-sort-function gnus-thread-sort-functions))
4054 (gnus-message 8 "Sorting threads...done"))))
4056 (defun gnus-sort-articles (articles)
4058 (when gnus-article-sort-functions
4059 (gnus-message 7 "Sorting articles...")
4061 (setq gnus-newsgroup-headers
4062 (sort articles (gnus-make-sort-function
4063 gnus-article-sort-functions)))
4064 (gnus-message 7 "Sorting articles...done"))))
4066 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4067 (defmacro gnus-thread-header (thread)
4068 "Return header of first article in THREAD.
4069 Note that THREAD must never, ever be anything else than a variable -
4070 using some other form will lead to serious barfage."
4071 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4072 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4073 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4076 (defsubst gnus-article-sort-by-number (h1 h2)
4077 "Sort articles by article number."
4078 (< (mail-header-number h1)
4079 (mail-header-number h2)))
4081 (defun gnus-thread-sort-by-number (h1 h2)
4082 "Sort threads by root article number."
4083 (gnus-article-sort-by-number
4084 (gnus-thread-header h1) (gnus-thread-header h2)))
4086 (defsubst gnus-article-sort-by-lines (h1 h2)
4087 "Sort articles by article Lines header."
4088 (< (mail-header-lines h1)
4089 (mail-header-lines h2)))
4091 (defun gnus-thread-sort-by-lines (h1 h2)
4092 "Sort threads by root article Lines header."
4093 (gnus-article-sort-by-lines
4094 (gnus-thread-header h1) (gnus-thread-header h2)))
4096 (defsubst gnus-article-sort-by-chars (h1 h2)
4097 "Sort articles by octet length."
4098 (< (mail-header-chars h1)
4099 (mail-header-chars h2)))
4101 (defun gnus-thread-sort-by-chars (h1 h2)
4102 "Sort threads by root article octet length."
4103 (gnus-article-sort-by-chars
4104 (gnus-thread-header h1) (gnus-thread-header h2)))
4106 (defsubst gnus-article-sort-by-author (h1 h2)
4107 "Sort articles by root author."
4109 (let ((extract (funcall
4110 gnus-extract-address-components
4111 (mail-header-from h1))))
4112 (or (car extract) (cadr extract) ""))
4113 (let ((extract (funcall
4114 gnus-extract-address-components
4115 (mail-header-from h2))))
4116 (or (car extract) (cadr extract) ""))))
4118 (defun gnus-thread-sort-by-author (h1 h2)
4119 "Sort threads by root author."
4120 (gnus-article-sort-by-author
4121 (gnus-thread-header h1) (gnus-thread-header h2)))
4123 (defsubst gnus-article-sort-by-subject (h1 h2)
4124 "Sort articles by root subject."
4126 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4127 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4129 (defun gnus-thread-sort-by-subject (h1 h2)
4130 "Sort threads by root subject."
4131 (gnus-article-sort-by-subject
4132 (gnus-thread-header h1) (gnus-thread-header h2)))
4134 (defsubst gnus-article-sort-by-date (h1 h2)
4135 "Sort articles by root article date."
4137 (gnus-date-get-time (mail-header-date h1))
4138 (gnus-date-get-time (mail-header-date h2))))
4140 (defun gnus-thread-sort-by-date (h1 h2)
4141 "Sort threads by root article date."
4142 (gnus-article-sort-by-date
4143 (gnus-thread-header h1) (gnus-thread-header h2)))
4145 (defsubst gnus-article-sort-by-score (h1 h2)
4146 "Sort articles by root article score.
4147 Unscored articles will be counted as having a score of zero."
4148 (> (or (cdr (assq (mail-header-number h1)
4149 gnus-newsgroup-scored))
4150 gnus-summary-default-score 0)
4151 (or (cdr (assq (mail-header-number h2)
4152 gnus-newsgroup-scored))
4153 gnus-summary-default-score 0)))
4155 (defun gnus-thread-sort-by-score (h1 h2)
4156 "Sort threads by root article score."
4157 (gnus-article-sort-by-score
4158 (gnus-thread-header h1) (gnus-thread-header h2)))
4160 (defun gnus-thread-sort-by-total-score (h1 h2)
4161 "Sort threads by the sum of all scores in the thread.
4162 Unscored articles will be counted as having a score of zero."
4163 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4165 (defun gnus-thread-total-score (thread)
4166 ;; This function find the total score of THREAD.
4171 (if (stringp (car thread))
4172 (apply gnus-thread-score-function 0
4173 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4174 (gnus-thread-total-score-1 thread)))
4176 (gnus-thread-total-score-1 (list thread)))))
4178 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4179 "Sort threads such that the thread with the most recently arrived article comes first."
4180 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4182 (defun gnus-thread-highest-number (thread)
4183 "Return the highest article number in THREAD."
4184 (apply 'max (mapcar (lambda (header)
4185 (mail-header-number header))
4186 (message-flatten-list thread))))
4188 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4189 "Sort threads such that the thread with the most recently dated article comes first."
4190 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4192 (defun gnus-thread-latest-date (thread)
4193 "Return the highest article date in THREAD."
4194 (let ((previous-time 0))
4199 (mail-header-parse-date
4201 (mail-header-date header)
4202 (error previous-time))))))
4204 (message-flatten-list thread)
4206 (< (mail-header-number h1)
4207 (mail-header-number h2))))))))
4209 (defun gnus-thread-total-score-1 (root)
4210 ;; This function find the total score of the thread below ROOT.
4211 (setq root (car root))
4212 (apply gnus-thread-score-function
4214 (mapcar 'gnus-thread-total-score
4215 (cdr (gnus-id-to-thread (mail-header-id root))))
4216 (when (> (mail-header-number root) 0)
4217 (list (or (cdr (assq (mail-header-number root)
4218 gnus-newsgroup-scored))
4219 gnus-summary-default-score 0))))
4220 (list gnus-summary-default-score)
4223 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4224 (defvar gnus-tmp-prev-subject nil)
4225 (defvar gnus-tmp-false-parent nil)
4226 (defvar gnus-tmp-root-expunged nil)
4227 (defvar gnus-tmp-dummy-line nil)
4229 (eval-when-compile (defvar gnus-tmp-header))
4230 (defun gnus-extra-header (type &optional header)
4231 "Return the extra header of TYPE."
4232 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4235 (defvar gnus-tmp-thread-tree-header-string "")
4237 (defvar gnus-sum-thread-tree-root "> "
4238 "With %B spec, used for the root of a thread.
4239 If nil, use subject instead.")
4240 (defvar gnus-sum-thread-tree-single-indent ""
4241 "With %B spec, used for a thread with just one message.
4242 If nil, use subject instead.")
4243 (defvar gnus-sum-thread-tree-vertical "| "
4244 "With %B spec, used for drawing a vertical line.")
4245 (defvar gnus-sum-thread-tree-indent " "
4246 "With %B spec, used for indenting.")
4247 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4248 "With %B spec, used for a leaf with brothers.")
4249 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4250 "With %B spec, used for a leaf without brothers.")
4252 (defun gnus-summary-prepare-threads (threads)
4253 "Prepare summary buffer from THREADS and indentation LEVEL.
4254 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4255 or a straight list of headers."
4256 (gnus-message 7 "Generating summary...")
4258 (setq gnus-newsgroup-threads threads)
4261 (let ((gnus-tmp-level 0)
4262 (default-score (or gnus-summary-default-score 0))
4263 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4264 thread number subject stack state gnus-tmp-gathered beg-match
4265 new-roots gnus-tmp-new-adopts thread-end
4266 gnus-tmp-header gnus-tmp-unread
4267 gnus-tmp-replied gnus-tmp-subject-or-nil
4268 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4269 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4270 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4273 (setq gnus-tmp-prev-subject nil)
4275 (if (vectorp (car threads))
4276 ;; If this is a straight (sic) list of headers, then a
4277 ;; threaded summary display isn't required, so we just create
4278 ;; an unthreaded one.
4279 (gnus-summary-prepare-unthreaded threads)
4281 ;; Do the threaded display.
4283 (while (or threads stack gnus-tmp-new-adopts new-roots)
4285 (if (and (= gnus-tmp-level 0)
4288 (not gnus-tmp-false-parent)
4289 (or gnus-tmp-new-adopts new-roots))
4290 (if gnus-tmp-new-adopts
4291 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4292 thread (list (car gnus-tmp-new-adopts))
4293 gnus-tmp-header (caar thread)
4294 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4296 (setq thread (list (car new-roots))
4297 gnus-tmp-header (caar thread)
4298 new-roots (cdr new-roots))))
4301 ;; If there are some threads, we do them before the
4302 ;; threads on the stack.
4303 (setq thread threads
4304 gnus-tmp-header (caar thread))
4305 ;; There were no current threads, so we pop something off
4307 (setq state (car stack)
4308 gnus-tmp-level (car state)
4309 tree-stack (cadr state)
4310 thread (caddr state)
4312 gnus-tmp-header (caar thread))))
4314 (setq gnus-tmp-false-parent nil)
4315 (setq gnus-tmp-root-expunged nil)
4316 (setq thread-end nil)
4318 (if (stringp gnus-tmp-header)
4319 ;; The header is a dummy root.
4321 ((eq gnus-summary-make-false-root 'adopt)
4322 ;; We let the first article adopt the rest.
4323 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4325 (setq gnus-tmp-gathered
4327 (lambda (h) (mail-header-number (car h)))
4330 (setq thread (cons (list (caar thread)
4333 (setq gnus-tmp-level -1
4334 gnus-tmp-false-parent t))
4335 ((eq gnus-summary-make-false-root 'empty)
4336 ;; We print adopted articles with empty subject fields.
4337 (setq gnus-tmp-gathered
4339 (lambda (h) (mail-header-number (car h)))
4342 (setq gnus-tmp-level -1))
4343 ((eq gnus-summary-make-false-root 'dummy)
4344 ;; We remember that we probably want to output a dummy
4346 (setq gnus-tmp-dummy-line gnus-tmp-header)
4347 (setq gnus-tmp-prev-subject gnus-tmp-header))
4349 ;; We do not make a root for the gathered
4350 ;; sub-threads at all.
4351 (setq gnus-tmp-level -1)))
4353 (setq number (mail-header-number gnus-tmp-header)
4354 subject (mail-header-subject gnus-tmp-header))
4357 ;; If the thread has changed subject, we might want to make
4358 ;; this subthread into a root.
4359 ((and (null gnus-thread-ignore-subject)
4360 (not (zerop gnus-tmp-level))
4361 gnus-tmp-prev-subject
4363 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4364 (setq new-roots (nconc new-roots (list (car thread)))
4366 gnus-tmp-header nil))
4367 ;; If the article lies outside the current limit,
4368 ;; then we do not display it.
4369 ((not (memq number gnus-newsgroup-limit))
4370 (setq gnus-tmp-gathered
4372 (lambda (h) (mail-header-number (car h)))
4375 (setq gnus-tmp-new-adopts (if (cdar thread)
4376 (append gnus-tmp-new-adopts
4378 gnus-tmp-new-adopts)
4380 gnus-tmp-header nil)
4381 (when (zerop gnus-tmp-level)
4382 (setq gnus-tmp-root-expunged t)))
4383 ;; Perhaps this article is to be marked as read?
4384 ((and gnus-summary-mark-below
4385 (< (or (cdr (assq number gnus-newsgroup-scored))
4387 gnus-summary-mark-below)
4388 ;; Don't touch sparse articles.
4389 (not (gnus-summary-article-sparse-p number))
4390 (not (gnus-summary-article-ancient-p number)))
4391 (setq gnus-newsgroup-unreads
4392 (delq number gnus-newsgroup-unreads))
4393 (if gnus-newsgroup-auto-expire
4394 (push number gnus-newsgroup-expirable)
4395 (push (cons number gnus-low-score-mark)
4396 gnus-newsgroup-reads))))
4398 (when gnus-tmp-header
4399 ;; We may have an old dummy line to output before this
4401 (when (and gnus-tmp-dummy-line
4404 (mail-header-subject gnus-tmp-header)))
4405 (gnus-summary-insert-dummy-line
4406 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4407 (setq gnus-tmp-dummy-line nil))
4409 ;; Compute the mark.
4410 (setq gnus-tmp-unread (gnus-article-mark number))
4412 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4413 gnus-tmp-header gnus-tmp-level)
4414 gnus-newsgroup-data)
4416 ;; Actually insert the line.
4418 gnus-tmp-subject-or-nil
4420 ((and gnus-thread-ignore-subject
4421 gnus-tmp-prev-subject
4422 (not (inline (gnus-subject-equal
4423 gnus-tmp-prev-subject subject))))
4425 ((zerop gnus-tmp-level)
4426 (if (and (eq gnus-summary-make-false-root 'empty)
4427 (memq number gnus-tmp-gathered)
4428 gnus-tmp-prev-subject
4429 (inline (gnus-subject-equal
4430 gnus-tmp-prev-subject subject)))
4431 gnus-summary-same-subject
4433 (t gnus-summary-same-subject)))
4434 (if (and (eq gnus-summary-make-false-root 'adopt)
4435 (= gnus-tmp-level 1)
4436 (memq number gnus-tmp-gathered))
4437 (setq gnus-tmp-opening-bracket ?\<
4438 gnus-tmp-closing-bracket ?\>)
4439 (setq gnus-tmp-opening-bracket ?\[
4440 gnus-tmp-closing-bracket ?\]))
4442 gnus-tmp-indentation
4443 (aref gnus-thread-indent-array gnus-tmp-level)
4444 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4445 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4446 gnus-summary-default-score 0)
4448 (if (or (null gnus-summary-default-score)
4449 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4450 gnus-summary-zcore-fuzz))
4452 (if (< gnus-tmp-score gnus-summary-default-score)
4453 gnus-score-below-mark gnus-score-over-mark))
4455 (cond ((memq number gnus-newsgroup-processable)
4457 ((memq number gnus-newsgroup-cached)
4459 ((memq number gnus-newsgroup-replied)
4461 ((memq number gnus-newsgroup-forwarded)
4462 gnus-forwarded-mark)
4463 ((memq number gnus-newsgroup-saved)
4465 ((memq number gnus-newsgroup-recent)
4467 ((memq number gnus-newsgroup-unseen)
4470 gnus-tmp-from (mail-header-from gnus-tmp-header)
4473 ((string-match "<[^>]+> *$" gnus-tmp-from)
4474 (setq beg-match (match-beginning 0))
4475 (or (and (string-match "^\".+\"" gnus-tmp-from)
4476 (substring gnus-tmp-from 1 (1- (match-end 0))))
4477 (substring gnus-tmp-from 0 beg-match)))
4478 ((string-match "(.+)" gnus-tmp-from)
4479 (substring gnus-tmp-from
4480 (1+ (match-beginning 0)) (1- (match-end 0))))
4482 gnus-tmp-thread-tree-header-string
4484 ((not gnus-show-threads) "")
4485 ((zerop gnus-tmp-level)
4487 (or gnus-sum-thread-tree-root subject)
4488 (or gnus-sum-thread-tree-single-indent subject)))
4490 (concat (apply 'concat
4491 (mapcar (lambda (item)
4493 gnus-sum-thread-tree-vertical
4494 gnus-sum-thread-tree-indent))
4495 (cdr (reverse tree-stack))))
4497 gnus-sum-thread-tree-leaf-with-other
4498 gnus-sum-thread-tree-single-leaf)))))
4499 (when (string= gnus-tmp-name "")
4500 (setq gnus-tmp-name gnus-tmp-from))
4501 (unless (numberp gnus-tmp-lines)
4502 (setq gnus-tmp-lines -1))
4503 (if (= gnus-tmp-lines -1)
4504 (setq gnus-tmp-lines "?")
4505 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4506 (gnus-put-text-property
4508 (progn (eval gnus-summary-line-format-spec) (point))
4509 'gnus-number number)
4512 (gnus-run-hooks 'gnus-summary-update-hook)
4515 (setq gnus-tmp-prev-subject subject)))
4517 (when (nth 1 thread)
4518 (push (list (max 0 gnus-tmp-level)
4519 (copy-list tree-stack)
4522 (push (if (nth 1 thread) 1 0) tree-stack)
4523 (incf gnus-tmp-level)
4524 (setq threads (if thread-end nil (cdar thread)))
4526 (setq gnus-tmp-level 0)))))
4527 (gnus-message 7 "Generating summary...done"))
4529 (defun gnus-summary-prepare-unthreaded (headers)
4530 "Generate an unthreaded summary buffer based on HEADERS."
4531 (let (header number mark)
4536 ;; We may have to root out some bad articles...
4537 (when (memq (setq number (mail-header-number
4538 (setq header (pop headers))))
4539 gnus-newsgroup-limit)
4540 ;; Mark article as read when it has a low score.
4541 (when (and gnus-summary-mark-below
4542 (< (or (cdr (assq number gnus-newsgroup-scored))
4543 gnus-summary-default-score 0)
4544 gnus-summary-mark-below)
4545 (not (gnus-summary-article-ancient-p number)))
4546 (setq gnus-newsgroup-unreads
4547 (delq number gnus-newsgroup-unreads))
4548 (if gnus-newsgroup-auto-expire
4549 (push number gnus-newsgroup-expirable)
4550 (push (cons number gnus-low-score-mark)
4551 gnus-newsgroup-reads)))
4553 (setq mark (gnus-article-mark number))
4554 (push (gnus-data-make number mark (1+ (point)) header 0)
4555 gnus-newsgroup-data)
4556 (gnus-summary-insert-line
4558 mark (memq number gnus-newsgroup-replied)
4559 (memq number gnus-newsgroup-expirable)
4560 (mail-header-subject header) nil
4561 (cdr (assq number gnus-newsgroup-scored))
4562 (memq number gnus-newsgroup-processable))))))
4564 (defun gnus-summary-remove-list-identifiers ()
4565 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4566 (let ((regexp (if (consp gnus-list-identifiers)
4567 (mapconcat 'identity gnus-list-identifiers " *\\|")
4568 gnus-list-identifiers))
4571 (dolist (header gnus-newsgroup-headers)
4572 (setq subject (mail-header-subject header)
4574 (while (string-match
4575 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4578 (concat (substring subject 0 (match-beginning 2))
4579 (substring subject (match-end 0)))
4583 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4585 (concat (substring subject 0 (match-beginning 1))
4586 (substring subject (match-end 1)))))
4588 (mail-header-set-subject header subject))))))
4590 (defun gnus-fetch-headers (articles)
4591 "Fetch headers of ARTICLES."
4592 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4593 (gnus-message 5 "Fetching headers for %s..." name)
4596 (setq gnus-headers-retrieved-by
4597 (gnus-retrieve-headers
4598 articles gnus-newsgroup-name
4599 ;; We might want to fetch old headers, but
4600 ;; not if there is only 1 article.
4602 (not (eq gnus-fetch-old-headers 'some))
4603 (not (numberp gnus-fetch-old-headers)))
4604 (> (length articles) 1))
4605 gnus-fetch-old-headers))))
4606 (gnus-get-newsgroup-headers-xover
4607 articles nil nil gnus-newsgroup-name t)
4608 (gnus-get-newsgroup-headers))
4609 (gnus-message 5 "Fetching headers for %s...done" name))))
4611 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4612 "Select newsgroup GROUP.
4613 If READ-ALL is non-nil, all articles in the group are selected.
4614 If SELECT-ARTICLES, only select those articles from GROUP."
4615 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4616 ;;!!! Dirty hack; should be removed.
4617 (gnus-summary-ignore-duplicates
4618 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4620 gnus-summary-ignore-duplicates))
4621 (info (nth 2 entry))
4622 articles fetched-articles cached)
4624 (unless (gnus-check-server
4625 (set (make-local-variable 'gnus-current-select-method)
4626 (gnus-find-method-for-group group)))
4627 (error "Couldn't open server"))
4629 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4630 (gnus-activate-group group) ; Or we can activate it...
4631 (progn ; Or we bug out.
4632 (when (equal major-mode 'gnus-summary-mode)
4633 (kill-buffer (current-buffer)))
4634 (error "Couldn't activate group %s: %s"
4635 group (gnus-status-message group))))
4637 (unless (gnus-request-group group t)
4638 (when (equal major-mode 'gnus-summary-mode)
4639 (kill-buffer (current-buffer)))
4640 (error "Couldn't request group %s: %s"
4641 group (gnus-status-message group)))
4643 (setq gnus-newsgroup-name group
4644 gnus-newsgroup-unselected nil
4645 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4647 (let ((display (gnus-group-find-parameter group 'display)))
4648 (setq gnus-newsgroup-display
4650 ((not (zerop (or (car-safe read-all) 0)))
4651 ;; The user entered the group with C-u SPC/RET, let's show
4657 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4659 ;; The following is probably the "correct" solution, but
4660 ;; it makes Gnus fetch all headers and then limit the
4661 ;; articles (which is slow), so instead we hack the
4662 ;; select-articles parameter instead. -- Simon Josefsson
4665 ;; (gnus-byte-compile
4666 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4668 (setq select-articles
4669 (gnus-uncompress-range
4670 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4674 (cdr (gnus-active group)))))
4679 (gnus-summary-setup-default-charset)
4681 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4682 (when (gnus-virtual-group-p group)
4683 (setq cached gnus-newsgroup-cached))
4685 (setq gnus-newsgroup-unreads
4686 (gnus-set-difference
4687 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4688 gnus-newsgroup-dormant))
4690 (setq gnus-newsgroup-processable nil)
4692 (gnus-update-read-articles group gnus-newsgroup-unreads)
4694 ;; Adjust and set lists of article marks.
4696 (gnus-adjust-marked-articles info))
4698 (if (setq articles select-articles)
4699 (setq gnus-newsgroup-unselected
4700 (gnus-sorted-intersection
4701 gnus-newsgroup-unreads
4702 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4703 (setq articles (gnus-articles-to-read group read-all)))
4707 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4709 ((eq articles 0) nil)
4711 ;; Init the dependencies hash table.
4712 (setq gnus-newsgroup-dependencies
4713 (gnus-make-hashtable (length articles)))
4714 (gnus-set-global-variables)
4715 ;; Retrieve the headers and read them in.
4716 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4718 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4720 (setq gnus-newsgroup-cached cached))
4722 ;; Suppress duplicates?
4723 (when gnus-suppress-duplicates
4724 (gnus-dup-suppress-articles))
4726 ;; Set the initial limit.
4727 (setq gnus-newsgroup-limit (copy-sequence articles))
4728 ;; Remove canceled articles from the list of unread articles.
4729 (setq fetched-articles
4730 (mapcar (lambda (headers) (mail-header-number headers))
4731 gnus-newsgroup-headers))
4732 (setq gnus-newsgroup-articles fetched-articles)
4733 (setq gnus-newsgroup-unreads
4734 (gnus-set-sorted-intersection
4735 gnus-newsgroup-unreads fetched-articles))
4737 ;; The `seen' marks are treated specially.
4738 (if (not gnus-newsgroup-seen)
4739 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4740 (dolist (article gnus-newsgroup-articles)
4741 (unless (gnus-member-of-range article gnus-newsgroup-seen)
4742 (push article gnus-newsgroup-unseen)))
4743 (setq gnus-newsgroup-unseen (nreverse gnus-newsgroup-unseen)))
4745 ;; Removed marked articles that do not exist.
4746 (gnus-update-missing-marks
4747 (gnus-sorted-complement fetched-articles articles))
4748 ;; We might want to build some more threads first.
4749 (when (and gnus-fetch-old-headers
4750 (eq gnus-headers-retrieved-by 'nov))
4751 (if (eq gnus-fetch-old-headers 'invisible)
4752 (gnus-build-all-threads)
4753 (gnus-build-old-threads)))
4754 ;; Let the Gnus agent mark articles as read.
4756 (gnus-agent-get-undownloaded-list))
4757 ;; Remove list identifiers from subject
4758 (when gnus-list-identifiers
4759 (gnus-summary-remove-list-identifiers))
4760 ;; Check whether auto-expire is to be done in this group.
4761 (setq gnus-newsgroup-auto-expire
4762 (gnus-group-auto-expirable-p group))
4763 ;; Set up the article buffer now, if necessary.
4764 (unless gnus-single-article-buffer
4765 (gnus-article-setup-buffer))
4766 ;; First and last article in this newsgroup.
4767 (when gnus-newsgroup-headers
4768 (setq gnus-newsgroup-begin
4769 (mail-header-number (car gnus-newsgroup-headers))
4772 (gnus-last-element gnus-newsgroup-headers))))
4773 ;; GROUP is successfully selected.
4774 (or gnus-newsgroup-headers t)))))
4776 (defun gnus-summary-display-make-predicate (display)
4777 (require 'gnus-agent)
4778 (when (= (length display) 1)
4779 (setq display (car display)))
4780 (unless gnus-summary-display-cache
4781 (dolist (elem (append (list (cons 'read 'read)
4782 (cons 'unseen 'unseen))
4783 gnus-article-mark-lists))
4784 (push (cons (cdr elem)
4786 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4787 gnus-summary-display-cache)))
4788 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4789 (gnus-get-predicate display)))
4791 ;; Uses the dynamically bound `number' variable.
4793 (defun gnus-article-marked-p (type &optional article)
4794 (let ((article (or article number)))
4797 (memq article gnus-newsgroup-marked))
4799 (memq article gnus-newsgroup-unsendable))
4800 ((eq type 'undownload)
4801 (memq article gnus-newsgroup-undownloaded))
4802 ((eq type 'download)
4803 (memq article gnus-newsgroup-downloadable))
4805 (memq article gnus-newsgroup-unreads))
4807 (memq article gnus-newsgroup-reads))
4809 (memq article gnus-newsgroup-dormant) )
4811 (memq article gnus-newsgroup-expirable))
4813 (memq article gnus-newsgroup-replied))
4815 (memq article gnus-newsgroup-killed))
4816 ((eq type 'bookmark)
4817 (assq article gnus-newsgroup-bookmarks))
4819 (assq article gnus-newsgroup-scored))
4821 (memq article gnus-newsgroup-saved))
4823 (memq article gnus-newsgroup-cached))
4825 (memq article gnus-newsgroup-forwarded))
4827 (not (memq article gnus-newsgroup-unseen)))
4829 (memq article gnus-newsgroup-recent))
4832 (defun gnus-articles-to-read (group &optional read-all)
4833 "Find out what articles the user wants to read."
4835 ;; Select all articles if `read-all' is non-nil, or if there
4836 ;; are no unread articles.
4838 (and (zerop (length gnus-newsgroup-marked))
4839 (zerop (length gnus-newsgroup-unreads)))
4840 (eq gnus-newsgroup-display 'gnus-not-ignore))
4841 ;; We want to select the headers for all the articles in
4842 ;; the group, so we select either all the active
4843 ;; articles in the group, or (if that's nil), the
4844 ;; articles in the cache.
4846 (gnus-uncompress-range (gnus-active group))
4847 (gnus-cache-articles-in-group group))
4848 ;; Select only the "normal" subset of articles.
4849 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4850 (copy-sequence gnus-newsgroup-unreads))
4852 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4853 (scored (length scored-list))
4854 (number (length articles))
4855 (marked (+ (length gnus-newsgroup-marked)
4856 (length gnus-newsgroup-dormant)))
4864 ((and (or (<= scored marked) (= scored number))
4865 (numberp gnus-large-newsgroup)
4866 (> number gnus-large-newsgroup))
4870 "How many articles from %s (default %d): "
4872 (gnus-group-decoded-name gnus-newsgroup-name)
4875 (if (string-match "^[ \t]*$" input) number input)))
4876 ((and (> scored marked) (< scored number)
4877 (> (- scored number) 20))
4880 (format "%s %s (%d scored, %d total): "
4881 "How many articles from"
4882 (gnus-group-decoded-name group)
4884 (if (string-match "^[ \t]*$" input)
4888 (message "Quit getting the articles to read")
4890 (setq select (if (stringp select) (string-to-number select) select))
4891 (if (or (null select) (zerop select))
4893 (if (and (not (zerop scored)) (<= (abs select) scored))
4895 (setq articles (sort scored-list '<))
4896 (setq number (length articles)))
4897 (setq articles (copy-sequence articles)))
4899 (when (< (abs select) number)
4901 ;; Select the N oldest articles.
4902 (setcdr (nthcdr (1- (abs select)) articles) nil)
4903 ;; Select the N most recent articles.
4904 (setq articles (nthcdr (- number select) articles))))
4905 (setq gnus-newsgroup-unselected
4906 (gnus-sorted-intersection
4907 gnus-newsgroup-unreads
4908 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4909 (when gnus-alter-articles-to-read-function
4910 (setq gnus-newsgroup-unreads
4912 (funcall gnus-alter-articles-to-read-function
4913 gnus-newsgroup-name gnus-newsgroup-unreads)
4917 (defun gnus-killed-articles (killed articles)
4920 (when (inline (gnus-member-of-range (car articles) killed))
4921 (push (car articles) out))
4922 (setq articles (cdr articles)))
4925 (defun gnus-uncompress-marks (marks)
4926 "Uncompress the mark ranges in MARKS."
4927 (let ((uncompressed '(score bookmark))
4930 (if (memq (caar marks) uncompressed)
4931 (push (car marks) out)
4932 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4933 (setq marks (cdr marks)))
4936 (defun gnus-article-mark-to-type (mark)
4937 "Return the type of MARK."
4938 (or (cadr (assq mark gnus-article-special-mark-lists))
4941 (defun gnus-article-unpropagatable-p (mark)
4942 "Return whether MARK should be propagated to backend."
4943 (memq mark gnus-article-unpropagated-mark-lists))
4945 (defun gnus-adjust-marked-articles (info)
4946 "Set all article lists and remove all marks that are no longer valid."
4947 (let* ((marked-lists (gnus-info-marks info))
4948 (active (gnus-active (gnus-info-group info)))
4951 (types gnus-article-mark-lists)
4952 marks var articles article mark mark-type)
4954 (dolist (marks marked-lists)
4955 (setq mark (car marks)
4956 mark-type (gnus-article-mark-to-type mark)
4957 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4959 ;; We set the variable according to the type of the marks list,
4960 ;; and then adjust the marks to a subset of the active articles.
4962 ;; Adjust "simple" lists.
4963 ((eq mark-type 'list)
4964 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4965 (when (memq mark '(tick dormant expire reply save))
4967 (when (or (< (setq article (pop articles)) min) (> article max))
4968 (set var (delq article (symbol-value var)))))))
4970 ((eq mark-type 'tuple)
4971 (set var (setq articles (cdr marks)))
4972 (when (not (listp (cdr (symbol-value var))))
4973 (set var (list (symbol-value var))))
4974 (when (not (listp (cdr articles)))
4975 (setq articles (list articles)))
4977 (when (or (not (consp (setq article (pop articles))))
4978 (< (car article) min)
4979 (> (car article) max))
4980 (set var (delq article (symbol-value var))))))
4981 ;; Adjust ranges (sloppily).
4982 ((eq mark-type 'range)
4985 (setq articles (cdr marks))
4986 (while (and articles
4987 (or (and (consp (car articles))
4988 (> min (cdar articles)))
4989 (and (numberp (car articles))
4990 (> min (car articles)))))
4992 (set var articles))))))))
4994 (defun gnus-update-missing-marks (missing)
4995 "Go through the list of MISSING articles and remove them from the mark lists."
4998 ;; Go through all types.
4999 (dolist (elem gnus-article-mark-lists)
5000 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5001 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5002 (when (symbol-value var)
5003 ;; This list has articles. So we delete all missing
5004 ;; articles from it.
5007 (set var (delq (pop m) (symbol-value var))))))))))
5009 (defun gnus-update-marks ()
5010 "Enter the various lists of marked articles into the newsgroup info list."
5011 (let ((types gnus-article-mark-lists)
5012 (info (gnus-get-info gnus-newsgroup-name))
5013 type list newmarked symbol delta-marks)
5015 ;; Add all marks lists to the list of marks lists.
5016 (while (setq type (pop types))
5017 (setq list (symbol-value
5019 (intern (format "gnus-newsgroup-%s" (car type))))))
5022 ;; Get rid of the entries of the articles that have the
5024 (when (and (eq (cdr type) 'score)
5028 (prev (cons nil list))
5031 (if (or (not (consp (car arts)))
5032 (= (cdar arts) gnus-summary-default-score))
5033 (setcdr prev (cdr arts))
5035 (setq arts (cdr arts)))
5036 (setq list (cdr all)))))
5038 (when (eq (cdr type) 'seen)
5039 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5041 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5042 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5044 (when (and (gnus-check-backend-function
5045 'request-set-mark gnus-newsgroup-name)
5046 (not (gnus-article-unpropagatable-p (cdr type))))
5047 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5048 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5049 (add (gnus-remove-from-range
5050 (gnus-copy-sequence list) old)))
5052 (push (list add 'add (list (cdr type))) delta-marks))
5054 (push (list del 'del (list (cdr type))) delta-marks))))
5057 (push (cons (cdr type) list) newmarked)))
5060 (unless (gnus-check-group gnus-newsgroup-name)
5061 (error "Can't open server for %s" gnus-newsgroup-name))
5062 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5064 ;; Enter these new marks into the info of the group.
5066 (setcar (nthcdr 3 info) newmarked)
5067 ;; Add the marks lists to the end of the info.
5069 (setcdr (nthcdr 2 info) (list newmarked))))
5071 ;; Cut off the end of the info if there's nothing else there.
5075 (when (nthcdr (decf i) info)
5076 (setcdr (nthcdr i info) nil)))))))
5078 (defun gnus-set-mode-line (where)
5079 "Set the mode line of the article or summary buffers.
5080 If WHERE is `summary', the summary mode line format will be used."
5081 ;; Is this mode line one we keep updated?
5082 (when (and (memq where gnus-updated-mode-lines)
5084 (intern (format "gnus-%s-mode-line-format-spec" where))))
5087 ;; We evaluate this in the summary buffer since these
5088 ;; variables are buffer-local to that buffer.
5089 (set-buffer gnus-summary-buffer)
5090 ;; We bind all these variables that are used in the `eval' form
5092 (let* ((mformat (symbol-value
5094 (format "gnus-%s-mode-line-format-spec" where))))
5095 (gnus-tmp-group-name (gnus-group-decoded-name
5096 gnus-newsgroup-name))
5097 (gnus-tmp-article-number (or gnus-current-article 0))
5098 (gnus-tmp-unread gnus-newsgroup-unreads)
5099 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5100 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5101 (gnus-tmp-unread-and-unselected
5102 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5103 (zerop gnus-tmp-unselected))
5105 ((zerop gnus-tmp-unselected)
5106 (format "{%d more}" gnus-tmp-unread-and-unticked))
5107 (t (format "{%d(+%d) more}"
5108 gnus-tmp-unread-and-unticked
5109 gnus-tmp-unselected))))
5111 (if (and gnus-current-headers
5112 (vectorp gnus-current-headers))
5113 (gnus-mode-string-quote
5114 (mail-header-subject gnus-current-headers))
5116 bufname-length max-len
5117 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5118 (setq mode-string (eval mformat))
5119 (setq bufname-length (if (string-match "%b" mode-string)
5122 (if (eq where 'summary)
5124 (get-buffer gnus-article-buffer))))
5127 (setq max-len (max 4 (if gnus-mode-non-string-length
5129 gnus-mode-non-string-length
5131 (length mode-string))))
5132 ;; We might have to chop a bit of the string off...
5133 (when (> (length mode-string) max-len)
5135 (concat (truncate-string-to-width mode-string (- max-len 3))
5137 ;; Pad the mode string a bit.
5138 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5139 ;; Update the mode line.
5140 (setq mode-line-buffer-identification
5141 (gnus-mode-line-buffer-identification (list mode-string)))
5142 (set-buffer-modified-p t))))
5144 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5145 "Go through the HEADERS list and add all Xrefs to a hash table.
5146 The resulting hash table is returned, or nil if no Xrefs were found."
5147 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5148 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5149 (xref-hashtb (gnus-make-hashtable))
5150 start group entry number xrefs header)
5152 (setq header (pop headers))
5153 (when (and (setq xrefs (mail-header-xref header))
5154 (not (memq (setq number (mail-header-number header))
5157 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5158 (setq start (match-end 0))
5159 (setq group (if prefix
5160 (concat prefix (substring xrefs (match-beginning 1)
5162 (substring xrefs (match-beginning 1) (match-end 1))))
5164 (string-to-int (substring xrefs (match-beginning 2)
5166 (if (setq entry (gnus-gethash group xref-hashtb))
5167 (setcdr entry (cons number (cdr entry)))
5168 (gnus-sethash group (cons number nil) xref-hashtb)))))
5169 (and start xref-hashtb)))
5171 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5172 "Look through all the headers and mark the Xrefs as read."
5173 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5174 name entry info xref-hashtb idlist method nth4)
5176 (set-buffer gnus-group-buffer)
5177 (when (setq xref-hashtb
5178 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5181 (unless (string= from-newsgroup (setq name (symbol-name group)))
5182 (setq idlist (symbol-value group))
5183 ;; Dead groups are not updated.
5185 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5187 (when (stringp (setq nth4 (gnus-info-method info)))
5188 (setq nth4 (gnus-server-to-method nth4))))
5189 ;; Only do the xrefs if the group has the same
5190 ;; select method as the group we have just read.
5191 (or (gnus-methods-equal-p
5192 nth4 (gnus-find-method-for-group from-newsgroup))
5194 (equal nth4 (setq method (gnus-find-method-for-group
5196 (and (equal (car nth4) (car method))
5197 (equal (nth 1 nth4) (nth 1 method))))
5198 gnus-use-cross-reference
5199 (or (not (eq gnus-use-cross-reference t))
5201 ;; Only do cross-references on subscribed
5202 ;; groups, if that is what is wanted.
5203 (<= (gnus-info-level info) gnus-level-subscribed))
5204 (gnus-group-make-articles-read name idlist))))
5207 (defun gnus-compute-read-articles (group articles)
5208 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5209 (info (nth 2 entry))
5210 (active (gnus-active group))
5213 ;; First peel off all invalid article numbers.
5215 (let ((ids articles)
5217 (while (setq id (pop ids))
5218 (when (and first (> id (cdr active)))
5219 ;; We'll end up in this situation in one particular
5220 ;; obscure situation. If you re-scan a group and get
5221 ;; a new article that is cross-posted to a different
5222 ;; group that has not been re-scanned, you might get
5223 ;; crossposted article that has a higher number than
5224 ;; Gnus believes possible. So we re-activate this
5225 ;; group as well. This might mean doing the
5226 ;; crossposting thingy will *increase* the number
5227 ;; of articles in some groups. Tsk, tsk.
5228 (setq active (or (gnus-activate-group group) active)))
5229 (when (or (> id (cdr active))
5230 (< id (car active)))
5231 (setq articles (delq id articles))))))
5232 ;; If the read list is nil, we init it.
5234 (null (gnus-info-read info))
5236 (setq ninfo (cons 1 (1- (car active))))
5237 (setq ninfo (gnus-info-read info)))
5238 ;; Then we add the read articles to the range.
5240 ninfo (setq articles (sort articles '<))))))
5242 (defun gnus-group-make-articles-read (group articles)
5243 "Update the info of GROUP to say that ARTICLES are read."
5245 (entry (gnus-gethash group gnus-newsrc-hashtb))
5246 (info (nth 2 entry))
5247 (active (gnus-active group))
5250 (setq range (gnus-compute-read-articles group articles))
5252 (set-buffer gnus-group-buffer)
5255 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5256 (gnus-info-set-read ',info ',(gnus-info-read info))
5257 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5258 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5259 (gnus-group-update-group ,group t))))
5260 ;; Add the read articles to the range.
5261 (gnus-info-set-read info range)
5262 (gnus-request-set-mark group (list (list range 'add '(read))))
5263 ;; Then we have to re-compute how many unread
5264 ;; articles there are in this group.
5268 (setq num (- (1+ (cdr active)) (car active))))
5269 ((not (listp (cdr range)))
5270 (setq num (- (cdr active) (- (1+ (cdr range))
5274 (if (numberp (car range))
5276 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5277 (setq range (cdr range)))
5278 (setq num (- (cdr active) num))))
5279 ;; Update the number of unread articles.
5281 ;; Update the group buffer.
5282 (gnus-group-update-group group t)))))
5284 (defvar gnus-newsgroup-none-id 0)
5286 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5287 (let ((cur nntp-server-buffer)
5290 (save-excursion (set-buffer gnus-summary-buffer)
5291 gnus-newsgroup-dependencies)))
5293 (mail-parse-charset gnus-newsgroup-charset)
5294 (mail-parse-ignored-charsets
5295 (save-excursion (condition-case nil
5296 (set-buffer gnus-summary-buffer)
5298 gnus-newsgroup-ignored-charsets)))
5300 (set-buffer nntp-server-buffer)
5301 ;; Translate all TAB characters into SPACE characters.
5302 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5303 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5304 (gnus-run-hooks 'gnus-parse-headers-hook)
5305 (let ((case-fold-search t)
5306 in-reply-to header p lines chars)
5307 (goto-char (point-min))
5308 ;; Search to the beginning of the next header. Error messages
5309 ;; do not begin with 2 or 3.
5310 (while (re-search-forward "^[23][0-9]+ " nil t)
5313 ;; This implementation of this function, with nine
5314 ;; search-forwards instead of the one re-search-forward and
5315 ;; a case (which basically was the old function) is actually
5316 ;; about twice as fast, even though it looks messier. You
5317 ;; can't have everything, I guess. Speed and elegance
5318 ;; doesn't always go hand in hand.
5327 (narrow-to-region (point)
5328 (or (and (search-forward "\n.\n" nil t)
5334 (if (search-forward "\nsubject:" nil t)
5335 (funcall gnus-decode-encoded-word-function
5336 (nnheader-header-value))
5341 (if (search-forward "\nfrom:" nil t)
5342 (funcall gnus-decode-encoded-word-function
5343 (nnheader-header-value))
5348 (if (search-forward "\ndate:" nil t)
5349 (nnheader-header-value) ""))
5353 (setq id (if (re-search-forward
5354 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5355 ;; We do it this way to make sure the Message-ID
5356 ;; is (somewhat) syntactically valid.
5357 (buffer-substring (match-beginning 1)
5359 ;; If there was no message-id, we just fake one
5360 ;; to make subsequent routines simpler.
5361 (nnheader-generate-fake-message-id))))
5365 (if (search-forward "\nreferences:" nil t)
5369 (nnheader-header-value)
5374 (search-backward ">" end t)
5377 (search-backward "<" end t)
5379 ;; Get the references from the in-reply-to header if there
5380 ;; were no references and the in-reply-to header looks
5382 (if (and (search-forward "\nin-reply-to:" nil t)
5383 (setq in-reply-to (nnheader-header-value))
5384 (string-match "<[^>]+>" in-reply-to))
5386 (setq ref (substring in-reply-to (match-beginning 0)
5388 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5389 (setq ref2 (substring in-reply-to (match-beginning 0)
5391 (when (> (length ref2) (length ref))
5398 (if (search-forward "\nchars: " nil t)
5399 (if (numberp (setq chars (ignore-errors (read cur))))
5405 (if (search-forward "\nlines: " nil t)
5406 (if (numberp (setq lines (ignore-errors (read cur))))
5412 (and (search-forward "\nxref:" nil t)
5413 (nnheader-header-value)))
5415 (when gnus-extra-headers
5416 (let ((extra gnus-extra-headers)
5420 (when (search-forward
5421 (concat "\n" (symbol-name (car extra)) ":") nil t)
5422 (push (cons (car extra) (nnheader-header-value))
5426 (when (equal id ref)
5429 (when gnus-alter-header-function
5430 (funcall gnus-alter-header-function header)
5431 (setq id (mail-header-id header)
5432 ref (gnus-parent-id (mail-header-references header))))
5435 (gnus-dependencies-add-header
5436 header dependencies force-new))
5437 (push header headers))
5438 (goto-char (point-max))
5440 (nreverse headers)))))
5442 ;; Goes through the xover lines and returns a list of vectors
5443 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5444 force-new dependencies
5445 group also-fetch-heads)
5446 "Parse the news overview data in the server buffer.
5447 Return a list of headers that match SEQUENCE (see
5448 `nntp-retrieve-headers')."
5449 ;; Get the Xref when the users reads the articles since most/some
5450 ;; NNTP servers do not include Xrefs when using XOVER.
5451 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5452 (let ((mail-parse-charset gnus-newsgroup-charset)
5453 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5454 (cur nntp-server-buffer)
5455 (dependencies (or dependencies gnus-newsgroup-dependencies))
5457 ((eq gnus-read-all-available-headers t)
5459 ((stringp gnus-read-all-available-headers)
5460 (string-match gnus-read-all-available-headers group))
5463 number headers header)
5465 (set-buffer nntp-server-buffer)
5466 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5467 ;; Allow the user to mangle the headers before parsing them.
5468 (gnus-run-hooks 'gnus-parse-headers-hook)
5469 (goto-char (point-min))
5472 (while (and (or sequence allp)
5474 (setq number (read cur))
5476 (while (and sequence
5477 (< (car sequence) number))
5478 (setq sequence (cdr sequence))))
5481 (eq number (car sequence))))
5483 (setq sequence (cdr sequence))
5484 (setq header (inline
5485 (gnus-nov-parse-line
5486 number dependencies force-new)))))
5487 (push header headers))
5490 (gnus-error 4 "Strange nov line (%d)"
5491 (count-lines (point-min) (point)))))
5493 ;; A common bug in inn is that if you have posted an article and
5494 ;; then retrieves the active file, it will answer correctly --
5495 ;; the new article is included. However, a NOV entry for the
5496 ;; article may not have been generated yet, so this may fail.
5497 ;; We work around this problem by retrieving the last few
5498 ;; headers using HEAD.
5499 (if (or (not also-fetch-heads)
5501 ;; We (probably) got all the headers.
5503 (let ((gnus-nov-is-evil t))
5506 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5507 (gnus-get-newsgroup-headers))))))))
5509 (defun gnus-article-get-xrefs ()
5510 "Fill in the Xref value in `gnus-current-headers', if necessary.
5511 This is meant to be called in `gnus-article-internal-prepare-hook'."
5512 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5513 gnus-current-headers)))
5514 (or (not gnus-use-cross-reference)
5516 (and (mail-header-xref headers)
5517 (not (string= (mail-header-xref headers) "")))
5518 (let ((case-fold-search t)
5521 (nnheader-narrow-to-headers)
5522 (goto-char (point-min))
5523 (when (or (and (not (eobp))
5524 (eq (downcase (char-after)) ?x)
5525 (looking-at "Xref:"))
5526 (search-forward "\nXref:" nil t))
5527 (goto-char (1+ (match-end 0)))
5528 (setq xref (buffer-substring (point)
5529 (progn (end-of-line) (point))))
5530 (mail-header-set-xref headers xref)))))))
5532 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5533 "Find article ID and insert the summary line for that article.
5534 OLD-HEADER can either be a header or a line number to insert
5535 the subject line on."
5536 (let* ((line (and (numberp old-header) old-header))
5537 (old-header (and (vectorp old-header) old-header))
5538 (header (cond ((and old-header use-old-header)
5541 (gnus-number-to-header id))
5542 (gnus-number-to-header id))
5544 (gnus-read-header id))))
5545 (number (and (numberp id) id))
5548 ;; Rebuild the thread that this article is part of and go to the
5549 ;; article we have fetched.
5550 (when (and (not gnus-show-threads)
5553 (setq d (gnus-data-find (mail-header-number old-header))))
5554 (goto-char (gnus-data-pos d))
5557 (- (gnus-point-at-bol)
5559 (1+ (gnus-point-at-eol))
5560 (gnus-delete-line))))))
5562 (mail-header-set-number header (mail-header-number old-header)))
5563 (setq gnus-newsgroup-sparse
5564 (delq (setq number (mail-header-number header))
5565 gnus-newsgroup-sparse))
5566 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5567 (push number gnus-newsgroup-limit)
5568 (gnus-rebuild-thread (mail-header-id header) line)
5569 (gnus-summary-goto-subject number nil t))
5570 (when (and (numberp number)
5572 ;; We have to update the boundaries even if we can't fetch the
5573 ;; article if ID is a number -- so that the next `P' or `N'
5574 ;; command will fetch the previous (or next) article even
5575 ;; if the one we tried to fetch this time has been canceled.
5576 (when (> number gnus-newsgroup-end)
5577 (setq gnus-newsgroup-end number))
5578 (when (< number gnus-newsgroup-begin)
5579 (setq gnus-newsgroup-begin number))
5580 (setq gnus-newsgroup-unselected
5581 (delq number gnus-newsgroup-unselected)))
5582 ;; Report back a success?
5583 (and header (mail-header-number header))))
5585 ;;; Process/prefix in the summary buffer
5587 (defun gnus-summary-work-articles (n)
5588 "Return a list of articles to be worked upon.
5589 The prefix argument, the list of process marked articles, and the
5590 current article will be taken into consideration."
5592 (set-buffer gnus-summary-buffer)
5595 ;; A numerical prefix has been given.
5596 (setq n (prefix-numeric-value n))
5597 (let ((backward (< n 0))
5598 (n (abs (prefix-numeric-value n)))
5603 (push (setq article (gnus-summary-article-number))
5606 (gnus-summary-find-prev nil article)
5607 (gnus-summary-find-next nil article)))
5609 (nreverse articles)))
5610 ((and (gnus-region-active-p) (mark))
5611 (message "region active")
5612 ;; Work on the region between point and mark.
5613 (let ((max (max (point) (mark)))
5616 (goto-char (min (min (point) (mark))))
5619 (push (setq article (gnus-summary-article-number)) articles)
5620 (gnus-summary-find-next nil article)
5622 (nreverse articles))))
5623 (gnus-newsgroup-processable
5624 ;; There are process-marked articles present.
5625 ;; Save current state.
5626 (gnus-summary-save-process-mark)
5628 (reverse gnus-newsgroup-processable))
5630 ;; Just return the current article.
5631 (list (gnus-summary-article-number))))))
5633 (defmacro gnus-summary-iterate (arg &rest forms)
5634 "Iterate over the process/prefixed articles and do FORMS.
5635 ARG is the interactive prefix given to the command. FORMS will be
5636 executed with point over the summary line of the articles."
5637 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5638 `(let ((,articles (gnus-summary-work-articles ,arg)))
5640 (gnus-summary-goto-subject (car ,articles))
5644 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5645 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5647 (defun gnus-summary-save-process-mark ()
5648 "Push the current set of process marked articles on the stack."
5650 (push (copy-sequence gnus-newsgroup-processable)
5651 gnus-newsgroup-process-stack))
5653 (defun gnus-summary-kill-process-mark ()
5654 "Push the current set of process marked articles on the stack and unmark."
5656 (gnus-summary-save-process-mark)
5657 (gnus-summary-unmark-all-processable))
5659 (defun gnus-summary-yank-process-mark ()
5660 "Pop the last process mark state off the stack and restore it."
5662 (unless gnus-newsgroup-process-stack
5663 (error "Empty mark stack"))
5664 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5666 (defun gnus-summary-process-mark-set (set)
5667 "Make SET into the current process marked articles."
5668 (gnus-summary-unmark-all-processable)
5670 (gnus-summary-set-process-mark (pop set))))
5672 ;;; Searching and stuff
5674 (defun gnus-summary-search-group (&optional backward use-level)
5675 "Search for next unread newsgroup.
5676 If optional argument BACKWARD is non-nil, search backward instead."
5678 (set-buffer gnus-group-buffer)
5679 (when (gnus-group-search-forward
5680 backward nil (if use-level (gnus-group-group-level) nil))
5681 (gnus-group-group-name))))
5683 (defun gnus-summary-best-group (&optional exclude-group)
5684 "Find the name of the best unread group.
5685 If EXCLUDE-GROUP, do not go to this group."
5687 (set-buffer gnus-group-buffer)
5689 (gnus-group-best-unread-group exclude-group))))
5691 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5692 (if backward (gnus-summary-find-prev)
5693 (let* ((dummy (gnus-summary-article-intangible-p))
5694 (article (or article (gnus-summary-article-number)))
5695 (arts (gnus-data-find-list article))
5697 (when (and (not dummy)
5698 (or (not gnus-summary-check-current)
5700 (not (gnus-data-unread-p (car arts)))))
5701 (setq arts (cdr arts)))
5706 (when (or (and undownloaded
5707 (eq gnus-undownloaded-mark
5708 (gnus-data-mark (car arts))))
5709 (gnus-data-unread-p (car arts)))
5710 (setq result (car arts)
5712 (setq arts (cdr arts)))
5715 (goto-char (gnus-data-pos result))
5716 (gnus-data-number result)))))
5718 (defun gnus-summary-find-prev (&optional unread article)
5719 (let* ((eobp (eobp))
5720 (article (or article (gnus-summary-article-number)))
5721 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5723 (when (and (not eobp)
5724 (or (not gnus-summary-check-current)
5726 (not (gnus-data-unread-p (car arts)))))
5727 (setq arts (cdr arts)))
5732 (when (gnus-data-unread-p (car arts))
5733 (setq result (car arts)
5735 (setq arts (cdr arts)))
5738 (goto-char (gnus-data-pos result))
5739 (gnus-data-number result))))
5741 (defun gnus-summary-find-subject (subject &optional unread backward article)
5742 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5743 (article (or article (gnus-summary-article-number)))
5744 (articles (gnus-data-list backward))
5745 (arts (gnus-data-find-list article articles))
5747 (when (or (not gnus-summary-check-current)
5749 (not (gnus-data-unread-p (car arts))))
5750 (setq arts (cdr arts)))
5752 (and (or (not unread)
5753 (gnus-data-unread-p (car arts)))
5754 (vectorp (gnus-data-header (car arts)))
5756 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5757 (setq result (car arts)
5759 (setq arts (cdr arts)))
5761 (goto-char (gnus-data-pos result))
5762 (gnus-data-number result))))
5764 (defun gnus-summary-search-forward (&optional unread subject backward)
5765 "Search forward for an article.
5766 If UNREAD, look for unread articles. If SUBJECT, look for
5767 articles with that subject. If BACKWARD, search backward instead."
5768 (cond (subject (gnus-summary-find-subject subject unread backward))
5769 (backward (gnus-summary-find-prev unread))
5770 (t (gnus-summary-find-next unread))))
5772 (defun gnus-recenter (&optional n)
5773 "Center point in window and redisplay frame.
5774 Also do horizontal recentering."
5776 (when (and gnus-auto-center-summary
5777 (not (eq gnus-auto-center-summary 'vertical)))
5778 (gnus-horizontal-recenter))
5781 (defun gnus-summary-recenter ()
5782 "Center point in the summary window.
5783 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5784 displayed, no centering will be performed."
5785 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5786 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5788 (let* ((top (cond ((< (window-height) 4) 0)
5789 ((< (window-height) 7) 1)
5790 (t (if (numberp gnus-auto-center-summary)
5791 gnus-auto-center-summary
5793 (height (1- (window-height)))
5794 (bottom (save-excursion (goto-char (point-max))
5795 (forward-line (- height))
5797 (window (get-buffer-window (current-buffer))))
5798 ;; The user has to want it.
5799 (when gnus-auto-center-summary
5800 (when (get-buffer-window gnus-article-buffer)
5801 ;; Only do recentering when the article buffer is displayed,
5802 ;; Set the window start to either `bottom', which is the biggest
5803 ;; possible valid number, or the second line from the top,
5804 ;; whichever is the least.
5805 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5806 (if (> bottom top-pos)
5807 ;; Keep the second line from the top visible
5808 (set-window-start window top-pos t)
5809 ;; Try to keep the bottom line visible; if it's partially
5810 ;; obscured, either scroll one more line to make it fully
5811 ;; visible, or revert to using TOP-POS.
5813 (goto-char (point-max))
5815 (let ((last-line-start (point)))
5817 (set-window-start window (point) t)
5818 (when (not (pos-visible-in-window-p last-line-start window))
5820 (set-window-start window (min (point) top-pos) t)))))))
5821 ;; Do horizontal recentering while we're at it.
5822 (when (and (get-buffer-window (current-buffer) t)
5823 (not (eq gnus-auto-center-summary 'vertical)))
5824 (let ((selected (selected-window)))
5825 (select-window (get-buffer-window (current-buffer) t))
5826 (gnus-summary-position-point)
5827 (gnus-horizontal-recenter)
5828 (select-window selected))))))
5830 (defun gnus-summary-jump-to-group (newsgroup)
5831 "Move point to NEWSGROUP in group mode buffer."
5832 ;; Keep update point of group mode buffer if visible.
5833 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5834 (save-window-excursion
5835 ;; Take care of tree window mode.
5836 (when (get-buffer-window gnus-group-buffer)
5837 (pop-to-buffer gnus-group-buffer))
5838 (gnus-group-jump-to-group newsgroup))
5840 ;; Take care of tree window mode.
5841 (if (get-buffer-window gnus-group-buffer)
5842 (pop-to-buffer gnus-group-buffer)
5843 (set-buffer gnus-group-buffer))
5844 (gnus-group-jump-to-group newsgroup))))
5846 ;; This function returns a list of article numbers based on the
5847 ;; difference between the ranges of read articles in this group and
5848 ;; the range of active articles.
5849 (defun gnus-list-of-unread-articles (group)
5850 (let* ((read (gnus-info-read (gnus-get-info group)))
5851 (active (or (gnus-active group) (gnus-activate-group group)))
5854 ;; If none are read, then all are unread.
5856 (setq first (car active))
5857 ;; If the range of read articles is a single range, then the
5858 ;; first unread article is the article after the last read
5859 ;; article. Sounds logical, doesn't it?
5860 (if (and (not (listp (cdr read)))
5861 (or (< (car read) (car active))
5862 (progn (setq read (list read))
5864 (setq first (max (car active) (1+ (cdr read))))
5865 ;; `read' is a list of ranges.
5866 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5869 (setq first (car active)))
5872 (while (< first nlast)
5874 (setq first (1+ first))))
5875 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5876 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5877 (setq read (cdr read)))))
5878 ;; And add the last unread articles.
5879 (while (<= first last)
5881 (setq first (1+ first)))
5882 ;; Return the list of unread articles.
5883 (delq 0 (nreverse unread))))
5885 (defun gnus-list-of-read-articles (group)
5886 "Return a list of unread, unticked and non-dormant articles."
5887 (let* ((info (gnus-get-info group))
5888 (marked (gnus-info-marks info))
5889 (active (gnus-active group)))
5891 (gnus-set-difference
5892 (gnus-sorted-complement
5893 (gnus-uncompress-range active)
5894 (gnus-list-of-unread-articles group))
5896 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5897 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5899 ;; Various summary commands
5901 (defun gnus-summary-select-article-buffer ()
5902 "Reconfigure windows to show article buffer."
5904 (if (not (gnus-buffer-live-p gnus-article-buffer))
5905 (error "There is no article buffer for this summary buffer")
5906 (gnus-configure-windows 'article)
5907 (select-window (get-buffer-window gnus-article-buffer))))
5909 (defun gnus-summary-universal-argument (arg)
5910 "Perform any operation on all articles that are process/prefixed."
5912 (let ((articles (gnus-summary-work-articles arg))
5919 (substitute-command-keys
5920 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5922 (gnus-error 1 "Undefined key")
5925 (gnus-summary-goto-subject (setq article (pop articles)))
5926 (let (gnus-newsgroup-processable)
5927 (command-execute func))
5928 (gnus-summary-remove-process-mark article)))))
5929 (gnus-summary-position-point))
5931 (defun gnus-summary-toggle-truncation (&optional arg)
5932 "Toggle truncation of summary lines.
5933 With arg, turn line truncation on iff arg is positive."
5935 (setq truncate-lines
5936 (if (null arg) (not truncate-lines)
5937 (> (prefix-numeric-value arg) 0)))
5940 (defun gnus-summary-reselect-current-group (&optional all rescan)
5941 "Exit and then reselect the current newsgroup.
5942 The prefix argument ALL means to select all articles."
5944 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5945 (error "Ephemeral groups can't be reselected"))
5946 (let ((current-subject (gnus-summary-article-number))
5947 (group gnus-newsgroup-name))
5948 (setq gnus-newsgroup-begin nil)
5950 ;; We have to adjust the point of group mode buffer because
5951 ;; point was moved to the next unread newsgroup by exiting.
5952 (gnus-summary-jump-to-group group)
5955 (gnus-group-get-new-news-this-group 1)))
5956 (gnus-group-read-group all t)
5957 (gnus-summary-goto-subject current-subject nil t)))
5959 (defun gnus-summary-rescan-group (&optional all)
5960 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5962 (gnus-summary-reselect-current-group all t))
5964 (defun gnus-summary-update-info (&optional non-destructive)
5966 (let ((group gnus-newsgroup-name))
5968 (when gnus-newsgroup-kill-headers
5969 (setq gnus-newsgroup-killed
5970 (gnus-compress-sequence
5972 (gnus-set-sorted-intersection
5973 (gnus-uncompress-range gnus-newsgroup-killed)
5974 (setq gnus-newsgroup-unselected
5975 (sort gnus-newsgroup-unselected '<)))
5976 (setq gnus-newsgroup-unreads
5977 (sort gnus-newsgroup-unreads '<)))
5979 (unless (listp (cdr gnus-newsgroup-killed))
5980 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5981 (let ((headers gnus-newsgroup-headers))
5982 ;; Set the new ranges of read articles.
5984 (set-buffer gnus-group-buffer)
5985 (gnus-undo-force-boundary))
5986 (gnus-update-read-articles
5987 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5988 ;; Set the current article marks.
5989 (let ((gnus-newsgroup-scored
5990 (if (and (not gnus-save-score)
5991 (not non-destructive))
5993 gnus-newsgroup-scored)))
5995 (gnus-update-marks)))
5996 ;; Do the cross-ref thing.
5997 (when gnus-use-cross-reference
5998 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5999 ;; Do not switch windows but change the buffer to work.
6000 (set-buffer gnus-group-buffer)
6001 (unless (gnus-ephemeral-group-p group)
6002 (gnus-group-update-group group)))))))
6004 (defun gnus-summary-save-newsrc (&optional force)
6005 "Save the current number of read/marked articles in the dribble buffer.
6006 The dribble buffer will then be saved.
6007 If FORCE (the prefix), also save the .newsrc file(s)."
6009 (gnus-summary-update-info t)
6011 (gnus-save-newsrc-file)
6012 (gnus-dribble-save)))
6014 (defun gnus-summary-exit (&optional temporary)
6015 "Exit reading current newsgroup, and then return to group selection mode.
6016 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6018 (gnus-set-global-variables)
6019 (when (gnus-buffer-live-p gnus-article-buffer)
6021 (set-buffer gnus-article-buffer)
6022 (mm-destroy-parts gnus-article-mime-handles)
6023 ;; Set it to nil for safety reason.
6024 (setq gnus-article-mime-handle-alist nil)
6025 (setq gnus-article-mime-handles nil)))
6026 (gnus-kill-save-kill-buffer)
6027 (gnus-async-halt-prefetch)
6028 (let* ((group gnus-newsgroup-name)
6029 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6032 (buf (current-buffer)))
6034 ;; Do adaptive scoring, and possibly save score files.
6035 (when gnus-newsgroup-adaptive
6036 (gnus-score-adaptive))
6037 (when gnus-use-scoring
6039 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6040 ;; If we have several article buffers, we kill them at exit.
6041 (unless gnus-single-article-buffer
6042 (gnus-kill-buffer gnus-original-article-buffer)
6043 (setq gnus-article-current nil))
6044 (when gnus-use-cache
6045 (gnus-cache-possibly-remove-articles)
6046 (gnus-cache-save-buffers))
6047 (gnus-async-prefetch-remove-group group)
6048 (when gnus-suppress-duplicates
6049 (gnus-dup-enter-articles))
6050 (when gnus-use-trees
6051 (gnus-tree-close group))
6052 (when gnus-use-cache
6053 (gnus-cache-write-active))
6054 ;; Remove entries for this group.
6055 (nnmail-purge-split-history (gnus-group-real-name group))
6056 ;; Make all changes in this group permanent.
6058 (gnus-run-hooks 'gnus-exit-group-hook)
6059 (gnus-summary-update-info))
6060 (gnus-close-group group)
6061 ;; Make sure where we were, and go to next newsgroup.
6062 (set-buffer gnus-group-buffer)
6064 (gnus-group-jump-to-group group))
6065 (gnus-run-hooks 'gnus-summary-exit-hook)
6066 (unless (or quit-config
6067 ;; If this group has disappeared from the summary
6068 ;; buffer, don't skip forwards.
6069 (not (string= group (gnus-group-group-name))))
6070 (gnus-group-next-unread-group 1))
6071 (setq group-point (point))
6074 ;; If we have several article buffers, we kill them at exit.
6075 (unless gnus-single-article-buffer
6076 (gnus-kill-buffer gnus-article-buffer)
6077 (gnus-kill-buffer gnus-original-article-buffer)
6078 (setq gnus-article-current nil))
6080 (if (not gnus-kill-summary-on-exit)
6082 (gnus-deaden-summary)
6084 ;; We set all buffer-local variables to nil. It is unclear why
6085 ;; this is needed, but if we don't, buffer-local variables are
6086 ;; not garbage-collected, it seems. This would the lead to en
6087 ;; ever-growing Emacs.
6088 (gnus-summary-clear-local-variables)
6089 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6090 (gnus-summary-clear-local-variables))
6091 (when (get-buffer gnus-article-buffer)
6092 (bury-buffer gnus-article-buffer))
6093 ;; We clear the global counterparts of the buffer-local
6094 ;; variables as well, just to be on the safe side.
6095 (set-buffer gnus-group-buffer)
6096 (gnus-summary-clear-local-variables)
6097 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6098 (gnus-summary-clear-local-variables)))
6099 (setq gnus-current-select-method gnus-select-method)
6100 (pop-to-buffer gnus-group-buffer)
6101 (if (not quit-config)
6103 (goto-char group-point)
6104 (gnus-configure-windows 'group 'force))
6105 (gnus-handle-ephemeral-exit quit-config))
6106 ;; Return to group mode buffer.
6107 (when (eq mode 'gnus-summary-mode)
6108 (gnus-kill-buffer buf))
6109 ;; Clear the current group name.
6111 (setq gnus-newsgroup-name nil)))))
6113 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6114 (defun gnus-summary-exit-no-update (&optional no-questions)
6115 "Quit reading current newsgroup without updating read article info."
6117 (let* ((group gnus-newsgroup-name)
6118 (quit-config (gnus-group-quit-config group)))
6119 (when (or no-questions
6121 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6122 (gnus-async-halt-prefetch)
6124 (delq 'gnus-summary-expire-articles
6125 (copy-sequence gnus-summary-prepare-exit-hook)))
6126 (when (gnus-buffer-live-p gnus-article-buffer)
6128 (set-buffer gnus-article-buffer)
6129 (mm-destroy-parts gnus-article-mime-handles)
6130 ;; Set it to nil for safety reason.
6131 (setq gnus-article-mime-handle-alist nil)
6132 (setq gnus-article-mime-handles nil)))
6133 ;; If we have several article buffers, we kill them at exit.
6134 (unless gnus-single-article-buffer
6135 (gnus-kill-buffer gnus-article-buffer)
6136 (gnus-kill-buffer gnus-original-article-buffer)
6137 (setq gnus-article-current nil))
6138 (if (not gnus-kill-summary-on-exit)
6139 (gnus-deaden-summary)
6140 (gnus-close-group group)
6141 (gnus-summary-clear-local-variables)
6142 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6143 (gnus-summary-clear-local-variables))
6144 (set-buffer gnus-group-buffer)
6145 (gnus-summary-clear-local-variables)
6146 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6147 (gnus-summary-clear-local-variables))
6148 (when (get-buffer gnus-summary-buffer)
6149 (kill-buffer gnus-summary-buffer)))
6150 (unless gnus-single-article-buffer
6151 (setq gnus-article-current nil))
6152 (when gnus-use-trees
6153 (gnus-tree-close group))
6154 (gnus-async-prefetch-remove-group group)
6155 (when (get-buffer gnus-article-buffer)
6156 (bury-buffer gnus-article-buffer))
6157 ;; Return to the group buffer.
6158 (gnus-configure-windows 'group 'force)
6159 ;; Clear the current group name.
6160 (setq gnus-newsgroup-name nil)
6161 (when (equal (gnus-group-group-name) group)
6162 (gnus-group-next-unread-group 1))
6164 (gnus-handle-ephemeral-exit quit-config)))))
6166 (defun gnus-handle-ephemeral-exit (quit-config)
6167 "Handle movement when leaving an ephemeral group.
6168 The state which existed when entering the ephemeral is reset."
6169 (if (not (buffer-name (car quit-config)))
6170 (gnus-configure-windows 'group 'force)
6171 (set-buffer (car quit-config))
6172 (cond ((eq major-mode 'gnus-summary-mode)
6173 (gnus-set-global-variables))
6174 ((eq major-mode 'gnus-article-mode)
6176 ;; The `gnus-summary-buffer' variable may point
6177 ;; to the old summary buffer when using a single
6179 (unless (gnus-buffer-live-p gnus-summary-buffer)
6180 (set-buffer gnus-group-buffer))
6181 (set-buffer gnus-summary-buffer)
6182 (gnus-set-global-variables))))
6183 (if (or (eq (cdr quit-config) 'article)
6184 (eq (cdr quit-config) 'pick))
6186 ;; The current article may be from the ephemeral group
6187 ;; thus it is best that we reload this article
6188 (gnus-summary-show-article)
6189 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6190 (gnus-configure-windows 'pick 'force)
6191 (gnus-configure-windows (cdr quit-config) 'force)))
6192 (gnus-configure-windows (cdr quit-config) 'force))
6193 (when (eq major-mode 'gnus-summary-mode)
6194 (gnus-summary-next-subject 1 nil t)
6195 (gnus-summary-recenter)
6196 (gnus-summary-position-point))))
6200 (defvar gnus-dead-summary-mode-map nil)
6202 (unless gnus-dead-summary-mode-map
6203 (setq gnus-dead-summary-mode-map (make-keymap))
6204 (suppress-keymap gnus-dead-summary-mode-map)
6205 (substitute-key-definition
6206 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6207 (dolist (key '("\C-d" "\r" "\177" [delete]))
6208 (define-key gnus-dead-summary-mode-map
6209 key 'gnus-summary-wake-up-the-dead))
6210 (dolist (key '("q" "Q"))
6211 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6213 (defvar gnus-dead-summary-mode nil
6214 "Minor mode for Gnus summary buffers.")
6216 (defun gnus-dead-summary-mode (&optional arg)
6217 "Minor mode for Gnus summary buffers."
6219 (when (eq major-mode 'gnus-summary-mode)
6220 (make-local-variable 'gnus-dead-summary-mode)
6221 (setq gnus-dead-summary-mode
6222 (if (null arg) (not gnus-dead-summary-mode)
6223 (> (prefix-numeric-value arg) 0)))
6224 (when gnus-dead-summary-mode
6225 (gnus-add-minor-mode
6226 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6228 (defun gnus-deaden-summary ()
6229 "Make the current summary buffer into a dead summary buffer."
6230 ;; Kill any previous dead summary buffer.
6231 (when (and gnus-dead-summary
6232 (buffer-name gnus-dead-summary))
6234 (set-buffer gnus-dead-summary)
6235 (when gnus-dead-summary-mode
6236 (kill-buffer (current-buffer)))))
6237 ;; Make this the current dead summary.
6238 (setq gnus-dead-summary (current-buffer))
6239 (gnus-dead-summary-mode 1)
6240 (let ((name (buffer-name)))
6241 (when (string-match "Summary" name)
6243 (concat (substring name 0 (match-beginning 0)) "Dead "
6244 (substring name (match-beginning 0)))
6248 (defun gnus-kill-or-deaden-summary (buffer)
6249 "Kill or deaden the summary BUFFER."
6251 (when (and (buffer-name buffer)
6252 (not gnus-single-article-buffer))
6255 (gnus-kill-buffer gnus-article-buffer)
6256 (gnus-kill-buffer gnus-original-article-buffer)))
6259 (gnus-kill-summary-on-exit
6260 (when (and gnus-use-trees
6261 (gnus-buffer-exists-p buffer))
6264 (gnus-tree-close gnus-newsgroup-name)))
6265 (gnus-kill-buffer buffer))
6266 ;; Deaden the buffer.
6267 ((gnus-buffer-exists-p buffer)
6270 (gnus-deaden-summary))))))
6272 (defun gnus-summary-wake-up-the-dead (&rest args)
6273 "Wake up the dead summary buffer."
6275 (gnus-dead-summary-mode -1)
6276 (let ((name (buffer-name)))
6277 (when (string-match "Dead " name)
6279 (concat (substring name 0 (match-beginning 0))
6280 (substring name (match-end 0)))
6282 (gnus-message 3 "This dead summary is now alive again"))
6284 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6285 (defun gnus-summary-fetch-faq (&optional faq-dir)
6286 "Fetch the FAQ for the current group.
6287 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6291 (when current-prefix-arg
6293 "Faq dir: " (and (listp gnus-group-faq-directory)
6294 (mapcar (lambda (file) (list file))
6295 gnus-group-faq-directory))))))
6296 (let (gnus-faq-buffer)
6297 (when (setq gnus-faq-buffer
6298 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6299 (gnus-configure-windows 'summary-faq))))
6301 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6302 (defun gnus-summary-describe-group (&optional force)
6303 "Describe the current newsgroup."
6305 (gnus-group-describe-group force gnus-newsgroup-name))
6307 (defun gnus-summary-describe-briefly ()
6308 "Describe summary mode commands briefly."
6310 (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")))
6312 ;; Walking around group mode buffer from summary mode.
6314 (defun gnus-summary-next-group (&optional no-article target-group backward)
6315 "Exit current newsgroup and then select next unread newsgroup.
6316 If prefix argument NO-ARTICLE is non-nil, no article is selected
6317 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6318 previous group instead."
6320 ;; Stop pre-fetching.
6321 (gnus-async-halt-prefetch)
6322 (let ((current-group gnus-newsgroup-name)
6323 (current-buffer (current-buffer))
6325 ;; First we semi-exit this group to update Xrefs and all variables.
6326 ;; We can't do a real exit, because the window conf must remain
6327 ;; the same in case the user is prompted for info, and we don't
6328 ;; want the window conf to change before that...
6329 (gnus-summary-exit t)
6330 (while (not entered)
6331 ;; Then we find what group we are supposed to enter.
6332 (set-buffer gnus-group-buffer)
6333 (gnus-group-jump-to-group current-group)
6336 (if (eq gnus-keep-same-level 'best)
6337 (gnus-summary-best-group gnus-newsgroup-name)
6338 (gnus-summary-search-group backward gnus-keep-same-level))))
6339 (if (not target-group)
6340 ;; There are no further groups, so we return to the group
6343 (gnus-message 5 "Returning to the group buffer")
6345 (when (gnus-buffer-live-p current-buffer)
6346 (set-buffer current-buffer)
6347 (gnus-summary-exit))
6348 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6349 ;; We try to enter the target group.
6350 (gnus-group-jump-to-group target-group)
6351 (let ((unreads (gnus-group-group-unread)))
6352 (if (and (or (eq t unreads)
6353 (and unreads (not (zerop unreads))))
6354 (gnus-summary-read-group
6355 target-group nil no-article
6356 (and (buffer-name current-buffer) current-buffer)
6359 (setq current-group target-group
6360 target-group nil)))))))
6362 (defun gnus-summary-prev-group (&optional no-article)
6363 "Exit current newsgroup and then select previous unread newsgroup.
6364 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6366 (gnus-summary-next-group no-article nil t))
6368 ;; Walking around summary lines.
6370 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6371 "Go to the first unread subject.
6372 If UNREAD is non-nil, go to the first unread article.
6373 Returns the article selected or nil if there are no unread articles."
6378 ((null gnus-newsgroup-data)
6379 (gnus-message 3 "No articles in the group")
6381 ;; Pick the first article.
6383 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6384 (gnus-data-number (car gnus-newsgroup-data)))
6385 ;; No unread articles.
6386 ((null gnus-newsgroup-unreads)
6387 (gnus-message 3 "No more unread articles")
6389 ;; Find the first unread article.
6391 (let ((data gnus-newsgroup-data))
6393 (and (not (and undownloaded
6394 (eq gnus-undownloaded-mark
6395 (gnus-data-mark (car data)))))
6398 (gnus-data-number (car data))
6399 gnus-newsgroup-unseen))
6400 (not (gnus-data-unread-p (car data))))
6401 (not (gnus-data-unread-p (car data))))))
6402 (setq data (cdr data)))
6404 (goto-char (gnus-data-pos (car data)))
6405 (gnus-data-number (car data))))))
6406 (gnus-summary-position-point)))
6408 (defun gnus-summary-next-subject (n &optional unread dont-display)
6409 "Go to next N'th summary line.
6410 If N is negative, go to the previous N'th subject line.
6411 If UNREAD is non-nil, only unread articles are selected.
6412 The difference between N and the actual number of steps taken is
6415 (let ((backward (< n 0))
6419 (gnus-summary-find-prev unread)
6420 (gnus-summary-find-next unread)))
6421 (unless (zerop (setq n (1- n)))
6422 (gnus-summary-show-thread)))
6424 (gnus-message 7 "No more%s articles"
6425 (if unread " unread" "")))
6426 (unless dont-display
6427 (gnus-summary-recenter)
6428 (gnus-summary-position-point))
6431 (defun gnus-summary-next-unread-subject (n)
6432 "Go to next N'th unread summary line."
6434 (gnus-summary-next-subject n t))
6436 (defun gnus-summary-prev-subject (n &optional unread)
6437 "Go to previous N'th summary line.
6438 If optional argument UNREAD is non-nil, only unread article is selected."
6440 (gnus-summary-next-subject (- n) unread))
6442 (defun gnus-summary-prev-unread-subject (n)
6443 "Go to previous N'th unread summary line."
6445 (gnus-summary-next-subject (- n) t))
6447 (defun gnus-summary-goto-subject (article &optional force silent)
6448 "Go the subject line of ARTICLE.
6449 If FORCE, also allow jumping to articles not currently shown."
6450 (interactive "nArticle number: ")
6451 (unless (numberp article)
6452 (error "Article %s is not a number" article))
6454 (data (gnus-data-find article)))
6455 ;; We read in the article if we have to.
6458 (gnus-summary-insert-subject
6460 (if (or (numberp force) (vectorp force)) force)
6462 (setq data (gnus-data-find article)))
6467 (gnus-message 3 "Can't find article %d" article))
6469 (let ((pt (gnus-data-pos data)))
6471 (gnus-summary-set-article-display-arrow pt))
6472 (gnus-summary-position-point)
6475 ;; Walking around summary lines with displaying articles.
6477 (defun gnus-summary-expand-window (&optional arg)
6478 "Make the summary buffer take up the entire Emacs frame.
6479 Given a prefix, will force an `article' buffer configuration."
6482 (gnus-configure-windows 'article 'force)
6483 (gnus-configure-windows 'summary 'force)))
6485 (defun gnus-summary-display-article (article &optional all-header)
6486 "Display ARTICLE in article buffer."
6487 (when (gnus-buffer-live-p gnus-article-buffer)
6488 (with-current-buffer gnus-article-buffer
6489 (mm-enable-multibyte)))
6490 (gnus-set-global-variables)
6491 (when (gnus-buffer-live-p gnus-article-buffer)
6492 (with-current-buffer gnus-article-buffer
6493 (setq gnus-article-charset gnus-newsgroup-charset)
6494 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6495 (mm-enable-multibyte)))
6499 (if gnus-summary-display-article-function
6500 (funcall gnus-summary-display-article-function article all-header)
6501 (gnus-article-prepare article all-header))
6502 (gnus-run-hooks 'gnus-select-article-hook)
6503 (when (and gnus-current-article
6504 (not (zerop gnus-current-article)))
6505 (gnus-summary-goto-subject gnus-current-article))
6506 (gnus-summary-recenter)
6507 (when (and gnus-use-trees gnus-show-threads)
6508 (gnus-possibly-generate-tree article)
6509 (gnus-highlight-selected-tree article))
6510 ;; Successfully display article.
6511 (gnus-article-set-window-start
6512 (cdr (assq article gnus-newsgroup-bookmarks))))))
6514 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6515 "Select the current article.
6516 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6517 non-nil, the article will be re-fetched even if it already present in
6518 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6520 ;; Make sure we are in the summary buffer to work around bbdb bug.
6521 (unless (eq major-mode 'gnus-summary-mode)
6522 (set-buffer gnus-summary-buffer))
6523 (let ((article (or article (gnus-summary-article-number)))
6524 (all-headers (not (not all-headers))) ;Must be t or nil.
6525 gnus-summary-display-article-function)
6527 (gnus-summary-article-pseudo-p article)
6528 (error "This is a pseudo-article"))
6530 (set-buffer gnus-summary-buffer)
6531 (if (or (and gnus-single-article-buffer
6532 (or (null gnus-current-article)
6533 (null gnus-article-current)
6534 (null (get-buffer gnus-article-buffer))
6535 (not (eq article (cdr gnus-article-current)))
6536 (not (equal (car gnus-article-current)
6537 gnus-newsgroup-name))))
6538 (and (not gnus-single-article-buffer)
6539 (or (null gnus-current-article)
6540 (not (eq gnus-current-article article))))
6542 ;; The requested article is different from the current article.
6544 (gnus-summary-display-article article all-headers)
6545 (when (gnus-buffer-live-p gnus-article-buffer)
6546 (with-current-buffer gnus-article-buffer
6547 (if (not gnus-article-decoded-p) ;; a local variable
6548 (mm-disable-multibyte))))
6549 ;;; Hidden headers are not hidden text any more.
6550 ;; (when (or all-headers gnus-show-all-headers)
6551 ;; (gnus-article-show-all-headers))
6552 (gnus-article-set-window-start
6553 (cdr (assq article gnus-newsgroup-bookmarks)))
6555 ;; (when (or all-headers gnus-show-all-headers)
6556 ;; (gnus-article-show-all-headers))
6559 (defun gnus-summary-force-verify-and-decrypt ()
6561 (let ((mm-verify-option 'known)
6562 (mm-decrypt-option 'known))
6563 (gnus-summary-select-article nil 'force)))
6565 (defun gnus-summary-set-current-mark (&optional current-mark)
6566 "Obsolete function."
6569 (defun gnus-summary-next-article (&optional unread subject backward push)
6570 "Select the next article.
6571 If UNREAD, only unread articles are selected.
6572 If SUBJECT, only articles with SUBJECT are selected.
6573 If BACKWARD, the previous article is selected instead of the next."
6576 ;; Is there such an article?
6577 ((and (gnus-summary-search-forward unread subject backward)
6578 (or (gnus-summary-display-article (gnus-summary-article-number))
6579 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6580 (gnus-summary-position-point))
6581 ;; If not, we try the first unread, if that is wanted.
6583 gnus-auto-select-same
6584 (gnus-summary-first-unread-article))
6585 (gnus-summary-position-point)
6586 (gnus-message 6 "Wrapped"))
6587 ;; Try to get next/previous article not displayed in this group.
6588 ((and gnus-auto-extend-newsgroup
6589 (not unread) (not subject))
6590 (gnus-summary-goto-article
6591 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6592 nil (count-lines (point-min) (point))))
6593 ;; Go to next/previous group.
6595 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6596 (gnus-summary-jump-to-group gnus-newsgroup-name))
6597 (let ((cmd last-command-char)
6600 (set-buffer gnus-group-buffer)
6603 (if (eq gnus-keep-same-level 'best)
6604 (gnus-summary-best-group gnus-newsgroup-name)
6605 (gnus-summary-search-group backward gnus-keep-same-level))))
6606 ;; For some reason, the group window gets selected. We change
6608 (select-window (get-buffer-window (current-buffer)))
6609 ;; Select next unread newsgroup automagically.
6611 ((or (not gnus-auto-select-next)
6613 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6614 ((or (eq gnus-auto-select-next 'quietly)
6615 (and (eq gnus-auto-select-next 'slightly-quietly)
6617 (and (eq gnus-auto-select-next 'almost-quietly)
6618 (gnus-summary-last-article-p)))
6620 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6622 (gnus-message 7 "No more%s articles (%s)..."
6623 (if unread " unread" "")
6624 (if group (concat "selecting " group)
6626 (gnus-summary-next-group nil group backward)))
6628 (when (gnus-key-press-event-p last-input-event)
6629 (gnus-summary-walk-group-buffer
6630 gnus-newsgroup-name cmd unread backward point))))))))
6632 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6633 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6634 (?\C-p (gnus-group-prev-unread-group 1))))
6635 (cursor-in-echo-area t)
6636 keve key group ended)
6638 (set-buffer gnus-group-buffer)
6641 (if (eq gnus-keep-same-level 'best)
6642 (gnus-summary-best-group gnus-newsgroup-name)
6643 (gnus-summary-search-group backward gnus-keep-same-level))))
6646 5 "No more%s articles%s" (if unread " unread" "")
6648 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6649 (format " (Type %s for %s [%s])"
6650 (single-key-description cmd) group
6651 (car (gnus-gethash group gnus-newsrc-hashtb)))
6652 (format " (Type %s to exit %s)"
6653 (single-key-description cmd)
6654 gnus-newsgroup-name)))
6655 ;; Confirm auto selection.
6656 (setq key (car (setq keve (gnus-read-event-char))))
6659 ((assq key keystrokes)
6660 (let ((obuf (current-buffer)))
6661 (switch-to-buffer gnus-group-buffer)
6663 (gnus-group-jump-to-group group))
6664 (eval (cadr (assq key keystrokes)))
6665 (setq group (gnus-group-group-name))
6666 (switch-to-buffer obuf))
6670 (gnus-ephemeral-group-p gnus-newsgroup-name))
6672 (gnus-summary-next-group nil group backward)))
6674 (push (cdr keve) unread-command-events))))))
6676 (defun gnus-summary-next-unread-article ()
6677 "Select unread article after current one."
6679 (gnus-summary-next-article
6680 (or (not (eq gnus-summary-goto-unread 'never))
6681 (gnus-summary-last-article-p (gnus-summary-article-number)))
6682 (and gnus-auto-select-same
6683 (gnus-summary-article-subject))))
6685 (defun gnus-summary-prev-article (&optional unread subject)
6686 "Select the article after the current one.
6687 If UNREAD is non-nil, only unread articles are selected."
6689 (gnus-summary-next-article unread subject t))
6691 (defun gnus-summary-prev-unread-article ()
6692 "Select unread article before current one."
6694 (gnus-summary-prev-article
6695 (or (not (eq gnus-summary-goto-unread 'never))
6696 (gnus-summary-first-article-p (gnus-summary-article-number)))
6697 (and gnus-auto-select-same
6698 (gnus-summary-article-subject))))
6700 (defun gnus-summary-next-page (&optional lines circular)
6701 "Show next page of the selected article.
6702 If at the end of the current article, select the next article.
6703 LINES says how many lines should be scrolled up.
6705 If CIRCULAR is non-nil, go to the start of the article instead of
6706 selecting the next article when reaching the end of the current
6709 (setq gnus-summary-buffer (current-buffer))
6710 (gnus-set-global-variables)
6711 (let ((article (gnus-summary-article-number))
6712 (article-window (get-buffer-window gnus-article-buffer t))
6714 ;; If the buffer is empty, we have no article.
6716 (error "No article to select"))
6717 (gnus-configure-windows 'article)
6718 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6719 (if (and (eq gnus-summary-goto-unread 'never)
6720 (not (gnus-summary-last-article-p article)))
6721 (gnus-summary-next-article)
6722 (gnus-summary-next-unread-article))
6723 (if (or (null gnus-current-article)
6724 (null gnus-article-current)
6725 (/= article (cdr gnus-article-current))
6726 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6727 ;; Selected subject is different from current article's.
6728 (gnus-summary-display-article article)
6729 (when article-window
6730 (gnus-eval-in-buffer-window gnus-article-buffer
6731 (setq endp (gnus-article-next-page lines)))
6734 (gnus-summary-beginning-of-article))
6736 (gnus-message 3 "End of message"))
6738 (if (and (eq gnus-summary-goto-unread 'never)
6739 (not (gnus-summary-last-article-p article)))
6740 (gnus-summary-next-article)
6741 (gnus-summary-next-unread-article))))))))
6742 (gnus-summary-recenter)
6743 (gnus-summary-position-point)))
6745 (defun gnus-summary-prev-page (&optional lines move)
6746 "Show previous page of selected article.
6747 Argument LINES specifies lines to be scrolled down.
6748 If MOVE, move to the previous unread article if point is at
6749 the beginning of the buffer."
6751 (let ((article (gnus-summary-article-number))
6752 (article-window (get-buffer-window gnus-article-buffer t))
6754 (gnus-configure-windows 'article)
6755 (if (or (null gnus-current-article)
6756 (null gnus-article-current)
6757 (/= article (cdr gnus-article-current))
6758 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6759 ;; Selected subject is different from current article's.
6760 (gnus-summary-display-article article)
6761 (gnus-summary-recenter)
6762 (when article-window
6763 (gnus-eval-in-buffer-window gnus-article-buffer
6764 (setq endp (gnus-article-prev-page lines)))
6765 (when (and move endp)
6767 (gnus-message 3 "Beginning of message"))
6769 (if (and (eq gnus-summary-goto-unread 'never)
6770 (not (gnus-summary-first-article-p article)))
6771 (gnus-summary-prev-article)
6772 (gnus-summary-prev-unread-article))))))))
6773 (gnus-summary-position-point))
6775 (defun gnus-summary-prev-page-or-article (&optional lines)
6776 "Show previous page of selected article.
6777 Argument LINES specifies lines to be scrolled down.
6778 If at the beginning of the article, go to the next article."
6780 (gnus-summary-prev-page lines t))
6782 (defun gnus-summary-scroll-up (lines)
6783 "Scroll up (or down) one line current article.
6784 Argument LINES specifies lines to be scrolled up (or down if negative)."
6786 (gnus-configure-windows 'article)
6787 (gnus-summary-show-thread)
6788 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6789 (gnus-eval-in-buffer-window gnus-article-buffer
6791 (when (gnus-article-next-page lines)
6792 (gnus-message 3 "End of message")))
6794 (gnus-article-prev-page (- lines))))))
6795 (gnus-summary-recenter)
6796 (gnus-summary-position-point))
6798 (defun gnus-summary-scroll-down (lines)
6799 "Scroll down (or up) one line current article.
6800 Argument LINES specifies lines to be scrolled down (or up if negative)."
6802 (gnus-summary-scroll-up (- lines)))
6804 (defun gnus-summary-next-same-subject ()
6805 "Select next article which has the same subject as current one."
6807 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6809 (defun gnus-summary-prev-same-subject ()
6810 "Select previous article which has the same subject as current one."
6812 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6814 (defun gnus-summary-next-unread-same-subject ()
6815 "Select next unread article which has the same subject as current one."
6817 (gnus-summary-next-article t (gnus-summary-article-subject)))
6819 (defun gnus-summary-prev-unread-same-subject ()
6820 "Select previous unread article which has the same subject as current one."
6822 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6824 (defun gnus-summary-first-unread-article ()
6825 "Select the first unread article.
6826 Return nil if there are no unread articles."
6829 (when (gnus-summary-first-subject t)
6830 (gnus-summary-show-thread)
6831 (gnus-summary-first-subject t)
6832 (gnus-summary-display-article (gnus-summary-article-number)))
6833 (gnus-summary-position-point)))
6835 (defun gnus-summary-first-unread-subject ()
6836 "Place the point on the subject line of the first unread article.
6837 Return nil if there are no unread articles."
6840 (when (gnus-summary-first-subject t)
6841 (gnus-summary-show-thread)
6842 (gnus-summary-first-subject t))
6843 (gnus-summary-position-point)))
6845 (defun gnus-summary-first-unseen-subject ()
6846 "Place the point on the subject line of the first unseen article.
6847 Return nil if there are no unseen articles."
6850 (when (gnus-summary-first-subject t t t)
6851 (gnus-summary-show-thread)
6852 (gnus-summary-first-subject t t t))
6853 (gnus-summary-position-point)))
6855 (defun gnus-summary-first-article ()
6856 "Select the first article.
6857 Return nil if there are no articles."
6860 (when (gnus-summary-first-subject)
6861 (gnus-summary-show-thread)
6862 (gnus-summary-first-subject)
6863 (gnus-summary-display-article (gnus-summary-article-number)))
6864 (gnus-summary-position-point)))
6866 (defun gnus-summary-best-unread-article (&optional arg)
6867 "Select the unread article with the highest score.
6868 If given a prefix argument, select the next unread article that has a
6869 score higher than the default score."
6871 (let ((article (if arg
6872 (gnus-summary-better-unread-subject)
6873 (gnus-summary-best-unread-subject))))
6875 (gnus-summary-goto-article article)
6876 (error "No unread articles"))))
6878 (defun gnus-summary-best-unread-subject ()
6879 "Select the unread subject with the highest score."
6881 (let ((best -1000000)
6882 (data gnus-newsgroup-data)
6885 (and (gnus-data-unread-p (car data))
6887 (gnus-summary-article-score (gnus-data-number (car data))))
6890 article (gnus-data-number (car data))))
6891 (setq data (cdr data)))
6893 (gnus-summary-goto-subject article))
6894 (gnus-summary-position-point)
6897 (defun gnus-summary-better-unread-subject ()
6898 "Select the first unread subject that has a score over the default score."
6900 (let ((data gnus-newsgroup-data)
6902 (while (and (setq article (gnus-data-number (car data)))
6903 (or (gnus-data-read-p (car data))
6904 (not (> (gnus-summary-article-score article)
6905 gnus-summary-default-score))))
6906 (setq data (cdr data)))
6908 (gnus-summary-goto-subject article))
6909 (gnus-summary-position-point)
6912 (defun gnus-summary-last-subject ()
6913 "Go to the last displayed subject line in the group."
6914 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6916 (gnus-summary-goto-subject article))))
6918 (defun gnus-summary-goto-article (article &optional all-headers force)
6919 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6920 If ALL-HEADERS is non-nil, no header lines are hidden.
6921 If FORCE, go to the article even if it isn't displayed. If FORCE
6922 is a number, it is the line the article is to be displayed on."
6926 "Article number or Message-ID: "
6927 (mapcar (lambda (number) (list (int-to-string number)))
6928 gnus-newsgroup-limit))
6932 (if (and (stringp article)
6933 (string-match "@" article))
6934 (gnus-summary-refer-article article)
6935 (when (stringp article)
6936 (setq article (string-to-number article)))
6937 (if (gnus-summary-goto-subject article force)
6938 (gnus-summary-display-article article all-headers)
6939 (gnus-message 4 "Couldn't go to article %s" article) nil))
6940 (gnus-summary-position-point)))
6942 (defun gnus-summary-goto-last-article ()
6943 "Go to the previously read article."
6946 (when gnus-last-article
6947 (gnus-summary-goto-article gnus-last-article nil t))
6948 (gnus-summary-position-point)))
6950 (defun gnus-summary-pop-article (number)
6951 "Pop one article off the history and go to the previous.
6952 NUMBER articles will be popped off."
6955 (setq gnus-newsgroup-history
6956 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6958 (gnus-summary-goto-article (car to) nil t)
6959 (error "Article history empty")))
6960 (gnus-summary-position-point))
6962 ;; Summary commands and functions for limiting the summary buffer.
6964 (defun gnus-summary-limit-to-articles (n)
6965 "Limit the summary buffer to the next N articles.
6966 If not given a prefix, use the process marked articles instead."
6969 (let ((articles (gnus-summary-work-articles n)))
6970 (setq gnus-newsgroup-processable nil)
6971 (gnus-summary-limit articles))
6972 (gnus-summary-position-point)))
6974 (defun gnus-summary-pop-limit (&optional total)
6975 "Restore the previous limit.
6976 If given a prefix, remove all limits."
6979 (setq gnus-newsgroup-limits
6980 (list (mapcar (lambda (h) (mail-header-number h))
6981 gnus-newsgroup-headers))))
6982 (unless gnus-newsgroup-limits
6983 (error "No limit to pop"))
6985 (gnus-summary-limit nil 'pop)
6986 (gnus-summary-position-point)))
6988 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6989 "Limit the summary buffer to articles that have subjects that match a regexp.
6990 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6992 (list (read-string (if current-prefix-arg
6993 "Exclude subject (regexp): "
6994 "Limit to subject (regexp): "))
6995 nil current-prefix-arg))
6997 (setq header "subject"))
6998 (when (not (equal "" subject))
7000 (let ((articles (gnus-summary-find-matching
7001 (or header "subject") subject 'all nil nil
7004 (error "Found no matches for \"%s\"" subject))
7005 (gnus-summary-limit articles))
7006 (gnus-summary-position-point))))
7008 (defun gnus-summary-limit-to-author (from &optional not-matching)
7009 "Limit the summary buffer to articles that have authors that match a regexp.
7010 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7012 (list (read-string (if current-prefix-arg
7013 "Exclude author (regexp): "
7014 "Limit to author (regexp): "))
7015 current-prefix-arg))
7016 (gnus-summary-limit-to-subject from "from" not-matching))
7018 (defun gnus-summary-limit-to-age (age &optional younger-p)
7019 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7020 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7021 articles that are younger than AGE days."
7023 (let ((younger current-prefix-arg)
7026 (while (not days-got)
7027 (setq days (if younger
7028 (read-string "Limit to articles within (in days): ")
7029 (read-string "Limit to articles older than (in days): ")))
7030 (when (> (length days) 0)
7031 (setq days (read days)))
7037 (setq younger (not younger))
7038 (setq days (* days -1)))))
7039 (message "Please enter a number.")
7041 (list days younger)))
7043 (let ((data gnus-newsgroup-data)
7044 (cutoff (days-to-time age))
7045 articles d date is-younger)
7046 (while (setq d (pop data))
7047 (when (and (vectorp (gnus-data-header d))
7048 (setq date (mail-header-date (gnus-data-header d))))
7049 (setq is-younger (time-less-p
7050 (time-since (condition-case ()
7057 (push (gnus-data-number d) articles))))
7058 (gnus-summary-limit (nreverse articles)))
7059 (gnus-summary-position-point)))
7061 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7062 "Limit the summary buffer to articles that match an 'extra' header."
7066 (gnus-completing-read-with-default
7067 (symbol-name (car gnus-extra-headers))
7068 (if current-prefix-arg
7069 "Exclude extra header:"
7070 "Limit extra header:")
7072 (cons (symbol-name x) x))
7077 (read-string (format "%s header %s (regexp): "
7078 (if current-prefix-arg "Exclude" "Limit to")
7080 current-prefix-arg)))
7081 (when (not (equal "" regexp))
7083 (let ((articles (gnus-summary-find-matching
7084 (cons 'extra header) regexp 'all nil nil
7087 (error "Found no matches for \"%s\"" regexp))
7088 (gnus-summary-limit articles))
7089 (gnus-summary-position-point))))
7091 (defun gnus-summary-limit-to-display-predicate ()
7092 "Limit the summary buffer to the predicated in the `display' group parameter."
7094 (unless gnus-newsgroup-display
7095 (error "There is no `display' group parameter"))
7097 (dolist (number gnus-newsgroup-articles)
7098 (when (funcall gnus-newsgroup-display)
7099 (push number articles)))
7100 (gnus-summary-limit articles))
7101 (gnus-summary-position-point))
7103 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7105 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7107 (defun gnus-summary-limit-to-unread (&optional all)
7108 "Limit the summary buffer to articles that are not marked as read.
7109 If ALL is non-nil, limit strictly to unread articles."
7112 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7113 (gnus-summary-limit-to-marks
7114 ;; Concat all the marks that say that an article is read and have
7116 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7117 gnus-killed-mark gnus-kill-file-mark
7118 gnus-low-score-mark gnus-expirable-mark
7119 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7120 gnus-duplicate-mark gnus-souped-mark)
7123 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7124 (make-obsolete 'gnus-summary-delete-marked-with
7125 'gnus-summary-limit-exlude-marks)
7127 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7128 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7129 If REVERSE, limit the summary buffer to articles that are marked
7130 with MARKS. MARKS can either be a string of marks or a list of marks.
7131 Returns how many articles were removed."
7132 (interactive "sMarks: ")
7133 (gnus-summary-limit-to-marks marks t))
7135 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7136 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7137 If REVERSE (the prefix), limit the summary buffer to articles that are
7138 not marked with MARKS. MARKS can either be a string of marks or a
7140 Returns how many articles were removed."
7141 (interactive "sMarks: \nP")
7143 (let ((data gnus-newsgroup-data)
7144 (marks (if (listp marks) marks
7145 (append marks nil))) ; Transform to list.
7148 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7149 (memq (gnus-data-mark (car data)) marks))
7150 (push (gnus-data-number (car data)) articles))
7151 (setq data (cdr data)))
7152 (gnus-summary-limit articles))
7153 (gnus-summary-position-point)))
7155 (defun gnus-summary-limit-to-score (score)
7156 "Limit to articles with score at or above SCORE."
7157 (interactive "NLimit to articles with score of at least: ")
7158 (let ((data gnus-newsgroup-data)
7161 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7163 (push (gnus-data-number (car data)) articles))
7164 (setq data (cdr data)))
7166 (gnus-summary-limit articles)
7167 (gnus-summary-position-point))))
7169 (defun gnus-summary-limit-include-thread (id)
7170 "Display all the hidden articles that is in the thread with ID in it.
7171 When called interactively, ID is the Message-ID of the current
7173 (interactive (list (mail-header-id (gnus-summary-article-header))))
7174 (let ((articles (gnus-articles-in-thread
7175 (gnus-id-to-thread (gnus-root-id id)))))
7177 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7178 (gnus-summary-limit-include-matching-articles
7180 (regexp-quote (gnus-simplify-subject-re
7181 (mail-header-subject (gnus-id-to-header id)))))
7182 (gnus-summary-position-point))))
7184 (defun gnus-summary-limit-include-matching-articles (header regexp)
7185 "Display all the hidden articles that have HEADERs that match REGEXP."
7186 (interactive (list (read-string "Match on header: ")
7187 (read-string "Regexp: ")))
7188 (let ((articles (gnus-find-matching-articles header regexp)))
7190 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7191 (gnus-summary-position-point))))
7193 (defun gnus-summary-limit-include-dormant ()
7194 "Display all the hidden articles that are marked as dormant.
7195 Note that this command only works on a subset of the articles currently
7196 fetched for this group."
7198 (unless gnus-newsgroup-dormant
7199 (error "There are no dormant articles in this group"))
7201 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7202 (gnus-summary-position-point)))
7204 (defun gnus-summary-limit-exclude-dormant ()
7205 "Hide all dormant articles."
7208 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7209 (gnus-summary-position-point)))
7211 (defun gnus-summary-limit-exclude-childless-dormant ()
7212 "Hide all dormant articles that have no children."
7214 (let ((data (gnus-data-list t))
7215 articles d children)
7216 ;; Find all articles that are either not dormant or have
7218 (while (setq d (pop data))
7219 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7221 (gnus-article-children (gnus-data-number d)))
7224 (when (memq (car children) articles)
7229 (push (gnus-data-number d) articles)))
7232 (gnus-summary-limit articles)
7233 (gnus-summary-position-point))))
7235 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7236 "Mark all unread excluded articles as read.
7237 If ALL, mark even excluded ticked and dormants as read."
7239 (let ((articles (gnus-sorted-complement
7241 (mapcar (lambda (h) (mail-header-number h))
7242 gnus-newsgroup-headers)
7244 (sort gnus-newsgroup-limit '<)))
7246 (setq gnus-newsgroup-unreads
7247 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7249 (setq gnus-newsgroup-dormant nil
7250 gnus-newsgroup-marked nil
7251 gnus-newsgroup-reads
7253 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7254 gnus-newsgroup-reads))
7255 (while (setq article (pop articles))
7256 (unless (or (memq article gnus-newsgroup-dormant)
7257 (memq article gnus-newsgroup-marked))
7258 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7260 (defun gnus-summary-limit (articles &optional pop)
7262 ;; We pop the previous limit off the stack and use that.
7263 (setq articles (car gnus-newsgroup-limits)
7264 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7265 ;; We use the new limit, so we push the old limit on the stack.
7266 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7268 (setq gnus-newsgroup-limit articles)
7269 (let ((total (length gnus-newsgroup-data))
7270 (data (gnus-data-find-list (gnus-summary-article-number)))
7271 (gnus-summary-mark-below nil) ; Inhibit this.
7273 ;; This will do all the work of generating the new summary buffer
7274 ;; according to the new limit.
7275 (gnus-summary-prepare)
7276 ;; Hide any threads, possibly.
7277 (gnus-summary-maybe-hide-threads)
7278 ;; Try to return to the article you were at, or one in the
7281 ;; We try to find some article after the current one.
7283 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7286 (setq data (cdr data))))
7288 ;; If there is no data, that means that we were after the last
7289 ;; article. The same goes when we can't find any articles
7290 ;; after the current one.
7291 (goto-char (point-max))
7292 (gnus-summary-find-prev))
7293 (gnus-set-mode-line 'summary)
7294 ;; We return how many articles were removed from the summary
7295 ;; buffer as a result of the new limit.
7296 (- total (length gnus-newsgroup-data))))
7298 (defsubst gnus-invisible-cut-children (threads)
7301 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7306 (defsubst gnus-cut-thread (thread)
7307 "Go forwards in the thread until we find an article that we want to display."
7308 (when (or (eq gnus-fetch-old-headers 'some)
7309 (eq gnus-fetch-old-headers 'invisible)
7310 (numberp gnus-fetch-old-headers)
7311 (eq gnus-build-sparse-threads 'some)
7312 (eq gnus-build-sparse-threads 'more))
7313 ;; Deal with old-fetched headers and sparse threads.
7317 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7318 (gnus-summary-article-ancient-p
7319 (mail-header-number (car thread))))
7320 (if (or (<= (length (cdr thread)) 1)
7321 (eq gnus-fetch-old-headers 'invisible))
7322 (setq gnus-newsgroup-limit
7323 (delq (mail-header-number (car thread))
7324 gnus-newsgroup-limit)
7325 thread (cadr thread))
7326 (when (gnus-invisible-cut-children (cdr thread))
7327 (let ((th (cdr thread)))
7329 (if (memq (mail-header-number (caar th))
7330 gnus-newsgroup-limit)
7331 (setq thread (car th)
7333 (setq th (cdr th))))))))))
7336 (defun gnus-cut-threads (threads)
7337 "Cut off all uninteresting articles from the beginning of threads."
7338 (when (or (eq gnus-fetch-old-headers 'some)
7339 (eq gnus-fetch-old-headers 'invisible)
7340 (numberp gnus-fetch-old-headers)
7341 (eq gnus-build-sparse-threads 'some)
7342 (eq gnus-build-sparse-threads 'more))
7345 (setcar th (gnus-cut-thread (car th)))
7346 (setq th (cdr th)))))
7347 ;; Remove nixed out threads.
7350 (defun gnus-summary-initial-limit (&optional show-if-empty)
7351 "Figure out what the initial limit is supposed to be on group entry.
7352 This entails weeding out unwanted dormants, low-scored articles,
7353 fetch-old-headers verbiage, and so on."
7354 ;; Most groups have nothing to remove.
7355 (if (or gnus-inhibit-limiting
7356 (and (null gnus-newsgroup-dormant)
7357 (eq gnus-newsgroup-display 'gnus-not-ignore)
7358 (not (eq gnus-fetch-old-headers 'some))
7359 (not (numberp gnus-fetch-old-headers))
7360 (not (eq gnus-fetch-old-headers 'invisible))
7361 (null gnus-summary-expunge-below)
7362 (not (eq gnus-build-sparse-threads 'some))
7363 (not (eq gnus-build-sparse-threads 'more))
7364 (null gnus-thread-expunge-below)
7365 (not gnus-use-nocem)))
7367 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7368 (setq gnus-newsgroup-limit nil)
7371 (unless (car (symbol-value node))
7372 ;; These threads have no parents -- they are roots.
7373 (let ((nodes (cdr (symbol-value node)))
7376 (if (and gnus-thread-expunge-below
7377 (< (gnus-thread-total-score (car nodes))
7378 gnus-thread-expunge-below))
7379 (gnus-expunge-thread (pop nodes))
7380 (setq thread (pop nodes))
7381 (gnus-summary-limit-children thread))))))
7382 gnus-newsgroup-dependencies)
7383 ;; If this limitation resulted in an empty group, we might
7384 ;; pop the previous limit and use it instead.
7385 (when (and (not gnus-newsgroup-limit)
7387 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7388 gnus-newsgroup-limit))
7390 (defun gnus-summary-limit-children (thread)
7391 "Return 1 if this subthread is visible and 0 if it is not."
7392 ;; First we get the number of visible children to this thread. This
7393 ;; is done by recursing down the thread using this function, so this
7394 ;; will really go down to a leaf article first, before slowly
7395 ;; working its way up towards the root.
7399 (apply '+ (mapcar 'gnus-summary-limit-children
7402 (number (mail-header-number (car thread)))
7405 (not (memq number gnus-newsgroup-marked))
7407 ;; If this article is dormant and has absolutely no visible
7408 ;; children, then this article isn't visible.
7409 (and (memq number gnus-newsgroup-dormant)
7411 ;; If this is "fetch-old-headered" and there is no
7412 ;; visible children, then we don't want this article.
7413 (and (or (eq gnus-fetch-old-headers 'some)
7414 (numberp gnus-fetch-old-headers))
7415 (gnus-summary-article-ancient-p number)
7417 ;; If this is "fetch-old-headered" and `invisible', then
7418 ;; we don't want this article.
7419 (and (eq gnus-fetch-old-headers 'invisible)
7420 (gnus-summary-article-ancient-p number))
7421 ;; If this is a sparsely inserted article with no children,
7422 ;; we don't want it.
7423 (and (eq gnus-build-sparse-threads 'some)
7424 (gnus-summary-article-sparse-p number)
7426 ;; If we use expunging, and this article is really
7427 ;; low-scored, then we don't want this article.
7428 (when (and gnus-summary-expunge-below
7430 (or (cdr (assq number gnus-newsgroup-scored))
7431 gnus-summary-default-score))
7432 gnus-summary-expunge-below))
7433 ;; We increase the expunge-tally here, but that has
7434 ;; nothing to do with the limits, really.
7435 (incf gnus-newsgroup-expunged-tally)
7436 ;; We also mark as read here, if that's wanted.
7437 (when (and gnus-summary-mark-below
7438 (< score gnus-summary-mark-below))
7439 (setq gnus-newsgroup-unreads
7440 (delq number gnus-newsgroup-unreads))
7441 (if gnus-newsgroup-auto-expire
7442 (push number gnus-newsgroup-expirable)
7443 (push (cons number gnus-low-score-mark)
7444 gnus-newsgroup-reads)))
7446 ;; Do the `display' group parameter.
7447 (and gnus-newsgroup-display
7448 (not (funcall gnus-newsgroup-display)))
7449 ;; Check NoCeM things.
7450 (if (and gnus-use-nocem
7451 (gnus-nocem-unwanted-article-p
7452 (mail-header-id (car thread))))
7454 (setq gnus-newsgroup-unreads
7455 (delq number gnus-newsgroup-unreads))
7457 ;; Nope, invisible article.
7459 ;; Ok, this article is to be visible, so we add it to the limit
7461 (push number gnus-newsgroup-limit)
7464 (defun gnus-expunge-thread (thread)
7465 "Mark all articles in THREAD as read."
7466 (let* ((number (mail-header-number (car thread))))
7467 (incf gnus-newsgroup-expunged-tally)
7468 ;; We also mark as read here, if that's wanted.
7469 (setq gnus-newsgroup-unreads
7470 (delq number gnus-newsgroup-unreads))
7471 (if gnus-newsgroup-auto-expire
7472 (push number gnus-newsgroup-expirable)
7473 (push (cons number gnus-low-score-mark)
7474 gnus-newsgroup-reads)))
7475 ;; Go recursively through all subthreads.
7476 (mapcar 'gnus-expunge-thread (cdr thread)))
7478 ;; Summary article oriented commands
7480 (defun gnus-summary-refer-parent-article (n)
7481 "Refer parent article N times.
7482 If N is negative, go to ancestor -N instead.
7483 The difference between N and the number of articles fetched is returned."
7487 (when (not (natnump n))
7492 (setq header (gnus-summary-article-header))
7493 (if (and (eq (mail-header-number header)
7494 (cdr gnus-article-current))
7495 (equal gnus-newsgroup-name
7496 (car gnus-article-current)))
7497 ;; If we try to find the parent of the currently
7498 ;; displayed article, then we take a look at the actual
7499 ;; References header, since this is slightly more
7500 ;; reliable than the References field we got from the
7503 (set-buffer gnus-original-article-buffer)
7504 (nnheader-narrow-to-headers)
7505 (unless (setq ref (message-fetch-field "references"))
7506 (setq ref (message-fetch-field "in-reply-to")))
7509 ;; It's not the current article, so we take a bet on
7510 ;; the value we got from the server.
7511 (mail-header-references header)))
7513 (not (equal ref "")))
7514 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7515 (gnus-message 1 "Couldn't find parent"))
7516 (gnus-message 1 "No references in article %d"
7517 (gnus-summary-article-number))
7520 (gnus-summary-position-point)
7523 (defun gnus-summary-refer-references ()
7524 "Fetch all articles mentioned in the References header.
7525 Return the number of articles fetched."
7527 (let ((ref (mail-header-references (gnus-summary-article-header)))
7528 (current (gnus-summary-article-number))
7532 (error "No References in the current article")
7533 ;; For each Message-ID in the References header...
7534 (while (string-match "<[^>]*>" ref)
7536 ;; ... fetch that article.
7537 (gnus-summary-refer-article
7538 (prog1 (match-string 0 ref)
7539 (setq ref (substring ref (match-end 0))))))
7540 (gnus-summary-goto-subject current)
7541 (gnus-summary-position-point)
7544 (defun gnus-summary-refer-thread (&optional limit)
7545 "Fetch all articles in the current thread.
7546 If LIMIT (the numerical prefix), fetch that many old headers instead
7547 of what's specified by the `gnus-refer-thread-limit' variable."
7549 (let ((id (mail-header-id (gnus-summary-article-header)))
7550 (limit (if limit (prefix-numeric-value limit)
7551 gnus-refer-thread-limit)))
7552 ;; We want to fetch LIMIT *old* headers, but we also have to
7553 ;; re-fetch all the headers in the current buffer, because many of
7554 ;; them may be undisplayed. So we adjust LIMIT.
7555 (when (numberp limit)
7556 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7557 (unless (eq gnus-fetch-old-headers 'invisible)
7558 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7559 ;; Retrieve the headers and read them in.
7560 (if (eq (gnus-retrieve-headers
7561 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7563 (gnus-build-all-threads)
7564 (error "Can't fetch thread from backends that don't support NOV"))
7565 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7566 (gnus-summary-limit-include-thread id)))
7568 (defun gnus-summary-refer-article (message-id)
7569 "Fetch an article specified by MESSAGE-ID."
7570 (interactive "sMessage-ID: ")
7571 (when (and (stringp message-id)
7572 (not (zerop (length message-id))))
7573 ;; Construct the correct Message-ID if necessary.
7574 ;; Suggested by tale@pawl.rpi.edu.
7575 (unless (string-match "^<" message-id)
7576 (setq message-id (concat "<" message-id)))
7577 (unless (string-match ">$" message-id)
7578 (setq message-id (concat message-id ">")))
7579 (let* ((header (gnus-id-to-header message-id))
7581 (gnus-summary-article-sparse-p
7582 (mail-header-number header))
7583 (memq (mail-header-number header)
7584 gnus-newsgroup-limit)))
7587 ;; If the article is present in the buffer we just go to it.
7589 (or (not (gnus-summary-article-sparse-p
7590 (mail-header-number header)))
7593 (gnus-summary-goto-article
7594 (mail-header-number header) nil t)
7596 (gnus-summary-update-article (mail-header-number header)))))
7598 ;; We fetch the article.
7600 (dolist (gnus-override-method (gnus-refer-article-methods))
7601 (gnus-check-server gnus-override-method)
7602 ;; Fetch the header, and display the article.
7603 (when (setq number (gnus-summary-insert-subject message-id))
7604 (gnus-summary-select-article nil nil nil number)
7606 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7608 (defun gnus-refer-article-methods ()
7609 "Return a list of referrable methods."
7611 ;; No method, so we default to current and native.
7612 ((null gnus-refer-article-method)
7613 (list gnus-current-select-method gnus-select-method))
7615 ((eq 'current gnus-refer-article-method)
7616 (list gnus-current-select-method))
7617 ;; List of select methods.
7618 ((not (and (symbolp (car gnus-refer-article-method))
7619 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7621 (dolist (method gnus-refer-article-method)
7622 (push (if (eq 'current method)
7623 gnus-current-select-method
7627 ;; One single select method.
7629 (list gnus-refer-article-method))))
7631 (defun gnus-summary-edit-parameters ()
7632 "Edit the group parameters of the current group."
7634 (gnus-group-edit-group gnus-newsgroup-name 'params))
7636 (defun gnus-summary-customize-parameters ()
7637 "Customize the group parameters of the current group."
7639 (gnus-group-customize gnus-newsgroup-name))
7641 (defun gnus-summary-enter-digest-group (&optional force)
7642 "Enter an nndoc group based on the current article.
7643 If FORCE, force a digest interpretation. If not, try
7644 to guess what the document format is."
7646 (let ((conf gnus-current-window-configuration))
7648 (gnus-summary-select-article))
7649 (setq gnus-current-window-configuration conf)
7650 (let* ((name (format "%s-%d"
7651 (gnus-group-prefixed-name
7652 gnus-newsgroup-name (list 'nndoc ""))
7654 (set-buffer gnus-summary-buffer)
7655 gnus-current-article)))
7656 (ogroup gnus-newsgroup-name)
7657 (params (append (gnus-info-params (gnus-get-info ogroup))
7658 (list (cons 'to-group ogroup))
7659 (list (cons 'save-article-group ogroup))))
7660 (case-fold-search t)
7661 (buf (current-buffer))
7664 (set-buffer gnus-original-article-buffer)
7665 ;; Have the digest group inherit the main mail address of
7666 ;; the parent article.
7667 (when (setq to-address (or (message-fetch-field "reply-to")
7668 (message-fetch-field "from")))
7669 (setq params (append
7670 (list (cons 'to-address
7671 (funcall gnus-decode-encoded-word-function
7673 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7674 (insert-buffer-substring gnus-original-article-buffer)
7675 ;; Remove lines that may lead nndoc to misinterpret the
7678 (goto-char (point-min))
7679 (or (search-forward "\n\n" nil t) (point)))
7680 (goto-char (point-min))
7681 (delete-matching-lines "^Path:\\|^From ")
7684 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7685 (gnus-newsgroup-ephemeral-ignored-charsets
7686 gnus-newsgroup-ignored-charsets))
7687 (gnus-group-read-ephemeral-group
7688 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7690 ,(if force 'mbox 'guess)))
7692 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7694 ;; Make all postings to this group go to the parent group.
7695 (nconc (gnus-info-params (gnus-get-info name))
7697 ;; Couldn't select this doc group.
7698 (switch-to-buffer buf)
7699 (gnus-set-global-variables)
7700 (gnus-configure-windows 'summary)
7701 (gnus-message 3 "Article couldn't be entered?"))
7702 (kill-buffer dig)))))
7704 (defun gnus-summary-read-document (n)
7705 "Open a new group based on the current article(s).
7706 This will allow you to read digests and other similar
7707 documents as newsgroups.
7708 Obeys the standard process/prefix convention."
7710 (let* ((articles (gnus-summary-work-articles n))
7711 (ogroup gnus-newsgroup-name)
7712 (params (append (gnus-info-params (gnus-get-info ogroup))
7713 (list (cons 'to-group ogroup))))
7714 article group egroup groups vgroup)
7715 (while (setq article (pop articles))
7716 (setq group (format "%s-%d" gnus-newsgroup-name article))
7717 (gnus-summary-remove-process-mark article)
7718 (when (gnus-summary-display-article article)
7721 (insert-buffer-substring gnus-original-article-buffer)
7722 ;; Remove some headers that may lead nndoc to make
7724 (message-narrow-to-head)
7725 (goto-char (point-min))
7726 (delete-matching-lines "^\\(Path\\):\\|^From ")
7729 (gnus-group-read-ephemeral-group
7730 group `(nndoc ,group (nndoc-address ,(current-buffer))
7731 (nndoc-article-type guess))
7734 ;; Make all postings to this group go to the parent group.
7735 (nconc (gnus-info-params (gnus-get-info egroup))
7737 (push egroup groups))
7738 ;; Couldn't select this doc group.
7739 (gnus-error 3 "Article couldn't be entered"))))))
7740 ;; Now we have selected all the documents.
7743 (error "None of the articles could be interpreted as documents"))
7744 ((gnus-group-read-ephemeral-group
7745 (setq vgroup (format
7746 "nnvirtual:%s-%s" gnus-newsgroup-name
7747 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7748 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7750 (cons (current-buffer) 'summary)))
7752 (error "Couldn't select virtual nndoc group")))))
7754 (defun gnus-summary-isearch-article (&optional regexp-p)
7755 "Do incremental search forward on the current article.
7756 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7758 (gnus-summary-select-article)
7759 (gnus-configure-windows 'article)
7760 (gnus-eval-in-buffer-window gnus-article-buffer
7763 (isearch-forward regexp-p))))
7765 (defun gnus-summary-search-article-forward (regexp &optional backward)
7766 "Search for an article containing REGEXP forward.
7767 If BACKWARD, search backward instead."
7770 (format "Search article %s (regexp%s): "
7771 (if current-prefix-arg "backward" "forward")
7772 (if gnus-last-search-regexp
7773 (concat ", default " gnus-last-search-regexp)
7775 current-prefix-arg))
7776 (if (string-equal regexp "")
7777 (setq regexp (or gnus-last-search-regexp ""))
7778 (setq gnus-last-search-regexp regexp)
7779 (setq gnus-article-before-search gnus-current-article))
7780 ;; Intentionally set gnus-last-article.
7781 (setq gnus-last-article gnus-article-before-search)
7782 (let ((gnus-last-article gnus-last-article))
7783 (if (gnus-summary-search-article regexp backward)
7784 (gnus-summary-show-thread)
7785 (error "Search failed: \"%s\"" regexp))))
7787 (defun gnus-summary-search-article-backward (regexp)
7788 "Search for an article containing REGEXP backward."
7791 (format "Search article backward (regexp%s): "
7792 (if gnus-last-search-regexp
7793 (concat ", default " gnus-last-search-regexp)
7795 (gnus-summary-search-article-forward regexp 'backward))
7797 (defun gnus-summary-search-article (regexp &optional backward)
7798 "Search for an article containing REGEXP.
7799 Optional argument BACKWARD means do search for backward.
7800 `gnus-select-article-hook' is not called during the search."
7801 ;; We have to require this here to make sure that the following
7802 ;; dynamic binding isn't shadowed by autoloading.
7803 (require 'gnus-async)
7805 (let ((gnus-select-article-hook nil) ;Disable hook.
7806 (gnus-article-prepare-hook nil)
7807 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7808 (gnus-use-article-prefetch nil)
7809 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7810 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7811 (sum (current-buffer))
7812 (gnus-display-mime-function nil)
7815 (gnus-save-hidden-threads
7816 (gnus-summary-select-article)
7817 (set-buffer gnus-article-buffer)
7818 (goto-char (window-point (get-buffer-window (current-buffer))))
7822 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7824 (re-search-backward regexp nil t)
7825 (re-search-forward regexp nil t))
7826 ;; We found the regexp.
7831 (get-buffer-window (current-buffer))
7835 (get-buffer-window (current-buffer))
7838 (setq point (point)))
7839 ;; We didn't find it, so we go to the next article.
7842 (while (eq found 'not)
7843 (if (not (if backward (gnus-summary-find-prev)
7844 (gnus-summary-find-next)))
7845 ;; No more articles.
7847 ;; Select the next article and adjust point.
7848 (unless (gnus-summary-article-sparse-p
7849 (gnus-summary-article-number))
7851 (gnus-summary-select-article)
7852 (set-buffer gnus-article-buffer)
7854 (goto-char (if backward (point-max) (point-min))))))))
7855 (gnus-message 7 ""))
7856 ;; Return whether we found the regexp.
7857 (when (eq found 'found)
7859 (gnus-summary-show-thread)
7860 (gnus-summary-goto-subject gnus-current-article)
7861 (gnus-summary-position-point)
7864 (defun gnus-find-matching-articles (header regexp)
7865 "Return a list of all articles that match REGEXP on HEADER.
7866 This search includes all articles in the current group that Gnus has
7867 fetched headers for, whether they are displayed or not."
7868 (let ((articles nil)
7869 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7870 (case-fold-search t))
7871 (dolist (header gnus-newsgroup-headers)
7872 (when (string-match regexp (funcall func header))
7873 (push (mail-header-number header) articles)))
7874 (nreverse articles)))
7876 (defun gnus-summary-find-matching (header regexp &optional backward unread
7877 not-case-fold not-matching)
7878 "Return a list of all articles that match REGEXP on HEADER.
7879 The search stars on the current article and goes forwards unless
7880 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7881 If UNREAD is non-nil, only unread articles will
7882 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7883 in the comparisons. If NOT-MATCHING, return a list of all articles that
7884 not match REGEXP on HEADER."
7885 (let ((case-fold-search (not not-case-fold))
7888 (if (eq (car header) 'extra)
7891 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7893 (error "%s is an invalid header" header))
7894 (unless (fboundp (intern (concat "mail-header-" header)))
7895 (error "%s is not a valid header" header))
7896 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7897 (dolist (d (if (eq backward 'all)
7899 (gnus-data-find-list
7900 (gnus-summary-article-number)
7901 (gnus-data-list backward))))
7902 (when (and (or (not unread) ; We want all articles...
7903 (gnus-data-unread-p d)) ; Or just unreads.
7904 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7908 (funcall func (gnus-data-header d))))
7909 (string-match regexp
7910 (funcall func (gnus-data-header d)))))
7911 (push (gnus-data-number d) articles))) ; Success!
7912 (nreverse articles)))
7914 (defun gnus-summary-execute-command (header regexp command &optional backward)
7915 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7916 If HEADER is an empty string (or nil), the match is done on the entire
7917 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7919 (list (let ((completion-ignore-case t))
7922 (mapcar (lambda (header) (list (format "%s" header)))
7924 '("Number" "Subject" "From" "Lines" "Date"
7925 "Message-ID" "Xref" "References" "Body")
7926 gnus-extra-headers))
7927 nil 'require-match))
7928 (read-string "Regexp: ")
7929 (read-key-sequence "Command: ")
7930 current-prefix-arg))
7931 (when (equal header "Body")
7933 ;; Hidden thread subtrees must be searched as well.
7934 (gnus-summary-show-all-threads)
7935 ;; We don't want to change current point nor window configuration.
7937 (save-window-excursion
7938 (gnus-message 6 "Executing %s..." (key-description command))
7939 ;; We'd like to execute COMMAND interactively so as to give arguments.
7940 (gnus-execute header regexp
7941 `(call-interactively ',(key-binding command))
7943 (gnus-message 6 "Executing %s...done" (key-description command)))))
7945 (defun gnus-summary-beginning-of-article ()
7946 "Scroll the article back to the beginning."
7948 (gnus-summary-select-article)
7949 (gnus-configure-windows 'article)
7950 (gnus-eval-in-buffer-window gnus-article-buffer
7952 (goto-char (point-min))
7953 (when gnus-page-broken
7954 (gnus-narrow-to-page))))
7956 (defun gnus-summary-end-of-article ()
7957 "Scroll to the end of the article."
7959 (gnus-summary-select-article)
7960 (gnus-configure-windows 'article)
7961 (gnus-eval-in-buffer-window gnus-article-buffer
7963 (goto-char (point-max))
7965 (when gnus-page-broken
7966 (gnus-narrow-to-page))))
7968 (defun gnus-summary-print-truncate-and-quote (string &optional len)
7969 "Truncate to LEN and quote all \"(\"'s in STRING."
7970 (gnus-replace-in-string (if (and len (> (length string) len))
7971 (substring string 0 len)
7975 (defun gnus-summary-print-article (&optional filename n)
7976 "Generate and print a PostScript image of the N next (mail) articles.
7978 If N is negative, print the N previous articles. If N is nil and articles
7979 have been marked with the process mark, print these instead.
7981 If the optional first argument FILENAME is nil, send the image to the
7982 printer. If FILENAME is a string, save the PostScript image in a file with
7983 that name. If FILENAME is a number, prompt the user for the name of the file
7985 (interactive (list (ps-print-preprint current-prefix-arg)))
7986 (dolist (article (gnus-summary-work-articles n))
7987 (gnus-summary-select-article nil nil 'pseudo article)
7988 (gnus-eval-in-buffer-window gnus-article-buffer
7989 (gnus-print-buffer))
7990 (gnus-summary-remove-process-mark article))
7991 (ps-despool filename))
7993 (defun gnus-print-buffer ()
7994 (let ((buffer (generate-new-buffer " *print*")))
7997 (copy-to-buffer buffer (point-min) (point-max))
7999 (gnus-article-delete-invisible-text)
8000 (when (gnus-visual-p 'article-highlight 'highlight)
8001 ;; Copy-to-buffer doesn't copy overlay. So redo
8003 (let ((gnus-article-buffer buffer))
8004 (gnus-article-highlight-citation t)
8005 (gnus-article-highlight-signature)))
8006 (let ((ps-left-header
8009 (gnus-summary-print-truncate-and-quote
8010 (mail-header-subject gnus-current-headers)
8013 (gnus-summary-print-truncate-and-quote
8014 (mail-header-from gnus-current-headers)
8018 "/pagenumberstring load"
8020 (mail-header-date gnus-current-headers) ")"))))
8021 (gnus-run-hooks 'gnus-ps-print-hook)
8024 (ps-spool-buffer-with-faces)
8025 (ps-spool-buffer)))))
8026 (kill-buffer buffer))))
8028 (defun gnus-summary-show-article (&optional arg)
8029 "Force redisplaying of the current article.
8030 If ARG (the prefix) is a number, show the article with the charset
8031 defined in `gnus-summary-show-article-charset-alist', or the charset
8033 If ARG (the prefix) is non-nil and not a number, show the raw article
8034 without any article massaging functions being run. Normally, the key strokes
8039 (gnus-summary-show-article t)
8040 (let ((gnus-newsgroup-charset
8041 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8042 (mm-read-coding-system
8043 "View as charset: " ;; actually it is coding system.
8045 (set-buffer gnus-article-buffer)
8046 (mm-detect-coding-region (point) (point-max))))))
8047 (gnus-newsgroup-ignored-charsets 'gnus-all))
8048 (gnus-summary-select-article nil 'force)
8049 (let ((deps gnus-newsgroup-dependencies)
8052 (set-buffer gnus-original-article-buffer)
8054 (message-narrow-to-head)
8055 (setq head (buffer-string))
8056 (goto-char (point-min))
8057 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8058 (goto-char (point-max))
8060 (setq lines (1- (count-lines (point) (point-max))))))
8062 (insert (format "211 %d Article retrieved.\n"
8063 (cdr gnus-article-current)))
8065 (if lines (insert (format "Lines: %d\n" lines)))
8067 (let ((nntp-server-buffer (current-buffer)))
8068 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8069 (gnus-data-set-header
8070 (gnus-data-find (cdr gnus-article-current))
8072 (gnus-summary-update-article-line
8073 (cdr gnus-article-current) header)
8074 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8075 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8077 ;; Select the article the normal way.
8078 (gnus-summary-select-article nil 'force))
8080 ;; We have to require this here to make sure that the following
8081 ;; dynamic binding isn't shadowed by autoloading.
8082 (require 'gnus-async)
8084 ;; Bind the article treatment functions to nil.
8085 (let ((gnus-have-all-headers t)
8086 gnus-article-prepare-hook
8087 gnus-article-decode-hook
8088 gnus-display-mime-function
8090 ;; Destroy any MIME parts.
8091 (when (gnus-buffer-live-p gnus-article-buffer)
8093 (set-buffer gnus-article-buffer)
8094 (mm-destroy-parts gnus-article-mime-handles)
8095 ;; Set it to nil for safety reason.
8096 (setq gnus-article-mime-handle-alist nil)
8097 (setq gnus-article-mime-handles nil)))
8098 (gnus-summary-select-article nil 'force))))
8099 (gnus-summary-goto-subject gnus-current-article)
8100 (gnus-summary-position-point))
8102 (defun gnus-summary-show-raw-article ()
8103 "Show the raw article without any article massaging functions being run."
8105 (gnus-summary-show-article t))
8107 (defun gnus-summary-verbose-headers (&optional arg)
8108 "Toggle permanent full header display.
8109 If ARG is a positive number, turn header display on.
8110 If ARG is a negative number, turn header display off."
8112 (setq gnus-show-all-headers
8113 (cond ((or (not (numberp arg))
8115 (not gnus-show-all-headers))
8118 (gnus-summary-show-article))
8120 (defun gnus-summary-toggle-header (&optional arg)
8121 "Show the headers if they are hidden, or hide them if they are shown.
8122 If ARG is a positive number, show the entire header.
8123 If ARG is a negative number, hide the unwanted header lines."
8126 (set-buffer gnus-article-buffer)
8128 (let* ((buffer-read-only nil)
8129 (inhibit-point-motion-hooks t)
8135 (article-narrow-to-head)
8136 (gnus-article-hidden-text-p 'headers))))
8137 (goto-char (point-min))
8138 (when (search-forward "\n\n" nil t)
8139 (delete-region (point-min) (1- (point))))
8140 (goto-char (point-min))
8142 (set-buffer gnus-original-article-buffer)
8143 (goto-char (point-min))
8144 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8145 (insert-buffer-substring gnus-original-article-buffer 1 e)
8147 (narrow-to-region (point-min) (point))
8148 (article-decode-encoded-words)
8150 (let ((gnus-treat-hide-headers nil)
8151 (gnus-treat-hide-boring-headers nil))
8152 (gnus-delete-wash-type 'headers)
8153 (gnus-treat-article 'head))
8154 (gnus-treat-article 'head)))
8155 (gnus-set-mode-line 'article)))))
8157 (defun gnus-summary-show-all-headers ()
8158 "Make all header lines visible."
8160 (gnus-summary-toggle-header 1))
8162 (defun gnus-summary-caesar-message (&optional arg)
8163 "Caesar rotate the current article by 13.
8164 The numerical prefix specifies how many places to rotate each letter
8167 (gnus-summary-select-article)
8168 (let ((mail-header-separator ""))
8169 (gnus-eval-in-buffer-window gnus-article-buffer
8172 (let ((start (window-start))
8174 (message-caesar-buffer-body arg)
8175 (set-window-start (get-buffer-window (current-buffer)) start))))))
8177 (defun gnus-summary-stop-page-breaking ()
8178 "Stop page breaking in the current article."
8180 (gnus-summary-select-article)
8181 (gnus-eval-in-buffer-window gnus-article-buffer
8183 (when (gnus-visual-p 'page-marker)
8184 (let ((buffer-read-only nil))
8185 (gnus-remove-text-with-property 'gnus-prev)
8186 (gnus-remove-text-with-property 'gnus-next))
8187 (setq gnus-page-broken nil))))
8189 (defun gnus-summary-move-article (&optional n to-newsgroup
8190 select-method action)
8191 "Move the current article to a different newsgroup.
8192 If N is a positive number, move the N next articles.
8193 If N is a negative number, move the N previous articles.
8194 If N is nil and any articles have been marked with the process mark,
8195 move those articles instead.
8196 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8197 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8198 re-spool using this method.
8200 For this function to work, both the current newsgroup and the
8201 newsgroup that you want to move to have to support the `request-move'
8202 and `request-accept' functions.
8204 ACTION can be either `move' (the default), `crosspost' or `copy'."
8207 (setq action 'move))
8208 ;; Check whether the source group supports the required functions.
8209 (cond ((and (eq action 'move)
8210 (not (gnus-check-backend-function
8211 'request-move-article gnus-newsgroup-name)))
8212 (error "The current group does not support article moving"))
8213 ((and (eq action 'crosspost)
8214 (not (gnus-check-backend-function
8215 'request-replace-article gnus-newsgroup-name)))
8216 (error "The current group does not support article editing")))
8217 (let ((articles (gnus-summary-work-articles n))
8218 (prefix (if (gnus-check-backend-function
8219 'request-move-article gnus-newsgroup-name)
8220 (gnus-group-real-prefix gnus-newsgroup-name)
8222 (names '((move "Move" "Moving")
8223 (copy "Copy" "Copying")
8224 (crosspost "Crosspost" "Crossposting")))
8225 (copy-buf (save-excursion
8226 (nnheader-set-temp-buffer " *copy article*")))
8227 art-group to-method new-xref article to-groups)
8228 (unless (assq action names)
8229 (error "Unknown action %s" action))
8230 ;; We have to select an article to give
8231 ;; `gnus-read-move-group-name' an opportunity to suggest an
8232 ;; appropriate default.
8233 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8234 (let ((gnus-display-mime-function nil)
8235 (gnus-article-prepare-hook nil))
8236 (gnus-summary-select-article nil nil nil (car articles))))
8237 ;; Read the newsgroup name.
8238 (when (and (not to-newsgroup)
8239 (not select-method))
8241 (gnus-read-move-group-name
8242 (cadr (assq action names))
8243 (symbol-value (intern (format "gnus-current-%s-group" action)))
8245 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8246 (setq to-method (or select-method
8247 (gnus-server-to-method
8248 (gnus-group-method to-newsgroup))))
8249 ;; Check the method we are to move this article to...
8250 (unless (gnus-check-backend-function
8251 'request-accept-article (car to-method))
8252 (error "%s does not support article copying" (car to-method)))
8253 (unless (gnus-check-server to-method)
8254 (error "Can't open server %s" (car to-method)))
8255 (gnus-message 6 "%s to %s: %s..."
8256 (caddr (assq action names))
8257 (or (car select-method) to-newsgroup) articles)
8259 (setq article (pop articles))
8263 ;; Move the article.
8265 ;; Remove this article from future suppression.
8266 (gnus-dup-unsuppress-article article)
8267 (gnus-request-move-article
8268 article ; Article to move
8269 gnus-newsgroup-name ; From newsgroup
8270 (nth 1 (gnus-find-method-for-group
8271 gnus-newsgroup-name)) ; Server
8272 (list 'gnus-request-accept-article
8273 to-newsgroup (list 'quote select-method)
8274 (not articles) t) ; Accept form
8275 (not articles))) ; Only save nov last time
8276 ;; Copy the article.
8279 (set-buffer copy-buf)
8280 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8281 (gnus-request-accept-article
8282 to-newsgroup select-method (not articles) t))))
8283 ;; Crosspost the article.
8284 ((eq action 'crosspost)
8285 (let ((xref (message-tokenize-header
8286 (mail-header-xref (gnus-summary-article-header article))
8288 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8289 ":" (number-to-string article)))
8291 (setq xref (list (system-name))))
8294 (mapconcat 'identity
8295 (delete "Xref:" (delete new-xref xref))
8299 (set-buffer copy-buf)
8300 ;; First put the article in the destination group.
8301 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8302 (when (consp (setq art-group
8303 (gnus-request-accept-article
8304 to-newsgroup select-method (not articles))))
8305 (setq new-xref (concat new-xref " " (car art-group)
8307 (number-to-string (cdr art-group))))
8308 ;; Now we have the new Xrefs header, so we insert
8309 ;; it and replace the new article.
8310 (nnheader-replace-header "Xref" new-xref)
8311 (gnus-request-replace-article
8312 (cdr art-group) to-newsgroup (current-buffer))
8316 (gnus-message 1 "Couldn't %s article %s: %s"
8317 (cadr (assq action names)) article
8318 (nnheader-get-report (car to-method))))
8319 ((eq art-group 'junk)
8320 (when (eq action 'move)
8321 (gnus-summary-mark-article article gnus-canceled-mark)
8322 (gnus-message 4 "Deleted article %s" article)))
8324 (let* ((pto-group (gnus-group-prefixed-name
8325 (car art-group) to-method))
8327 (gnus-gethash pto-group gnus-newsrc-hashtb))
8328 (info (nth 2 entry))
8329 (to-group (gnus-info-group info))
8331 ;; Update the group that has been moved to.
8333 (memq action '(move copy)))
8334 (unless (member to-group to-groups)
8335 (push to-group to-groups))
8337 (unless (memq article gnus-newsgroup-unreads)
8338 (push 'read to-marks)
8340 info (gnus-add-to-range (gnus-info-read info)
8341 (list (cdr art-group)))))
8343 ;; See whether the article is to be put in the cache.
8344 (let ((marks gnus-article-mark-lists)
8345 (to-article (cdr art-group)))
8347 ;; Enter the article into the cache in the new group,
8348 ;; if that is required.
8349 (when gnus-use-cache
8350 (gnus-cache-possibly-enter-article
8352 (memq article gnus-newsgroup-marked)
8353 (memq article gnus-newsgroup-dormant)
8354 (memq article gnus-newsgroup-unreads)))
8356 (when gnus-preserve-marks
8357 ;; Copy any marks over to the new group.
8358 (when (and (equal to-group gnus-newsgroup-name)
8359 (not (memq article gnus-newsgroup-unreads)))
8360 ;; Mark this article as read in this group.
8361 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8362 (setcdr (gnus-active to-group) to-article)
8363 (setcdr gnus-newsgroup-active to-article))
8366 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8367 (when (memq article (symbol-value
8368 (intern (format "gnus-newsgroup-%s"
8370 (push (cdar marks) to-marks)
8371 ;; If the other group is the same as this group,
8372 ;; then we have to add the mark to the list.
8373 (when (equal to-group gnus-newsgroup-name)
8374 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8377 (intern (format "gnus-newsgroup-%s"
8379 ;; Copy the marks to other group.
8380 (gnus-add-marked-articles
8381 to-group (cdar marks) (list to-article) info)))
8382 (setq marks (cdr marks)))
8384 (gnus-request-set-mark to-group (list (list (list to-article)
8389 (concat "(gnus-group-set-info '"
8390 (gnus-prin1-to-string (gnus-get-info to-group))
8393 ;; Update the Xref header in this article to point to
8394 ;; the new crossposted article we have just created.
8395 (when (eq action 'crosspost)
8397 (set-buffer copy-buf)
8398 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8399 (nnheader-replace-header "Xref" new-xref)
8400 (gnus-request-replace-article
8401 article gnus-newsgroup-name (current-buffer)))))
8403 ;;;!!!Why is this necessary?
8404 (set-buffer gnus-summary-buffer)
8406 (gnus-summary-goto-subject article)
8407 (when (eq action 'move)
8408 (gnus-summary-mark-article article gnus-canceled-mark))))
8409 (gnus-summary-remove-process-mark article))
8410 ;; Re-activate all groups that have been moved to.
8412 (set-buffer gnus-group-buffer)
8413 (let ((gnus-group-marked to-groups))
8414 (gnus-group-get-new-news-this-group nil t)))
8416 (gnus-kill-buffer copy-buf)
8417 (gnus-summary-position-point)
8418 (gnus-set-mode-line 'summary)))
8420 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8421 "Move the current article to a different newsgroup.
8422 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8423 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8424 re-spool using this method."
8426 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8428 (defun gnus-summary-crosspost-article (&optional n)
8429 "Crosspost the current article to some other group."
8431 (gnus-summary-move-article n nil nil 'crosspost))
8433 (defcustom gnus-summary-respool-default-method nil
8434 "Default method type for respooling an article.
8435 If nil, use to the current newsgroup method."
8437 :group 'gnus-summary-mail)
8439 (defun gnus-summary-respool-article (&optional n method)
8440 "Respool the current article.
8441 The article will be squeezed through the mail spooling process again,
8442 which means that it will be put in some mail newsgroup or other
8443 depending on `nnmail-split-methods'.
8444 If N is a positive number, respool the N next articles.
8445 If N is a negative number, respool the N previous articles.
8446 If N is nil and any articles have been marked with the process mark,
8447 respool those articles instead.
8449 Respooling can be done both from mail groups and \"real\" newsgroups.
8450 In the former case, the articles in question will be moved from the
8451 current group into whatever groups they are destined to. In the
8452 latter case, they will be copied into the relevant groups."
8454 (list current-prefix-arg
8455 (let* ((methods (gnus-methods-using 'respool))
8457 (symbol-name (or gnus-summary-respool-default-method
8458 (car (gnus-find-method-for-group
8459 gnus-newsgroup-name)))))
8461 (gnus-completing-read-with-default
8462 methname "What backend do you want to use when respooling?"
8463 methods nil t nil 'gnus-mail-method-history))
8466 ((zerop (length (setq ms (gnus-servers-using-backend
8468 (list (intern method) ""))
8472 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8473 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8476 (error "No method given for respooling"))
8477 (if (assoc (symbol-name
8478 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8479 (gnus-methods-using 'respool))
8480 (gnus-summary-move-article n nil method)
8481 (gnus-summary-copy-article n nil method)))
8483 (defun gnus-summary-import-article (file &optional edit)
8484 "Import an arbitrary file into a mail newsgroup."
8485 (interactive "fImport file: \nP")
8486 (let ((group gnus-newsgroup-name)
8487 (now (current-time))
8488 atts lines group-art)
8489 (unless (gnus-check-backend-function 'request-accept-article group)
8490 (error "%s does not support article importing" group))
8491 (or (file-readable-p file)
8492 (not (file-regular-p file))
8493 (error "Can't read %s" file))
8495 (set-buffer (gnus-get-buffer-create " *import file*"))
8497 (nnheader-insert-file-contents file)
8498 (goto-char (point-min))
8499 (if (nnheader-article-p)
8501 (goto-char (point-min))
8502 (search-forward "\n\n" nil t)
8503 (narrow-to-region (point-min) (1- (point)))
8504 (goto-char (point-min))
8505 (unless (re-search-forward "^date:" nil t)
8506 (goto-char (point-max))
8507 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8508 ;; This doesn't look like an article, so we fudge some headers.
8509 (setq atts (file-attributes file)
8510 lines (count-lines (point-min) (point-max)))
8511 (insert "From: " (read-string "From: ") "\n"
8512 "Subject: " (read-string "Subject: ") "\n"
8513 "Date: " (message-make-date (nth 5 atts)) "\n"
8514 "Message-ID: " (message-make-message-id) "\n"
8515 "Lines: " (int-to-string lines) "\n"
8516 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8517 (setq group-art (gnus-request-accept-article group nil t))
8518 (kill-buffer (current-buffer)))
8519 (setq gnus-newsgroup-active (gnus-activate-group group))
8521 (gnus-summary-goto-article (cdr group-art) nil t)
8523 (gnus-summary-edit-article))))
8525 (defun gnus-summary-create-article ()
8526 "Create an article in a mail newsgroup."
8528 (let ((group gnus-newsgroup-name)
8529 (now (current-time))
8531 (unless (gnus-check-backend-function 'request-accept-article group)
8532 (error "%s does not support article importing" group))
8534 (set-buffer (gnus-get-buffer-create " *import file*"))
8536 (goto-char (point-min))
8537 ;; This doesn't look like an article, so we fudge some headers.
8538 (insert "From: " (read-string "From: ") "\n"
8539 "Subject: " (read-string "Subject: ") "\n"
8540 "Date: " (message-make-date now) "\n"
8541 "Message-ID: " (message-make-message-id) "\n")
8542 (setq group-art (gnus-request-accept-article group nil t))
8543 (kill-buffer (current-buffer)))
8544 (setq gnus-newsgroup-active (gnus-activate-group group))
8546 (gnus-summary-goto-article (cdr group-art) nil t)
8547 (gnus-summary-edit-article)))
8549 (defun gnus-summary-article-posted-p ()
8550 "Say whether the current (mail) article is available from news as well.
8551 This will be the case if the article has both been mailed and posted."
8553 (let ((id (mail-header-references (gnus-summary-article-header)))
8554 (gnus-override-method (car (gnus-refer-article-methods))))
8555 (if (gnus-request-head id "")
8556 (gnus-message 2 "The current message was found on %s"
8557 gnus-override-method)
8558 (gnus-message 2 "The current message couldn't be found on %s"
8559 gnus-override-method)
8562 (defun gnus-summary-expire-articles (&optional now)
8563 "Expire all articles that are marked as expirable in the current group."
8565 (when (gnus-check-backend-function
8566 'request-expire-articles gnus-newsgroup-name)
8567 ;; This backend supports expiry.
8568 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8569 (expirable (if total
8571 ;; We need to update the info for
8572 ;; this group for `gnus-list-of-read-articles'
8573 ;; to give us the right answer.
8574 (gnus-run-hooks 'gnus-exit-group-hook)
8575 (gnus-summary-update-info)
8576 (gnus-list-of-read-articles gnus-newsgroup-name))
8577 (setq gnus-newsgroup-expirable
8578 (sort gnus-newsgroup-expirable '<))))
8579 (expiry-wait (if now 'immediate
8580 (gnus-group-find-parameter
8581 gnus-newsgroup-name 'expiry-wait)))
8582 (nnmail-expiry-target
8583 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8584 nnmail-expiry-target))
8587 ;; There are expirable articles in this group, so we run them
8588 ;; through the expiry process.
8589 (gnus-message 6 "Expiring articles...")
8590 (unless (gnus-check-group gnus-newsgroup-name)
8591 (error "Can't open server for %s" gnus-newsgroup-name))
8592 ;; The list of articles that weren't expired is returned.
8595 (let ((nnmail-expiry-wait-function nil)
8596 (nnmail-expiry-wait expiry-wait))
8597 (setq es (gnus-request-expire-articles
8598 expirable gnus-newsgroup-name)))
8599 (setq es (gnus-request-expire-articles
8600 expirable gnus-newsgroup-name)))
8602 (setq gnus-newsgroup-expirable es))
8603 ;; We go through the old list of expirable, and mark all
8604 ;; really expired articles as nonexistent.
8605 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8606 (let ((gnus-use-cache nil))
8608 (unless (memq (car expirable) es)
8609 (when (gnus-data-find (car expirable))
8610 (gnus-summary-mark-article
8611 (car expirable) gnus-canceled-mark)))
8612 (setq expirable (cdr expirable))))))
8613 (gnus-message 6 "Expiring articles...done")))))
8615 (defun gnus-summary-expire-articles-now ()
8616 "Expunge all expirable articles in the current group.
8617 This means that *all* articles that are marked as expirable will be
8618 deleted forever, right now."
8620 (or gnus-expert-user
8622 "Are you really, really, really sure you want to delete all these messages? ")
8624 (gnus-summary-expire-articles t))
8626 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8627 (defun gnus-summary-delete-article (&optional n)
8628 "Delete the N next (mail) articles.
8629 This command actually deletes articles. This is not a marking
8630 command. The article will disappear forever from your life, never to
8632 If N is negative, delete backwards.
8633 If N is nil and articles have been marked with the process mark,
8634 delete these instead."
8636 (unless (gnus-check-backend-function 'request-expire-articles
8637 gnus-newsgroup-name)
8638 (error "The current newsgroup does not support article deletion"))
8639 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8640 (error "Couldn't open server"))
8641 ;; Compute the list of articles to delete.
8642 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8644 (if (and gnus-novice-user
8645 (not (gnus-yes-or-no-p
8646 (format "Do you really want to delete %s forever? "
8647 (if (> (length articles) 1)
8648 (format "these %s articles" (length articles))
8651 ;; Delete the articles.
8652 (setq not-deleted (gnus-request-expire-articles
8653 articles gnus-newsgroup-name 'force))
8655 (gnus-summary-remove-process-mark (car articles))
8656 ;; The backend might not have been able to delete the article
8658 (unless (memq (car articles) not-deleted)
8659 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8660 (setq articles (cdr articles)))
8662 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8663 (gnus-summary-position-point)
8664 (gnus-set-mode-line 'summary)
8667 (defun gnus-summary-edit-article (&optional arg)
8668 "Edit the current article.
8669 This will have permanent effect only in mail groups.
8670 If ARG is nil, edit the decoded articles.
8671 If ARG is 1, edit the raw articles.
8672 If ARG is 2, edit the raw articles even in read-only groups.
8673 If ARG is 3, edit the articles with the current handles.
8674 Otherwise, allow editing of articles even in read-only
8677 (let (force raw current-handles)
8686 (setq current-handles
8687 (and (gnus-buffer-live-p gnus-article-buffer)
8688 (with-current-buffer gnus-article-buffer
8690 gnus-article-mime-handles
8691 (setq gnus-article-mime-handles nil))))))
8694 (when (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8695 (error "Can't edit the raw article in group nndraft:drafts"))
8697 (set-buffer gnus-summary-buffer)
8698 (let ((mail-parse-charset gnus-newsgroup-charset)
8699 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8700 (gnus-set-global-variables)
8701 (when (and (not force)
8702 (gnus-group-read-only-p))
8703 (error "The current newsgroup does not support article editing"))
8704 (gnus-summary-show-article t)
8705 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8706 (with-current-buffer gnus-article-buffer
8707 (mm-enable-multibyte)))
8708 (if (equal gnus-newsgroup-name "nndraft:drafts")
8710 (gnus-article-edit-article
8713 (let ((mbl mml-buffer-list))
8714 (setq mml-buffer-list nil)
8715 (mime-to-mml ,'current-handles)
8716 (let ((mbl1 mml-buffer-list))
8717 (setq mml-buffer-list mbl)
8718 (set (make-local-variable 'mml-buffer-list) mbl1))
8719 (make-local-hook 'kill-buffer-hook)
8720 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8721 `(lambda (no-highlight)
8722 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8723 (message-options message-options)
8724 (message-options-set-recipient)
8725 (mail-parse-ignored-charsets
8726 ',gnus-newsgroup-ignored-charsets))
8727 ,(if (not raw) '(progn
8729 (mml-destroy-buffers)
8730 (remove-hook 'kill-buffer-hook
8731 'mml-destroy-buffers t)
8732 (kill-local-variable 'mml-buffer-list)))
8733 (gnus-summary-edit-article-done
8734 ,(or (mail-header-references gnus-current-headers) "")
8735 ,(gnus-group-read-only-p)
8736 ,gnus-summary-buffer no-highlight))))))))
8738 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8740 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8742 "Make edits to the current article permanent."
8745 ;; The buffer restriction contains the entire article if it exists.
8746 (when (article-goto-body)
8747 (let ((lines (count-lines (point) (point-max)))
8748 (length (- (point-max) (point)))
8749 (case-fold-search t)
8750 (body (copy-marker (point))))
8751 (goto-char (point-min))
8752 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8753 (delete-region (match-beginning 1) (match-end 1))
8754 (insert (number-to-string length)))
8755 (goto-char (point-min))
8756 (when (re-search-forward
8757 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8758 (delete-region (match-beginning 1) (match-end 1))
8759 (insert (number-to-string length)))
8760 (goto-char (point-min))
8761 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8762 (delete-region (match-beginning 1) (match-end 1))
8763 (insert (number-to-string lines))))))
8764 ;; Replace the article.
8765 (let ((buf (current-buffer)))
8767 (insert-buffer-substring buf)
8769 (if (and (not read-only)
8770 (not (gnus-request-replace-article
8771 (cdr gnus-article-current) (car gnus-article-current)
8772 (current-buffer) t)))
8773 (error "Couldn't replace article")
8774 ;; Update the summary buffer.
8776 (equal (message-tokenize-header references " ")
8777 (message-tokenize-header
8778 (or (message-fetch-field "references") "") " ")))
8779 ;; We only have to update this line.
8782 (message-narrow-to-head)
8783 (let ((head (buffer-string))
8786 (insert (format "211 %d Article retrieved.\n"
8787 (cdr gnus-article-current)))
8790 (let ((nntp-server-buffer (current-buffer)))
8791 (setq header (car (gnus-get-newsgroup-headers
8793 (set-buffer gnus-summary-buffer)
8794 gnus-newsgroup-dependencies)
8797 (set-buffer gnus-summary-buffer)
8798 (gnus-data-set-header
8799 (gnus-data-find (cdr gnus-article-current))
8801 (gnus-summary-update-article-line
8802 (cdr gnus-article-current) header)
8803 (if (gnus-summary-goto-subject
8804 (cdr gnus-article-current) nil t)
8805 (gnus-summary-update-secondary-mark
8806 (cdr gnus-article-current))))))))
8808 (set-buffer (or buffer gnus-summary-buffer))
8809 (gnus-summary-update-article (cdr gnus-article-current))
8810 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8811 (gnus-summary-update-secondary-mark
8812 (cdr gnus-article-current))))
8813 ;; Prettify the article buffer again.
8814 (unless no-highlight
8816 (set-buffer gnus-article-buffer)
8817 ;;;!!! Fix this -- article should be rehighlighted.
8818 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8819 (set-buffer gnus-original-article-buffer)
8820 (gnus-request-article
8821 (cdr gnus-article-current)
8822 (car gnus-article-current) (current-buffer))))
8823 ;; Prettify the summary buffer line.
8824 (when (gnus-visual-p 'summary-highlight 'highlight)
8825 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8827 (defun gnus-summary-edit-wash (key)
8828 "Perform editing command KEY in the article buffer."
8832 (message "%s" (concat (this-command-keys) "- "))
8835 (gnus-summary-edit-article)
8836 (execute-kbd-macro (concat (this-command-keys) key))
8837 (gnus-article-edit-done))
8841 (defun gnus-summary-respool-query (&optional silent trace)
8842 "Query where the respool algorithm would put this article."
8844 (let (gnus-mark-article-hook)
8845 (gnus-summary-select-article)
8847 (set-buffer gnus-original-article-buffer)
8849 (message-narrow-to-head)
8850 (let ((groups (nnmail-article-group 'identity trace)))
8853 (message "This message would go to %s"
8854 (mapconcat 'car groups ", "))
8855 (message "This message would go to no groups"))
8858 (defun gnus-summary-respool-trace ()
8859 "Trace where the respool algorithm would put this article.
8860 Display a buffer showing all fancy splitting patterns which matched."
8862 (gnus-summary-respool-query nil t))
8864 ;; Summary marking commands.
8866 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8867 "Mark articles which has the same subject as read, and then select the next.
8868 If UNMARK is positive, remove any kind of mark.
8869 If UNMARK is negative, tick articles."
8872 (setq unmark (prefix-numeric-value unmark)))
8874 (gnus-summary-mark-same-subject
8875 (gnus-summary-article-subject) unmark)))
8876 ;; Select next unread article. If auto-select-same mode, should
8877 ;; select the first unread article.
8878 (gnus-summary-next-article t (and gnus-auto-select-same
8879 (gnus-summary-article-subject)))
8880 (gnus-message 7 "%d article%s marked as %s"
8881 count (if (= count 1) " is" "s are")
8882 (if unmark "unread" "read"))))
8884 (defun gnus-summary-kill-same-subject (&optional unmark)
8885 "Mark articles which has the same subject as read.
8886 If UNMARK is positive, remove any kind of mark.
8887 If UNMARK is negative, tick articles."
8890 (setq unmark (prefix-numeric-value unmark)))
8892 (gnus-summary-mark-same-subject
8893 (gnus-summary-article-subject) unmark)))
8894 ;; If marked as read, go to next unread subject.
8896 ;; Go to next unread subject.
8897 (gnus-summary-next-subject 1 t))
8898 (gnus-message 7 "%d articles are marked as %s"
8899 count (if unmark "unread" "read"))))
8901 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8902 "Mark articles with same SUBJECT as read, and return marked number.
8903 If optional argument UNMARK is positive, remove any kinds of marks.
8904 If optional argument UNMARK is negative, mark articles as unread instead."
8908 ((null unmark) ; Mark as read.
8911 (gnus-summary-mark-article-as-read gnus-killed-mark)
8912 (gnus-summary-show-thread) t)
8913 (gnus-summary-find-subject subject))
8914 (setq count (1+ count))))
8915 ((> unmark 0) ; Tick.
8918 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8919 (gnus-summary-show-thread) t)
8920 (gnus-summary-find-subject subject))
8921 (setq count (1+ count))))
8922 (t ; Mark as unread.
8925 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8926 (gnus-summary-show-thread) t)
8927 (gnus-summary-find-subject subject))
8928 (setq count (1+ count)))))
8929 (gnus-set-mode-line 'summary)
8930 ;; Return the number of marked articles.
8933 (defun gnus-summary-mark-as-processable (n &optional unmark)
8934 "Set the process mark on the next N articles.
8935 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8936 the process mark instead. The difference between N and the actual
8937 number of articles marked is returned."
8939 (if (and (null n) (gnus-region-active-p))
8940 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8941 (setq n (prefix-numeric-value n))
8942 (let ((backward (< n 0))
8947 (gnus-summary-remove-process-mark
8948 (gnus-summary-article-number))
8949 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8950 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8953 (gnus-message 7 "No more articles"))
8954 (gnus-summary-recenter)
8955 (gnus-summary-position-point)
8958 (defun gnus-summary-unmark-as-processable (n)
8959 "Remove the process mark from the next N articles.
8960 If N is negative, unmark backward instead. The difference between N and
8961 the actual number of articles unmarked is returned."
8963 (gnus-summary-mark-as-processable n t))
8965 (defun gnus-summary-unmark-all-processable ()
8966 "Remove the process mark from all articles."
8969 (while gnus-newsgroup-processable
8970 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8971 (gnus-summary-position-point))
8973 (defun gnus-summary-add-mark (article type)
8974 "Mark ARTICLE with a mark of TYPE."
8975 (let ((vtype (car (assq type gnus-article-mark-lists)))
8978 (error "No such mark type: %s" type)
8979 (setq var (intern (format "gnus-newsgroup-%s" type)))
8980 (set var (cons article (symbol-value var)))
8981 (if (memq type '(processable cached replied forwarded recent saved))
8982 (gnus-summary-update-secondary-mark article)
8983 ;;; !!! This is bogus. We should find out what primary
8984 ;;; !!! mark we want to set.
8985 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8987 (defun gnus-summary-mark-as-expirable (n)
8988 "Mark N articles forward as expirable.
8989 If N is negative, mark backward instead. The difference between N and
8990 the actual number of articles marked is returned."
8992 (gnus-summary-mark-forward n gnus-expirable-mark))
8994 (defun gnus-summary-mark-article-as-replied (article)
8995 "Mark ARTICLE as replied to and update the summary line.
8996 ARTICLE can also be a list of articles."
8997 (interactive (list (gnus-summary-article-number)))
8998 (let ((articles (if (listp article) article (list article))))
8999 (dolist (article articles)
9000 (push article gnus-newsgroup-replied)
9001 (let ((buffer-read-only nil))
9002 (when (gnus-summary-goto-subject article nil t)
9003 (gnus-summary-update-secondary-mark article))))))
9005 (defun gnus-summary-mark-article-as-forwarded (article)
9006 "Mark ARTICLE as forwarded and update the summary line.
9007 ARTICLE can also be a list of articles."
9008 (let ((articles (if (listp article) article (list article))))
9009 (dolist (article articles)
9010 (push article gnus-newsgroup-forwarded)
9011 (let ((buffer-read-only nil))
9012 (when (gnus-summary-goto-subject article nil t)
9013 (gnus-summary-update-secondary-mark article))))))
9015 (defun gnus-summary-set-bookmark (article)
9016 "Set a bookmark in current article."
9017 (interactive (list (gnus-summary-article-number)))
9018 (when (or (not (get-buffer gnus-article-buffer))
9019 (not gnus-current-article)
9020 (not gnus-article-current)
9021 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9022 (error "No current article selected"))
9023 ;; Remove old bookmark, if one exists.
9024 (let ((old (assq article gnus-newsgroup-bookmarks)))
9026 (setq gnus-newsgroup-bookmarks
9027 (delq old gnus-newsgroup-bookmarks))))
9028 ;; Set the new bookmark, which is on the form
9029 ;; (article-number . line-number-in-body).
9033 (set-buffer gnus-article-buffer)
9037 (goto-char (point-min))
9038 (search-forward "\n\n" nil t)
9041 gnus-newsgroup-bookmarks)
9042 (gnus-message 6 "A bookmark has been added to the current article."))
9044 (defun gnus-summary-remove-bookmark (article)
9045 "Remove the bookmark from the current article."
9046 (interactive (list (gnus-summary-article-number)))
9047 ;; Remove old bookmark, if one exists.
9048 (let ((old (assq article gnus-newsgroup-bookmarks)))
9051 (setq gnus-newsgroup-bookmarks
9052 (delq old gnus-newsgroup-bookmarks))
9053 (gnus-message 6 "Removed bookmark."))
9054 (gnus-message 6 "No bookmark in current article."))))
9056 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9057 (defun gnus-summary-mark-as-dormant (n)
9058 "Mark N articles forward as dormant.
9059 If N is negative, mark backward instead. The difference between N and
9060 the actual number of articles marked is returned."
9062 (gnus-summary-mark-forward n gnus-dormant-mark))
9064 (defun gnus-summary-set-process-mark (article)
9065 "Set the process mark on ARTICLE and update the summary line."
9066 (setq gnus-newsgroup-processable
9068 (delq article gnus-newsgroup-processable)))
9069 (when (gnus-summary-goto-subject article)
9070 (gnus-summary-show-thread)
9071 (gnus-summary-goto-subject article)
9072 (gnus-summary-update-secondary-mark article)))
9074 (defun gnus-summary-remove-process-mark (article)
9075 "Remove the process mark from ARTICLE and update the summary line."
9076 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9077 (when (gnus-summary-goto-subject article)
9078 (gnus-summary-show-thread)
9079 (gnus-summary-goto-subject article)
9080 (gnus-summary-update-secondary-mark article)))
9082 (defun gnus-summary-set-saved-mark (article)
9083 "Set the process mark on ARTICLE and update the summary line."
9084 (push article gnus-newsgroup-saved)
9085 (when (gnus-summary-goto-subject article)
9086 (gnus-summary-update-secondary-mark article)))
9088 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9089 "Mark N articles as read forwards.
9090 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9091 The difference between N and the actual number of articles marked is
9093 Iff NO-EXPIRE, auto-expiry will be inhibited."
9095 (gnus-summary-show-thread)
9096 (let ((backward (< n 0))
9097 (gnus-summary-goto-unread
9098 (and gnus-summary-goto-unread
9099 (not (eq gnus-summary-goto-unread 'never))
9100 (not (memq mark (list gnus-unread-mark
9101 gnus-ticked-mark gnus-dormant-mark)))))
9103 (mark (or mark gnus-del-mark)))
9105 (gnus-summary-mark-article nil mark no-expire)
9106 (zerop (gnus-summary-next-subject
9108 (and gnus-summary-goto-unread
9109 (not (eq gnus-summary-goto-unread 'never)))
9113 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9114 (gnus-summary-recenter)
9115 (gnus-summary-position-point)
9116 (gnus-set-mode-line 'summary)
9119 (defun gnus-summary-mark-article-as-read (mark)
9120 "Mark the current article quickly as read with MARK."
9121 (let ((article (gnus-summary-article-number)))
9122 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9123 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9124 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9125 (push (cons article mark) gnus-newsgroup-reads)
9126 ;; Possibly remove from cache, if that is used.
9127 (when gnus-use-cache
9128 (gnus-cache-enter-remove-article article))
9129 ;; Allow the backend to change the mark.
9130 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9131 ;; Check for auto-expiry.
9132 (when (and gnus-newsgroup-auto-expire
9133 (memq mark gnus-auto-expirable-marks))
9134 (setq mark gnus-expirable-mark)
9135 ;; Let the backend know about the mark change.
9136 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9137 (push article gnus-newsgroup-expirable))
9138 ;; Set the mark in the buffer.
9139 (gnus-summary-update-mark mark 'unread)
9142 (defun gnus-summary-mark-article-as-unread (mark)
9143 "Mark the current article quickly as unread with MARK."
9144 (let* ((article (gnus-summary-article-number))
9145 (old-mark (gnus-summary-article-mark article)))
9146 ;; Allow the backend to change the mark.
9147 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9148 (if (eq mark old-mark)
9152 (gnus-error 1 "Can't mark negative article numbers")
9154 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9155 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9156 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9157 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9158 (cond ((= mark gnus-ticked-mark)
9159 (push article gnus-newsgroup-marked))
9160 ((= mark gnus-dormant-mark)
9161 (push article gnus-newsgroup-dormant))
9163 (push article gnus-newsgroup-unreads)))
9164 (gnus-pull article gnus-newsgroup-reads)
9166 ;; See whether the article is to be put in the cache.
9168 (vectorp (gnus-summary-article-header article))
9170 (gnus-cache-possibly-enter-article
9171 gnus-newsgroup-name article
9172 (= mark gnus-ticked-mark)
9173 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9176 (gnus-summary-update-mark mark 'unread)
9179 (defun gnus-summary-mark-article (&optional article mark no-expire)
9180 "Mark ARTICLE with MARK. MARK can be any character.
9181 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9182 `??' (dormant) and `?E' (expirable).
9183 If MARK is nil, then the default character `?r' is used.
9184 If ARTICLE is nil, then the article on the current line will be
9186 Iff NO-EXPIRE, auto-expiry will be inhibited."
9187 ;; The mark might be a string.
9188 (when (stringp mark)
9189 (setq mark (aref mark 0)))
9190 ;; If no mark is given, then we check auto-expiring.
9192 (setq mark gnus-del-mark))
9193 (when (and (not no-expire)
9194 gnus-newsgroup-auto-expire
9195 (memq mark gnus-auto-expirable-marks))
9196 (setq mark gnus-expirable-mark))
9197 (let ((article (or article (gnus-summary-article-number)))
9198 (old-mark (gnus-summary-article-mark article)))
9199 ;; Allow the backend to change the mark.
9200 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9201 (if (eq mark old-mark)
9204 (error "No article on current line"))
9205 (if (not (if (or (= mark gnus-unread-mark)
9206 (= mark gnus-ticked-mark)
9207 (= mark gnus-dormant-mark))
9208 (gnus-mark-article-as-unread article mark)
9209 (gnus-mark-article-as-read article mark)))
9211 ;; See whether the article is to be put in the cache.
9213 (not (= mark gnus-canceled-mark))
9214 (vectorp (gnus-summary-article-header article))
9216 (gnus-cache-possibly-enter-article
9217 gnus-newsgroup-name article
9218 (= mark gnus-ticked-mark)
9219 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9221 (when (gnus-summary-goto-subject article nil t)
9222 (let ((buffer-read-only nil))
9223 (gnus-summary-show-thread)
9225 (gnus-summary-update-mark mark 'unread)
9228 (defun gnus-summary-update-secondary-mark (article)
9229 "Update the secondary (read, process, cache) mark."
9230 (gnus-summary-update-mark
9231 (cond ((memq article gnus-newsgroup-processable)
9233 ((memq article gnus-newsgroup-cached)
9235 ((memq article gnus-newsgroup-replied)
9237 ((memq article gnus-newsgroup-forwarded)
9238 gnus-forwarded-mark)
9239 ((memq article gnus-newsgroup-saved)
9241 ((memq article gnus-newsgroup-recent)
9243 ((memq article gnus-newsgroup-unseen)
9247 (when (gnus-visual-p 'summary-highlight 'highlight)
9248 (gnus-run-hooks 'gnus-summary-update-hook))
9251 (defun gnus-summary-update-mark (mark type)
9252 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9253 (buffer-read-only nil))
9254 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9256 (when (looking-at "\r")
9258 (when (<= (+ forward (point)) (point-max))
9259 ;; Go to the right position on the line.
9260 (goto-char (+ forward (point)))
9261 ;; Replace the old mark with the new mark.
9262 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9263 ;; Optionally update the marks by some user rule.
9264 (when (eq type 'unread)
9266 (gnus-data-find (gnus-summary-article-number)) mark)
9267 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9269 (defun gnus-mark-article-as-read (article &optional mark)
9270 "Enter ARTICLE in the pertinent lists and remove it from others."
9271 ;; Make the article expirable.
9272 (let ((mark (or mark gnus-del-mark)))
9273 (if (= mark gnus-expirable-mark)
9274 (push article gnus-newsgroup-expirable)
9275 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9276 ;; Remove from unread and marked lists.
9277 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9278 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9279 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9280 (push (cons article mark) gnus-newsgroup-reads)
9281 ;; Possibly remove from cache, if that is used.
9282 (when gnus-use-cache
9283 (gnus-cache-enter-remove-article article))
9286 (defun gnus-mark-article-as-unread (article &optional mark)
9287 "Enter ARTICLE in the pertinent lists and remove it from others."
9288 (let ((mark (or mark gnus-ticked-mark)))
9291 (gnus-error 1 "Can't mark negative article numbers")
9293 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9294 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9295 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9296 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9298 ;; Unsuppress duplicates?
9299 (when gnus-suppress-duplicates
9300 (gnus-dup-unsuppress-article article))
9302 (cond ((= mark gnus-ticked-mark)
9303 (push article gnus-newsgroup-marked))
9304 ((= mark gnus-dormant-mark)
9305 (push article gnus-newsgroup-dormant))
9307 (push article gnus-newsgroup-unreads)))
9308 (gnus-pull article gnus-newsgroup-reads)
9311 (defalias 'gnus-summary-mark-as-unread-forward
9312 'gnus-summary-tick-article-forward)
9313 (make-obsolete 'gnus-summary-mark-as-unread-forward
9314 'gnus-summary-tick-article-forward)
9315 (defun gnus-summary-tick-article-forward (n)
9316 "Tick N articles forwards.
9317 If N is negative, tick backwards instead.
9318 The difference between N and the number of articles ticked is returned."
9320 (gnus-summary-mark-forward n gnus-ticked-mark))
9322 (defalias 'gnus-summary-mark-as-unread-backward
9323 'gnus-summary-tick-article-backward)
9324 (make-obsolete 'gnus-summary-mark-as-unread-backward
9325 'gnus-summary-tick-article-backward)
9326 (defun gnus-summary-tick-article-backward (n)
9327 "Tick N articles backwards.
9328 The difference between N and the number of articles ticked is returned."
9330 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9332 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9333 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9334 (defun gnus-summary-tick-article (&optional article clear-mark)
9335 "Mark current article as unread.
9336 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9337 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9339 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9342 (defun gnus-summary-mark-as-read-forward (n)
9343 "Mark N articles as read forwards.
9344 If N is negative, mark backwards instead.
9345 The difference between N and the actual number of articles marked is
9348 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9350 (defun gnus-summary-mark-as-read-backward (n)
9351 "Mark the N articles as read backwards.
9352 The difference between N and the actual number of articles marked is
9355 (gnus-summary-mark-forward
9356 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9358 (defun gnus-summary-mark-as-read (&optional article mark)
9359 "Mark current article as read.
9360 ARTICLE specifies the article to be marked as read.
9361 MARK specifies a string to be inserted at the beginning of the line."
9362 (gnus-summary-mark-article article mark))
9364 (defun gnus-summary-clear-mark-forward (n)
9365 "Clear marks from N articles forward.
9366 If N is negative, clear backward instead.
9367 The difference between N and the number of marks cleared is returned."
9369 (gnus-summary-mark-forward n gnus-unread-mark))
9371 (defun gnus-summary-clear-mark-backward (n)
9372 "Clear marks from N articles backward.
9373 The difference between N and the number of marks cleared is returned."
9375 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9377 (defun gnus-summary-mark-unread-as-read ()
9378 "Intended to be used by `gnus-summary-mark-article-hook'."
9379 (when (memq gnus-current-article gnus-newsgroup-unreads)
9380 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9382 (defun gnus-summary-mark-read-and-unread-as-read ()
9383 "Intended to be used by `gnus-summary-mark-article-hook'."
9384 (let ((mark (gnus-summary-article-mark)))
9385 (when (or (gnus-unread-mark-p mark)
9386 (gnus-read-mark-p mark))
9387 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9389 (defun gnus-summary-mark-unread-as-ticked ()
9390 "Intended to be used by `gnus-summary-mark-article-hook'."
9391 (when (memq gnus-current-article gnus-newsgroup-unreads)
9392 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9394 (defun gnus-summary-mark-region-as-read (point mark all)
9395 "Mark all unread articles between point and mark as read.
9396 If given a prefix, mark all articles between point and mark as read,
9397 even ticked and dormant ones."
9398 (interactive "r\nP")
9407 (memq (setq article (gnus-summary-article-number))
9408 gnus-newsgroup-unreads))
9409 (gnus-summary-mark-article article gnus-del-mark))
9411 (gnus-summary-find-next))))))
9413 (defun gnus-summary-mark-below (score mark)
9414 "Mark articles with score less than SCORE with MARK."
9415 (interactive "P\ncMark: ")
9416 (setq score (if score
9417 (prefix-numeric-value score)
9418 (or gnus-summary-default-score 0)))
9420 (set-buffer gnus-summary-buffer)
9421 (goto-char (point-min))
9424 (and (< (gnus-summary-article-score) score)
9425 (gnus-summary-mark-article nil mark))
9426 (gnus-summary-find-next)))))
9428 (defun gnus-summary-kill-below (&optional score)
9429 "Mark articles with score below SCORE as read."
9431 (gnus-summary-mark-below score gnus-killed-mark))
9433 (defun gnus-summary-clear-above (&optional score)
9434 "Clear all marks from articles with score above SCORE."
9436 (gnus-summary-mark-above score gnus-unread-mark))
9438 (defun gnus-summary-tick-above (&optional score)
9439 "Tick all articles with score above SCORE."
9441 (gnus-summary-mark-above score gnus-ticked-mark))
9443 (defun gnus-summary-mark-above (score mark)
9444 "Mark articles with score over SCORE with MARK."
9445 (interactive "P\ncMark: ")
9446 (setq score (if score
9447 (prefix-numeric-value score)
9448 (or gnus-summary-default-score 0)))
9450 (set-buffer gnus-summary-buffer)
9451 (goto-char (point-min))
9453 (when (> (gnus-summary-article-score) score)
9454 (gnus-summary-mark-article nil mark))
9456 (gnus-summary-find-next)))))
9458 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9459 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9460 (defun gnus-summary-limit-include-expunged (&optional no-error)
9461 "Display all the hidden articles that were expunged for low scores."
9463 (let ((buffer-read-only nil))
9464 (let ((scored gnus-newsgroup-scored)
9467 (unless (gnus-summary-article-header (caar scored))
9468 (and (setq h (gnus-number-to-header (caar scored)))
9469 (< (cdar scored) gnus-summary-expunge-below)
9471 (setq scored (cdr scored)))
9473 (when (not no-error)
9474 (error "No expunged articles hidden"))
9475 (goto-char (point-min))
9476 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9477 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9478 (mapcar (lambda (x) (push (mail-header-number x)
9479 gnus-newsgroup-limit))
9481 (gnus-summary-prepare-unthreaded (nreverse headers))
9482 (goto-char (point-min))
9483 (gnus-summary-position-point)
9486 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9487 "Mark all unread articles in this newsgroup as read.
9488 If prefix argument ALL is non-nil, ticked and dormant articles will
9489 also be marked as read.
9490 If QUIETLY is non-nil, no questions will be asked.
9491 If TO-HERE is non-nil, it should be a point in the buffer. All
9492 articles before (after, if REVERSE is set) this point will be marked as read.
9493 Note that this function will only catch up the unread article
9494 in the current summary buffer limitation.
9495 The number of articles marked as read is returned."
9500 (not gnus-interactive-catchup) ;Without confirmation?
9504 "Mark absolutely all articles as read? "
9505 "Mark all unread articles as read? ")))
9507 (not gnus-newsgroup-adaptive)
9508 (not gnus-newsgroup-auto-expire)
9509 (not gnus-suppress-duplicates)
9510 (or (not gnus-use-cache)
9511 (eq gnus-use-cache 'passive)))
9514 (setq gnus-newsgroup-marked nil
9515 gnus-newsgroup-dormant nil))
9516 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9517 ;; We actually mark all articles as canceled, which we
9518 ;; have to do when using auto-expiry or adaptive scoring.
9519 (gnus-summary-show-all-threads)
9520 (if (and to-here reverse)
9524 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9525 (gnus-summary-find-next (not all) nil nil t))))
9526 (when (gnus-summary-first-subject (not all) t)
9528 (if to-here (< (point) to-here) t)
9529 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9530 (gnus-summary-find-next (not all) nil nil t)))))
9531 (gnus-set-mode-line 'summary))
9533 (gnus-summary-position-point)))
9535 (defun gnus-summary-catchup-to-here (&optional all)
9536 "Mark all unticked articles before the current one as read.
9537 If ALL is non-nil, also mark ticked and dormant articles as read."
9540 (gnus-save-hidden-threads
9541 (let ((beg (point)))
9542 ;; We check that there are unread articles.
9543 (when (or all (gnus-summary-find-prev))
9544 (gnus-summary-catchup all t beg)))))
9545 (gnus-summary-position-point))
9547 (defun gnus-summary-catchup-from-here (&optional all)
9548 "Mark all unticked articles after the current one as read.
9549 If ALL is non-nil, also mark ticked and dormant articles as read."
9552 (gnus-save-hidden-threads
9553 (let ((beg (point)))
9554 ;; We check that there are unread articles.
9555 (when (or all (gnus-summary-find-next))
9556 (gnus-summary-catchup all t beg nil t)))))
9558 (gnus-summary-position-point))
9559 (defun gnus-summary-catchup-all (&optional quietly)
9560 "Mark all articles in this newsgroup as read."
9562 (gnus-summary-catchup t quietly))
9564 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9565 "Mark all unread articles in this group as read, then exit.
9566 If prefix argument ALL is non-nil, all articles are marked as read.
9567 If QUIETLY is non-nil, no questions will be asked."
9569 (when (gnus-summary-catchup all quietly nil 'fast)
9570 ;; Select next newsgroup or exit.
9571 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9572 (eq gnus-auto-select-next 'quietly))
9573 (gnus-summary-next-group nil)
9574 (gnus-summary-exit))))
9576 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9577 "Mark all articles in this newsgroup as read, and then exit."
9579 (gnus-summary-catchup-and-exit t quietly))
9581 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9582 "Mark all articles in this group as read and select the next group.
9583 If given a prefix, mark all articles, unread as well as ticked, as
9587 (gnus-summary-catchup all))
9588 (gnus-summary-next-group))
9594 (defmacro gnus-with-article (article &rest forms)
9595 "Select ARTICLE and perform FORMS in the original article buffer.
9596 Then replace the article with the result."
9598 ;; We don't want the article to be marked as read.
9599 (let (gnus-mark-article-hook)
9600 (gnus-summary-select-article t t nil ,article))
9601 (set-buffer gnus-original-article-buffer)
9603 (if (not (gnus-check-backend-function
9604 'request-replace-article (car gnus-article-current)))
9605 (gnus-message 5 "Read-only group; not replacing")
9606 (unless (gnus-request-replace-article
9607 ,article (car gnus-article-current)
9609 (error "Couldn't replace article")))
9610 ;; The cache and backlog have to be flushed somewhat.
9611 (when gnus-keep-backlog
9612 (gnus-backlog-remove-article
9613 (car gnus-article-current) (cdr gnus-article-current)))
9614 (when gnus-use-cache
9615 (gnus-cache-update-article
9616 (car gnus-article-current) (cdr gnus-article-current)))))
9618 (put 'gnus-with-article 'lisp-indent-function 1)
9619 (put 'gnus-with-article 'edebug-form-spec '(form body))
9621 ;; Thread-based commands.
9623 (defun gnus-summary-articles-in-thread (&optional article)
9624 "Return a list of all articles in the current thread.
9625 If ARTICLE is non-nil, return all articles in the thread that starts
9627 (let* ((article (or article (gnus-summary-article-number)))
9628 (data (gnus-data-find-list article))
9629 (top-level (gnus-data-level (car data)))
9631 (cond ((null gnus-thread-operation-ignore-subject)
9632 (gnus-simplify-subject-re
9633 (mail-header-subject (gnus-data-header (car data)))))
9634 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9635 (gnus-simplify-subject-fuzzy
9636 (mail-header-subject (gnus-data-header (car data)))))
9638 (end-point (save-excursion
9639 (if (gnus-summary-go-to-next-thread)
9640 (point) (point-max))))
9643 (< (gnus-data-pos (car data)) end-point))
9644 (when (or (not top-subject)
9645 (string= top-subject
9646 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9647 (gnus-simplify-subject-fuzzy
9648 (mail-header-subject
9649 (gnus-data-header (car data))))
9650 (gnus-simplify-subject-re
9651 (mail-header-subject
9652 (gnus-data-header (car data)))))))
9653 (push (gnus-data-number (car data)) articles))
9654 (unless (and (setq data (cdr data))
9655 (> (gnus-data-level (car data)) top-level))
9657 ;; Return the list of articles.
9658 (nreverse articles)))
9660 (defun gnus-summary-rethread-current ()
9661 "Rethread the thread the current article is part of."
9663 (let* ((gnus-show-threads t)
9664 (article (gnus-summary-article-number))
9665 (id (mail-header-id (gnus-summary-article-header)))
9666 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9668 (error "No article on the current line"))
9669 (gnus-rebuild-thread id)
9670 (gnus-summary-goto-subject article)))
9672 (defun gnus-summary-reparent-thread ()
9673 "Make the current article child of the marked (or previous) article.
9675 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9676 is non-nil or the Subject: of both articles are the same."
9678 (unless (not (gnus-group-read-only-p))
9679 (error "The current newsgroup does not support article editing"))
9680 (unless (<= (length gnus-newsgroup-processable) 1)
9681 (error "No more than one article may be marked"))
9682 (save-window-excursion
9683 (let ((gnus-article-buffer " *reparent*")
9684 (current-article (gnus-summary-article-number))
9685 ;; First grab the marked article, otherwise one line up.
9686 (parent-article (if (not (null gnus-newsgroup-processable))
9687 (car gnus-newsgroup-processable)
9689 (if (eq (forward-line -1) 0)
9690 (gnus-summary-article-number)
9691 (error "Beginning of summary buffer"))))))
9692 (unless (not (eq current-article parent-article))
9693 (error "An article may not be self-referential"))
9694 (let ((message-id (mail-header-id
9695 (gnus-summary-article-header parent-article))))
9696 (unless (and message-id (not (equal message-id "")))
9697 (error "No message-id in desired parent"))
9698 (gnus-with-article current-article
9700 (goto-char (point-min))
9701 (message-narrow-to-head)
9702 (if (re-search-forward "^References: " nil t)
9704 (re-search-forward "^[^ \t]" nil t)
9707 (insert " " message-id))
9708 (insert "References: " message-id "\n"))))
9709 (set-buffer gnus-summary-buffer)
9710 (gnus-summary-unmark-all-processable)
9711 (gnus-summary-update-article current-article)
9712 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9713 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9714 (gnus-summary-rethread-current)
9715 (gnus-message 3 "Article %d is now the child of article %d"
9716 current-article parent-article)))))
9718 (defun gnus-summary-toggle-threads (&optional arg)
9719 "Toggle showing conversation threads.
9720 If ARG is positive number, turn showing conversation threads on."
9722 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9723 (setq gnus-show-threads
9724 (if (null arg) (not gnus-show-threads)
9725 (> (prefix-numeric-value arg) 0)))
9726 (gnus-summary-prepare)
9727 (gnus-summary-goto-subject current)
9728 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9729 (gnus-summary-position-point)))
9731 (defun gnus-summary-show-all-threads ()
9735 (let ((buffer-read-only nil))
9736 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9737 (gnus-summary-position-point))
9739 (defun gnus-summary-show-thread ()
9740 "Show thread subtrees.
9741 Returns nil if no thread was there to be shown."
9743 (let ((buffer-read-only nil)
9745 ;; first goto end then to beg, to have point at beg after let
9746 (end (progn (end-of-line) (point)))
9747 (beg (progn (beginning-of-line) (point))))
9749 ;; Any hidden lines here?
9750 (search-forward "\r" end t)
9751 (subst-char-in-region beg end ?\^M ?\n t)
9753 (gnus-summary-position-point))))
9755 (defun gnus-summary-maybe-hide-threads ()
9756 "If requested, hide the threads that should be hidden."
9757 (when (and gnus-show-threads
9758 gnus-thread-hide-subtree)
9759 (gnus-summary-hide-all-threads
9760 (if (or (consp gnus-thread-hide-subtree)
9761 (gnus-functionp gnus-thread-hide-subtree))
9762 (gnus-make-predicate gnus-thread-hide-subtree)
9765 ;;; Hiding predicates.
9767 (defun gnus-article-unread-p (header)
9768 (memq (mail-header-number header) gnus-newsgroup-unreads))
9770 (defun gnus-article-unseen-p (header)
9771 (memq (mail-header-number header) gnus-newsgroup-unseen))
9773 (defun gnus-map-articles (predicate articles)
9774 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
9775 (apply 'gnus-or (mapcar predicate
9776 (mapcar 'gnus-summary-article-header articles))))
9778 (defun gnus-summary-hide-all-threads (&optional predicate)
9779 "Hide all thread subtrees.
9780 If PREDICATE is supplied, threads that satisfy this predicate
9781 will not be hidden."
9784 (goto-char (point-min))
9787 (when (or (not predicate)
9789 predicate (gnus-summary-article-children)))
9790 (gnus-summary-hide-thread))
9791 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
9792 (gnus-summary-position-point))
9794 (defun gnus-summary-hide-thread ()
9795 "Hide thread subtrees.
9796 If PREDICATE is supplied, threads that satisfy this predicate
9798 Returns nil if no threads were there to be hidden."
9800 (let ((buffer-read-only nil)
9802 (article (gnus-summary-article-number)))
9804 ;; Go forward until either the buffer ends or the subthread
9806 (when (and (not (eobp))
9807 (or (zerop (gnus-summary-next-thread 1 t))
9808 (goto-char (point-max))))
9810 (if (and (> (point) start)
9811 (search-backward "\n" start t))
9813 (subst-char-in-region start (point) ?\n ?\^M)
9814 (gnus-summary-goto-subject article))
9818 (defun gnus-summary-go-to-next-thread (&optional previous)
9819 "Go to the same level (or less) next thread.
9820 If PREVIOUS is non-nil, go to previous thread instead.
9821 Return the article number moved to, or nil if moving was impossible."
9822 (let ((level (gnus-summary-thread-level))
9823 (way (if previous -1 1))
9826 (while (and (not (eobp))
9827 (< level (gnus-summary-thread-level)))
9835 (gnus-summary-article-number)
9838 (defun gnus-summary-next-thread (n &optional silent)
9839 "Go to the same level next N'th thread.
9840 If N is negative, search backward instead.
9841 Returns the difference between N and the number of skips actually
9844 If SILENT, don't output messages."
9846 (let ((backward (< n 0))
9849 (gnus-summary-go-to-next-thread backward))
9852 (gnus-summary-position-point))
9853 (when (and (not silent) (/= 0 n))
9854 (gnus-message 7 "No more threads"))
9857 (defun gnus-summary-prev-thread (n)
9858 "Go to the same level previous N'th thread.
9859 Returns the difference between N and the number of skips actually
9862 (gnus-summary-next-thread (- n)))
9864 (defun gnus-summary-go-down-thread ()
9865 "Go down one level in the current thread."
9866 (let ((children (gnus-summary-article-children)))
9868 (gnus-summary-goto-subject (car children)))))
9870 (defun gnus-summary-go-up-thread ()
9871 "Go up one level in the current thread."
9872 (let ((parent (gnus-summary-article-parent)))
9874 (gnus-summary-goto-subject parent))))
9876 (defun gnus-summary-down-thread (n)
9877 "Go down thread N steps.
9878 If N is negative, go up instead.
9879 Returns the difference between N and how many steps down that were
9885 (if up (gnus-summary-go-up-thread)
9886 (gnus-summary-go-down-thread)))
9888 (gnus-summary-position-point)
9890 (gnus-message 7 "Can't go further"))
9893 (defun gnus-summary-up-thread (n)
9894 "Go up thread N steps.
9895 If N is negative, go down instead.
9896 Returns the difference between N and how many steps down that were
9899 (gnus-summary-down-thread (- n)))
9901 (defun gnus-summary-top-thread ()
9902 "Go to the top of the thread."
9904 (while (gnus-summary-go-up-thread))
9905 (gnus-summary-article-number))
9907 (defun gnus-summary-kill-thread (&optional unmark)
9908 "Mark articles under current thread as read.
9909 If the prefix argument is positive, remove any kinds of marks.
9910 If the prefix argument is negative, tick articles instead."
9913 (setq unmark (prefix-numeric-value unmark)))
9914 (let ((articles (gnus-summary-articles-in-thread)))
9916 ;; Expand the thread.
9917 (gnus-summary-show-thread)
9918 ;; Mark all the articles.
9920 (gnus-summary-goto-subject (car articles))
9921 (cond ((null unmark)
9922 (gnus-summary-mark-article-as-read gnus-killed-mark))
9924 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9926 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9927 (setq articles (cdr articles))))
9928 ;; Hide killed subtrees.
9930 gnus-thread-hide-killed
9931 (gnus-summary-hide-thread))
9932 ;; If marked as read, go to next unread subject.
9934 ;; Go to next unread subject.
9935 (gnus-summary-next-subject 1 t)))
9936 (gnus-set-mode-line 'summary))
9938 ;; Summary sorting commands
9940 (defun gnus-summary-sort-by-number (&optional reverse)
9941 "Sort the summary buffer by article number.
9942 Argument REVERSE means reverse order."
9944 (gnus-summary-sort 'number reverse))
9946 (defun gnus-summary-sort-by-author (&optional reverse)
9947 "Sort the summary buffer by author name alphabetically.
9948 If `case-fold-search' is non-nil, case of letters is ignored.
9949 Argument REVERSE means reverse order."
9951 (gnus-summary-sort 'author reverse))
9953 (defun gnus-summary-sort-by-subject (&optional reverse)
9954 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9955 If `case-fold-search' is non-nil, case of letters is ignored.
9956 Argument REVERSE means reverse order."
9958 (gnus-summary-sort 'subject reverse))
9960 (defun gnus-summary-sort-by-date (&optional reverse)
9961 "Sort the summary buffer by date.
9962 Argument REVERSE means reverse order."
9964 (gnus-summary-sort 'date reverse))
9966 (defun gnus-summary-sort-by-score (&optional reverse)
9967 "Sort the summary buffer by score.
9968 Argument REVERSE means reverse order."
9970 (gnus-summary-sort 'score reverse))
9972 (defun gnus-summary-sort-by-lines (&optional reverse)
9973 "Sort the summary buffer by the number of lines.
9974 Argument REVERSE means reverse order."
9976 (gnus-summary-sort 'lines reverse))
9978 (defun gnus-summary-sort-by-chars (&optional reverse)
9979 "Sort the summary buffer by article length.
9980 Argument REVERSE means reverse order."
9982 (gnus-summary-sort 'chars reverse))
9984 (defun gnus-summary-sort-by-original (&optional reverse)
9985 "Sort the summary buffer using the default sorting method.
9986 Argument REVERSE means reverse order."
9988 (let* ((buffer-read-only)
9989 (gnus-summary-prepare-hook nil))
9990 ;; We do the sorting by regenerating the threads.
9991 (gnus-summary-prepare)
9992 ;; Hide subthreads if needed.
9993 (gnus-summary-maybe-hide-threads)))
9995 (defun gnus-summary-sort (predicate reverse)
9996 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9997 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9998 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9999 (gnus-thread-sort-functions
10004 (gnus-sort-gathered-threads-function
10005 gnus-thread-sort-functions)
10006 (gnus-article-sort-functions
10010 (,article t2 t1))))
10012 (gnus-summary-prepare-hook nil))
10013 ;; We do the sorting by regenerating the threads.
10014 (gnus-summary-prepare)
10015 ;; Hide subthreads if needed.
10016 (gnus-summary-maybe-hide-threads)))
10018 ;; Summary saving commands.
10020 (defun gnus-summary-save-article (&optional n not-saved)
10021 "Save the current article using the default saver function.
10022 If N is a positive number, save the N next articles.
10023 If N is a negative number, save the N previous articles.
10024 If N is nil and any articles have been marked with the process mark,
10025 save those articles instead.
10026 The variable `gnus-default-article-saver' specifies the saver function."
10028 (let* ((articles (gnus-summary-work-articles n))
10029 (save-buffer (save-excursion
10030 (nnheader-set-temp-buffer " *Gnus Save*")))
10031 (num (length articles))
10033 (dolist (article articles)
10034 (setq header (gnus-summary-article-header article))
10035 (if (not (vectorp header))
10036 ;; This is a pseudo-article.
10037 (if (assq 'name header)
10038 (gnus-copy-file (cdr (assq 'name header)))
10039 (gnus-message 1 "Article %d is unsaveable" article))
10040 ;; This is a real article.
10041 (save-window-excursion
10042 (let ((gnus-display-mime-function nil)
10043 (gnus-article-prepare-hook nil))
10044 (gnus-summary-select-article t nil nil article)))
10046 (set-buffer save-buffer)
10048 (insert-buffer-substring gnus-original-article-buffer))
10049 (setq file (gnus-article-save save-buffer file num))
10050 (gnus-summary-remove-process-mark article)
10052 (gnus-summary-set-saved-mark article))))
10053 (gnus-kill-buffer save-buffer)
10054 (gnus-summary-position-point)
10055 (gnus-set-mode-line 'summary)
10058 (defun gnus-summary-pipe-output (&optional arg)
10059 "Pipe the current article to a subprocess.
10060 If N is a positive number, pipe the N next articles.
10061 If N is a negative number, pipe the N previous articles.
10062 If N is nil and any articles have been marked with the process mark,
10063 pipe those articles instead."
10065 (require 'gnus-art)
10066 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10067 (gnus-summary-save-article arg t))
10068 (let ((buffer (get-buffer "*Shell Command Output*")))
10070 (with-current-buffer buffer (> (point-max) (point-min))))
10071 (gnus-configure-windows 'pipe))))
10073 (defun gnus-summary-save-article-mail (&optional arg)
10074 "Append the current article to an mail file.
10075 If N is a positive number, save the N next articles.
10076 If N is a negative number, save the N previous articles.
10077 If N is nil and any articles have been marked with the process mark,
10078 save those articles instead."
10080 (require 'gnus-art)
10081 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10082 (gnus-summary-save-article arg)))
10084 (defun gnus-summary-save-article-rmail (&optional arg)
10085 "Append the current article to an rmail file.
10086 If N is a positive number, save the N next articles.
10087 If N is a negative number, save the N previous articles.
10088 If N is nil and any articles have been marked with the process mark,
10089 save those articles instead."
10091 (require 'gnus-art)
10092 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10093 (gnus-summary-save-article arg)))
10095 (defun gnus-summary-save-article-file (&optional arg)
10096 "Append the current article to a file.
10097 If N is a positive number, save the N next articles.
10098 If N is a negative number, save the N previous articles.
10099 If N is nil and any articles have been marked with the process mark,
10100 save those articles instead."
10102 (require 'gnus-art)
10103 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10104 (gnus-summary-save-article arg)))
10106 (defun gnus-summary-write-article-file (&optional arg)
10107 "Write the current article to a file, deleting the previous file.
10108 If N is a positive number, save the N next articles.
10109 If N is a negative number, save the N previous articles.
10110 If N is nil and any articles have been marked with the process mark,
10111 save those articles instead."
10113 (require 'gnus-art)
10114 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10115 (gnus-summary-save-article arg)))
10117 (defun gnus-summary-save-article-body-file (&optional arg)
10118 "Append the current article body to a file.
10119 If N is a positive number, save the N next articles.
10120 If N is a negative number, save the N previous articles.
10121 If N is nil and any articles have been marked with the process mark,
10122 save those articles instead."
10124 (require 'gnus-art)
10125 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10126 (gnus-summary-save-article arg)))
10128 (defun gnus-summary-muttprint (&optional arg)
10129 "Print the current article using Muttprint.
10130 If N is a positive number, save the N next articles.
10131 If N is a negative number, save the N previous articles.
10132 If N is nil and any articles have been marked with the process mark,
10133 save those articles instead."
10135 (require 'gnus-art)
10136 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10137 (gnus-summary-save-article arg t)))
10139 (defun gnus-summary-pipe-message (program)
10140 "Pipe the current article through PROGRAM."
10141 (interactive "sProgram: ")
10142 (gnus-summary-select-article)
10143 (let ((mail-header-separator ""))
10144 (gnus-eval-in-buffer-window gnus-article-buffer
10147 (let ((start (window-start))
10149 (message-pipe-buffer-body program)
10150 (set-window-start (get-buffer-window (current-buffer)) start))))))
10152 (defun gnus-get-split-value (methods)
10153 "Return a value based on the split METHODS."
10154 (let (split-name method result match)
10157 (set-buffer gnus-original-article-buffer)
10159 (nnheader-narrow-to-headers)
10160 (while (and methods (not split-name))
10161 (goto-char (point-min))
10162 (setq method (pop methods))
10163 (setq match (car method))
10166 ;; Regular expression.
10168 (re-search-forward match nil t)))
10169 ((gnus-functionp match)
10173 (setq result (funcall match gnus-newsgroup-name))))
10178 (setq result (eval match)))))
10179 (setq split-name (cdr method))
10180 (cond ((stringp result)
10181 (push (expand-file-name
10182 result gnus-article-save-directory)
10185 (setq split-name (append result split-name)))))))))
10186 (nreverse split-name)))
10188 (defun gnus-valid-move-group-p (group)
10189 (and (boundp group)
10190 (symbol-name group)
10191 (symbol-value group)
10192 (gnus-get-function (gnus-find-method-for-group
10193 (symbol-name group)) 'request-accept-article t)))
10195 (defun gnus-read-move-group-name (prompt default articles prefix)
10196 "Read a group name."
10197 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10198 (minibuffer-confirm-incomplete nil) ; XEmacs
10200 (format "%s %s to:"
10202 (if (> (length articles) 1)
10203 (format "these %d articles" (length articles))
10208 (gnus-completing-read-with-default
10211 'gnus-valid-move-group-p
10213 'gnus-group-history))
10214 ((= 1 (length split-name))
10215 (gnus-completing-read-with-default
10216 (car split-name) prom
10218 'gnus-valid-move-group-p
10220 'gnus-group-history))
10222 (gnus-completing-read-with-default
10224 (mapcar (lambda (el) (list el))
10225 (nreverse split-name))
10227 'gnus-group-history))))
10228 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10230 (if (or (string= to-newsgroup "")
10231 (string= to-newsgroup prefix))
10232 (setq to-newsgroup default))
10233 (unless to-newsgroup
10234 (error "No group name entered"))
10235 (or (gnus-active to-newsgroup)
10236 (gnus-activate-group to-newsgroup nil nil to-method)
10237 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10239 (or (and (gnus-request-create-group to-newsgroup to-method)
10240 (gnus-activate-group
10241 to-newsgroup nil nil to-method)
10242 (gnus-subscribe-group to-newsgroup))
10243 (error "Couldn't create group %s" to-newsgroup)))
10244 (error "No such group: %s" to-newsgroup)))
10247 (defun gnus-summary-save-parts (type dir n &optional reverse)
10248 "Save parts matching TYPE to DIR.
10249 If REVERSE, save parts that do not match TYPE."
10251 (list (read-string "Save parts of type: "
10252 (or (car gnus-summary-save-parts-type-history)
10253 gnus-summary-save-parts-default-mime)
10254 'gnus-summary-save-parts-type-history)
10255 (setq gnus-summary-save-parts-last-directory
10256 (read-file-name "Save to directory: "
10257 gnus-summary-save-parts-last-directory
10259 current-prefix-arg))
10260 (gnus-summary-iterate n
10261 (let ((gnus-display-mime-function nil)
10262 (gnus-inhibit-treatment t))
10263 (gnus-summary-select-article))
10265 (set-buffer gnus-article-buffer)
10266 (let ((handles (or gnus-article-mime-handles
10267 (mm-dissect-buffer) (mm-uu-dissect))))
10269 (gnus-summary-save-parts-1 type dir handles reverse)
10270 (unless gnus-article-mime-handles ;; Don't destroy this case.
10271 (mm-destroy-parts handles)))))))
10273 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10274 (if (stringp (car handle))
10275 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10278 (not (string-match type (mm-handle-media-type handle)))
10279 (string-match type (mm-handle-media-type handle)))
10280 (let ((file (expand-file-name
10281 (file-name-nondirectory
10283 (mail-content-type-get
10284 (mm-handle-disposition handle) 'filename)
10285 (concat gnus-newsgroup-name
10286 "." (number-to-string
10287 (cdr gnus-article-current)))))
10289 (unless (file-exists-p file)
10290 (mm-save-part-to-file handle file))))))
10292 ;; Summary extract commands
10294 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10295 (let ((buffer-read-only nil)
10296 (article (gnus-summary-article-number))
10298 (unless (gnus-summary-goto-subject article)
10299 (error "No such article: %d" article))
10300 (gnus-summary-position-point)
10301 ;; If all commands are to be bunched up on one line, we collect
10303 (unless gnus-view-pseudos-separately
10304 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10307 (setq action (cdr (assq 'action (car ps))))
10308 (setq files (list (cdr (assq 'name (car ps)))))
10309 (while (and ps (cdr ps)
10310 (string= (or action "1")
10311 (or (cdr (assq 'action (cadr ps))) "2")))
10312 (push (cdr (assq 'name (cadr ps))) files)
10313 (setcdr ps (cddr ps)))
10315 (when (not (string-match "%s" action))
10318 (when (assq 'execute (car ps))
10319 (setcdr (assq 'execute (car ps))
10320 (funcall (if (string-match "%s" action)
10329 (setq ps (cdr ps)))))
10330 (if (and gnus-view-pseudos (not not-view))
10332 (when (assq 'execute (car pslist))
10333 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10334 (eq gnus-view-pseudos 'not-confirm)))
10335 (setq pslist (cdr pslist)))
10338 (setq after-article (or (cdr (assq 'article (car pslist)))
10339 (gnus-summary-article-number)))
10340 (gnus-summary-goto-subject after-article)
10343 (insert " " (file-name-nondirectory
10344 (cdr (assq 'name (car pslist))))
10345 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10347 (forward-line -1) ; back to `b'
10348 (gnus-add-text-properties
10349 b (1- e) (list 'gnus-number gnus-reffed-article-number
10350 gnus-mouse-face-prop gnus-mouse-face))
10352 after-article gnus-reffed-article-number
10353 gnus-unread-mark b (car pslist) 0 (- e b))
10354 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10355 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10356 (setq pslist (cdr pslist)))))))
10358 (defun gnus-pseudos< (p1 p2)
10359 (let ((c1 (cdr (assq 'action p1)))
10360 (c2 (cdr (assq 'action p2))))
10361 (and c1 c2 (string< c1 c2))))
10363 (defun gnus-request-pseudo-article (props)
10364 (cond ((assq 'execute props)
10365 (gnus-execute-command (cdr (assq 'execute props)))))
10366 (let ((gnus-current-article (gnus-summary-article-number)))
10367 (gnus-run-hooks 'gnus-mark-article-hook)))
10369 (defun gnus-execute-command (command &optional automatic)
10371 (gnus-article-setup-buffer)
10372 (set-buffer gnus-article-buffer)
10373 (setq buffer-read-only nil)
10374 (let ((command (if automatic command
10375 (read-string "Command: " (cons command 0)))))
10377 (insert "$ " command "\n\n")
10378 (if gnus-view-pseudo-asynchronously
10379 (start-process "gnus-execute" (current-buffer) shell-file-name
10380 shell-command-switch command)
10381 (call-process shell-file-name nil t nil
10382 shell-command-switch command)))))
10384 ;; Summary kill commands.
10386 (defun gnus-summary-edit-global-kill (article)
10387 "Edit the \"global\" kill file."
10388 (interactive (list (gnus-summary-article-number)))
10389 (gnus-group-edit-global-kill article))
10391 (defun gnus-summary-edit-local-kill ()
10392 "Edit a local kill file applied to the current newsgroup."
10394 (setq gnus-current-headers (gnus-summary-article-header))
10395 (gnus-group-edit-local-kill
10396 (gnus-summary-article-number) gnus-newsgroup-name))
10398 ;;; Header reading.
10400 (defun gnus-read-header (id &optional header)
10401 "Read the headers of article ID and enter them into the Gnus system."
10402 (let ((group gnus-newsgroup-name)
10403 (gnus-override-method
10405 gnus-override-method
10406 (and (gnus-news-group-p gnus-newsgroup-name)
10407 (car (gnus-refer-article-methods)))))
10409 ;; First we check to see whether the header in question is already
10412 ;; This is a Message-ID.
10413 (setq header (or header (gnus-id-to-header id)))
10414 ;; This is an article number.
10415 (setq header (or header (gnus-summary-article-header id))))
10417 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10418 ;; We have found the header.
10420 ;; If this is a sparse article, we have to nix out its
10421 ;; previous entry in the thread hashtb.
10423 (gnus-summary-article-sparse-p (mail-header-number header)))
10424 (let* ((parent (gnus-parent-id (mail-header-references header)))
10425 (thread (and parent (gnus-id-to-thread parent))))
10427 (delq (assq header thread) thread))))
10428 ;; We have to really fetch the header to this article.
10430 (set-buffer nntp-server-buffer)
10431 (when (setq where (gnus-request-head id group))
10432 (nnheader-fold-continuation-lines)
10433 (goto-char (point-max))
10435 (goto-char (point-min))
10439 ((cdr where) (cdr where))
10440 (header (mail-header-number header))
10441 (t gnus-reffed-article-number))
10443 (insert " Article retrieved.\n"))
10444 (if (or (not where)
10445 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10446 () ; Malformed head.
10447 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10448 (when (and (stringp id)
10449 (not (string= (gnus-group-real-name group)
10451 ;; If we fetched by Message-ID and the article came
10452 ;; from a different group, we fudge some bogus article
10453 ;; numbers for this article.
10454 (mail-header-set-number header gnus-reffed-article-number))
10456 (set-buffer gnus-summary-buffer)
10457 (decf gnus-reffed-article-number)
10458 (gnus-remove-header (mail-header-number header))
10459 (push header gnus-newsgroup-headers)
10460 (setq gnus-current-headers header)
10461 (push (mail-header-number header) gnus-newsgroup-limit)))
10464 (defun gnus-remove-header (number)
10465 "Remove header NUMBER from `gnus-newsgroup-headers'."
10466 (if (and gnus-newsgroup-headers
10467 (= number (mail-header-number (car gnus-newsgroup-headers))))
10468 (pop gnus-newsgroup-headers)
10469 (let ((headers gnus-newsgroup-headers))
10470 (while (and (cdr headers)
10471 (not (= number (mail-header-number (cadr headers)))))
10473 (when (cdr headers)
10474 (setcdr headers (cddr headers))))))
10477 ;;; summary highlights
10480 (defun gnus-highlight-selected-summary ()
10481 "Highlight selected article in summary buffer."
10482 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10483 (when gnus-summary-selected-face
10485 (let* ((beg (progn (beginning-of-line) (point)))
10486 (end (progn (end-of-line) (point)))
10487 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10488 (from (if (get-text-property beg gnus-mouse-face-prop)
10490 (or (next-single-property-change
10491 beg gnus-mouse-face-prop nil end)
10496 (or (next-single-property-change
10497 from gnus-mouse-face-prop nil end)
10499 ;; If no mouse-face prop on line we will have to = from = end,
10500 ;; so we highlight the entire line instead.
10501 (when (= (+ to 2) from)
10504 (if gnus-newsgroup-selected-overlay
10505 ;; Move old overlay.
10507 gnus-newsgroup-selected-overlay from to (current-buffer))
10508 ;; Create new overlay.
10510 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10511 'face gnus-summary-selected-face))))))
10513 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10514 (defun gnus-summary-highlight-line ()
10515 "Highlight current line according to `gnus-summary-highlight'."
10516 (let* ((list gnus-summary-highlight)
10518 (end (progn (end-of-line) (point)))
10519 ;; now find out where the line starts and leave point there.
10520 (beg (progn (beginning-of-line) (point)))
10521 (article (gnus-summary-article-number))
10522 (score (or (cdr (assq (or article gnus-current-article)
10523 gnus-newsgroup-scored))
10524 gnus-summary-default-score 0))
10525 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10526 (inhibit-read-only t))
10527 ;; Eval the cars of the lists until we find a match.
10528 (let ((default gnus-summary-default-score)
10529 (default-high gnus-summary-default-high-score)
10530 (default-low gnus-summary-default-low-score))
10532 (not (eval (caar list))))
10533 (setq list (cdr list))))
10534 (let ((face (cdar list)))
10535 (unless (eq face (get-text-property beg 'face))
10536 (gnus-put-text-property-excluding-characters-with-faces
10538 (setq face (if (boundp face) (symbol-value face) face)))
10539 (when gnus-summary-highlight-line-function
10540 (funcall gnus-summary-highlight-line-function article face))))
10543 (defun gnus-update-read-articles (group unread &optional compute)
10544 "Update the list of read articles in GROUP."
10545 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10546 (entry (gnus-gethash group gnus-newsrc-hashtb))
10547 (info (nth 2 entry))
10549 (unread (sort (copy-sequence unread) '<))
10551 (if (or (not info) (not active))
10552 ;; There is no info on this group if it was, in fact,
10553 ;; killed. Gnus stores no information on killed groups, so
10554 ;; there's nothing to be done.
10555 ;; One could store the information somewhere temporarily,
10556 ;; perhaps... Hmmm...
10558 ;; Remove any negative articles numbers.
10559 (while (and unread (< (car unread) 0))
10560 (setq unread (cdr unread)))
10561 ;; Remove any expired article numbers
10562 (while (and unread (< (car unread) (car active)))
10563 (setq unread (cdr unread)))
10564 ;; Compute the ranges of read articles by looking at the list of
10565 ;; unread articles.
10567 (when (/= (car unread) prev)
10568 (push (if (= prev (1- (car unread))) prev
10569 (cons prev (1- (car unread))))
10571 (setq prev (1+ (car unread)))
10572 (setq unread (cdr unread)))
10573 (when (<= prev (cdr active))
10574 (push (cons prev (cdr active)) read))
10575 (setq read (if (> (length read) 1) (nreverse read) read))
10580 ;; Propagate the read marks to the backend.
10581 (when (gnus-check-backend-function 'request-set-mark group)
10582 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10583 (add (gnus-remove-from-range read (gnus-info-read info))))
10585 (unless (gnus-check-group group)
10586 (error "Can't open server for %s" group))
10587 (gnus-request-set-mark
10588 group (delq nil (list (if add (list add 'add '(read)))
10589 (if del (list del 'del '(read))))))
10591 `(gnus-request-set-mark
10594 (if del (list del 'add '(read)))
10595 (if add (list add 'del '(read))))))))))
10596 (set-buffer gnus-group-buffer)
10597 (gnus-undo-register
10599 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10600 (gnus-info-set-read ',info ',(gnus-info-read info))
10601 (gnus-get-unread-articles-in-group ',info
10602 (gnus-active ,group))
10603 (gnus-group-update-group ,group t)
10605 ;; Enter this list into the group info.
10606 (gnus-info-set-read info read)
10607 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10608 (gnus-get-unread-articles-in-group info (gnus-active group))
10611 (defun gnus-offer-save-summaries ()
10612 "Offer to save all active summary buffers."
10614 ;; Go through all buffers and find all summaries.
10615 (dolist (buffer (buffer-list))
10616 (when (and (setq buffer (buffer-name buffer))
10617 (string-match "Summary" buffer)
10619 (set-buffer buffer)
10620 ;; We check that this is, indeed, a summary buffer.
10621 (and (eq major-mode 'gnus-summary-mode)
10622 ;; Also make sure this isn't bogus.
10623 gnus-newsgroup-prepared
10624 ;; Also make sure that this isn't a
10625 ;; dead summary buffer.
10626 (not gnus-dead-summary-mode))))
10627 (push buffer buffers)))
10628 ;; Go through all these summary buffers and offer to save them.
10632 "Update summary buffer %s? "
10634 (switch-to-buffer buf)
10635 (gnus-summary-exit))
10638 (defun gnus-summary-setup-default-charset ()
10639 "Setup newsgroup default charset."
10640 (if (equal gnus-newsgroup-name "nndraft:drafts")
10641 (setq gnus-newsgroup-charset nil)
10642 (let* ((ignored-charsets
10643 (or gnus-newsgroup-ephemeral-ignored-charsets
10645 (and gnus-newsgroup-name
10646 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10647 gnus-newsgroup-ignored-charsets))))
10648 (setq gnus-newsgroup-charset
10649 (or gnus-newsgroup-ephemeral-charset
10650 (and gnus-newsgroup-name
10651 (gnus-parameter-charset gnus-newsgroup-name))
10652 gnus-default-charset))
10653 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10654 ignored-charsets))))
10660 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10661 "Display the current article buffer fully MIME-buttonized.
10662 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10663 treated as multipart/mixed."
10665 (require 'gnus-art)
10666 (let ((gnus-unbuttonized-mime-types nil)
10667 (gnus-mime-display-multipart-as-mixed show-all-parts))
10668 (gnus-summary-show-article)))
10670 (defun gnus-summary-repair-multipart (article)
10671 "Add a Content-Type header to a multipart article without one."
10672 (interactive (list (gnus-summary-article-number)))
10673 (gnus-with-article article
10674 (message-narrow-to-head)
10675 (message-remove-header "Mime-Version")
10676 (goto-char (point-max))
10677 (insert "Mime-Version: 1.0\n")
10679 (when (search-forward "\n--" nil t)
10680 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10681 (message-narrow-to-head)
10682 (message-remove-header "Content-Type")
10683 (goto-char (point-max))
10684 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10687 (let (gnus-mark-article-hook)
10688 (gnus-summary-select-article t t nil article)))
10690 (defun gnus-summary-toggle-display-buttonized ()
10691 "Toggle the buttonizing of the article buffer."
10693 (require 'gnus-art)
10694 (if (setq gnus-inhibit-mime-unbuttonizing
10695 (not gnus-inhibit-mime-unbuttonizing))
10696 (let ((gnus-unbuttonized-mime-types nil))
10697 (gnus-summary-show-article))
10698 (gnus-summary-show-article)))
10701 ;;; Generic summary marking commands
10704 (defvar gnus-summary-marking-alist
10705 '((read gnus-del-mark "d")
10706 (unread gnus-unread-mark "u")
10707 (ticked gnus-ticked-mark "!")
10708 (dormant gnus-dormant-mark "?")
10709 (expirable gnus-expirable-mark "e"))
10710 "An alist of names/marks/keystrokes.")
10712 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10713 (defvar gnus-summary-mark-map)
10715 (defun gnus-summary-make-all-marking-commands ()
10716 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10717 (dolist (elem gnus-summary-marking-alist)
10718 (apply 'gnus-summary-make-marking-command elem)))
10720 (defun gnus-summary-make-marking-command (name mark keystroke)
10721 (let ((map (make-sparse-keymap)))
10722 (define-key gnus-summary-generic-mark-map keystroke map)
10723 (dolist (lway `((next "next" next nil "n")
10724 (next-unread "next unread" next t "N")
10725 (prev "previous" prev nil "p")
10726 (prev-unread "previous unread" prev t "P")
10727 (nomove "" nil nil ,keystroke)))
10728 (let ((func (gnus-summary-make-marking-command-1
10729 mark (car lway) lway name)))
10730 (setq func (eval func))
10731 (define-key map (nth 4 lway) func)))))
10733 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10735 (format "gnus-summary-put-mark-as-%s%s"
10736 name (if (eq way 'nomove)
10738 (concat "-" (symbol-name way)))))
10741 "Mark the current article as %s%s.
10742 If N, the prefix, then repeat N times.
10743 If N is negative, move in reverse order.
10744 The difference between N and the actual number of articles marked is
10748 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10750 (defun gnus-summary-generic-mark (n mark move unread)
10751 "Mark N articles with MARK."
10752 (unless (eq major-mode 'gnus-summary-mode)
10753 (error "This command can only be used in the summary buffer"))
10754 (gnus-summary-show-thread)
10757 ((eq move 'next) 1)
10758 ((eq move 'prev) -1)
10760 (if (zerop nummove)
10764 nummove (* -1 nummove))))
10765 (while (and (> n 0)
10766 (gnus-summary-mark-article nil mark)
10767 (zerop (gnus-summary-next-subject nummove unread t)))
10770 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10771 (gnus-summary-recenter)
10772 (gnus-summary-position-point)
10773 (gnus-set-mode-line 'summary)
10776 (defun gnus-summary-insert-articles (articles)
10777 (when (setq articles
10778 (gnus-set-difference articles
10779 (mapcar (lambda (h) (mail-header-number h))
10780 gnus-newsgroup-headers)))
10781 (setq gnus-newsgroup-headers
10783 gnus-newsgroup-headers
10784 (gnus-fetch-headers articles)
10785 'gnus-article-sort-by-number))
10786 ;; Suppress duplicates?
10787 (when gnus-suppress-duplicates
10788 (gnus-dup-suppress-articles))
10790 ;; We might want to build some more threads first.
10791 (when (and gnus-fetch-old-headers
10792 (eq gnus-headers-retrieved-by 'nov))
10793 (if (eq gnus-fetch-old-headers 'invisible)
10794 (gnus-build-all-threads)
10795 (gnus-build-old-threads)))
10796 ;; Let the Gnus agent mark articles as read.
10798 (gnus-agent-get-undownloaded-list))
10799 ;; Remove list identifiers from subject
10800 (when gnus-list-identifiers
10801 (gnus-summary-remove-list-identifiers))
10802 ;; First and last article in this newsgroup.
10803 (when gnus-newsgroup-headers
10804 (setq gnus-newsgroup-begin
10805 (mail-header-number (car gnus-newsgroup-headers))
10807 (mail-header-number
10808 (gnus-last-element gnus-newsgroup-headers))))
10809 (when gnus-use-scoring
10810 (gnus-possibly-score-headers))))
10812 (defun gnus-summary-insert-old-articles (&optional all)
10813 "Insert all old articles in this group.
10814 If ALL is non-nil, already read articles become readable.
10815 If ALL is a number, fetch this number of articles."
10818 (let ((old (mapcar 'car gnus-newsgroup-data))
10819 (i (car gnus-newsgroup-active))
10821 (while (<= i (cdr gnus-newsgroup-active))
10822 (or (memq i old) (push i older))
10824 (setq len (length older))
10829 (setq older (subseq older 0 all))))
10832 (if (and (numberp gnus-large-newsgroup)
10833 (> len gnus-large-newsgroup))
10837 "How many articles from %s (default %d): "
10839 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10841 (unless (string-match "^[ \t]*$" input)
10842 (setq all (string-to-number input))
10844 (setq older (subseq older 0 all))))))))
10846 (message "No old news.")
10847 (let ((gnus-fetch-old-headers t))
10848 (gnus-summary-insert-articles older))
10849 (gnus-summary-limit (gnus-union older old))))
10850 (gnus-summary-position-point)))
10852 (defun gnus-summary-insert-new-articles ()
10853 "Insert all new articles in this group."
10856 (let ((old (mapcar 'car gnus-newsgroup-data))
10857 (old-active gnus-newsgroup-active)
10858 (nnmail-fetched-sources (list t))
10860 (setq gnus-newsgroup-active
10861 (gnus-activate-group gnus-newsgroup-name 'scan))
10862 (setq i (1+ (cdr old-active)))
10863 (while (<= i (cdr gnus-newsgroup-active))
10867 (message "No gnus is bad news.")
10868 (setq new (nreverse new))
10869 (gnus-summary-insert-articles new)
10870 (setq gnus-newsgroup-unreads
10871 (append gnus-newsgroup-unreads new))
10872 (gnus-summary-limit (gnus-union old new))))
10873 (gnus-summary-position-point)))
10875 (gnus-summary-make-all-marking-commands)
10877 (gnus-ems-redefine)
10879 (provide 'gnus-sum)
10881 (run-hooks 'gnus-sum-load-hook)
10883 ;;; gnus-sum.el ends here