1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
42 ;; (require 'gnus-art)
51 (autoload 'gnus-cache-articles-in-group "gnus-cache")
52 (autoload 'pgg-decrypt-region "pgg" nil t)
53 (autoload 'pgg-verify-region "pgg" nil t))
55 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
56 (autoload 'gnus-cache-write-active "gnus-cache")
57 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
58 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
59 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
60 (autoload 'mm-uu-dissect "mm-uu")
62 (defcustom gnus-kill-summary-on-exit t
63 "*If non-nil, kill the summary buffer when you exit from it.
64 If nil, the summary will become a \"*Dead Summary*\" buffer, and
65 it will be killed sometime later."
66 :group 'gnus-summary-exit
69 (defcustom gnus-fetch-old-headers nil
70 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
71 If an unread article in the group refers to an older, already read (or
72 just marked as read) article, the old article will not normally be
73 displayed in the Summary buffer. If this variable is non-nil, Gnus
74 will attempt to grab the headers to the old articles, and thereby
75 build complete threads. If it has the value `some', only enough
76 headers to connect otherwise loose threads will be displayed. This
77 variable can also be a number. In that case, no more than that number
78 of old headers will be fetched. If it has the value `invisible', all
79 old headers will be fetched, but none will be displayed.
81 The server has to support NOV for any of this to work."
83 :type '(choice (const :tag "off" nil)
86 (sexp :menu-tag "other" t)))
88 (defcustom gnus-refer-thread-limit 200
89 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
90 If t, fetch all the available old headers."
93 (sexp :menu-tag "other" t)))
95 (defcustom gnus-summary-make-false-root 'adopt
96 "*nil means that Gnus won't gather loose threads.
97 If the root of a thread has expired or been read in a previous
98 session, the information necessary to build a complete thread has been
99 lost. Instead of having many small sub-threads from this original thread
100 scattered all over the summary buffer, Gnus can gather them.
102 If non-nil, Gnus will try to gather all loose sub-threads from an
103 original thread into one large thread.
105 If this variable is non-nil, it should be one of `none', `adopt',
108 If this variable is `none', Gnus will not make a false root, but just
109 present the sub-threads after another.
110 If this variable is `dummy', Gnus will create a dummy root that will
111 have all the sub-threads as children.
112 If this variable is `adopt', Gnus will make one of the \"children\"
113 the parent and mark all the step-children as such.
114 If this variable is `empty', the \"children\" are printed with empty
115 subject fields. (Or rather, they will be printed with a string
116 given by the `gnus-summary-same-subject' variable.)"
118 :type '(choice (const :tag "off" nil)
124 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
125 "*A regexp to match subjects to be excluded from loose thread gathering.
126 As loose thread gathering is done on subjects only, that means that
127 there can be many false gatherings performed. By rooting out certain
128 common subjects, gathering might become saner."
132 (defcustom gnus-summary-gather-subject-limit nil
133 "*Maximum length of subject comparisons when gathering loose threads.
134 Use nil to compare full subjects. Setting this variable to a low
135 number will help gather threads that have been corrupted by
136 newsreaders chopping off subject lines, but it might also mean that
137 unrelated articles that have subject that happen to begin with the
138 same few characters will be incorrectly gathered.
140 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
143 :type '(choice (const :tag "off" nil)
145 (sexp :menu-tag "on" t)))
147 (defcustom gnus-simplify-subject-functions nil
148 "List of functions taking a string argument that simplify subjects.
149 The functions are applied recursively.
151 Useful functions to put in this list include: `gnus-simplify-subject-re',
152 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 (they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-default-high-score 0
217 "*Default threshold for a high scored article.
218 An article will be highlighted as high scored if its score is greater
220 :group 'gnus-score-default
223 (defcustom gnus-summary-default-low-score 0
224 "*Default threshold for a low scored article.
225 An article will be highlighted as low scored if its score is smaller
227 :group 'gnus-score-default
230 (defcustom gnus-summary-zcore-fuzz 0
231 "*Fuzziness factor for the zcore in the summary buffer.
232 Articles with scores closer than this to `gnus-summary-default-score'
234 :group 'gnus-summary-format
237 (defcustom gnus-simplify-subject-fuzzy-regexp nil
238 "*Strings to be removed when doing fuzzy matches.
239 This can either be a regular expression or list of regular expressions
240 that will be removed from subject strings if fuzzy subject
241 simplification is selected."
243 :type '(repeat regexp))
245 (defcustom gnus-show-threads t
246 "*If non-nil, display threads in summary mode."
250 (defcustom gnus-thread-hide-subtree nil
251 "*If non-nil, hide all threads initially.
252 If threads are hidden, you have to run the command
253 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
254 to expose hidden threads."
258 (defcustom gnus-thread-hide-killed t
259 "*If non-nil, hide killed threads automatically."
263 (defcustom gnus-thread-ignore-subject t
264 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
265 If nil, articles that have different subjects from their parents will
266 start separate threads."
270 (defcustom gnus-thread-operation-ignore-subject t
271 "*If non-nil, subjects will be ignored when doing thread commands.
272 This affects commands like `gnus-summary-kill-thread' and
273 `gnus-summary-lower-thread'.
275 If this variable is nil, articles in the same thread with different
276 subjects will not be included in the operation in question. If this
277 variable is `fuzzy', only articles that have subjects that are fuzzily
278 equal will be included."
280 :type '(choice (const :tag "off" nil)
284 (defcustom gnus-thread-indent-level 4
285 "*Number that says how much each sub-thread should be indented."
289 (defcustom gnus-auto-extend-newsgroup t
290 "*If non-nil, extend newsgroup forward and backward when requested."
291 :group 'gnus-summary-choose
294 (defcustom gnus-auto-select-first t
295 "*If nil, don't select the first unread article when entering a group.
296 If this variable is `best', select the highest-scored unread article
297 in the group. If t, select the first unread article.
299 This variable can also be a function to place point on a likely
300 subject line. Useful values include `gnus-summary-first-unread-subject',
301 `gnus-summary-first-unread-article' and
302 `gnus-summary-best-unread-article'.
304 If you want to prevent automatic selection of the first unread article
305 in some newsgroups, set the variable to nil in
306 `gnus-select-group-hook'."
307 :group 'gnus-group-select
308 :type '(choice (const :tag "none" nil)
310 (sexp :menu-tag "first" t)
311 (function-item gnus-summary-first-unread-subject)
312 (function-item gnus-summary-first-unread-article)
313 (function-item gnus-summary-best-unread-article)))
315 (defcustom gnus-dont-select-after-jump-to-other-group nil
316 "If non-nil, don't select the first unread article after entering the
317 other group by the command `gnus-summary-jump-to-other-group'. If nil,
318 it is depend on the value of `gnus-auto-select-first' whether to select
320 :group 'gnus-group-select
323 (defcustom gnus-auto-select-next t
324 "*If non-nil, offer to go to the next group from the end of the previous.
325 If the value is t and the next newsgroup is empty, Gnus will exit
326 summary mode and go back to group mode. If the value is neither nil
327 nor t, Gnus will select the following unread newsgroup. In
328 particular, if the value is the symbol `quietly', the next unread
329 newsgroup will be selected without any confirmation, and if it is
330 `almost-quietly', the next group will be selected without any
331 confirmation if you are located on the last article in the group.
332 Finally, if this variable is `slightly-quietly', the `Z n' command
333 will go to the next group without confirmation."
334 :group 'gnus-summary-maneuvering
335 :type '(choice (const :tag "off" nil)
337 (const almost-quietly)
338 (const slightly-quietly)
339 (sexp :menu-tag "on" t)))
341 (defcustom gnus-auto-select-same nil
342 "*If non-nil, select the next article with the same subject.
343 If there are no more articles with the same subject, go to
344 the first unread article."
345 :group 'gnus-summary-maneuvering
348 (defcustom gnus-summary-check-current nil
349 "*If non-nil, consider the current article when moving.
350 The \"unread\" movement commands will stay on the same line if the
351 current article is unread."
352 :group 'gnus-summary-maneuvering
355 (defcustom gnus-auto-center-summary t
356 "*If non-nil, always center the current summary buffer.
357 In particular, if `vertical' do only vertical recentering. If non-nil
358 and non-`vertical', do both horizontal and vertical recentering."
359 :group 'gnus-summary-maneuvering
360 :type '(choice (const :tag "none" nil)
362 (integer :tag "height")
363 (sexp :menu-tag "both" t)))
365 (defcustom gnus-show-all-headers nil
366 "*If non-nil, don't hide any headers."
367 :group 'gnus-article-hiding
368 :group 'gnus-article-headers
371 (defcustom gnus-summary-ignore-duplicates nil
372 "*If non-nil, ignore articles with identical Message-ID headers."
376 (defcustom gnus-single-article-buffer t
377 "*If non-nil, display all articles in the same buffer.
378 If nil, each group will get its own article buffer."
379 :group 'gnus-article-various
382 (defcustom gnus-break-pages t
383 "*If non-nil, do page breaking on articles.
384 The page delimiter is specified by the `gnus-page-delimiter'
386 :group 'gnus-article-various
389 (defcustom gnus-show-mime t
390 "*If non-nil, do mime processing of articles.
391 The articles will simply be fed to the function given by
392 `gnus-article-display-method-for-mime'."
393 :group 'gnus-article-mime
396 (defcustom gnus-move-split-methods nil
397 "*Variable used to suggest where articles are to be moved to.
398 It uses the same syntax as the `gnus-split-methods' variable.
399 However, whereas `gnus-split-methods' specifies file names as targets,
400 this variable specifies group names."
401 :group 'gnus-summary-mail
402 :type '(repeat (choice (list :value (fun) function)
403 (cons :value ("" "") regexp (repeat string))
406 (defcustom gnus-unread-mark ? ;Whitespace
407 "*Mark used for unread articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-ticked-mark ?!
412 "*Mark used for ticked articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-dormant-mark ??
417 "*Mark used for dormant articles."
418 :group 'gnus-summary-marks
421 (defcustom gnus-del-mark ?r
422 "*Mark used for del'd articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-read-mark ?R
427 "*Mark used for read articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-expirable-mark ?E
432 "*Mark used for expirable articles."
433 :group 'gnus-summary-marks
436 (defcustom gnus-killed-mark ?K
437 "*Mark used for killed articles."
438 :group 'gnus-summary-marks
441 (defcustom gnus-souped-mark ?F
442 "*Mark used for souped articles."
443 :group 'gnus-summary-marks
446 (defcustom gnus-kill-file-mark ?X
447 "*Mark used for articles killed by kill files."
448 :group 'gnus-summary-marks
451 (defcustom gnus-low-score-mark ?Y
452 "*Mark used for articles with a low score."
453 :group 'gnus-summary-marks
456 (defcustom gnus-catchup-mark ?C
457 "*Mark used for articles that are caught up."
458 :group 'gnus-summary-marks
461 (defcustom gnus-replied-mark ?A
462 "*Mark used for articles that have been replied to."
463 :group 'gnus-summary-marks
466 (defcustom gnus-forwarded-mark ?O
467 "*Mark used for articles that have been forwarded."
468 :group 'gnus-summary-marks
471 (defcustom gnus-cached-mark ?*
472 "*Mark used for articles that are in the cache."
473 :group 'gnus-summary-marks
476 (defcustom gnus-saved-mark ?S
477 "*Mark used for articles that have been saved to."
478 :group 'gnus-summary-marks
481 (defcustom gnus-no-mark ? ;Whitespace
482 "*Mark used for articles that have no other secondary mark."
483 :group 'gnus-summary-marks
486 (defcustom gnus-ancient-mark ?O
487 "*Mark used for ancient articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-sparse-mark ?Q
492 "*Mark used for sparsely reffed articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-canceled-mark ?G
497 "*Mark used for canceled articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-duplicate-mark ?M
502 "*Mark used for duplicate articles."
503 :group 'gnus-summary-marks
506 (defcustom gnus-undownloaded-mark ?@
507 "*Mark used for articles that weren't downloaded."
508 :group 'gnus-summary-marks
511 (defcustom gnus-downloadable-mark ?%
512 "*Mark used for articles that are to be downloaded."
513 :group 'gnus-summary-marks
516 (defcustom gnus-unsendable-mark ?=
517 "*Mark used for articles that won't be sent."
518 :group 'gnus-summary-marks
521 (defcustom gnus-score-over-mark ?+
522 "*Score mark used for articles with high scores."
523 :group 'gnus-summary-marks
526 (defcustom gnus-score-below-mark ?-
527 "*Score mark used for articles with low scores."
528 :group 'gnus-summary-marks
531 (defcustom gnus-empty-thread-mark ? ;Whitespace
532 "*There is no thread under the article."
533 :group 'gnus-summary-marks
536 (defcustom gnus-not-empty-thread-mark ?=
537 "*There is a thread under the article."
538 :group 'gnus-summary-marks
541 (defcustom gnus-view-pseudo-asynchronously nil
542 "*If non-nil, Gnus will view pseudo-articles asynchronously."
543 :group 'gnus-extract-view
546 (defcustom gnus-auto-expirable-marks
547 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
548 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
549 gnus-souped-mark gnus-duplicate-mark)
550 "*The list of marks converted into expiration if a group is auto-expirable."
553 :type '(repeat character))
555 (defcustom gnus-inhibit-user-auto-expire t
556 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
561 (defcustom gnus-view-pseudos nil
562 "*If `automatic', pseudo-articles will be viewed automatically.
563 If `not-confirm', pseudos will be viewed automatically, and the user
564 will not be asked to confirm the command."
565 :group 'gnus-extract-view
566 :type '(choice (const :tag "off" nil)
568 (const not-confirm)))
570 (defcustom gnus-view-pseudos-separately t
571 "*If non-nil, one pseudo-article will be created for each file to be viewed.
572 If nil, all files that use the same viewing command will be given as a
573 list of parameters to that command."
574 :group 'gnus-extract-view
577 (defcustom gnus-insert-pseudo-articles t
578 "*If non-nil, insert pseudo-articles when decoding articles."
579 :group 'gnus-extract-view
582 (defcustom gnus-summary-dummy-line-format
584 "*The format specification for the dummy roots in the summary buffer.
585 It works along the same lines as a normal formatting string,
586 with some simple extensions.
589 :group 'gnus-threading
592 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
593 "*The format specification for the summary mode line.
594 It works along the same lines as a normal formatting string,
595 with some simple extensions:
598 %p Unprefixed group name
599 %A Current article number
600 %z Current article score
602 %U Number of unread articles in the group
603 %e Number of unselected articles in the group
604 %Z A string with unread/unselected article counts
605 %g Shortish group name
606 %S Subject of the current article
608 %s Current score file name
609 %d Number of dormant articles
610 %r Number of articles that have been marked as read in this session
611 %E Number of articles expunged by the score files"
612 :group 'gnus-summary-format
615 (defcustom gnus-list-identifiers nil
616 "Regexp that matches list identifiers to be removed from subject.
617 This can also be a list of regexps."
619 :group 'gnus-summary-format
620 :group 'gnus-article-hiding
621 :type '(choice (const :tag "none" nil)
623 (repeat :value (".*") regexp)))
625 (defcustom gnus-summary-mark-below 0
626 "*Mark all articles with a score below this variable as read.
627 This variable is local to each summary buffer and usually set by the
629 :group 'gnus-score-default
632 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
633 "*List of functions used for sorting articles in the summary buffer.
635 Each function takes two articles and returns non-nil if the first
636 article should be sorted before the other. If you use more than one
637 function, the primary sort function should be the last. You should
638 probably always include `gnus-article-sort-by-number' in the list of
639 sorting functions -- preferably first. Also note that sorting by date
640 is often much slower than sorting by number, and the sorting order is
641 very similar. (Sorting by date means sorting by the time the message
642 was sent, sorting by number means sorting by arrival time.)
644 Ready-made functions include `gnus-article-sort-by-number',
645 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
646 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
648 When threading is turned on, the variable `gnus-thread-sort-functions'
649 controls how articles are sorted."
650 :group 'gnus-summary-sort
651 :type '(repeat (choice (function-item gnus-article-sort-by-number)
652 (function-item gnus-article-sort-by-author)
653 (function-item gnus-article-sort-by-subject)
654 (function-item gnus-article-sort-by-date)
655 (function-item gnus-article-sort-by-score)
656 (function :tag "other"))))
658 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
659 "*List of functions used for sorting threads in the summary buffer.
660 By default, threads are sorted by article number.
662 Each function takes two threads and returns non-nil if the first
663 thread should be sorted before the other. If you use more than one
664 function, the primary sort function should be the last. You should
665 probably always include `gnus-thread-sort-by-number' in the list of
666 sorting functions -- preferably first. Also note that sorting by date
667 is often much slower than sorting by number, and the sorting order is
668 very similar. (Sorting by date means sorting by the time the message
669 was sent, sorting by number means sorting by arrival time.)
671 Ready-made functions include `gnus-thread-sort-by-number',
672 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
673 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
674 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
676 When threading is turned off, the variable
677 `gnus-article-sort-functions' controls how articles are sorted."
678 :group 'gnus-summary-sort
679 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
680 (function-item gnus-thread-sort-by-author)
681 (function-item gnus-thread-sort-by-subject)
682 (function-item gnus-thread-sort-by-date)
683 (function-item gnus-thread-sort-by-score)
684 (function-item gnus-thread-sort-by-total-score)
685 (function :tag "other"))))
687 (defcustom gnus-thread-score-function '+
688 "*Function used for calculating the total score of a thread.
690 The function is called with the scores of the article and each
691 subthread and should then return the score of the thread.
693 Some functions you can use are `+', `max', or `min'."
694 :group 'gnus-summary-sort
697 (defcustom gnus-summary-expunge-below nil
698 "All articles that have a score less than this variable will be expunged.
699 This variable is local to the summary buffers."
700 :group 'gnus-score-default
701 :type '(choice (const :tag "off" nil)
704 (defcustom gnus-thread-expunge-below nil
705 "All threads that have a total score less than this variable will be expunged.
706 See `gnus-thread-score-function' for en explanation of what a
709 This variable is local to the summary buffers."
710 :group 'gnus-threading
711 :group 'gnus-score-default
712 :type '(choice (const :tag "off" nil)
715 (defcustom gnus-summary-mode-hook nil
716 "*A hook for Gnus summary mode.
717 This hook is run before any variables are set in the summary buffer."
718 :options '(turn-on-gnus-mailing-list-mode)
719 :group 'gnus-summary-various
722 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
723 (when (featurep 'xemacs)
724 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
725 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
726 (add-hook 'gnus-summary-mode-hook
727 'gnus-xmas-switch-horizontal-scrollbar-off))
729 (defcustom gnus-summary-menu-hook nil
730 "*Hook run after the creation of the summary mode menu."
731 :group 'gnus-summary-visual
734 (defcustom gnus-summary-exit-hook nil
735 "*A hook called on exit from the summary buffer.
736 It will be called with point in the group buffer."
737 :group 'gnus-summary-exit
740 (defcustom gnus-summary-prepare-hook nil
741 "*A hook called after the summary buffer has been generated.
742 If you want to modify the summary buffer, you can use this hook."
743 :group 'gnus-summary-various
746 (defcustom gnus-summary-prepared-hook nil
747 "*A hook called as the last thing after the summary buffer has been generated."
748 :group 'gnus-summary-various
751 (defcustom gnus-summary-generate-hook nil
752 "*A hook run just before generating the summary buffer.
753 This hook is commonly used to customize threading variables and the
755 :group 'gnus-summary-various
758 (defcustom gnus-select-group-hook nil
759 "*A hook called when a newsgroup is selected.
761 If you'd like to simplify subjects like the
762 `gnus-summary-next-same-subject' command does, you can use the
765 (setq gnus-select-group-hook
768 (mapcar (lambda (header)
769 (mail-header-set-subject
771 (gnus-simplify-subject
772 (mail-header-subject header) 're-only)))
773 gnus-newsgroup-headers))))"
774 :group 'gnus-group-select
777 (defcustom gnus-select-article-hook nil
778 "*A hook called when an article is selected."
779 :group 'gnus-summary-choose
782 (defcustom gnus-visual-mark-article-hook
783 (list 'gnus-highlight-selected-summary)
784 "*Hook run after selecting an article in the summary buffer.
785 It is meant to be used for highlighting the article in some way. It
786 is not run if `gnus-visual' is nil."
787 :group 'gnus-summary-visual
790 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
791 "*A hook called before parsing the headers."
795 (defcustom gnus-exit-group-hook nil
796 "*A hook called when exiting summary mode.
797 This hook is not called from the non-updating exit commands like `Q'."
801 (defcustom gnus-summary-update-hook
802 (list 'gnus-summary-highlight-line)
803 "*A hook called when a summary line is changed.
804 The hook will not be called if `gnus-visual' is nil.
806 The default function `gnus-summary-highlight-line' will
807 highlight the line according to the `gnus-summary-highlight'
809 :group 'gnus-summary-visual
812 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
813 "*A hook called when an article is selected for the first time.
814 The hook is intended to mark an article as read (or unread)
815 automatically when it is selected."
816 :group 'gnus-summary-choose
819 (defcustom gnus-group-no-more-groups-hook nil
820 "*A hook run when returning to group mode having no more (unread) groups."
821 :group 'gnus-group-select
824 (defcustom gnus-ps-print-hook nil
825 "*A hook run before ps-printing something from Gnus."
829 (defcustom gnus-summary-display-arrow
830 (and (fboundp 'display-graphic-p)
832 "*If non-nil, display an arrow highlighting the current article."
837 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
838 "Face used for highlighting the current article in the summary buffer."
839 :group 'gnus-summary-visual
842 (defcustom gnus-summary-highlight
843 '(((= mark gnus-canceled-mark)
844 . gnus-summary-cancelled-face)
845 ((and (> score default-high)
846 (or (= mark gnus-dormant-mark)
847 (= mark gnus-ticked-mark)))
848 . gnus-summary-high-ticked-face)
849 ((and (< score default-low)
850 (or (= mark gnus-dormant-mark)
851 (= mark gnus-ticked-mark)))
852 . gnus-summary-low-ticked-face)
853 ((or (= mark gnus-dormant-mark)
854 (= mark gnus-ticked-mark))
855 . gnus-summary-normal-ticked-face)
856 ((and (> score default-high) (= mark gnus-ancient-mark))
857 . gnus-summary-high-ancient-face)
858 ((and (< score default-low) (= mark gnus-ancient-mark))
859 . gnus-summary-low-ancient-face)
860 ((= mark gnus-ancient-mark)
861 . gnus-summary-normal-ancient-face)
862 ((and (> score default-high) (= mark gnus-unread-mark))
863 . gnus-summary-high-unread-face)
864 ((and (< score default-low) (= mark gnus-unread-mark))
865 . gnus-summary-low-unread-face)
866 ((= mark gnus-unread-mark)
867 . gnus-summary-normal-unread-face)
868 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
869 gnus-undownloaded-mark)))
870 . gnus-summary-high-unread-face)
871 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
872 gnus-undownloaded-mark)))
873 . gnus-summary-low-unread-face)
874 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
875 (memq article gnus-newsgroup-unreads))
876 . gnus-summary-normal-unread-face)
877 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
878 . gnus-summary-normal-read-face)
879 ((> score default-high)
880 . gnus-summary-high-read-face)
881 ((< score default-low)
882 . gnus-summary-low-read-face)
884 . gnus-summary-normal-read-face))
885 "*Controls the highlighting of summary buffer lines.
887 A list of (FORM . FACE) pairs. When deciding how a a particular
888 summary line should be displayed, each form is evaluated. The content
889 of the face field after the first true form is used. You can change
890 how those summary lines are displayed, by editing the face field.
892 You can use the following variables in the FORM field.
894 score: The article's score
895 default: The default article score.
896 default-high: The default score for high scored articles.
897 default-low: The default score for low scored articles.
898 below: The score below which articles are automatically marked as read.
899 mark: The articles mark."
900 :group 'gnus-summary-visual
901 :type '(repeat (cons (sexp :tag "Form" nil)
904 (defcustom gnus-alter-header-function nil
905 "Function called to allow alteration of article header structures.
906 The function is called with one parameter, the article header vector,
907 which it may alter in any way.")
909 (defvar gnus-decode-encoded-word-function
910 (mime-find-field-decoder 'From 'nov)
911 "Variable that says which function should be used to decode a string with encoded words.")
913 (defcustom gnus-extra-headers nil
914 "*Extra headers to parse."
917 :type '(repeat symbol))
919 (defcustom gnus-ignored-from-addresses
920 (and user-mail-address (regexp-quote user-mail-address))
921 "*Regexp of From headers that may be suppressed in favor of To headers."
926 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
927 "List of charsets that should be ignored.
928 When these charsets are used in the \"charset\" parameter, the
929 default charset will be used instead."
931 :type '(repeat symbol)
932 :group 'gnus-charset)
934 (gnus-define-group-parameter
938 "Return the ignored charsets of GROUP."
939 :variable gnus-group-ignored-charsets-alist
941 '(("alt\\.chinese\\.text" iso-8859-1))
943 "Alist of regexps (to match group names) and charsets that should be ignored.
944 When these charsets are used in the \"charset\" parameter, the
945 default charset will be used instead."
946 :variable-group gnus-charset
947 :variable-type '(repeat (cons (regexp :tag "Group")
949 :parameter-type '(choice :tag "Ignored charsets"
952 :parameter-document "\
953 List of charsets that should be ignored.
955 When these charsets are used in the \"charset\" parameter, the
956 default charset will be used instead.")
958 (defcustom gnus-group-highlight-words-alist nil
959 "Alist of group regexps and highlight regexps.
960 This variable uses the same syntax as `gnus-emphasis-alist'."
962 :type '(repeat (cons (regexp :tag "Group")
963 (repeat (list (regexp :tag "Highlight regexp")
964 (number :tag "Group for entire word" 0)
965 (number :tag "Group for displayed part" 0)
967 gnus-emphasis-highlight-words)))))
968 :group 'gnus-summary-visual)
970 (defcustom gnus-use-wheel nil
971 "Use Intelli-mouse on summary movement"
973 :group 'gnus-summary-maneuvering)
975 (defcustom gnus-wheel-scroll-amount '(5 . 1)
976 "Amount to scroll messages by spinning the mouse wheel.
977 This is actually a cons cell, where the first item is the amount to scroll
978 on a normal wheel event, and the second is the amount to scroll when the
979 wheel is moved with the shift key depressed."
980 :type '(cons (integer :tag "Shift") integer)
981 :group 'gnus-summary-maneuvering)
983 (defcustom gnus-wheel-edge-resistance 2
984 "How hard it should be to change the current article
985 by moving the mouse over the edge of the article window."
987 :group 'gnus-summary-maneuvering)
989 (defcustom gnus-summary-show-article-charset-alist
991 "Alist of number and charset.
992 The article will be shown with the charset corresponding to the
994 For example: ((1 . cn-gb-2312) (2 . big5))."
996 :type '(repeat (cons (number :tag "Argument" 1)
997 (symbol :tag "Charset")))
998 :group 'gnus-charset)
1000 (defcustom gnus-preserve-marks t
1001 "Whether marks are preserved when moving, copying and respooling messages."
1004 :group 'gnus-summary-marks)
1006 (defcustom gnus-alter-articles-to-read-function nil
1007 "Function to be called to alter the list of articles to be selected."
1008 :type '(choice (const nil) function)
1009 :group 'gnus-summary)
1011 (defcustom gnus-orphan-score nil
1012 "*All orphans get this score added. Set in the score file."
1013 :group 'gnus-score-default
1014 :type '(choice (const nil)
1017 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1018 "*A regexp to match MIME parts when saving multiple parts of a message
1019 with gnus-summary-save-parts (X m). This regexp will be used by default
1020 when prompting the user for which type of files to save."
1021 :group 'gnus-summary
1025 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1026 "*A regexp to match MIME parts when saving multiple parts of a message
1027 with gnus-summary-save-parts (X m). This regexp will be used by default
1028 when prompting the user for which type of files to save."
1029 :group 'gnus-summary
1032 (defcustom gnus-read-all-available-headers nil
1033 "Whether Gnus should parse all headers made available to it.
1034 This is mostly relevant for slow backends where the user may
1035 wish to widen the summary buffer to include all headers
1036 that were fetched. Say, for nnultimate groups."
1037 :group 'gnus-summary
1038 :type '(choice boolean regexp))
1040 ;;; Internal variables
1042 (defvar gnus-article-mime-handles nil)
1043 (defvar gnus-article-decoded-p nil)
1044 (defvar gnus-article-charset nil)
1045 (defvar gnus-article-ignored-charsets nil)
1046 (defvar gnus-scores-exclude-files nil)
1047 (defvar gnus-page-broken nil)
1048 (defvar gnus-inhibit-mime-unbuttonizing nil)
1050 (defvar gnus-original-article nil)
1051 (defvar gnus-article-internal-prepare-hook nil)
1052 (defvar gnus-newsgroup-process-stack nil)
1054 (defvar gnus-thread-indent-array nil)
1055 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1056 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1057 "Function called to sort the articles within a thread after it has been gathered together.")
1059 (defvar gnus-summary-save-parts-type-history nil)
1060 (defvar gnus-summary-save-parts-last-directory nil)
1062 (defvar gnus-summary-save-parts-type-history nil)
1063 (defvar gnus-summary-save-parts-last-directory nil)
1065 ;; Avoid highlighting in kill files.
1066 (defvar gnus-summary-inhibit-highlight nil)
1067 (defvar gnus-newsgroup-selected-overlay nil)
1068 (defvar gnus-inhibit-limiting nil)
1069 (defvar gnus-newsgroup-adaptive-score-file nil)
1070 (defvar gnus-current-score-file nil)
1071 (defvar gnus-current-move-group nil)
1072 (defvar gnus-current-copy-group nil)
1073 (defvar gnus-current-crosspost-group nil)
1075 (defvar gnus-newsgroup-dependencies nil)
1076 (defvar gnus-newsgroup-adaptive nil)
1077 (defvar gnus-summary-display-article-function nil)
1078 (defvar gnus-summary-highlight-line-function nil
1079 "Function called after highlighting a summary line.")
1081 (defvar gnus-summary-line-format-alist
1082 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1083 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1084 (?s gnus-tmp-subject-or-nil ?s)
1085 (?n gnus-tmp-name ?s)
1086 (?A (std11-address-string
1087 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1088 (?a (or (std11-full-name-string
1089 (car (mime-entity-read-field gnus-tmp-header 'From)))
1091 (?F gnus-tmp-from ?s)
1092 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1093 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1094 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1095 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1096 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1097 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1098 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1099 (?L gnus-tmp-lines ?s)
1100 (?I gnus-tmp-indentation ?s)
1101 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1102 (?R gnus-tmp-replied ?c)
1103 (?\[ gnus-tmp-opening-bracket ?c)
1104 (?\] gnus-tmp-closing-bracket ?c)
1105 (?\> (make-string gnus-tmp-level ? ) ?s)
1106 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1107 (?i gnus-tmp-score ?d)
1108 (?z gnus-tmp-score-char ?c)
1109 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1110 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1111 (?U gnus-tmp-unread ?c)
1112 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1113 (?t (gnus-summary-number-of-articles-in-thread
1114 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1116 (?e (gnus-summary-number-of-articles-in-thread
1117 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1119 (?u gnus-tmp-user-defined ?s)
1120 (?P (gnus-pick-line-number) ?d)
1121 (?B gnus-tmp-thread-tree-header-string ?s))
1122 "An alist of format specifications that can appear in summary lines.
1123 These are paired with what variables they correspond with, along with
1124 the type of the variable (string, integer, character, etc).")
1126 (defvar gnus-summary-dummy-line-format-alist
1127 `((?S gnus-tmp-subject ?s)
1128 (?N gnus-tmp-number ?d)
1129 (?u gnus-tmp-user-defined ?s)))
1131 (defvar gnus-summary-mode-line-format-alist
1132 `((?G gnus-tmp-group-name ?s)
1133 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1134 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1135 (?A gnus-tmp-article-number ?d)
1136 (?Z gnus-tmp-unread-and-unselected ?s)
1137 (?V gnus-version ?s)
1138 (?U gnus-tmp-unread-and-unticked ?d)
1139 (?S gnus-tmp-subject ?s)
1140 (?e gnus-tmp-unselected ?d)
1141 (?u gnus-tmp-user-defined ?s)
1142 (?d (length gnus-newsgroup-dormant) ?d)
1143 (?t (length gnus-newsgroup-marked) ?d)
1144 (?r (length gnus-newsgroup-reads) ?d)
1145 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1146 (?E gnus-newsgroup-expunged-tally ?d)
1147 (?s (gnus-current-score-file-nondirectory) ?s)))
1149 (defvar gnus-last-search-regexp nil
1150 "Default regexp for article search command.")
1152 (defvar gnus-summary-search-article-matched-data nil
1153 "Last matched data of article search command. It is the local variable
1154 in `gnus-article-buffer' which consists of the list of start position,
1155 end position and text.")
1157 (defvar gnus-last-shell-command nil
1158 "Default shell command on article.")
1160 (defvar gnus-newsgroup-begin nil)
1161 (defvar gnus-newsgroup-end nil)
1162 (defvar gnus-newsgroup-last-rmail nil)
1163 (defvar gnus-newsgroup-last-mail nil)
1164 (defvar gnus-newsgroup-last-folder nil)
1165 (defvar gnus-newsgroup-last-file nil)
1166 (defvar gnus-newsgroup-auto-expire nil)
1167 (defvar gnus-newsgroup-active nil)
1169 (defvar gnus-newsgroup-data nil)
1170 (defvar gnus-newsgroup-data-reverse nil)
1171 (defvar gnus-newsgroup-limit nil)
1172 (defvar gnus-newsgroup-limits nil)
1174 (defvar gnus-newsgroup-unreads nil
1175 "List of unread articles in the current newsgroup.")
1177 (defvar gnus-newsgroup-unselected nil
1178 "List of unselected unread articles in the current newsgroup.")
1180 (defvar gnus-newsgroup-reads nil
1181 "Alist of read articles and article marks in the current newsgroup.")
1183 (defvar gnus-newsgroup-expunged-tally nil)
1185 (defvar gnus-newsgroup-marked nil
1186 "List of ticked articles in the current newsgroup (a subset of unread art).")
1188 (defvar gnus-newsgroup-killed nil
1189 "List of ranges of articles that have been through the scoring process.")
1191 (defvar gnus-newsgroup-cached nil
1192 "List of articles that come from the article cache.")
1194 (defvar gnus-newsgroup-saved nil
1195 "List of articles that have been saved.")
1197 (defvar gnus-newsgroup-kill-headers nil)
1199 (defvar gnus-newsgroup-replied nil
1200 "List of articles that have been replied to in the current newsgroup.")
1202 (defvar gnus-newsgroup-forwarded nil
1203 "List of articles that have been forwarded in the current newsgroup.")
1205 (defvar gnus-newsgroup-expirable nil
1206 "List of articles in the current newsgroup that can be expired.")
1208 (defvar gnus-newsgroup-processable nil
1209 "List of articles in the current newsgroup that can be processed.")
1211 (defvar gnus-newsgroup-downloadable nil
1212 "List of articles in the current newsgroup that can be processed.")
1214 (defvar gnus-newsgroup-undownloaded nil
1215 "List of articles in the current newsgroup that haven't been downloaded..")
1217 (defvar gnus-newsgroup-unsendable nil
1218 "List of articles in the current newsgroup that won't be sent.")
1220 (defvar gnus-newsgroup-bookmarks nil
1221 "List of articles in the current newsgroup that have bookmarks.")
1223 (defvar gnus-newsgroup-dormant nil
1224 "List of dormant articles in the current newsgroup.")
1226 (defvar gnus-newsgroup-scored nil
1227 "List of scored articles in the current newsgroup.")
1229 (defvar gnus-newsgroup-incorporated nil
1230 "List of incorporated articles in the current newsgroup.")
1232 (defvar gnus-newsgroup-headers nil
1233 "List of article headers in the current newsgroup.")
1235 (defvar gnus-newsgroup-threads nil)
1237 (defvar gnus-newsgroup-prepared nil
1238 "Whether the current group has been prepared properly.")
1240 (defvar gnus-newsgroup-ancient nil
1241 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1243 (defvar gnus-newsgroup-sparse nil)
1245 (defvar gnus-current-article nil)
1246 (defvar gnus-article-current nil)
1247 (defvar gnus-current-headers nil)
1248 (defvar gnus-have-all-headers nil)
1249 (defvar gnus-last-article nil)
1250 (defvar gnus-newsgroup-history nil)
1251 (defvar gnus-newsgroup-charset nil)
1252 (defvar gnus-newsgroup-ephemeral-charset nil)
1253 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1255 (defvar gnus-article-before-search nil)
1257 (defconst gnus-summary-local-variables
1258 '(gnus-newsgroup-name
1259 gnus-newsgroup-begin gnus-newsgroup-end
1260 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1261 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1262 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1263 gnus-newsgroup-unselected gnus-newsgroup-marked
1264 gnus-newsgroup-reads gnus-newsgroup-saved
1265 gnus-newsgroup-replied gnus-newsgroup-forwarded
1266 gnus-newsgroup-expirable
1267 gnus-newsgroup-processable gnus-newsgroup-killed
1268 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1269 gnus-newsgroup-unsendable
1270 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1271 gnus-newsgroup-headers gnus-newsgroup-threads
1272 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1273 gnus-current-article gnus-current-headers gnus-have-all-headers
1274 gnus-last-article gnus-article-internal-prepare-hook
1275 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1276 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1277 gnus-thread-expunge-below
1278 gnus-score-alist gnus-current-score-file
1279 (gnus-summary-expunge-below . global)
1280 (gnus-summary-mark-below . global)
1281 (gnus-orphan-score . global)
1282 gnus-newsgroup-active gnus-scores-exclude-files
1283 gnus-newsgroup-history gnus-newsgroup-ancient
1284 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1285 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1286 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1287 (gnus-newsgroup-expunged-tally . 0)
1288 gnus-cache-removable-articles gnus-newsgroup-cached
1289 gnus-newsgroup-data gnus-newsgroup-data-reverse
1290 gnus-newsgroup-limit gnus-newsgroup-limits
1291 gnus-newsgroup-charset
1292 gnus-newsgroup-incorporated)
1293 "Variables that are buffer-local to the summary buffers.")
1295 (defvar gnus-newsgroup-variables nil
1296 "Variables that have separate values in the newsgroups.")
1298 ;; Byte-compiler warning.
1299 (eval-when-compile (defvar gnus-article-mode-map))
1301 ;; Subject simplification.
1303 (defun gnus-simplify-whitespace (str)
1304 "Remove excessive whitespace from STR."
1307 (while (string-match "[ \t][ \t]+" mystr)
1308 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1310 (substring mystr (match-end 0)))))
1312 (when (string-match "^[ \t]+" mystr)
1313 (setq mystr (substring mystr (match-end 0))))
1315 (when (string-match "[ \t]+$" mystr)
1316 (setq mystr (substring mystr 0 (match-beginning 0))))
1319 (defsubst gnus-simplify-subject-re (subject)
1320 "Remove \"Re:\" from subject lines."
1321 (if (string-match message-subject-re-regexp subject)
1322 (substring subject (match-end 0))
1325 (defun gnus-simplify-subject (subject &optional re-only)
1326 "Remove `Re:' and words in parentheses.
1327 If RE-ONLY is non-nil, strip leading `Re:'s only."
1328 (let ((case-fold-search t)) ;Ignore case.
1329 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1330 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1331 (setq subject (substring subject (match-end 0))))
1332 ;; Remove uninteresting prefixes.
1333 (when (and (not re-only)
1334 gnus-simplify-ignored-prefixes
1335 (string-match gnus-simplify-ignored-prefixes subject))
1336 (setq subject (substring subject (match-end 0))))
1337 ;; Remove words in parentheses from end.
1339 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1340 (setq subject (substring subject 0 (match-beginning 0)))))
1341 ;; Return subject string.
1344 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1346 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1347 (goto-char (point-min))
1348 (while (re-search-forward regexp nil t)
1349 (replace-match (or newtext ""))))
1351 (defun gnus-simplify-buffer-fuzzy ()
1352 "Simplify string in the buffer fuzzily.
1353 The string in the accessible portion of the current buffer is simplified.
1354 It is assumed to be a single-line subject.
1355 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1356 matter is removed. Additional things can be deleted by setting
1357 `gnus-simplify-subject-fuzzy-regexp'."
1358 (let ((case-fold-search t)
1360 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1362 (while (not (eq modified-tick (buffer-modified-tick)))
1363 (setq modified-tick (buffer-modified-tick))
1365 ((listp gnus-simplify-subject-fuzzy-regexp)
1366 (mapcar 'gnus-simplify-buffer-fuzzy-step
1367 gnus-simplify-subject-fuzzy-regexp))
1368 (gnus-simplify-subject-fuzzy-regexp
1369 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1370 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1371 (gnus-simplify-buffer-fuzzy-step
1372 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1373 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1375 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1376 (gnus-simplify-buffer-fuzzy-step " +" " ")
1377 (gnus-simplify-buffer-fuzzy-step " $")
1378 (gnus-simplify-buffer-fuzzy-step "^ +")))
1380 (defun gnus-simplify-subject-fuzzy (subject)
1381 "Simplify a subject string fuzzily.
1382 See `gnus-simplify-buffer-fuzzy' for details."
1384 (gnus-set-work-buffer)
1385 (let ((case-fold-search t))
1386 ;; Remove uninteresting prefixes.
1387 (when (and gnus-simplify-ignored-prefixes
1388 (string-match gnus-simplify-ignored-prefixes subject))
1389 (setq subject (substring subject (match-end 0))))
1391 (inline (gnus-simplify-buffer-fuzzy))
1394 (defsubst gnus-simplify-subject-fully (subject)
1395 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1397 (gnus-simplify-subject-functions
1398 (gnus-map-function gnus-simplify-subject-functions subject))
1399 ((null gnus-summary-gather-subject-limit)
1400 (gnus-simplify-subject-re subject))
1401 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1402 (gnus-simplify-subject-fuzzy subject))
1403 ((numberp gnus-summary-gather-subject-limit)
1404 (gnus-limit-string (gnus-simplify-subject-re subject)
1405 gnus-summary-gather-subject-limit))
1409 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1410 "Check whether two subjects are equal.
1411 If optional argument simple-first is t, first argument is already
1414 ((null simple-first)
1415 (equal (gnus-simplify-subject-fully s1)
1416 (gnus-simplify-subject-fully s2)))
1419 (gnus-simplify-subject-fully s2)))))
1421 (defun gnus-summary-bubble-group ()
1422 "Increase the score of the current group.
1423 This is a handy function to add to `gnus-summary-exit-hook' to
1424 increase the score of each group you read."
1425 (gnus-group-add-score gnus-newsgroup-name))
1429 ;;; Gnus summary mode
1432 (put 'gnus-summary-mode 'mode-class 'special)
1434 (defvar gnus-article-commands-menu)
1437 ;; Non-orthogonal keys
1439 (gnus-define-keys gnus-summary-mode-map
1440 " " gnus-summary-next-page
1441 "\177" gnus-summary-prev-page
1442 [delete] gnus-summary-prev-page
1443 [backspace] gnus-summary-prev-page
1444 "\r" gnus-summary-scroll-up
1445 "\M-\r" gnus-summary-scroll-down
1446 "n" gnus-summary-next-unread-article
1447 "p" gnus-summary-prev-unread-article
1448 "N" gnus-summary-next-article
1449 "P" gnus-summary-prev-article
1450 "\M-\C-n" gnus-summary-next-same-subject
1451 "\M-\C-p" gnus-summary-prev-same-subject
1452 "\M-n" gnus-summary-next-unread-subject
1453 "\M-p" gnus-summary-prev-unread-subject
1454 "." gnus-summary-first-unread-article
1455 "," gnus-summary-best-unread-article
1456 "\M-s" gnus-summary-search-article-forward
1457 "\M-r" gnus-summary-search-article-backward
1458 "<" gnus-summary-beginning-of-article
1459 ">" gnus-summary-end-of-article
1460 "j" gnus-summary-goto-article
1461 "^" gnus-summary-refer-parent-article
1462 "\M-^" gnus-summary-refer-article
1463 "u" gnus-summary-tick-article-forward
1464 "!" gnus-summary-tick-article-forward
1465 "U" gnus-summary-tick-article-backward
1466 "d" gnus-summary-mark-as-read-forward
1467 "D" gnus-summary-mark-as-read-backward
1468 "E" gnus-summary-mark-as-expirable
1469 "\M-u" gnus-summary-clear-mark-forward
1470 "\M-U" gnus-summary-clear-mark-backward
1471 "k" gnus-summary-kill-same-subject-and-select
1472 "\C-k" gnus-summary-kill-same-subject
1473 "\M-\C-k" gnus-summary-kill-thread
1474 "\M-\C-l" gnus-summary-lower-thread
1475 "e" gnus-summary-edit-article
1476 "#" gnus-summary-mark-as-processable
1477 "\M-#" gnus-summary-unmark-as-processable
1478 "\M-\C-t" gnus-summary-toggle-threads
1479 "\M-\C-s" gnus-summary-show-thread
1480 "\M-\C-h" gnus-summary-hide-thread
1481 "\M-\C-f" gnus-summary-next-thread
1482 "\M-\C-b" gnus-summary-prev-thread
1483 [(meta down)] gnus-summary-next-thread
1484 [(meta up)] gnus-summary-prev-thread
1485 "\M-\C-u" gnus-summary-up-thread
1486 "\M-\C-d" gnus-summary-down-thread
1487 "&" gnus-summary-execute-command
1488 "c" gnus-summary-catchup-and-exit
1489 "\C-w" gnus-summary-mark-region-as-read
1490 "\C-t" gnus-summary-toggle-truncation
1491 "?" gnus-summary-mark-as-dormant
1492 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1493 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1494 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1495 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1496 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1497 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1498 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1499 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1500 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1501 "=" gnus-summary-expand-window
1502 "\C-x\C-s" gnus-summary-reselect-current-group
1503 "\M-g" gnus-summary-rescan-group
1504 "w" gnus-summary-stop-page-breaking
1505 "\C-c\C-r" gnus-summary-caesar-message
1506 "\M-t" gnus-summary-toggle-mime
1507 "f" gnus-summary-followup
1508 "F" gnus-summary-followup-with-original
1509 "C" gnus-summary-cancel-article
1510 "r" gnus-summary-reply
1511 "R" gnus-summary-reply-with-original
1512 "\C-c\C-f" gnus-summary-mail-forward
1513 "o" gnus-summary-save-article
1514 "\C-o" gnus-summary-save-article-mail
1515 "|" gnus-summary-pipe-output
1516 "\M-k" gnus-summary-edit-local-kill
1517 "\M-K" gnus-summary-edit-global-kill
1519 "\C-c\C-d" gnus-summary-describe-group
1520 "q" gnus-summary-exit
1521 "Q" gnus-summary-exit-no-update
1522 "\C-c\C-i" gnus-info-find-node
1523 gnus-mouse-2 gnus-mouse-pick-article
1524 "m" gnus-summary-mail-other-window
1525 "a" gnus-summary-post-news
1526 "x" gnus-summary-limit-to-unread
1527 "s" gnus-summary-isearch-article
1528 "t" gnus-article-toggle-headers
1529 "g" gnus-summary-show-article
1530 "l" gnus-summary-goto-last-article
1531 "v" gnus-summary-preview-mime-message
1532 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1533 "\C-d" gnus-summary-enter-digest-group
1534 "\M-\C-d" gnus-summary-read-document
1535 "\M-\C-e" gnus-summary-edit-parameters
1536 "\M-\C-a" gnus-summary-customize-parameters
1538 "*" gnus-cache-enter-article
1539 "\M-*" gnus-cache-remove-article
1540 "\M-&" gnus-summary-universal-argument
1541 "\C-l" gnus-recenter
1542 "I" gnus-summary-increase-score
1543 "L" gnus-summary-lower-score
1544 "\M-i" gnus-symbolic-argument
1545 "h" gnus-summary-select-article-buffer
1547 "V" gnus-summary-score-map
1548 "X" gnus-uu-extract-map
1549 "S" gnus-summary-send-map)
1551 ;; Sort of orthogonal keymap
1552 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1553 "t" gnus-summary-tick-article-forward
1554 "!" gnus-summary-tick-article-forward
1555 "d" gnus-summary-mark-as-read-forward
1556 "r" gnus-summary-mark-as-read-forward
1557 "c" gnus-summary-clear-mark-forward
1558 " " gnus-summary-clear-mark-forward
1559 "e" gnus-summary-mark-as-expirable
1560 "x" gnus-summary-mark-as-expirable
1561 "?" gnus-summary-mark-as-dormant
1562 "b" gnus-summary-set-bookmark
1563 "B" gnus-summary-remove-bookmark
1564 "#" gnus-summary-mark-as-processable
1565 "\M-#" gnus-summary-unmark-as-processable
1566 "S" gnus-summary-limit-include-expunged
1567 "C" gnus-summary-catchup
1568 "H" gnus-summary-catchup-to-here
1569 "h" gnus-summary-catchup-from-here
1570 "\C-c" gnus-summary-catchup-all
1571 "k" gnus-summary-kill-same-subject-and-select
1572 "K" gnus-summary-kill-same-subject
1573 "P" gnus-uu-mark-map)
1575 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1576 "c" gnus-summary-clear-above
1577 "u" gnus-summary-tick-above
1578 "m" gnus-summary-mark-above
1579 "k" gnus-summary-kill-below)
1581 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1582 "/" gnus-summary-limit-to-subject
1583 "n" gnus-summary-limit-to-articles
1584 "w" gnus-summary-pop-limit
1585 "s" gnus-summary-limit-to-subject
1586 "a" gnus-summary-limit-to-author
1587 "u" gnus-summary-limit-to-unread
1588 "m" gnus-summary-limit-to-marks
1589 "M" gnus-summary-limit-exclude-marks
1590 "v" gnus-summary-limit-to-score
1591 "*" gnus-summary-limit-include-cached
1592 "D" gnus-summary-limit-include-dormant
1593 "T" gnus-summary-limit-include-thread
1594 "d" gnus-summary-limit-exclude-dormant
1595 "t" gnus-summary-limit-to-age
1596 "x" gnus-summary-limit-to-extra
1597 "E" gnus-summary-limit-include-expunged
1598 "c" gnus-summary-limit-exclude-childless-dormant
1599 "C" gnus-summary-limit-mark-excluded-as-read
1600 "o" gnus-summary-insert-old-articles
1601 "N" gnus-summary-insert-new-articles)
1603 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1604 "n" gnus-summary-next-unread-article
1605 "p" gnus-summary-prev-unread-article
1606 "N" gnus-summary-next-article
1607 "P" gnus-summary-prev-article
1608 "\C-n" gnus-summary-next-same-subject
1609 "\C-p" gnus-summary-prev-same-subject
1610 "\M-n" gnus-summary-next-unread-subject
1611 "\M-p" gnus-summary-prev-unread-subject
1612 "f" gnus-summary-first-unread-article
1613 "b" gnus-summary-best-unread-article
1614 "j" gnus-summary-goto-article
1615 "g" gnus-summary-goto-subject
1616 "l" gnus-summary-goto-last-article
1617 "o" gnus-summary-pop-article)
1619 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1620 "k" gnus-summary-kill-thread
1621 "l" gnus-summary-lower-thread
1622 "i" gnus-summary-raise-thread
1623 "T" gnus-summary-toggle-threads
1624 "t" gnus-summary-rethread-current
1625 "^" gnus-summary-reparent-thread
1626 "s" gnus-summary-show-thread
1627 "S" gnus-summary-show-all-threads
1628 "h" gnus-summary-hide-thread
1629 "H" gnus-summary-hide-all-threads
1630 "n" gnus-summary-next-thread
1631 "p" gnus-summary-prev-thread
1632 "u" gnus-summary-up-thread
1633 "o" gnus-summary-top-thread
1634 "d" gnus-summary-down-thread
1635 "#" gnus-uu-mark-thread
1636 "\M-#" gnus-uu-unmark-thread)
1638 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1639 "g" gnus-summary-prepare
1640 "c" gnus-summary-insert-cached-articles)
1642 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1643 "c" gnus-summary-catchup-and-exit
1644 "C" gnus-summary-catchup-all-and-exit
1645 "E" gnus-summary-exit-no-update
1646 "J" gnus-summary-jump-to-other-group
1647 "Q" gnus-summary-exit
1648 "Z" gnus-summary-exit
1649 "n" gnus-summary-catchup-and-goto-next-group
1650 "R" gnus-summary-reselect-current-group
1651 "G" gnus-summary-rescan-group
1652 "N" gnus-summary-next-group
1653 "s" gnus-summary-save-newsrc
1654 "P" gnus-summary-prev-group)
1656 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1657 " " gnus-summary-next-page
1658 "n" gnus-summary-next-page
1659 "\177" gnus-summary-prev-page
1660 [delete] gnus-summary-prev-page
1661 "p" gnus-summary-prev-page
1662 "\r" gnus-summary-scroll-up
1663 "\M-\r" gnus-summary-scroll-down
1664 "<" gnus-summary-beginning-of-article
1665 ">" gnus-summary-end-of-article
1666 "b" gnus-summary-beginning-of-article
1667 "e" gnus-summary-end-of-article
1668 "^" gnus-summary-refer-parent-article
1669 "r" gnus-summary-refer-parent-article
1670 "D" gnus-summary-enter-digest-group
1671 "R" gnus-summary-refer-references
1672 "T" gnus-summary-refer-thread
1673 "g" gnus-summary-show-article
1674 "s" gnus-summary-isearch-article
1675 "P" gnus-summary-print-article
1676 "M" gnus-mailing-list-insinuate
1677 "t" gnus-article-babel)
1679 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1680 "b" gnus-article-add-buttons
1681 "B" gnus-article-add-buttons-to-head
1682 "o" gnus-article-treat-overstrike
1683 "e" gnus-article-emphasize
1684 "w" gnus-article-fill-cited-article
1685 "Q" gnus-article-fill-long-lines
1686 "C" gnus-article-capitalize-sentences
1687 "c" gnus-article-remove-cr
1688 "Z" gnus-article-decode-HZ
1689 "f" gnus-article-display-x-face
1690 "l" gnus-summary-stop-page-breaking
1691 "r" gnus-summary-caesar-message
1692 "t" gnus-article-toggle-headers
1693 "v" gnus-summary-verbose-headers
1694 "m" gnus-summary-toggle-mime
1695 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1696 "p" gnus-article-verify-x-pgp-sig
1697 "d" gnus-article-treat-dumbquotes
1698 "s" gnus-smiley-display)
1700 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1701 "a" gnus-article-hide
1702 "h" gnus-article-toggle-headers
1703 "b" gnus-article-hide-boring-headers
1704 "s" gnus-article-hide-signature
1705 "c" gnus-article-hide-citation
1706 "C" gnus-article-hide-citation-in-followups
1707 "l" gnus-article-hide-list-identifiers
1708 "p" gnus-article-hide-pgp
1709 "B" gnus-article-strip-banner
1710 "P" gnus-article-hide-pem
1711 "\C-c" gnus-article-hide-citation-maybe)
1713 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1714 "a" gnus-article-highlight
1715 "h" gnus-article-highlight-headers
1716 "c" gnus-article-highlight-citation
1717 "s" gnus-article-highlight-signature)
1719 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1720 "z" gnus-article-date-ut
1721 "u" gnus-article-date-ut
1722 "l" gnus-article-date-local
1723 "p" gnus-article-date-english
1724 "e" gnus-article-date-lapsed
1725 "o" gnus-article-date-original
1726 "i" gnus-article-date-iso8601
1727 "s" gnus-article-date-user)
1729 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1730 "t" gnus-article-remove-trailing-blank-lines
1731 "l" gnus-article-strip-leading-blank-lines
1732 "m" gnus-article-strip-multiple-blank-lines
1733 "a" gnus-article-strip-blank-lines
1734 "A" gnus-article-strip-all-blank-lines
1735 "s" gnus-article-strip-leading-space
1736 "e" gnus-article-strip-trailing-space
1737 "w" gnus-article-remove-leading-whitespace)
1739 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1741 "f" gnus-summary-fetch-faq
1742 "d" gnus-summary-describe-group
1743 "h" gnus-summary-describe-briefly
1744 "i" gnus-info-find-node)
1746 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1747 "e" gnus-summary-expire-articles
1748 "\M-\C-e" gnus-summary-expire-articles-now
1749 "\177" gnus-summary-delete-article
1750 [delete] gnus-summary-delete-article
1751 [backspace] gnus-summary-delete-article
1752 "m" gnus-summary-move-article
1753 "r" gnus-summary-respool-article
1754 "w" gnus-summary-edit-article
1755 "c" gnus-summary-copy-article
1756 "B" gnus-summary-crosspost-article
1757 "q" gnus-summary-respool-query
1758 "t" gnus-summary-respool-trace
1759 "i" gnus-summary-import-article
1760 "I" gnus-summary-create-article
1761 "p" gnus-summary-article-posted-p)
1763 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1764 "o" gnus-summary-save-article
1765 "m" gnus-summary-save-article-mail
1766 "F" gnus-summary-write-article-file
1767 "r" gnus-summary-save-article-rmail
1768 "f" gnus-summary-save-article-file
1769 "b" gnus-summary-save-article-body-file
1770 "h" gnus-summary-save-article-folder
1771 "v" gnus-summary-save-article-vm
1772 "p" gnus-summary-pipe-output
1773 "s" gnus-soup-add-article)
1775 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1776 "b" gnus-summary-display-buttonized
1777 "m" gnus-summary-repair-multipart
1778 "v" gnus-article-view-part
1779 "o" gnus-article-save-part
1780 "c" gnus-article-copy-part
1781 "C" gnus-article-view-part-as-charset
1782 "e" gnus-article-externalize-part
1783 "E" gnus-article-encrypt-body
1784 "i" gnus-article-inline-part
1785 "|" gnus-article-pipe-part))
1787 (defvar gnus-article-post-menu nil)
1789 (defun gnus-summary-make-menu-bar ()
1790 (gnus-turn-off-edit-menu 'summary)
1792 (unless (boundp 'gnus-summary-misc-menu)
1795 gnus-summary-kill-menu gnus-summary-mode-map ""
1800 ["Customize" gnus-score-customize t])
1801 (gnus-make-score-map 'increase)
1802 (gnus-make-score-map 'lower)
1804 ["Kill below" gnus-summary-kill-below t]
1805 ["Mark above" gnus-summary-mark-above t]
1806 ["Tick above" gnus-summary-tick-above t]
1807 ["Clear above" gnus-summary-clear-above t])
1808 ["Current score" gnus-summary-current-score t]
1809 ["Set score" gnus-summary-set-score t]
1810 ["Switch current score file..." gnus-score-change-score-file t]
1811 ["Set mark below..." gnus-score-set-mark-below t]
1812 ["Set expunge below..." gnus-score-set-expunge-below t]
1813 ["Edit current score file" gnus-score-edit-current-scores t]
1814 ["Edit score file" gnus-score-edit-file t]
1815 ["Trace score" gnus-score-find-trace t]
1816 ["Find words" gnus-score-find-favourite-words t]
1817 ["Rescore buffer" gnus-summary-rescore t]
1818 ["Increase score..." gnus-summary-increase-score t]
1819 ["Lower score..." gnus-summary-lower-score t]))))
1821 ;; Define both the Article menu in the summary buffer and the equivalent
1822 ;; Commands menu in the article buffer here for consistency.
1825 ["All" gnus-article-hide t]
1826 ["Headers" gnus-article-toggle-headers t]
1827 ["Signature" gnus-article-hide-signature t]
1828 ["Citation" gnus-article-hide-citation t]
1829 ["List identifiers" gnus-article-hide-list-identifiers t]
1830 ["PGP" gnus-article-hide-pgp t]
1831 ["Banner" gnus-article-strip-banner t]
1832 ["Boring headers" gnus-article-hide-boring-headers t])
1834 ["All" gnus-article-highlight t]
1835 ["Headers" gnus-article-highlight-headers t]
1836 ["Signature" gnus-article-highlight-signature t]
1837 ["Citation" gnus-article-highlight-citation t])
1839 ["Local" gnus-article-date-local t]
1840 ["ISO8601" gnus-article-date-iso8601 t]
1841 ["UT" gnus-article-date-ut t]
1842 ["Original" gnus-article-date-original t]
1843 ["Lapsed" gnus-article-date-lapsed t]
1844 ["User-defined" gnus-article-date-user t])
1847 ["Leading" gnus-article-strip-leading-blank-lines t]
1848 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1849 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1850 ["All of the above" gnus-article-strip-blank-lines t]
1851 ["All" gnus-article-strip-all-blank-lines t]
1852 ["Leading space" gnus-article-strip-leading-space t]
1853 ["Trailing space" gnus-article-strip-trailing-space t]
1854 ["Leading space in headers"
1855 gnus-article-remove-leading-whitespace t])
1856 ["Overstrike" gnus-article-treat-overstrike t]
1857 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1858 ["Emphasis" gnus-article-emphasize t]
1859 ["Word wrap" gnus-article-fill-cited-article t]
1860 ["Fill long lines" gnus-article-fill-long-lines t]
1861 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1862 ["CR" gnus-article-remove-cr t]
1863 ["Show X-Face" gnus-article-display-x-face t]
1864 ["Rot 13" gnus-summary-caesar-message
1865 ,@(if (featurep 'xemacs) '(t)
1866 '(:help "\"Caesar rotate\" article by 13"))]
1867 ["Unix pipe" gnus-summary-pipe-message t]
1868 ["Add buttons" gnus-article-add-buttons t]
1869 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1870 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1871 ["Toggle MIME" gnus-summary-toggle-mime t]
1872 ["Verbose header" gnus-summary-verbose-headers t]
1873 ["Toggle header" gnus-summary-toggle-header t]
1874 ["Toggle smileys" gnus-smiley-display t]
1875 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1876 ["HZ" gnus-article-decode-HZ t])
1878 ["Save in default format" gnus-summary-save-article
1879 ,@(if (featurep 'xemacs) '(t)
1880 '(:help "Save article using default method"))]
1881 ["Save in file" gnus-summary-save-article-file
1882 ,@(if (featurep 'xemacs) '(t)
1883 '(:help "Save article in file"))]
1884 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1885 ["Save in MH folder" gnus-summary-save-article-folder t]
1886 ["Save in VM folder" gnus-summary-save-article-vm t]
1887 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1888 ["Save body in file" gnus-summary-save-article-body-file t]
1889 ["Pipe through a filter" gnus-summary-pipe-output t]
1890 ["Add to SOUP packet" gnus-soup-add-article t]
1891 ["Print" gnus-summary-print-article t])
1893 ["Respool article..." gnus-summary-respool-article t]
1894 ["Move article..." gnus-summary-move-article
1895 (gnus-check-backend-function
1896 'request-move-article gnus-newsgroup-name)]
1897 ["Copy article..." gnus-summary-copy-article t]
1898 ["Crosspost article..." gnus-summary-crosspost-article
1899 (gnus-check-backend-function
1900 'request-replace-article gnus-newsgroup-name)]
1901 ["Import file..." gnus-summary-import-article t]
1902 ["Create article..." gnus-summary-create-article t]
1903 ["Check if posted" gnus-summary-article-posted-p t]
1904 ["Edit article" gnus-summary-edit-article
1905 (not (gnus-group-read-only-p))]
1906 ["Delete article" gnus-summary-delete-article
1907 (gnus-check-backend-function
1908 'request-expire-articles gnus-newsgroup-name)]
1909 ["Query respool" gnus-summary-respool-query t]
1910 ["Trace respool" gnus-summary-respool-trace t]
1911 ["Delete expirable articles" gnus-summary-expire-articles-now
1912 (gnus-check-backend-function
1913 'request-expire-articles gnus-newsgroup-name)])
1915 ["Uudecode" gnus-uu-decode-uu
1916 ,@(if (featurep 'xemacs) '(t)
1917 '(:help "Decode uuencoded article(s)"))]
1918 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1919 ["Unshar" gnus-uu-decode-unshar t]
1920 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1921 ["Save" gnus-uu-decode-save t]
1922 ["Binhex" gnus-uu-decode-binhex t]
1923 ["Postscript" gnus-uu-decode-postscript t])
1925 ["Enter article" gnus-cache-enter-article t]
1926 ["Remove article" gnus-cache-remove-article t])
1927 ["Translate" gnus-article-babel t]
1928 ["Select article buffer" gnus-summary-select-article-buffer t]
1929 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1930 ["Isearch article..." gnus-summary-isearch-article t]
1931 ["Beginning of the article" gnus-summary-beginning-of-article t]
1932 ["End of the article" gnus-summary-end-of-article t]
1933 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1934 ["Fetch referenced articles" gnus-summary-refer-references t]
1935 ["Fetch current thread" gnus-summary-refer-thread t]
1936 ["Fetch article with id..." gnus-summary-refer-article t]
1937 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1938 ["Redisplay" gnus-summary-show-article t]
1939 ["Raw article" gnus-summary-show-raw-article t])))
1941 gnus-summary-article-menu gnus-summary-mode-map ""
1942 (cons "Article" innards))
1944 (if (not (keymapp gnus-summary-article-menu))
1946 gnus-article-commands-menu gnus-article-mode-map ""
1947 (cons "Commands" innards))
1948 ;; in Emacs, don't share menu.
1949 (setq gnus-article-commands-menu
1950 (copy-keymap gnus-summary-article-menu))
1951 (define-key gnus-article-mode-map [menu-bar commands]
1952 (cons "Commands" gnus-article-commands-menu))))
1955 gnus-summary-thread-menu gnus-summary-mode-map ""
1957 ["Toggle threading" gnus-summary-toggle-threads t]
1958 ["Hide threads" gnus-summary-hide-all-threads t]
1959 ["Show threads" gnus-summary-show-all-threads t]
1960 ["Hide thread" gnus-summary-hide-thread t]
1961 ["Show thread" gnus-summary-show-thread t]
1962 ["Go to next thread" gnus-summary-next-thread t]
1963 ["Go to previous thread" gnus-summary-prev-thread t]
1964 ["Go down thread" gnus-summary-down-thread t]
1965 ["Go up thread" gnus-summary-up-thread t]
1966 ["Top of thread" gnus-summary-top-thread t]
1967 ["Mark thread as read" gnus-summary-kill-thread t]
1968 ["Lower thread score" gnus-summary-lower-thread t]
1969 ["Raise thread score" gnus-summary-raise-thread t]
1970 ["Rethread current" gnus-summary-rethread-current t]))
1973 gnus-summary-post-menu gnus-summary-mode-map ""
1975 ["Post an article" gnus-summary-post-news
1976 ,@(if (featurep 'xemacs) '(t)
1977 '(:help "Post an article"))]
1978 ["Followup" gnus-summary-followup
1979 ,@(if (featurep 'xemacs) '(t)
1980 '(:help "Post followup to this article"))]
1981 ["Followup and yank" gnus-summary-followup-with-original
1982 ,@(if (featurep 'xemacs) '(t)
1983 '(:help "Post followup to this article, quoting its contents"))]
1984 ["Supersede article" gnus-summary-supersede-article t]
1985 ["Cancel article" gnus-summary-cancel-article
1986 ,@(if (featurep 'xemacs) '(t)
1987 '(:help "Cancel an article you posted"))]
1988 ["Reply" gnus-summary-reply t]
1989 ["Reply and yank" gnus-summary-reply-with-original t]
1990 ["Wide reply" gnus-summary-wide-reply t]
1991 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1992 ,@(if (featurep 'xemacs) '(t)
1993 '(:help "Mail a reply, quoting this article"))]
1994 ["Mail forward" gnus-summary-mail-forward t]
1995 ["Post forward" gnus-summary-post-forward t]
1996 ["Digest and mail" gnus-summary-digest-mail-forward t]
1997 ["Digest and post" gnus-summary-digest-post-forward t]
1998 ["Resend message" gnus-summary-resend-message t]
1999 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2000 ["Send a mail" gnus-summary-mail-other-window t]
2001 ["Uuencode and post" gnus-uu-post-news
2002 ,@(if (featurep 'xemacs) '(t)
2003 '(:help "Post a uuencoded article"))]
2004 ["Followup via news" gnus-summary-followup-to-mail t]
2005 ["Followup via news and yank"
2006 gnus-summary-followup-to-mail-with-original t]
2008 ;;["Send" gnus-summary-send-draft t]
2009 ;;["Send bounced" gnus-resend-bounced-mail t])
2013 ((not (keymapp gnus-summary-post-menu))
2014 (setq gnus-article-post-menu gnus-summary-post-menu))
2015 ((not gnus-article-post-menu)
2016 ;; Don't share post menu.
2017 (setq gnus-article-post-menu
2018 (copy-keymap gnus-summary-post-menu))))
2019 (define-key gnus-article-mode-map [menu-bar post]
2020 (cons "Post" gnus-article-post-menu))
2023 gnus-summary-misc-menu gnus-summary-mode-map ""
2026 ["Mark as read" gnus-summary-mark-as-read-forward t]
2027 ["Mark same subject and select"
2028 gnus-summary-kill-same-subject-and-select t]
2029 ["Mark same subject" gnus-summary-kill-same-subject t]
2030 ["Catchup" gnus-summary-catchup
2031 ,@(if (featurep 'xemacs) '(t)
2032 '(:help "Mark unread articles in this group as read"))]
2033 ["Catchup all" gnus-summary-catchup-all t]
2034 ["Catchup to here" gnus-summary-catchup-to-here t]
2035 ["Catchup from here" gnus-summary-catchup-from-here t]
2036 ["Catchup region" gnus-summary-mark-region-as-read t]
2037 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2039 ["Tick" gnus-summary-tick-article-forward t]
2040 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2041 ["Remove marks" gnus-summary-clear-mark-forward t]
2042 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2043 ["Set bookmark" gnus-summary-set-bookmark t]
2044 ["Remove bookmark" gnus-summary-remove-bookmark t])
2046 ["Marks..." gnus-summary-limit-to-marks t]
2047 ["Subject..." gnus-summary-limit-to-subject t]
2048 ["Author..." gnus-summary-limit-to-author t]
2049 ["Age..." gnus-summary-limit-to-age t]
2050 ["Extra..." gnus-summary-limit-to-extra t]
2051 ["Score" gnus-summary-limit-to-score t]
2052 ["Unread" gnus-summary-limit-to-unread t]
2053 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2054 ["Articles" gnus-summary-limit-to-articles t]
2055 ["Pop limit" gnus-summary-pop-limit t]
2056 ["Show dormant" gnus-summary-limit-include-dormant t]
2057 ["Hide childless dormant"
2058 gnus-summary-limit-exclude-childless-dormant t]
2059 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2060 ["Hide marked" gnus-summary-limit-exclude-marks t]
2061 ["Show expunged" gnus-summary-limit-include-expunged t])
2063 ["Set mark" gnus-summary-mark-as-processable t]
2064 ["Remove mark" gnus-summary-unmark-as-processable t]
2065 ["Remove all marks" gnus-summary-unmark-all-processable t]
2066 ["Mark above" gnus-uu-mark-over t]
2067 ["Mark series" gnus-uu-mark-series t]
2068 ["Mark region" gnus-uu-mark-region t]
2069 ["Unmark region" gnus-uu-unmark-region t]
2070 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2071 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2072 ["Mark all" gnus-uu-mark-all t]
2073 ["Mark buffer" gnus-uu-mark-buffer t]
2074 ["Mark sparse" gnus-uu-mark-sparse t]
2075 ["Mark thread" gnus-uu-mark-thread t]
2076 ["Unmark thread" gnus-uu-unmark-thread t]
2077 ("Process Mark Sets"
2078 ["Kill" gnus-summary-kill-process-mark t]
2079 ["Yank" gnus-summary-yank-process-mark
2080 gnus-newsgroup-process-stack]
2081 ["Save" gnus-summary-save-process-mark t]))
2083 ["Page forward" gnus-summary-next-page
2084 ,@(if (featurep 'xemacs) '(t)
2085 '(:help "Show next page of article"))]
2086 ["Page backward" gnus-summary-prev-page
2087 ,@(if (featurep 'xemacs) '(t)
2088 '(:help "Show previous page of article"))]
2089 ["Line forward" gnus-summary-scroll-up t])
2091 ["Next unread article" gnus-summary-next-unread-article t]
2092 ["Previous unread article" gnus-summary-prev-unread-article t]
2093 ["Next article" gnus-summary-next-article t]
2094 ["Previous article" gnus-summary-prev-article t]
2095 ["Next unread subject" gnus-summary-next-unread-subject t]
2096 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2097 ["Next article same subject" gnus-summary-next-same-subject t]
2098 ["Previous article same subject" gnus-summary-prev-same-subject t]
2099 ["First unread article" gnus-summary-first-unread-article t]
2100 ["Best unread article" gnus-summary-best-unread-article t]
2101 ["Go to subject number..." gnus-summary-goto-subject t]
2102 ["Go to article number..." gnus-summary-goto-article t]
2103 ["Go to the last article" gnus-summary-goto-last-article t]
2104 ["Pop article off history" gnus-summary-pop-article t])
2106 ["Sort by number" gnus-summary-sort-by-number t]
2107 ["Sort by author" gnus-summary-sort-by-author t]
2108 ["Sort by subject" gnus-summary-sort-by-subject t]
2109 ["Sort by date" gnus-summary-sort-by-date t]
2110 ["Sort by score" gnus-summary-sort-by-score t]
2111 ["Sort by lines" gnus-summary-sort-by-lines t]
2112 ["Sort by characters" gnus-summary-sort-by-chars t]
2113 ["Original sort" gnus-summary-sort-by-original t])
2115 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2116 ["Describe group" gnus-summary-describe-group t]
2117 ["Read manual" gnus-info-find-node t])
2119 ["Pick and read" gnus-pick-mode t]
2120 ["Binary" gnus-binary-mode t])
2122 ["Regenerate" gnus-summary-prepare t]
2123 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2124 ["Toggle threading" gnus-summary-toggle-threads t])
2125 ["See old articles" gnus-summary-insert-old-articles t]
2126 ["See new articles" gnus-summary-insert-new-articles t]
2127 ["Filter articles..." gnus-summary-execute-command t]
2128 ["Run command on subjects..." gnus-summary-universal-argument t]
2129 ["Search articles forward..." gnus-summary-search-article-forward t]
2130 ["Search articles backward..." gnus-summary-search-article-backward t]
2131 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2132 ["Expand window" gnus-summary-expand-window t]
2133 ["Expire expirable articles" gnus-summary-expire-articles
2134 (gnus-check-backend-function
2135 'request-expire-articles gnus-newsgroup-name)]
2136 ["Edit local kill file" gnus-summary-edit-local-kill t]
2137 ["Edit main kill file" gnus-summary-edit-global-kill t]
2138 ["Edit group parameters" gnus-summary-edit-parameters t]
2139 ["Customize group parameters" gnus-summary-customize-parameters t]
2140 ["Send a bug report" gnus-bug t]
2142 ["Catchup and exit" gnus-summary-catchup-and-exit
2143 ,@(if (featurep 'xemacs) '(t)
2144 '(:help "Mark unread articles in this group as read, then exit"))]
2145 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2146 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2147 ["Exit group" gnus-summary-exit
2148 ,@(if (featurep 'xemacs) '(t)
2149 '(:help "Exit current group, return to group selection mode"))]
2150 ["Exit group without updating" gnus-summary-exit-no-update t]
2151 ["Exit and goto next group" gnus-summary-next-group t]
2152 ["Exit and goto prev group" gnus-summary-prev-group t]
2153 ["Reselect group" gnus-summary-reselect-current-group t]
2154 ["Rescan group" gnus-summary-rescan-group t]
2155 ["Update dribble" gnus-summary-save-newsrc t])))
2157 (gnus-run-hooks 'gnus-summary-menu-hook)))
2159 (defvar gnus-summary-tool-bar-map nil)
2161 ;; Emacs 21 tool bar. Should be no-op otherwise.
2162 (defun gnus-summary-make-tool-bar ()
2163 (if (and (fboundp 'tool-bar-add-item-from-menu)
2164 (default-value 'tool-bar-mode)
2165 (not gnus-summary-tool-bar-map))
2166 (setq gnus-summary-tool-bar-map
2167 (let ((tool-bar-map (make-sparse-keymap))
2168 (load-path (mm-image-load-path)))
2169 (tool-bar-add-item-from-menu
2170 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2171 (tool-bar-add-item-from-menu
2172 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2173 (tool-bar-add-item-from-menu
2174 'gnus-summary-post-news "post" gnus-summary-mode-map)
2175 (tool-bar-add-item-from-menu
2176 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2177 (tool-bar-add-item-from-menu
2178 'gnus-summary-followup "followup" gnus-summary-mode-map)
2179 (tool-bar-add-item-from-menu
2180 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2181 (tool-bar-add-item-from-menu
2182 'gnus-summary-reply "reply" gnus-summary-mode-map)
2183 (tool-bar-add-item-from-menu
2184 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2185 (tool-bar-add-item-from-menu
2186 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2187 (tool-bar-add-item-from-menu
2188 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2189 (tool-bar-add-item-from-menu
2190 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2191 (tool-bar-add-item-from-menu
2192 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2193 (tool-bar-add-item-from-menu
2194 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2195 (tool-bar-add-item-from-menu
2196 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2197 (tool-bar-add-item-from-menu
2198 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2200 (if gnus-summary-tool-bar-map
2201 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2203 (defun gnus-score-set-default (var value)
2204 "A version of set that updates the GNU Emacs menu-bar."
2206 ;; It is the message that forces the active status to be updated.
2209 (defun gnus-make-score-map (type)
2210 "Make a summary score map of type TYPE."
2213 (let ((headers '(("author" "from" string)
2214 ("subject" "subject" string)
2215 ("article body" "body" string)
2216 ("article head" "head" string)
2217 ("xref" "xref" string)
2218 ("extra header" "extra" string)
2219 ("lines" "lines" number)
2220 ("followups to author" "followup" string)))
2221 (types '((number ("less than" <)
2224 (string ("substring" s)
2228 (perms '(("temporary" (current-time-string))
2236 (if (eq type 'lower)
2241 (setq header (car headers))
2247 (let ((ts (cdr (assoc (nth 2 header) types)))
2263 'gnus-summary-score-entry
2265 (if (or (string= (nth 1 header)
2267 (string= (nth 1 header)
2270 (list 'gnus-summary-header
2272 (list 'quote (nth 1 (car ts)))
2273 (list 'gnus-score-delta-default
2280 (list (nreverse outp))))
2283 (list (nreverse outt))))
2285 (setq headers (cdr headers)))
2286 (list (nreverse outh))))))))
2290 (defun gnus-summary-mode (&optional group)
2291 "Major mode for reading articles.
2293 All normal editing commands are switched off.
2294 \\<gnus-summary-mode-map>
2295 Each line in this buffer represents one article. To read an
2296 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2297 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2300 You can also post articles and send mail from this buffer. To
2301 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2302 of an article, type `\\[gnus-summary-reply]'.
2304 There are approx. one gazillion commands you can execute in this
2305 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2307 The following commands are available:
2309 \\{gnus-summary-mode-map}"
2311 (kill-all-local-variables)
2312 (when (gnus-visual-p 'summary-menu 'menu)
2313 (gnus-summary-make-menu-bar)
2314 (gnus-summary-make-tool-bar))
2315 (gnus-summary-make-local-variables)
2316 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2317 (gnus-summary-make-local-variables))
2318 (gnus-make-thread-indent-array)
2319 (gnus-simplify-mode-line)
2320 (setq major-mode 'gnus-summary-mode)
2321 (setq mode-name "Summary")
2322 (make-local-variable 'minor-mode-alist)
2323 (use-local-map gnus-summary-mode-map)
2324 (buffer-disable-undo)
2325 (setq buffer-read-only t) ;Disable modification
2326 (setq truncate-lines t)
2327 (setq selective-display t)
2328 (setq selective-display-ellipses t) ;Display `...'
2329 (gnus-summary-set-display-table)
2330 (gnus-set-default-directory)
2331 (setq gnus-newsgroup-name group)
2332 (unless (gnus-news-group-p group)
2333 (setq gnus-newsgroup-incorporated
2334 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2335 (make-local-variable 'gnus-summary-line-format)
2336 (make-local-variable 'gnus-summary-line-format-spec)
2337 (make-local-variable 'gnus-summary-dummy-line-format)
2338 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2339 (make-local-variable 'gnus-summary-mark-positions)
2340 (make-local-hook 'pre-command-hook)
2341 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2342 (gnus-run-hooks 'gnus-summary-mode-hook)
2343 (turn-on-gnus-mailing-list-mode)
2344 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2345 (gnus-update-summary-mark-positions))
2347 (defun gnus-summary-make-local-variables ()
2348 "Make all the local summary buffer variables."
2350 (dolist (local gnus-summary-local-variables)
2353 (if (eq (cdr local) 'global)
2354 ;; Copy the global value of the variable.
2355 (setq global (symbol-value (car local)))
2356 ;; Use the value from the list.
2357 (setq global (eval (cdr local))))
2358 (set (make-local-variable (car local)) global))
2359 ;; Simple nil-valued local variable.
2360 (set (make-local-variable local) nil)))))
2362 (defun gnus-summary-clear-local-variables ()
2363 (let ((locals gnus-summary-local-variables))
2365 (if (consp (car locals))
2366 (and (vectorp (caar locals))
2367 (set (caar locals) nil))
2368 (and (vectorp (car locals))
2369 (set (car locals) nil)))
2370 (setq locals (cdr locals)))))
2372 ;; Summary data functions.
2374 (defmacro gnus-data-number (data)
2377 (defmacro gnus-data-set-number (data number)
2378 `(setcar ,data ,number))
2380 (defmacro gnus-data-mark (data)
2383 (defmacro gnus-data-set-mark (data mark)
2384 `(setcar (nthcdr 1 ,data) ,mark))
2386 (defmacro gnus-data-pos (data)
2389 (defmacro gnus-data-set-pos (data pos)
2390 `(setcar (nthcdr 2 ,data) ,pos))
2392 (defmacro gnus-data-header (data)
2395 (defmacro gnus-data-set-header (data header)
2396 `(setcar (nthcdr 3 ,data) ,header))
2398 (defmacro gnus-data-level (data)
2401 (defmacro gnus-data-unread-p (data)
2402 `(= (nth 1 ,data) gnus-unread-mark))
2404 (defmacro gnus-data-read-p (data)
2405 `(/= (nth 1 ,data) gnus-unread-mark))
2407 (defmacro gnus-data-pseudo-p (data)
2408 `(consp (nth 3 ,data)))
2410 (defmacro gnus-data-find (number)
2411 `(assq ,number gnus-newsgroup-data))
2413 (defmacro gnus-data-find-list (number &optional data)
2414 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2415 (memq (assq ,number bdata)
2418 (defmacro gnus-data-make (number mark pos header level)
2419 `(list ,number ,mark ,pos ,header ,level))
2421 (defun gnus-data-enter (after-article number mark pos header level offset)
2422 (let ((data (gnus-data-find-list after-article)))
2424 (error "No such article: %d" after-article))
2425 (setcdr data (cons (gnus-data-make number mark pos header level)
2427 (setq gnus-newsgroup-data-reverse nil)
2428 (gnus-data-update-list (cddr data) offset)))
2430 (defun gnus-data-enter-list (after-article list &optional offset)
2432 (let ((data (and after-article (gnus-data-find-list after-article)))
2436 (let ((odata gnus-newsgroup-data))
2437 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2439 (gnus-data-update-list odata offset)))
2440 ;; Find the last element in the list to be spliced into the main
2443 (setq list (cdr list)))
2446 (setcdr list gnus-newsgroup-data)
2447 (setq gnus-newsgroup-data ilist)
2449 (gnus-data-update-list (cdr list) offset)))
2450 (setcdr list (cdr data))
2453 (gnus-data-update-list (cdr list) offset))))
2454 (setq gnus-newsgroup-data-reverse nil))))
2456 (defun gnus-data-remove (article &optional offset)
2457 (let ((data gnus-newsgroup-data))
2458 (if (= (gnus-data-number (car data)) article)
2460 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2461 gnus-newsgroup-data-reverse nil)
2463 (gnus-data-update-list gnus-newsgroup-data offset)))
2465 (when (= (gnus-data-number (cadr data)) article)
2466 (setcdr data (cddr data))
2468 (gnus-data-update-list (cdr data) offset))
2470 gnus-newsgroup-data-reverse nil))
2471 (setq data (cdr data))))))
2473 (defmacro gnus-data-list (backward)
2475 (or gnus-newsgroup-data-reverse
2476 (setq gnus-newsgroup-data-reverse
2477 (reverse gnus-newsgroup-data)))
2478 gnus-newsgroup-data))
2480 (defun gnus-data-update-list (data offset)
2481 "Add OFFSET to the POS of all data entries in DATA."
2482 (setq gnus-newsgroup-data-reverse nil)
2484 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2485 (setq data (cdr data))))
2487 (defun gnus-summary-article-pseudo-p (article)
2488 "Say whether this article is a pseudo article or not."
2489 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2491 (defmacro gnus-summary-article-sparse-p (article)
2492 "Say whether this article is a sparse article or not."
2493 `(memq ,article gnus-newsgroup-sparse))
2495 (defmacro gnus-summary-article-ancient-p (article)
2496 "Say whether this article is a sparse article or not."
2497 `(memq ,article gnus-newsgroup-ancient))
2499 (defun gnus-article-parent-p (number)
2500 "Say whether this article is a parent or not."
2501 (let ((data (gnus-data-find-list number)))
2502 (and (cdr data) ; There has to be an article after...
2503 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2504 (gnus-data-level (nth 1 data))))))
2506 (defun gnus-article-children (number)
2507 "Return a list of all children to NUMBER."
2508 (let* ((data (gnus-data-find-list number))
2509 (level (gnus-data-level (car data)))
2511 (setq data (cdr data))
2513 (= (gnus-data-level (car data)) (1+ level)))
2514 (push (gnus-data-number (car data)) children)
2515 (setq data (cdr data)))
2518 (defmacro gnus-summary-skip-intangible ()
2519 "If the current article is intangible, then jump to a different article."
2520 '(let ((to (get-text-property (point) 'gnus-intangible)))
2521 (and to (gnus-summary-goto-subject to))))
2523 (defmacro gnus-summary-article-intangible-p ()
2524 "Say whether this article is intangible or not."
2525 '(get-text-property (point) 'gnus-intangible))
2527 (defun gnus-article-read-p (article)
2528 "Say whether ARTICLE is read or not."
2529 (not (or (memq article gnus-newsgroup-marked)
2530 (memq article gnus-newsgroup-unreads)
2531 (memq article gnus-newsgroup-unselected)
2532 (memq article gnus-newsgroup-dormant))))
2534 ;; Some summary mode macros.
2536 (defmacro gnus-summary-article-number ()
2537 "The article number of the article on the current line.
2538 If there isn's an article number here, then we return the current
2541 (gnus-summary-skip-intangible)
2542 (or (get-text-property (point) 'gnus-number)
2543 (gnus-summary-last-subject))))
2545 (defmacro gnus-summary-article-header (&optional number)
2546 "Return the header of article NUMBER."
2547 `(gnus-data-header (gnus-data-find
2548 ,(or number '(gnus-summary-article-number)))))
2550 (defmacro gnus-summary-thread-level (&optional number)
2551 "Return the level of thread that starts with article NUMBER."
2552 `(if (and (eq gnus-summary-make-false-root 'dummy)
2553 (get-text-property (point) 'gnus-intangible))
2555 (gnus-data-level (gnus-data-find
2556 ,(or number '(gnus-summary-article-number))))))
2558 (defmacro gnus-summary-article-mark (&optional number)
2559 "Return the mark of article NUMBER."
2560 `(gnus-data-mark (gnus-data-find
2561 ,(or number '(gnus-summary-article-number)))))
2563 (defmacro gnus-summary-article-pos (&optional number)
2564 "Return the position of the line of article NUMBER."
2565 `(gnus-data-pos (gnus-data-find
2566 ,(or number '(gnus-summary-article-number)))))
2568 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2569 (defmacro gnus-summary-article-subject (&optional number)
2570 "Return current subject string or nil if nothing."
2573 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2574 '(gnus-data-header (assq (gnus-summary-article-number)
2575 gnus-newsgroup-data)))))
2578 (mail-header-subject headers))))
2580 (defmacro gnus-summary-article-score (&optional number)
2581 "Return current article score."
2582 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2583 gnus-newsgroup-scored))
2584 gnus-summary-default-score 0))
2586 (defun gnus-summary-article-children (&optional number)
2587 "Return a list of article numbers that are children of article NUMBER."
2588 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2589 (level (gnus-data-level (car data)))
2591 (while (and (setq data (cdr data))
2592 (> (setq l (gnus-data-level (car data))) level))
2593 (and (= (1+ level) l)
2594 (push (gnus-data-number (car data))
2596 (nreverse children)))
2598 (defun gnus-summary-article-parent (&optional number)
2599 "Return the article number of the parent of article NUMBER."
2600 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2601 (gnus-data-list t)))
2602 (level (gnus-data-level (car data))))
2604 () ; This is a root.
2605 ;; We search until we find an article with a level less than
2606 ;; this one. That function has to be the parent.
2607 (while (and (setq data (cdr data))
2608 (not (< (gnus-data-level (car data)) level))))
2609 (and data (gnus-data-number (car data))))))
2611 (defun gnus-unread-mark-p (mark)
2612 "Say whether MARK is the unread mark."
2613 (= mark gnus-unread-mark))
2615 (defun gnus-read-mark-p (mark)
2616 "Say whether MARK is one of the marks that mark as read.
2617 This is all marks except unread, ticked, dormant, and expirable."
2618 (not (or (= mark gnus-unread-mark)
2619 (= mark gnus-ticked-mark)
2620 (= mark gnus-dormant-mark)
2621 (= mark gnus-expirable-mark))))
2623 (defmacro gnus-article-mark (number)
2624 "Return the MARK of article NUMBER.
2625 This macro should only be used when computing the mark the \"first\"
2626 time; i.e., when generating the summary lines. After that,
2627 `gnus-summary-article-mark' should be used to examine the
2630 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2631 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2632 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2633 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2634 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2635 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2636 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2637 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2638 gnus-ancient-mark))))
2640 ;; Saving hidden threads.
2642 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2643 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2645 (defmacro gnus-save-hidden-threads (&rest forms)
2646 "Save hidden threads, eval FORMS, and restore the hidden threads."
2647 (let ((config (make-symbol "config")))
2648 `(let ((,config (gnus-hidden-threads-configuration)))
2652 (gnus-restore-hidden-threads-configuration ,config)))))
2654 (defun gnus-data-compute-positions ()
2655 "Compute the positions of all articles."
2656 (setq gnus-newsgroup-data-reverse nil)
2657 (let ((data gnus-newsgroup-data))
2659 (gnus-save-hidden-threads
2660 (gnus-summary-show-all-threads)
2661 (goto-char (point-min))
2663 (while (get-text-property (point) 'gnus-intangible)
2665 (gnus-data-set-pos (car data) (+ (point) 3))
2666 (setq data (cdr data))
2667 (forward-line 1))))))
2669 (defun gnus-hidden-threads-configuration ()
2670 "Return the current hidden threads configuration."
2673 (goto-char (point-min))
2674 (while (search-forward "\r" nil t)
2675 (push (1- (point)) config))
2678 (defun gnus-restore-hidden-threads-configuration (config)
2679 "Restore hidden threads configuration from CONFIG."
2681 (let (point buffer-read-only)
2682 (while (setq point (pop config))
2683 (when (and (< point (point-max))
2685 (eq (char-after) ?\n))
2686 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2688 ;; Various summary mode internalish functions.
2690 (defun gnus-mouse-pick-article (e)
2693 (gnus-summary-next-page nil t))
2695 (defun gnus-summary-set-display-table ()
2696 "Change the display table.
2697 Odd characters have a tendency to mess
2698 up nicely formatted displays - we make all possible glyphs
2699 display only a single character."
2701 ;; We start from the standard display table, if any.
2702 (let ((table (or (copy-sequence standard-display-table)
2703 (make-display-table)))
2705 ;; Nix out all the control chars...
2706 (while (>= (setq i (1- i)) 0)
2707 (aset table i [??]))
2708 ;; ... but not newline and cr, of course. (cr is necessary for the
2709 ;; selective display).
2710 (aset table ?\n nil)
2711 (aset table ?\r nil)
2712 ;; We keep TAB as well.
2713 (aset table ?\t nil)
2714 ;; We nix out any glyphs over 126 that are not set already.
2716 (while (>= (setq i (1- i)) 127)
2717 ;; Only modify if the entry is nil.
2718 (unless (aref table i)
2719 (aset table i [??]))))
2720 (setq buffer-display-table table)))
2722 (defun gnus-summary-set-article-display-arrow (pos)
2723 "Update the overlay arrow to point to line at position POS."
2724 (when (and gnus-summary-display-arrow
2725 (boundp 'overlay-arrow-position)
2726 (boundp 'overlay-arrow-string))
2730 (unless overlay-arrow-position
2731 (setq overlay-arrow-position (make-marker)))
2732 (setq overlay-arrow-string "=>"
2733 overlay-arrow-position (set-marker overlay-arrow-position
2735 (current-buffer))))))
2737 (defun gnus-summary-buffer-name (group)
2738 "Return the summary buffer name of GROUP."
2739 (concat "*Summary " group "*"))
2741 (defun gnus-summary-setup-buffer (group)
2742 "Initialize summary buffer."
2743 (let ((buffer (gnus-summary-buffer-name group)))
2744 (if (get-buffer buffer)
2747 (setq gnus-summary-buffer (current-buffer))
2748 (not gnus-newsgroup-prepared))
2749 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2750 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2751 (gnus-summary-mode group)
2753 (gnus-carpal-setup-buffer 'summary))
2754 (unless gnus-single-article-buffer
2755 (make-local-variable 'gnus-article-buffer)
2756 (make-local-variable 'gnus-article-current)
2757 (make-local-variable 'gnus-original-article-buffer))
2758 (setq gnus-newsgroup-name group)
2759 ;; Set any local variables in the group parameters.
2760 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2763 (defun gnus-set-global-variables ()
2764 "Set the global equivalents of the buffer-local variables.
2765 They are set to the latest values they had. These reflect the summary
2766 buffer that was in action when the last article was fetched."
2767 (when (eq major-mode 'gnus-summary-mode)
2768 (setq gnus-summary-buffer (current-buffer))
2769 (let ((name gnus-newsgroup-name)
2770 (marked gnus-newsgroup-marked)
2771 (unread gnus-newsgroup-unreads)
2772 (headers gnus-current-headers)
2773 (data gnus-newsgroup-data)
2774 (summary gnus-summary-buffer)
2775 (article-buffer gnus-article-buffer)
2776 (original gnus-original-article-buffer)
2777 (gac gnus-article-current)
2778 (reffed gnus-reffed-article-number)
2779 (score-file gnus-current-score-file)
2780 (default-charset gnus-newsgroup-charset)
2782 (let ((locals gnus-newsgroup-variables))
2784 (if (consp (car locals))
2785 (push (eval (caar locals)) vlist)
2786 (push (eval (car locals)) vlist))
2787 (setq locals (cdr locals)))
2788 (setq vlist (nreverse vlist)))
2790 (set-buffer gnus-group-buffer)
2791 (setq gnus-newsgroup-name name
2792 gnus-newsgroup-marked marked
2793 gnus-newsgroup-unreads unread
2794 gnus-current-headers headers
2795 gnus-newsgroup-data data
2796 gnus-article-current gac
2797 gnus-summary-buffer summary
2798 gnus-article-buffer article-buffer
2799 gnus-original-article-buffer original
2800 gnus-reffed-article-number reffed
2801 gnus-current-score-file score-file
2802 gnus-newsgroup-charset default-charset)
2803 (let ((locals gnus-newsgroup-variables))
2805 (if (consp (car locals))
2806 (set (caar locals) (pop vlist))
2807 (set (car locals) (pop vlist)))
2808 (setq locals (cdr locals))))
2809 ;; The article buffer also has local variables.
2810 (when (gnus-buffer-live-p gnus-article-buffer)
2811 (set-buffer gnus-article-buffer)
2812 (setq gnus-summary-buffer summary))))))
2814 (defun gnus-summary-article-unread-p (article)
2815 "Say whether ARTICLE is unread or not."
2816 (memq article gnus-newsgroup-unreads))
2818 (defun gnus-summary-first-article-p (&optional article)
2819 "Return whether ARTICLE is the first article in the buffer."
2820 (if (not (setq article (or article (gnus-summary-article-number))))
2822 (eq article (caar gnus-newsgroup-data))))
2824 (defun gnus-summary-last-article-p (&optional article)
2825 "Return whether ARTICLE is the last article in the buffer."
2826 (if (not (setq article (or article (gnus-summary-article-number))))
2827 ;; All non-existent numbers are the last article. :-)
2829 (not (cdr (gnus-data-find-list article)))))
2831 (defun gnus-make-thread-indent-array ()
2833 (unless (and gnus-thread-indent-array
2834 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2835 (setq gnus-thread-indent-array (make-vector 201 "")
2836 gnus-thread-indent-array-level gnus-thread-indent-level)
2838 (aset gnus-thread-indent-array n
2839 (make-string (* n gnus-thread-indent-level) ? ))
2842 (defun gnus-update-summary-mark-positions ()
2843 "Compute where the summary marks are to go."
2845 (when (gnus-buffer-exists-p gnus-summary-buffer)
2846 (set-buffer gnus-summary-buffer))
2847 (let ((gnus-replied-mark 129)
2848 (gnus-score-below-mark 130)
2849 (gnus-score-over-mark 130)
2850 (gnus-download-mark 131)
2851 (spec gnus-summary-line-format-spec)
2854 (gnus-set-work-buffer)
2855 (let ((gnus-summary-line-format-spec spec)
2856 (gnus-newsgroup-downloadable '((0 . t))))
2857 (gnus-summary-insert-line
2858 (make-full-mail-header 0 "" "nobody"
2859 "05 Apr 2001 23:33:09 +0400"
2861 0 nil 128 t nil "" nil 1)
2862 (goto-char (point-min))
2863 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2865 (goto-char (point-min))
2866 (push (cons 'replied (and (search-forward "\201" nil t)
2869 (goto-char (point-min))
2870 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2872 (goto-char (point-min))
2873 (push (cons 'download
2874 (and (search-forward "\203" nil t) (- (point) 2)))
2876 (setq gnus-summary-mark-positions pos))))
2878 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2879 "Insert a dummy root in the summary buffer."
2881 (gnus-add-text-properties
2882 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2883 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2885 (defun gnus-summary-from-or-to-or-newsgroups (header)
2886 (let ((to (cdr (assq 'To (mail-header-extra header))))
2887 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2888 (default-mime-charset (with-current-buffer gnus-summary-buffer
2889 default-mime-charset)))
2892 gnus-ignored-from-addresses
2893 (string-match gnus-ignored-from-addresses
2894 (mail-header-from header)))
2896 (or (car (funcall gnus-extract-address-components
2898 gnus-decode-encoded-word-function to)))
2899 (funcall gnus-decode-encoded-word-function to))))
2901 gnus-ignored-from-addresses
2902 (string-match gnus-ignored-from-addresses
2903 (mail-header-from header)))
2904 (concat "=> " newsgroups))
2906 (or (car (funcall gnus-extract-address-components
2907 (mail-header-from header)))
2908 (mail-header-from header))))))
2910 (defun gnus-summary-insert-line (gnus-tmp-header
2911 gnus-tmp-level gnus-tmp-current
2912 gnus-tmp-unread gnus-tmp-replied
2913 gnus-tmp-expirable gnus-tmp-subject-or-nil
2914 &optional gnus-tmp-dummy gnus-tmp-score
2916 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2917 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2918 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2919 (gnus-tmp-score-char
2920 (if (or (null gnus-summary-default-score)
2921 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2922 gnus-summary-zcore-fuzz))
2924 (if (< gnus-tmp-score gnus-summary-default-score)
2925 gnus-score-below-mark gnus-score-over-mark)))
2927 (cond (gnus-tmp-process gnus-process-mark)
2928 ((memq gnus-tmp-current gnus-newsgroup-cached)
2930 (gnus-tmp-replied gnus-replied-mark)
2931 ((memq gnus-tmp-current gnus-newsgroup-saved)
2934 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2937 ((string-match "<[^>]+> *$" gnus-tmp-from)
2938 (let ((beg (match-beginning 0)))
2939 (or (and (string-match "^\".+\"" gnus-tmp-from)
2940 (substring gnus-tmp-from 1 (1- (match-end 0))))
2941 (substring gnus-tmp-from 0 beg))))
2942 ((string-match "(.+)" gnus-tmp-from)
2943 (substring gnus-tmp-from
2944 (1+ (match-beginning 0)) (1- (match-end 0))))
2946 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2947 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2948 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2949 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2950 (buffer-read-only nil))
2951 (when (string= gnus-tmp-name "")
2952 (setq gnus-tmp-name gnus-tmp-from))
2953 (unless (numberp gnus-tmp-lines)
2954 (setq gnus-tmp-lines -1))
2955 (when (= gnus-tmp-lines -1)
2956 (setq gnus-tmp-lines "?"))
2957 (gnus-put-text-property-excluding-characters-with-faces
2959 (progn (eval gnus-summary-line-format-spec) (point))
2960 'gnus-number gnus-tmp-number)
2961 (when (gnus-visual-p 'summary-highlight 'highlight)
2963 (gnus-run-hooks 'gnus-summary-update-hook)
2966 (defun gnus-summary-update-line (&optional dont-update)
2967 "Update summary line after change."
2968 (when (and gnus-summary-default-score
2969 (not gnus-summary-inhibit-highlight))
2970 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2971 (article (gnus-summary-article-number))
2972 (score (gnus-summary-article-score article)))
2974 (if (and gnus-summary-mark-below
2975 (< (gnus-summary-article-score)
2976 gnus-summary-mark-below))
2977 ;; This article has a low score, so we mark it as read.
2978 (when (memq article gnus-newsgroup-unreads)
2979 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2980 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2981 ;; This article was previously marked as read on account
2982 ;; of a low score, but now it has risen, so we mark it as
2984 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2985 (gnus-summary-update-mark
2986 (if (or (null gnus-summary-default-score)
2987 (<= (abs (- score gnus-summary-default-score))
2988 gnus-summary-zcore-fuzz))
2990 (if (< score gnus-summary-default-score)
2991 gnus-score-below-mark gnus-score-over-mark))
2993 ;; Do visual highlighting.
2994 (when (gnus-visual-p 'summary-highlight 'highlight)
2995 (gnus-run-hooks 'gnus-summary-update-hook)))))
2997 (defvar gnus-tmp-new-adopts nil)
2999 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3000 "Return the number of articles in THREAD.
3001 This may be 0 in some cases -- if none of the articles in
3002 the thread are to be displayed."
3004 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3006 ((not (listp thread))
3008 ((and (consp thread) (cdr thread))
3011 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3014 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3017 (when (and level (zerop level) gnus-tmp-new-adopts)
3020 'gnus-summary-number-of-articles-in-thread
3021 gnus-tmp-new-adopts))))
3023 (if (> number 1) gnus-not-empty-thread-mark
3024 gnus-empty-thread-mark)
3027 (defun gnus-summary-set-local-parameters (group)
3028 "Go through the local params of GROUP and set all variable specs in that list."
3029 (let ((params (gnus-group-find-parameter group))
3030 (vars '(quit-config)) ; Ignore quit-config.
3033 (setq elem (car params)
3034 params (cdr params))
3035 (and (consp elem) ; Has to be a cons.
3036 (consp (cdr elem)) ; The cdr has to be a list.
3037 (symbolp (car elem)) ; Has to be a symbol in there.
3038 (not (memq (car elem) vars))
3039 (ignore-errors ; So we set it.
3040 (push (car elem) vars)
3041 (make-local-variable (car elem))
3042 (set (car elem) (eval (nth 1 elem))))))))
3044 (defun gnus-summary-read-group (group &optional show-all no-article
3045 kill-buffer no-display backward
3047 "Start reading news in newsgroup GROUP.
3048 If SHOW-ALL is non-nil, already read articles are also listed.
3049 If NO-ARTICLE is non-nil, no article is selected initially.
3050 If NO-DISPLAY, don't generate a summary buffer."
3054 (let ((gnus-auto-select-next nil))
3055 (or (gnus-summary-read-group-1
3056 group show-all no-article
3057 kill-buffer no-display
3060 select-articles nil)))))
3061 (eq gnus-auto-select-next 'quietly))
3062 (set-buffer gnus-group-buffer)
3063 ;; The entry function called above goes to the next
3064 ;; group automatically, so we go two groups back
3065 ;; if we are searching for the previous group.
3067 (gnus-group-prev-unread-group 2))
3068 (if (not (equal group (gnus-group-group-name)))
3069 (setq group (gnus-group-group-name))
3073 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3074 "Directly jump to the other GROUP from summary buffer.
3075 If SHOW-ALL is non-nil, already read articles are also listed."
3077 (if (eq gnus-summary-buffer (current-buffer))
3078 (list (completing-read
3079 "Group: " gnus-active-hashtb nil t
3080 (when (and gnus-newsgroup-name
3081 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3082 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3083 'gnus-group-history)
3085 (error "%s must be invoked from a gnus summary buffer." this-command)))
3086 (unless (or (zerop (length group))
3087 (and gnus-newsgroup-name
3088 (string-equal gnus-newsgroup-name group)))
3090 (gnus-summary-read-group group show-all
3091 gnus-dont-select-after-jump-to-other-group)))
3093 (defun gnus-summary-read-group-1 (group show-all no-article
3094 kill-buffer no-display
3095 &optional select-articles)
3096 ;; Killed foreign groups can't be entered.
3097 ;; (when (and (not (gnus-group-native-p group))
3098 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3099 ;; (error "Dead non-native groups can't be entered"))
3100 (gnus-message 5 "Retrieving newsgroup: %s..."
3101 (gnus-group-decoded-name group))
3102 (let* ((new-group (gnus-summary-setup-buffer group))
3103 (quit-config (gnus-group-quit-config group))
3104 (did-select (and new-group (gnus-select-newsgroup
3105 group show-all select-articles))))
3107 ;; This summary buffer exists already, so we just select it.
3109 (gnus-set-global-variables)
3111 (gnus-kill-or-deaden-summary kill-buffer))
3112 (gnus-configure-windows 'summary 'force)
3113 (gnus-set-mode-line 'summary)
3114 (gnus-summary-position-point)
3117 ;; We couldn't select this group.
3119 (when (and (eq major-mode 'gnus-summary-mode)
3120 (not (equal (current-buffer) kill-buffer)))
3121 (kill-buffer (current-buffer))
3122 (if (not quit-config)
3124 ;; Update the info -- marks might need to be removed,
3126 (gnus-summary-update-info)
3127 (set-buffer gnus-group-buffer)
3128 (gnus-group-jump-to-group group)
3129 (gnus-group-next-unread-group 1))
3130 (gnus-handle-ephemeral-exit quit-config)))
3131 (let ((grpinfo (gnus-get-info group)))
3132 (if (null (gnus-info-read grpinfo))
3133 (gnus-message 3 "Group %s contains no messages"
3134 (gnus-group-decoded-name group))
3135 (gnus-message 3 "Can't select group")))
3137 ;; The user did a `C-g' while prompting for number of articles,
3138 ;; so we exit this group.
3139 ((eq did-select 'quit)
3140 (and (eq major-mode 'gnus-summary-mode)
3141 (not (equal (current-buffer) kill-buffer))
3142 (kill-buffer (current-buffer)))
3144 (gnus-kill-or-deaden-summary kill-buffer))
3145 (if (not quit-config)
3147 (set-buffer gnus-group-buffer)
3148 (gnus-group-jump-to-group group)
3149 (gnus-group-next-unread-group 1)
3150 (gnus-configure-windows 'group 'force))
3151 (gnus-handle-ephemeral-exit quit-config))
3152 ;; Finally signal the quit.
3154 ;; The group was successfully selected.
3156 (gnus-set-global-variables)
3157 ;; Save the active value in effect when the group was entered.
3158 (setq gnus-newsgroup-active
3160 (gnus-active gnus-newsgroup-name)))
3161 ;; You can change the summary buffer in some way with this hook.
3162 (gnus-run-hooks 'gnus-select-group-hook)
3163 (gnus-update-format-specifications
3164 nil 'summary 'summary-mode 'summary-dummy)
3165 (gnus-update-summary-mark-positions)
3166 ;; Do score processing.
3167 (when gnus-use-scoring
3168 (gnus-possibly-score-headers))
3169 ;; Check whether to fill in the gaps in the threads.
3170 (when gnus-build-sparse-threads
3171 (gnus-build-sparse-threads))
3172 ;; Find the initial limit.
3173 (if gnus-show-threads
3175 (let ((gnus-newsgroup-dormant nil))
3176 (gnus-summary-initial-limit show-all))
3177 (gnus-summary-initial-limit show-all))
3178 ;; When untreaded, all articles are always shown.
3179 (setq gnus-newsgroup-limit
3181 (lambda (header) (mail-header-number header))
3182 gnus-newsgroup-headers)))
3183 ;; Generate the summary buffer.
3185 (gnus-summary-prepare))
3186 (when gnus-use-trees
3187 (gnus-tree-open group)
3188 (setq gnus-summary-highlight-line-function
3189 'gnus-tree-highlight-article))
3190 ;; If the summary buffer is empty, but there are some low-scored
3191 ;; articles or some excluded dormants, we include these in the
3193 (when (and (zerop (buffer-size))
3195 (cond (gnus-newsgroup-dormant
3196 (gnus-summary-limit-include-dormant))
3197 ((and gnus-newsgroup-scored show-all)
3198 (gnus-summary-limit-include-expunged t))))
3199 ;; Function `gnus-apply-kill-file' must be called in this hook.
3200 (gnus-run-hooks 'gnus-apply-kill-hook)
3201 (if (and (zerop (buffer-size))
3204 ;; This newsgroup is empty.
3205 (gnus-summary-catchup-and-exit nil t)
3206 (gnus-message 6 "No unread news")
3208 (gnus-kill-or-deaden-summary kill-buffer))
3209 ;; Return nil from this function.
3211 ;; Hide conversation thread subtrees. We cannot do this in
3212 ;; gnus-summary-prepare-hook since kill processing may not
3213 ;; work with hidden articles.
3214 (and gnus-show-threads
3215 gnus-thread-hide-subtree
3216 (gnus-summary-hide-all-threads))
3218 (gnus-kill-or-deaden-summary kill-buffer))
3219 ;; Show first unread article if requested.
3220 (if (and (not no-article)
3222 gnus-newsgroup-unreads
3223 gnus-auto-select-first)
3225 (gnus-configure-windows 'summary)
3227 ((eq gnus-auto-select-first 'best)
3228 (gnus-summary-best-unread-article))
3229 ((eq gnus-auto-select-first t)
3230 (gnus-summary-first-unread-article))
3231 ((gnus-functionp gnus-auto-select-first)
3232 (funcall gnus-auto-select-first))))
3233 ;; Don't select any articles, just move point to the first
3234 ;; article in the group.
3235 (goto-char (point-min))
3236 (gnus-summary-position-point)
3237 (gnus-configure-windows 'summary 'force)
3238 (gnus-set-mode-line 'summary))
3239 (when (get-buffer-window gnus-group-buffer t)
3240 ;; Gotta use windows, because recenter does weird stuff if
3241 ;; the current buffer ain't the displayed window.
3242 (let ((owin (selected-window)))
3243 (select-window (get-buffer-window gnus-group-buffer t))
3244 (when (gnus-group-goto-group group)
3246 (select-window owin)))
3247 ;; Mark this buffer as "prepared".
3248 (setq gnus-newsgroup-prepared t)
3249 (gnus-run-hooks 'gnus-summary-prepared-hook)
3252 (defun gnus-summary-prepare ()
3253 "Generate the summary buffer."
3255 (let ((buffer-read-only nil))
3257 (setq gnus-newsgroup-data nil
3258 gnus-newsgroup-data-reverse nil)
3259 (gnus-run-hooks 'gnus-summary-generate-hook)
3260 ;; Generate the buffer, either with threads or without.
3261 (when gnus-newsgroup-headers
3262 (gnus-summary-prepare-threads
3263 (if gnus-show-threads
3264 (gnus-sort-gathered-threads
3265 (funcall gnus-summary-thread-gathering-function
3267 (gnus-cut-threads (gnus-make-threads)))))
3268 ;; Unthreaded display.
3269 (gnus-sort-articles gnus-newsgroup-headers))))
3270 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3271 ;; Call hooks for modifying summary buffer.
3272 (goto-char (point-min))
3273 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3275 (defsubst gnus-general-simplify-subject (subject)
3276 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3279 ;; Truncate the subject.
3280 (gnus-simplify-subject-functions
3281 (gnus-map-function gnus-simplify-subject-functions subject))
3282 ((numberp gnus-summary-gather-subject-limit)
3283 (setq subject (gnus-simplify-subject-re subject))
3284 (if (> (length subject) gnus-summary-gather-subject-limit)
3285 (substring subject 0 gnus-summary-gather-subject-limit)
3287 ;; Fuzzily simplify it.
3288 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3289 (gnus-simplify-subject-fuzzy subject))
3290 ;; Just remove the leading "Re:".
3292 (gnus-simplify-subject-re subject))))
3294 (if (and gnus-summary-gather-exclude-subject
3295 (string-match gnus-summary-gather-exclude-subject subject))
3296 nil ; This article shouldn't be gathered
3299 (defun gnus-summary-simplify-subject-query ()
3300 "Query where the respool algorithm would put this article."
3302 (gnus-summary-select-article)
3304 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3306 (defun gnus-gather-threads-by-subject (threads)
3307 "Gather threads by looking at Subject headers."
3308 (if (not gnus-summary-make-false-root)
3310 (let ((hashtb (gnus-make-hashtable 1024))
3313 subject hthread whole-subject)
3315 (setq subject (gnus-general-simplify-subject
3316 (setq whole-subject (mail-header-subject
3319 (if (setq hthread (gnus-gethash subject hashtb))
3321 ;; We enter a dummy root into the thread, if we
3322 ;; haven't done that already.
3323 (unless (stringp (caar hthread))
3324 (setcar hthread (list whole-subject (car hthread))))
3325 ;; We add this new gathered thread to this gathered
3327 (setcdr (car hthread)
3328 (nconc (cdar hthread) (list (car threads))))
3329 ;; Remove it from the list of threads.
3330 (setcdr prev (cdr threads))
3331 (setq threads prev))
3332 ;; Enter this thread into the hash table.
3333 (gnus-sethash subject threads hashtb)))
3335 (setq threads (cdr threads)))
3338 (defun gnus-gather-threads-by-references (threads)
3339 "Gather threads by looking at References headers."
3340 (let ((idhashtb (gnus-make-hashtable 1024))
3341 (thhashtb (gnus-make-hashtable 1024))
3344 ids references id gthread gid entered ref)
3346 (when (setq references (mail-header-references (caar threads)))
3347 (setq id (mail-header-id (caar threads))
3348 ids (gnus-split-references references)
3350 (while (setq ref (pop ids))
3351 (setq ids (delete ref ids))
3352 (if (not (setq gid (gnus-gethash ref idhashtb)))
3354 (gnus-sethash ref id idhashtb)
3355 (gnus-sethash id threads thhashtb))
3356 (setq gthread (gnus-gethash gid thhashtb))
3358 ;; We enter a dummy root into the thread, if we
3359 ;; haven't done that already.
3360 (unless (stringp (caar gthread))
3361 (setcar gthread (list (mail-header-subject (caar gthread))
3363 ;; We add this new gathered thread to this gathered
3365 (setcdr (car gthread)
3366 (nconc (cdar gthread) (list (car threads)))))
3367 ;; Add it into the thread hash table.
3368 (gnus-sethash id gthread thhashtb)
3370 ;; Remove it from the list of threads.
3371 (setcdr prev (cdr threads))
3372 (setq threads prev))))
3374 (setq threads (cdr threads)))
3377 (defun gnus-sort-gathered-threads (threads)
3378 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3379 (let ((result threads))
3381 (when (stringp (caar threads))
3382 (setcdr (car threads)
3383 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3384 (setq threads (cdr threads)))
3387 (defun gnus-thread-loop-p (root thread)
3388 "Say whether ROOT is in THREAD."
3389 (let ((stack (list thread))
3392 (while (setq thread (pop stack))
3393 (setq th (cdr thread))
3395 (not (eq (caar th) root)))
3398 ;; We have found a loop.
3400 (setcdr thread (delq (car th) (cdr thread)))
3401 (if (boundp (setq ref-dep (intern "none"
3402 gnus-newsgroup-dependencies)))
3403 (setcdr (symbol-value ref-dep)
3404 (nconc (cdr (symbol-value ref-dep))
3406 (set ref-dep (list nil (car th))))
3409 ;; Push all the subthreads onto the stack.
3410 (push (cdr thread) stack)))
3413 (defun gnus-make-threads ()
3414 "Go through the dependency hashtb and find the roots. Return all threads."
3416 (while (catch 'infloop
3419 ;; Deal with self-referencing References loops.
3420 (when (and (car (symbol-value refs))
3427 (car (symbol-value refs)) thread))
3428 (cdr (symbol-value refs)))))))
3431 (unless (car (symbol-value refs))
3432 ;; These threads do not refer back to any other articles,
3433 ;; so they're roots.
3434 (setq threads (append (cdr (symbol-value refs)) threads))))
3435 gnus-newsgroup-dependencies)))
3438 ;; Build the thread tree.
3439 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3440 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3442 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3443 if it was already present.
3445 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3446 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3447 Message-IDs will be renamed be renamed to a unique Message-ID before
3450 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3451 (let* ((id (mail-header-id header))
3452 (id-dep (and id (intern id dependencies)))
3453 ref ref-dep ref-header)
3454 ;; Enter this `header' in the `dependencies' table.
3458 ;; The first two cases do the normal part: enter a new `header'
3459 ;; in the `dependencies' table.
3460 ((not (boundp id-dep))
3461 (set id-dep (list header)))
3462 ((null (car (symbol-value id-dep)))
3463 (setcar (symbol-value id-dep) header))
3465 ;; From here the `header' was already present in the
3466 ;; `dependencies' table.
3468 ;; Overrides an existing entry;
3469 ;; just set the header part of the entry.
3470 (setcar (symbol-value id-dep) header))
3472 ;; Renames the existing `header' to a unique Message-ID.
3473 ((not gnus-summary-ignore-duplicates)
3474 ;; An article with this Message-ID has already been seen.
3475 ;; We rename the Message-ID.
3476 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3478 (mail-header-set-id header id))
3480 ;; The last case ignores an existing entry, except it adds any
3481 ;; additional Xrefs (in case the two articles came from different
3483 ;; Also sets `header' to `nil' meaning that the `dependencies'
3484 ;; table was *not* modified.
3486 (mail-header-set-xref
3487 (car (symbol-value id-dep))
3488 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3490 (or (mail-header-xref header) "")))
3494 ;; First check if that we are not creating a References loop.
3495 (setq ref (gnus-parent-id (mail-header-references header)))
3497 (setq ref-dep (intern-soft ref dependencies))
3499 (setq ref-header (car (symbol-value ref-dep))))
3500 (if (string= id ref)
3501 ;; Yuk! This is a reference loop. Make the article be a
3504 (mail-header-set-references (car (symbol-value id-dep)) "none")
3506 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3507 (setq ref (gnus-parent-id (mail-header-references header)))
3508 (setq ref-dep (intern (or ref "none") dependencies))
3509 (if (boundp ref-dep)
3510 (setcdr (symbol-value ref-dep)
3511 (nconc (cdr (symbol-value ref-dep))
3512 (list (symbol-value id-dep))))
3513 (set ref-dep (list nil (symbol-value id-dep)))))
3516 (defun gnus-build-sparse-threads ()
3517 (let ((headers gnus-newsgroup-headers)
3518 (mail-parse-charset gnus-newsgroup-charset)
3519 (gnus-summary-ignore-duplicates t)
3520 header references generation relations
3521 subject child end new-child date)
3522 ;; First we create an alist of generations/relations, where
3523 ;; generations is how much we trust the relation, and the relation
3525 (gnus-message 7 "Making sparse threads...")
3527 (nnheader-set-temp-buffer " *gnus sparse threads*")
3528 (while (setq header (pop headers))
3529 (when (and (setq references (mail-header-references header))
3530 (not (string= references "")))
3532 (setq child (mail-header-id header)
3533 subject (mail-header-subject header)
3534 date (mail-header-date header)
3536 (while (search-backward ">" nil t)
3537 (setq end (1+ (point)))
3538 (when (search-backward "<" nil t)
3539 (setq new-child (buffer-substring (point) end))
3540 (push (list (incf generation)
3541 child (setq child new-child)
3545 (push (list (1+ generation) child nil subject) relations))
3547 (kill-buffer (current-buffer)))
3548 ;; Sort over trustworthiness.
3551 (when (gnus-dependencies-add-header
3552 (make-full-mail-header-from-decoded-header
3553 gnus-reffed-article-number
3554 (nth 3 relation) "" (or (nth 4 relation) "")
3556 (or (nth 2 relation) "") 0 0 "")
3557 gnus-newsgroup-dependencies nil)
3558 (push gnus-reffed-article-number gnus-newsgroup-limit)
3559 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3560 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3561 gnus-newsgroup-reads)
3562 (decf gnus-reffed-article-number)))
3563 (sort relations 'car-less-than-car))
3564 (gnus-message 7 "Making sparse threads...done")))
3566 (defun gnus-build-old-threads ()
3567 ;; Look at all the articles that refer back to old articles, and
3568 ;; fetch the headers for the articles that aren't there. This will
3569 ;; build complete threads - if the roots haven't been expired by the
3571 (let ((mail-parse-charset gnus-newsgroup-charset)
3575 (when (not (car (symbol-value refs)))
3576 (setq heads (cdr (symbol-value refs)))
3578 (if (memq (mail-header-number (caar heads))
3579 gnus-newsgroup-dormant)
3580 (setq heads (cdr heads))
3581 (setq id (symbol-name refs))
3582 (while (and (setq id (gnus-build-get-header id))
3583 (not (car (gnus-id-to-thread id)))))
3584 (setq heads nil)))))
3585 gnus-newsgroup-dependencies)))
3587 ;; This function has to be called with point after the article number
3588 ;; on the beginning of the line.
3589 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3590 (let ((eol (gnus-point-at-eol))
3591 (buffer (current-buffer))
3594 ;; overview: [num subject from date id refs chars lines misc]
3597 (narrow-to-region (point) eol)
3602 (make-full-mail-header
3604 (nnheader-nov-field) ; subject
3605 (nnheader-nov-field) ; from
3606 (nnheader-nov-field) ; date
3607 (nnheader-nov-read-message-id) ; id
3608 (nnheader-nov-field) ; refs
3609 (nnheader-nov-read-integer) ; chars
3610 (nnheader-nov-read-integer) ; lines
3612 (if (looking-at "Xref: ")
3613 (goto-char (match-end 0)))
3614 (nnheader-nov-field)) ; Xref
3615 (nnheader-nov-parse-extra)))) ; extra
3619 (when gnus-alter-header-function
3620 (funcall gnus-alter-header-function header))
3621 (gnus-dependencies-add-header header dependencies force-new)))
3623 (defun gnus-build-get-header (id)
3624 "Look through the buffer of NOV lines and find the header to ID.
3625 Enter this line into the dependencies hash table, and return
3626 the id of the parent article (if any)."
3627 (let ((deps gnus-newsgroup-dependencies)
3631 (set-buffer nntp-server-buffer)
3632 (let ((case-fold-search nil))
3633 (goto-char (point-min))
3634 (while (and (not found)
3635 (search-forward id nil t))
3637 (setq found (looking-at
3638 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3639 (regexp-quote id))))
3640 (or found (beginning-of-line 2)))
3644 (setq header (gnus-nov-parse-line
3645 (read (current-buffer)) deps))
3646 (gnus-parent-id (mail-header-references header))))))
3648 (let ((number (mail-header-number header)))
3649 (push number gnus-newsgroup-limit)
3650 (push header gnus-newsgroup-headers)
3651 (if (memq number gnus-newsgroup-unselected)
3653 (push number gnus-newsgroup-unreads)
3654 (setq gnus-newsgroup-unselected
3655 (delq number gnus-newsgroup-unselected)))
3656 (push number gnus-newsgroup-ancient)))))))
3658 (defun gnus-build-all-threads ()
3659 "Read all the headers."
3660 (let ((gnus-summary-ignore-duplicates t)
3661 (mail-parse-charset gnus-newsgroup-charset)
3662 (dependencies gnus-newsgroup-dependencies)
3665 (set-buffer nntp-server-buffer)
3666 (let ((case-fold-search nil))
3667 (goto-char (point-min))
3670 (setq article (read (current-buffer))
3671 header (gnus-nov-parse-line article dependencies)))
3674 (set-buffer gnus-summary-buffer)
3675 (push header gnus-newsgroup-headers)
3676 (if (memq (setq article (mail-header-number header))
3677 gnus-newsgroup-unselected)
3679 (push article gnus-newsgroup-unreads)
3680 (setq gnus-newsgroup-unselected
3681 (delq article gnus-newsgroup-unselected)))
3682 (push article gnus-newsgroup-ancient)))
3683 (forward-line 1)))))))
3685 (defun gnus-summary-update-article-line (article header)
3686 "Update the line for ARTICLE using HEADERS."
3687 (let* ((id (mail-header-id header))
3688 (thread (gnus-id-to-thread id)))
3690 (error "Article in no thread"))
3691 ;; Update the thread.
3692 (setcar thread header)
3693 (gnus-summary-goto-subject article)
3694 (let* ((datal (gnus-data-find-list article))
3696 (length (when (cdr datal)
3697 (- (gnus-data-pos data)
3698 (gnus-data-pos (cadr datal)))))
3699 (buffer-read-only nil)
3700 (level (gnus-summary-thread-level)))
3702 (gnus-summary-insert-line
3703 header level nil (gnus-article-mark article)
3704 (memq article gnus-newsgroup-replied)
3705 (memq article gnus-newsgroup-expirable)
3706 ;; Only insert the Subject string when it's different
3707 ;; from the previous Subject string.
3712 (mail-header-subject
3715 (gnus-data-find-list
3717 (gnus-data-list t)))))
3718 ;; Error on the side of excessive subjects.
3720 (mail-header-subject header)))
3722 (mail-header-subject header))
3723 nil (cdr (assq article gnus-newsgroup-scored))
3724 (memq article gnus-newsgroup-processable))
3726 (gnus-data-update-list
3727 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3729 (defun gnus-summary-update-article (article &optional iheader)
3730 "Update ARTICLE in the summary buffer."
3731 (set-buffer gnus-summary-buffer)
3732 (let* ((header (gnus-summary-article-header article))
3733 (id (mail-header-id header))
3734 (data (gnus-data-find article))
3735 (thread (gnus-id-to-thread id))
3736 (references (mail-header-references header))
3740 (when (and references
3741 (not (equal "" references)))
3744 (buffer-read-only nil)
3750 (delq thread parent)))
3751 (if (gnus-summary-insert-subject id header)
3752 ;; Set the (possibly) new article number in the data structure.
3753 (gnus-data-set-number data (gnus-id-to-article id))
3757 (defun gnus-rebuild-thread (id &optional line)
3758 "Rebuild the thread containing ID.
3759 If LINE, insert the rebuilt thread starting on line LINE."
3760 (let ((buffer-read-only nil)
3761 old-pos current thread data)
3762 (if (not gnus-show-threads)
3763 (setq thread (list (car (gnus-id-to-thread id))))
3764 ;; Get the thread this article is part of.
3765 (setq thread (gnus-remove-thread id)))
3766 (setq old-pos (gnus-point-at-bol))
3767 (setq current (save-excursion
3768 (and (re-search-backward "[\r\n]" nil t)
3769 (gnus-summary-article-number))))
3770 ;; If this is a gathered thread, we have to go some re-gathering.
3771 (when (stringp (car thread))
3772 (let ((subject (car thread))
3774 (setq thread (cdr thread))
3776 (unless (memq (setq thr (gnus-id-to-thread
3778 (mail-header-id (caar thread)))))
3781 (setq thread (cdr thread)))
3782 ;; We now have all (unique) roots.
3783 (if (= (length roots) 1)
3784 ;; All the loose roots are now one solid root.
3785 (setq thread (car roots))
3786 (setq thread (cons subject (gnus-sort-threads roots))))))
3788 ;; We then insert this thread into the summary buffer.
3790 (goto-char (point-min))
3791 (forward-line (1- line)))
3792 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3793 (if gnus-show-threads
3794 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3795 (gnus-summary-prepare-unthreaded thread))
3796 (setq data (nreverse gnus-newsgroup-data))
3797 (setq threads gnus-newsgroup-threads))
3798 ;; We splice the new data into the data structure.
3799 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3800 ;;!!! then we want to insert at the beginning of the buffer.
3801 ;;!!! That happens to be true with Gnus now, but that may
3802 ;;!!! change in the future. Perhaps.
3803 (gnus-data-enter-list
3804 (if line nil current) data (- (point) old-pos))
3805 (setq gnus-newsgroup-threads
3806 (nconc threads gnus-newsgroup-threads))
3807 (gnus-data-compute-positions))))
3809 (defun gnus-number-to-header (number)
3810 "Return the header for article NUMBER."
3811 (let ((headers gnus-newsgroup-headers))
3813 (not (= number (mail-header-number (car headers)))))
3818 (defun gnus-parent-headers (in-headers &optional generation)
3819 "Return the headers of the GENERATIONeth parent of HEADERS."
3821 (setq generation 1))
3823 (headers in-headers)
3826 (not (zerop generation))
3827 (setq references (mail-header-references headers)))
3828 (setq headers (if (and references
3829 (setq parent (gnus-parent-id references)))
3830 (car (gnus-id-to-thread parent))
3833 (and (not (eq headers in-headers))
3836 (defun gnus-id-to-thread (id)
3837 "Return the (sub-)thread where ID appears."
3838 (gnus-gethash id gnus-newsgroup-dependencies))
3840 (defun gnus-id-to-article (id)
3841 "Return the article number of ID."
3842 (let ((thread (gnus-id-to-thread id)))
3845 (mail-header-number (car thread)))))
3847 (defun gnus-id-to-header (id)
3848 "Return the article headers of ID."
3849 (car (gnus-id-to-thread id)))
3851 (defun gnus-article-displayed-root-p (article)
3852 "Say whether ARTICLE is a root(ish) article."
3853 (let ((level (gnus-summary-thread-level article))
3854 (refs (mail-header-references (gnus-summary-article-header article)))
3860 ((null (gnus-parent-id refs)) t)
3862 (null (setq particle (gnus-id-to-article
3863 (gnus-parent-id refs))))
3864 (null (gnus-summary-thread-level particle)))))))
3866 (defun gnus-root-id (id)
3867 "Return the id of the root of the thread where ID appears."
3869 (while (and id (setq prev (car (gnus-id-to-thread id))))
3871 id (gnus-parent-id (mail-header-references prev))))
3874 (defun gnus-articles-in-thread (thread)
3875 "Return the list of articles in THREAD."
3876 (cons (mail-header-number (car thread))
3877 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3879 (defun gnus-remove-thread (id &optional dont-remove)
3880 "Remove the thread that has ID in it."
3881 (let (headers thread last-id)
3882 ;; First go up in this thread until we find the root.
3883 (setq last-id (gnus-root-id id)
3884 headers (message-flatten-list (gnus-id-to-thread last-id)))
3885 ;; We have now found the real root of this thread. It might have
3886 ;; been gathered into some loose thread, so we have to search
3887 ;; through the threads to find the thread we wanted.
3888 (let ((threads gnus-newsgroup-threads)
3891 (setq sub (car threads))
3892 (if (stringp (car sub))
3893 ;; This is a gathered thread, so we look at the roots
3894 ;; below it to find whether this article is in this
3897 (setq sub (cdr sub))
3899 (when (member (caar sub) headers)
3900 (setq thread (car threads)
3903 (setq sub (cdr sub))))
3904 ;; It's an ordinary thread, so we check it.
3905 (when (eq (car sub) (car headers))
3908 (setq threads (cdr threads)))
3909 ;; If this article is in no thread, then it's a root.
3912 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3913 (setq thread (gnus-id-to-thread last-id)))
3916 thread ; We return this thread.
3918 (if (stringp (car thread))
3920 ;; If we use dummy roots, then we have to remove the
3921 ;; dummy root as well.
3922 (when (eq gnus-summary-make-false-root 'dummy)
3923 ;; We go to the dummy root by going to
3924 ;; the first sub-"thread", and then one line up.
3925 (gnus-summary-goto-article
3926 (mail-header-number (caadr thread)))
3929 (gnus-data-compute-positions))
3930 (setq thread (cdr thread))
3932 (gnus-remove-thread-1 (car thread))
3933 (setq thread (cdr thread))))
3934 (gnus-remove-thread-1 thread))))))))
3936 (defun gnus-remove-thread-1 (thread)
3937 "Remove the thread THREAD recursively."
3938 (let ((number (mail-header-number (pop thread)))
3940 (setq thread (reverse thread))
3942 (gnus-remove-thread-1 (pop thread)))
3943 (when (setq d (gnus-data-find number))
3944 (goto-char (gnus-data-pos d))
3945 (gnus-summary-show-thread)
3948 (- (gnus-point-at-bol)
3950 (1+ (gnus-point-at-eol))
3951 (gnus-delete-line)))))))
3953 (defun gnus-sort-threads-1 (threads func)
3954 (sort (mapcar (lambda (thread)
3957 (gnus-sort-threads-1 (cdr thread) func))))
3960 (defun gnus-sort-threads (threads)
3962 (if (not gnus-thread-sort-functions)
3964 (gnus-message 8 "Sorting threads...")
3966 (gnus-sort-threads-1
3968 (gnus-make-sort-function gnus-thread-sort-functions))
3969 (gnus-message 8 "Sorting threads...done"))))
3971 (defun gnus-sort-articles (articles)
3973 (when gnus-article-sort-functions
3974 (gnus-message 7 "Sorting articles...")
3976 (setq gnus-newsgroup-headers
3977 (sort articles (gnus-make-sort-function
3978 gnus-article-sort-functions)))
3979 (gnus-message 7 "Sorting articles...done"))))
3981 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3982 (defmacro gnus-thread-header (thread)
3983 "Return header of first article in THREAD.
3984 Note that THREAD must never, ever be anything else than a variable -
3985 using some other form will lead to serious barfage."
3986 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3987 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3988 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3991 (defsubst gnus-article-sort-by-number (h1 h2)
3992 "Sort articles by article number."
3993 (< (mail-header-number h1)
3994 (mail-header-number h2)))
3996 (defun gnus-thread-sort-by-number (h1 h2)
3997 "Sort threads by root article number."
3998 (gnus-article-sort-by-number
3999 (gnus-thread-header h1) (gnus-thread-header h2)))
4001 (defsubst gnus-article-sort-by-lines (h1 h2)
4002 "Sort articles by article Lines header."
4003 (< (mail-header-lines h1)
4004 (mail-header-lines h2)))
4006 (defun gnus-thread-sort-by-lines (h1 h2)
4007 "Sort threads by root article Lines header."
4008 (gnus-article-sort-by-lines
4009 (gnus-thread-header h1) (gnus-thread-header h2)))
4011 (defsubst gnus-article-sort-by-chars (h1 h2)
4012 "Sort articles by octet length."
4013 (< (mail-header-chars h1)
4014 (mail-header-chars h2)))
4016 (defun gnus-thread-sort-by-chars (h1 h2)
4017 "Sort threads by root article octet length."
4018 (gnus-article-sort-by-chars
4019 (gnus-thread-header h1) (gnus-thread-header h2)))
4021 (defsubst gnus-article-sort-by-author (h1 h2)
4022 "Sort articles by root author."
4024 (let ((addr (car (mime-entity-read-field h1 'From))))
4025 (or (std11-full-name-string addr)
4026 (std11-address-string addr)
4028 (let ((addr (car (mime-entity-read-field h2 'From))))
4029 (or (std11-full-name-string addr)
4030 (std11-address-string addr)
4034 (defun gnus-thread-sort-by-author (h1 h2)
4035 "Sort threads by root author."
4036 (gnus-article-sort-by-author
4037 (gnus-thread-header h1) (gnus-thread-header h2)))
4039 (defsubst gnus-article-sort-by-subject (h1 h2)
4040 "Sort articles by root subject."
4042 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4043 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4045 (defun gnus-thread-sort-by-subject (h1 h2)
4046 "Sort threads by root subject."
4047 (gnus-article-sort-by-subject
4048 (gnus-thread-header h1) (gnus-thread-header h2)))
4050 (defsubst gnus-article-sort-by-date (h1 h2)
4051 "Sort articles by root article date."
4053 (gnus-date-get-time (mail-header-date h1))
4054 (gnus-date-get-time (mail-header-date h2))))
4056 (defun gnus-thread-sort-by-date (h1 h2)
4057 "Sort threads by root article date."
4058 (gnus-article-sort-by-date
4059 (gnus-thread-header h1) (gnus-thread-header h2)))
4061 (defsubst gnus-article-sort-by-score (h1 h2)
4062 "Sort articles by root article score.
4063 Unscored articles will be counted as having a score of zero."
4064 (> (or (cdr (assq (mail-header-number h1)
4065 gnus-newsgroup-scored))
4066 gnus-summary-default-score 0)
4067 (or (cdr (assq (mail-header-number h2)
4068 gnus-newsgroup-scored))
4069 gnus-summary-default-score 0)))
4071 (defun gnus-thread-sort-by-score (h1 h2)
4072 "Sort threads by root article score."
4073 (gnus-article-sort-by-score
4074 (gnus-thread-header h1) (gnus-thread-header h2)))
4076 (defun gnus-thread-sort-by-total-score (h1 h2)
4077 "Sort threads by the sum of all scores in the thread.
4078 Unscored articles will be counted as having a score of zero."
4079 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4081 (defun gnus-thread-total-score (thread)
4082 ;; This function find the total score of THREAD.
4083 (cond ((null thread)
4086 (if (stringp (car thread))
4087 (apply gnus-thread-score-function 0
4088 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4089 (gnus-thread-total-score-1 thread)))
4091 (gnus-thread-total-score-1 (list thread)))))
4093 (defun gnus-thread-total-score-1 (root)
4094 ;; This function find the total score of the thread below ROOT.
4095 (setq root (car root))
4096 (apply gnus-thread-score-function
4098 (mapcar 'gnus-thread-total-score
4099 (cdr (gnus-id-to-thread (mail-header-id root))))
4100 (when (> (mail-header-number root) 0)
4101 (list (or (cdr (assq (mail-header-number root)
4102 gnus-newsgroup-scored))
4103 gnus-summary-default-score 0))))
4104 (list gnus-summary-default-score)
4107 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4108 (defvar gnus-tmp-prev-subject nil)
4109 (defvar gnus-tmp-false-parent nil)
4110 (defvar gnus-tmp-root-expunged nil)
4111 (defvar gnus-tmp-dummy-line nil)
4113 (eval-when-compile (defvar gnus-tmp-header))
4114 (defun gnus-extra-header (type &optional header)
4115 "Return the extra header of TYPE."
4116 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4119 (defvar gnus-tmp-thread-tree-header-string "")
4121 (defvar gnus-sum-thread-tree-root "> ")
4122 (defvar gnus-sum-thread-tree-single-indent "")
4123 (defvar gnus-sum-thread-tree-vertical "| ")
4124 (defvar gnus-sum-thread-tree-indent " ")
4125 (defvar gnus-sum-thread-tree-leaf-with-other "+-> ")
4126 (defvar gnus-sum-thread-tree-single-leaf "\\-> ")
4128 (defun gnus-summary-prepare-threads (threads)
4129 "Prepare summary buffer from THREADS and indentation LEVEL.
4130 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4131 or a straight list of headers."
4132 (gnus-message 7 "Generating summary...")
4134 (setq gnus-newsgroup-threads threads)
4137 (let ((gnus-tmp-level 0)
4138 (default-score (or gnus-summary-default-score 0))
4139 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4140 thread number subject stack state gnus-tmp-gathered beg-match
4141 new-roots gnus-tmp-new-adopts thread-end
4142 gnus-tmp-header gnus-tmp-unread
4143 gnus-tmp-replied gnus-tmp-subject-or-nil
4144 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4145 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4146 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4149 (setq gnus-tmp-prev-subject nil)
4151 (if (vectorp (car threads))
4152 ;; If this is a straight (sic) list of headers, then a
4153 ;; threaded summary display isn't required, so we just create
4154 ;; an unthreaded one.
4155 (gnus-summary-prepare-unthreaded threads)
4157 ;; Do the threaded display.
4159 (while (or threads stack gnus-tmp-new-adopts new-roots)
4161 (if (and (= gnus-tmp-level 0)
4164 (not gnus-tmp-false-parent)
4165 (or gnus-tmp-new-adopts new-roots))
4166 (if gnus-tmp-new-adopts
4167 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4168 thread (list (car gnus-tmp-new-adopts))
4169 gnus-tmp-header (caar thread)
4170 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4172 (setq thread (list (car new-roots))
4173 gnus-tmp-header (caar thread)
4174 new-roots (cdr new-roots))))
4177 ;; If there are some threads, we do them before the
4178 ;; threads on the stack.
4179 (setq thread threads
4180 gnus-tmp-header (caar thread))
4181 ;; There were no current threads, so we pop something off
4183 (setq state (car stack)
4184 gnus-tmp-level (car state)
4185 tree-stack (cadr state)
4186 thread (caddr state)
4188 gnus-tmp-header (caar thread))))
4190 (setq gnus-tmp-false-parent nil)
4191 (setq gnus-tmp-root-expunged nil)
4192 (setq thread-end nil)
4194 (if (stringp gnus-tmp-header)
4195 ;; The header is a dummy root.
4197 ((eq gnus-summary-make-false-root 'adopt)
4198 ;; We let the first article adopt the rest.
4199 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4201 (setq gnus-tmp-gathered
4203 (lambda (h) (mail-header-number (car h)))
4206 (setq thread (cons (list (caar thread)
4209 (setq gnus-tmp-level -1
4210 gnus-tmp-false-parent t))
4211 ((eq gnus-summary-make-false-root 'empty)
4212 ;; We print adopted articles with empty subject fields.
4213 (setq gnus-tmp-gathered
4215 (lambda (h) (mail-header-number (car h)))
4218 (setq gnus-tmp-level -1))
4219 ((eq gnus-summary-make-false-root 'dummy)
4220 ;; We remember that we probably want to output a dummy
4222 (setq gnus-tmp-dummy-line gnus-tmp-header)
4223 (setq gnus-tmp-prev-subject gnus-tmp-header))
4225 ;; We do not make a root for the gathered
4226 ;; sub-threads at all.
4227 (setq gnus-tmp-level -1)))
4229 (setq number (mail-header-number gnus-tmp-header)
4230 subject (mail-header-subject gnus-tmp-header))
4233 ;; If the thread has changed subject, we might want to make
4234 ;; this subthread into a root.
4235 ((and (null gnus-thread-ignore-subject)
4236 (not (zerop gnus-tmp-level))
4237 gnus-tmp-prev-subject
4239 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4240 (setq new-roots (nconc new-roots (list (car thread)))
4242 gnus-tmp-header nil))
4243 ;; If the article lies outside the current limit,
4244 ;; then we do not display it.
4245 ((not (memq number gnus-newsgroup-limit))
4246 (setq gnus-tmp-gathered
4248 (lambda (h) (mail-header-number (car h)))
4251 (setq gnus-tmp-new-adopts (if (cdar thread)
4252 (append gnus-tmp-new-adopts
4254 gnus-tmp-new-adopts)
4256 gnus-tmp-header nil)
4257 (when (zerop gnus-tmp-level)
4258 (setq gnus-tmp-root-expunged t)))
4259 ;; Perhaps this article is to be marked as read?
4260 ((and gnus-summary-mark-below
4261 (< (or (cdr (assq number gnus-newsgroup-scored))
4263 gnus-summary-mark-below)
4264 ;; Don't touch sparse articles.
4265 (not (gnus-summary-article-sparse-p number))
4266 (not (gnus-summary-article-ancient-p number)))
4267 (setq gnus-newsgroup-unreads
4268 (delq number gnus-newsgroup-unreads))
4269 (if gnus-newsgroup-auto-expire
4270 (push number gnus-newsgroup-expirable)
4271 (push (cons number gnus-low-score-mark)
4272 gnus-newsgroup-reads))))
4274 (when gnus-tmp-header
4275 ;; We may have an old dummy line to output before this
4277 (when (and gnus-tmp-dummy-line
4280 (mail-header-subject gnus-tmp-header)))
4281 (gnus-summary-insert-dummy-line
4282 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4283 (setq gnus-tmp-dummy-line nil))
4285 ;; Compute the mark.
4286 (setq gnus-tmp-unread (gnus-article-mark number))
4288 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4289 gnus-tmp-header gnus-tmp-level)
4290 gnus-newsgroup-data)
4292 ;; Actually insert the line.
4294 gnus-tmp-subject-or-nil
4296 ((and gnus-thread-ignore-subject
4297 gnus-tmp-prev-subject
4298 (not (inline (gnus-subject-equal
4299 gnus-tmp-prev-subject subject))))
4301 ((zerop gnus-tmp-level)
4302 (if (and (eq gnus-summary-make-false-root 'empty)
4303 (memq number gnus-tmp-gathered)
4304 gnus-tmp-prev-subject
4305 (inline (gnus-subject-equal
4306 gnus-tmp-prev-subject subject)))
4307 gnus-summary-same-subject
4309 (t gnus-summary-same-subject)))
4310 (if (and (eq gnus-summary-make-false-root 'adopt)
4311 (= gnus-tmp-level 1)
4312 (memq number gnus-tmp-gathered))
4313 (setq gnus-tmp-opening-bracket ?\<
4314 gnus-tmp-closing-bracket ?\>)
4315 (setq gnus-tmp-opening-bracket ?\[
4316 gnus-tmp-closing-bracket ?\]))
4318 gnus-tmp-indentation
4319 (aref gnus-thread-indent-array gnus-tmp-level)
4320 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4321 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4322 gnus-summary-default-score 0)
4324 (if (or (null gnus-summary-default-score)
4325 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4326 gnus-summary-zcore-fuzz))
4328 (if (< gnus-tmp-score gnus-summary-default-score)
4329 gnus-score-below-mark gnus-score-over-mark))
4331 (cond ((memq number gnus-newsgroup-processable)
4333 ((memq number gnus-newsgroup-cached)
4335 ((memq number gnus-newsgroup-replied)
4337 ((memq number gnus-newsgroup-forwarded)
4338 gnus-forwarded-mark)
4339 ((memq number gnus-newsgroup-saved)
4342 gnus-tmp-from (mail-header-from gnus-tmp-header)
4345 ((string-match "<[^>]+> *$" gnus-tmp-from)
4346 (setq beg-match (match-beginning 0))
4347 (or (and (string-match "^\".+\"" gnus-tmp-from)
4348 (substring gnus-tmp-from 1 (1- (match-end 0))))
4349 (substring gnus-tmp-from 0 beg-match)))
4350 ((string-match "(.+)" gnus-tmp-from)
4351 (substring gnus-tmp-from
4352 (1+ (match-beginning 0)) (1- (match-end 0))))
4354 gnus-tmp-thread-tree-header-string
4355 (if (zerop gnus-tmp-level)
4357 gnus-sum-thread-tree-root
4358 gnus-sum-thread-tree-single-indent)
4359 (concat (apply 'concat
4360 (mapcar (lambda (item)
4362 gnus-sum-thread-tree-vertical
4363 gnus-sum-thread-tree-indent))
4364 (cdr (reverse tree-stack))))
4366 gnus-sum-thread-tree-leaf-with-other
4367 gnus-sum-thread-tree-single-leaf))))
4369 (when (string= gnus-tmp-name "")
4370 (setq gnus-tmp-name gnus-tmp-from))
4371 (unless (numberp gnus-tmp-lines)
4372 (setq gnus-tmp-lines -1))
4373 (when (= gnus-tmp-lines -1)
4374 (setq gnus-tmp-lines "?"))
4375 (gnus-put-text-property
4377 (progn (eval gnus-summary-line-format-spec) (point))
4378 'gnus-number number)
4381 (gnus-run-hooks 'gnus-summary-update-hook)
4384 (setq gnus-tmp-prev-subject subject)))
4386 (when (nth 1 thread)
4387 (push (list (max 0 gnus-tmp-level)
4388 (copy-list tree-stack)
4391 (push (if (nth 1 thread) 1 0) tree-stack)
4392 (incf gnus-tmp-level)
4393 (setq threads (if thread-end nil (cdar thread)))
4395 (setq gnus-tmp-level 0)))))
4396 (gnus-message 7 "Generating summary...done"))
4398 (defun gnus-summary-prepare-unthreaded (headers)
4399 "Generate an unthreaded summary buffer based on HEADERS."
4400 (let (header number mark)
4405 ;; We may have to root out some bad articles...
4406 (when (memq (setq number (mail-header-number
4407 (setq header (pop headers))))
4408 gnus-newsgroup-limit)
4409 ;; Mark article as read when it has a low score.
4410 (when (and gnus-summary-mark-below
4411 (< (or (cdr (assq number gnus-newsgroup-scored))
4412 gnus-summary-default-score 0)
4413 gnus-summary-mark-below)
4414 (not (gnus-summary-article-ancient-p number)))
4415 (setq gnus-newsgroup-unreads
4416 (delq number gnus-newsgroup-unreads))
4417 (if gnus-newsgroup-auto-expire
4418 (push number gnus-newsgroup-expirable)
4419 (push (cons number gnus-low-score-mark)
4420 gnus-newsgroup-reads)))
4422 (setq mark (gnus-article-mark number))
4423 (push (gnus-data-make number mark (1+ (point)) header 0)
4424 gnus-newsgroup-data)
4425 (gnus-summary-insert-line
4427 mark (memq number gnus-newsgroup-replied)
4428 (memq number gnus-newsgroup-expirable)
4429 (mail-header-subject header) nil
4430 (cdr (assq number gnus-newsgroup-scored))
4431 (memq number gnus-newsgroup-processable))))))
4433 (defun gnus-summary-remove-list-identifiers ()
4434 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4435 (let ((regexp (if (consp gnus-list-identifiers)
4436 (mapconcat 'identity gnus-list-identifiers " *\\|")
4437 gnus-list-identifiers))
4440 (dolist (header gnus-newsgroup-headers)
4441 (setq subject (mail-header-subject header)
4443 (while (string-match
4444 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4447 (concat (substring subject 0 (match-beginning 2))
4448 (substring subject (match-end 0)))
4452 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4454 (concat (substring subject 0 (match-beginning 1))
4455 (substring subject (match-end 1)))))
4457 (mail-header-set-subject header subject))))))
4459 (defun gnus-fetch-headers (articles)
4460 "Fetch headers of ARTICLES."
4461 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4462 (gnus-message 5 "Fetching headers for %s..." name)
4464 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
4465 (if (eq 'nnimap (car (gnus-find-method-for-group name)))
4467 (setq gnus-headers-retrieved-by
4468 (gnus-retrieve-headers
4469 articles gnus-newsgroup-name
4470 ;; We might want to fetch old headers, but
4471 ;; not if there is only 1 article.
4473 (not (eq gnus-fetch-old-headers 'some))
4474 (not (numberp gnus-fetch-old-headers)))
4475 (> (length articles) 1))
4476 gnus-fetch-old-headers))))
4477 (gnus-get-newsgroup-headers-xover
4478 articles nil nil gnus-newsgroup-name t)
4479 (gnus-get-newsgroup-headers))
4480 (gnus-retrieve-parsed-headers
4481 articles gnus-newsgroup-name
4482 ;; We might want to fetch old headers, but
4483 ;; not if there is only 1 article.
4484 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4485 (not (numberp gnus-fetch-old-headers)))
4486 (> (length articles) 1))
4487 gnus-fetch-old-headers)))
4488 (gnus-message 5 "Fetching headers for %s...done" name))))
4490 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4491 "Select newsgroup GROUP.
4492 If READ-ALL is non-nil, all articles in the group are selected.
4493 If SELECT-ARTICLES, only select those articles from GROUP."
4494 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4495 ;;!!! Dirty hack; should be removed.
4496 (gnus-summary-ignore-duplicates
4497 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4499 gnus-summary-ignore-duplicates))
4500 (info (nth 2 entry))
4501 articles fetched-articles cached)
4503 (unless (gnus-check-server
4504 (setq gnus-current-select-method
4505 (gnus-find-method-for-group group)))
4506 (error "Couldn't open server"))
4508 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4509 (gnus-activate-group group) ; Or we can activate it...
4510 (progn ; Or we bug out.
4511 (when (equal major-mode 'gnus-summary-mode)
4512 (kill-buffer (current-buffer)))
4513 (error "Couldn't activate group %s: %s"
4514 group (gnus-status-message group))))
4516 (unless (gnus-request-group group t)
4517 (when (equal major-mode 'gnus-summary-mode)
4518 (kill-buffer (current-buffer)))
4519 (error "Couldn't request group %s: %s"
4520 group (gnus-status-message group)))
4522 (setq gnus-newsgroup-name group)
4523 (setq gnus-newsgroup-unselected nil)
4524 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4525 (gnus-summary-setup-default-charset)
4527 ;; Adjust and set lists of article marks.
4529 (gnus-adjust-marked-articles info))
4531 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4533 (if (gnus-virtual-group-p group)
4534 gnus-newsgroup-cached
4535 (gnus-cache-articles-in-group group)))
4537 (setq gnus-newsgroup-unreads
4538 (gnus-set-difference
4539 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4540 gnus-newsgroup-dormant))
4542 (setq gnus-newsgroup-processable nil)
4544 (gnus-update-read-articles group gnus-newsgroup-unreads)
4546 (if (setq articles select-articles)
4547 (setq gnus-newsgroup-unselected
4548 (gnus-sorted-intersection
4549 gnus-newsgroup-unreads
4550 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4551 (setq articles (gnus-articles-to-read group read-all)))
4555 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4557 ((eq articles 0) nil)
4559 ;; Init the dependencies hash table.
4560 (setq gnus-newsgroup-dependencies
4561 (gnus-make-hashtable (length articles)))
4562 (gnus-set-global-variables)
4563 ;; Retrieve the headers and read them in.
4564 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4566 ;; Suppress duplicates?
4567 (when gnus-suppress-duplicates
4568 (gnus-dup-suppress-articles))
4570 ;; Set the initial limit.
4571 (setq gnus-newsgroup-limit (copy-sequence articles))
4572 ;; Remove canceled articles from the list of unread articles.
4573 (setq gnus-newsgroup-unreads
4574 (gnus-set-sorted-intersection
4575 gnus-newsgroup-unreads
4576 (setq fetched-articles
4577 (mapcar (lambda (headers) (mail-header-number headers))
4578 gnus-newsgroup-headers))))
4579 ;; Removed marked articles that do not exist.
4580 (gnus-update-missing-marks
4581 (gnus-sorted-complement fetched-articles articles))
4583 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4585 (setq gnus-newsgroup-cached cached))
4587 ;; We might want to build some more threads first.
4588 (when (and gnus-fetch-old-headers
4589 (eq gnus-headers-retrieved-by 'nov))
4590 (if (eq gnus-fetch-old-headers 'invisible)
4591 (gnus-build-all-threads)
4592 (gnus-build-old-threads)))
4593 ;; Let the Gnus agent mark articles as read.
4595 (gnus-agent-get-undownloaded-list))
4596 ;; Remove list identifiers from subject
4597 (when gnus-list-identifiers
4598 (gnus-summary-remove-list-identifiers))
4599 ;; Check whether auto-expire is to be done in this group.
4600 (setq gnus-newsgroup-auto-expire
4601 (gnus-group-auto-expirable-p group))
4602 ;; Set up the article buffer now, if necessary.
4603 (unless gnus-single-article-buffer
4604 (gnus-article-setup-buffer))
4605 ;; First and last article in this newsgroup.
4606 (when gnus-newsgroup-headers
4607 (setq gnus-newsgroup-begin
4608 (mail-header-number (car gnus-newsgroup-headers))
4611 (gnus-last-element gnus-newsgroup-headers))))
4612 ;; GROUP is successfully selected.
4613 (or gnus-newsgroup-headers t)))))
4615 (defun gnus-articles-to-read (group &optional read-all)
4616 "Find out what articles the user wants to read."
4618 ;; Select all articles if `read-all' is non-nil, or if there
4619 ;; are no unread articles.
4621 (and (zerop (length gnus-newsgroup-marked))
4622 (zerop (length gnus-newsgroup-unreads)))
4623 (eq (gnus-group-find-parameter group 'display)
4626 (gnus-uncompress-range (gnus-active group))
4627 (gnus-cache-articles-in-group group))
4628 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4629 (copy-sequence gnus-newsgroup-unreads))
4631 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4632 (scored (length scored-list))
4633 (number (length articles))
4634 (marked (+ (length gnus-newsgroup-marked)
4635 (length gnus-newsgroup-dormant)))
4643 ((and (or (<= scored marked) (= scored number))
4644 (natnump gnus-large-newsgroup)
4645 (> number gnus-large-newsgroup))
4646 (let* ((cursor-in-echo-area nil)
4648 (read-from-minibuffer
4650 "How many articles from %s (max %d): "
4652 (gnus-group-decoded-name gnus-newsgroup-name)
4655 (cons (number-to-string gnus-large-newsgroup)
4657 (if (string-match "^[ \t]*$" input)
4660 ((and (> scored marked) (< scored number)
4661 (> (- scored number) 20))
4664 (format "%s %s (%d scored, %d total): "
4665 "How many articles from"
4666 (gnus-group-decoded-name group)
4668 (if (string-match "^[ \t]*$" input)
4672 (message "Quit getting the articles to read")
4674 (setq select (if (stringp select) (string-to-number select) select))
4675 (if (or (null select) (zerop select))
4677 (if (and (not (zerop scored)) (<= (abs select) scored))
4679 (setq articles (sort scored-list '<))
4680 (setq number (length articles)))
4681 (setq articles (copy-sequence articles)))
4683 (when (< (abs select) number)
4685 ;; Select the N oldest articles.
4686 (setcdr (nthcdr (1- (abs select)) articles) nil)
4687 ;; Select the N most recent articles.
4688 (setq articles (nthcdr (- number select) articles))))
4689 (setq gnus-newsgroup-unselected
4690 (gnus-sorted-intersection
4691 gnus-newsgroup-unreads
4692 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4693 (when gnus-alter-articles-to-read-function
4694 (setq gnus-newsgroup-unreads
4696 (funcall gnus-alter-articles-to-read-function
4697 gnus-newsgroup-name gnus-newsgroup-unreads)
4701 (defun gnus-killed-articles (killed articles)
4704 (when (inline (gnus-member-of-range (car articles) killed))
4705 (push (car articles) out))
4706 (setq articles (cdr articles)))
4709 (defun gnus-uncompress-marks (marks)
4710 "Uncompress the mark ranges in MARKS."
4711 (let ((uncompressed '(score bookmark))
4714 (if (memq (caar marks) uncompressed)
4715 (push (car marks) out)
4716 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4717 (setq marks (cdr marks)))
4720 (defun gnus-adjust-marked-articles (info)
4721 "Set all article lists and remove all marks that are no longer valid."
4722 (let* ((marked-lists (gnus-info-marks info))
4723 (active (gnus-active (gnus-info-group info)))
4726 (types gnus-article-mark-lists)
4727 (uncompressed '(score bookmark killed))
4728 marks var articles article mark)
4731 (setq marks (pop marked-lists))
4732 (set (setq var (intern (format "gnus-newsgroup-%s"
4733 (car (rassq (setq mark (car marks))
4735 (if (memq (car marks) uncompressed) (cdr marks)
4736 (gnus-uncompress-range (cdr marks))))
4738 (setq articles (symbol-value var))
4740 ;; All articles have to be subsets of the active articles.
4742 ;; Adjust "simple" lists.
4743 ((memq mark '(tick dormant expire reply save))
4745 (when (or (< (setq article (pop articles)) min) (> article max))
4746 (set var (delq article (symbol-value var))))))
4748 ((memq mark uncompressed)
4749 (when (not (listp (cdr (symbol-value var))))
4750 (set var (list (symbol-value var))))
4751 (when (not (listp (cdr articles)))
4752 (setq articles (list articles)))
4754 (when (or (not (consp (setq article (pop articles))))
4755 (< (car article) min)
4756 (> (car article) max))
4757 (set var (delq article (symbol-value var))))))))))
4759 (defun gnus-update-missing-marks (missing)
4760 "Go through the list of MISSING articles and remove them from the mark lists."
4762 (let ((types gnus-article-mark-lists)
4764 ;; Go through all types.
4766 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4767 (when (symbol-value var)
4768 ;; This list has articles. So we delete all missing articles
4772 (set var (delq (pop m) (symbol-value var)))))))))
4774 (defun gnus-update-marks ()
4775 "Enter the various lists of marked articles into the newsgroup info list."
4776 (let ((types gnus-article-mark-lists)
4777 (info (gnus-get-info gnus-newsgroup-name))
4778 (uncompressed '(score bookmark killed))
4779 type list newmarked symbol delta-marks)
4781 ;; Add all marks lists to the list of marks lists.
4782 (while (setq type (pop types))
4783 (setq list (symbol-value
4785 (intern (format "gnus-newsgroup-%s"
4789 ;; Get rid of the entries of the articles that have the
4791 (when (and (eq (cdr type) 'score)
4795 (prev (cons nil list))
4798 (if (or (not (consp (car arts)))
4799 (= (cdar arts) gnus-summary-default-score))
4800 (setcdr prev (cdr arts))
4802 (setq arts (cdr arts)))
4803 (setq list (cdr all)))))
4805 (unless (memq (cdr type) uncompressed)
4806 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4808 (when (gnus-check-backend-function
4809 'request-set-mark gnus-newsgroup-name)
4810 ;; propagate flags to server, with the following exceptions:
4811 ;; uncompressed:s are not proper flags (they are cons cells)
4812 ;; cache is a internal gnus flag
4813 ;; download are local to one gnus installation (well)
4814 ;; unsend are for nndraft groups only
4815 ;; xxx: generality of this? this suits nnimap anyway
4816 (unless (memq (cdr type) (append '(cache download unsend)
4818 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4819 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4820 (add (gnus-remove-from-range
4821 (gnus-copy-sequence list) old)))
4823 (push (list add 'add (list (cdr type))) delta-marks))
4825 (push (list del 'del (list (cdr type))) delta-marks)))))
4828 (push (cons (cdr type) list) newmarked)))
4831 (unless (gnus-check-group gnus-newsgroup-name)
4832 (error "Can't open server for %s" gnus-newsgroup-name))
4833 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4835 ;; Enter these new marks into the info of the group.
4837 (setcar (nthcdr 3 info) newmarked)
4838 ;; Add the marks lists to the end of the info.
4840 (setcdr (nthcdr 2 info) (list newmarked))))
4842 ;; Cut off the end of the info if there's nothing else there.
4846 (when (nthcdr (decf i) info)
4847 (setcdr (nthcdr i info) nil)))))))
4849 (defun gnus-set-mode-line (where)
4850 "Set the mode line of the article or summary buffers.
4851 If WHERE is `summary', the summary mode line format will be used."
4852 ;; Is this mode line one we keep updated?
4853 (when (and (memq where gnus-updated-mode-lines)
4855 (intern (format "gnus-%s-mode-line-format-spec" where))))
4858 ;; We evaluate this in the summary buffer since these
4859 ;; variables are buffer-local to that buffer.
4860 (set-buffer gnus-summary-buffer)
4861 ;; We bind all these variables that are used in the `eval' form
4863 (let* ((mformat (symbol-value
4865 (format "gnus-%s-mode-line-format-spec" where))))
4866 (gnus-tmp-group-name (gnus-group-decoded-name
4867 gnus-newsgroup-name))
4868 (gnus-tmp-article-number (or gnus-current-article 0))
4869 (gnus-tmp-unread gnus-newsgroup-unreads)
4870 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4871 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4872 (gnus-tmp-unread-and-unselected
4873 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4874 (zerop gnus-tmp-unselected))
4876 ((zerop gnus-tmp-unselected)
4877 (format "{%d more}" gnus-tmp-unread-and-unticked))
4878 (t (format "{%d(+%d) more}"
4879 gnus-tmp-unread-and-unticked
4880 gnus-tmp-unselected))))
4882 (if (and gnus-current-headers
4883 (vectorp gnus-current-headers))
4884 (gnus-mode-string-quote
4885 (mail-header-subject gnus-current-headers))
4887 bufname-length max-len
4888 gnus-tmp-header);; passed as argument to any user-format-funcs
4889 (setq mode-string (eval mformat))
4890 (setq bufname-length (if (string-match "%b" mode-string)
4893 (if (eq where 'summary)
4895 (get-buffer gnus-article-buffer))))
4898 (setq max-len (max 4 (if gnus-mode-non-string-length
4900 gnus-mode-non-string-length
4902 (length mode-string))))
4903 ;; We might have to chop a bit of the string off...
4904 (when (> (length mode-string) max-len)
4906 (concat (gnus-truncate-string mode-string (- max-len 3))
4908 ;; Pad the mode string a bit.
4909 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4910 ;; Update the mode line.
4911 (setq mode-line-buffer-identification
4912 (gnus-mode-line-buffer-identification (list mode-string)))
4913 (set-buffer-modified-p t))))
4915 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4916 "Go through the HEADERS list and add all Xrefs to a hash table.
4917 The resulting hash table is returned, or nil if no Xrefs were found."
4918 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4919 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4920 (xref-hashtb (gnus-make-hashtable))
4921 start group entry number xrefs header)
4923 (setq header (pop headers))
4924 (when (and (setq xrefs (mail-header-xref header))
4925 (not (memq (setq number (mail-header-number header))
4928 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4929 (setq start (match-end 0))
4930 (setq group (if prefix
4931 (concat prefix (substring xrefs (match-beginning 1)
4933 (substring xrefs (match-beginning 1) (match-end 1))))
4935 (string-to-int (substring xrefs (match-beginning 2)
4937 (if (setq entry (gnus-gethash group xref-hashtb))
4938 (setcdr entry (cons number (cdr entry)))
4939 (gnus-sethash group (cons number nil) xref-hashtb)))))
4940 (and start xref-hashtb)))
4942 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4943 "Look through all the headers and mark the Xrefs as read."
4944 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4945 name entry info xref-hashtb idlist method nth4)
4947 (set-buffer gnus-group-buffer)
4948 (when (setq xref-hashtb
4949 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4952 (unless (string= from-newsgroup (setq name (symbol-name group)))
4953 (setq idlist (symbol-value group))
4954 ;; Dead groups are not updated.
4956 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4958 (when (stringp (setq nth4 (gnus-info-method info)))
4959 (setq nth4 (gnus-server-to-method nth4))))
4960 ;; Only do the xrefs if the group has the same
4961 ;; select method as the group we have just read.
4962 (or (gnus-methods-equal-p
4963 nth4 (gnus-find-method-for-group from-newsgroup))
4965 (equal nth4 (setq method (gnus-find-method-for-group
4967 (and (equal (car nth4) (car method))
4968 (equal (nth 1 nth4) (nth 1 method))))
4969 gnus-use-cross-reference
4970 (or (not (eq gnus-use-cross-reference t))
4972 ;; Only do cross-references on subscribed
4973 ;; groups, if that is what is wanted.
4974 (<= (gnus-info-level info) gnus-level-subscribed))
4975 (gnus-group-make-articles-read name idlist))))
4978 (defun gnus-compute-read-articles (group articles)
4979 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4980 (info (nth 2 entry))
4981 (active (gnus-active group))
4984 ;; First peel off all invalid article numbers.
4986 (let ((ids articles)
4988 (while (setq id (pop ids))
4989 (when (and first (> id (cdr active)))
4990 ;; We'll end up in this situation in one particular
4991 ;; obscure situation. If you re-scan a group and get
4992 ;; a new article that is cross-posted to a different
4993 ;; group that has not been re-scanned, you might get
4994 ;; crossposted article that has a higher number than
4995 ;; Gnus believes possible. So we re-activate this
4996 ;; group as well. This might mean doing the
4997 ;; crossposting thingy will *increase* the number
4998 ;; of articles in some groups. Tsk, tsk.
4999 (setq active (or (gnus-activate-group group) active)))
5000 (when (or (> id (cdr active))
5001 (< id (car active)))
5002 (setq articles (delq id articles))))))
5003 ;; If the read list is nil, we init it.
5005 (null (gnus-info-read info))
5007 (setq ninfo (cons 1 (1- (car active))))
5008 (setq ninfo (gnus-info-read info)))
5009 ;; Then we add the read articles to the range.
5011 ninfo (setq articles (sort articles '<))))))
5013 (defun gnus-group-make-articles-read (group articles)
5014 "Update the info of GROUP to say that ARTICLES are read."
5016 (entry (gnus-gethash group gnus-newsrc-hashtb))
5017 (info (nth 2 entry))
5018 (active (gnus-active group))
5021 (setq range (gnus-compute-read-articles group articles))
5023 (set-buffer gnus-group-buffer)
5026 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5027 (gnus-info-set-read ',info ',(gnus-info-read info))
5028 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5029 (gnus-group-update-group ,group t))))
5030 ;; Add the read articles to the range.
5031 (gnus-info-set-read info range)
5032 ;; Then we have to re-compute how many unread
5033 ;; articles there are in this group.
5037 (setq num (- (1+ (cdr active)) (car active))))
5038 ((not (listp (cdr range)))
5039 (setq num (- (cdr active) (- (1+ (cdr range))
5043 (if (numberp (car range))
5045 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5046 (setq range (cdr range)))
5047 (setq num (- (cdr active) num))))
5048 ;; Update the number of unread articles.
5050 ;; Update the group buffer.
5051 (gnus-group-update-group group t)))))
5053 (defvar gnus-newsgroup-none-id 0)
5055 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5056 (let ((cur nntp-server-buffer)
5059 (save-excursion (set-buffer gnus-summary-buffer)
5060 gnus-newsgroup-dependencies)))
5062 (mail-parse-charset gnus-newsgroup-charset)
5063 (mail-parse-ignored-charsets
5064 (save-excursion (condition-case nil
5065 (set-buffer gnus-summary-buffer)
5067 gnus-newsgroup-ignored-charsets)))
5069 (set-buffer nntp-server-buffer)
5070 ;; Translate all TAB characters into SPACE characters.
5071 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5072 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5073 (gnus-run-hooks 'gnus-parse-headers-hook)
5074 (let ((case-fold-search t)
5075 in-reply-to header p lines chars ctype)
5076 (goto-char (point-min))
5077 ;; Search to the beginning of the next header. Error messages
5078 ;; do not begin with 2 or 3.
5079 (while (re-search-forward "^[23][0-9]+ " nil t)
5082 ;; This implementation of this function, with nine
5083 ;; search-forwards instead of the one re-search-forward and
5084 ;; a case (which basically was the old function) is actually
5085 ;; about twice as fast, even though it looks messier. You
5086 ;; can't have everything, I guess. Speed and elegance
5087 ;; doesn't always go hand in hand.
5090 (make-full-mail-header
5096 (narrow-to-region (point)
5097 (or (and (search-forward "\n.\n" nil t)
5103 (if (search-forward "\nsubject:" nil t)
5104 (nnheader-header-value)
5109 (if (search-forward "\nfrom:" nil t)
5110 (nnheader-header-value)
5115 (if (search-forward "\ndate:" nil t)
5116 (nnheader-header-value) ""))
5120 (setq id (if (re-search-forward
5121 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5122 ;; We do it this way to make sure the Message-ID
5123 ;; is (somewhat) syntactically valid.
5124 (buffer-substring (match-beginning 1)
5126 ;; If there was no message-id, we just fake one
5127 ;; to make subsequent routines simpler.
5128 (nnheader-generate-fake-message-id))))
5132 (if (search-forward "\nreferences:" nil t)
5136 (nnheader-header-value)
5141 (search-backward ">" end t)
5144 (search-backward "<" end t)
5146 ;; Get the references from the in-reply-to header if there
5147 ;; were no references and the in-reply-to header looks
5149 (if (and (search-forward "\nin-reply-to:" nil t)
5150 (setq in-reply-to (nnheader-header-value))
5151 (string-match "<[^>]+>" in-reply-to))
5153 (setq ref (substring in-reply-to (match-beginning 0)
5155 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5156 (setq ref2 (substring in-reply-to (match-beginning 0)
5158 (when (> (length ref2) (length ref))
5165 (if (search-forward "\nchars: " nil t)
5166 (if (numberp (setq chars (ignore-errors (read cur))))
5172 (if (search-forward "\nlines: " nil t)
5173 (if (numberp (setq lines (ignore-errors (read cur))))
5179 (and (search-forward "\nxref:" nil t)
5180 (nnheader-header-value)))
5182 (when gnus-extra-headers
5183 (let ((extra gnus-extra-headers)
5187 (when (search-forward
5188 (concat "\n" (symbol-name (car extra)) ":") nil t)
5189 (push (cons (car extra) (nnheader-header-value)) out))
5193 (if (and (search-forward "\ncontent-type: " nil t)
5194 (setq ctype (nnheader-header-value)))
5195 (mime-entity-set-content-type-internal
5196 header (mime-parse-Content-Type ctype)))
5197 (when (equal id ref)
5200 (when gnus-alter-header-function
5201 (funcall gnus-alter-header-function header)
5202 (setq id (mail-header-id header)
5203 ref (gnus-parent-id (mail-header-references header))))
5206 (gnus-dependencies-add-header
5207 header dependencies force-new))
5208 (push header headers))
5209 (goto-char (point-max))
5211 (nreverse headers)))))
5213 ;; Goes through the xover lines and returns a list of vectors
5214 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5215 force-new dependencies
5216 group also-fetch-heads)
5217 "Parse the news overview data in the server buffer.
5218 Return a list of headers that match SEQUENCE (see
5219 `nntp-retrieve-headers')."
5220 ;; Get the Xref when the users reads the articles since most/some
5221 ;; NNTP servers do not include Xrefs when using XOVER.
5222 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5223 (let ((mail-parse-charset gnus-newsgroup-charset)
5224 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5225 (cur nntp-server-buffer)
5226 (dependencies (or dependencies gnus-newsgroup-dependencies))
5228 ((eq gnus-read-all-available-headers t)
5230 ((stringp gnus-read-all-available-headers)
5231 (string-match gnus-read-all-available-headers group))
5234 number headers header)
5236 (set-buffer nntp-server-buffer)
5237 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5238 ;; Allow the user to mangle the headers before parsing them.
5239 (gnus-run-hooks 'gnus-parse-headers-hook)
5240 (goto-char (point-min))
5243 (while (and (or sequence allp)
5245 (setq number (read cur))
5247 (while (and sequence
5248 (< (car sequence) number))
5249 (setq sequence (cdr sequence))))
5252 (eq number (car sequence))))
5254 (setq sequence (cdr sequence))
5255 (setq header (inline
5256 (gnus-nov-parse-line
5257 number dependencies force-new)))))
5258 (push header headers))
5261 (gnus-error 4 "Strange nov line (%d)"
5262 (count-lines (point-min) (point)))))
5264 ;; A common bug in inn is that if you have posted an article and
5265 ;; then retrieves the active file, it will answer correctly --
5266 ;; the new article is included. However, a NOV entry for the
5267 ;; article may not have been generated yet, so this may fail.
5268 ;; We work around this problem by retrieving the last few
5269 ;; headers using HEAD.
5270 (if (or (not also-fetch-heads)
5272 ;; We (probably) got all the headers.
5274 (let ((gnus-nov-is-evil t))
5277 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
5278 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
5279 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5280 (gnus-get-newsgroup-headers))
5281 (gnus-retrieve-parsed-headers sequence group))))))))
5283 (defun gnus-article-get-xrefs ()
5284 "Fill in the Xref value in `gnus-current-headers', if necessary.
5285 This is meant to be called in `gnus-article-internal-prepare-hook'."
5286 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5287 gnus-current-headers)))
5288 (or (not gnus-use-cross-reference)
5290 (and (mail-header-xref headers)
5291 (not (string= (mail-header-xref headers) "")))
5292 (let ((case-fold-search t)
5295 (nnheader-narrow-to-headers)
5296 (goto-char (point-min))
5297 (when (or (and (not (eobp))
5298 (eq (downcase (char-after)) ?x)
5299 (looking-at "Xref:"))
5300 (search-forward "\nXref:" nil t))
5301 (goto-char (1+ (match-end 0)))
5302 (setq xref (buffer-substring (point)
5303 (progn (end-of-line) (point))))
5304 (mail-header-set-xref headers xref)))))))
5306 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5307 "Find article ID and insert the summary line for that article.
5308 OLD-HEADER can either be a header or a line number to insert
5309 the subject line on."
5310 (let* ((line (and (numberp old-header) old-header))
5311 (old-header (and (vectorp old-header) old-header))
5312 (header (cond ((and old-header use-old-header)
5315 (gnus-number-to-header id))
5316 (gnus-number-to-header id))
5318 (gnus-read-header id))))
5319 (number (and (numberp id) id))
5322 ;; Rebuild the thread that this article is part of and go to the
5323 ;; article we have fetched.
5324 (when (and (not gnus-show-threads)
5327 (setq d (gnus-data-find (mail-header-number old-header))))
5328 (goto-char (gnus-data-pos d))
5331 (- (gnus-point-at-bol)
5333 (1+ (gnus-point-at-eol))
5334 (gnus-delete-line))))))
5336 (mail-header-set-number header (mail-header-number old-header)))
5337 (setq gnus-newsgroup-sparse
5338 (delq (setq number (mail-header-number header))
5339 gnus-newsgroup-sparse))
5340 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5341 (push number gnus-newsgroup-limit)
5342 (gnus-rebuild-thread (mail-header-id header) line)
5343 (gnus-summary-goto-subject number nil t))
5344 (when (and (numberp number)
5346 ;; We have to update the boundaries even if we can't fetch the
5347 ;; article if ID is a number -- so that the next `P' or `N'
5348 ;; command will fetch the previous (or next) article even
5349 ;; if the one we tried to fetch this time has been canceled.
5350 (when (> number gnus-newsgroup-end)
5351 (setq gnus-newsgroup-end number))
5352 (when (< number gnus-newsgroup-begin)
5353 (setq gnus-newsgroup-begin number))
5354 (setq gnus-newsgroup-unselected
5355 (delq number gnus-newsgroup-unselected)))
5356 ;; Report back a success?
5357 (and header (mail-header-number header))))
5359 ;;; Process/prefix in the summary buffer
5361 (defun gnus-summary-work-articles (n)
5362 "Return a list of articles to be worked upon.
5363 The prefix argument, the list of process marked articles, and the
5364 current article will be taken into consideration."
5366 (set-buffer gnus-summary-buffer)
5369 ;; A numerical prefix has been given.
5370 (setq n (prefix-numeric-value n))
5371 (let ((backward (< n 0))
5372 (n (abs (prefix-numeric-value n)))
5377 (push (setq article (gnus-summary-article-number))
5380 (gnus-summary-find-prev nil article)
5381 (gnus-summary-find-next nil article)))
5383 (nreverse articles)))
5384 ((and (gnus-region-active-p) (mark))
5385 (message "region active")
5386 ;; Work on the region between point and mark.
5387 (let ((max (max (point) (mark)))
5390 (goto-char (min (point) (mark)))
5393 (push (setq article (gnus-summary-article-number)) articles)
5394 (gnus-summary-find-next nil article)
5396 (nreverse articles))))
5397 (gnus-newsgroup-processable
5398 ;; There are process-marked articles present.
5399 ;; Save current state.
5400 (gnus-summary-save-process-mark)
5402 (reverse gnus-newsgroup-processable))
5404 ;; Just return the current article.
5405 (list (gnus-summary-article-number))))))
5407 (defmacro gnus-summary-iterate (arg &rest forms)
5408 "Iterate over the process/prefixed articles and do FORMS.
5409 ARG is the interactive prefix given to the command. FORMS will be
5410 executed with point over the summary line of the articles."
5411 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5412 `(let ((,articles (gnus-summary-work-articles ,arg)))
5414 (gnus-summary-goto-subject (car ,articles))
5418 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5419 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5421 (defun gnus-summary-save-process-mark ()
5422 "Push the current set of process marked articles on the stack."
5424 (push (copy-sequence gnus-newsgroup-processable)
5425 gnus-newsgroup-process-stack))
5427 (defun gnus-summary-kill-process-mark ()
5428 "Push the current set of process marked articles on the stack and unmark."
5430 (gnus-summary-save-process-mark)
5431 (gnus-summary-unmark-all-processable))
5433 (defun gnus-summary-yank-process-mark ()
5434 "Pop the last process mark state off the stack and restore it."
5436 (unless gnus-newsgroup-process-stack
5437 (error "Empty mark stack"))
5438 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5440 (defun gnus-summary-process-mark-set (set)
5441 "Make SET into the current process marked articles."
5442 (gnus-summary-unmark-all-processable)
5444 (gnus-summary-set-process-mark (pop set))))
5446 ;;; Searching and stuff
5448 (defun gnus-summary-search-group (&optional backward use-level)
5449 "Search for next unread newsgroup.
5450 If optional argument BACKWARD is non-nil, search backward instead."
5452 (set-buffer gnus-group-buffer)
5453 (when (gnus-group-search-forward
5454 backward nil (if use-level (gnus-group-group-level) nil))
5455 (gnus-group-group-name))))
5457 (defun gnus-summary-best-group (&optional exclude-group)
5458 "Find the name of the best unread group.
5459 If EXCLUDE-GROUP, do not go to this group."
5461 (set-buffer gnus-group-buffer)
5463 (gnus-group-best-unread-group exclude-group))))
5465 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5466 (if backward (gnus-summary-find-prev)
5467 (let* ((dummy (gnus-summary-article-intangible-p))
5468 (article (or article (gnus-summary-article-number)))
5469 (arts (gnus-data-find-list article))
5471 (when (and (not dummy)
5472 (or (not gnus-summary-check-current)
5474 (not (gnus-data-unread-p (car arts)))))
5475 (setq arts (cdr arts)))
5480 (when (or (and undownloaded
5481 (eq gnus-undownloaded-mark
5482 (gnus-data-mark (car arts))))
5483 (gnus-data-unread-p (car arts)))
5484 (setq result (car arts)
5486 (setq arts (cdr arts)))
5489 (goto-char (gnus-data-pos result))
5490 (gnus-data-number result)))))
5492 (defun gnus-summary-find-prev (&optional unread article)
5493 (let* ((eobp (eobp))
5494 (article (or article (gnus-summary-article-number)))
5495 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5497 (when (and (not eobp)
5498 (or (not gnus-summary-check-current)
5500 (not (gnus-data-unread-p (car arts)))))
5501 (setq arts (cdr arts)))
5506 (when (gnus-data-unread-p (car arts))
5507 (setq result (car arts)
5509 (setq arts (cdr arts)))
5512 (goto-char (gnus-data-pos result))
5513 (gnus-data-number result))))
5515 (defun gnus-summary-find-subject (subject &optional unread backward article)
5516 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5517 (article (or article (gnus-summary-article-number)))
5518 (articles (gnus-data-list backward))
5519 (arts (gnus-data-find-list article articles))
5521 (when (or (not gnus-summary-check-current)
5523 (not (gnus-data-unread-p (car arts))))
5524 (setq arts (cdr arts)))
5526 (and (or (not unread)
5527 (gnus-data-unread-p (car arts)))
5528 (vectorp (gnus-data-header (car arts)))
5530 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5531 (setq result (car arts)
5533 (setq arts (cdr arts)))
5535 (goto-char (gnus-data-pos result))
5536 (gnus-data-number result))))
5538 (defun gnus-summary-search-forward (&optional unread subject backward)
5539 "Search forward for an article.
5540 If UNREAD, look for unread articles. If SUBJECT, look for
5541 articles with that subject. If BACKWARD, search backward instead."
5542 (cond (subject (gnus-summary-find-subject subject unread backward))
5543 (backward (gnus-summary-find-prev unread))
5544 (t (gnus-summary-find-next unread))))
5546 (defun gnus-recenter (&optional n)
5547 "Center point in window and redisplay frame.
5548 Also do horizontal recentering."
5550 (when (and gnus-auto-center-summary
5551 (not (eq gnus-auto-center-summary 'vertical)))
5552 (gnus-horizontal-recenter))
5555 (defun gnus-summary-recenter ()
5556 "Center point in the summary window.
5557 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5558 displayed, no centering will be performed."
5559 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5560 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5562 (let* ((top (cond ((< (window-height) 4) 0)
5563 ((< (window-height) 7) 1)
5564 (t (if (numberp gnus-auto-center-summary)
5565 gnus-auto-center-summary
5567 (height (1- (window-height)))
5568 (bottom (save-excursion (goto-char (point-max))
5569 (forward-line (- height))
5571 (window (get-buffer-window (current-buffer))))
5572 ;; The user has to want it.
5573 (when gnus-auto-center-summary
5574 (when (get-buffer-window gnus-article-buffer)
5575 ;; Only do recentering when the article buffer is displayed,
5576 ;; Set the window start to either `bottom', which is the biggest
5577 ;; possible valid number, or the second line from the top,
5578 ;; whichever is the least.
5579 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5580 (if (> bottom top-pos)
5581 ;; Keep the second line from the top visible
5582 (set-window-start window top-pos t)
5583 ;; Try to keep the bottom line visible; if it's partially
5584 ;; obscured, either scroll one more line to make it fully
5585 ;; visible, or revert to using TOP-POS.
5587 (goto-char (point-max))
5589 (let ((last-line-start (point)))
5591 (set-window-start window (point) t)
5592 (when (not (pos-visible-in-window-p last-line-start window))
5594 (set-window-start window (min (point) top-pos) t)))))))
5595 ;; Do horizontal recentering while we're at it.
5596 (when (and (get-buffer-window (current-buffer) t)
5597 (not (eq gnus-auto-center-summary 'vertical)))
5598 (let ((selected (selected-window)))
5599 (select-window (get-buffer-window (current-buffer) t))
5600 (gnus-summary-position-point)
5601 (gnus-horizontal-recenter)
5602 (select-window selected))))))
5604 (defun gnus-summary-jump-to-group (newsgroup)
5605 "Move point to NEWSGROUP in group mode buffer."
5606 ;; Keep update point of group mode buffer if visible.
5607 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5608 (save-window-excursion
5609 ;; Take care of tree window mode.
5610 (when (get-buffer-window gnus-group-buffer)
5611 (pop-to-buffer gnus-group-buffer))
5612 (gnus-group-jump-to-group newsgroup))
5614 ;; Take care of tree window mode.
5615 (if (get-buffer-window gnus-group-buffer)
5616 (pop-to-buffer gnus-group-buffer)
5617 (set-buffer gnus-group-buffer))
5618 (gnus-group-jump-to-group newsgroup))))
5620 ;; This function returns a list of article numbers based on the
5621 ;; difference between the ranges of read articles in this group and
5622 ;; the range of active articles.
5623 (defun gnus-list-of-unread-articles (group)
5624 (let* ((read (gnus-info-read (gnus-get-info group)))
5625 (active (or (gnus-active group) (gnus-activate-group group)))
5628 ;; If none are read, then all are unread.
5630 (setq first (car active))
5631 ;; If the range of read articles is a single range, then the
5632 ;; first unread article is the article after the last read
5633 ;; article. Sounds logical, doesn't it?
5634 (if (and (not (listp (cdr read)))
5635 (or (< (car read) (car active))
5636 (progn (setq read (list read))
5638 (setq first (max (car active) (1+ (cdr read))))
5639 ;; `read' is a list of ranges.
5640 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5643 (setq first (car active)))
5646 (while (< first nlast)
5648 (setq first (1+ first))))
5649 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5650 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5651 (setq read (cdr read)))))
5652 ;; And add the last unread articles.
5653 (while (<= first last)
5655 (setq first (1+ first)))
5656 ;; Return the list of unread articles.
5657 (delq 0 (nreverse unread))))
5659 (defun gnus-list-of-read-articles (group)
5660 "Return a list of unread, unticked and non-dormant articles."
5661 (let* ((info (gnus-get-info group))
5662 (marked (gnus-info-marks info))
5663 (active (gnus-active group)))
5665 (gnus-set-difference
5666 (gnus-sorted-complement
5667 (gnus-uncompress-range active)
5668 (gnus-list-of-unread-articles group))
5670 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5671 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5673 ;; Various summary commands
5675 (defun gnus-summary-select-article-buffer ()
5676 "Reconfigure windows to show article buffer."
5678 (if (not (gnus-buffer-live-p gnus-article-buffer))
5679 (error "There is no article buffer for this summary buffer")
5680 (gnus-configure-windows 'article)
5681 (select-window (get-buffer-window gnus-article-buffer))))
5683 (defun gnus-summary-universal-argument (arg)
5684 "Perform any operation on all articles that are process/prefixed."
5686 (let ((articles (gnus-summary-work-articles arg))
5693 (substitute-command-keys
5694 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5696 (gnus-error 1 "Undefined key")
5699 (gnus-summary-goto-subject (setq article (pop articles)))
5700 (let (gnus-newsgroup-processable)
5701 (command-execute func))
5702 (gnus-summary-remove-process-mark article)))))
5703 (gnus-summary-position-point))
5705 (defun gnus-summary-toggle-truncation (&optional arg)
5706 "Toggle truncation of summary lines.
5707 With arg, turn line truncation on iff arg is positive."
5709 (setq truncate-lines
5710 (if (null arg) (not truncate-lines)
5711 (> (prefix-numeric-value arg) 0)))
5714 (defun gnus-summary-reselect-current-group (&optional all rescan)
5715 "Exit and then reselect the current newsgroup.
5716 The prefix argument ALL means to select all articles."
5718 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5719 (error "Ephemeral groups can't be reselected"))
5720 (let ((current-subject (gnus-summary-article-number))
5721 (group gnus-newsgroup-name))
5722 (setq gnus-newsgroup-begin nil)
5724 ;; We have to adjust the point of group mode buffer because
5725 ;; point was moved to the next unread newsgroup by exiting.
5726 (gnus-summary-jump-to-group group)
5729 (save-window-excursion
5730 ;; Don't show group contents.
5731 (set-window-start (selected-window) (point-max))
5732 (gnus-group-get-new-news-this-group 1))))
5733 (gnus-group-read-group all t)
5734 (gnus-summary-goto-subject current-subject nil t)))
5736 (defun gnus-summary-rescan-group (&optional all)
5737 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5739 (gnus-summary-reselect-current-group all t))
5741 (defun gnus-summary-update-info (&optional non-destructive)
5743 (let ((group gnus-newsgroup-name))
5745 (when gnus-newsgroup-kill-headers
5746 (setq gnus-newsgroup-killed
5747 (gnus-compress-sequence
5749 (gnus-set-sorted-intersection
5750 (gnus-uncompress-range gnus-newsgroup-killed)
5751 (setq gnus-newsgroup-unselected
5752 (sort gnus-newsgroup-unselected '<)))
5753 (setq gnus-newsgroup-unreads
5754 (sort gnus-newsgroup-unreads '<)))
5756 (unless (listp (cdr gnus-newsgroup-killed))
5757 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5758 (let ((headers gnus-newsgroup-headers))
5759 ;; Set the new ranges of read articles.
5761 (set-buffer gnus-group-buffer)
5762 (gnus-undo-force-boundary))
5763 (gnus-update-read-articles
5764 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5765 ;; Set the current article marks.
5766 (let ((gnus-newsgroup-scored
5767 (if (and (not gnus-save-score)
5768 (not non-destructive))
5770 gnus-newsgroup-scored)))
5772 (gnus-update-marks)))
5773 ;; Do the cross-ref thing.
5774 (when gnus-use-cross-reference
5775 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5776 ;; Do not switch windows but change the buffer to work.
5777 (set-buffer gnus-group-buffer)
5778 (unless (gnus-ephemeral-group-p group)
5779 (gnus-group-update-group group)))))))
5781 (defun gnus-summary-save-newsrc (&optional force)
5782 "Save the current number of read/marked articles in the dribble buffer.
5783 The dribble buffer will then be saved.
5784 If FORCE (the prefix), also save the .newsrc file(s)."
5786 (gnus-summary-update-info t)
5788 (gnus-save-newsrc-file)
5789 (gnus-dribble-save)))
5791 (defun gnus-summary-exit (&optional temporary)
5792 "Exit reading current newsgroup, and then return to group selection mode.
5793 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5795 (gnus-set-global-variables)
5796 (gnus-kill-save-kill-buffer)
5797 (gnus-async-halt-prefetch)
5798 (let* ((group gnus-newsgroup-name)
5799 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5802 (buf (current-buffer)))
5804 ;; Do adaptive scoring, and possibly save score files.
5805 (when gnus-newsgroup-adaptive
5806 (gnus-score-adaptive))
5807 (when gnus-use-scoring
5809 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5810 ;; If we have several article buffers, we kill them at exit.
5811 (unless gnus-single-article-buffer
5812 (gnus-kill-buffer gnus-original-article-buffer)
5813 (setq gnus-article-current nil))
5814 (when gnus-use-cache
5815 (gnus-cache-possibly-remove-articles)
5816 (gnus-cache-save-buffers))
5817 (gnus-async-prefetch-remove-group group)
5818 (when gnus-suppress-duplicates
5819 (gnus-dup-enter-articles))
5820 (when gnus-use-trees
5821 (gnus-tree-close group))
5822 (when gnus-use-cache
5823 (gnus-cache-write-active))
5824 ;; Remove entries for this group.
5825 (nnmail-purge-split-history (gnus-group-real-name group))
5826 ;; Make all changes in this group permanent.
5828 (gnus-run-hooks 'gnus-exit-group-hook)
5829 (gnus-summary-update-info))
5830 (gnus-close-group group)
5831 ;; Make sure where we were, and go to next newsgroup.
5832 (set-buffer gnus-group-buffer)
5834 (gnus-group-jump-to-group group))
5835 (gnus-run-hooks 'gnus-summary-exit-hook)
5836 (unless (or quit-config
5837 ;; If this group has disappeared from the summary
5838 ;; buffer, don't skip forwards.
5839 (not (string= group (gnus-group-group-name))))
5840 (gnus-group-next-unread-group 1))
5841 (setq group-point (point))
5844 ;; If we have several article buffers, we kill them at exit.
5845 (unless gnus-single-article-buffer
5846 (gnus-kill-buffer gnus-article-buffer)
5847 (gnus-kill-buffer gnus-original-article-buffer)
5848 (setq gnus-article-current nil))
5850 (if (not gnus-kill-summary-on-exit)
5852 (gnus-deaden-summary)
5854 ;; We set all buffer-local variables to nil. It is unclear why
5855 ;; this is needed, but if we don't, buffer-local variables are
5856 ;; not garbage-collected, it seems. This would the lead to en
5857 ;; ever-growing Emacs.
5858 (gnus-summary-clear-local-variables)
5859 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5860 (gnus-summary-clear-local-variables))
5861 (when (get-buffer gnus-article-buffer)
5862 (bury-buffer gnus-article-buffer))
5863 ;; We clear the global counterparts of the buffer-local
5864 ;; variables as well, just to be on the safe side.
5865 (set-buffer gnus-group-buffer)
5866 (gnus-summary-clear-local-variables)
5867 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5868 (gnus-summary-clear-local-variables)))
5869 (setq gnus-current-select-method gnus-select-method)
5870 (pop-to-buffer gnus-group-buffer)
5871 (if (not quit-config)
5873 (goto-char group-point)
5874 (gnus-configure-windows 'group 'force)
5875 (unless (pos-visible-in-window-p)
5876 (forward-line (/ (static-if (featurep 'xemacs)
5877 (window-displayed-height)
5878 (1- (window-height)))
5880 (set-window-start (selected-window) (point))
5881 (goto-char group-point)))
5882 (gnus-handle-ephemeral-exit quit-config))
5883 ;; Return to group mode buffer.
5884 (when (eq mode 'gnus-summary-mode)
5885 (gnus-kill-buffer buf))
5886 ;; Clear the current group name.
5888 (setq gnus-newsgroup-name nil)))))
5890 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5891 (defun gnus-summary-exit-no-update (&optional no-questions)
5892 "Quit reading current newsgroup without updating read article info."
5894 (let* ((group gnus-newsgroup-name)
5895 (quit-config (gnus-group-quit-config group)))
5896 (when (or no-questions
5898 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5899 (gnus-async-halt-prefetch)
5901 (delq 'gnus-summary-expire-articles
5902 (copy-sequence gnus-summary-prepare-exit-hook)))
5903 ;; If we have several article buffers, we kill them at exit.
5904 (unless gnus-single-article-buffer
5905 (gnus-kill-buffer gnus-article-buffer)
5906 (gnus-kill-buffer gnus-original-article-buffer)
5907 (setq gnus-article-current nil))
5908 (if (not gnus-kill-summary-on-exit)
5909 (gnus-deaden-summary)
5910 (gnus-close-group group)
5911 (gnus-summary-clear-local-variables)
5912 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5913 (gnus-summary-clear-local-variables))
5914 (set-buffer gnus-group-buffer)
5915 (gnus-summary-clear-local-variables)
5916 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5917 (gnus-summary-clear-local-variables))
5918 (when (get-buffer gnus-summary-buffer)
5919 (kill-buffer gnus-summary-buffer)))
5920 (unless gnus-single-article-buffer
5921 (setq gnus-article-current nil))
5922 (when gnus-use-trees
5923 (gnus-tree-close group))
5924 (gnus-async-prefetch-remove-group group)
5925 (when (get-buffer gnus-article-buffer)
5926 (bury-buffer gnus-article-buffer))
5927 ;; Return to the group buffer.
5928 (gnus-configure-windows 'group 'force)
5929 ;; Clear the current group name.
5930 (setq gnus-newsgroup-name nil)
5931 (when (equal (gnus-group-group-name) group)
5932 (gnus-group-next-unread-group 1))
5934 (gnus-handle-ephemeral-exit quit-config)))))
5936 (defun gnus-handle-ephemeral-exit (quit-config)
5937 "Handle movement when leaving an ephemeral group.
5938 The state which existed when entering the ephemeral is reset."
5939 (if (not (buffer-name (car quit-config)))
5940 (gnus-configure-windows 'group 'force)
5941 (set-buffer (car quit-config))
5942 (cond ((eq major-mode 'gnus-summary-mode)
5943 (gnus-set-global-variables))
5944 ((eq major-mode 'gnus-article-mode)
5946 ;; The `gnus-summary-buffer' variable may point
5947 ;; to the old summary buffer when using a single
5949 (unless (gnus-buffer-live-p gnus-summary-buffer)
5950 (set-buffer gnus-group-buffer))
5951 (set-buffer gnus-summary-buffer)
5952 (gnus-set-global-variables))))
5953 (if (or (eq (cdr quit-config) 'article)
5954 (eq (cdr quit-config) 'pick))
5956 ;; The current article may be from the ephemeral group
5957 ;; thus it is best that we reload this article
5958 (gnus-summary-show-article)
5959 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5960 (gnus-configure-windows 'pick 'force)
5961 (gnus-configure-windows (cdr quit-config) 'force)))
5962 (gnus-configure-windows (cdr quit-config) 'force))
5963 (when (eq major-mode 'gnus-summary-mode)
5964 (gnus-summary-next-subject 1 nil t)
5965 (gnus-summary-recenter)
5966 (gnus-summary-position-point))))
5968 (defun gnus-summary-preview-mime-message ()
5969 "MIME decode and play this message."
5971 (let ((gnus-break-pages nil)
5973 (gnus-summary-select-article gnus-show-all-headers t))
5974 (select-window (get-buffer-window gnus-article-buffer)))
5978 (defvar gnus-dead-summary-mode-map nil)
5980 (unless gnus-dead-summary-mode-map
5981 (setq gnus-dead-summary-mode-map (make-keymap))
5982 (suppress-keymap gnus-dead-summary-mode-map)
5983 (substitute-key-definition
5984 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5985 (let ((keys '("\C-d" "\r" "\177" [delete])))
5987 (define-key gnus-dead-summary-mode-map
5988 (pop keys) 'gnus-summary-wake-up-the-dead))))
5990 (defvar gnus-dead-summary-mode nil
5991 "Minor mode for Gnus summary buffers.")
5993 (defun gnus-dead-summary-mode (&optional arg)
5994 "Minor mode for Gnus summary buffers."
5996 (when (eq major-mode 'gnus-summary-mode)
5997 (make-local-variable 'gnus-dead-summary-mode)
5998 (setq gnus-dead-summary-mode
5999 (if (null arg) (not gnus-dead-summary-mode)
6000 (> (prefix-numeric-value arg) 0)))
6001 (when gnus-dead-summary-mode
6002 (gnus-add-minor-mode
6003 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6005 (defun gnus-deaden-summary ()
6006 "Make the current summary buffer into a dead summary buffer."
6007 ;; Kill any previous dead summary buffer.
6008 (when (and gnus-dead-summary
6009 (buffer-name gnus-dead-summary))
6011 (set-buffer gnus-dead-summary)
6012 (when gnus-dead-summary-mode
6013 (kill-buffer (current-buffer)))))
6014 ;; Make this the current dead summary.
6015 (setq gnus-dead-summary (current-buffer))
6016 (gnus-dead-summary-mode 1)
6017 (let ((name (buffer-name)))
6018 (when (string-match "Summary" name)
6020 (concat (substring name 0 (match-beginning 0)) "Dead "
6021 (substring name (match-beginning 0)))
6025 (defun gnus-kill-or-deaden-summary (buffer)
6026 "Kill or deaden the summary BUFFER."
6028 (when (and (buffer-name buffer)
6029 (not gnus-single-article-buffer))
6032 (gnus-kill-buffer gnus-article-buffer)
6033 (gnus-kill-buffer gnus-original-article-buffer)))
6034 (cond (gnus-kill-summary-on-exit
6035 (when (and gnus-use-trees
6036 (gnus-buffer-exists-p buffer))
6039 (gnus-tree-close gnus-newsgroup-name)))
6040 (gnus-kill-buffer buffer))
6041 ((gnus-buffer-exists-p buffer)
6044 (gnus-deaden-summary))))))
6046 (defun gnus-summary-wake-up-the-dead (&rest args)
6047 "Wake up the dead summary buffer."
6049 (gnus-dead-summary-mode -1)
6050 (let ((name (buffer-name)))
6051 (when (string-match "Dead " name)
6053 (concat (substring name 0 (match-beginning 0))
6054 (substring name (match-end 0)))
6056 (gnus-message 3 "This dead summary is now alive again"))
6058 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6059 (defun gnus-summary-fetch-faq (&optional faq-dir)
6060 "Fetch the FAQ for the current group.
6061 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6065 (when current-prefix-arg
6067 "Faq dir: " (and (listp gnus-group-faq-directory)
6068 (mapcar (lambda (file) (list file))
6069 gnus-group-faq-directory))))))
6070 (let (gnus-faq-buffer)
6071 (when (setq gnus-faq-buffer
6072 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6073 (gnus-configure-windows 'summary-faq))))
6075 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6076 (defun gnus-summary-describe-group (&optional force)
6077 "Describe the current newsgroup."
6079 (gnus-group-describe-group force gnus-newsgroup-name))
6081 (defun gnus-summary-describe-briefly ()
6082 "Describe summary mode commands briefly."
6084 (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")))
6086 ;; Walking around group mode buffer from summary mode.
6088 (defun gnus-summary-next-group (&optional no-article target-group backward)
6089 "Exit current newsgroup and then select next unread newsgroup.
6090 If prefix argument NO-ARTICLE is non-nil, no article is selected
6091 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6092 previous group instead."
6094 ;; Stop pre-fetching.
6095 (gnus-async-halt-prefetch)
6096 (let ((current-group gnus-newsgroup-name)
6097 (current-buffer (current-buffer))
6099 ;; First we semi-exit this group to update Xrefs and all variables.
6100 ;; We can't do a real exit, because the window conf must remain
6101 ;; the same in case the user is prompted for info, and we don't
6102 ;; want the window conf to change before that...
6103 (gnus-summary-exit t)
6104 (while (not entered)
6105 ;; Then we find what group we are supposed to enter.
6106 (set-buffer gnus-group-buffer)
6107 (gnus-group-jump-to-group current-group)
6110 (if (eq gnus-keep-same-level 'best)
6111 (gnus-summary-best-group gnus-newsgroup-name)
6112 (gnus-summary-search-group backward gnus-keep-same-level))))
6113 (if (not target-group)
6114 ;; There are no further groups, so we return to the group
6117 (gnus-message 5 "Returning to the group buffer")
6119 (when (gnus-buffer-live-p current-buffer)
6120 (set-buffer current-buffer)
6121 (gnus-summary-exit))
6122 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6123 ;; We try to enter the target group.
6124 (gnus-group-jump-to-group target-group)
6125 (let ((unreads (gnus-group-group-unread)))
6126 (if (and (or (eq t unreads)
6127 (and unreads (not (zerop unreads))))
6128 (gnus-summary-read-group
6129 target-group nil no-article
6130 (and (buffer-name current-buffer) current-buffer)
6133 (setq current-group target-group
6134 target-group nil)))))))
6136 (defun gnus-summary-prev-group (&optional no-article)
6137 "Exit current newsgroup and then select previous unread newsgroup.
6138 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6140 (gnus-summary-next-group no-article nil t))
6142 ;; Walking around summary lines.
6144 (defun gnus-summary-first-subject (&optional unread undownloaded)
6145 "Go to the first unread subject.
6146 If UNREAD is non-nil, go to the first unread article.
6147 Returns the article selected or nil if there are no unread articles."
6152 ((null gnus-newsgroup-data)
6153 (gnus-message 3 "No articles in the group")
6155 ;; Pick the first article.
6157 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6158 (gnus-data-number (car gnus-newsgroup-data)))
6159 ;; No unread articles.
6160 ((null gnus-newsgroup-unreads)
6161 (gnus-message 3 "No more unread articles")
6163 ;; Find the first unread article.
6165 (let ((data gnus-newsgroup-data))
6167 (and (not (and undownloaded
6168 (eq gnus-undownloaded-mark
6169 (gnus-data-mark (car data)))))
6170 (not (gnus-data-unread-p (car data)))))
6171 (setq data (cdr data)))
6173 (goto-char (gnus-data-pos (car data)))
6174 (gnus-data-number (car data))))))
6175 (gnus-summary-position-point)))
6177 (defun gnus-summary-next-subject (n &optional unread dont-display)
6178 "Go to next N'th summary line.
6179 If N is negative, go to the previous N'th subject line.
6180 If UNREAD is non-nil, only unread articles are selected.
6181 The difference between N and the actual number of steps taken is
6184 (let ((backward (< n 0))
6188 (gnus-summary-find-prev unread)
6189 (gnus-summary-find-next unread)))
6190 (unless (zerop (setq n (1- n)))
6191 (gnus-summary-show-thread)))
6193 (gnus-message 7 "No more%s articles"
6194 (if unread " unread" "")))
6195 (unless dont-display
6196 (gnus-summary-recenter)
6197 (gnus-summary-position-point))
6200 (defun gnus-summary-next-unread-subject (n)
6201 "Go to next N'th unread summary line."
6203 (gnus-summary-next-subject n t))
6205 (defun gnus-summary-prev-subject (n &optional unread)
6206 "Go to previous N'th summary line.
6207 If optional argument UNREAD is non-nil, only unread article is selected."
6209 (gnus-summary-next-subject (- n) unread))
6211 (defun gnus-summary-prev-unread-subject (n)
6212 "Go to previous N'th unread summary line."
6214 (gnus-summary-next-subject (- n) t))
6216 (defun gnus-summary-goto-subject (article &optional force silent)
6217 "Go the subject line of ARTICLE.
6218 If FORCE, also allow jumping to articles not currently shown."
6219 (interactive "nArticle number: ")
6221 (data (gnus-data-find article)))
6222 ;; We read in the article if we have to.
6225 (gnus-summary-insert-subject
6227 (if (or (numberp force) (vectorp force)) force)
6229 (setq data (gnus-data-find article)))
6234 (gnus-message 3 "Can't find article %d" article))
6236 (let ((pt (gnus-data-pos data)))
6238 (gnus-summary-set-article-display-arrow pt))
6239 (gnus-summary-position-point)
6242 ;; Walking around summary lines with displaying articles.
6244 (defun gnus-summary-expand-window (&optional arg)
6245 "Make the summary buffer take up the entire Emacs frame.
6246 Given a prefix, will force an `article' buffer configuration."
6249 (gnus-configure-windows 'article 'force)
6250 (gnus-configure-windows 'summary 'force)))
6252 (defun gnus-summary-display-article (article &optional all-header)
6253 "Display ARTICLE in article buffer."
6254 (when (gnus-buffer-live-p gnus-article-buffer)
6255 (with-current-buffer gnus-article-buffer
6256 (set-buffer-multibyte t)))
6257 (gnus-set-global-variables)
6258 (when (gnus-buffer-live-p gnus-article-buffer)
6259 (with-current-buffer gnus-article-buffer
6260 (setq gnus-article-charset gnus-newsgroup-charset)
6261 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6265 (if gnus-summary-display-article-function
6266 (funcall gnus-summary-display-article-function article all-header)
6267 (gnus-article-prepare article all-header))
6268 (with-current-buffer gnus-article-buffer
6269 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6271 (gnus-run-hooks 'gnus-select-article-hook)
6272 (when (and gnus-current-article
6273 (not (zerop gnus-current-article)))
6274 (gnus-summary-goto-subject gnus-current-article))
6275 (gnus-summary-recenter)
6276 (when (and gnus-use-trees gnus-show-threads)
6277 (gnus-possibly-generate-tree article)
6278 (gnus-highlight-selected-tree article))
6279 ;; Successfully display article.
6280 (gnus-article-set-window-start
6281 (cdr (assq article gnus-newsgroup-bookmarks))))))
6283 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6284 "Select the current article.
6285 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6286 non-nil, the article will be re-fetched even if it already present in
6287 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6289 ;; Make sure we are in the summary buffer to work around bbdb bug.
6290 (unless (eq major-mode 'gnus-summary-mode)
6291 (set-buffer gnus-summary-buffer))
6292 (let ((article (or article (gnus-summary-article-number)))
6293 (all-headers (not (not all-headers))) ;Must be T or NIL.
6294 gnus-summary-display-article-function)
6296 (gnus-summary-article-pseudo-p article)
6297 (error "This is a pseudo-article"))
6299 (set-buffer gnus-summary-buffer)
6300 (if (or (and gnus-single-article-buffer
6301 (or (null gnus-current-article)
6302 (null gnus-article-current)
6303 (null (get-buffer gnus-article-buffer))
6304 (not (eq article (cdr gnus-article-current)))
6305 (not (equal (car gnus-article-current)
6306 gnus-newsgroup-name))))
6307 (and (not gnus-single-article-buffer)
6308 (or (null gnus-current-article)
6309 (not (eq gnus-current-article article))))
6311 ;; The requested article is different from the current article.
6313 (gnus-summary-display-article article all-headers)
6314 (when (or all-headers gnus-show-all-headers)
6315 (gnus-article-show-all-headers))
6316 (gnus-article-set-window-start
6317 (cdr (assq article gnus-newsgroup-bookmarks)))
6319 (when (or all-headers gnus-show-all-headers)
6320 (gnus-article-show-all-headers))
6323 (defun gnus-summary-force-verify-and-decrypt ()
6325 (let ((mm-verify-option 'known)
6326 (mm-decrypt-option 'known))
6327 (gnus-summary-select-article nil 'force)))
6329 (defun gnus-summary-set-current-mark (&optional current-mark)
6330 "Obsolete function."
6333 (defun gnus-summary-next-article (&optional unread subject backward push)
6334 "Select the next article.
6335 If UNREAD, only unread articles are selected.
6336 If SUBJECT, only articles with SUBJECT are selected.
6337 If BACKWARD, the previous article is selected instead of the next."
6340 ;; Is there such an article?
6341 ((and (gnus-summary-search-forward unread subject backward)
6342 (or (gnus-summary-display-article (gnus-summary-article-number))
6343 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6344 (gnus-summary-position-point))
6345 ;; If not, we try the first unread, if that is wanted.
6347 gnus-auto-select-same
6348 (gnus-summary-first-unread-article))
6349 (gnus-summary-position-point)
6350 (gnus-message 6 "Wrapped"))
6351 ;; Try to get next/previous article not displayed in this group.
6352 ((and gnus-auto-extend-newsgroup
6353 (not unread) (not subject))
6354 (gnus-summary-goto-article
6355 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6356 nil (count-lines (point-min) (point))))
6357 ;; Go to next/previous group.
6359 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6360 (gnus-summary-jump-to-group gnus-newsgroup-name))
6361 (let ((cmd last-command-char)
6364 (set-buffer gnus-group-buffer)
6367 (if (eq gnus-keep-same-level 'best)
6368 (gnus-summary-best-group gnus-newsgroup-name)
6369 (gnus-summary-search-group backward gnus-keep-same-level))))
6370 ;; For some reason, the group window gets selected. We change
6372 (select-window (get-buffer-window (current-buffer)))
6373 ;; Select next unread newsgroup automagically.
6375 ((or (not gnus-auto-select-next)
6377 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6378 ((or (eq gnus-auto-select-next 'quietly)
6379 (and (eq gnus-auto-select-next 'slightly-quietly)
6381 (and (eq gnus-auto-select-next 'almost-quietly)
6382 (gnus-summary-last-article-p)))
6384 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6386 (gnus-message 7 "No more%s articles (%s)..."
6387 (if unread " unread" "")
6388 (if group (concat "selecting " group)
6390 (gnus-summary-next-group nil group backward)))
6392 (when (gnus-key-press-event-p last-input-event)
6393 (gnus-summary-walk-group-buffer
6394 gnus-newsgroup-name cmd unread backward point))))))))
6396 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6397 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6398 (?\C-p (gnus-group-prev-unread-group 1))))
6399 (cursor-in-echo-area t)
6400 keve key group ended)
6402 (set-buffer gnus-group-buffer)
6405 (if (eq gnus-keep-same-level 'best)
6406 (gnus-summary-best-group gnus-newsgroup-name)
6407 (gnus-summary-search-group backward gnus-keep-same-level))))
6410 5 "No more%s articles%s" (if unread " unread" "")
6412 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6413 (format " (Type %s for %s [%s])"
6414 (single-key-description cmd) group
6415 (car (gnus-gethash group gnus-newsrc-hashtb)))
6416 (format " (Type %s to exit %s)"
6417 (single-key-description cmd)
6418 gnus-newsgroup-name)))
6419 ;; Confirm auto selection.
6420 (setq key (car (setq keve (gnus-read-event-char))))
6423 ((assq key keystrokes)
6424 (let ((obuf (current-buffer)))
6425 (switch-to-buffer gnus-group-buffer)
6427 (gnus-group-jump-to-group group))
6428 (eval (cadr (assq key keystrokes)))
6429 (setq group (gnus-group-group-name))
6430 (switch-to-buffer obuf))
6434 (gnus-ephemeral-group-p gnus-newsgroup-name))
6436 (gnus-summary-next-group nil group backward)))
6438 (push (cdr keve) unread-command-events))))))
6440 (defun gnus-summary-next-unread-article ()
6441 "Select unread article after current one."
6443 (gnus-summary-next-article
6444 (or (not (eq gnus-summary-goto-unread 'never))
6445 (gnus-summary-last-article-p (gnus-summary-article-number)))
6446 (and gnus-auto-select-same
6447 (gnus-summary-article-subject))))
6449 (defun gnus-summary-prev-article (&optional unread subject)
6450 "Select the article after the current one.
6451 If UNREAD is non-nil, only unread articles are selected."
6453 (gnus-summary-next-article unread subject t))
6455 (defun gnus-summary-prev-unread-article ()
6456 "Select unread article before current one."
6458 (gnus-summary-prev-article
6459 (or (not (eq gnus-summary-goto-unread 'never))
6460 (gnus-summary-first-article-p (gnus-summary-article-number)))
6461 (and gnus-auto-select-same
6462 (gnus-summary-article-subject))))
6464 (defun gnus-summary-next-page (&optional lines circular)
6465 "Show next page of the selected article.
6466 If at the end of the current article, select the next article.
6467 LINES says how many lines should be scrolled up.
6469 If CIRCULAR is non-nil, go to the start of the article instead of
6470 selecting the next article when reaching the end of the current
6473 (setq gnus-summary-buffer (current-buffer))
6474 (gnus-set-global-variables)
6475 (let ((article (gnus-summary-article-number))
6476 (article-window (get-buffer-window gnus-article-buffer t))
6478 ;; If the buffer is empty, we have no article.
6480 (error "No article to select"))
6481 (gnus-configure-windows 'article)
6482 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6483 (if (and (eq gnus-summary-goto-unread 'never)
6484 (not (gnus-summary-last-article-p article)))
6485 (gnus-summary-next-article)
6486 (gnus-summary-next-unread-article))
6487 (if (or (null gnus-current-article)
6488 (null gnus-article-current)
6489 (/= article (cdr gnus-article-current))
6490 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6491 ;; Selected subject is different from current article's.
6492 (gnus-summary-display-article article)
6493 (when article-window
6494 (gnus-eval-in-buffer-window gnus-article-buffer
6495 (setq endp (gnus-article-next-page lines)))
6498 (gnus-summary-beginning-of-article))
6500 (gnus-message 3 "End of message"))
6502 (if (and (eq gnus-summary-goto-unread 'never)
6503 (not (gnus-summary-last-article-p article)))
6504 (gnus-summary-next-article)
6505 (gnus-summary-next-unread-article))))))))
6506 (gnus-summary-recenter)
6507 (gnus-summary-position-point)))
6509 (defun gnus-summary-prev-page (&optional lines move)
6510 "Show previous page of selected article.
6511 Argument LINES specifies lines to be scrolled down.
6512 If MOVE, move to the previous unread article if point is at
6513 the beginning of the buffer."
6515 (let ((article (gnus-summary-article-number))
6516 (article-window (get-buffer-window gnus-article-buffer t))
6518 (gnus-configure-windows 'article)
6519 (if (or (null gnus-current-article)
6520 (null gnus-article-current)
6521 (/= article (cdr gnus-article-current))
6522 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6523 ;; Selected subject is different from current article's.
6524 (gnus-summary-display-article article)
6525 (gnus-summary-recenter)
6526 (when article-window
6527 (gnus-eval-in-buffer-window gnus-article-buffer
6528 (setq endp (gnus-article-prev-page lines)))
6529 (when (and move endp)
6531 (gnus-message 3 "Beginning of message"))
6533 (if (and (eq gnus-summary-goto-unread 'never)
6534 (not (gnus-summary-first-article-p article)))
6535 (gnus-summary-prev-article)
6536 (gnus-summary-prev-unread-article))))))))
6537 (gnus-summary-position-point))
6539 (defun gnus-summary-prev-page-or-article (&optional lines)
6540 "Show previous page of selected article.
6541 Argument LINES specifies lines to be scrolled down.
6542 If at the beginning of the article, go to the next article."
6544 (gnus-summary-prev-page lines t))
6546 (defun gnus-summary-scroll-up (lines)
6547 "Scroll up (or down) one line current article.
6548 Argument LINES specifies lines to be scrolled up (or down if negative)."
6550 (gnus-configure-windows 'article)
6551 (gnus-summary-show-thread)
6552 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6553 (gnus-eval-in-buffer-window gnus-article-buffer
6555 (when (gnus-article-next-page lines)
6556 (gnus-message 3 "End of message")))
6558 (gnus-article-prev-page (- lines))))))
6559 (gnus-summary-recenter)
6560 (gnus-summary-position-point))
6562 (defun gnus-summary-scroll-down (lines)
6563 "Scroll down (or up) one line current article.
6564 Argument LINES specifies lines to be scrolled down (or up if negative)."
6566 (gnus-summary-scroll-up (- lines)))
6568 (defun gnus-summary-next-same-subject ()
6569 "Select next article which has the same subject as current one."
6571 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6573 (defun gnus-summary-prev-same-subject ()
6574 "Select previous article which has the same subject as current one."
6576 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6578 (defun gnus-summary-next-unread-same-subject ()
6579 "Select next unread article which has the same subject as current one."
6581 (gnus-summary-next-article t (gnus-summary-article-subject)))
6583 (defun gnus-summary-prev-unread-same-subject ()
6584 "Select previous unread article which has the same subject as current one."
6586 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6588 (defun gnus-summary-first-unread-article ()
6589 "Select the first unread article.
6590 Return nil if there are no unread articles."
6593 (when (gnus-summary-first-subject t)
6594 (gnus-summary-show-thread)
6595 (gnus-summary-first-subject t)
6596 (gnus-summary-display-article (gnus-summary-article-number)))
6597 (gnus-summary-position-point)))
6599 (defun gnus-summary-first-unread-subject ()
6600 "Place the point on the subject line of the first unread article.
6601 Return nil if there are no unread articles."
6604 (when (gnus-summary-first-subject t)
6605 (gnus-summary-show-thread)
6606 (gnus-summary-first-subject t))
6607 (gnus-summary-position-point)))
6609 (defun gnus-summary-first-article ()
6610 "Select the first article.
6611 Return nil if there are no articles."
6614 (when (gnus-summary-first-subject)
6615 (gnus-summary-show-thread)
6616 (gnus-summary-first-subject)
6617 (gnus-summary-display-article (gnus-summary-article-number)))
6618 (gnus-summary-position-point)))
6620 (defun gnus-summary-best-unread-article ()
6621 "Select the unread article with the highest score."
6623 (let ((best -1000000)
6624 (data gnus-newsgroup-data)
6627 (and (gnus-data-unread-p (car data))
6629 (gnus-summary-article-score (gnus-data-number (car data))))
6632 article (gnus-data-number (car data))))
6633 (setq data (cdr data)))
6636 (gnus-summary-goto-article article)
6637 (error "No unread articles"))
6638 (gnus-summary-position-point))))
6640 (defun gnus-summary-last-subject ()
6641 "Go to the last displayed subject line in the group."
6642 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6644 (gnus-summary-goto-subject article))))
6646 (defun gnus-summary-goto-article (article &optional all-headers force)
6647 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6648 If ALL-HEADERS is non-nil, no header lines are hidden.
6649 If FORCE, go to the article even if it isn't displayed. If FORCE
6650 is a number, it is the line the article is to be displayed on."
6654 "Article number or Message-ID: "
6655 (mapcar (lambda (number) (list (int-to-string number)))
6656 gnus-newsgroup-limit))
6660 (if (and (stringp article)
6661 (string-match "@" article))
6662 (gnus-summary-refer-article article)
6663 (when (stringp article)
6664 (setq article (string-to-number article)))
6665 (if (gnus-summary-goto-subject article force)
6666 (gnus-summary-display-article article all-headers)
6667 (gnus-message 4 "Couldn't go to article %s" article) nil))
6668 (gnus-summary-position-point)))
6670 (defun gnus-summary-goto-last-article ()
6671 "Go to the previously read article."
6674 (when gnus-last-article
6675 (gnus-summary-goto-article gnus-last-article nil t))
6676 (gnus-summary-position-point)))
6678 (defun gnus-summary-pop-article (number)
6679 "Pop one article off the history and go to the previous.
6680 NUMBER articles will be popped off."
6683 (setq gnus-newsgroup-history
6684 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6686 (gnus-summary-goto-article (car to) nil t)
6687 (error "Article history empty")))
6688 (gnus-summary-position-point))
6690 ;; Summary commands and functions for limiting the summary buffer.
6692 (defun gnus-summary-limit-to-articles (n)
6693 "Limit the summary buffer to the next N articles.
6694 If not given a prefix, use the process marked articles instead."
6697 (let ((articles (gnus-summary-work-articles n)))
6698 (setq gnus-newsgroup-processable nil)
6699 (gnus-summary-limit articles))
6700 (gnus-summary-position-point)))
6702 (defun gnus-summary-pop-limit (&optional total)
6703 "Restore the previous limit.
6704 If given a prefix, remove all limits."
6707 (setq gnus-newsgroup-limits
6708 (list (mapcar (lambda (h) (mail-header-number h))
6709 gnus-newsgroup-headers))))
6710 (unless gnus-newsgroup-limits
6711 (error "No limit to pop"))
6713 (gnus-summary-limit nil 'pop)
6714 (gnus-summary-position-point)))
6716 (defun gnus-summary-limit-to-subject (subject &optional header)
6717 "Limit the summary buffer to articles that have subjects that match a regexp."
6718 (interactive "sLimit to subject (regexp): ")
6720 (setq header "subject"))
6721 (when (not (equal "" subject))
6723 (let ((articles (gnus-summary-find-matching
6724 (or header "subject") subject 'all)))
6726 (error "Found no matches for \"%s\"" subject))
6727 (gnus-summary-limit articles))
6728 (gnus-summary-position-point))))
6730 (defun gnus-summary-limit-to-author (from)
6731 "Limit the summary buffer to articles that have authors that match a regexp."
6732 (interactive "sLimit to author (regexp): ")
6733 (gnus-summary-limit-to-subject from "from"))
6735 (defun gnus-summary-limit-to-age (age &optional younger-p)
6736 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6737 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6738 articles that are younger than AGE days."
6740 (let ((younger current-prefix-arg)
6743 (while (not days-got)
6744 (setq days (if younger
6745 (read-string "Limit to articles within (in days): ")
6746 (read-string "Limit to articles older than (in days): ")))
6747 (when (> (length days) 0)
6748 (setq days (read days)))
6751 (message "Please enter a number.")
6753 (list days younger)))
6755 (let ((data gnus-newsgroup-data)
6756 (cutoff (days-to-time age))
6757 articles d date is-younger)
6758 (while (setq d (pop data))
6759 (when (and (vectorp (gnus-data-header d))
6760 (setq date (mail-header-date (gnus-data-header d))))
6761 (setq is-younger (time-less-p
6762 (time-since (condition-case ()
6769 (push (gnus-data-number d) articles))))
6770 (gnus-summary-limit (nreverse articles)))
6771 (gnus-summary-position-point)))
6773 (defun gnus-summary-limit-to-extra (header regexp)
6774 "Limit the summary buffer to articles that match an 'extra' header."
6778 (gnus-completing-read
6779 (symbol-name (car gnus-extra-headers))
6780 "Limit extra header:"
6782 (cons (symbol-name x) x))
6787 (read-string (format "Limit to header %s (regexp): " header)))))
6788 (when (not (equal "" regexp))
6790 (let ((articles (gnus-summary-find-matching
6791 (cons 'extra header) regexp 'all)))
6793 (error "Found no matches for \"%s\"" regexp))
6794 (gnus-summary-limit articles))
6795 (gnus-summary-position-point))))
6797 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6799 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6801 (defun gnus-summary-limit-to-unread (&optional all)
6802 "Limit the summary buffer to articles that are not marked as read.
6803 If ALL is non-nil, limit strictly to unread articles."
6806 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6807 (gnus-summary-limit-to-marks
6808 ;; Concat all the marks that say that an article is read and have
6810 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6811 gnus-killed-mark gnus-kill-file-mark
6812 gnus-low-score-mark gnus-expirable-mark
6813 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6814 gnus-duplicate-mark gnus-souped-mark)
6817 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6818 (make-obsolete 'gnus-summary-delete-marked-with
6819 'gnus-summary-limit-exlude-marks)
6821 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6822 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6823 If REVERSE, limit the summary buffer to articles that are marked
6824 with MARKS. MARKS can either be a string of marks or a list of marks.
6825 Returns how many articles were removed."
6826 (interactive "sMarks: ")
6827 (gnus-summary-limit-to-marks marks t))
6829 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6830 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6831 If REVERSE (the prefix), limit the summary buffer to articles that are
6832 not marked with MARKS. MARKS can either be a string of marks or a
6834 Returns how many articles were removed."
6835 (interactive "sMarks: \nP")
6837 (let ((data gnus-newsgroup-data)
6838 (marks (if (listp marks) marks
6839 (append marks nil))) ; Transform to list.
6842 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6843 (memq (gnus-data-mark (car data)) marks))
6844 (push (gnus-data-number (car data)) articles))
6845 (setq data (cdr data)))
6846 (gnus-summary-limit articles))
6847 (gnus-summary-position-point)))
6849 (defun gnus-summary-limit-to-score (&optional score)
6850 "Limit to articles with score at or above SCORE."
6852 (setq score (if score
6853 (prefix-numeric-value score)
6854 (or gnus-summary-default-score 0)))
6855 (let ((data gnus-newsgroup-data)
6858 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6860 (push (gnus-data-number (car data)) articles))
6861 (setq data (cdr data)))
6863 (gnus-summary-limit articles)
6864 (gnus-summary-position-point))))
6866 (defun gnus-summary-limit-include-thread (id)
6867 "Display all the hidden articles that is in the thread with ID in it.
6868 When called interactively, ID is the Message-ID of the current
6870 (interactive (list (mail-header-id (gnus-summary-article-header))))
6871 (let ((articles (gnus-articles-in-thread
6872 (gnus-id-to-thread (gnus-root-id id)))))
6874 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6875 (gnus-summary-limit-include-matching-articles
6877 (regexp-quote (gnus-simplify-subject-re
6878 (mail-header-subject (gnus-id-to-header id)))))
6879 (gnus-summary-position-point))))
6881 (defun gnus-summary-limit-include-matching-articles (header regexp)
6882 "Display all the hidden articles that have HEADERs that match REGEXP."
6883 (interactive (list (read-string "Match on header: ")
6884 (read-string "Regexp: ")))
6885 (let ((articles (gnus-find-matching-articles header regexp)))
6887 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6888 (gnus-summary-position-point))))
6890 (defun gnus-summary-limit-include-dormant ()
6891 "Display all the hidden articles that are marked as dormant.
6892 Note that this command only works on a subset of the articles currently
6893 fetched for this group."
6895 (unless gnus-newsgroup-dormant
6896 (error "There are no dormant articles in this group"))
6898 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6899 (gnus-summary-position-point)))
6901 (defun gnus-summary-limit-exclude-dormant ()
6902 "Hide all dormant articles."
6905 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6906 (gnus-summary-position-point)))
6908 (defun gnus-summary-limit-exclude-childless-dormant ()
6909 "Hide all dormant articles that have no children."
6911 (let ((data (gnus-data-list t))
6912 articles d children)
6913 ;; Find all articles that are either not dormant or have
6915 (while (setq d (pop data))
6916 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6918 (gnus-article-children (gnus-data-number d)))
6921 (when (memq (car children) articles)
6926 (push (gnus-data-number d) articles)))
6929 (gnus-summary-limit articles)
6930 (gnus-summary-position-point))))
6932 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6933 "Mark all unread excluded articles as read.
6934 If ALL, mark even excluded ticked and dormants as read."
6936 (let ((articles (gnus-sorted-complement
6938 (mapcar (lambda (h) (mail-header-number h))
6939 gnus-newsgroup-headers)
6941 (sort gnus-newsgroup-limit '<)))
6943 (setq gnus-newsgroup-unreads
6944 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6946 (setq gnus-newsgroup-dormant nil
6947 gnus-newsgroup-marked nil
6948 gnus-newsgroup-reads
6950 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6951 gnus-newsgroup-reads))
6952 (while (setq article (pop articles))
6953 (unless (or (memq article gnus-newsgroup-dormant)
6954 (memq article gnus-newsgroup-marked))
6955 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6957 (defun gnus-summary-limit (articles &optional pop)
6959 ;; We pop the previous limit off the stack and use that.
6960 (setq articles (car gnus-newsgroup-limits)
6961 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6962 ;; We use the new limit, so we push the old limit on the stack.
6963 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6965 (setq gnus-newsgroup-limit articles)
6966 (let ((total (length gnus-newsgroup-data))
6967 (data (gnus-data-find-list (gnus-summary-article-number)))
6968 (gnus-summary-mark-below nil) ; Inhibit this.
6970 ;; This will do all the work of generating the new summary buffer
6971 ;; according to the new limit.
6972 (gnus-summary-prepare)
6973 ;; Hide any threads, possibly.
6974 (and gnus-show-threads
6975 gnus-thread-hide-subtree
6976 (gnus-summary-hide-all-threads))
6977 ;; Try to return to the article you were at, or one in the
6980 ;; We try to find some article after the current one.
6982 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6985 (setq data (cdr data))))
6987 ;; If there is no data, that means that we were after the last
6988 ;; article. The same goes when we can't find any articles
6989 ;; after the current one.
6990 (goto-char (point-max))
6991 (gnus-summary-find-prev))
6992 (gnus-set-mode-line 'summary)
6993 ;; We return how many articles were removed from the summary
6994 ;; buffer as a result of the new limit.
6995 (- total (length gnus-newsgroup-data))))
6997 (defsubst gnus-invisible-cut-children (threads)
7000 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7005 (defsubst gnus-cut-thread (thread)
7006 "Go forwards in the thread until we find an article that we want to display."
7007 (when (or (eq gnus-fetch-old-headers 'some)
7008 (eq gnus-fetch-old-headers 'invisible)
7009 (numberp gnus-fetch-old-headers)
7010 (eq gnus-build-sparse-threads 'some)
7011 (eq gnus-build-sparse-threads 'more))
7012 ;; Deal with old-fetched headers and sparse threads.
7016 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7017 (gnus-summary-article-ancient-p
7018 (mail-header-number (car thread))))
7019 (if (or (<= (length (cdr thread)) 1)
7020 (eq gnus-fetch-old-headers 'invisible))
7021 (setq gnus-newsgroup-limit
7022 (delq (mail-header-number (car thread))
7023 gnus-newsgroup-limit)
7024 thread (cadr thread))
7025 (when (gnus-invisible-cut-children (cdr thread))
7026 (let ((th (cdr thread)))
7028 (if (memq (mail-header-number (caar th))
7029 gnus-newsgroup-limit)
7030 (setq thread (car th)
7032 (setq th (cdr th))))))))))
7035 (defun gnus-cut-threads (threads)
7036 "Cut off all uninteresting articles from the beginning of threads."
7037 (when (or (eq gnus-fetch-old-headers 'some)
7038 (eq gnus-fetch-old-headers 'invisible)
7039 (numberp gnus-fetch-old-headers)
7040 (eq gnus-build-sparse-threads 'some)
7041 (eq gnus-build-sparse-threads 'more))
7044 (setcar th (gnus-cut-thread (car th)))
7045 (setq th (cdr th)))))
7046 ;; Remove nixed out threads.
7049 (defun gnus-summary-initial-limit (&optional show-if-empty)
7050 "Figure out what the initial limit is supposed to be on group entry.
7051 This entails weeding out unwanted dormants, low-scored articles,
7052 fetch-old-headers verbiage, and so on."
7053 ;; Most groups have nothing to remove.
7054 (if (or gnus-inhibit-limiting
7055 (and (null gnus-newsgroup-dormant)
7056 (not (eq gnus-fetch-old-headers 'some))
7057 (not (numberp gnus-fetch-old-headers))
7058 (not (eq gnus-fetch-old-headers 'invisible))
7059 (null gnus-summary-expunge-below)
7060 (not (eq gnus-build-sparse-threads 'some))
7061 (not (eq gnus-build-sparse-threads 'more))
7062 (null gnus-thread-expunge-below)
7063 (not gnus-use-nocem)))
7065 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7066 (setq gnus-newsgroup-limit nil)
7069 (unless (car (symbol-value node))
7070 ;; These threads have no parents -- they are roots.
7071 (let ((nodes (cdr (symbol-value node)))
7074 (if (and gnus-thread-expunge-below
7075 (< (gnus-thread-total-score (car nodes))
7076 gnus-thread-expunge-below))
7077 (gnus-expunge-thread (pop nodes))
7078 (setq thread (pop nodes))
7079 (gnus-summary-limit-children thread))))))
7080 gnus-newsgroup-dependencies)
7081 ;; If this limitation resulted in an empty group, we might
7082 ;; pop the previous limit and use it instead.
7083 (when (and (not gnus-newsgroup-limit)
7085 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7086 gnus-newsgroup-limit))
7088 (defun gnus-summary-limit-children (thread)
7089 "Return 1 if this subthread is visible and 0 if it is not."
7090 ;; First we get the number of visible children to this thread. This
7091 ;; is done by recursing down the thread using this function, so this
7092 ;; will really go down to a leaf article first, before slowly
7093 ;; working its way up towards the root.
7097 (apply '+ (mapcar 'gnus-summary-limit-children
7100 (number (mail-header-number (car thread)))
7103 (not (memq number gnus-newsgroup-marked))
7105 ;; If this article is dormant and has absolutely no visible
7106 ;; children, then this article isn't visible.
7107 (and (memq number gnus-newsgroup-dormant)
7109 ;; If this is "fetch-old-headered" and there is no
7110 ;; visible children, then we don't want this article.
7111 (and (or (eq gnus-fetch-old-headers 'some)
7112 (numberp gnus-fetch-old-headers))
7113 (gnus-summary-article-ancient-p number)
7115 ;; If this is "fetch-old-headered" and `invisible', then
7116 ;; we don't want this article.
7117 (and (eq gnus-fetch-old-headers 'invisible)
7118 (gnus-summary-article-ancient-p number))
7119 ;; If this is a sparsely inserted article with no children,
7120 ;; we don't want it.
7121 (and (eq gnus-build-sparse-threads 'some)
7122 (gnus-summary-article-sparse-p number)
7124 ;; If we use expunging, and this article is really
7125 ;; low-scored, then we don't want this article.
7126 (when (and gnus-summary-expunge-below
7128 (or (cdr (assq number gnus-newsgroup-scored))
7129 gnus-summary-default-score))
7130 gnus-summary-expunge-below))
7131 ;; We increase the expunge-tally here, but that has
7132 ;; nothing to do with the limits, really.
7133 (incf gnus-newsgroup-expunged-tally)
7134 ;; We also mark as read here, if that's wanted.
7135 (when (and gnus-summary-mark-below
7136 (< score gnus-summary-mark-below))
7137 (setq gnus-newsgroup-unreads
7138 (delq number gnus-newsgroup-unreads))
7139 (if gnus-newsgroup-auto-expire
7140 (push number gnus-newsgroup-expirable)
7141 (push (cons number gnus-low-score-mark)
7142 gnus-newsgroup-reads)))
7144 ;; Check NoCeM things.
7145 (if (and gnus-use-nocem
7146 (gnus-nocem-unwanted-article-p
7147 (mail-header-id (car thread))))
7149 (setq gnus-newsgroup-unreads
7150 (delq number gnus-newsgroup-unreads))
7152 ;; Nope, invisible article.
7154 ;; Ok, this article is to be visible, so we add it to the limit
7156 (push number gnus-newsgroup-limit)
7159 (defun gnus-expunge-thread (thread)
7160 "Mark all articles in THREAD as read."
7161 (let* ((number (mail-header-number (car thread))))
7162 (incf gnus-newsgroup-expunged-tally)
7163 ;; We also mark as read here, if that's wanted.
7164 (setq gnus-newsgroup-unreads
7165 (delq number gnus-newsgroup-unreads))
7166 (if gnus-newsgroup-auto-expire
7167 (push number gnus-newsgroup-expirable)
7168 (push (cons number gnus-low-score-mark)
7169 gnus-newsgroup-reads)))
7170 ;; Go recursively through all subthreads.
7171 (mapcar 'gnus-expunge-thread (cdr thread)))
7173 ;; Summary article oriented commands
7175 (defun gnus-summary-refer-parent-article (n)
7176 "Refer parent article N times.
7177 If N is negative, go to ancestor -N instead.
7178 The difference between N and the number of articles fetched is returned."
7182 (when (not (natnump n))
7187 (setq header (gnus-summary-article-header))
7188 (if (and (eq (mail-header-number header)
7189 (cdr gnus-article-current))
7190 (equal gnus-newsgroup-name
7191 (car gnus-article-current)))
7192 ;; If we try to find the parent of the currently
7193 ;; displayed article, then we take a look at the actual
7194 ;; References header, since this is slightly more
7195 ;; reliable than the References field we got from the
7198 (set-buffer gnus-original-article-buffer)
7199 (nnheader-narrow-to-headers)
7200 (unless (setq ref (message-fetch-field "references"))
7201 (setq ref (message-fetch-field "in-reply-to")))
7204 ;; It's not the current article, so we take a bet on
7205 ;; the value we got from the server.
7206 (mail-header-references header)))
7208 (not (equal ref "")))
7209 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7210 (gnus-message 1 "Couldn't find parent"))
7211 (gnus-message 1 "No references in article %d"
7212 (gnus-summary-article-number))
7215 (gnus-summary-position-point)
7218 (defun gnus-summary-refer-references ()
7219 "Fetch all articles mentioned in the References header.
7220 Return the number of articles fetched."
7222 (let ((ref (mail-header-references (gnus-summary-article-header)))
7223 (current (gnus-summary-article-number))
7227 (error "No References in the current article")
7228 ;; For each Message-ID in the References header...
7229 (while (string-match "<[^>]*>" ref)
7231 ;; ... fetch that article.
7232 (gnus-summary-refer-article
7233 (prog1 (match-string 0 ref)
7234 (setq ref (substring ref (match-end 0))))))
7235 (gnus-summary-goto-subject current)
7236 (gnus-summary-position-point)
7239 (defun gnus-summary-refer-thread (&optional limit)
7240 "Fetch all articles in the current thread.
7241 If LIMIT (the numerical prefix), fetch that many old headers instead
7242 of what's specified by the `gnus-refer-thread-limit' variable."
7244 (let ((id (mail-header-id (gnus-summary-article-header)))
7245 (limit (if limit (prefix-numeric-value limit)
7246 gnus-refer-thread-limit)))
7247 ;; We want to fetch LIMIT *old* headers, but we also have to
7248 ;; re-fetch all the headers in the current buffer, because many of
7249 ;; them may be undisplayed. So we adjust LIMIT.
7250 (when (numberp limit)
7251 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7252 (unless (eq gnus-fetch-old-headers 'invisible)
7253 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7254 ;; Retrieve the headers and read them in.
7255 (if (eq (gnus-retrieve-headers
7256 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7258 (gnus-build-all-threads)
7259 (error "Can't fetch thread from backends that don't support NOV"))
7260 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7261 (gnus-summary-limit-include-thread id)))
7263 (defun gnus-summary-refer-article (message-id)
7264 "Fetch an article specified by MESSAGE-ID."
7265 (interactive "sMessage-ID: ")
7266 (when (and (stringp message-id)
7267 (not (zerop (length message-id))))
7268 ;; Construct the correct Message-ID if necessary.
7269 ;; Suggested by tale@pawl.rpi.edu.
7270 (unless (string-match "^<" message-id)
7271 (setq message-id (concat "<" message-id)))
7272 (unless (string-match ">$" message-id)
7273 (setq message-id (concat message-id ">")))
7274 (let* ((header (gnus-id-to-header message-id))
7276 (gnus-summary-article-sparse-p
7277 (mail-header-number header))
7278 (memq (mail-header-number header)
7279 gnus-newsgroup-limit)))
7282 ;; If the article is present in the buffer we just go to it.
7284 (or (not (gnus-summary-article-sparse-p
7285 (mail-header-number header)))
7288 (gnus-summary-goto-article
7289 (mail-header-number header) nil t)
7291 (gnus-summary-update-article (mail-header-number header)))))
7293 ;; We fetch the article.
7295 (dolist (gnus-override-method (gnus-refer-article-methods))
7296 (gnus-check-server gnus-override-method)
7297 ;; Fetch the header, and display the article.
7298 (when (setq number (gnus-summary-insert-subject message-id))
7299 (gnus-summary-select-article nil nil nil number)
7301 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7303 (defun gnus-refer-article-methods ()
7304 "Return a list of referrable methods."
7306 ;; No method, so we default to current and native.
7307 ((null gnus-refer-article-method)
7308 (list gnus-current-select-method gnus-select-method))
7310 ((eq 'current gnus-refer-article-method)
7311 (list gnus-current-select-method))
7312 ;; List of select methods.
7313 ((not (and (symbolp (car gnus-refer-article-method))
7314 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7316 (dolist (method gnus-refer-article-method)
7317 (push (if (eq 'current method)
7318 gnus-current-select-method
7322 ;; One single select method.
7324 (list gnus-refer-article-method))))
7326 (defun gnus-summary-edit-parameters ()
7327 "Edit the group parameters of the current group."
7329 (gnus-group-edit-group gnus-newsgroup-name 'params))
7331 (defun gnus-summary-customize-parameters ()
7332 "Customize the group parameters of the current group."
7334 (gnus-group-customize gnus-newsgroup-name))
7336 (defun gnus-summary-enter-digest-group (&optional force)
7337 "Enter an nndoc group based on the current article.
7338 If FORCE, force a digest interpretation. If not, try
7339 to guess what the document format is."
7341 (let ((conf gnus-current-window-configuration))
7343 (gnus-summary-select-article))
7344 (setq gnus-current-window-configuration conf)
7345 (let* ((name (format "%s-%d"
7346 (gnus-group-prefixed-name
7347 gnus-newsgroup-name (list 'nndoc ""))
7349 (set-buffer gnus-summary-buffer)
7350 gnus-current-article)))
7351 (ogroup gnus-newsgroup-name)
7352 (params (append (gnus-info-params (gnus-get-info ogroup))
7353 (list (cons 'to-group ogroup))
7354 (list (cons 'save-article-group ogroup))))
7355 (case-fold-search t)
7356 (buf (current-buffer))
7359 (set-buffer gnus-original-article-buffer)
7360 ;; Have the digest group inherit the main mail address of
7361 ;; the parent article.
7362 (when (setq to-address (or (message-fetch-field "reply-to")
7363 (message-fetch-field "from")))
7364 (setq params (append
7365 (list (cons 'to-address
7366 (funcall gnus-decode-encoded-word-function
7368 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7369 (insert-buffer-substring gnus-original-article-buffer)
7370 ;; Remove lines that may lead nndoc to misinterpret the
7373 (goto-char (point-min))
7374 (or (search-forward "\n\n" nil t) (point)))
7375 (goto-char (point-min))
7376 (delete-matching-lines "^Path:\\|^From ")
7379 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7380 (gnus-newsgroup-ephemeral-ignored-charsets
7381 gnus-newsgroup-ignored-charsets))
7382 (gnus-group-read-ephemeral-group
7383 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7385 ,(if force 'mbox 'guess))) t))
7386 ;; Make all postings to this group go to the parent group.
7387 (nconc (gnus-info-params (gnus-get-info name))
7389 ;; Couldn't select this doc group.
7390 (switch-to-buffer buf)
7391 (gnus-set-global-variables)
7392 (gnus-configure-windows 'summary)
7393 (gnus-message 3 "Article couldn't be entered?"))
7394 (kill-buffer dig)))))
7396 (defun gnus-summary-read-document (n)
7397 "Open a new group based on the current article(s).
7398 This will allow you to read digests and other similar
7399 documents as newsgroups.
7400 Obeys the standard process/prefix convention."
7402 (let* ((articles (gnus-summary-work-articles n))
7403 (ogroup gnus-newsgroup-name)
7404 (params (append (gnus-info-params (gnus-get-info ogroup))
7405 (list (cons 'to-group ogroup))))
7406 article group egroup groups vgroup)
7407 (while (setq article (pop articles))
7408 (setq group (format "%s-%d" gnus-newsgroup-name article))
7409 (gnus-summary-remove-process-mark article)
7410 (when (gnus-summary-display-article article)
7413 (insert-buffer-substring gnus-original-article-buffer)
7414 ;; Remove some headers that may lead nndoc to make
7416 (message-narrow-to-head)
7417 (goto-char (point-min))
7418 (delete-matching-lines "^\\(Path\\):\\|^From ")
7421 (gnus-group-read-ephemeral-group
7422 group `(nndoc ,group (nndoc-address ,(current-buffer))
7423 (nndoc-article-type guess))
7426 ;; Make all postings to this group go to the parent group.
7427 (nconc (gnus-info-params (gnus-get-info egroup))
7429 (push egroup groups))
7430 ;; Couldn't select this doc group.
7431 (gnus-error 3 "Article couldn't be entered"))))))
7432 ;; Now we have selected all the documents.
7435 (error "None of the articles could be interpreted as documents"))
7436 ((gnus-group-read-ephemeral-group
7437 (setq vgroup (format
7438 "nnvirtual:%s-%s" gnus-newsgroup-name
7439 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7440 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7442 (cons (current-buffer) 'summary)))
7444 (error "Couldn't select virtual nndoc group")))))
7446 (defun gnus-summary-isearch-article (&optional regexp-p)
7447 "Do incremental search forward on the current article.
7448 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7450 (let* ((gnus-inhibit-treatment t)
7451 (old (gnus-summary-select-article)))
7452 (gnus-configure-windows 'article)
7453 (gnus-eval-in-buffer-window gnus-article-buffer
7457 (gnus-article-show-all-headers))
7458 (goto-char (point-min))
7459 (isearch-forward regexp-p)))))
7461 (defun gnus-summary-search-article-forward (regexp &optional backward)
7462 "Search for an article containing REGEXP forward.
7463 If BACKWARD, search backward instead."
7466 (format "Search article %s (regexp%s): "
7467 (if current-prefix-arg "backward" "forward")
7468 (if gnus-last-search-regexp
7469 (concat ", default " gnus-last-search-regexp)
7471 current-prefix-arg))
7472 (if (string-equal regexp "")
7473 (setq regexp (or gnus-last-search-regexp ""))
7474 (setq gnus-last-search-regexp regexp)
7475 (setq gnus-article-before-search gnus-current-article))
7476 ;; Intentionally set gnus-last-article.
7477 (setq gnus-last-article gnus-article-before-search)
7478 (let ((gnus-last-article gnus-last-article))
7479 (if (gnus-summary-search-article regexp backward)
7480 (gnus-summary-show-thread)
7481 (error "Search failed: \"%s\"" regexp))))
7483 (defun gnus-summary-search-article-backward (regexp)
7484 "Search for an article containing REGEXP backward."
7487 (format "Search article backward (regexp%s): "
7488 (if gnus-last-search-regexp
7489 (concat ", default " gnus-last-search-regexp)
7491 (gnus-summary-search-article-forward regexp 'backward))
7494 (defmacro gnus-summary-search-article-position-point (regexp backward)
7495 "Dehighlight the last matched text and goto the beginning position."
7496 (` (if (and gnus-summary-search-article-matched-data
7497 (let ((text (caddr gnus-summary-search-article-matched-data))
7498 (inhibit-read-only t)
7501 (goto-char (car gnus-summary-search-article-matched-data))
7502 (cadr gnus-summary-search-article-matched-data))
7504 (string-match (, regexp) text)))
7505 (if (, backward) (beginning-of-line) (end-of-line))
7506 (goto-char (if (, backward) (point-max) (point-min))))))
7508 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7509 "Place point where X-Face image is displayed."
7510 (if (featurep 'xemacs)
7511 (` (let ((end (if (search-forward "\n\n" nil t)
7512 (goto-char (1- (point)))
7515 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7516 (unless (and (re-search-forward "^From:" end t)
7517 (setq extent (extent-at (point)))
7518 (extent-begin-glyph extent))
7519 (goto-char (, opoint)))))
7520 (` (let ((end (if (search-forward "\n\n" nil t)
7521 (goto-char (1- (point)))
7523 (start (or (search-backward "\n\n" nil t) (point-min))))
7525 (or (text-property-any start end 'x-face-image t);; x-face-e21
7526 (text-property-any start end 'x-face-mule-bitmap-image t)
7529 (defmacro gnus-summary-search-article-highlight-matched-text
7530 (backward treated x-face)
7531 "Highlight matched text in the function `gnus-summary-search-article'."
7532 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7533 (end (set-marker (make-marker) (match-end 0)))
7534 (inhibit-read-only t)
7538 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7540 (lambda (item) (setq items (delq item items)))
7541 '(gnus-treat-buttonize
7542 gnus-treat-fill-article
7543 gnus-treat-fill-long-lines
7544 gnus-treat-emphasize
7545 gnus-treat-highlight-headers
7546 gnus-treat-highlight-citation
7547 gnus-treat-highlight-signature
7548 gnus-treat-overstrike
7549 gnus-treat-display-xface
7550 gnus-treat-buttonize-head
7551 gnus-treat-decode-article-as-default-mime-charset))
7552 (static-if (featurep 'xemacs)
7554 (cons '(x-face-mule-delete-x-face-field
7557 (gnus-treat-display-xface
7558 (when (, x-face) gnus-treat-display-xface)))
7559 (gnus-article-prepare-mime-display)))
7560 (goto-char (if (, backward) start end))
7562 (gnus-summary-search-article-highlight-goto-x-face (point)))
7563 (setq gnus-summary-search-article-matched-data
7564 (list start end (buffer-substring start end)))
7565 (unless (eq start end);; matched text has been deleted. :-<
7566 (put-text-property start end 'face
7567 (or (find-face 'isearch)
7568 'secondary-selection))))))
7571 (defun gnus-summary-search-article (regexp &optional backward)
7572 "Search for an article containing REGEXP.
7573 Optional argument BACKWARD means do search for backward.
7574 `gnus-select-article-hook' is not called during the search."
7575 ;; We have to require this here to make sure that the following
7576 ;; dynamic binding isn't shadowed by autoloading.
7577 (require 'gnus-async)
7579 (let ((gnus-select-article-hook nil) ;Disable hook.
7580 (gnus-article-prepare-hook nil)
7581 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7582 (gnus-use-article-prefetch nil)
7583 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7584 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7585 (sum (current-buffer))
7588 (gnus-save-hidden-threads
7589 (static-if (featurep 'xemacs)
7590 (let ((gnus-inhibit-treatment t))
7591 (setq treated (eq 'old (gnus-summary-select-article)))
7593 (not (and (gnus-buffer-live-p gnus-article-buffer)
7594 (window-live-p (get-buffer-window
7595 gnus-article-buffer t)))))
7596 (gnus-summary-select-article nil t)
7597 (setq treated nil)))
7598 (let ((gnus-inhibit-treatment t)
7599 (x-face-mule-delete-x-face-field 'never))
7600 (setq treated (eq 'old (gnus-summary-select-article)))
7603 (and (gnus-buffer-live-p gnus-article-buffer)
7604 (window-live-p (get-buffer-window
7605 gnus-article-buffer t))
7606 (or (not (string-match "^\\^X-Face:" regexp))
7607 (with-current-buffer gnus-article-buffer
7608 gnus-summary-search-article-matched-data)))))
7609 (gnus-summary-select-article nil t)
7610 (setq treated nil))))
7611 (set-buffer gnus-article-buffer)
7615 (gnus-article-show-all-headers)
7616 (gnus-summary-search-article-position-point regexp backward))
7617 (goto-char (if backward (point-max) (point-min))))
7619 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7621 (re-search-backward regexp nil t)
7622 (re-search-forward regexp nil t))
7623 ;; We found the regexp.
7625 (gnus-summary-search-article-highlight-matched-text
7626 backward treated (string-match "^\\^X-Face:" regexp))
7629 (/ (- 2 (window-height
7630 (get-buffer-window gnus-article-buffer t)))
7633 (get-buffer-window (current-buffer))
7636 (setq point (point)))
7637 ;; We didn't find it, so we go to the next article.
7640 (while (eq found 'not)
7641 (if (not (if backward (gnus-summary-find-prev)
7642 (gnus-summary-find-next)))
7643 ;; No more articles.
7645 ;; Select the next article and adjust point.
7646 (unless (gnus-summary-article-sparse-p
7647 (gnus-summary-article-number))
7649 (let ((gnus-inhibit-treatment t))
7650 (gnus-summary-select-article))
7652 (set-buffer gnus-article-buffer)
7654 (goto-char (if backward (point-max) (point-min))))))))
7655 (gnus-message 7 ""))
7656 ;; Return whether we found the regexp.
7657 (when (eq found 'found)
7659 (gnus-summary-show-thread)
7660 (gnus-summary-goto-subject gnus-current-article)
7661 (gnus-summary-position-point)
7664 (defun gnus-find-matching-articles (header regexp)
7665 "Return a list of all articles that match REGEXP on HEADER.
7666 This search includes all articles in the current group that Gnus has
7667 fetched headers for, whether they are displayed or not."
7668 (let ((articles nil)
7669 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7670 (case-fold-search t))
7671 (dolist (header gnus-newsgroup-headers)
7672 (when (string-match regexp (funcall func header))
7673 (push (mail-header-number header) articles)))
7674 (nreverse articles)))
7676 (defun gnus-summary-find-matching (header regexp &optional backward unread
7678 "Return a list of all articles that match REGEXP on HEADER.
7679 The search stars on the current article and goes forwards unless
7680 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7681 If UNREAD is non-nil, only unread articles will
7682 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7683 in the comparisons."
7684 (let ((case-fold-search (not not-case-fold))
7687 (if (eq (car header) 'extra)
7690 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7692 (error "%s is an invalid header" header))
7693 (unless (fboundp (intern (concat "mail-header-" header)))
7694 (error "%s is not a valid header" header))
7695 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7696 (dolist (d (if (eq backward 'all)
7698 (gnus-data-find-list
7699 (gnus-summary-article-number)
7700 (gnus-data-list backward))))
7701 (when (and (or (not unread) ; We want all articles...
7702 (gnus-data-unread-p d)) ; Or just unreads.
7703 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7704 (string-match regexp
7705 (funcall func (gnus-data-header d)))) ; Match.
7706 (push (gnus-data-number d) articles))) ; Success!
7707 (nreverse articles)))
7709 (defun gnus-summary-execute-command (header regexp command &optional backward)
7710 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7711 If HEADER is an empty string (or nil), the match is done on the entire
7712 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7714 (list (let ((completion-ignore-case t))
7717 (mapcar (lambda (header) (list (format "%s" header)))
7719 '("Number" "Subject" "From" "Lines" "Date"
7720 "Message-ID" "Xref" "References" "Body")
7721 gnus-extra-headers))
7722 nil 'require-match))
7723 (read-string "Regexp: ")
7724 (read-key-sequence "Command: ")
7725 current-prefix-arg))
7726 (when (equal header "Body")
7728 ;; Hidden thread subtrees must be searched as well.
7729 (gnus-summary-show-all-threads)
7730 ;; We don't want to change current point nor window configuration.
7732 (save-window-excursion
7733 (gnus-message 6 "Executing %s..." (key-description command))
7734 ;; We'd like to execute COMMAND interactively so as to give arguments.
7735 (gnus-execute header regexp
7736 `(call-interactively ',(key-binding command))
7738 (gnus-message 6 "Executing %s...done" (key-description command)))))
7740 (defun gnus-summary-beginning-of-article ()
7741 "Scroll the article back to the beginning."
7743 (gnus-summary-select-article)
7744 (gnus-configure-windows 'article)
7745 (gnus-eval-in-buffer-window gnus-article-buffer
7747 (goto-char (point-min))
7748 (when gnus-page-broken
7749 (gnus-narrow-to-page))))
7751 (defun gnus-summary-end-of-article ()
7752 "Scroll to the end of the article."
7754 (gnus-summary-select-article)
7755 (gnus-configure-windows 'article)
7756 (gnus-eval-in-buffer-window gnus-article-buffer
7758 (goto-char (point-max))
7760 (when gnus-page-broken
7761 (gnus-narrow-to-page))))
7763 (defun gnus-summary-print-article (&optional filename n)
7764 "Generate and print a PostScript image of the N next (mail) articles.
7766 If N is negative, print the N previous articles. If N is nil and articles
7767 have been marked with the process mark, print these instead.
7769 If the optional first argument FILENAME is nil, send the image to the
7770 printer. If FILENAME is a string, save the PostScript image in a file with
7771 that name. If FILENAME is a number, prompt the user for the name of the file
7773 (interactive (list (ps-print-preprint current-prefix-arg)))
7774 (dolist (article (gnus-summary-work-articles n))
7775 (gnus-summary-select-article nil nil 'pseudo article)
7776 (gnus-eval-in-buffer-window gnus-article-buffer
7777 (let ((buffer (generate-new-buffer " *print*")))
7780 (copy-to-buffer buffer (point-min) (point-max))
7782 (gnus-article-delete-invisible-text)
7783 (when (gnus-visual-p 'article-highlight 'highlight)
7784 ;; Copy-to-buffer doesn't copy overlay. So redo
7786 (let ((gnus-article-buffer buffer))
7787 (gnus-article-highlight-citation t)
7788 (gnus-article-highlight-signature)))
7789 (let ((ps-left-header
7792 (mail-header-subject gnus-current-headers) ")")
7794 (mail-header-from gnus-current-headers) ")")))
7797 "/pagenumberstring load"
7799 (mail-header-date gnus-current-headers) ")"))))
7800 (gnus-run-hooks 'gnus-ps-print-hook)
7803 (ps-spool-buffer-with-faces)
7804 (ps-spool-buffer)))))
7805 (kill-buffer buffer))))
7806 (gnus-summary-remove-process-mark article))
7807 (ps-despool filename))
7809 (defun gnus-summary-show-article (&optional arg)
7810 "Force re-fetching of the current article.
7811 If ARG (the prefix) is a number, show the article with the charset
7812 defined in `gnus-summary-show-article-charset-alist', or the charset
7814 If ARG (the prefix) is non-nil and not a number, show the raw article
7815 without any article massaging functions being run."
7819 (let ((gnus-newsgroup-charset
7820 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7821 (mm-read-coding-system "Charset: ")))
7822 (gnus-newsgroup-ignored-charsets 'gnus-all))
7823 (gnus-summary-select-article nil 'force)
7824 (let ((deps gnus-newsgroup-dependencies)
7827 (set-buffer gnus-original-article-buffer)
7829 (message-narrow-to-head)
7830 (setq head (buffer-string)))
7832 (insert (format "211 %d Article retrieved.\n"
7833 (cdr gnus-article-current)))
7836 (let ((nntp-server-buffer (current-buffer)))
7837 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7838 (gnus-data-set-header
7839 (gnus-data-find (cdr gnus-article-current))
7841 (gnus-summary-update-article-line
7842 (cdr gnus-article-current) header))))
7844 ;; Select the article the normal way.
7845 (gnus-summary-select-article nil 'force))
7847 ;; We have to require this here to make sure that the following
7848 ;; dynamic binding isn't shadowed by autoloading.
7849 (require 'gnus-async)
7851 ;; Bind the article treatment functions to nil.
7852 (let ((gnus-have-all-headers t)
7853 gnus-article-prepare-hook
7854 gnus-article-decode-hook
7857 (gnus-inhibit-treatment t))
7858 (gnus-summary-select-article nil 'force))))
7859 (gnus-summary-goto-subject gnus-current-article)
7860 (gnus-summary-position-point))
7862 (defun gnus-summary-show-raw-article ()
7863 "Show the raw article without any article massaging functions being run."
7865 (gnus-summary-show-article t))
7867 (defun gnus-summary-verbose-headers (&optional arg)
7868 "Toggle permanent full header display.
7869 If ARG is a positive number, turn header display on.
7870 If ARG is a negative number, turn header display off."
7872 (setq gnus-show-all-headers
7873 (cond ((or (not (numberp arg))
7875 (not gnus-show-all-headers))
7878 (gnus-summary-show-article))
7880 (defun gnus-summary-toggle-header (&optional arg)
7881 "Show the headers if they are hidden, or hide them if they are shown.
7882 If ARG is a positive number, show the entire header.
7883 If ARG is a negative number, hide the unwanted header lines."
7886 (set-buffer gnus-article-buffer)
7888 (let* ((buffer-read-only nil)
7889 (inhibit-point-motion-hooks t)
7895 (article-narrow-to-head)
7896 (gnus-article-hidden-text-p 'headers))))
7897 (goto-char (point-min))
7898 (when (search-forward "\n\n" nil t)
7899 (delete-region (point-min) (1- (point))))
7900 (goto-char (point-min))
7902 (set-buffer gnus-original-article-buffer)
7903 (goto-char (point-min))
7904 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7905 (insert-buffer-substring gnus-original-article-buffer 1 e)
7907 (narrow-to-region (point-min) (point))
7908 (article-decode-encoded-words)
7910 (let ((gnus-treat-hide-headers nil)
7911 (gnus-treat-hide-boring-headers nil))
7912 (setq gnus-article-wash-types
7913 (delq 'headers gnus-article-wash-types))
7914 (gnus-treat-article 'head))
7915 (gnus-treat-article 'head)))
7916 (gnus-set-mode-line 'article)))))
7918 (defun gnus-summary-show-all-headers ()
7919 "Make all header lines visible."
7921 (gnus-summary-toggle-header 1))
7923 (defun gnus-summary-toggle-mime (&optional arg)
7924 "Toggle MIME processing.
7925 If ARG is a positive number, turn MIME processing on."
7927 (setq gnus-show-mime
7929 (not gnus-show-mime)
7930 (> (prefix-numeric-value arg) 0)))
7931 (gnus-summary-select-article t 'force))
7933 (defun gnus-summary-caesar-message (&optional arg)
7934 "Caesar rotate the current article by 13.
7935 The numerical prefix specifies how many places to rotate each letter
7938 (gnus-summary-select-article)
7939 (let ((mail-header-separator ""))
7940 (gnus-eval-in-buffer-window gnus-article-buffer
7943 (let ((start (window-start))
7945 (message-caesar-buffer-body arg)
7946 (set-window-start (get-buffer-window (current-buffer)) start))))))
7948 (defun gnus-summary-stop-page-breaking ()
7949 "Stop page breaking in the current article."
7951 (gnus-summary-select-article)
7952 (gnus-eval-in-buffer-window gnus-article-buffer
7954 (when (gnus-visual-p 'page-marker)
7955 (let ((buffer-read-only nil))
7956 (gnus-remove-text-with-property 'gnus-prev)
7957 (gnus-remove-text-with-property 'gnus-next))
7958 (setq gnus-page-broken nil))))
7960 (defun gnus-summary-move-article (&optional n to-newsgroup
7961 select-method action)
7962 "Move the current article to a different newsgroup.
7963 If N is a positive number, move the N next articles.
7964 If N is a negative number, move the N previous articles.
7965 If N is nil and any articles have been marked with the process mark,
7966 move those articles instead.
7967 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7968 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7969 re-spool using this method.
7971 For this function to work, both the current newsgroup and the
7972 newsgroup that you want to move to have to support the `request-move'
7973 and `request-accept' functions.
7975 ACTION can be either `move' (the default), `crosspost' or `copy'."
7978 (setq action 'move))
7979 ;; Disable marking as read.
7980 (let (gnus-mark-article-hook)
7981 (save-window-excursion
7982 (gnus-summary-select-article)))
7983 ;; Check whether the source group supports the required functions.
7984 (cond ((and (eq action 'move)
7985 (not (gnus-check-backend-function
7986 'request-move-article gnus-newsgroup-name)))
7987 (error "The current group does not support article moving"))
7988 ((and (eq action 'crosspost)
7989 (not (gnus-check-backend-function
7990 'request-replace-article gnus-newsgroup-name)))
7991 (error "The current group does not support article editing")))
7992 (let ((articles (gnus-summary-work-articles n))
7993 (prefix (if (gnus-check-backend-function
7994 'request-move-article gnus-newsgroup-name)
7995 (gnus-group-real-prefix gnus-newsgroup-name)
7997 (names '((move "Move" "Moving")
7998 (copy "Copy" "Copying")
7999 (crosspost "Crosspost" "Crossposting")))
8000 (copy-buf (save-excursion
8001 (nnheader-set-temp-buffer " *copy article*")))
8002 (default-marks gnus-article-mark-lists)
8003 (no-expire-marks (delete '(expirable . expire)
8004 (copy-sequence gnus-article-mark-lists)))
8005 art-group to-method new-xref article to-groups)
8006 (unless (assq action names)
8007 (error "Unknown action %s" action))
8008 ;; Read the newsgroup name.
8009 (when (and (not to-newsgroup)
8010 (not select-method))
8012 (gnus-read-move-group-name
8013 (cadr (assq action names))
8014 (symbol-value (intern (format "gnus-current-%s-group" action)))
8016 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8017 (setq to-method (or select-method
8018 (gnus-server-to-method
8019 (gnus-group-method to-newsgroup))))
8020 ;; Check the method we are to move this article to...
8021 (unless (gnus-check-backend-function
8022 'request-accept-article (car to-method))
8023 (error "%s does not support article copying" (car to-method)))
8024 (unless (gnus-check-server to-method)
8025 (error "Can't open server %s" (car to-method)))
8026 (gnus-message 6 "%s to %s: %s..."
8027 (caddr (assq action names))
8028 (or (car select-method) to-newsgroup) articles)
8030 (setq article (pop articles))
8034 ;; Move the article.
8036 ;; Remove this article from future suppression.
8037 (gnus-dup-unsuppress-article article)
8038 (gnus-request-move-article
8039 article ; Article to move
8040 gnus-newsgroup-name ; From newsgroup
8041 (nth 1 (gnus-find-method-for-group
8042 gnus-newsgroup-name)) ; Server
8043 (list 'gnus-request-accept-article
8044 to-newsgroup (list 'quote select-method)
8045 (not articles) t) ; Accept form
8046 (not articles))) ; Only save nov last time
8047 ;; Copy the article.
8050 (set-buffer copy-buf)
8051 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8052 (gnus-request-accept-article
8053 to-newsgroup select-method (not articles) t))))
8054 ;; Crosspost the article.
8055 ((eq action 'crosspost)
8056 (let ((xref (message-tokenize-header
8057 (mail-header-xref (gnus-summary-article-header article))
8059 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8062 (setq xref (list (system-name))))
8065 (mapconcat 'identity
8066 (delete "Xref:" (delete new-xref xref))
8070 (set-buffer copy-buf)
8071 ;; First put the article in the destination group.
8072 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8073 (when (consp (setq art-group
8074 (gnus-request-accept-article
8075 to-newsgroup select-method (not articles))))
8076 (setq new-xref (concat new-xref " " (car art-group)
8077 ":" (cdr art-group)))
8078 ;; Now we have the new Xrefs header, so we insert
8079 ;; it and replace the new article.
8080 (nnheader-replace-header "Xref" new-xref)
8081 (gnus-request-replace-article
8082 (cdr art-group) to-newsgroup (current-buffer))
8086 (gnus-message 1 "Couldn't %s article %s: %s"
8087 (cadr (assq action names)) article
8088 (nnheader-get-report (car to-method))))
8089 ((eq art-group 'junk)
8090 (when (eq action 'move)
8091 (gnus-summary-mark-article article gnus-canceled-mark)
8092 (gnus-message 4 "Deleted article %s" article)))
8094 (let* ((pto-group (gnus-group-prefixed-name
8095 (car art-group) to-method))
8097 (gnus-gethash pto-group gnus-newsrc-hashtb))
8098 (info (nth 2 entry))
8099 (to-group (gnus-info-group info))
8101 ;; Update the group that has been moved to.
8103 (memq action '(move copy)))
8104 (unless (member to-group to-groups)
8105 (push to-group to-groups))
8107 (unless (memq article gnus-newsgroup-unreads)
8108 (push 'read to-marks)
8110 info (gnus-add-to-range (gnus-info-read info)
8111 (list (cdr art-group)))))
8113 ;; See whether the article is to be put in the cache.
8114 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8117 (to-article (cdr art-group)))
8119 ;; Enter the article into the cache in the new group,
8120 ;; if that is required.
8121 (when gnus-use-cache
8122 (gnus-cache-possibly-enter-article
8124 (let ((header (copy-sequence
8125 (gnus-summary-article-header article))))
8126 (mail-header-set-number header to-article)
8128 (memq article gnus-newsgroup-marked)
8129 (memq article gnus-newsgroup-dormant)
8130 (memq article gnus-newsgroup-unreads)))
8132 (when gnus-preserve-marks
8133 ;; Copy any marks over to the new group.
8134 (when (and (equal to-group gnus-newsgroup-name)
8135 (not (memq article gnus-newsgroup-unreads)))
8136 ;; Mark this article as read in this group.
8137 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8138 (setcdr (gnus-active to-group) to-article)
8139 (setcdr gnus-newsgroup-active to-article))
8142 (when (memq article (symbol-value
8143 (intern (format "gnus-newsgroup-%s"
8145 (push (cdar marks) to-marks)
8146 ;; If the other group is the same as this group,
8147 ;; then we have to add the mark to the list.
8148 (when (equal to-group gnus-newsgroup-name)
8149 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8152 (intern (format "gnus-newsgroup-%s"
8154 ;; Copy the marks to other group.
8155 (gnus-add-marked-articles
8156 to-group (cdar marks) (list to-article) info))
8157 (setq marks (cdr marks)))
8159 (gnus-request-set-mark to-group (list (list (list to-article)
8164 (concat "(gnus-group-set-info '"
8165 (gnus-prin1-to-string (gnus-get-info to-group))
8168 ;; Update the Xref header in this article to point to
8169 ;; the new crossposted article we have just created.
8170 (when (eq action 'crosspost)
8172 (set-buffer copy-buf)
8173 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8174 (nnheader-replace-header "Xref" new-xref)
8175 (gnus-request-replace-article
8176 article gnus-newsgroup-name (current-buffer)))))
8178 ;;;!!!Why is this necessary?
8179 (set-buffer gnus-summary-buffer)
8181 (gnus-summary-goto-subject article)
8182 (when (eq action 'move)
8183 (gnus-summary-mark-article article gnus-canceled-mark))))
8184 (gnus-summary-remove-process-mark article))
8185 ;; Re-activate all groups that have been moved to.
8188 (set-buffer gnus-group-buffer)
8189 (when (gnus-group-goto-group (car to-groups) t)
8190 (gnus-group-get-new-news-this-group 1 t))
8193 (gnus-kill-buffer copy-buf)
8194 (gnus-summary-position-point)
8195 (gnus-set-mode-line 'summary)))
8197 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8198 "Move the current article to a different newsgroup.
8199 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8200 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8201 re-spool using this method."
8203 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8205 (defun gnus-summary-crosspost-article (&optional n)
8206 "Crosspost the current article to some other group."
8208 (gnus-summary-move-article n nil nil 'crosspost))
8210 (defcustom gnus-summary-respool-default-method nil
8211 "Default method for respooling an article.
8212 If nil, use to the current newsgroup method."
8213 :type '(choice (gnus-select-method :value (nnml ""))
8215 :group 'gnus-summary-mail)
8217 (defun gnus-summary-respool-article (&optional n method)
8218 "Respool the current article.
8219 The article will be squeezed through the mail spooling process again,
8220 which means that it will be put in some mail newsgroup or other
8221 depending on `nnmail-split-methods'.
8222 If N is a positive number, respool the N next articles.
8223 If N is a negative number, respool the N previous articles.
8224 If N is nil and any articles have been marked with the process mark,
8225 respool those articles instead.
8227 Respooling can be done both from mail groups and \"real\" newsgroups.
8228 In the former case, the articles in question will be moved from the
8229 current group into whatever groups they are destined to. In the
8230 latter case, they will be copied into the relevant groups."
8232 (list current-prefix-arg
8233 (let* ((methods (gnus-methods-using 'respool))
8235 (symbol-name (or gnus-summary-respool-default-method
8236 (car (gnus-find-method-for-group
8237 gnus-newsgroup-name)))))
8239 (gnus-completing-read
8240 methname "What backend do you want to use when respooling?"
8241 methods nil t nil 'gnus-mail-method-history))
8244 ((zerop (length (setq ms (gnus-servers-using-backend
8246 (list (intern method) ""))
8250 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8251 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8254 (error "No method given for respooling"))
8255 (if (assoc (symbol-name
8256 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8257 (gnus-methods-using 'respool))
8258 (gnus-summary-move-article n nil method)
8259 (gnus-summary-copy-article n nil method)))
8261 (defun gnus-summary-import-article (file &optional edit)
8262 "Import an arbitrary file into a mail newsgroup."
8263 (interactive "fImport file: \nP")
8264 (let ((group gnus-newsgroup-name)
8265 (now (current-time))
8266 atts lines group-art)
8267 (unless (gnus-check-backend-function 'request-accept-article group)
8268 (error "%s does not support article importing" group))
8269 (or (file-readable-p file)
8270 (not (file-regular-p file))
8271 (error "Can't read %s" file))
8273 (set-buffer (gnus-get-buffer-create " *import file*"))
8275 (nnheader-insert-file-contents file)
8276 (goto-char (point-min))
8277 (if (nnheader-article-p)
8279 (goto-char (point-min))
8280 (search-forward "\n\n" nil t)
8281 (narrow-to-region (point-min) (1- (point)))
8282 (goto-char (point-min))
8283 (unless (re-search-forward "^date:" nil t)
8284 (goto-char (point-max))
8285 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8286 ;; This doesn't look like an article, so we fudge some headers.
8287 (setq atts (file-attributes file)
8288 lines (count-lines (point-min) (point-max)))
8289 (insert "From: " (read-string "From: ") "\n"
8290 "Subject: " (read-string "Subject: ") "\n"
8291 "Date: " (message-make-date (nth 5 atts)) "\n"
8292 "Message-ID: " (message-make-message-id) "\n"
8293 "Lines: " (int-to-string lines) "\n"
8294 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8295 (setq group-art (gnus-request-accept-article group nil t))
8296 (kill-buffer (current-buffer)))
8297 (setq gnus-newsgroup-active (gnus-activate-group group))
8299 (gnus-summary-goto-article (cdr group-art) nil t)
8301 (gnus-summary-edit-article))))
8303 (defun gnus-summary-create-article ()
8304 "Create an article in a mail newsgroup."
8306 (let ((group gnus-newsgroup-name)
8307 (now (current-time))
8309 (unless (gnus-check-backend-function 'request-accept-article group)
8310 (error "%s does not support article importing" group))
8312 (set-buffer (gnus-get-buffer-create " *import file*"))
8314 (goto-char (point-min))
8315 ;; This doesn't look like an article, so we fudge some headers.
8316 (insert "From: " (read-string "From: ") "\n"
8317 "Subject: " (read-string "Subject: ") "\n"
8318 "Date: " (message-make-date now) "\n"
8319 "Message-ID: " (message-make-message-id) "\n")
8320 (setq group-art (gnus-request-accept-article group nil t))
8321 (kill-buffer (current-buffer)))
8322 (setq gnus-newsgroup-active (gnus-activate-group group))
8324 (gnus-summary-goto-article (cdr group-art) nil t)
8325 (gnus-summary-edit-article)))
8327 (defun gnus-summary-article-posted-p ()
8328 "Say whether the current (mail) article is available from news as well.
8329 This will be the case if the article has both been mailed and posted."
8331 (let ((id (mail-header-references (gnus-summary-article-header)))
8332 (gnus-override-method (car (gnus-refer-article-methods))))
8333 (if (gnus-request-head id "")
8334 (gnus-message 2 "The current message was found on %s"
8335 gnus-override-method)
8336 (gnus-message 2 "The current message couldn't be found on %s"
8337 gnus-override-method)
8340 (defun gnus-summary-expire-articles (&optional now)
8341 "Expire all articles that are marked as expirable in the current group."
8343 (when (gnus-check-backend-function
8344 'request-expire-articles gnus-newsgroup-name)
8345 ;; This backend supports expiry.
8346 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8347 (expirable (if total
8349 ;; We need to update the info for
8350 ;; this group for `gnus-list-of-read-articles'
8351 ;; to give us the right answer.
8352 (gnus-run-hooks 'gnus-exit-group-hook)
8353 (gnus-summary-update-info)
8354 (gnus-list-of-read-articles gnus-newsgroup-name))
8355 (setq gnus-newsgroup-expirable
8356 (sort gnus-newsgroup-expirable '<))))
8357 (expiry-wait (if now 'immediate
8358 (gnus-group-find-parameter
8359 gnus-newsgroup-name 'expiry-wait)))
8360 (nnmail-expiry-target
8361 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8362 nnmail-expiry-target))
8365 ;; There are expirable articles in this group, so we run them
8366 ;; through the expiry process.
8367 (gnus-message 6 "Expiring articles...")
8368 (unless (gnus-check-group gnus-newsgroup-name)
8369 (error "Can't open server for %s" gnus-newsgroup-name))
8370 ;; The list of articles that weren't expired is returned.
8373 (let ((nnmail-expiry-wait-function nil)
8374 (nnmail-expiry-wait expiry-wait))
8375 (setq es (gnus-request-expire-articles
8376 expirable gnus-newsgroup-name)))
8377 (setq es (gnus-request-expire-articles
8378 expirable gnus-newsgroup-name)))
8380 (setq gnus-newsgroup-expirable es))
8381 ;; We go through the old list of expirable, and mark all
8382 ;; really expired articles as nonexistent.
8383 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8384 (let ((gnus-use-cache nil))
8386 (unless (memq (car expirable) es)
8387 (when (gnus-data-find (car expirable))
8388 (gnus-summary-mark-article
8389 (car expirable) gnus-canceled-mark)))
8390 (setq expirable (cdr expirable))))))
8391 (gnus-message 6 "Expiring articles...done")))))
8393 (defun gnus-summary-expire-articles-now ()
8394 "Expunge all expirable articles in the current group.
8395 This means that *all* articles that are marked as expirable will be
8396 deleted forever, right now."
8398 (or gnus-expert-user
8400 "Are you really, really, really sure you want to delete all these messages? ")
8402 (gnus-summary-expire-articles t))
8404 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8405 (defun gnus-summary-delete-article (&optional n)
8406 "Delete the N next (mail) articles.
8407 This command actually deletes articles. This is not a marking
8408 command. The article will disappear forever from your life, never to
8410 If N is negative, delete backwards.
8411 If N is nil and articles have been marked with the process mark,
8412 delete these instead."
8414 (unless (gnus-check-backend-function 'request-expire-articles
8415 gnus-newsgroup-name)
8416 (error "The current newsgroup does not support article deletion"))
8417 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8418 (error "Couldn't open server"))
8419 ;; Compute the list of articles to delete.
8420 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8422 (if (and gnus-novice-user
8423 (not (gnus-yes-or-no-p
8424 (format "Do you really want to delete %s forever? "
8425 (if (> (length articles) 1)
8426 (format "these %s articles" (length articles))
8429 ;; Delete the articles.
8430 (setq not-deleted (gnus-request-expire-articles
8431 articles gnus-newsgroup-name 'force))
8433 (gnus-summary-remove-process-mark (car articles))
8434 ;; The backend might not have been able to delete the article
8436 (unless (memq (car articles) not-deleted)
8437 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8438 (setq articles (cdr articles)))
8440 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8441 (gnus-summary-position-point)
8442 (gnus-set-mode-line 'summary)
8445 (defun gnus-summary-edit-article (&optional force)
8446 "Edit the current article.
8447 This will have permanent effect only in mail groups.
8448 If FORCE is non-nil, allow editing of articles even in read-only
8452 (set-buffer gnus-summary-buffer)
8453 (let ((mail-parse-charset gnus-newsgroup-charset)
8454 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8455 (gnus-set-global-variables)
8456 (when (and (not force)
8457 (gnus-group-read-only-p))
8458 (error "The current newsgroup does not support article editing"))
8459 (gnus-summary-show-article t)
8460 (gnus-article-edit-article
8462 `(lambda (no-highlight)
8463 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8464 (message-options message-options)
8465 (message-options-set-recipient)
8466 (mail-parse-ignored-charsets
8467 ',gnus-newsgroup-ignored-charsets))
8468 (gnus-summary-edit-article-done
8469 ,(or (mail-header-references gnus-current-headers) "")
8470 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8472 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8474 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8476 "Make edits to the current article permanent."
8479 ;; The buffer restriction contains the entire article if it exists.
8480 (when (article-goto-body)
8481 (let ((lines (count-lines (point) (point-max)))
8482 (length (- (point-max) (point)))
8483 (case-fold-search t)
8484 (body (copy-marker (point))))
8485 (goto-char (point-min))
8486 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8487 (delete-region (match-beginning 1) (match-end 1))
8488 (insert (number-to-string length)))
8489 (goto-char (point-min))
8490 (when (re-search-forward
8491 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8492 (delete-region (match-beginning 1) (match-end 1))
8493 (insert (number-to-string length)))
8494 (goto-char (point-min))
8495 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8496 (delete-region (match-beginning 1) (match-end 1))
8497 (insert (number-to-string lines))))))
8498 ;; Replace the article.
8499 (let ((buf (current-buffer)))
8501 (insert-buffer-substring buf)
8503 (if (and (not read-only)
8504 (not (gnus-request-replace-article
8505 (cdr gnus-article-current) (car gnus-article-current)
8506 (current-buffer) t)))
8507 (error "Couldn't replace article")
8508 ;; Update the summary buffer.
8510 (equal (message-tokenize-header references " ")
8511 (message-tokenize-header
8512 (or (message-fetch-field "references") "") " ")))
8513 ;; We only have to update this line.
8516 (message-narrow-to-head)
8517 (let ((head (buffer-string))
8520 (insert (format "211 %d Article retrieved.\n"
8521 (cdr gnus-article-current)))
8524 (let ((nntp-server-buffer (current-buffer)))
8525 (setq header (car (gnus-get-newsgroup-headers
8527 (set-buffer gnus-summary-buffer)
8528 gnus-newsgroup-dependencies)
8531 (set-buffer gnus-summary-buffer)
8532 (gnus-data-set-header
8533 (gnus-data-find (cdr gnus-article-current))
8535 (gnus-summary-update-article-line
8536 (cdr gnus-article-current) header))))))
8538 (set-buffer (or buffer gnus-summary-buffer))
8539 (gnus-summary-update-article (cdr gnus-article-current)))
8540 ;; Prettify the article buffer again.
8541 (unless no-highlight
8543 (set-buffer gnus-article-buffer)
8544 ;;;!!! Fix this -- article should be rehighlighted.
8545 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8546 (set-buffer gnus-original-article-buffer)
8547 (gnus-request-article
8548 (cdr gnus-article-current)
8549 (car gnus-article-current) (current-buffer))))
8550 ;; Prettify the summary buffer line.
8551 (when (gnus-visual-p 'summary-highlight 'highlight)
8552 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8554 (defun gnus-summary-edit-wash (key)
8555 "Perform editing command KEY in the article buffer."
8559 (message "%s" (concat (this-command-keys) "- "))
8562 (gnus-summary-edit-article)
8563 (execute-kbd-macro (concat (this-command-keys) key))
8564 (gnus-article-edit-done))
8568 (defun gnus-summary-respool-query (&optional silent trace)
8569 "Query where the respool algorithm would put this article."
8571 (let (gnus-mark-article-hook)
8572 (gnus-summary-select-article)
8574 (set-buffer gnus-original-article-buffer)
8576 (message-narrow-to-head)
8577 (let ((groups (nnmail-article-group 'identity trace)))
8580 (message "This message would go to %s"
8581 (mapconcat 'car groups ", "))
8582 (message "This message would go to no groups"))
8585 (defun gnus-summary-respool-trace ()
8586 "Trace where the respool algorithm would put this article.
8587 Display a buffer showing all fancy splitting patterns which matched."
8589 (gnus-summary-respool-query nil t))
8591 ;; Summary marking commands.
8593 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8594 "Mark articles which has the same subject as read, and then select the next.
8595 If UNMARK is positive, remove any kind of mark.
8596 If UNMARK is negative, tick articles."
8599 (setq unmark (prefix-numeric-value unmark)))
8601 (gnus-summary-mark-same-subject
8602 (gnus-summary-article-subject) unmark)))
8603 ;; Select next unread article. If auto-select-same mode, should
8604 ;; select the first unread article.
8605 (gnus-summary-next-article t (and gnus-auto-select-same
8606 (gnus-summary-article-subject)))
8607 (gnus-message 7 "%d article%s marked as %s"
8608 count (if (= count 1) " is" "s are")
8609 (if unmark "unread" "read"))))
8611 (defun gnus-summary-kill-same-subject (&optional unmark)
8612 "Mark articles which has the same subject as read.
8613 If UNMARK is positive, remove any kind of mark.
8614 If UNMARK is negative, tick articles."
8617 (setq unmark (prefix-numeric-value unmark)))
8619 (gnus-summary-mark-same-subject
8620 (gnus-summary-article-subject) unmark)))
8621 ;; If marked as read, go to next unread subject.
8623 ;; Go to next unread subject.
8624 (gnus-summary-next-subject 1 t))
8625 (gnus-message 7 "%d articles are marked as %s"
8626 count (if unmark "unread" "read"))))
8628 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8629 "Mark articles with same SUBJECT as read, and return marked number.
8630 If optional argument UNMARK is positive, remove any kinds of marks.
8631 If optional argument UNMARK is negative, mark articles as unread instead."
8635 ((null unmark) ; Mark as read.
8638 (gnus-summary-mark-article-as-read gnus-killed-mark)
8639 (gnus-summary-show-thread) t)
8640 (gnus-summary-find-subject subject))
8641 (setq count (1+ count))))
8642 ((> unmark 0) ; Tick.
8645 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8646 (gnus-summary-show-thread) t)
8647 (gnus-summary-find-subject subject))
8648 (setq count (1+ count))))
8649 (t ; Mark as unread.
8652 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8653 (gnus-summary-show-thread) t)
8654 (gnus-summary-find-subject subject))
8655 (setq count (1+ count)))))
8656 (gnus-set-mode-line 'summary)
8657 ;; Return the number of marked articles.
8660 (defun gnus-summary-mark-as-processable (n &optional unmark)
8661 "Set the process mark on the next N articles.
8662 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8663 the process mark instead. The difference between N and the actual
8664 number of articles marked is returned."
8666 (if (and (null n) (gnus-region-active-p))
8667 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8668 (setq n (prefix-numeric-value n))
8669 (let ((backward (< n 0))
8674 (gnus-summary-remove-process-mark
8675 (gnus-summary-article-number))
8676 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8677 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8680 (gnus-message 7 "No more articles"))
8681 (gnus-summary-recenter)
8682 (gnus-summary-position-point)
8685 (defun gnus-summary-unmark-as-processable (n)
8686 "Remove the process mark from the next N articles.
8687 If N is negative, unmark backward instead. The difference between N and
8688 the actual number of articles unmarked is returned."
8690 (gnus-summary-mark-as-processable n t))
8692 (defun gnus-summary-unmark-all-processable ()
8693 "Remove the process mark from all articles."
8696 (while gnus-newsgroup-processable
8697 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8698 (gnus-summary-position-point))
8700 (defun gnus-summary-add-mark (article type)
8701 "Mark ARTICLE with a mark of TYPE."
8702 (let ((vtype (car (assq type gnus-article-mark-lists)))
8705 (error "No such mark type: %s" type)
8706 (setq var (intern (format "gnus-newsgroup-%s" type)))
8707 (set var (cons article (symbol-value var)))
8708 (if (memq type '(processable cached replied forwarded saved))
8709 (gnus-summary-update-secondary-mark article)
8710 ;;; !!! This is bobus. We should find out what primary
8711 ;;; !!! mark we want to set.
8712 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8714 (defun gnus-summary-mark-as-expirable (n)
8715 "Mark N articles forward as expirable.
8716 If N is negative, mark backward instead. The difference between N and
8717 the actual number of articles marked is returned."
8719 (gnus-summary-mark-forward n gnus-expirable-mark))
8721 (defun gnus-summary-mark-article-as-replied (article)
8722 "Mark ARTICLE as replied to and update the summary line.
8723 ARTICLE can also be a list of articles."
8724 (interactive (list (gnus-summary-article-number)))
8725 (let ((articles (if (listp article) article (list article))))
8726 (dolist (article articles)
8727 (push article gnus-newsgroup-replied)
8728 (let ((buffer-read-only nil))
8729 (when (gnus-summary-goto-subject article nil t)
8730 (gnus-summary-update-secondary-mark article))))))
8732 (defun gnus-summary-mark-article-as-forwarded (article)
8733 "Mark ARTICLE as forwarded and update the summary line.
8734 ARTICLE can also be a list of articles."
8735 (let ((articles (if (listp article) article (list article))))
8736 (dolist (article articles)
8737 (push article gnus-newsgroup-forwarded)
8738 (let ((buffer-read-only nil))
8739 (when (gnus-summary-goto-subject article nil t)
8740 (gnus-summary-update-secondary-mark article))))))
8742 (defun gnus-summary-set-bookmark (article)
8743 "Set a bookmark in current article."
8744 (interactive (list (gnus-summary-article-number)))
8745 (when (or (not (get-buffer gnus-article-buffer))
8746 (not gnus-current-article)
8747 (not gnus-article-current)
8748 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8749 (error "No current article selected"))
8750 ;; Remove old bookmark, if one exists.
8751 (let ((old (assq article gnus-newsgroup-bookmarks)))
8753 (setq gnus-newsgroup-bookmarks
8754 (delq old gnus-newsgroup-bookmarks))))
8755 ;; Set the new bookmark, which is on the form
8756 ;; (article-number . line-number-in-body).
8760 (set-buffer gnus-article-buffer)
8764 (goto-char (point-min))
8765 (search-forward "\n\n" nil t)
8768 gnus-newsgroup-bookmarks)
8769 (gnus-message 6 "A bookmark has been added to the current article."))
8771 (defun gnus-summary-remove-bookmark (article)
8772 "Remove the bookmark from the current article."
8773 (interactive (list (gnus-summary-article-number)))
8774 ;; Remove old bookmark, if one exists.
8775 (let ((old (assq article gnus-newsgroup-bookmarks)))
8778 (setq gnus-newsgroup-bookmarks
8779 (delq old gnus-newsgroup-bookmarks))
8780 (gnus-message 6 "Removed bookmark."))
8781 (gnus-message 6 "No bookmark in current article."))))
8783 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8784 (defun gnus-summary-mark-as-dormant (n)
8785 "Mark N articles forward as dormant.
8786 If N is negative, mark backward instead. The difference between N and
8787 the actual number of articles marked is returned."
8789 (gnus-summary-mark-forward n gnus-dormant-mark))
8791 (defun gnus-summary-set-process-mark (article)
8792 "Set the process mark on ARTICLE and update the summary line."
8793 (setq gnus-newsgroup-processable
8795 (delq article gnus-newsgroup-processable)))
8796 (when (gnus-summary-goto-subject article)
8797 (gnus-summary-show-thread)
8798 (gnus-summary-goto-subject article)
8799 (gnus-summary-update-secondary-mark article)))
8801 (defun gnus-summary-remove-process-mark (article)
8802 "Remove the process mark from ARTICLE and update the summary line."
8803 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8804 (when (gnus-summary-goto-subject article)
8805 (gnus-summary-show-thread)
8806 (gnus-summary-goto-subject article)
8807 (gnus-summary-update-secondary-mark article)))
8809 (defun gnus-summary-set-saved-mark (article)
8810 "Set the process mark on ARTICLE and update the summary line."
8811 (push article gnus-newsgroup-saved)
8812 (when (gnus-summary-goto-subject article)
8813 (gnus-summary-update-secondary-mark article)))
8815 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8816 "Mark N articles as read forwards.
8817 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8818 The difference between N and the actual number of articles marked is
8820 Iff NO-EXPIRE, auto-expiry will be inhibited."
8822 (gnus-summary-show-thread)
8823 (let ((backward (< n 0))
8824 (gnus-summary-goto-unread
8825 (and gnus-summary-goto-unread
8826 (not (eq gnus-summary-goto-unread 'never))
8827 (not (memq mark (list gnus-unread-mark
8828 gnus-ticked-mark gnus-dormant-mark)))))
8830 (mark (or mark gnus-del-mark)))
8832 (gnus-summary-mark-article nil mark no-expire)
8833 (zerop (gnus-summary-next-subject
8835 (and gnus-summary-goto-unread
8836 (not (eq gnus-summary-goto-unread 'never)))
8840 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8841 (gnus-summary-recenter)
8842 (gnus-summary-position-point)
8843 (gnus-set-mode-line 'summary)
8846 (defun gnus-summary-mark-article-as-read (mark)
8847 "Mark the current article quickly as read with MARK."
8848 (let ((article (gnus-summary-article-number)))
8849 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8850 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8851 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8852 (push (cons article mark) gnus-newsgroup-reads)
8853 ;; Possibly remove from cache, if that is used.
8854 (when gnus-use-cache
8855 (gnus-cache-enter-remove-article article))
8856 ;; Allow the backend to change the mark.
8857 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8858 ;; Check for auto-expiry.
8859 (when (and gnus-newsgroup-auto-expire
8860 (memq mark gnus-auto-expirable-marks))
8861 (setq mark gnus-expirable-mark)
8862 ;; Let the backend know about the mark change.
8863 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8864 (push article gnus-newsgroup-expirable))
8865 ;; Set the mark in the buffer.
8866 (gnus-summary-update-mark mark 'unread)
8869 (defun gnus-summary-mark-article-as-unread (mark)
8870 "Mark the current article quickly as unread with MARK."
8871 (let* ((article (gnus-summary-article-number))
8872 (old-mark (gnus-summary-article-mark article)))
8873 ;; Allow the backend to change the mark.
8874 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8875 (if (eq mark old-mark)
8879 (gnus-error 1 "Can't mark negative article numbers")
8881 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8882 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8883 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8884 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8885 (cond ((= mark gnus-ticked-mark)
8886 (push article gnus-newsgroup-marked))
8887 ((= mark gnus-dormant-mark)
8888 (push article gnus-newsgroup-dormant))
8890 (push article gnus-newsgroup-unreads)))
8891 (gnus-pull article gnus-newsgroup-reads)
8893 ;; See whether the article is to be put in the cache.
8895 (vectorp (gnus-summary-article-header article))
8897 (gnus-cache-possibly-enter-article
8898 gnus-newsgroup-name article
8899 (gnus-summary-article-header article)
8900 (= mark gnus-ticked-mark)
8901 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8904 (gnus-summary-update-mark mark 'unread)
8907 (defun gnus-summary-mark-article (&optional article mark no-expire)
8908 "Mark ARTICLE with MARK. MARK can be any character.
8909 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8910 `??' (dormant) and `?E' (expirable).
8911 If MARK is nil, then the default character `?r' is used.
8912 If ARTICLE is nil, then the article on the current line will be
8914 Iff NO-EXPIRE, auto-expiry will be inhibited."
8915 ;; The mark might be a string.
8916 (when (stringp mark)
8917 (setq mark (aref mark 0)))
8918 ;; If no mark is given, then we check auto-expiring.
8920 (setq mark gnus-del-mark))
8921 (when (and (not no-expire)
8922 gnus-newsgroup-auto-expire
8923 (memq mark gnus-auto-expirable-marks))
8924 (setq mark gnus-expirable-mark))
8925 (let ((article (or article (gnus-summary-article-number)))
8926 (old-mark (gnus-summary-article-mark article)))
8927 ;; Allow the backend to change the mark.
8928 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8929 (if (eq mark old-mark)
8932 (error "No article on current line"))
8933 (if (not (if (or (= mark gnus-unread-mark)
8934 (= mark gnus-ticked-mark)
8935 (= mark gnus-dormant-mark))
8936 (gnus-mark-article-as-unread article mark)
8937 (gnus-mark-article-as-read article mark)))
8939 ;; See whether the article is to be put in the cache.
8941 (not (= mark gnus-canceled-mark))
8942 (vectorp (gnus-summary-article-header article))
8944 (gnus-cache-possibly-enter-article
8945 gnus-newsgroup-name article
8946 (gnus-summary-article-header article)
8947 (= mark gnus-ticked-mark)
8948 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8950 (when (gnus-summary-goto-subject article nil t)
8951 (let ((buffer-read-only nil))
8952 (gnus-summary-show-thread)
8954 (gnus-summary-update-mark mark 'unread)
8957 (defun gnus-summary-update-secondary-mark (article)
8958 "Update the secondary (read, process, cache) mark."
8959 (gnus-summary-update-mark
8960 (cond ((memq article gnus-newsgroup-processable)
8962 ((memq article gnus-newsgroup-cached)
8964 ((memq article gnus-newsgroup-replied)
8966 ((memq article gnus-newsgroup-forwarded)
8967 gnus-forwarded-mark)
8968 ((memq article gnus-newsgroup-saved)
8972 (when (gnus-visual-p 'summary-highlight 'highlight)
8973 (gnus-run-hooks 'gnus-summary-update-hook))
8976 (defun gnus-summary-update-mark (mark type)
8977 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8978 (buffer-read-only nil))
8979 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8981 (when (looking-at "\r")
8983 (when (<= (+ forward (point)) (point-max))
8984 ;; Go to the right position on the line.
8985 (goto-char (+ forward (point)))
8986 ;; Replace the old mark with the new mark.
8987 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8988 ;; Optionally update the marks by some user rule.
8989 (when (eq type 'unread)
8991 (gnus-data-find (gnus-summary-article-number)) mark)
8992 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8994 (defun gnus-mark-article-as-read (article &optional mark)
8995 "Enter ARTICLE in the pertinent lists and remove it from others."
8996 ;; Make the article expirable.
8997 (let ((mark (or mark gnus-del-mark)))
8998 (if (= mark gnus-expirable-mark)
8999 (push article gnus-newsgroup-expirable)
9000 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9001 ;; Remove from unread and marked lists.
9002 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9003 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9004 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9005 (push (cons article mark) gnus-newsgroup-reads)
9006 ;; Possibly remove from cache, if that is used.
9007 (when gnus-use-cache
9008 (gnus-cache-enter-remove-article article))
9011 (defun gnus-mark-article-as-unread (article &optional mark)
9012 "Enter ARTICLE in the pertinent lists and remove it from others."
9013 (let ((mark (or mark gnus-ticked-mark)))
9016 (gnus-error 1 "Can't mark negative article numbers")
9018 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9019 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9020 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9021 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9023 ;; Unsuppress duplicates?
9024 (when gnus-suppress-duplicates
9025 (gnus-dup-unsuppress-article article))
9027 (cond ((= mark gnus-ticked-mark)
9028 (push article gnus-newsgroup-marked))
9029 ((= mark gnus-dormant-mark)
9030 (push article gnus-newsgroup-dormant))
9032 (push article gnus-newsgroup-unreads)))
9033 (gnus-pull article gnus-newsgroup-reads)
9036 (defalias 'gnus-summary-mark-as-unread-forward
9037 'gnus-summary-tick-article-forward)
9038 (make-obsolete 'gnus-summary-mark-as-unread-forward
9039 'gnus-summary-tick-article-forward)
9040 (defun gnus-summary-tick-article-forward (n)
9041 "Tick N articles forwards.
9042 If N is negative, tick backwards instead.
9043 The difference between N and the number of articles ticked is returned."
9045 (gnus-summary-mark-forward n gnus-ticked-mark))
9047 (defalias 'gnus-summary-mark-as-unread-backward
9048 'gnus-summary-tick-article-backward)
9049 (make-obsolete 'gnus-summary-mark-as-unread-backward
9050 'gnus-summary-tick-article-backward)
9051 (defun gnus-summary-tick-article-backward (n)
9052 "Tick N articles backwards.
9053 The difference between N and the number of articles ticked is returned."
9055 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9057 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9058 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9059 (defun gnus-summary-tick-article (&optional article clear-mark)
9060 "Mark current article as unread.
9061 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9062 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9064 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9067 (defun gnus-summary-mark-as-read-forward (n)
9068 "Mark N articles as read forwards.
9069 If N is negative, mark backwards instead.
9070 The difference between N and the actual number of articles marked is
9073 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9075 (defun gnus-summary-mark-as-read-backward (n)
9076 "Mark the N articles as read backwards.
9077 The difference between N and the actual number of articles marked is
9080 (gnus-summary-mark-forward
9081 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9083 (defun gnus-summary-mark-as-read (&optional article mark)
9084 "Mark current article as read.
9085 ARTICLE specifies the article to be marked as read.
9086 MARK specifies a string to be inserted at the beginning of the line."
9087 (gnus-summary-mark-article article mark))
9089 (defun gnus-summary-clear-mark-forward (n)
9090 "Clear marks from N articles forward.
9091 If N is negative, clear backward instead.
9092 The difference between N and the number of marks cleared is returned."
9094 (gnus-summary-mark-forward n gnus-unread-mark))
9096 (defun gnus-summary-clear-mark-backward (n)
9097 "Clear marks from N articles backward.
9098 The difference between N and the number of marks cleared is returned."
9100 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9102 (defun gnus-summary-mark-unread-as-read ()
9103 "Intended to be used by `gnus-summary-mark-article-hook'."
9104 (when (memq gnus-current-article gnus-newsgroup-unreads)
9105 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9107 (defun gnus-summary-mark-read-and-unread-as-read ()
9108 "Intended to be used by `gnus-summary-mark-article-hook'."
9109 (let ((mark (gnus-summary-article-mark)))
9110 (when (or (gnus-unread-mark-p mark)
9111 (gnus-read-mark-p mark))
9112 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9114 (defun gnus-summary-mark-unread-as-ticked ()
9115 "Intended to be used by `gnus-summary-mark-article-hook'."
9116 (when (memq gnus-current-article gnus-newsgroup-unreads)
9117 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9119 (defun gnus-summary-mark-region-as-read (point mark all)
9120 "Mark all unread articles between point and mark as read.
9121 If given a prefix, mark all articles between point and mark as read,
9122 even ticked and dormant ones."
9123 (interactive "r\nP")
9132 (memq (setq article (gnus-summary-article-number))
9133 gnus-newsgroup-unreads))
9134 (gnus-summary-mark-article article gnus-del-mark))
9136 (gnus-summary-find-next))))))
9138 (defun gnus-summary-mark-below (score mark)
9139 "Mark articles with score less than SCORE with MARK."
9140 (interactive "P\ncMark: ")
9141 (setq score (if score
9142 (prefix-numeric-value score)
9143 (or gnus-summary-default-score 0)))
9145 (set-buffer gnus-summary-buffer)
9146 (goto-char (point-min))
9149 (and (< (gnus-summary-article-score) score)
9150 (gnus-summary-mark-article nil mark))
9151 (gnus-summary-find-next)))))
9153 (defun gnus-summary-kill-below (&optional score)
9154 "Mark articles with score below SCORE as read."
9156 (gnus-summary-mark-below score gnus-killed-mark))
9158 (defun gnus-summary-clear-above (&optional score)
9159 "Clear all marks from articles with score above SCORE."
9161 (gnus-summary-mark-above score gnus-unread-mark))
9163 (defun gnus-summary-tick-above (&optional score)
9164 "Tick all articles with score above SCORE."
9166 (gnus-summary-mark-above score gnus-ticked-mark))
9168 (defun gnus-summary-mark-above (score mark)
9169 "Mark articles with score over SCORE with MARK."
9170 (interactive "P\ncMark: ")
9171 (setq score (if score
9172 (prefix-numeric-value score)
9173 (or gnus-summary-default-score 0)))
9175 (set-buffer gnus-summary-buffer)
9176 (goto-char (point-min))
9178 (when (> (gnus-summary-article-score) score)
9179 (gnus-summary-mark-article nil mark))
9181 (gnus-summary-find-next)))))
9183 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9184 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9185 (defun gnus-summary-limit-include-expunged (&optional no-error)
9186 "Display all the hidden articles that were expunged for low scores."
9188 (let ((buffer-read-only nil))
9189 (let ((scored gnus-newsgroup-scored)
9192 (unless (gnus-summary-article-header (caar scored))
9193 (and (setq h (gnus-number-to-header (caar scored)))
9194 (< (cdar scored) gnus-summary-expunge-below)
9196 (setq scored (cdr scored)))
9198 (when (not no-error)
9199 (error "No expunged articles hidden"))
9200 (goto-char (point-min))
9201 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9202 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9203 (mapcar (lambda (x) (push (mail-header-number x)
9204 gnus-newsgroup-limit))
9206 (gnus-summary-prepare-unthreaded (nreverse headers))
9207 (goto-char (point-min))
9208 (gnus-summary-position-point)
9211 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9212 "Mark all unread articles in this newsgroup as read.
9213 If prefix argument ALL is non-nil, ticked and dormant articles will
9214 also be marked as read.
9215 If QUIETLY is non-nil, no questions will be asked.
9216 If TO-HERE is non-nil, it should be a point in the buffer. All
9217 articles before (after, if REVERSE is set) this point will be marked as read.
9218 Note that this function will only catch up the unread article
9219 in the current summary buffer limitation.
9220 The number of articles marked as read is returned."
9225 (not gnus-interactive-catchup) ;Without confirmation?
9229 "Mark absolutely all articles as read? "
9230 "Mark all unread articles as read? ")))
9232 (not gnus-newsgroup-adaptive)
9233 (not gnus-newsgroup-auto-expire)
9234 (not gnus-suppress-duplicates)
9235 (or (not gnus-use-cache)
9236 (eq gnus-use-cache 'passive)))
9239 (setq gnus-newsgroup-marked nil
9240 gnus-newsgroup-dormant nil))
9241 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9242 ;; We actually mark all articles as canceled, which we
9243 ;; have to do when using auto-expiry or adaptive scoring.
9244 (gnus-summary-show-all-threads)
9245 (if (and to-here reverse)
9249 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9250 (gnus-summary-find-next (not all) nil nil t))))
9251 (when (gnus-summary-first-subject (not all) t)
9253 (if to-here (< (point) to-here) t)
9254 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9255 (gnus-summary-find-next (not all) nil nil t)))))
9256 (gnus-set-mode-line 'summary))
9258 (gnus-summary-position-point)))
9260 (defun gnus-summary-catchup-to-here (&optional all)
9261 "Mark all unticked articles before the current one as read.
9262 If ALL is non-nil, also mark ticked and dormant articles as read."
9265 (gnus-save-hidden-threads
9266 (let ((beg (point)))
9267 ;; We check that there are unread articles.
9268 (when (or all (gnus-summary-find-prev))
9269 (gnus-summary-catchup all t beg)))))
9270 (gnus-summary-position-point))
9272 (defun gnus-summary-catchup-from-here (&optional all)
9273 "Mark all unticked articles after the current one as read.
9274 If ALL is non-nil, also mark ticked and dormant articles as read."
9277 (gnus-save-hidden-threads
9278 (let ((beg (point)))
9279 ;; We check that there are unread articles.
9280 (when (or all (gnus-summary-find-next))
9281 (gnus-summary-catchup all t beg nil t)))))
9282 (gnus-summary-position-point))
9284 (defun gnus-summary-catchup-all (&optional quietly)
9285 "Mark all articles in this newsgroup as read."
9287 (gnus-summary-catchup t quietly))
9289 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9290 "Mark all unread articles in this group as read, then exit.
9291 If prefix argument ALL is non-nil, all articles are marked as read.
9292 If QUIETLY is non-nil, no questions will be asked."
9294 (when (gnus-summary-catchup all quietly nil 'fast)
9295 ;; Select next newsgroup or exit.
9296 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9297 (eq gnus-auto-select-next 'quietly))
9298 (gnus-summary-next-group nil)
9299 (gnus-summary-exit))))
9301 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9302 "Mark all articles in this newsgroup as read, and then exit."
9304 (gnus-summary-catchup-and-exit t quietly))
9306 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9307 "Mark all articles in this group as read and select the next group.
9308 If given a prefix, mark all articles, unread as well as ticked, as
9312 (gnus-summary-catchup all))
9313 (gnus-summary-next-group))
9319 (defmacro gnus-with-article (article &rest forms)
9320 "Select ARTICLE and perform FORMS in the original article buffer.
9321 Then replace the article with the result."
9323 ;; We don't want the article to be marked as read.
9324 (let (gnus-mark-article-hook)
9325 (gnus-summary-select-article t t nil ,article))
9326 (set-buffer gnus-original-article-buffer)
9328 (if (not (gnus-check-backend-function
9329 'request-replace-article (car gnus-article-current)))
9330 (gnus-message 5 "Read-only group; not replacing")
9331 (unless (gnus-request-replace-article
9332 ,article (car gnus-article-current)
9334 (error "Couldn't replace article")))
9335 ;; The cache and backlog have to be flushed somewhat.
9336 (when gnus-keep-backlog
9337 (gnus-backlog-remove-article
9338 (car gnus-article-current) (cdr gnus-article-current)))
9339 (when gnus-use-cache
9340 (gnus-cache-update-article
9341 (car gnus-article-current) (cdr gnus-article-current)))))
9343 (put 'gnus-with-article 'lisp-indent-function 1)
9344 (put 'gnus-with-article 'edebug-form-spec '(form body))
9346 ;; Thread-based commands.
9348 (defun gnus-summary-articles-in-thread (&optional article)
9349 "Return a list of all articles in the current thread.
9350 If ARTICLE is non-nil, return all articles in the thread that starts
9352 (let* ((article (or article (gnus-summary-article-number)))
9353 (data (gnus-data-find-list article))
9354 (top-level (gnus-data-level (car data)))
9356 (cond ((null gnus-thread-operation-ignore-subject)
9357 (gnus-simplify-subject-re
9358 (mail-header-subject (gnus-data-header (car data)))))
9359 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9360 (gnus-simplify-subject-fuzzy
9361 (mail-header-subject (gnus-data-header (car data)))))
9363 (end-point (save-excursion
9364 (if (gnus-summary-go-to-next-thread)
9365 (point) (point-max))))
9368 (< (gnus-data-pos (car data)) end-point))
9369 (when (or (not top-subject)
9370 (string= top-subject
9371 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9372 (gnus-simplify-subject-fuzzy
9373 (mail-header-subject
9374 (gnus-data-header (car data))))
9375 (gnus-simplify-subject-re
9376 (mail-header-subject
9377 (gnus-data-header (car data)))))))
9378 (push (gnus-data-number (car data)) articles))
9379 (unless (and (setq data (cdr data))
9380 (> (gnus-data-level (car data)) top-level))
9382 ;; Return the list of articles.
9383 (nreverse articles)))
9385 (defun gnus-summary-rethread-current ()
9386 "Rethread the thread the current article is part of."
9388 (let* ((gnus-show-threads t)
9389 (article (gnus-summary-article-number))
9390 (id (mail-header-id (gnus-summary-article-header)))
9391 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9393 (error "No article on the current line"))
9394 (gnus-rebuild-thread id)
9395 (gnus-summary-goto-subject article)))
9397 (defun gnus-summary-reparent-thread ()
9398 "Make the current article child of the marked (or previous) article.
9400 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9401 is non-nil or the Subject: of both articles are the same."
9403 (unless (not (gnus-group-read-only-p))
9404 (error "The current newsgroup does not support article editing"))
9405 (unless (<= (length gnus-newsgroup-processable) 1)
9406 (error "No more than one article may be marked"))
9407 (save-window-excursion
9408 (let ((gnus-article-buffer " *reparent*")
9409 (current-article (gnus-summary-article-number))
9410 ;; First grab the marked article, otherwise one line up.
9411 (parent-article (if (not (null gnus-newsgroup-processable))
9412 (car gnus-newsgroup-processable)
9414 (if (eq (forward-line -1) 0)
9415 (gnus-summary-article-number)
9416 (error "Beginning of summary buffer"))))))
9417 (unless (not (eq current-article parent-article))
9418 (error "An article may not be self-referential"))
9419 (let ((message-id (mail-header-id
9420 (gnus-summary-article-header parent-article))))
9421 (unless (and message-id (not (equal message-id "")))
9422 (error "No message-id in desired parent"))
9423 (gnus-with-article current-article
9425 (goto-char (point-min))
9426 (message-narrow-to-head)
9427 (if (re-search-forward "^References: " nil t)
9429 (re-search-forward "^[^ \t]" nil t)
9432 (insert " " message-id))
9433 (insert "References: " message-id "\n"))))
9434 (set-buffer gnus-summary-buffer)
9435 (gnus-summary-unmark-all-processable)
9436 (gnus-summary-update-article current-article)
9437 (gnus-summary-rethread-current)
9438 (gnus-message 3 "Article %d is now the child of article %d"
9439 current-article parent-article)))))
9441 (defun gnus-summary-toggle-threads (&optional arg)
9442 "Toggle showing conversation threads.
9443 If ARG is positive number, turn showing conversation threads on."
9445 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9446 (setq gnus-show-threads
9447 (if (null arg) (not gnus-show-threads)
9448 (> (prefix-numeric-value arg) 0)))
9449 (gnus-summary-prepare)
9450 (gnus-summary-goto-subject current)
9451 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9452 (gnus-summary-position-point)))
9454 (defun gnus-summary-show-all-threads ()
9458 (let ((buffer-read-only nil))
9459 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9460 (gnus-summary-position-point))
9462 (defun gnus-summary-show-thread ()
9463 "Show thread subtrees.
9464 Returns nil if no thread was there to be shown."
9466 (let ((buffer-read-only nil)
9468 ;; first goto end then to beg, to have point at beg after let
9469 (end (progn (end-of-line) (point)))
9470 (beg (progn (beginning-of-line) (point))))
9472 ;; Any hidden lines here?
9473 (search-forward "\r" end t)
9474 (subst-char-in-region beg end ?\^M ?\n t)
9476 (gnus-summary-position-point))))
9478 (defun gnus-summary-hide-all-threads ()
9479 "Hide all thread subtrees."
9482 (goto-char (point-min))
9483 (gnus-summary-hide-thread)
9484 (while (zerop (gnus-summary-next-thread 1 t))
9485 (gnus-summary-hide-thread)))
9486 (gnus-summary-position-point))
9488 (defun gnus-summary-hide-thread ()
9489 "Hide thread subtrees.
9490 Returns nil if no threads were there to be hidden."
9492 (let ((buffer-read-only nil)
9494 (article (gnus-summary-article-number)))
9496 ;; Go forward until either the buffer ends or the subthread
9498 (when (and (not (eobp))
9499 (or (zerop (gnus-summary-next-thread 1 t))
9500 (goto-char (point-max))))
9502 (if (and (> (point) start)
9503 (search-backward "\n" start t))
9505 (subst-char-in-region start (point) ?\n ?\^M)
9506 (gnus-summary-goto-subject article))
9510 (defun gnus-summary-go-to-next-thread (&optional previous)
9511 "Go to the same level (or less) next thread.
9512 If PREVIOUS is non-nil, go to previous thread instead.
9513 Return the article number moved to, or nil if moving was impossible."
9514 (let ((level (gnus-summary-thread-level))
9515 (way (if previous -1 1))
9518 (while (and (not (eobp))
9519 (< level (gnus-summary-thread-level)))
9527 (gnus-summary-article-number)
9530 (defun gnus-summary-next-thread (n &optional silent)
9531 "Go to the same level next N'th thread.
9532 If N is negative, search backward instead.
9533 Returns the difference between N and the number of skips actually
9536 If SILENT, don't output messages."
9538 (let ((backward (< n 0))
9541 (gnus-summary-go-to-next-thread backward))
9544 (gnus-summary-position-point))
9545 (when (and (not silent) (/= 0 n))
9546 (gnus-message 7 "No more threads"))
9549 (defun gnus-summary-prev-thread (n)
9550 "Go to the same level previous N'th thread.
9551 Returns the difference between N and the number of skips actually
9554 (gnus-summary-next-thread (- n)))
9556 (defun gnus-summary-go-down-thread ()
9557 "Go down one level in the current thread."
9558 (let ((children (gnus-summary-article-children)))
9560 (gnus-summary-goto-subject (car children)))))
9562 (defun gnus-summary-go-up-thread ()
9563 "Go up one level in the current thread."
9564 (let ((parent (gnus-summary-article-parent)))
9566 (gnus-summary-goto-subject parent))))
9568 (defun gnus-summary-down-thread (n)
9569 "Go down thread N steps.
9570 If N is negative, go up instead.
9571 Returns the difference between N and how many steps down that were
9577 (if up (gnus-summary-go-up-thread)
9578 (gnus-summary-go-down-thread)))
9580 (gnus-summary-position-point)
9582 (gnus-message 7 "Can't go further"))
9585 (defun gnus-summary-up-thread (n)
9586 "Go up thread N steps.
9587 If N is negative, go down instead.
9588 Returns the difference between N and how many steps down that were
9591 (gnus-summary-down-thread (- n)))
9593 (defun gnus-summary-top-thread ()
9594 "Go to the top of the thread."
9596 (while (gnus-summary-go-up-thread))
9597 (gnus-summary-article-number))
9599 (defun gnus-summary-kill-thread (&optional unmark)
9600 "Mark articles under current thread as read.
9601 If the prefix argument is positive, remove any kinds of marks.
9602 If the prefix argument is negative, tick articles instead."
9605 (setq unmark (prefix-numeric-value unmark)))
9606 (let ((articles (gnus-summary-articles-in-thread)))
9608 ;; Expand the thread.
9609 (gnus-summary-show-thread)
9610 ;; Mark all the articles.
9612 (gnus-summary-goto-subject (car articles))
9613 (cond ((null unmark)
9614 (gnus-summary-mark-article-as-read gnus-killed-mark))
9616 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9618 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9619 (setq articles (cdr articles))))
9620 ;; Hide killed subtrees.
9622 gnus-thread-hide-killed
9623 (gnus-summary-hide-thread))
9624 ;; If marked as read, go to next unread subject.
9626 ;; Go to next unread subject.
9627 (gnus-summary-next-subject 1 t)))
9628 (gnus-set-mode-line 'summary))
9630 ;; Summary sorting commands
9632 (defun gnus-summary-sort-by-number (&optional reverse)
9633 "Sort the summary buffer by article number.
9634 Argument REVERSE means reverse order."
9636 (gnus-summary-sort 'number reverse))
9638 (defun gnus-summary-sort-by-author (&optional reverse)
9639 "Sort the summary buffer by author name alphabetically.
9640 If `case-fold-search' is non-nil, case of letters is ignored.
9641 Argument REVERSE means reverse order."
9643 (gnus-summary-sort 'author reverse))
9645 (defun gnus-summary-sort-by-subject (&optional reverse)
9646 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9647 If `case-fold-search' is non-nil, case of letters is ignored.
9648 Argument REVERSE means reverse order."
9650 (gnus-summary-sort 'subject reverse))
9652 (defun gnus-summary-sort-by-date (&optional reverse)
9653 "Sort the summary buffer by date.
9654 Argument REVERSE means reverse order."
9656 (gnus-summary-sort 'date reverse))
9658 (defun gnus-summary-sort-by-score (&optional reverse)
9659 "Sort the summary buffer by score.
9660 Argument REVERSE means reverse order."
9662 (gnus-summary-sort 'score reverse))
9664 (defun gnus-summary-sort-by-lines (&optional reverse)
9665 "Sort the summary buffer by the number of lines.
9666 Argument REVERSE means reverse order."
9668 (gnus-summary-sort 'lines reverse))
9670 (defun gnus-summary-sort-by-chars (&optional reverse)
9671 "Sort the summary buffer by article length.
9672 Argument REVERSE means reverse order."
9674 (gnus-summary-sort 'chars reverse))
9676 (defun gnus-summary-sort-by-original (&optional reverse)
9677 "Sort the summary buffer using the default sorting method.
9678 Argument REVERSE means reverse order."
9680 (let* ((buffer-read-only)
9681 (gnus-summary-prepare-hook nil))
9682 ;; We do the sorting by regenerating the threads.
9683 (gnus-summary-prepare)
9684 ;; Hide subthreads if needed.
9685 (when (and gnus-show-threads gnus-thread-hide-subtree)
9686 (gnus-summary-hide-all-threads))))
9688 (defun gnus-summary-sort (predicate reverse)
9689 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9690 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9691 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9692 (gnus-thread-sort-functions
9697 (gnus-sort-gathered-threads-function
9698 gnus-thread-sort-functions)
9699 (gnus-article-sort-functions
9705 (gnus-summary-prepare-hook nil))
9706 ;; We do the sorting by regenerating the threads.
9707 (gnus-summary-prepare)
9708 ;; Hide subthreads if needed.
9709 (when (and gnus-show-threads gnus-thread-hide-subtree)
9710 (gnus-summary-hide-all-threads))))
9712 ;; Summary saving commands.
9714 (defun gnus-summary-save-article (&optional n not-saved)
9715 "Save the current article using the default saver function.
9716 If N is a positive number, save the N next articles.
9717 If N is a negative number, save the N previous articles.
9718 If N is nil and any articles have been marked with the process mark,
9719 save those articles instead.
9720 The variable `gnus-default-article-saver' specifies the saver function."
9722 (let* ((articles (gnus-summary-work-articles n))
9723 (save-buffer (save-excursion
9724 (nnheader-set-temp-buffer " *Gnus Save*")))
9725 (num (length articles))
9727 (dolist (article articles)
9728 (setq header (gnus-summary-article-header article))
9729 (if (not (vectorp header))
9730 ;; This is a pseudo-article.
9731 (if (assq 'name header)
9732 (gnus-copy-file (cdr (assq 'name header)))
9733 (gnus-message 1 "Article %d is unsaveable" article))
9734 ;; This is a real article.
9735 (save-window-excursion
9736 (gnus-summary-select-article t nil nil article))
9738 (set-buffer save-buffer)
9740 (insert-buffer-substring gnus-original-article-buffer))
9741 (setq file (gnus-article-save save-buffer file num))
9742 (gnus-summary-remove-process-mark article)
9744 (gnus-summary-set-saved-mark article))))
9745 (gnus-kill-buffer save-buffer)
9746 (gnus-summary-position-point)
9747 (gnus-set-mode-line 'summary)
9750 (defun gnus-summary-pipe-output (&optional arg)
9751 "Pipe the current article to a subprocess.
9752 If N is a positive number, pipe the N next articles.
9753 If N is a negative number, pipe the N previous articles.
9754 If N is nil and any articles have been marked with the process mark,
9755 pipe those articles instead."
9758 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9759 (gnus-summary-save-article arg t))
9760 (let ((buffer (get-buffer "*Shell Command Output*")))
9762 (with-current-buffer buffer (> (point-max) (point-min))))
9763 (gnus-configure-windows 'pipe))))
9765 (defun gnus-summary-save-article-mail (&optional arg)
9766 "Append the current article to an mail file.
9767 If N is a positive number, save the N next articles.
9768 If N is a negative number, save the N previous articles.
9769 If N is nil and any articles have been marked with the process mark,
9770 save those articles instead."
9773 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9774 (gnus-summary-save-article arg)))
9776 (defun gnus-summary-save-article-rmail (&optional arg)
9777 "Append the current article to an rmail file.
9778 If N is a positive number, save the N next articles.
9779 If N is a negative number, save the N previous articles.
9780 If N is nil and any articles have been marked with the process mark,
9781 save those articles instead."
9784 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9785 (gnus-summary-save-article arg)))
9787 (defun gnus-summary-save-article-file (&optional arg)
9788 "Append the current article to a file.
9789 If N is a positive number, save the N next articles.
9790 If N is a negative number, save the N previous articles.
9791 If N is nil and any articles have been marked with the process mark,
9792 save those articles instead."
9795 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9796 (gnus-summary-save-article arg)))
9798 (defun gnus-summary-write-article-file (&optional arg)
9799 "Write the current article to a file, deleting the previous file.
9800 If N is a positive number, save the N next articles.
9801 If N is a negative number, save the N previous articles.
9802 If N is nil and any articles have been marked with the process mark,
9803 save those articles instead."
9806 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9807 (gnus-summary-save-article arg)))
9809 (defun gnus-summary-save-article-body-file (&optional arg)
9810 "Append the current article body to a file.
9811 If N is a positive number, save the N next articles.
9812 If N is a negative number, save the N previous articles.
9813 If N is nil and any articles have been marked with the process mark,
9814 save those articles instead."
9817 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9818 (gnus-summary-save-article arg)))
9820 (defun gnus-summary-pipe-message (program)
9821 "Pipe the current article through PROGRAM."
9822 (interactive "sProgram: ")
9823 (gnus-summary-select-article)
9824 (let ((mail-header-separator ""))
9825 (gnus-eval-in-buffer-window gnus-article-buffer
9828 (let ((start (window-start))
9830 (message-pipe-buffer-body program)
9831 (set-window-start (get-buffer-window (current-buffer)) start))))))
9833 (defun gnus-get-split-value (methods)
9834 "Return a value based on the split METHODS."
9835 (let (split-name method result match)
9838 (set-buffer gnus-original-article-buffer)
9840 (nnheader-narrow-to-headers)
9841 (while (and methods (not split-name))
9842 (goto-char (point-min))
9843 (setq method (pop methods))
9844 (setq match (car method))
9847 ;; Regular expression.
9849 (re-search-forward match nil t)))
9850 ((gnus-functionp match)
9854 (setq result (funcall match gnus-newsgroup-name))))
9859 (setq result (eval match)))))
9860 (setq split-name (cdr method))
9861 (cond ((stringp result)
9862 (push (expand-file-name
9863 result gnus-article-save-directory)
9866 (setq split-name (append result split-name)))))))))
9867 (nreverse split-name)))
9869 (defun gnus-valid-move-group-p (group)
9872 (symbol-value group)
9873 (gnus-get-function (gnus-find-method-for-group
9874 (symbol-name group)) 'request-accept-article t)))
9876 (defun gnus-read-move-group-name (prompt default articles prefix)
9877 "Read a group name."
9878 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9879 (minibuffer-confirm-incomplete nil) ; XEmacs
9883 (if (> (length articles) 1)
9884 (format "these %d articles" (length articles))
9889 (gnus-completing-read default prom
9891 'gnus-valid-move-group-p
9893 'gnus-group-history))
9894 ((= 1 (length split-name))
9895 (gnus-completing-read (car split-name) prom
9897 'gnus-valid-move-group-p
9899 'gnus-group-history))
9901 (gnus-completing-read nil prom
9902 (mapcar (lambda (el) (list el))
9903 (nreverse split-name))
9905 'gnus-group-history))))
9906 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9908 (if (or (string= to-newsgroup "")
9909 (string= to-newsgroup prefix))
9910 (setq to-newsgroup default))
9911 (unless to-newsgroup
9912 (error "No group name entered"))
9913 (or (gnus-active to-newsgroup)
9914 (gnus-activate-group to-newsgroup nil nil to-method)
9915 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9917 (or (and (gnus-request-create-group to-newsgroup to-method)
9918 (gnus-activate-group
9919 to-newsgroup nil nil to-method)
9920 (gnus-subscribe-group to-newsgroup))
9921 (error "Couldn't create group %s" to-newsgroup)))
9922 (error "No such group: %s" to-newsgroup)))
9925 (defun gnus-summary-save-parts (type dir n &optional reverse)
9926 "Save parts matching TYPE to DIR.
9927 If REVERSE, save parts that do not match TYPE."
9929 (list (read-string "Save parts of type: "
9930 (or (car gnus-summary-save-parts-type-history)
9931 gnus-summary-save-parts-default-mime)
9932 'gnus-summary-save-parts-type-history)
9933 (setq gnus-summary-save-parts-last-directory
9934 (read-file-name "Save to directory: "
9935 gnus-summary-save-parts-last-directory
9937 current-prefix-arg))
9938 (gnus-summary-iterate n
9939 (let ((gnus-display-mime-function nil)
9940 (gnus-inhibit-treatment t))
9941 (gnus-summary-select-article))
9943 (set-buffer gnus-article-buffer)
9944 (let ((handles (or gnus-article-mime-handles
9945 (mm-dissect-buffer) (mm-uu-dissect))))
9947 (gnus-summary-save-parts-1 type dir handles reverse)
9948 (unless gnus-article-mime-handles ;; Don't destroy this case.
9949 (mm-destroy-parts handles)))))))
9951 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9952 (if (stringp (car handle))
9953 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9956 (not (string-match type (mm-handle-media-type handle)))
9957 (string-match type (mm-handle-media-type handle)))
9958 (let ((file (expand-file-name
9959 (file-name-nondirectory
9961 (mail-content-type-get
9962 (mm-handle-disposition handle) 'filename)
9963 (concat gnus-newsgroup-name
9964 "." (number-to-string
9965 (cdr gnus-article-current)))))
9967 (unless (file-exists-p file)
9968 (mm-save-part-to-file handle file))))))
9970 ;; Summary extract commands
9972 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9973 (let ((buffer-read-only nil)
9974 (article (gnus-summary-article-number))
9976 (unless (gnus-summary-goto-subject article)
9977 (error "No such article: %d" article))
9978 (gnus-summary-position-point)
9979 ;; If all commands are to be bunched up on one line, we collect
9981 (unless gnus-view-pseudos-separately
9982 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9985 (setq action (cdr (assq 'action (car ps))))
9986 (setq files (list (cdr (assq 'name (car ps)))))
9987 (while (and ps (cdr ps)
9988 (string= (or action "1")
9989 (or (cdr (assq 'action (cadr ps))) "2")))
9990 (push (cdr (assq 'name (cadr ps))) files)
9991 (setcdr ps (cddr ps)))
9993 (when (not (string-match "%s" action))
9996 (when (assq 'execute (car ps))
9997 (setcdr (assq 'execute (car ps))
9998 (funcall (if (string-match "%s" action)
10005 (gnus-quote-arg-for-sh-or-csh f)))
10007 (setq ps (cdr ps)))))
10008 (if (and gnus-view-pseudos (not not-view))
10010 (when (assq 'execute (car pslist))
10011 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10012 (eq gnus-view-pseudos 'not-confirm)))
10013 (setq pslist (cdr pslist)))
10016 (setq after-article (or (cdr (assq 'article (car pslist)))
10017 (gnus-summary-article-number)))
10018 (gnus-summary-goto-subject after-article)
10021 (insert " " (file-name-nondirectory
10022 (cdr (assq 'name (car pslist))))
10023 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10025 (forward-line -1) ; back to `b'
10026 (gnus-add-text-properties
10027 b (1- e) (list 'gnus-number gnus-reffed-article-number
10028 gnus-mouse-face-prop gnus-mouse-face))
10030 after-article gnus-reffed-article-number
10031 gnus-unread-mark b (car pslist) 0 (- e b))
10032 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10033 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10034 (setq pslist (cdr pslist)))))))
10036 (defun gnus-pseudos< (p1 p2)
10037 (let ((c1 (cdr (assq 'action p1)))
10038 (c2 (cdr (assq 'action p2))))
10039 (and c1 c2 (string< c1 c2))))
10041 (defun gnus-request-pseudo-article (props)
10042 (cond ((assq 'execute props)
10043 (gnus-execute-command (cdr (assq 'execute props)))))
10044 (let ((gnus-current-article (gnus-summary-article-number)))
10045 (gnus-run-hooks 'gnus-mark-article-hook)))
10047 (defun gnus-execute-command (command &optional automatic)
10049 (gnus-article-setup-buffer)
10050 (set-buffer gnus-article-buffer)
10051 (setq buffer-read-only nil)
10052 (let ((command (if automatic command
10053 (read-string "Command: " (cons command 0)))))
10055 (insert "$ " command "\n\n")
10056 (if gnus-view-pseudo-asynchronously
10057 (start-process "gnus-execute" (current-buffer) shell-file-name
10058 shell-command-switch command)
10059 (call-process shell-file-name nil t nil
10060 shell-command-switch command)))))
10062 ;; Summary kill commands.
10064 (defun gnus-summary-edit-global-kill (article)
10065 "Edit the \"global\" kill file."
10066 (interactive (list (gnus-summary-article-number)))
10067 (gnus-group-edit-global-kill article))
10069 (defun gnus-summary-edit-local-kill ()
10070 "Edit a local kill file applied to the current newsgroup."
10072 (setq gnus-current-headers (gnus-summary-article-header))
10073 (gnus-group-edit-local-kill
10074 (gnus-summary-article-number) gnus-newsgroup-name))
10076 ;;; Header reading.
10078 (defun gnus-read-header (id &optional header)
10079 "Read the headers of article ID and enter them into the Gnus system."
10080 (let ((group gnus-newsgroup-name)
10081 (gnus-override-method
10083 gnus-override-method
10084 (and (gnus-news-group-p gnus-newsgroup-name)
10085 (car (gnus-refer-article-methods)))))
10087 ;; First we check to see whether the header in question is already
10090 ;; This is a Message-ID.
10091 (setq header (or header (gnus-id-to-header id)))
10092 ;; This is an article number.
10093 (setq header (or header (gnus-summary-article-header id))))
10095 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10096 ;; We have found the header.
10098 ;; If this is a sparse article, we have to nix out its
10099 ;; previous entry in the thread hashtb.
10101 (gnus-summary-article-sparse-p (mail-header-number header)))
10102 (let* ((parent (gnus-parent-id (mail-header-references header)))
10103 (thread (and parent (gnus-id-to-thread parent))))
10105 (delq (assq header thread) thread))))
10106 ;; We have to really fetch the header to this article.
10108 (set-buffer nntp-server-buffer)
10109 (when (setq where (gnus-request-head id group))
10110 (nnheader-fold-continuation-lines)
10111 (goto-char (point-max))
10113 (goto-char (point-min))
10117 ((cdr where) (cdr where))
10118 (header (mail-header-number header))
10119 (t gnus-reffed-article-number))
10121 (insert " Article retrieved.\n"))
10122 (if (or (not where)
10123 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10124 () ; Malformed head.
10125 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10126 (when (and (stringp id)
10127 (not (string= (gnus-group-real-name group)
10129 ;; If we fetched by Message-ID and the article came
10130 ;; from a different group, we fudge some bogus article
10131 ;; numbers for this article.
10132 (mail-header-set-number header gnus-reffed-article-number))
10134 (set-buffer gnus-summary-buffer)
10135 (decf gnus-reffed-article-number)
10136 (gnus-remove-header (mail-header-number header))
10137 (push header gnus-newsgroup-headers)
10138 (setq gnus-current-headers header)
10139 (push (mail-header-number header) gnus-newsgroup-limit)))
10142 (defun gnus-remove-header (number)
10143 "Remove header NUMBER from `gnus-newsgroup-headers'."
10144 (if (and gnus-newsgroup-headers
10145 (= number (mail-header-number (car gnus-newsgroup-headers))))
10146 (pop gnus-newsgroup-headers)
10147 (let ((headers gnus-newsgroup-headers))
10148 (while (and (cdr headers)
10149 (not (= number (mail-header-number (cadr headers)))))
10151 (when (cdr headers)
10152 (setcdr headers (cddr headers))))))
10155 ;;; summary highlights
10158 (defun gnus-highlight-selected-summary ()
10159 "Highlight selected article in summary buffer."
10160 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10161 (when gnus-summary-selected-face
10163 (let* ((beg (progn (beginning-of-line) (point)))
10164 (end (progn (end-of-line) (point)))
10165 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10166 (from (if (get-text-property beg gnus-mouse-face-prop)
10168 (or (next-single-property-change
10169 beg gnus-mouse-face-prop nil end)
10174 (or (next-single-property-change
10175 from gnus-mouse-face-prop nil end)
10177 ;; If no mouse-face prop on line we will have to = from = end,
10178 ;; so we highlight the entire line instead.
10179 (when (= (+ to 2) from)
10182 (if gnus-newsgroup-selected-overlay
10183 ;; Move old overlay.
10185 gnus-newsgroup-selected-overlay from to (current-buffer))
10186 ;; Create new overlay.
10188 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10189 'face gnus-summary-selected-face))))))
10191 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10192 (defun gnus-summary-highlight-line ()
10193 "Highlight current line according to `gnus-summary-highlight'."
10194 (let* ((list gnus-summary-highlight)
10196 (end (progn (end-of-line) (point)))
10197 ;; now find out where the line starts and leave point there.
10198 (beg (progn (beginning-of-line) (point)))
10199 (article (gnus-summary-article-number))
10200 (score (or (cdr (assq (or article gnus-current-article)
10201 gnus-newsgroup-scored))
10202 gnus-summary-default-score 0))
10203 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10204 (inhibit-read-only t))
10205 ;; Eval the cars of the lists until we find a match.
10206 (let ((default gnus-summary-default-score)
10207 (default-high gnus-summary-default-high-score)
10208 (default-low gnus-summary-default-low-score))
10210 (not (eval (caar list))))
10211 (setq list (cdr list))))
10212 (let ((face (cdar list)))
10213 (unless (eq face (get-text-property beg 'face))
10214 (gnus-put-text-property-excluding-characters-with-faces
10216 (setq face (if (boundp face) (symbol-value face) face)))
10217 (when gnus-summary-highlight-line-function
10218 (funcall gnus-summary-highlight-line-function article face))))
10221 (defun gnus-update-read-articles (group unread &optional compute)
10222 "Update the list of read articles in GROUP."
10223 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10224 (entry (gnus-gethash group gnus-newsrc-hashtb))
10225 (info (nth 2 entry))
10227 (unread (sort (copy-sequence unread) '<))
10229 (if (or (not info) (not active))
10230 ;; There is no info on this group if it was, in fact,
10231 ;; killed. Gnus stores no information on killed groups, so
10232 ;; there's nothing to be done.
10233 ;; One could store the information somewhere temporarily,
10234 ;; perhaps... Hmmm...
10236 ;; Remove any negative articles numbers.
10237 (while (and unread (< (car unread) 0))
10238 (setq unread (cdr unread)))
10239 ;; Remove any expired article numbers
10240 (while (and unread (< (car unread) (car active)))
10241 (setq unread (cdr unread)))
10242 ;; Compute the ranges of read articles by looking at the list of
10243 ;; unread articles.
10245 (when (/= (car unread) prev)
10246 (push (if (= prev (1- (car unread))) prev
10247 (cons prev (1- (car unread))))
10249 (setq prev (1+ (car unread)))
10250 (setq unread (cdr unread)))
10251 (when (<= prev (cdr active))
10252 (push (cons prev (cdr active)) read))
10253 (setq read (if (> (length read) 1) (nreverse read) read))
10258 ;; Propagate the read marks to the backend.
10259 (when (gnus-check-backend-function 'request-set-mark group)
10260 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10261 (add (gnus-remove-from-range read (gnus-info-read info))))
10263 (unless (gnus-check-group group)
10264 (error "Can't open server for %s" group))
10265 (gnus-request-set-mark
10266 group (delq nil (list (if add (list add 'add '(read)))
10267 (if del (list del 'del '(read))))))
10269 `(gnus-request-set-mark
10272 (if del (list del 'add '(read)))
10273 (if add (list add 'del '(read))))))))))
10274 (set-buffer gnus-group-buffer)
10275 (gnus-undo-register
10277 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10278 (gnus-info-set-read ',info ',(gnus-info-read info))
10279 (gnus-get-unread-articles-in-group ',info
10280 (gnus-active ,group))
10281 (gnus-group-update-group ,group t)
10283 ;; Enter this list into the group info.
10284 (gnus-info-set-read info read)
10285 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10286 (gnus-get-unread-articles-in-group info (gnus-active group))
10289 (defun gnus-offer-save-summaries ()
10290 "Offer to save all active summary buffers."
10292 ;; Go through all buffers and find all summaries.
10293 (dolist (buffer (buffer-list))
10294 (when (and (setq buffer (buffer-name buffer))
10295 (string-match "Summary" buffer)
10297 (set-buffer buffer)
10298 ;; We check that this is, indeed, a summary buffer.
10299 (and (eq major-mode 'gnus-summary-mode)
10300 ;; Also make sure this isn't bogus.
10301 gnus-newsgroup-prepared
10302 ;; Also make sure that this isn't a
10303 ;; dead summary buffer.
10304 (not gnus-dead-summary-mode))))
10305 (push buffer buffers)))
10306 ;; Go through all these summary buffers and offer to save them.
10310 "Update summary buffer %s? "
10312 (switch-to-buffer buf)
10313 (gnus-summary-exit))
10317 ;;; @ for mime-partial
10320 (defun gnus-request-partial-message ()
10322 (let ((number (gnus-summary-article-number))
10323 (group gnus-newsgroup-name)
10324 (mother gnus-article-buffer))
10325 (set-buffer (get-buffer-create " *Partial Article*"))
10327 (setq mime-preview-buffer mother)
10328 (gnus-request-article-this-buffer number group)
10329 (mime-parse-buffer)
10332 (autoload 'mime-combine-message/partial-pieces-automatically
10334 "Internal method to combine message/partial messages automatically.")
10336 (mime-add-condition
10337 'action '((type . message)(subtype . partial)
10338 (major-mode . gnus-original-article-mode)
10339 (method . mime-combine-message/partial-pieces-automatically)
10340 (summary-buffer-exp . gnus-summary-buffer)
10341 (request-partial-message-method . gnus-request-partial-message)
10345 ;;; @ for message/rfc822
10348 (defun gnus-mime-extract-message/rfc822 (entity situation)
10349 (let (group article num cwin swin cur)
10351 (mime-insert-entity-content entity)
10352 (setq group (or (cdr (assq 'group situation))
10353 (completing-read "Group: "
10356 (gnus-read-active-file-p)
10357 gnus-newsgroup-name))
10358 article (gnus-request-accept-article group)))
10359 (when (and (consp article)
10360 (numberp (setq article (cdr article))))
10361 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10362 cwin (get-buffer-window (current-buffer) t))
10363 (save-window-excursion
10364 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10365 (select-window swin)
10366 (set-buffer gnus-summary-buffer))
10367 (setq cur gnus-current-article)
10369 (let (gnus-show-threads)
10370 (gnus-summary-goto-subject article t))
10371 (gnus-summary-clear-mark-forward 1)
10372 (gnus-summary-goto-subject cur))
10373 (when (and cwin (window-frame cwin))
10374 (select-frame (window-frame cwin)))
10375 (when (boundp 'mime-acting-situation-to-override)
10376 (set-alist 'mime-acting-situation-to-override
10379 (set-alist 'mime-acting-situation-to-override
10382 (save-current-buffer
10383 (set-buffer gnus-group-buffer)
10384 (gnus-activate-group ,group))
10385 (gnus-summary-goto-article ,cur
10386 gnus-show-all-headers)))
10387 (set-alist 'mime-acting-situation-to-override
10390 (mime-add-condition
10391 'action '((type . message)(subtype . rfc822)
10392 (major-mode . gnus-original-article-mode)
10393 (method . gnus-mime-extract-message/rfc822)
10397 (mime-add-condition
10398 'action '((type . message)(subtype . news)
10399 (major-mode . gnus-original-article-mode)
10400 (method . gnus-mime-extract-message/rfc822)
10404 (defun gnus-mime-extract-multipart (entity situation)
10405 (let ((children (mime-entity-children entity))
10406 mime-acting-situation-to-override
10409 (mime-play-entity (car children)
10410 (cons (assq 'mode situation)
10411 mime-acting-situation-to-override))
10412 (setq children (cdr children)))
10413 (if (setq f (cdr (assq 'after-method
10414 mime-acting-situation-to-override)))
10418 (mime-add-condition
10419 'action '((type . multipart)
10420 (method . gnus-mime-extract-multipart)
10429 (defun gnus-summary-setup-default-charset ()
10430 "Setup newsgroup default charset."
10431 (if (equal gnus-newsgroup-name "nndraft:drafts")
10432 (setq gnus-newsgroup-charset nil)
10433 (let* ((ignored-charsets
10434 (or gnus-newsgroup-ephemeral-ignored-charsets
10436 (and gnus-newsgroup-name
10437 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10438 gnus-newsgroup-ignored-charsets))))
10439 (setq gnus-newsgroup-charset
10440 (or gnus-newsgroup-ephemeral-charset
10441 (and gnus-newsgroup-name
10442 (gnus-parameter-charset gnus-newsgroup-name))
10443 gnus-default-charset))
10444 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10445 ignored-charsets))))
10451 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10452 "Display the current article buffer fully MIME-buttonized.
10453 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10454 treated as multipart/mixed."
10456 (require 'gnus-art)
10457 (let ((gnus-unbuttonized-mime-types nil)
10458 (gnus-mime-display-multipart-as-mixed show-all-parts))
10459 (gnus-summary-show-article)))
10461 (defun gnus-summary-repair-multipart (article)
10462 "Add a Content-Type header to a multipart article without one."
10463 (interactive (list (gnus-summary-article-number)))
10464 (gnus-with-article article
10465 (message-narrow-to-head)
10466 (message-remove-header "Mime-Version")
10467 (goto-char (point-max))
10468 (insert "Mime-Version: 1.0\n")
10470 (when (search-forward "\n--" nil t)
10471 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10472 (message-narrow-to-head)
10473 (message-remove-header "Content-Type")
10474 (goto-char (point-max))
10475 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10478 (let (gnus-mark-article-hook)
10479 (gnus-summary-select-article t t nil article)))
10481 (defun gnus-summary-toggle-display-buttonized ()
10482 "Toggle the buttonizing of the article buffer."
10484 (require 'gnus-art)
10485 (if (setq gnus-inhibit-mime-unbuttonizing
10486 (not gnus-inhibit-mime-unbuttonizing))
10487 (let ((gnus-unbuttonized-mime-types nil))
10488 (gnus-summary-show-article))
10489 (gnus-summary-show-article)))
10492 ;;; Intelli-mouse commmands
10495 (defun gnus-wheel-summary-scroll (event)
10497 (let ((amount (if (memq 'shift (event-modifiers event))
10498 (car gnus-wheel-scroll-amount)
10499 (cdr gnus-wheel-scroll-amount)))
10500 (direction (- (* (static-if (featurep 'xemacs)
10501 (event-button event)
10502 (cond ((eq 'mouse-4 (event-basic-type event))
10504 ((eq 'mouse-5 (event-basic-type event))
10508 (gnus-summary-scroll-up (* amount direction))
10509 (when (gnus-eval-in-buffer-window gnus-article-buffer
10512 (and (if (< 0 direction)
10513 (gnus-article-next-page 0)
10514 (gnus-article-prev-page 0)
10516 (if (setq edge (get-text-property
10517 (point-min) 'gnus-wheel-edge))
10518 (setq edge (* edge direction))
10521 (let ((buffer-read-only nil)
10522 (inhibit-read-only t))
10523 (put-text-property (point-min) (point-max)
10524 'gnus-wheel-edge direction)
10526 (or (> edge gnus-wheel-edge-resistance)
10527 (let ((buffer-read-only nil)
10528 (inhibit-read-only t))
10529 (put-text-property (point-min) (point-max)
10531 (* (1+ edge) direction))
10533 (eq last-command 'gnus-wheel-summary-scroll))))
10534 (gnus-summary-next-article nil nil (minusp direction)))))
10536 (defun gnus-wheel-install ()
10537 "Enable mouse wheel support on summary window."
10538 (when gnus-use-wheel
10540 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10542 (define-key gnus-summary-mode-map key
10543 'gnus-wheel-summary-scroll)))))
10545 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10548 ;;; Traditional PGP commmands
10551 (defun gnus-summary-decrypt-article (&optional force)
10552 "Decrypt the current article in traditional PGP way.
10553 This will have permanent effect only in mail groups.
10554 If FORCE is non-nil, allow editing of articles even in read-only
10557 (gnus-summary-select-article t)
10558 (gnus-eval-in-buffer-window gnus-article-buffer
10562 (goto-char (point-min))
10563 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10564 (error "Not a traditional PGP message!"))
10565 (let ((armor-start (match-beginning 0)))
10566 (if (and (pgg-decrypt-region armor-start (point-max))
10567 (or force (not (gnus-group-read-only-p))))
10568 (let ((inhibit-read-only t)
10570 (delete-region armor-start
10572 (re-search-forward "^-+END PGP" nil t)
10573 (beginning-of-line 2)
10575 (insert-buffer-substring pgg-output-buffer))))))))
10577 (defun gnus-summary-verify-article ()
10578 "Verify the current article in traditional PGP way."
10581 (set-buffer gnus-original-article-buffer)
10582 (goto-char (point-min))
10583 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10584 (error "Not a traditional PGP message!"))
10585 (re-search-forward "^-+END PGP" nil t)
10586 (beginning-of-line 2)
10587 (call-interactively (function pgg-verify-region))))
10590 ;;; Generic summary marking commands
10593 (defvar gnus-summary-marking-alist
10594 '((read gnus-del-mark "d")
10595 (unread gnus-unread-mark "u")
10596 (ticked gnus-ticked-mark "!")
10597 (dormant gnus-dormant-mark "?")
10598 (expirable gnus-expirable-mark "e"))
10599 "An alist of names/marks/keystrokes.")
10601 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10602 (defvar gnus-summary-mark-map)
10604 (defun gnus-summary-make-all-marking-commands ()
10605 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10606 (dolist (elem gnus-summary-marking-alist)
10607 (apply 'gnus-summary-make-marking-command elem)))
10609 (defun gnus-summary-make-marking-command (name mark keystroke)
10610 (let ((map (make-sparse-keymap)))
10611 (define-key gnus-summary-generic-mark-map keystroke map)
10612 (dolist (lway `((next "next" next nil "n")
10613 (next-unread "next unread" next t "N")
10614 (prev "previous" prev nil "p")
10615 (prev-unread "previous unread" prev t "P")
10616 (nomove "" nil nil ,keystroke)))
10617 (let ((func (gnus-summary-make-marking-command-1
10618 mark (car lway) lway name)))
10619 (setq func (eval func))
10620 (define-key map (nth 4 lway) func)))))
10622 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10624 (format "gnus-summary-put-mark-as-%s%s"
10625 name (if (eq way 'nomove)
10627 (concat "-" (symbol-name way)))))
10630 "Mark the current article as %s%s.
10631 If N, the prefix, then repeat N times.
10632 If N is negative, move in reverse order.
10633 The difference between N and the actual number of articles marked is
10635 name (car (cdr lway)))
10637 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10639 (defun gnus-summary-generic-mark (n mark move unread)
10640 "Mark N articles with MARK."
10641 (unless (eq major-mode 'gnus-summary-mode)
10642 (error "This command can only be used in the summary buffer"))
10643 (gnus-summary-show-thread)
10646 ((eq move 'next) 1)
10647 ((eq move 'prev) -1)
10649 (if (zerop nummove)
10653 nummove (* -1 nummove))))
10654 (while (and (> n 0)
10655 (gnus-summary-mark-article nil mark)
10656 (zerop (gnus-summary-next-subject nummove unread t)))
10659 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10660 (gnus-summary-recenter)
10661 (gnus-summary-position-point)
10662 (gnus-set-mode-line 'summary)
10665 (defun gnus-summary-insert-articles (articles)
10666 (when (setq articles
10667 (gnus-set-difference articles
10668 (mapcar (lambda (h) (mail-header-number h))
10669 gnus-newsgroup-headers)))
10670 (setq gnus-newsgroup-headers
10672 gnus-newsgroup-headers
10673 (gnus-fetch-headers articles)
10674 'gnus-article-sort-by-number))
10675 ;; Suppress duplicates?
10676 (when gnus-suppress-duplicates
10677 (gnus-dup-suppress-articles))
10679 ;; We might want to build some more threads first.
10680 (when (and gnus-fetch-old-headers
10681 (eq gnus-headers-retrieved-by 'nov))
10682 (if (eq gnus-fetch-old-headers 'invisible)
10683 (gnus-build-all-threads)
10684 (gnus-build-old-threads)))
10685 ;; Let the Gnus agent mark articles as read.
10687 (gnus-agent-get-undownloaded-list))
10688 ;; Remove list identifiers from subject
10689 (when gnus-list-identifiers
10690 (gnus-summary-remove-list-identifiers))
10691 ;; First and last article in this newsgroup.
10692 (when gnus-newsgroup-headers
10693 (setq gnus-newsgroup-begin
10694 (mail-header-number (car gnus-newsgroup-headers))
10696 (mail-header-number
10697 (gnus-last-element gnus-newsgroup-headers))))
10698 (when gnus-use-scoring
10699 (gnus-possibly-score-headers))))
10701 (defun gnus-summary-insert-old-articles (&optional all)
10702 "Insert all old articles in this group.
10703 If ALL is non-nil, already read articles become readable.
10704 If ALL is a number, fetch this number of articles."
10707 (let ((old (mapcar 'car gnus-newsgroup-data))
10708 (i (car gnus-newsgroup-active))
10710 (while (<= i (cdr gnus-newsgroup-active))
10711 (or (memq i old) (push i older))
10713 (setq len (length older))
10718 (setq older (subseq older 0 all))))
10721 (if (and (numberp gnus-large-newsgroup)
10722 (> len gnus-large-newsgroup))
10726 "How many articles from %s (default %d): "
10728 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10730 (unless (string-match "^[ \t]*$" input)
10731 (setq all (string-to-number input))
10733 (setq older (subseq older 0 all))))))))
10735 (message "No old news.")
10736 (gnus-summary-insert-articles older)
10737 (gnus-summary-limit (gnus-union older old))))
10738 (gnus-summary-position-point)))
10740 (defun gnus-summary-insert-new-articles ()
10741 "Insert all new articles in this group."
10744 (let ((old (mapcar 'car gnus-newsgroup-data))
10745 (old-active gnus-newsgroup-active)
10746 (nnmail-fetched-sources (list t))
10748 (setq gnus-newsgroup-active
10749 (gnus-activate-group gnus-newsgroup-name 'scan))
10750 (setq i (1+ (cdr old-active)))
10751 (while (<= i (cdr gnus-newsgroup-active))
10755 (message "No gnus is bad news.")
10756 (setq new (nreverse new))
10757 (gnus-summary-insert-articles new)
10758 (setq gnus-newsgroup-unreads
10759 (append gnus-newsgroup-unreads new))
10760 (gnus-summary-limit (gnus-union old new))))
10761 (gnus-summary-position-point)))
10763 (gnus-summary-make-all-marking-commands)
10765 (gnus-ems-redefine)
10767 (provide 'gnus-sum)
10769 (run-hooks 'gnus-sum-load-hook)
10771 ;;; gnus-sum.el ends here