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-selected-face 'gnus-summary-selected-face
830 "Face used for highlighting the current article in the summary buffer."
831 :group 'gnus-summary-visual
834 (defcustom gnus-summary-highlight
835 '(((= mark gnus-canceled-mark)
836 . gnus-summary-cancelled-face)
837 ((and (> score default-high)
838 (or (= mark gnus-dormant-mark)
839 (= mark gnus-ticked-mark)))
840 . gnus-summary-high-ticked-face)
841 ((and (< score default-low)
842 (or (= mark gnus-dormant-mark)
843 (= mark gnus-ticked-mark)))
844 . gnus-summary-low-ticked-face)
845 ((or (= mark gnus-dormant-mark)
846 (= mark gnus-ticked-mark))
847 . gnus-summary-normal-ticked-face)
848 ((and (> score default-high) (= mark gnus-ancient-mark))
849 . gnus-summary-high-ancient-face)
850 ((and (< score default-low) (= mark gnus-ancient-mark))
851 . gnus-summary-low-ancient-face)
852 ((= mark gnus-ancient-mark)
853 . gnus-summary-normal-ancient-face)
854 ((and (> score default-high) (= mark gnus-unread-mark))
855 . gnus-summary-high-unread-face)
856 ((and (< score default-low) (= mark gnus-unread-mark))
857 . gnus-summary-low-unread-face)
858 ((= mark gnus-unread-mark)
859 . gnus-summary-normal-unread-face)
860 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
861 gnus-undownloaded-mark)))
862 . gnus-summary-high-unread-face)
863 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
864 gnus-undownloaded-mark)))
865 . gnus-summary-low-unread-face)
866 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
867 (memq article gnus-newsgroup-unreads))
868 . gnus-summary-normal-unread-face)
869 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
870 . gnus-summary-normal-read-face)
871 ((> score default-high)
872 . gnus-summary-high-read-face)
873 ((< score default-low)
874 . gnus-summary-low-read-face)
876 . gnus-summary-normal-read-face))
877 "*Controls the highlighting of summary buffer lines.
879 A list of (FORM . FACE) pairs. When deciding how a a particular
880 summary line should be displayed, each form is evaluated. The content
881 of the face field after the first true form is used. You can change
882 how those summary lines are displayed, by editing the face field.
884 You can use the following variables in the FORM field.
886 score: The article's score
887 default: The default article score.
888 default-high: The default score for high scored articles.
889 default-low: The default score for low scored articles.
890 below: The score below which articles are automatically marked as read.
891 mark: The articles mark."
892 :group 'gnus-summary-visual
893 :type '(repeat (cons (sexp :tag "Form" nil)
896 (defcustom gnus-alter-header-function nil
897 "Function called to allow alteration of article header structures.
898 The function is called with one parameter, the article header vector,
899 which it may alter in any way.")
901 (defvar gnus-decode-encoded-word-function
902 (mime-find-field-decoder 'From 'nov)
903 "Variable that says which function should be used to decode a string with encoded words.")
905 (defcustom gnus-extra-headers nil
906 "*Extra headers to parse."
909 :type '(repeat symbol))
911 (defcustom gnus-ignored-from-addresses
912 (and user-mail-address (regexp-quote user-mail-address))
913 "*Regexp of From headers that may be suppressed in favor of To headers."
918 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
919 "List of charsets that should be ignored.
920 When these charsets are used in the \"charset\" parameter, the
921 default charset will be used instead."
923 :type '(repeat symbol)
924 :group 'gnus-charset)
926 (gnus-define-group-parameter
930 "Return the ignored charsets of GROUP."
931 :variable gnus-group-ignored-charsets-alist
933 '(("alt\\.chinese\\.text" iso-8859-1))
935 "Alist of regexps (to match group names) and charsets that should be ignored.
936 When these charsets are used in the \"charset\" parameter, the
937 default charset will be used instead."
938 :variable-group gnus-charset
939 :variable-type '(repeat (cons (regexp :tag "Group")
941 :parameter-type '(choice :tag "Ignored charsets"
944 :parameter-document "\
945 List of charsets that should be ignored.
947 When these charsets are used in the \"charset\" parameter, the
948 default charset will be used instead.")
950 (defcustom gnus-group-highlight-words-alist nil
951 "Alist of group regexps and highlight regexps.
952 This variable uses the same syntax as `gnus-emphasis-alist'."
954 :type '(repeat (cons (regexp :tag "Group")
955 (repeat (list (regexp :tag "Highlight regexp")
956 (number :tag "Group for entire word" 0)
957 (number :tag "Group for displayed part" 0)
959 gnus-emphasis-highlight-words)))))
960 :group 'gnus-summary-visual)
962 (defcustom gnus-use-wheel nil
963 "Use Intelli-mouse on summary movement"
965 :group 'gnus-summary-maneuvering)
967 (defcustom gnus-wheel-scroll-amount '(5 . 1)
968 "Amount to scroll messages by spinning the mouse wheel.
969 This is actually a cons cell, where the first item is the amount to scroll
970 on a normal wheel event, and the second is the amount to scroll when the
971 wheel is moved with the shift key depressed."
972 :type '(cons (integer :tag "Shift") integer)
973 :group 'gnus-summary-maneuvering)
975 (defcustom gnus-wheel-edge-resistance 2
976 "How hard it should be to change the current article
977 by moving the mouse over the edge of the article window."
979 :group 'gnus-summary-maneuvering)
981 (defcustom gnus-summary-show-article-charset-alist
983 "Alist of number and charset.
984 The article will be shown with the charset corresponding to the
986 For example: ((1 . cn-gb-2312) (2 . big5))."
988 :type '(repeat (cons (number :tag "Argument" 1)
989 (symbol :tag "Charset")))
990 :group 'gnus-charset)
992 (defcustom gnus-preserve-marks t
993 "Whether marks are preserved when moving, copying and respooling messages."
996 :group 'gnus-summary-marks)
998 (defcustom gnus-alter-articles-to-read-function nil
999 "Function to be called to alter the list of articles to be selected."
1000 :type '(choice (const nil) function)
1001 :group 'gnus-summary)
1003 (defcustom gnus-orphan-score nil
1004 "*All orphans get this score added. Set in the score file."
1005 :group 'gnus-score-default
1006 :type '(choice (const nil)
1009 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1010 "*A regexp to match MIME parts when saving multiple parts of a message
1011 with gnus-summary-save-parts (X m). This regexp will be used by default
1012 when prompting the user for which type of files to save."
1013 :group 'gnus-summary
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
1024 (defcustom gnus-read-all-available-headers nil
1025 "Whether Gnus should parse all headers made available to it.
1026 This is mostly relevant for slow backends where the user may
1027 wish to widen the summary buffer to include all headers
1028 that were fetched. Say, for nnultimate groups."
1029 :group 'gnus-summary
1030 :type '(choice boolean regexp))
1032 ;;; Internal variables
1034 (defvar gnus-article-mime-handles nil)
1035 (defvar gnus-article-decoded-p nil)
1036 (defvar gnus-article-charset nil)
1037 (defvar gnus-article-ignored-charsets nil)
1038 (defvar gnus-scores-exclude-files nil)
1039 (defvar gnus-page-broken nil)
1040 (defvar gnus-inhibit-mime-unbuttonizing nil)
1042 (defvar gnus-original-article nil)
1043 (defvar gnus-article-internal-prepare-hook nil)
1044 (defvar gnus-newsgroup-process-stack nil)
1046 (defvar gnus-thread-indent-array nil)
1047 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1048 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1049 "Function called to sort the articles within a thread after it has been gathered together.")
1051 (defvar gnus-summary-save-parts-type-history nil)
1052 (defvar gnus-summary-save-parts-last-directory nil)
1054 (defvar gnus-summary-save-parts-type-history nil)
1055 (defvar gnus-summary-save-parts-last-directory nil)
1057 ;; Avoid highlighting in kill files.
1058 (defvar gnus-summary-inhibit-highlight nil)
1059 (defvar gnus-newsgroup-selected-overlay nil)
1060 (defvar gnus-inhibit-limiting nil)
1061 (defvar gnus-newsgroup-adaptive-score-file nil)
1062 (defvar gnus-current-score-file nil)
1063 (defvar gnus-current-move-group nil)
1064 (defvar gnus-current-copy-group nil)
1065 (defvar gnus-current-crosspost-group nil)
1067 (defvar gnus-newsgroup-dependencies nil)
1068 (defvar gnus-newsgroup-adaptive nil)
1069 (defvar gnus-summary-display-article-function nil)
1070 (defvar gnus-summary-highlight-line-function nil
1071 "Function called after highlighting a summary line.")
1073 (defvar gnus-summary-line-format-alist
1074 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1075 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1076 (?s gnus-tmp-subject-or-nil ?s)
1077 (?n gnus-tmp-name ?s)
1078 (?A (std11-address-string
1079 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1080 (?a (or (std11-full-name-string
1081 (car (mime-entity-read-field gnus-tmp-header 'From)))
1083 (?F gnus-tmp-from ?s)
1084 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1085 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1086 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1087 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1088 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1089 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1090 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1091 (?L gnus-tmp-lines ?s)
1092 (?I gnus-tmp-indentation ?s)
1093 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1094 (?R gnus-tmp-replied ?c)
1095 (?\[ gnus-tmp-opening-bracket ?c)
1096 (?\] gnus-tmp-closing-bracket ?c)
1097 (?\> (make-string gnus-tmp-level ? ) ?s)
1098 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1099 (?i gnus-tmp-score ?d)
1100 (?z gnus-tmp-score-char ?c)
1101 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1102 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1103 (?U gnus-tmp-unread ?c)
1104 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1105 (?t (gnus-summary-number-of-articles-in-thread
1106 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1108 (?e (gnus-summary-number-of-articles-in-thread
1109 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1111 (?u gnus-tmp-user-defined ?s)
1112 (?P (gnus-pick-line-number) ?d))
1113 "An alist of format specifications that can appear in summary lines.
1114 These are paired with what variables they correspond with, along with
1115 the type of the variable (string, integer, character, etc).")
1117 (defvar gnus-summary-dummy-line-format-alist
1118 `((?S gnus-tmp-subject ?s)
1119 (?N gnus-tmp-number ?d)
1120 (?u gnus-tmp-user-defined ?s)))
1122 (defvar gnus-summary-mode-line-format-alist
1123 `((?G gnus-tmp-group-name ?s)
1124 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1125 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1126 (?A gnus-tmp-article-number ?d)
1127 (?Z gnus-tmp-unread-and-unselected ?s)
1128 (?V gnus-version ?s)
1129 (?U gnus-tmp-unread-and-unticked ?d)
1130 (?S gnus-tmp-subject ?s)
1131 (?e gnus-tmp-unselected ?d)
1132 (?u gnus-tmp-user-defined ?s)
1133 (?d (length gnus-newsgroup-dormant) ?d)
1134 (?t (length gnus-newsgroup-marked) ?d)
1135 (?r (length gnus-newsgroup-reads) ?d)
1136 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1137 (?E gnus-newsgroup-expunged-tally ?d)
1138 (?s (gnus-current-score-file-nondirectory) ?s)))
1140 (defvar gnus-last-search-regexp nil
1141 "Default regexp for article search command.")
1143 (defvar gnus-summary-search-article-matched-data nil
1144 "Last matched data of article search command. It is the local variable
1145 in `gnus-article-buffer' which consists of the list of start position,
1146 end position and text.")
1148 (defvar gnus-last-shell-command nil
1149 "Default shell command on article.")
1151 (defvar gnus-newsgroup-begin nil)
1152 (defvar gnus-newsgroup-end nil)
1153 (defvar gnus-newsgroup-last-rmail nil)
1154 (defvar gnus-newsgroup-last-mail nil)
1155 (defvar gnus-newsgroup-last-folder nil)
1156 (defvar gnus-newsgroup-last-file nil)
1157 (defvar gnus-newsgroup-auto-expire nil)
1158 (defvar gnus-newsgroup-active nil)
1160 (defvar gnus-newsgroup-data nil)
1161 (defvar gnus-newsgroup-data-reverse nil)
1162 (defvar gnus-newsgroup-limit nil)
1163 (defvar gnus-newsgroup-limits nil)
1165 (defvar gnus-newsgroup-unreads nil
1166 "List of unread articles in the current newsgroup.")
1168 (defvar gnus-newsgroup-unselected nil
1169 "List of unselected unread articles in the current newsgroup.")
1171 (defvar gnus-newsgroup-reads nil
1172 "Alist of read articles and article marks in the current newsgroup.")
1174 (defvar gnus-newsgroup-expunged-tally nil)
1176 (defvar gnus-newsgroup-marked nil
1177 "List of ticked articles in the current newsgroup (a subset of unread art).")
1179 (defvar gnus-newsgroup-killed nil
1180 "List of ranges of articles that have been through the scoring process.")
1182 (defvar gnus-newsgroup-cached nil
1183 "List of articles that come from the article cache.")
1185 (defvar gnus-newsgroup-saved nil
1186 "List of articles that have been saved.")
1188 (defvar gnus-newsgroup-kill-headers nil)
1190 (defvar gnus-newsgroup-replied nil
1191 "List of articles that have been replied to in the current newsgroup.")
1193 (defvar gnus-newsgroup-forwarded nil
1194 "List of articles that have been forwarded in the current newsgroup.")
1196 (defvar gnus-newsgroup-expirable nil
1197 "List of articles in the current newsgroup that can be expired.")
1199 (defvar gnus-newsgroup-processable nil
1200 "List of articles in the current newsgroup that can be processed.")
1202 (defvar gnus-newsgroup-downloadable nil
1203 "List of articles in the current newsgroup that can be processed.")
1205 (defvar gnus-newsgroup-undownloaded nil
1206 "List of articles in the current newsgroup that haven't been downloaded..")
1208 (defvar gnus-newsgroup-unsendable nil
1209 "List of articles in the current newsgroup that won't be sent.")
1211 (defvar gnus-newsgroup-bookmarks nil
1212 "List of articles in the current newsgroup that have bookmarks.")
1214 (defvar gnus-newsgroup-dormant nil
1215 "List of dormant articles in the current newsgroup.")
1217 (defvar gnus-newsgroup-scored nil
1218 "List of scored articles in the current newsgroup.")
1220 (defvar gnus-newsgroup-incorporated nil
1221 "List of incorporated articles in the current newsgroup.")
1223 (defvar gnus-newsgroup-headers nil
1224 "List of article headers in the current newsgroup.")
1226 (defvar gnus-newsgroup-threads nil)
1228 (defvar gnus-newsgroup-prepared nil
1229 "Whether the current group has been prepared properly.")
1231 (defvar gnus-newsgroup-ancient nil
1232 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1234 (defvar gnus-newsgroup-sparse nil)
1236 (defvar gnus-current-article nil)
1237 (defvar gnus-article-current nil)
1238 (defvar gnus-current-headers nil)
1239 (defvar gnus-have-all-headers nil)
1240 (defvar gnus-last-article nil)
1241 (defvar gnus-newsgroup-history nil)
1242 (defvar gnus-newsgroup-charset nil)
1243 (defvar gnus-newsgroup-ephemeral-charset nil)
1244 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1246 (defvar gnus-article-before-search nil)
1248 (defconst gnus-summary-local-variables
1249 '(gnus-newsgroup-name
1250 gnus-newsgroup-begin gnus-newsgroup-end
1251 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1252 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1253 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1254 gnus-newsgroup-unselected gnus-newsgroup-marked
1255 gnus-newsgroup-reads gnus-newsgroup-saved
1256 gnus-newsgroup-replied gnus-newsgroup-forwarded
1257 gnus-newsgroup-expirable
1258 gnus-newsgroup-processable gnus-newsgroup-killed
1259 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1260 gnus-newsgroup-unsendable
1261 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1262 gnus-newsgroup-headers gnus-newsgroup-threads
1263 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1264 gnus-current-article gnus-current-headers gnus-have-all-headers
1265 gnus-last-article gnus-article-internal-prepare-hook
1266 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1267 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1268 gnus-thread-expunge-below
1269 gnus-score-alist gnus-current-score-file
1270 (gnus-summary-expunge-below . global)
1271 (gnus-summary-mark-below . global)
1272 (gnus-orphan-score . global)
1273 gnus-newsgroup-active gnus-scores-exclude-files
1274 gnus-newsgroup-history gnus-newsgroup-ancient
1275 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1276 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1277 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1278 (gnus-newsgroup-expunged-tally . 0)
1279 gnus-cache-removable-articles gnus-newsgroup-cached
1280 gnus-newsgroup-data gnus-newsgroup-data-reverse
1281 gnus-newsgroup-limit gnus-newsgroup-limits
1282 gnus-newsgroup-charset
1283 gnus-newsgroup-incorporated)
1284 "Variables that are buffer-local to the summary buffers.")
1286 (defvar gnus-newsgroup-variables nil
1287 "Variables that have separate values in the newsgroups.")
1289 ;; Byte-compiler warning.
1290 (eval-when-compile (defvar gnus-article-mode-map))
1292 ;; Subject simplification.
1294 (defun gnus-simplify-whitespace (str)
1295 "Remove excessive whitespace from STR."
1298 (while (string-match "[ \t][ \t]+" mystr)
1299 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1301 (substring mystr (match-end 0)))))
1303 (when (string-match "^[ \t]+" mystr)
1304 (setq mystr (substring mystr (match-end 0))))
1306 (when (string-match "[ \t]+$" mystr)
1307 (setq mystr (substring mystr 0 (match-beginning 0))))
1310 (defsubst gnus-simplify-subject-re (subject)
1311 "Remove \"Re:\" from subject lines."
1312 (if (string-match message-subject-re-regexp subject)
1313 (substring subject (match-end 0))
1316 (defun gnus-simplify-subject (subject &optional re-only)
1317 "Remove `Re:' and words in parentheses.
1318 If RE-ONLY is non-nil, strip leading `Re:'s only."
1319 (let ((case-fold-search t)) ;Ignore case.
1320 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1321 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1322 (setq subject (substring subject (match-end 0))))
1323 ;; Remove uninteresting prefixes.
1324 (when (and (not re-only)
1325 gnus-simplify-ignored-prefixes
1326 (string-match gnus-simplify-ignored-prefixes subject))
1327 (setq subject (substring subject (match-end 0))))
1328 ;; Remove words in parentheses from end.
1330 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1331 (setq subject (substring subject 0 (match-beginning 0)))))
1332 ;; Return subject string.
1335 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1337 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1338 (goto-char (point-min))
1339 (while (re-search-forward regexp nil t)
1340 (replace-match (or newtext ""))))
1342 (defun gnus-simplify-buffer-fuzzy ()
1343 "Simplify string in the buffer fuzzily.
1344 The string in the accessible portion of the current buffer is simplified.
1345 It is assumed to be a single-line subject.
1346 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1347 matter is removed. Additional things can be deleted by setting
1348 `gnus-simplify-subject-fuzzy-regexp'."
1349 (let ((case-fold-search t)
1351 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1353 (while (not (eq modified-tick (buffer-modified-tick)))
1354 (setq modified-tick (buffer-modified-tick))
1356 ((listp gnus-simplify-subject-fuzzy-regexp)
1357 (mapcar 'gnus-simplify-buffer-fuzzy-step
1358 gnus-simplify-subject-fuzzy-regexp))
1359 (gnus-simplify-subject-fuzzy-regexp
1360 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1361 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1362 (gnus-simplify-buffer-fuzzy-step
1363 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1364 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1366 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1367 (gnus-simplify-buffer-fuzzy-step " +" " ")
1368 (gnus-simplify-buffer-fuzzy-step " $")
1369 (gnus-simplify-buffer-fuzzy-step "^ +")))
1371 (defun gnus-simplify-subject-fuzzy (subject)
1372 "Simplify a subject string fuzzily.
1373 See `gnus-simplify-buffer-fuzzy' for details."
1375 (gnus-set-work-buffer)
1376 (let ((case-fold-search t))
1377 ;; Remove uninteresting prefixes.
1378 (when (and gnus-simplify-ignored-prefixes
1379 (string-match gnus-simplify-ignored-prefixes subject))
1380 (setq subject (substring subject (match-end 0))))
1382 (inline (gnus-simplify-buffer-fuzzy))
1385 (defsubst gnus-simplify-subject-fully (subject)
1386 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1388 (gnus-simplify-subject-functions
1389 (gnus-map-function gnus-simplify-subject-functions subject))
1390 ((null gnus-summary-gather-subject-limit)
1391 (gnus-simplify-subject-re subject))
1392 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1393 (gnus-simplify-subject-fuzzy subject))
1394 ((numberp gnus-summary-gather-subject-limit)
1395 (gnus-limit-string (gnus-simplify-subject-re subject)
1396 gnus-summary-gather-subject-limit))
1400 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1401 "Check whether two subjects are equal.
1402 If optional argument simple-first is t, first argument is already
1405 ((null simple-first)
1406 (equal (gnus-simplify-subject-fully s1)
1407 (gnus-simplify-subject-fully s2)))
1410 (gnus-simplify-subject-fully s2)))))
1412 (defun gnus-summary-bubble-group ()
1413 "Increase the score of the current group.
1414 This is a handy function to add to `gnus-summary-exit-hook' to
1415 increase the score of each group you read."
1416 (gnus-group-add-score gnus-newsgroup-name))
1420 ;;; Gnus summary mode
1423 (put 'gnus-summary-mode 'mode-class 'special)
1425 (defvar gnus-article-commands-menu)
1428 ;; Non-orthogonal keys
1430 (gnus-define-keys gnus-summary-mode-map
1431 " " gnus-summary-next-page
1432 "\177" gnus-summary-prev-page
1433 [delete] gnus-summary-prev-page
1434 [backspace] gnus-summary-prev-page
1435 "\r" gnus-summary-scroll-up
1436 "\M-\r" gnus-summary-scroll-down
1437 "n" gnus-summary-next-unread-article
1438 "p" gnus-summary-prev-unread-article
1439 "N" gnus-summary-next-article
1440 "P" gnus-summary-prev-article
1441 "\M-\C-n" gnus-summary-next-same-subject
1442 "\M-\C-p" gnus-summary-prev-same-subject
1443 "\M-n" gnus-summary-next-unread-subject
1444 "\M-p" gnus-summary-prev-unread-subject
1445 "." gnus-summary-first-unread-article
1446 "," gnus-summary-best-unread-article
1447 "\M-s" gnus-summary-search-article-forward
1448 "\M-r" gnus-summary-search-article-backward
1449 "<" gnus-summary-beginning-of-article
1450 ">" gnus-summary-end-of-article
1451 "j" gnus-summary-goto-article
1452 "^" gnus-summary-refer-parent-article
1453 "\M-^" gnus-summary-refer-article
1454 "u" gnus-summary-tick-article-forward
1455 "!" gnus-summary-tick-article-forward
1456 "U" gnus-summary-tick-article-backward
1457 "d" gnus-summary-mark-as-read-forward
1458 "D" gnus-summary-mark-as-read-backward
1459 "E" gnus-summary-mark-as-expirable
1460 "\M-u" gnus-summary-clear-mark-forward
1461 "\M-U" gnus-summary-clear-mark-backward
1462 "k" gnus-summary-kill-same-subject-and-select
1463 "\C-k" gnus-summary-kill-same-subject
1464 "\M-\C-k" gnus-summary-kill-thread
1465 "\M-\C-l" gnus-summary-lower-thread
1466 "e" gnus-summary-edit-article
1467 "#" gnus-summary-mark-as-processable
1468 "\M-#" gnus-summary-unmark-as-processable
1469 "\M-\C-t" gnus-summary-toggle-threads
1470 "\M-\C-s" gnus-summary-show-thread
1471 "\M-\C-h" gnus-summary-hide-thread
1472 "\M-\C-f" gnus-summary-next-thread
1473 "\M-\C-b" gnus-summary-prev-thread
1474 [(meta down)] gnus-summary-next-thread
1475 [(meta up)] gnus-summary-prev-thread
1476 "\M-\C-u" gnus-summary-up-thread
1477 "\M-\C-d" gnus-summary-down-thread
1478 "&" gnus-summary-execute-command
1479 "c" gnus-summary-catchup-and-exit
1480 "\C-w" gnus-summary-mark-region-as-read
1481 "\C-t" gnus-summary-toggle-truncation
1482 "?" gnus-summary-mark-as-dormant
1483 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1484 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1485 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1486 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1487 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1488 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1489 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1490 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1491 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1492 "=" gnus-summary-expand-window
1493 "\C-x\C-s" gnus-summary-reselect-current-group
1494 "\M-g" gnus-summary-rescan-group
1495 "w" gnus-summary-stop-page-breaking
1496 "\C-c\C-r" gnus-summary-caesar-message
1497 "\M-t" gnus-summary-toggle-mime
1498 "f" gnus-summary-followup
1499 "F" gnus-summary-followup-with-original
1500 "C" gnus-summary-cancel-article
1501 "r" gnus-summary-reply
1502 "R" gnus-summary-reply-with-original
1503 "\C-c\C-f" gnus-summary-mail-forward
1504 "o" gnus-summary-save-article
1505 "\C-o" gnus-summary-save-article-mail
1506 "|" gnus-summary-pipe-output
1507 "\M-k" gnus-summary-edit-local-kill
1508 "\M-K" gnus-summary-edit-global-kill
1510 "\C-c\C-d" gnus-summary-describe-group
1511 "q" gnus-summary-exit
1512 "Q" gnus-summary-exit-no-update
1513 "\C-c\C-i" gnus-info-find-node
1514 gnus-mouse-2 gnus-mouse-pick-article
1515 "m" gnus-summary-mail-other-window
1516 "a" gnus-summary-post-news
1517 "x" gnus-summary-limit-to-unread
1518 "s" gnus-summary-isearch-article
1519 "t" gnus-article-toggle-headers
1520 "g" gnus-summary-show-article
1521 "l" gnus-summary-goto-last-article
1522 "v" gnus-summary-preview-mime-message
1523 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1524 "\C-d" gnus-summary-enter-digest-group
1525 "\M-\C-d" gnus-summary-read-document
1526 "\M-\C-e" gnus-summary-edit-parameters
1527 "\M-\C-a" gnus-summary-customize-parameters
1529 "*" gnus-cache-enter-article
1530 "\M-*" gnus-cache-remove-article
1531 "\M-&" gnus-summary-universal-argument
1532 "\C-l" gnus-recenter
1533 "I" gnus-summary-increase-score
1534 "L" gnus-summary-lower-score
1535 "\M-i" gnus-symbolic-argument
1536 "h" gnus-summary-select-article-buffer
1538 "V" gnus-summary-score-map
1539 "X" gnus-uu-extract-map
1540 "S" gnus-summary-send-map)
1542 ;; Sort of orthogonal keymap
1543 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1544 "t" gnus-summary-tick-article-forward
1545 "!" gnus-summary-tick-article-forward
1546 "d" gnus-summary-mark-as-read-forward
1547 "r" gnus-summary-mark-as-read-forward
1548 "c" gnus-summary-clear-mark-forward
1549 " " gnus-summary-clear-mark-forward
1550 "e" gnus-summary-mark-as-expirable
1551 "x" gnus-summary-mark-as-expirable
1552 "?" gnus-summary-mark-as-dormant
1553 "b" gnus-summary-set-bookmark
1554 "B" gnus-summary-remove-bookmark
1555 "#" gnus-summary-mark-as-processable
1556 "\M-#" gnus-summary-unmark-as-processable
1557 "S" gnus-summary-limit-include-expunged
1558 "C" gnus-summary-catchup
1559 "H" gnus-summary-catchup-to-here
1560 "h" gnus-summary-catchup-from-here
1561 "\C-c" gnus-summary-catchup-all
1562 "k" gnus-summary-kill-same-subject-and-select
1563 "K" gnus-summary-kill-same-subject
1564 "P" gnus-uu-mark-map)
1566 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1567 "c" gnus-summary-clear-above
1568 "u" gnus-summary-tick-above
1569 "m" gnus-summary-mark-above
1570 "k" gnus-summary-kill-below)
1572 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1573 "/" gnus-summary-limit-to-subject
1574 "n" gnus-summary-limit-to-articles
1575 "w" gnus-summary-pop-limit
1576 "s" gnus-summary-limit-to-subject
1577 "a" gnus-summary-limit-to-author
1578 "u" gnus-summary-limit-to-unread
1579 "m" gnus-summary-limit-to-marks
1580 "M" gnus-summary-limit-exclude-marks
1581 "v" gnus-summary-limit-to-score
1582 "*" gnus-summary-limit-include-cached
1583 "D" gnus-summary-limit-include-dormant
1584 "T" gnus-summary-limit-include-thread
1585 "d" gnus-summary-limit-exclude-dormant
1586 "t" gnus-summary-limit-to-age
1587 "x" gnus-summary-limit-to-extra
1588 "E" gnus-summary-limit-include-expunged
1589 "c" gnus-summary-limit-exclude-childless-dormant
1590 "C" gnus-summary-limit-mark-excluded-as-read
1591 "o" gnus-summary-insert-old-articles
1592 "N" gnus-summary-insert-new-articles)
1594 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1595 "n" gnus-summary-next-unread-article
1596 "p" gnus-summary-prev-unread-article
1597 "N" gnus-summary-next-article
1598 "P" gnus-summary-prev-article
1599 "\C-n" gnus-summary-next-same-subject
1600 "\C-p" gnus-summary-prev-same-subject
1601 "\M-n" gnus-summary-next-unread-subject
1602 "\M-p" gnus-summary-prev-unread-subject
1603 "f" gnus-summary-first-unread-article
1604 "b" gnus-summary-best-unread-article
1605 "j" gnus-summary-goto-article
1606 "g" gnus-summary-goto-subject
1607 "l" gnus-summary-goto-last-article
1608 "o" gnus-summary-pop-article)
1610 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1611 "k" gnus-summary-kill-thread
1612 "l" gnus-summary-lower-thread
1613 "i" gnus-summary-raise-thread
1614 "T" gnus-summary-toggle-threads
1615 "t" gnus-summary-rethread-current
1616 "^" gnus-summary-reparent-thread
1617 "s" gnus-summary-show-thread
1618 "S" gnus-summary-show-all-threads
1619 "h" gnus-summary-hide-thread
1620 "H" gnus-summary-hide-all-threads
1621 "n" gnus-summary-next-thread
1622 "p" gnus-summary-prev-thread
1623 "u" gnus-summary-up-thread
1624 "o" gnus-summary-top-thread
1625 "d" gnus-summary-down-thread
1626 "#" gnus-uu-mark-thread
1627 "\M-#" gnus-uu-unmark-thread)
1629 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1630 "g" gnus-summary-prepare
1631 "c" gnus-summary-insert-cached-articles)
1633 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1634 "c" gnus-summary-catchup-and-exit
1635 "C" gnus-summary-catchup-all-and-exit
1636 "E" gnus-summary-exit-no-update
1637 "J" gnus-summary-jump-to-other-group
1638 "Q" gnus-summary-exit
1639 "Z" gnus-summary-exit
1640 "n" gnus-summary-catchup-and-goto-next-group
1641 "R" gnus-summary-reselect-current-group
1642 "G" gnus-summary-rescan-group
1643 "N" gnus-summary-next-group
1644 "s" gnus-summary-save-newsrc
1645 "P" gnus-summary-prev-group)
1647 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1648 " " gnus-summary-next-page
1649 "n" gnus-summary-next-page
1650 "\177" gnus-summary-prev-page
1651 [delete] gnus-summary-prev-page
1652 "p" gnus-summary-prev-page
1653 "\r" gnus-summary-scroll-up
1654 "\M-\r" gnus-summary-scroll-down
1655 "<" gnus-summary-beginning-of-article
1656 ">" gnus-summary-end-of-article
1657 "b" gnus-summary-beginning-of-article
1658 "e" gnus-summary-end-of-article
1659 "^" gnus-summary-refer-parent-article
1660 "r" gnus-summary-refer-parent-article
1661 "D" gnus-summary-enter-digest-group
1662 "R" gnus-summary-refer-references
1663 "T" gnus-summary-refer-thread
1664 "g" gnus-summary-show-article
1665 "s" gnus-summary-isearch-article
1666 "P" gnus-summary-print-article
1667 "M" gnus-mailing-list-insinuate
1668 "t" gnus-article-babel)
1670 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1671 "b" gnus-article-add-buttons
1672 "B" gnus-article-add-buttons-to-head
1673 "o" gnus-article-treat-overstrike
1674 "e" gnus-article-emphasize
1675 "w" gnus-article-fill-cited-article
1676 "Q" gnus-article-fill-long-lines
1677 "C" gnus-article-capitalize-sentences
1678 "c" gnus-article-remove-cr
1679 "Z" gnus-article-decode-HZ
1680 "f" gnus-article-display-x-face
1681 "l" gnus-summary-stop-page-breaking
1682 "r" gnus-summary-caesar-message
1683 "t" gnus-article-toggle-headers
1684 "v" gnus-summary-verbose-headers
1685 "m" gnus-summary-toggle-mime
1686 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1687 "p" gnus-article-verify-x-pgp-sig
1688 "d" gnus-article-treat-dumbquotes
1689 "s" gnus-smiley-display)
1691 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1692 "a" gnus-article-hide
1693 "h" gnus-article-toggle-headers
1694 "b" gnus-article-hide-boring-headers
1695 "s" gnus-article-hide-signature
1696 "c" gnus-article-hide-citation
1697 "C" gnus-article-hide-citation-in-followups
1698 "l" gnus-article-hide-list-identifiers
1699 "p" gnus-article-hide-pgp
1700 "B" gnus-article-strip-banner
1701 "P" gnus-article-hide-pem
1702 "\C-c" gnus-article-hide-citation-maybe)
1704 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1705 "a" gnus-article-highlight
1706 "h" gnus-article-highlight-headers
1707 "c" gnus-article-highlight-citation
1708 "s" gnus-article-highlight-signature)
1710 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1711 "z" gnus-article-date-ut
1712 "u" gnus-article-date-ut
1713 "l" gnus-article-date-local
1714 "p" gnus-article-date-english
1715 "e" gnus-article-date-lapsed
1716 "o" gnus-article-date-original
1717 "i" gnus-article-date-iso8601
1718 "s" gnus-article-date-user)
1720 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1721 "t" gnus-article-remove-trailing-blank-lines
1722 "l" gnus-article-strip-leading-blank-lines
1723 "m" gnus-article-strip-multiple-blank-lines
1724 "a" gnus-article-strip-blank-lines
1725 "A" gnus-article-strip-all-blank-lines
1726 "s" gnus-article-strip-leading-space
1727 "e" gnus-article-strip-trailing-space
1728 "w" gnus-article-remove-leading-whitespace)
1730 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1732 "f" gnus-summary-fetch-faq
1733 "d" gnus-summary-describe-group
1734 "h" gnus-summary-describe-briefly
1735 "i" gnus-info-find-node)
1737 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1738 "e" gnus-summary-expire-articles
1739 "\M-\C-e" gnus-summary-expire-articles-now
1740 "\177" gnus-summary-delete-article
1741 [delete] gnus-summary-delete-article
1742 [backspace] gnus-summary-delete-article
1743 "m" gnus-summary-move-article
1744 "r" gnus-summary-respool-article
1745 "w" gnus-summary-edit-article
1746 "c" gnus-summary-copy-article
1747 "B" gnus-summary-crosspost-article
1748 "q" gnus-summary-respool-query
1749 "t" gnus-summary-respool-trace
1750 "i" gnus-summary-import-article
1751 "I" gnus-summary-create-article
1752 "p" gnus-summary-article-posted-p)
1754 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1755 "o" gnus-summary-save-article
1756 "m" gnus-summary-save-article-mail
1757 "F" gnus-summary-write-article-file
1758 "r" gnus-summary-save-article-rmail
1759 "f" gnus-summary-save-article-file
1760 "b" gnus-summary-save-article-body-file
1761 "h" gnus-summary-save-article-folder
1762 "v" gnus-summary-save-article-vm
1763 "p" gnus-summary-pipe-output
1764 "s" gnus-soup-add-article)
1766 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1767 "b" gnus-summary-display-buttonized
1768 "m" gnus-summary-repair-multipart
1769 "v" gnus-article-view-part
1770 "o" gnus-article-save-part
1771 "c" gnus-article-copy-part
1772 "C" gnus-article-view-part-as-charset
1773 "e" gnus-article-externalize-part
1774 "E" gnus-article-encrypt-body
1775 "i" gnus-article-inline-part
1776 "|" gnus-article-pipe-part))
1778 (defvar gnus-article-post-menu nil)
1780 (defun gnus-summary-make-menu-bar ()
1781 (gnus-turn-off-edit-menu 'summary)
1783 (unless (boundp 'gnus-summary-misc-menu)
1786 gnus-summary-kill-menu gnus-summary-mode-map ""
1791 ["Customize" gnus-score-customize t])
1792 (gnus-make-score-map 'increase)
1793 (gnus-make-score-map 'lower)
1795 ["Kill below" gnus-summary-kill-below t]
1796 ["Mark above" gnus-summary-mark-above t]
1797 ["Tick above" gnus-summary-tick-above t]
1798 ["Clear above" gnus-summary-clear-above t])
1799 ["Current score" gnus-summary-current-score t]
1800 ["Set score" gnus-summary-set-score t]
1801 ["Switch current score file..." gnus-score-change-score-file t]
1802 ["Set mark below..." gnus-score-set-mark-below t]
1803 ["Set expunge below..." gnus-score-set-expunge-below t]
1804 ["Edit current score file" gnus-score-edit-current-scores t]
1805 ["Edit score file" gnus-score-edit-file t]
1806 ["Trace score" gnus-score-find-trace t]
1807 ["Find words" gnus-score-find-favourite-words t]
1808 ["Rescore buffer" gnus-summary-rescore t]
1809 ["Increase score..." gnus-summary-increase-score t]
1810 ["Lower score..." gnus-summary-lower-score t]))))
1812 ;; Define both the Article menu in the summary buffer and the equivalent
1813 ;; Commands menu in the article buffer here for consistency.
1816 ["All" gnus-article-hide t]
1817 ["Headers" gnus-article-toggle-headers t]
1818 ["Signature" gnus-article-hide-signature t]
1819 ["Citation" gnus-article-hide-citation t]
1820 ["List identifiers" gnus-article-hide-list-identifiers t]
1821 ["PGP" gnus-article-hide-pgp t]
1822 ["Banner" gnus-article-strip-banner t]
1823 ["Boring headers" gnus-article-hide-boring-headers t])
1825 ["All" gnus-article-highlight t]
1826 ["Headers" gnus-article-highlight-headers t]
1827 ["Signature" gnus-article-highlight-signature t]
1828 ["Citation" gnus-article-highlight-citation t])
1830 ["Local" gnus-article-date-local t]
1831 ["ISO8601" gnus-article-date-iso8601 t]
1832 ["UT" gnus-article-date-ut t]
1833 ["Original" gnus-article-date-original t]
1834 ["Lapsed" gnus-article-date-lapsed t]
1835 ["User-defined" gnus-article-date-user t])
1838 ["Leading" gnus-article-strip-leading-blank-lines t]
1839 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1840 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1841 ["All of the above" gnus-article-strip-blank-lines t]
1842 ["All" gnus-article-strip-all-blank-lines t]
1843 ["Leading space" gnus-article-strip-leading-space t]
1844 ["Trailing space" gnus-article-strip-trailing-space t]
1845 ["Leading space in headers"
1846 gnus-article-remove-leading-whitespace t])
1847 ["Overstrike" gnus-article-treat-overstrike t]
1848 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1849 ["Emphasis" gnus-article-emphasize t]
1850 ["Word wrap" gnus-article-fill-cited-article t]
1851 ["Fill long lines" gnus-article-fill-long-lines t]
1852 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1853 ["CR" gnus-article-remove-cr t]
1854 ["Show X-Face" gnus-article-display-x-face t]
1855 ["Rot 13" gnus-summary-caesar-message
1856 ,@(if (featurep 'xemacs) '(t)
1857 '(:help "\"Caesar rotate\" article by 13"))]
1858 ["Unix pipe" gnus-summary-pipe-message t]
1859 ["Add buttons" gnus-article-add-buttons t]
1860 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1861 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1862 ["Toggle MIME" gnus-summary-toggle-mime t]
1863 ["Verbose header" gnus-summary-verbose-headers t]
1864 ["Toggle header" gnus-summary-toggle-header t]
1865 ["Toggle smileys" gnus-smiley-display t]
1866 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1867 ["HZ" gnus-article-decode-HZ t])
1869 ["Save in default format" gnus-summary-save-article
1870 ,@(if (featurep 'xemacs) '(t)
1871 '(:help "Save article using default method"))]
1872 ["Save in file" gnus-summary-save-article-file
1873 ,@(if (featurep 'xemacs) '(t)
1874 '(:help "Save article in file"))]
1875 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1876 ["Save in MH folder" gnus-summary-save-article-folder t]
1877 ["Save in VM folder" gnus-summary-save-article-vm t]
1878 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1879 ["Save body in file" gnus-summary-save-article-body-file t]
1880 ["Pipe through a filter" gnus-summary-pipe-output t]
1881 ["Add to SOUP packet" gnus-soup-add-article t]
1882 ["Print" gnus-summary-print-article t])
1884 ["Respool article..." gnus-summary-respool-article t]
1885 ["Move article..." gnus-summary-move-article
1886 (gnus-check-backend-function
1887 'request-move-article gnus-newsgroup-name)]
1888 ["Copy article..." gnus-summary-copy-article t]
1889 ["Crosspost article..." gnus-summary-crosspost-article
1890 (gnus-check-backend-function
1891 'request-replace-article gnus-newsgroup-name)]
1892 ["Import file..." gnus-summary-import-article t]
1893 ["Create article..." gnus-summary-create-article t]
1894 ["Check if posted" gnus-summary-article-posted-p t]
1895 ["Edit article" gnus-summary-edit-article
1896 (not (gnus-group-read-only-p))]
1897 ["Delete article" gnus-summary-delete-article
1898 (gnus-check-backend-function
1899 'request-expire-articles gnus-newsgroup-name)]
1900 ["Query respool" gnus-summary-respool-query t]
1901 ["Trace respool" gnus-summary-respool-trace t]
1902 ["Delete expirable articles" gnus-summary-expire-articles-now
1903 (gnus-check-backend-function
1904 'request-expire-articles gnus-newsgroup-name)])
1906 ["Uudecode" gnus-uu-decode-uu
1907 ,@(if (featurep 'xemacs) '(t)
1908 '(:help "Decode uuencoded article(s)"))]
1909 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1910 ["Unshar" gnus-uu-decode-unshar t]
1911 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1912 ["Save" gnus-uu-decode-save t]
1913 ["Binhex" gnus-uu-decode-binhex t]
1914 ["Postscript" gnus-uu-decode-postscript t])
1916 ["Enter article" gnus-cache-enter-article t]
1917 ["Remove article" gnus-cache-remove-article t])
1918 ["Translate" gnus-article-babel t]
1919 ["Select article buffer" gnus-summary-select-article-buffer t]
1920 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1921 ["Isearch article..." gnus-summary-isearch-article t]
1922 ["Beginning of the article" gnus-summary-beginning-of-article t]
1923 ["End of the article" gnus-summary-end-of-article t]
1924 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1925 ["Fetch referenced articles" gnus-summary-refer-references t]
1926 ["Fetch current thread" gnus-summary-refer-thread t]
1927 ["Fetch article with id..." gnus-summary-refer-article t]
1928 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1929 ["Redisplay" gnus-summary-show-article t])))
1931 gnus-summary-article-menu gnus-summary-mode-map ""
1932 (cons "Article" innards))
1934 (if (not (keymapp gnus-summary-article-menu))
1936 gnus-article-commands-menu gnus-article-mode-map ""
1937 (cons "Commands" innards))
1938 ;; in Emacs, don't share menu.
1939 (setq gnus-article-commands-menu
1940 (copy-keymap gnus-summary-article-menu))
1941 (define-key gnus-article-mode-map [menu-bar commands]
1942 (cons "Commands" gnus-article-commands-menu))))
1945 gnus-summary-thread-menu gnus-summary-mode-map ""
1947 ["Toggle threading" gnus-summary-toggle-threads t]
1948 ["Hide threads" gnus-summary-hide-all-threads t]
1949 ["Show threads" gnus-summary-show-all-threads t]
1950 ["Hide thread" gnus-summary-hide-thread t]
1951 ["Show thread" gnus-summary-show-thread t]
1952 ["Go to next thread" gnus-summary-next-thread t]
1953 ["Go to previous thread" gnus-summary-prev-thread t]
1954 ["Go down thread" gnus-summary-down-thread t]
1955 ["Go up thread" gnus-summary-up-thread t]
1956 ["Top of thread" gnus-summary-top-thread t]
1957 ["Mark thread as read" gnus-summary-kill-thread t]
1958 ["Lower thread score" gnus-summary-lower-thread t]
1959 ["Raise thread score" gnus-summary-raise-thread t]
1960 ["Rethread current" gnus-summary-rethread-current t]))
1963 gnus-summary-post-menu gnus-summary-mode-map ""
1965 ["Post an article" gnus-summary-post-news
1966 ,@(if (featurep 'xemacs) '(t)
1967 '(:help "Post an article"))]
1968 ["Followup" gnus-summary-followup
1969 ,@(if (featurep 'xemacs) '(t)
1970 '(:help "Post followup to this article"))]
1971 ["Followup and yank" gnus-summary-followup-with-original
1972 ,@(if (featurep 'xemacs) '(t)
1973 '(:help "Post followup to this article, quoting its contents"))]
1974 ["Supersede article" gnus-summary-supersede-article t]
1975 ["Cancel article" gnus-summary-cancel-article
1976 ,@(if (featurep 'xemacs) '(t)
1977 '(:help "Cancel an article you posted"))]
1978 ["Reply" gnus-summary-reply t]
1979 ["Reply and yank" gnus-summary-reply-with-original t]
1980 ["Wide reply" gnus-summary-wide-reply t]
1981 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1982 ,@(if (featurep 'xemacs) '(t)
1983 '(:help "Mail a reply, quoting this article"))]
1984 ["Mail forward" gnus-summary-mail-forward t]
1985 ["Post forward" gnus-summary-post-forward t]
1986 ["Digest and mail" gnus-summary-digest-mail-forward t]
1987 ["Digest and post" gnus-summary-digest-post-forward t]
1988 ["Resend message" gnus-summary-resend-message t]
1989 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1990 ["Send a mail" gnus-summary-mail-other-window t]
1991 ["Uuencode and post" gnus-uu-post-news
1992 ,@(if (featurep 'xemacs) '(t)
1993 '(:help "Post a uuencoded article"))]
1994 ["Followup via news" gnus-summary-followup-to-mail t]
1995 ["Followup via news and yank"
1996 gnus-summary-followup-to-mail-with-original t]
1998 ;;["Send" gnus-summary-send-draft t]
1999 ;;["Send bounced" gnus-resend-bounced-mail t])
2003 ((not (keymapp gnus-summary-post-menu))
2004 (setq gnus-article-post-menu gnus-summary-post-menu))
2005 ((not gnus-article-post-menu)
2006 ;; Don't share post menu.
2007 (setq gnus-article-post-menu
2008 (copy-keymap gnus-summary-post-menu))))
2009 (define-key gnus-article-mode-map [menu-bar post]
2010 (cons "Post" gnus-article-post-menu))
2013 gnus-summary-misc-menu gnus-summary-mode-map ""
2016 ["Mark as read" gnus-summary-mark-as-read-forward t]
2017 ["Mark same subject and select"
2018 gnus-summary-kill-same-subject-and-select t]
2019 ["Mark same subject" gnus-summary-kill-same-subject t]
2020 ["Catchup" gnus-summary-catchup
2021 ,@(if (featurep 'xemacs) '(t)
2022 '(:help "Mark unread articles in this group as read"))]
2023 ["Catchup all" gnus-summary-catchup-all t]
2024 ["Catchup to here" gnus-summary-catchup-to-here t]
2025 ["Catchup from here" gnus-summary-catchup-from-here t]
2026 ["Catchup region" gnus-summary-mark-region-as-read t]
2027 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2029 ["Tick" gnus-summary-tick-article-forward t]
2030 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2031 ["Remove marks" gnus-summary-clear-mark-forward t]
2032 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2033 ["Set bookmark" gnus-summary-set-bookmark t]
2034 ["Remove bookmark" gnus-summary-remove-bookmark t])
2036 ["Marks..." gnus-summary-limit-to-marks t]
2037 ["Subject..." gnus-summary-limit-to-subject t]
2038 ["Author..." gnus-summary-limit-to-author t]
2039 ["Age..." gnus-summary-limit-to-age t]
2040 ["Extra..." gnus-summary-limit-to-extra t]
2041 ["Score" gnus-summary-limit-to-score t]
2042 ["Unread" gnus-summary-limit-to-unread t]
2043 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2044 ["Articles" gnus-summary-limit-to-articles t]
2045 ["Pop limit" gnus-summary-pop-limit t]
2046 ["Show dormant" gnus-summary-limit-include-dormant t]
2047 ["Hide childless dormant"
2048 gnus-summary-limit-exclude-childless-dormant t]
2049 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2050 ["Hide marked" gnus-summary-limit-exclude-marks t]
2051 ["Show expunged" gnus-summary-limit-include-expunged t])
2053 ["Set mark" gnus-summary-mark-as-processable t]
2054 ["Remove mark" gnus-summary-unmark-as-processable t]
2055 ["Remove all marks" gnus-summary-unmark-all-processable t]
2056 ["Mark above" gnus-uu-mark-over t]
2057 ["Mark series" gnus-uu-mark-series t]
2058 ["Mark region" gnus-uu-mark-region t]
2059 ["Unmark region" gnus-uu-unmark-region t]
2060 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2061 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2062 ["Mark all" gnus-uu-mark-all t]
2063 ["Mark buffer" gnus-uu-mark-buffer t]
2064 ["Mark sparse" gnus-uu-mark-sparse t]
2065 ["Mark thread" gnus-uu-mark-thread t]
2066 ["Unmark thread" gnus-uu-unmark-thread t]
2067 ("Process Mark Sets"
2068 ["Kill" gnus-summary-kill-process-mark t]
2069 ["Yank" gnus-summary-yank-process-mark
2070 gnus-newsgroup-process-stack]
2071 ["Save" gnus-summary-save-process-mark t]))
2073 ["Page forward" gnus-summary-next-page
2074 ,@(if (featurep 'xemacs) '(t)
2075 '(:help "Show next page of article"))]
2076 ["Page backward" gnus-summary-prev-page
2077 ,@(if (featurep 'xemacs) '(t)
2078 '(:help "Show previous page of article"))]
2079 ["Line forward" gnus-summary-scroll-up t])
2081 ["Next unread article" gnus-summary-next-unread-article t]
2082 ["Previous unread article" gnus-summary-prev-unread-article t]
2083 ["Next article" gnus-summary-next-article t]
2084 ["Previous article" gnus-summary-prev-article t]
2085 ["Next unread subject" gnus-summary-next-unread-subject t]
2086 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2087 ["Next article same subject" gnus-summary-next-same-subject t]
2088 ["Previous article same subject" gnus-summary-prev-same-subject t]
2089 ["First unread article" gnus-summary-first-unread-article t]
2090 ["Best unread article" gnus-summary-best-unread-article t]
2091 ["Go to subject number..." gnus-summary-goto-subject t]
2092 ["Go to article number..." gnus-summary-goto-article t]
2093 ["Go to the last article" gnus-summary-goto-last-article t]
2094 ["Pop article off history" gnus-summary-pop-article t])
2096 ["Sort by number" gnus-summary-sort-by-number t]
2097 ["Sort by author" gnus-summary-sort-by-author t]
2098 ["Sort by subject" gnus-summary-sort-by-subject t]
2099 ["Sort by date" gnus-summary-sort-by-date t]
2100 ["Sort by score" gnus-summary-sort-by-score t]
2101 ["Sort by lines" gnus-summary-sort-by-lines t]
2102 ["Sort by characters" gnus-summary-sort-by-chars t]
2103 ["Original sort" gnus-summary-sort-by-original t])
2105 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2106 ["Describe group" gnus-summary-describe-group t]
2107 ["Read manual" gnus-info-find-node t])
2109 ["Pick and read" gnus-pick-mode t]
2110 ["Binary" gnus-binary-mode t])
2112 ["Regenerate" gnus-summary-prepare t]
2113 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2114 ["Toggle threading" gnus-summary-toggle-threads t])
2115 ["See old articles" gnus-summary-insert-old-articles t]
2116 ["See new articles" gnus-summary-insert-new-articles t]
2117 ["Filter articles..." gnus-summary-execute-command t]
2118 ["Run command on subjects..." gnus-summary-universal-argument t]
2119 ["Search articles forward..." gnus-summary-search-article-forward t]
2120 ["Search articles backward..." gnus-summary-search-article-backward t]
2121 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2122 ["Expand window" gnus-summary-expand-window t]
2123 ["Expire expirable articles" gnus-summary-expire-articles
2124 (gnus-check-backend-function
2125 'request-expire-articles gnus-newsgroup-name)]
2126 ["Edit local kill file" gnus-summary-edit-local-kill t]
2127 ["Edit main kill file" gnus-summary-edit-global-kill t]
2128 ["Edit group parameters" gnus-summary-edit-parameters t]
2129 ["Customize group parameters" gnus-summary-customize-parameters t]
2130 ["Send a bug report" gnus-bug t]
2132 ["Catchup and exit" gnus-summary-catchup-and-exit
2133 ,@(if (featurep 'xemacs) '(t)
2134 '(:help "Mark unread articles in this group as read, then exit"))]
2135 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2136 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2137 ["Exit group" gnus-summary-exit
2138 ,@(if (featurep 'xemacs) '(t)
2139 '(:help "Exit current group, return to group selection mode"))]
2140 ["Exit group without updating" gnus-summary-exit-no-update t]
2141 ["Exit and goto next group" gnus-summary-next-group t]
2142 ["Exit and goto prev group" gnus-summary-prev-group t]
2143 ["Reselect group" gnus-summary-reselect-current-group t]
2144 ["Rescan group" gnus-summary-rescan-group t]
2145 ["Update dribble" gnus-summary-save-newsrc t])))
2147 (gnus-run-hooks 'gnus-summary-menu-hook)))
2149 (defvar gnus-summary-tool-bar-map nil)
2151 ;; Emacs 21 tool bar. Should be no-op otherwise.
2152 (defun gnus-summary-make-tool-bar ()
2153 (if (and (fboundp 'tool-bar-add-item-from-menu)
2154 (default-value 'tool-bar-mode)
2155 (not gnus-summary-tool-bar-map))
2156 (setq gnus-summary-tool-bar-map
2157 (let ((tool-bar-map (make-sparse-keymap))
2158 (load-path (mm-image-load-path)))
2159 (tool-bar-add-item-from-menu
2160 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2161 (tool-bar-add-item-from-menu
2162 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2163 (tool-bar-add-item-from-menu
2164 'gnus-summary-post-news "post" gnus-summary-mode-map)
2165 (tool-bar-add-item-from-menu
2166 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2167 (tool-bar-add-item-from-menu
2168 'gnus-summary-followup "followup" gnus-summary-mode-map)
2169 (tool-bar-add-item-from-menu
2170 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2171 (tool-bar-add-item-from-menu
2172 'gnus-summary-reply "reply" gnus-summary-mode-map)
2173 (tool-bar-add-item-from-menu
2174 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2175 (tool-bar-add-item-from-menu
2176 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2177 (tool-bar-add-item-from-menu
2178 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2179 (tool-bar-add-item-from-menu
2180 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2181 (tool-bar-add-item-from-menu
2182 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2183 (tool-bar-add-item-from-menu
2184 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2185 (tool-bar-add-item-from-menu
2186 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2187 (tool-bar-add-item-from-menu
2188 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2190 (if gnus-summary-tool-bar-map
2191 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2193 (defun gnus-score-set-default (var value)
2194 "A version of set that updates the GNU Emacs menu-bar."
2196 ;; It is the message that forces the active status to be updated.
2199 (defun gnus-make-score-map (type)
2200 "Make a summary score map of type TYPE."
2203 (let ((headers '(("author" "from" string)
2204 ("subject" "subject" string)
2205 ("article body" "body" string)
2206 ("article head" "head" string)
2207 ("xref" "xref" string)
2208 ("extra header" "extra" string)
2209 ("lines" "lines" number)
2210 ("followups to author" "followup" string)))
2211 (types '((number ("less than" <)
2214 (string ("substring" s)
2218 (perms '(("temporary" (current-time-string))
2226 (if (eq type 'lower)
2231 (setq header (car headers))
2237 (let ((ts (cdr (assoc (nth 2 header) types)))
2253 'gnus-summary-score-entry
2255 (if (or (string= (nth 1 header)
2257 (string= (nth 1 header)
2260 (list 'gnus-summary-header
2262 (list 'quote (nth 1 (car ts)))
2263 (list 'gnus-score-delta-default
2270 (list (nreverse outp))))
2273 (list (nreverse outt))))
2275 (setq headers (cdr headers)))
2276 (list (nreverse outh))))))))
2280 (defun gnus-summary-mode (&optional group)
2281 "Major mode for reading articles.
2283 All normal editing commands are switched off.
2284 \\<gnus-summary-mode-map>
2285 Each line in this buffer represents one article. To read an
2286 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2287 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2290 You can also post articles and send mail from this buffer. To
2291 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2292 of an article, type `\\[gnus-summary-reply]'.
2294 There are approx. one gazillion commands you can execute in this
2295 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2297 The following commands are available:
2299 \\{gnus-summary-mode-map}"
2301 (kill-all-local-variables)
2302 (when (gnus-visual-p 'summary-menu 'menu)
2303 (gnus-summary-make-menu-bar)
2304 (gnus-summary-make-tool-bar))
2305 (gnus-summary-make-local-variables)
2306 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2307 (gnus-summary-make-local-variables))
2308 (gnus-make-thread-indent-array)
2309 (gnus-simplify-mode-line)
2310 (setq major-mode 'gnus-summary-mode)
2311 (setq mode-name "Summary")
2312 (make-local-variable 'minor-mode-alist)
2313 (use-local-map gnus-summary-mode-map)
2314 (buffer-disable-undo)
2315 (setq buffer-read-only t) ;Disable modification
2316 (setq truncate-lines t)
2317 (setq selective-display t)
2318 (setq selective-display-ellipses t) ;Display `...'
2319 (gnus-summary-set-display-table)
2320 (gnus-set-default-directory)
2321 (setq gnus-newsgroup-name group)
2322 (unless (gnus-news-group-p group)
2323 (setq gnus-newsgroup-incorporated
2324 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2325 (make-local-variable 'gnus-summary-line-format)
2326 (make-local-variable 'gnus-summary-line-format-spec)
2327 (make-local-variable 'gnus-summary-dummy-line-format)
2328 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2329 (make-local-variable 'gnus-summary-mark-positions)
2330 (make-local-hook 'pre-command-hook)
2331 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2332 (gnus-run-hooks 'gnus-summary-mode-hook)
2333 (turn-on-gnus-mailing-list-mode)
2334 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2335 (gnus-update-summary-mark-positions))
2337 (defun gnus-summary-make-local-variables ()
2338 "Make all the local summary buffer variables."
2340 (dolist (local gnus-summary-local-variables)
2343 (if (eq (cdr local) 'global)
2344 ;; Copy the global value of the variable.
2345 (setq global (symbol-value (car local)))
2346 ;; Use the value from the list.
2347 (setq global (eval (cdr local))))
2348 (set (make-local-variable (car local)) global))
2349 ;; Simple nil-valued local variable.
2350 (set (make-local-variable local) nil)))))
2352 (defun gnus-summary-clear-local-variables ()
2353 (let ((locals gnus-summary-local-variables))
2355 (if (consp (car locals))
2356 (and (vectorp (caar locals))
2357 (set (caar locals) nil))
2358 (and (vectorp (car locals))
2359 (set (car locals) nil)))
2360 (setq locals (cdr locals)))))
2362 ;; Summary data functions.
2364 (defmacro gnus-data-number (data)
2367 (defmacro gnus-data-set-number (data number)
2368 `(setcar ,data ,number))
2370 (defmacro gnus-data-mark (data)
2373 (defmacro gnus-data-set-mark (data mark)
2374 `(setcar (nthcdr 1 ,data) ,mark))
2376 (defmacro gnus-data-pos (data)
2379 (defmacro gnus-data-set-pos (data pos)
2380 `(setcar (nthcdr 2 ,data) ,pos))
2382 (defmacro gnus-data-header (data)
2385 (defmacro gnus-data-set-header (data header)
2386 `(setcar (nthcdr 3 ,data) ,header))
2388 (defmacro gnus-data-level (data)
2391 (defmacro gnus-data-unread-p (data)
2392 `(= (nth 1 ,data) gnus-unread-mark))
2394 (defmacro gnus-data-read-p (data)
2395 `(/= (nth 1 ,data) gnus-unread-mark))
2397 (defmacro gnus-data-pseudo-p (data)
2398 `(consp (nth 3 ,data)))
2400 (defmacro gnus-data-find (number)
2401 `(assq ,number gnus-newsgroup-data))
2403 (defmacro gnus-data-find-list (number &optional data)
2404 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2405 (memq (assq ,number bdata)
2408 (defmacro gnus-data-make (number mark pos header level)
2409 `(list ,number ,mark ,pos ,header ,level))
2411 (defun gnus-data-enter (after-article number mark pos header level offset)
2412 (let ((data (gnus-data-find-list after-article)))
2414 (error "No such article: %d" after-article))
2415 (setcdr data (cons (gnus-data-make number mark pos header level)
2417 (setq gnus-newsgroup-data-reverse nil)
2418 (gnus-data-update-list (cddr data) offset)))
2420 (defun gnus-data-enter-list (after-article list &optional offset)
2422 (let ((data (and after-article (gnus-data-find-list after-article)))
2426 (let ((odata gnus-newsgroup-data))
2427 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2429 (gnus-data-update-list odata offset)))
2430 ;; Find the last element in the list to be spliced into the main
2433 (setq list (cdr list)))
2436 (setcdr list gnus-newsgroup-data)
2437 (setq gnus-newsgroup-data ilist)
2439 (gnus-data-update-list (cdr list) offset)))
2440 (setcdr list (cdr data))
2443 (gnus-data-update-list (cdr list) offset))))
2444 (setq gnus-newsgroup-data-reverse nil))))
2446 (defun gnus-data-remove (article &optional offset)
2447 (let ((data gnus-newsgroup-data))
2448 (if (= (gnus-data-number (car data)) article)
2450 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2451 gnus-newsgroup-data-reverse nil)
2453 (gnus-data-update-list gnus-newsgroup-data offset)))
2455 (when (= (gnus-data-number (cadr data)) article)
2456 (setcdr data (cddr data))
2458 (gnus-data-update-list (cdr data) offset))
2460 gnus-newsgroup-data-reverse nil))
2461 (setq data (cdr data))))))
2463 (defmacro gnus-data-list (backward)
2465 (or gnus-newsgroup-data-reverse
2466 (setq gnus-newsgroup-data-reverse
2467 (reverse gnus-newsgroup-data)))
2468 gnus-newsgroup-data))
2470 (defun gnus-data-update-list (data offset)
2471 "Add OFFSET to the POS of all data entries in DATA."
2472 (setq gnus-newsgroup-data-reverse nil)
2474 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2475 (setq data (cdr data))))
2477 (defun gnus-summary-article-pseudo-p (article)
2478 "Say whether this article is a pseudo article or not."
2479 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2481 (defmacro gnus-summary-article-sparse-p (article)
2482 "Say whether this article is a sparse article or not."
2483 `(memq ,article gnus-newsgroup-sparse))
2485 (defmacro gnus-summary-article-ancient-p (article)
2486 "Say whether this article is a sparse article or not."
2487 `(memq ,article gnus-newsgroup-ancient))
2489 (defun gnus-article-parent-p (number)
2490 "Say whether this article is a parent or not."
2491 (let ((data (gnus-data-find-list number)))
2492 (and (cdr data) ; There has to be an article after...
2493 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2494 (gnus-data-level (nth 1 data))))))
2496 (defun gnus-article-children (number)
2497 "Return a list of all children to NUMBER."
2498 (let* ((data (gnus-data-find-list number))
2499 (level (gnus-data-level (car data)))
2501 (setq data (cdr data))
2503 (= (gnus-data-level (car data)) (1+ level)))
2504 (push (gnus-data-number (car data)) children)
2505 (setq data (cdr data)))
2508 (defmacro gnus-summary-skip-intangible ()
2509 "If the current article is intangible, then jump to a different article."
2510 '(let ((to (get-text-property (point) 'gnus-intangible)))
2511 (and to (gnus-summary-goto-subject to))))
2513 (defmacro gnus-summary-article-intangible-p ()
2514 "Say whether this article is intangible or not."
2515 '(get-text-property (point) 'gnus-intangible))
2517 (defun gnus-article-read-p (article)
2518 "Say whether ARTICLE is read or not."
2519 (not (or (memq article gnus-newsgroup-marked)
2520 (memq article gnus-newsgroup-unreads)
2521 (memq article gnus-newsgroup-unselected)
2522 (memq article gnus-newsgroup-dormant))))
2524 ;; Some summary mode macros.
2526 (defmacro gnus-summary-article-number ()
2527 "The article number of the article on the current line.
2528 If there isn's an article number here, then we return the current
2531 (gnus-summary-skip-intangible)
2532 (or (get-text-property (point) 'gnus-number)
2533 (gnus-summary-last-subject))))
2535 (defmacro gnus-summary-article-header (&optional number)
2536 "Return the header of article NUMBER."
2537 `(gnus-data-header (gnus-data-find
2538 ,(or number '(gnus-summary-article-number)))))
2540 (defmacro gnus-summary-thread-level (&optional number)
2541 "Return the level of thread that starts with article NUMBER."
2542 `(if (and (eq gnus-summary-make-false-root 'dummy)
2543 (get-text-property (point) 'gnus-intangible))
2545 (gnus-data-level (gnus-data-find
2546 ,(or number '(gnus-summary-article-number))))))
2548 (defmacro gnus-summary-article-mark (&optional number)
2549 "Return the mark of article NUMBER."
2550 `(gnus-data-mark (gnus-data-find
2551 ,(or number '(gnus-summary-article-number)))))
2553 (defmacro gnus-summary-article-pos (&optional number)
2554 "Return the position of the line of article NUMBER."
2555 `(gnus-data-pos (gnus-data-find
2556 ,(or number '(gnus-summary-article-number)))))
2558 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2559 (defmacro gnus-summary-article-subject (&optional number)
2560 "Return current subject string or nil if nothing."
2563 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2564 '(gnus-data-header (assq (gnus-summary-article-number)
2565 gnus-newsgroup-data)))))
2568 (mail-header-subject headers))))
2570 (defmacro gnus-summary-article-score (&optional number)
2571 "Return current article score."
2572 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2573 gnus-newsgroup-scored))
2574 gnus-summary-default-score 0))
2576 (defun gnus-summary-article-children (&optional number)
2577 "Return a list of article numbers that are children of article NUMBER."
2578 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2579 (level (gnus-data-level (car data)))
2581 (while (and (setq data (cdr data))
2582 (> (setq l (gnus-data-level (car data))) level))
2583 (and (= (1+ level) l)
2584 (push (gnus-data-number (car data))
2586 (nreverse children)))
2588 (defun gnus-summary-article-parent (&optional number)
2589 "Return the article number of the parent of article NUMBER."
2590 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2591 (gnus-data-list t)))
2592 (level (gnus-data-level (car data))))
2594 () ; This is a root.
2595 ;; We search until we find an article with a level less than
2596 ;; this one. That function has to be the parent.
2597 (while (and (setq data (cdr data))
2598 (not (< (gnus-data-level (car data)) level))))
2599 (and data (gnus-data-number (car data))))))
2601 (defun gnus-unread-mark-p (mark)
2602 "Say whether MARK is the unread mark."
2603 (= mark gnus-unread-mark))
2605 (defun gnus-read-mark-p (mark)
2606 "Say whether MARK is one of the marks that mark as read.
2607 This is all marks except unread, ticked, dormant, and expirable."
2608 (not (or (= mark gnus-unread-mark)
2609 (= mark gnus-ticked-mark)
2610 (= mark gnus-dormant-mark)
2611 (= mark gnus-expirable-mark))))
2613 (defmacro gnus-article-mark (number)
2614 "Return the MARK of article NUMBER.
2615 This macro should only be used when computing the mark the \"first\"
2616 time; i.e., when generating the summary lines. After that,
2617 `gnus-summary-article-mark' should be used to examine the
2620 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2621 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2622 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2623 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2624 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2625 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2626 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2627 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2628 gnus-ancient-mark))))
2630 ;; Saving hidden threads.
2632 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2633 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2635 (defmacro gnus-save-hidden-threads (&rest forms)
2636 "Save hidden threads, eval FORMS, and restore the hidden threads."
2637 (let ((config (make-symbol "config")))
2638 `(let ((,config (gnus-hidden-threads-configuration)))
2642 (gnus-restore-hidden-threads-configuration ,config)))))
2644 (defun gnus-data-compute-positions ()
2645 "Compute the positions of all articles."
2646 (setq gnus-newsgroup-data-reverse nil)
2647 (let ((data gnus-newsgroup-data))
2649 (gnus-save-hidden-threads
2650 (gnus-summary-show-all-threads)
2651 (goto-char (point-min))
2653 (while (get-text-property (point) 'gnus-intangible)
2655 (gnus-data-set-pos (car data) (+ (point) 3))
2656 (setq data (cdr data))
2657 (forward-line 1))))))
2659 (defun gnus-hidden-threads-configuration ()
2660 "Return the current hidden threads configuration."
2663 (goto-char (point-min))
2664 (while (search-forward "\r" nil t)
2665 (push (1- (point)) config))
2668 (defun gnus-restore-hidden-threads-configuration (config)
2669 "Restore hidden threads configuration from CONFIG."
2671 (let (point buffer-read-only)
2672 (while (setq point (pop config))
2673 (when (and (< point (point-max))
2675 (eq (char-after) ?\n))
2676 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2678 ;; Various summary mode internalish functions.
2680 (defun gnus-mouse-pick-article (e)
2683 (gnus-summary-next-page nil t))
2685 (defun gnus-summary-set-display-table ()
2686 "Change the display table.
2687 Odd characters have a tendency to mess
2688 up nicely formatted displays - we make all possible glyphs
2689 display only a single character."
2691 ;; We start from the standard display table, if any.
2692 (let ((table (or (copy-sequence standard-display-table)
2693 (make-display-table)))
2695 ;; Nix out all the control chars...
2696 (while (>= (setq i (1- i)) 0)
2697 (aset table i [??]))
2698 ;; ... but not newline and cr, of course. (cr is necessary for the
2699 ;; selective display).
2700 (aset table ?\n nil)
2701 (aset table ?\r nil)
2702 ;; We keep TAB as well.
2703 (aset table ?\t nil)
2704 ;; We nix out any glyphs over 126 that are not set already.
2706 (while (>= (setq i (1- i)) 127)
2707 ;; Only modify if the entry is nil.
2708 (unless (aref table i)
2709 (aset table i [??]))))
2710 (setq buffer-display-table table)))
2712 (defun gnus-summary-buffer-name (group)
2713 "Return the summary buffer name of GROUP."
2714 (concat "*Summary " group "*"))
2716 (defun gnus-summary-setup-buffer (group)
2717 "Initialize summary buffer."
2718 (let ((buffer (gnus-summary-buffer-name group)))
2719 (if (get-buffer buffer)
2722 (setq gnus-summary-buffer (current-buffer))
2723 (not gnus-newsgroup-prepared))
2724 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2725 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2726 (gnus-summary-mode group)
2728 (gnus-carpal-setup-buffer 'summary))
2729 (unless gnus-single-article-buffer
2730 (make-local-variable 'gnus-article-buffer)
2731 (make-local-variable 'gnus-article-current)
2732 (make-local-variable 'gnus-original-article-buffer))
2733 (setq gnus-newsgroup-name group)
2734 ;; Set any local variables in the group parameters.
2735 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2738 (defun gnus-set-global-variables ()
2739 "Set the global equivalents of the buffer-local variables.
2740 They are set to the latest values they had. These reflect the summary
2741 buffer that was in action when the last article was fetched."
2742 (when (eq major-mode 'gnus-summary-mode)
2743 (setq gnus-summary-buffer (current-buffer))
2744 (let ((name gnus-newsgroup-name)
2745 (marked gnus-newsgroup-marked)
2746 (unread gnus-newsgroup-unreads)
2747 (headers gnus-current-headers)
2748 (data gnus-newsgroup-data)
2749 (summary gnus-summary-buffer)
2750 (article-buffer gnus-article-buffer)
2751 (original gnus-original-article-buffer)
2752 (gac gnus-article-current)
2753 (reffed gnus-reffed-article-number)
2754 (score-file gnus-current-score-file)
2755 (default-charset gnus-newsgroup-charset)
2757 (let ((locals gnus-newsgroup-variables))
2759 (if (consp (car locals))
2760 (push (eval (caar locals)) vlist)
2761 (push (eval (car locals)) vlist))
2762 (setq locals (cdr locals)))
2763 (setq vlist (nreverse vlist)))
2765 (set-buffer gnus-group-buffer)
2766 (setq gnus-newsgroup-name name
2767 gnus-newsgroup-marked marked
2768 gnus-newsgroup-unreads unread
2769 gnus-current-headers headers
2770 gnus-newsgroup-data data
2771 gnus-article-current gac
2772 gnus-summary-buffer summary
2773 gnus-article-buffer article-buffer
2774 gnus-original-article-buffer original
2775 gnus-reffed-article-number reffed
2776 gnus-current-score-file score-file
2777 gnus-newsgroup-charset default-charset)
2778 (let ((locals gnus-newsgroup-variables))
2780 (if (consp (car locals))
2781 (set (caar locals) (pop vlist))
2782 (set (car locals) (pop vlist)))
2783 (setq locals (cdr locals))))
2784 ;; The article buffer also has local variables.
2785 (when (gnus-buffer-live-p gnus-article-buffer)
2786 (set-buffer gnus-article-buffer)
2787 (setq gnus-summary-buffer summary))))))
2789 (defun gnus-summary-article-unread-p (article)
2790 "Say whether ARTICLE is unread or not."
2791 (memq article gnus-newsgroup-unreads))
2793 (defun gnus-summary-first-article-p (&optional article)
2794 "Return whether ARTICLE is the first article in the buffer."
2795 (if (not (setq article (or article (gnus-summary-article-number))))
2797 (eq article (caar gnus-newsgroup-data))))
2799 (defun gnus-summary-last-article-p (&optional article)
2800 "Return whether ARTICLE is the last article in the buffer."
2801 (if (not (setq article (or article (gnus-summary-article-number))))
2802 ;; All non-existent numbers are the last article. :-)
2804 (not (cdr (gnus-data-find-list article)))))
2806 (defun gnus-make-thread-indent-array ()
2808 (unless (and gnus-thread-indent-array
2809 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2810 (setq gnus-thread-indent-array (make-vector 201 "")
2811 gnus-thread-indent-array-level gnus-thread-indent-level)
2813 (aset gnus-thread-indent-array n
2814 (make-string (* n gnus-thread-indent-level) ? ))
2817 (defun gnus-update-summary-mark-positions ()
2818 "Compute where the summary marks are to go."
2820 (when (gnus-buffer-exists-p gnus-summary-buffer)
2821 (set-buffer gnus-summary-buffer))
2822 (let ((gnus-replied-mark 129)
2823 (gnus-score-below-mark 130)
2824 (gnus-score-over-mark 130)
2825 (gnus-download-mark 131)
2826 (spec gnus-summary-line-format-spec)
2829 (gnus-set-work-buffer)
2830 (let ((gnus-summary-line-format-spec spec)
2831 (gnus-newsgroup-downloadable '((0 . t))))
2832 (gnus-summary-insert-line
2833 (make-full-mail-header 0 "" "nobody"
2834 "05 Apr 2001 23:33:09 +0400"
2836 0 nil 128 t nil "" nil 1)
2837 (goto-char (point-min))
2838 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2840 (goto-char (point-min))
2841 (push (cons 'replied (and (search-forward "\201" nil t)
2844 (goto-char (point-min))
2845 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2847 (goto-char (point-min))
2848 (push (cons 'download
2849 (and (search-forward "\203" nil t) (- (point) 2)))
2851 (setq gnus-summary-mark-positions pos))))
2853 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2854 "Insert a dummy root in the summary buffer."
2856 (gnus-add-text-properties
2857 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2858 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2860 (defun gnus-summary-from-or-to-or-newsgroups (header)
2861 (let ((to (cdr (assq 'To (mail-header-extra header))))
2862 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2863 (default-mime-charset (with-current-buffer gnus-summary-buffer
2864 default-mime-charset)))
2867 gnus-ignored-from-addresses
2868 (string-match gnus-ignored-from-addresses
2869 (mail-header-from header)))
2871 (or (car (funcall gnus-extract-address-components
2873 gnus-decode-encoded-word-function to)))
2874 (funcall gnus-decode-encoded-word-function to))))
2876 gnus-ignored-from-addresses
2877 (string-match gnus-ignored-from-addresses
2878 (mail-header-from header)))
2879 (concat "=> " newsgroups))
2881 (or (car (funcall gnus-extract-address-components
2882 (mail-header-from header)))
2883 (mail-header-from header))))))
2885 (defun gnus-summary-insert-line (gnus-tmp-header
2886 gnus-tmp-level gnus-tmp-current
2887 gnus-tmp-unread gnus-tmp-replied
2888 gnus-tmp-expirable gnus-tmp-subject-or-nil
2889 &optional gnus-tmp-dummy gnus-tmp-score
2891 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2892 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2893 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2894 (gnus-tmp-score-char
2895 (if (or (null gnus-summary-default-score)
2896 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2897 gnus-summary-zcore-fuzz))
2899 (if (< gnus-tmp-score gnus-summary-default-score)
2900 gnus-score-below-mark gnus-score-over-mark)))
2902 (cond (gnus-tmp-process gnus-process-mark)
2903 ((memq gnus-tmp-current gnus-newsgroup-cached)
2905 (gnus-tmp-replied gnus-replied-mark)
2906 ((memq gnus-tmp-current gnus-newsgroup-saved)
2909 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2912 ((string-match "<[^>]+> *$" gnus-tmp-from)
2913 (let ((beg (match-beginning 0)))
2914 (or (and (string-match "^\".+\"" gnus-tmp-from)
2915 (substring gnus-tmp-from 1 (1- (match-end 0))))
2916 (substring gnus-tmp-from 0 beg))))
2917 ((string-match "(.+)" gnus-tmp-from)
2918 (substring gnus-tmp-from
2919 (1+ (match-beginning 0)) (1- (match-end 0))))
2921 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2922 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2923 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2924 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2925 (buffer-read-only nil))
2926 (when (string= gnus-tmp-name "")
2927 (setq gnus-tmp-name gnus-tmp-from))
2928 (unless (numberp gnus-tmp-lines)
2929 (setq gnus-tmp-lines -1))
2930 (when (= gnus-tmp-lines -1)
2931 (setq gnus-tmp-lines "?"))
2932 (gnus-put-text-property-excluding-characters-with-faces
2934 (progn (eval gnus-summary-line-format-spec) (point))
2935 'gnus-number gnus-tmp-number)
2936 (when (gnus-visual-p 'summary-highlight 'highlight)
2938 (gnus-run-hooks 'gnus-summary-update-hook)
2941 (defun gnus-summary-update-line (&optional dont-update)
2942 "Update summary line after change."
2943 (when (and gnus-summary-default-score
2944 (not gnus-summary-inhibit-highlight))
2945 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2946 (article (gnus-summary-article-number))
2947 (score (gnus-summary-article-score article)))
2949 (if (and gnus-summary-mark-below
2950 (< (gnus-summary-article-score)
2951 gnus-summary-mark-below))
2952 ;; This article has a low score, so we mark it as read.
2953 (when (memq article gnus-newsgroup-unreads)
2954 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2955 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2956 ;; This article was previously marked as read on account
2957 ;; of a low score, but now it has risen, so we mark it as
2959 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2960 (gnus-summary-update-mark
2961 (if (or (null gnus-summary-default-score)
2962 (<= (abs (- score gnus-summary-default-score))
2963 gnus-summary-zcore-fuzz))
2965 (if (< score gnus-summary-default-score)
2966 gnus-score-below-mark gnus-score-over-mark))
2968 ;; Do visual highlighting.
2969 (when (gnus-visual-p 'summary-highlight 'highlight)
2970 (gnus-run-hooks 'gnus-summary-update-hook)))))
2972 (defvar gnus-tmp-new-adopts nil)
2974 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2975 "Return the number of articles in THREAD.
2976 This may be 0 in some cases -- if none of the articles in
2977 the thread are to be displayed."
2979 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2981 ((not (listp thread))
2983 ((and (consp thread) (cdr thread))
2986 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2989 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2992 (when (and level (zerop level) gnus-tmp-new-adopts)
2995 'gnus-summary-number-of-articles-in-thread
2996 gnus-tmp-new-adopts))))
2998 (if (> number 1) gnus-not-empty-thread-mark
2999 gnus-empty-thread-mark)
3002 (defun gnus-summary-set-local-parameters (group)
3003 "Go through the local params of GROUP and set all variable specs in that list."
3004 (let ((params (gnus-group-find-parameter group))
3005 (vars '(quit-config)) ; Ignore quit-config.
3008 (setq elem (car params)
3009 params (cdr params))
3010 (and (consp elem) ; Has to be a cons.
3011 (consp (cdr elem)) ; The cdr has to be a list.
3012 (symbolp (car elem)) ; Has to be a symbol in there.
3013 (not (memq (car elem) vars))
3014 (ignore-errors ; So we set it.
3015 (push (car elem) vars)
3016 (make-local-variable (car elem))
3017 (set (car elem) (eval (nth 1 elem))))))))
3019 (defun gnus-summary-read-group (group &optional show-all no-article
3020 kill-buffer no-display backward
3022 "Start reading news in newsgroup GROUP.
3023 If SHOW-ALL is non-nil, already read articles are also listed.
3024 If NO-ARTICLE is non-nil, no article is selected initially.
3025 If NO-DISPLAY, don't generate a summary buffer."
3029 (let ((gnus-auto-select-next nil))
3030 (or (gnus-summary-read-group-1
3031 group show-all no-article
3032 kill-buffer no-display
3035 select-articles nil)))))
3036 (eq gnus-auto-select-next 'quietly))
3037 (set-buffer gnus-group-buffer)
3038 ;; The entry function called above goes to the next
3039 ;; group automatically, so we go two groups back
3040 ;; if we are searching for the previous group.
3042 (gnus-group-prev-unread-group 2))
3043 (if (not (equal group (gnus-group-group-name)))
3044 (setq group (gnus-group-group-name))
3048 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3049 "Directly jump to the other GROUP from summary buffer.
3050 If SHOW-ALL is non-nil, already read articles are also listed."
3052 (if (eq gnus-summary-buffer (current-buffer))
3053 (list (completing-read
3054 "Group: " gnus-active-hashtb nil t
3055 (when (and gnus-newsgroup-name
3056 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3057 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3058 'gnus-group-history)
3060 (error "%s must be invoked from a gnus summary buffer." this-command)))
3061 (unless (or (zerop (length group))
3062 (and gnus-newsgroup-name
3063 (string-equal gnus-newsgroup-name group)))
3065 (gnus-summary-read-group group show-all
3066 gnus-dont-select-after-jump-to-other-group)))
3068 (defun gnus-summary-read-group-1 (group show-all no-article
3069 kill-buffer no-display
3070 &optional select-articles)
3071 ;; Killed foreign groups can't be entered.
3072 ;; (when (and (not (gnus-group-native-p group))
3073 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3074 ;; (error "Dead non-native groups can't be entered"))
3075 (gnus-message 5 "Retrieving newsgroup: %s..."
3076 (gnus-group-decoded-name group))
3077 (let* ((new-group (gnus-summary-setup-buffer group))
3078 (quit-config (gnus-group-quit-config group))
3079 (did-select (and new-group (gnus-select-newsgroup
3080 group show-all select-articles))))
3082 ;; This summary buffer exists already, so we just select it.
3084 (gnus-set-global-variables)
3086 (gnus-kill-or-deaden-summary kill-buffer))
3087 (gnus-configure-windows 'summary 'force)
3088 (gnus-set-mode-line 'summary)
3089 (gnus-summary-position-point)
3092 ;; We couldn't select this group.
3094 (when (and (eq major-mode 'gnus-summary-mode)
3095 (not (equal (current-buffer) kill-buffer)))
3096 (kill-buffer (current-buffer))
3097 (if (not quit-config)
3099 ;; Update the info -- marks might need to be removed,
3101 (gnus-summary-update-info)
3102 (set-buffer gnus-group-buffer)
3103 (gnus-group-jump-to-group group)
3104 (gnus-group-next-unread-group 1))
3105 (gnus-handle-ephemeral-exit quit-config)))
3106 (let ((grpinfo (gnus-get-info group)))
3107 (if (null (gnus-info-read grpinfo))
3108 (gnus-message 3 "Group %s contains no messages"
3109 (gnus-group-decoded-name group))
3110 (gnus-message 3 "Can't select group")))
3112 ;; The user did a `C-g' while prompting for number of articles,
3113 ;; so we exit this group.
3114 ((eq did-select 'quit)
3115 (and (eq major-mode 'gnus-summary-mode)
3116 (not (equal (current-buffer) kill-buffer))
3117 (kill-buffer (current-buffer)))
3119 (gnus-kill-or-deaden-summary kill-buffer))
3120 (if (not quit-config)
3122 (set-buffer gnus-group-buffer)
3123 (gnus-group-jump-to-group group)
3124 (gnus-group-next-unread-group 1)
3125 (gnus-configure-windows 'group 'force))
3126 (gnus-handle-ephemeral-exit quit-config))
3127 ;; Finally signal the quit.
3129 ;; The group was successfully selected.
3131 (gnus-set-global-variables)
3132 ;; Save the active value in effect when the group was entered.
3133 (setq gnus-newsgroup-active
3135 (gnus-active gnus-newsgroup-name)))
3136 ;; You can change the summary buffer in some way with this hook.
3137 (gnus-run-hooks 'gnus-select-group-hook)
3138 (gnus-update-format-specifications
3139 nil 'summary 'summary-mode 'summary-dummy)
3140 (gnus-update-summary-mark-positions)
3141 ;; Do score processing.
3142 (when gnus-use-scoring
3143 (gnus-possibly-score-headers))
3144 ;; Check whether to fill in the gaps in the threads.
3145 (when gnus-build-sparse-threads
3146 (gnus-build-sparse-threads))
3147 ;; Find the initial limit.
3148 (if gnus-show-threads
3150 (let ((gnus-newsgroup-dormant nil))
3151 (gnus-summary-initial-limit show-all))
3152 (gnus-summary-initial-limit show-all))
3153 ;; When untreaded, all articles are always shown.
3154 (setq gnus-newsgroup-limit
3156 (lambda (header) (mail-header-number header))
3157 gnus-newsgroup-headers)))
3158 ;; Generate the summary buffer.
3160 (gnus-summary-prepare))
3161 (when gnus-use-trees
3162 (gnus-tree-open group)
3163 (setq gnus-summary-highlight-line-function
3164 'gnus-tree-highlight-article))
3165 ;; If the summary buffer is empty, but there are some low-scored
3166 ;; articles or some excluded dormants, we include these in the
3168 (when (and (zerop (buffer-size))
3170 (cond (gnus-newsgroup-dormant
3171 (gnus-summary-limit-include-dormant))
3172 ((and gnus-newsgroup-scored show-all)
3173 (gnus-summary-limit-include-expunged t))))
3174 ;; Function `gnus-apply-kill-file' must be called in this hook.
3175 (gnus-run-hooks 'gnus-apply-kill-hook)
3176 (if (and (zerop (buffer-size))
3179 ;; This newsgroup is empty.
3180 (gnus-summary-catchup-and-exit nil t)
3181 (gnus-message 6 "No unread news")
3183 (gnus-kill-or-deaden-summary kill-buffer))
3184 ;; Return nil from this function.
3186 ;; Hide conversation thread subtrees. We cannot do this in
3187 ;; gnus-summary-prepare-hook since kill processing may not
3188 ;; work with hidden articles.
3189 (and gnus-show-threads
3190 gnus-thread-hide-subtree
3191 (gnus-summary-hide-all-threads))
3193 (gnus-kill-or-deaden-summary kill-buffer))
3194 ;; Show first unread article if requested.
3195 (if (and (not no-article)
3197 gnus-newsgroup-unreads
3198 gnus-auto-select-first)
3200 (gnus-configure-windows 'summary)
3202 ((eq gnus-auto-select-first 'best)
3203 (gnus-summary-best-unread-article))
3204 ((eq gnus-auto-select-first t)
3205 (gnus-summary-first-unread-article))
3206 ((gnus-functionp gnus-auto-select-first)
3207 (funcall gnus-auto-select-first))))
3208 ;; Don't select any articles, just move point to the first
3209 ;; article in the group.
3210 (goto-char (point-min))
3211 (gnus-summary-position-point)
3212 (gnus-configure-windows 'summary 'force)
3213 (gnus-set-mode-line 'summary))
3214 (when (get-buffer-window gnus-group-buffer t)
3215 ;; Gotta use windows, because recenter does weird stuff if
3216 ;; the current buffer ain't the displayed window.
3217 (let ((owin (selected-window)))
3218 (select-window (get-buffer-window gnus-group-buffer t))
3219 (when (gnus-group-goto-group group)
3221 (select-window owin)))
3222 ;; Mark this buffer as "prepared".
3223 (setq gnus-newsgroup-prepared t)
3224 (gnus-run-hooks 'gnus-summary-prepared-hook)
3227 (defun gnus-summary-prepare ()
3228 "Generate the summary buffer."
3230 (let ((buffer-read-only nil))
3232 (setq gnus-newsgroup-data nil
3233 gnus-newsgroup-data-reverse nil)
3234 (gnus-run-hooks 'gnus-summary-generate-hook)
3235 ;; Generate the buffer, either with threads or without.
3236 (when gnus-newsgroup-headers
3237 (gnus-summary-prepare-threads
3238 (if gnus-show-threads
3239 (gnus-sort-gathered-threads
3240 (funcall gnus-summary-thread-gathering-function
3242 (gnus-cut-threads (gnus-make-threads)))))
3243 ;; Unthreaded display.
3244 (gnus-sort-articles gnus-newsgroup-headers))))
3245 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3246 ;; Call hooks for modifying summary buffer.
3247 (goto-char (point-min))
3248 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3250 (defsubst gnus-general-simplify-subject (subject)
3251 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3254 ;; Truncate the subject.
3255 (gnus-simplify-subject-functions
3256 (gnus-map-function gnus-simplify-subject-functions subject))
3257 ((numberp gnus-summary-gather-subject-limit)
3258 (setq subject (gnus-simplify-subject-re subject))
3259 (if (> (length subject) gnus-summary-gather-subject-limit)
3260 (substring subject 0 gnus-summary-gather-subject-limit)
3262 ;; Fuzzily simplify it.
3263 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3264 (gnus-simplify-subject-fuzzy subject))
3265 ;; Just remove the leading "Re:".
3267 (gnus-simplify-subject-re subject))))
3269 (if (and gnus-summary-gather-exclude-subject
3270 (string-match gnus-summary-gather-exclude-subject subject))
3271 nil ; This article shouldn't be gathered
3274 (defun gnus-summary-simplify-subject-query ()
3275 "Query where the respool algorithm would put this article."
3277 (gnus-summary-select-article)
3279 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3281 (defun gnus-gather-threads-by-subject (threads)
3282 "Gather threads by looking at Subject headers."
3283 (if (not gnus-summary-make-false-root)
3285 (let ((hashtb (gnus-make-hashtable 1024))
3288 subject hthread whole-subject)
3290 (setq subject (gnus-general-simplify-subject
3291 (setq whole-subject (mail-header-subject
3294 (if (setq hthread (gnus-gethash subject hashtb))
3296 ;; We enter a dummy root into the thread, if we
3297 ;; haven't done that already.
3298 (unless (stringp (caar hthread))
3299 (setcar hthread (list whole-subject (car hthread))))
3300 ;; We add this new gathered thread to this gathered
3302 (setcdr (car hthread)
3303 (nconc (cdar hthread) (list (car threads))))
3304 ;; Remove it from the list of threads.
3305 (setcdr prev (cdr threads))
3306 (setq threads prev))
3307 ;; Enter this thread into the hash table.
3308 (gnus-sethash subject threads hashtb)))
3310 (setq threads (cdr threads)))
3313 (defun gnus-gather-threads-by-references (threads)
3314 "Gather threads by looking at References headers."
3315 (let ((idhashtb (gnus-make-hashtable 1024))
3316 (thhashtb (gnus-make-hashtable 1024))
3319 ids references id gthread gid entered ref)
3321 (when (setq references (mail-header-references (caar threads)))
3322 (setq id (mail-header-id (caar threads))
3323 ids (gnus-split-references references)
3325 (while (setq ref (pop ids))
3326 (setq ids (delete ref ids))
3327 (if (not (setq gid (gnus-gethash ref idhashtb)))
3329 (gnus-sethash ref id idhashtb)
3330 (gnus-sethash id threads thhashtb))
3331 (setq gthread (gnus-gethash gid thhashtb))
3333 ;; We enter a dummy root into the thread, if we
3334 ;; haven't done that already.
3335 (unless (stringp (caar gthread))
3336 (setcar gthread (list (mail-header-subject (caar gthread))
3338 ;; We add this new gathered thread to this gathered
3340 (setcdr (car gthread)
3341 (nconc (cdar gthread) (list (car threads)))))
3342 ;; Add it into the thread hash table.
3343 (gnus-sethash id gthread thhashtb)
3345 ;; Remove it from the list of threads.
3346 (setcdr prev (cdr threads))
3347 (setq threads prev))))
3349 (setq threads (cdr threads)))
3352 (defun gnus-sort-gathered-threads (threads)
3353 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3354 (let ((result threads))
3356 (when (stringp (caar threads))
3357 (setcdr (car threads)
3358 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3359 (setq threads (cdr threads)))
3362 (defun gnus-thread-loop-p (root thread)
3363 "Say whether ROOT is in THREAD."
3364 (let ((stack (list thread))
3367 (while (setq thread (pop stack))
3368 (setq th (cdr thread))
3370 (not (eq (caar th) root)))
3373 ;; We have found a loop.
3375 (setcdr thread (delq (car th) (cdr thread)))
3376 (if (boundp (setq ref-dep (intern "none"
3377 gnus-newsgroup-dependencies)))
3378 (setcdr (symbol-value ref-dep)
3379 (nconc (cdr (symbol-value ref-dep))
3381 (set ref-dep (list nil (car th))))
3384 ;; Push all the subthreads onto the stack.
3385 (push (cdr thread) stack)))
3388 (defun gnus-make-threads ()
3389 "Go through the dependency hashtb and find the roots. Return all threads."
3391 (while (catch 'infloop
3394 ;; Deal with self-referencing References loops.
3395 (when (and (car (symbol-value refs))
3402 (car (symbol-value refs)) thread))
3403 (cdr (symbol-value refs)))))))
3406 (unless (car (symbol-value refs))
3407 ;; These threads do not refer back to any other articles,
3408 ;; so they're roots.
3409 (setq threads (append (cdr (symbol-value refs)) threads))))
3410 gnus-newsgroup-dependencies)))
3413 ;; Build the thread tree.
3414 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3415 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3417 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3418 if it was already present.
3420 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3421 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3422 Message-IDs will be renamed be renamed to a unique Message-ID before
3425 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3426 (let* ((id (mail-header-id header))
3427 (id-dep (and id (intern id dependencies)))
3428 ref ref-dep ref-header)
3429 ;; Enter this `header' in the `dependencies' table.
3433 ;; The first two cases do the normal part: enter a new `header'
3434 ;; in the `dependencies' table.
3435 ((not (boundp id-dep))
3436 (set id-dep (list header)))
3437 ((null (car (symbol-value id-dep)))
3438 (setcar (symbol-value id-dep) header))
3440 ;; From here the `header' was already present in the
3441 ;; `dependencies' table.
3443 ;; Overrides an existing entry;
3444 ;; just set the header part of the entry.
3445 (setcar (symbol-value id-dep) header))
3447 ;; Renames the existing `header' to a unique Message-ID.
3448 ((not gnus-summary-ignore-duplicates)
3449 ;; An article with this Message-ID has already been seen.
3450 ;; We rename the Message-ID.
3451 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3453 (mail-header-set-id header id))
3455 ;; The last case ignores an existing entry, except it adds any
3456 ;; additional Xrefs (in case the two articles came from different
3458 ;; Also sets `header' to `nil' meaning that the `dependencies'
3459 ;; table was *not* modified.
3461 (mail-header-set-xref
3462 (car (symbol-value id-dep))
3463 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3465 (or (mail-header-xref header) "")))
3469 ;; First check if that we are not creating a References loop.
3470 (setq ref (gnus-parent-id (mail-header-references header)))
3472 (setq ref-dep (intern-soft ref dependencies))
3474 (setq ref-header (car (symbol-value ref-dep))))
3475 (if (string= id ref)
3476 ;; Yuk! This is a reference loop. Make the article be a
3479 (mail-header-set-references (car (symbol-value id-dep)) "none")
3481 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3482 (setq ref (gnus-parent-id (mail-header-references header)))
3483 (setq ref-dep (intern (or ref "none") dependencies))
3484 (if (boundp ref-dep)
3485 (setcdr (symbol-value ref-dep)
3486 (nconc (cdr (symbol-value ref-dep))
3487 (list (symbol-value id-dep))))
3488 (set ref-dep (list nil (symbol-value id-dep)))))
3491 (defun gnus-build-sparse-threads ()
3492 (let ((headers gnus-newsgroup-headers)
3493 (mail-parse-charset gnus-newsgroup-charset)
3494 (gnus-summary-ignore-duplicates t)
3495 header references generation relations
3496 subject child end new-child date)
3497 ;; First we create an alist of generations/relations, where
3498 ;; generations is how much we trust the relation, and the relation
3500 (gnus-message 7 "Making sparse threads...")
3502 (nnheader-set-temp-buffer " *gnus sparse threads*")
3503 (while (setq header (pop headers))
3504 (when (and (setq references (mail-header-references header))
3505 (not (string= references "")))
3507 (setq child (mail-header-id header)
3508 subject (mail-header-subject header)
3509 date (mail-header-date header)
3511 (while (search-backward ">" nil t)
3512 (setq end (1+ (point)))
3513 (when (search-backward "<" nil t)
3514 (setq new-child (buffer-substring (point) end))
3515 (push (list (incf generation)
3516 child (setq child new-child)
3520 (push (list (1+ generation) child nil subject) relations))
3522 (kill-buffer (current-buffer)))
3523 ;; Sort over trustworthiness.
3526 (when (gnus-dependencies-add-header
3527 (make-full-mail-header-from-decoded-header
3528 gnus-reffed-article-number
3529 (nth 3 relation) "" (or (nth 4 relation) "")
3531 (or (nth 2 relation) "") 0 0 "")
3532 gnus-newsgroup-dependencies nil)
3533 (push gnus-reffed-article-number gnus-newsgroup-limit)
3534 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3535 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3536 gnus-newsgroup-reads)
3537 (decf gnus-reffed-article-number)))
3538 (sort relations 'car-less-than-car))
3539 (gnus-message 7 "Making sparse threads...done")))
3541 (defun gnus-build-old-threads ()
3542 ;; Look at all the articles that refer back to old articles, and
3543 ;; fetch the headers for the articles that aren't there. This will
3544 ;; build complete threads - if the roots haven't been expired by the
3546 (let ((mail-parse-charset gnus-newsgroup-charset)
3550 (when (not (car (symbol-value refs)))
3551 (setq heads (cdr (symbol-value refs)))
3553 (if (memq (mail-header-number (caar heads))
3554 gnus-newsgroup-dormant)
3555 (setq heads (cdr heads))
3556 (setq id (symbol-name refs))
3557 (while (and (setq id (gnus-build-get-header id))
3558 (not (car (gnus-id-to-thread id)))))
3559 (setq heads nil)))))
3560 gnus-newsgroup-dependencies)))
3562 ;; This function has to be called with point after the article number
3563 ;; on the beginning of the line.
3564 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3565 (let ((eol (gnus-point-at-eol))
3566 (buffer (current-buffer))
3569 ;; overview: [num subject from date id refs chars lines misc]
3572 (narrow-to-region (point) eol)
3577 (make-full-mail-header
3579 (nnheader-nov-field) ; subject
3580 (nnheader-nov-field) ; from
3581 (nnheader-nov-field) ; date
3582 (nnheader-nov-read-message-id) ; id
3583 (nnheader-nov-field) ; refs
3584 (nnheader-nov-read-integer) ; chars
3585 (nnheader-nov-read-integer) ; lines
3587 (if (looking-at "Xref: ")
3588 (goto-char (match-end 0)))
3589 (nnheader-nov-field)) ; Xref
3590 (nnheader-nov-parse-extra)))) ; extra
3594 (when gnus-alter-header-function
3595 (funcall gnus-alter-header-function header))
3596 (gnus-dependencies-add-header header dependencies force-new)))
3598 (defun gnus-build-get-header (id)
3599 "Look through the buffer of NOV lines and find the header to ID.
3600 Enter this line into the dependencies hash table, and return
3601 the id of the parent article (if any)."
3602 (let ((deps gnus-newsgroup-dependencies)
3606 (set-buffer nntp-server-buffer)
3607 (let ((case-fold-search nil))
3608 (goto-char (point-min))
3609 (while (and (not found)
3610 (search-forward id nil t))
3612 (setq found (looking-at
3613 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3614 (regexp-quote id))))
3615 (or found (beginning-of-line 2)))
3619 (setq header (gnus-nov-parse-line
3620 (read (current-buffer)) deps))
3621 (gnus-parent-id (mail-header-references header))))))
3623 (let ((number (mail-header-number header)))
3624 (push number gnus-newsgroup-limit)
3625 (push header gnus-newsgroup-headers)
3626 (if (memq number gnus-newsgroup-unselected)
3628 (push number gnus-newsgroup-unreads)
3629 (setq gnus-newsgroup-unselected
3630 (delq number gnus-newsgroup-unselected)))
3631 (push number gnus-newsgroup-ancient)))))))
3633 (defun gnus-build-all-threads ()
3634 "Read all the headers."
3635 (let ((gnus-summary-ignore-duplicates t)
3636 (mail-parse-charset gnus-newsgroup-charset)
3637 (dependencies gnus-newsgroup-dependencies)
3640 (set-buffer nntp-server-buffer)
3641 (let ((case-fold-search nil))
3642 (goto-char (point-min))
3645 (setq article (read (current-buffer))
3646 header (gnus-nov-parse-line article dependencies)))
3649 (set-buffer gnus-summary-buffer)
3650 (push header gnus-newsgroup-headers)
3651 (if (memq (setq article (mail-header-number header))
3652 gnus-newsgroup-unselected)
3654 (push article gnus-newsgroup-unreads)
3655 (setq gnus-newsgroup-unselected
3656 (delq article gnus-newsgroup-unselected)))
3657 (push article gnus-newsgroup-ancient)))
3658 (forward-line 1)))))))
3660 (defun gnus-summary-update-article-line (article header)
3661 "Update the line for ARTICLE using HEADERS."
3662 (let* ((id (mail-header-id header))
3663 (thread (gnus-id-to-thread id)))
3665 (error "Article in no thread"))
3666 ;; Update the thread.
3667 (setcar thread header)
3668 (gnus-summary-goto-subject article)
3669 (let* ((datal (gnus-data-find-list article))
3671 (length (when (cdr datal)
3672 (- (gnus-data-pos data)
3673 (gnus-data-pos (cadr datal)))))
3674 (buffer-read-only nil)
3675 (level (gnus-summary-thread-level)))
3677 (gnus-summary-insert-line
3678 header level nil (gnus-article-mark article)
3679 (memq article gnus-newsgroup-replied)
3680 (memq article gnus-newsgroup-expirable)
3681 ;; Only insert the Subject string when it's different
3682 ;; from the previous Subject string.
3687 (mail-header-subject
3690 (gnus-data-find-list
3692 (gnus-data-list t)))))
3693 ;; Error on the side of excessive subjects.
3695 (mail-header-subject header)))
3697 (mail-header-subject header))
3698 nil (cdr (assq article gnus-newsgroup-scored))
3699 (memq article gnus-newsgroup-processable))
3701 (gnus-data-update-list
3702 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3704 (defun gnus-summary-update-article (article &optional iheader)
3705 "Update ARTICLE in the summary buffer."
3706 (set-buffer gnus-summary-buffer)
3707 (let* ((header (gnus-summary-article-header article))
3708 (id (mail-header-id header))
3709 (data (gnus-data-find article))
3710 (thread (gnus-id-to-thread id))
3711 (references (mail-header-references header))
3715 (when (and references
3716 (not (equal "" references)))
3719 (buffer-read-only nil)
3725 (delq thread parent)))
3726 (if (gnus-summary-insert-subject id header)
3727 ;; Set the (possibly) new article number in the data structure.
3728 (gnus-data-set-number data (gnus-id-to-article id))
3732 (defun gnus-rebuild-thread (id &optional line)
3733 "Rebuild the thread containing ID.
3734 If LINE, insert the rebuilt thread starting on line LINE."
3735 (let ((buffer-read-only nil)
3736 old-pos current thread data)
3737 (if (not gnus-show-threads)
3738 (setq thread (list (car (gnus-id-to-thread id))))
3739 ;; Get the thread this article is part of.
3740 (setq thread (gnus-remove-thread id)))
3741 (setq old-pos (gnus-point-at-bol))
3742 (setq current (save-excursion
3743 (and (zerop (forward-line -1))
3744 (gnus-summary-article-number))))
3745 ;; If this is a gathered thread, we have to go some re-gathering.
3746 (when (stringp (car thread))
3747 (let ((subject (car thread))
3749 (setq thread (cdr thread))
3751 (unless (memq (setq thr (gnus-id-to-thread
3753 (mail-header-id (caar thread)))))
3756 (setq thread (cdr thread)))
3757 ;; We now have all (unique) roots.
3758 (if (= (length roots) 1)
3759 ;; All the loose roots are now one solid root.
3760 (setq thread (car roots))
3761 (setq thread (cons subject (gnus-sort-threads roots))))))
3763 ;; We then insert this thread into the summary buffer.
3765 (goto-char (point-min))
3766 (forward-line (1- line)))
3767 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3768 (if gnus-show-threads
3769 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3770 (gnus-summary-prepare-unthreaded thread))
3771 (setq data (nreverse gnus-newsgroup-data))
3772 (setq threads gnus-newsgroup-threads))
3773 ;; We splice the new data into the data structure.
3774 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3775 ;;!!! then we want to insert at the beginning of the buffer.
3776 ;;!!! That happens to be true with Gnus now, but that may
3777 ;;!!! change in the future. Perhaps.
3778 (gnus-data-enter-list
3779 (if line nil current) data (- (point) old-pos))
3780 (setq gnus-newsgroup-threads
3781 (nconc threads gnus-newsgroup-threads))
3782 (gnus-data-compute-positions))))
3784 (defun gnus-number-to-header (number)
3785 "Return the header for article NUMBER."
3786 (let ((headers gnus-newsgroup-headers))
3788 (not (= number (mail-header-number (car headers)))))
3793 (defun gnus-parent-headers (in-headers &optional generation)
3794 "Return the headers of the GENERATIONeth parent of HEADERS."
3796 (setq generation 1))
3798 (headers in-headers)
3801 (not (zerop generation))
3802 (setq references (mail-header-references headers)))
3803 (setq headers (if (and references
3804 (setq parent (gnus-parent-id references)))
3805 (car (gnus-id-to-thread parent))
3808 (and (not (eq headers in-headers))
3811 (defun gnus-id-to-thread (id)
3812 "Return the (sub-)thread where ID appears."
3813 (gnus-gethash id gnus-newsgroup-dependencies))
3815 (defun gnus-id-to-article (id)
3816 "Return the article number of ID."
3817 (let ((thread (gnus-id-to-thread id)))
3820 (mail-header-number (car thread)))))
3822 (defun gnus-id-to-header (id)
3823 "Return the article headers of ID."
3824 (car (gnus-id-to-thread id)))
3826 (defun gnus-article-displayed-root-p (article)
3827 "Say whether ARTICLE is a root(ish) article."
3828 (let ((level (gnus-summary-thread-level article))
3829 (refs (mail-header-references (gnus-summary-article-header article)))
3835 ((null (gnus-parent-id refs)) t)
3837 (null (setq particle (gnus-id-to-article
3838 (gnus-parent-id refs))))
3839 (null (gnus-summary-thread-level particle)))))))
3841 (defun gnus-root-id (id)
3842 "Return the id of the root of the thread where ID appears."
3844 (while (and id (setq prev (car (gnus-id-to-thread id))))
3846 id (gnus-parent-id (mail-header-references prev))))
3849 (defun gnus-articles-in-thread (thread)
3850 "Return the list of articles in THREAD."
3851 (cons (mail-header-number (car thread))
3852 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3854 (defun gnus-remove-thread (id &optional dont-remove)
3855 "Remove the thread that has ID in it."
3856 (let (headers thread last-id)
3857 ;; First go up in this thread until we find the root.
3858 (setq last-id (gnus-root-id id)
3859 headers (message-flatten-list (gnus-id-to-thread last-id)))
3860 ;; We have now found the real root of this thread. It might have
3861 ;; been gathered into some loose thread, so we have to search
3862 ;; through the threads to find the thread we wanted.
3863 (let ((threads gnus-newsgroup-threads)
3866 (setq sub (car threads))
3867 (if (stringp (car sub))
3868 ;; This is a gathered thread, so we look at the roots
3869 ;; below it to find whether this article is in this
3872 (setq sub (cdr sub))
3874 (when (member (caar sub) headers)
3875 (setq thread (car threads)
3878 (setq sub (cdr sub))))
3879 ;; It's an ordinary thread, so we check it.
3880 (when (eq (car sub) (car headers))
3883 (setq threads (cdr threads)))
3884 ;; If this article is in no thread, then it's a root.
3887 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3888 (setq thread (gnus-id-to-thread last-id)))
3891 thread ; We return this thread.
3893 (if (stringp (car thread))
3895 ;; If we use dummy roots, then we have to remove the
3896 ;; dummy root as well.
3897 (when (eq gnus-summary-make-false-root 'dummy)
3898 ;; We go to the dummy root by going to
3899 ;; the first sub-"thread", and then one line up.
3900 (gnus-summary-goto-article
3901 (mail-header-number (caadr thread)))
3904 (gnus-data-compute-positions))
3905 (setq thread (cdr thread))
3907 (gnus-remove-thread-1 (car thread))
3908 (setq thread (cdr thread))))
3909 (gnus-remove-thread-1 thread))))))))
3911 (defun gnus-remove-thread-1 (thread)
3912 "Remove the thread THREAD recursively."
3913 (let ((number (mail-header-number (pop thread)))
3915 (setq thread (reverse thread))
3917 (gnus-remove-thread-1 (pop thread)))
3918 (when (setq d (gnus-data-find number))
3919 (goto-char (gnus-data-pos d))
3920 (gnus-summary-show-thread)
3923 (- (gnus-point-at-bol)
3925 (1+ (gnus-point-at-eol))
3926 (gnus-delete-line)))))))
3928 (defun gnus-sort-threads-1 (threads func)
3929 (sort (mapcar (lambda (thread)
3932 (gnus-sort-threads-1 (cdr thread) func))))
3935 (defun gnus-sort-threads (threads)
3937 (if (not gnus-thread-sort-functions)
3939 (gnus-message 8 "Sorting threads...")
3941 (gnus-sort-threads-1
3943 (gnus-make-sort-function gnus-thread-sort-functions))
3944 (gnus-message 8 "Sorting threads...done"))))
3946 (defun gnus-sort-articles (articles)
3948 (when gnus-article-sort-functions
3949 (gnus-message 7 "Sorting articles...")
3951 (setq gnus-newsgroup-headers
3952 (sort articles (gnus-make-sort-function
3953 gnus-article-sort-functions)))
3954 (gnus-message 7 "Sorting articles...done"))))
3956 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3957 (defmacro gnus-thread-header (thread)
3958 "Return header of first article in THREAD.
3959 Note that THREAD must never, ever be anything else than a variable -
3960 using some other form will lead to serious barfage."
3961 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3962 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3963 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3966 (defsubst gnus-article-sort-by-number (h1 h2)
3967 "Sort articles by article number."
3968 (< (mail-header-number h1)
3969 (mail-header-number h2)))
3971 (defun gnus-thread-sort-by-number (h1 h2)
3972 "Sort threads by root article number."
3973 (gnus-article-sort-by-number
3974 (gnus-thread-header h1) (gnus-thread-header h2)))
3976 (defsubst gnus-article-sort-by-lines (h1 h2)
3977 "Sort articles by article Lines header."
3978 (< (mail-header-lines h1)
3979 (mail-header-lines h2)))
3981 (defun gnus-thread-sort-by-lines (h1 h2)
3982 "Sort threads by root article Lines header."
3983 (gnus-article-sort-by-lines
3984 (gnus-thread-header h1) (gnus-thread-header h2)))
3986 (defsubst gnus-article-sort-by-chars (h1 h2)
3987 "Sort articles by octet length."
3988 (< (mail-header-chars h1)
3989 (mail-header-chars h2)))
3991 (defun gnus-thread-sort-by-chars (h1 h2)
3992 "Sort threads by root article octet length."
3993 (gnus-article-sort-by-chars
3994 (gnus-thread-header h1) (gnus-thread-header h2)))
3996 (defsubst gnus-article-sort-by-author (h1 h2)
3997 "Sort articles by root author."
3999 (let ((addr (car (mime-entity-read-field h1 'From))))
4000 (or (std11-full-name-string addr)
4001 (std11-address-string addr)
4003 (let ((addr (car (mime-entity-read-field h2 'From))))
4004 (or (std11-full-name-string addr)
4005 (std11-address-string addr)
4009 (defun gnus-thread-sort-by-author (h1 h2)
4010 "Sort threads by root author."
4011 (gnus-article-sort-by-author
4012 (gnus-thread-header h1) (gnus-thread-header h2)))
4014 (defsubst gnus-article-sort-by-subject (h1 h2)
4015 "Sort articles by root subject."
4017 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4018 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4020 (defun gnus-thread-sort-by-subject (h1 h2)
4021 "Sort threads by root subject."
4022 (gnus-article-sort-by-subject
4023 (gnus-thread-header h1) (gnus-thread-header h2)))
4025 (defsubst gnus-article-sort-by-date (h1 h2)
4026 "Sort articles by root article date."
4028 (gnus-date-get-time (mail-header-date h1))
4029 (gnus-date-get-time (mail-header-date h2))))
4031 (defun gnus-thread-sort-by-date (h1 h2)
4032 "Sort threads by root article date."
4033 (gnus-article-sort-by-date
4034 (gnus-thread-header h1) (gnus-thread-header h2)))
4036 (defsubst gnus-article-sort-by-score (h1 h2)
4037 "Sort articles by root article score.
4038 Unscored articles will be counted as having a score of zero."
4039 (> (or (cdr (assq (mail-header-number h1)
4040 gnus-newsgroup-scored))
4041 gnus-summary-default-score 0)
4042 (or (cdr (assq (mail-header-number h2)
4043 gnus-newsgroup-scored))
4044 gnus-summary-default-score 0)))
4046 (defun gnus-thread-sort-by-score (h1 h2)
4047 "Sort threads by root article score."
4048 (gnus-article-sort-by-score
4049 (gnus-thread-header h1) (gnus-thread-header h2)))
4051 (defun gnus-thread-sort-by-total-score (h1 h2)
4052 "Sort threads by the sum of all scores in the thread.
4053 Unscored articles will be counted as having a score of zero."
4054 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4056 (defun gnus-thread-total-score (thread)
4057 ;; This function find the total score of THREAD.
4058 (cond ((null thread)
4061 (if (stringp (car thread))
4062 (apply gnus-thread-score-function 0
4063 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4064 (gnus-thread-total-score-1 thread)))
4066 (gnus-thread-total-score-1 (list thread)))))
4068 (defun gnus-thread-total-score-1 (root)
4069 ;; This function find the total score of the thread below ROOT.
4070 (setq root (car root))
4071 (apply gnus-thread-score-function
4073 (mapcar 'gnus-thread-total-score
4074 (cdr (gnus-id-to-thread (mail-header-id root))))
4075 (when (> (mail-header-number root) 0)
4076 (list (or (cdr (assq (mail-header-number root)
4077 gnus-newsgroup-scored))
4078 gnus-summary-default-score 0))))
4079 (list gnus-summary-default-score)
4082 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4083 (defvar gnus-tmp-prev-subject nil)
4084 (defvar gnus-tmp-false-parent nil)
4085 (defvar gnus-tmp-root-expunged nil)
4086 (defvar gnus-tmp-dummy-line nil)
4088 (eval-when-compile (defvar gnus-tmp-header))
4089 (defun gnus-extra-header (type &optional header)
4090 "Return the extra header of TYPE."
4091 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4094 (defun gnus-summary-prepare-threads (threads)
4095 "Prepare summary buffer from THREADS and indentation LEVEL.
4096 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4097 or a straight list of headers."
4098 (gnus-message 7 "Generating summary...")
4100 (setq gnus-newsgroup-threads threads)
4103 (let ((gnus-tmp-level 0)
4104 (default-score (or gnus-summary-default-score 0))
4105 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4106 thread number subject stack state gnus-tmp-gathered beg-match
4107 new-roots gnus-tmp-new-adopts thread-end
4108 gnus-tmp-header gnus-tmp-unread
4109 gnus-tmp-replied gnus-tmp-subject-or-nil
4110 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4111 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4112 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4114 (setq gnus-tmp-prev-subject nil)
4116 (if (vectorp (car threads))
4117 ;; If this is a straight (sic) list of headers, then a
4118 ;; threaded summary display isn't required, so we just create
4119 ;; an unthreaded one.
4120 (gnus-summary-prepare-unthreaded threads)
4122 ;; Do the threaded display.
4124 (while (or threads stack gnus-tmp-new-adopts new-roots)
4126 (if (and (= gnus-tmp-level 0)
4129 (not gnus-tmp-false-parent)
4130 (or gnus-tmp-new-adopts new-roots))
4131 (if gnus-tmp-new-adopts
4132 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4133 thread (list (car gnus-tmp-new-adopts))
4134 gnus-tmp-header (caar thread)
4135 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4137 (setq thread (list (car new-roots))
4138 gnus-tmp-header (caar thread)
4139 new-roots (cdr new-roots))))
4142 ;; If there are some threads, we do them before the
4143 ;; threads on the stack.
4144 (setq thread threads
4145 gnus-tmp-header (caar thread))
4146 ;; There were no current threads, so we pop something off
4148 (setq state (car stack)
4149 gnus-tmp-level (car state)
4152 gnus-tmp-header (caar thread))))
4154 (setq gnus-tmp-false-parent nil)
4155 (setq gnus-tmp-root-expunged nil)
4156 (setq thread-end nil)
4158 (if (stringp gnus-tmp-header)
4159 ;; The header is a dummy root.
4161 ((eq gnus-summary-make-false-root 'adopt)
4162 ;; We let the first article adopt the rest.
4163 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4165 (setq gnus-tmp-gathered
4167 (lambda (h) (mail-header-number (car h)))
4170 (setq thread (cons (list (caar thread)
4173 (setq gnus-tmp-level -1
4174 gnus-tmp-false-parent t))
4175 ((eq gnus-summary-make-false-root 'empty)
4176 ;; We print adopted articles with empty subject fields.
4177 (setq gnus-tmp-gathered
4179 (lambda (h) (mail-header-number (car h)))
4182 (setq gnus-tmp-level -1))
4183 ((eq gnus-summary-make-false-root 'dummy)
4184 ;; We remember that we probably want to output a dummy
4186 (setq gnus-tmp-dummy-line gnus-tmp-header)
4187 (setq gnus-tmp-prev-subject gnus-tmp-header))
4189 ;; We do not make a root for the gathered
4190 ;; sub-threads at all.
4191 (setq gnus-tmp-level -1)))
4193 (setq number (mail-header-number gnus-tmp-header)
4194 subject (mail-header-subject gnus-tmp-header))
4197 ;; If the thread has changed subject, we might want to make
4198 ;; this subthread into a root.
4199 ((and (null gnus-thread-ignore-subject)
4200 (not (zerop gnus-tmp-level))
4201 gnus-tmp-prev-subject
4203 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4204 (setq new-roots (nconc new-roots (list (car thread)))
4206 gnus-tmp-header nil))
4207 ;; If the article lies outside the current limit,
4208 ;; then we do not display it.
4209 ((not (memq number gnus-newsgroup-limit))
4210 (setq gnus-tmp-gathered
4212 (lambda (h) (mail-header-number (car h)))
4215 (setq gnus-tmp-new-adopts (if (cdar thread)
4216 (append gnus-tmp-new-adopts
4218 gnus-tmp-new-adopts)
4220 gnus-tmp-header nil)
4221 (when (zerop gnus-tmp-level)
4222 (setq gnus-tmp-root-expunged t)))
4223 ;; Perhaps this article is to be marked as read?
4224 ((and gnus-summary-mark-below
4225 (< (or (cdr (assq number gnus-newsgroup-scored))
4227 gnus-summary-mark-below)
4228 ;; Don't touch sparse articles.
4229 (not (gnus-summary-article-sparse-p number))
4230 (not (gnus-summary-article-ancient-p number)))
4231 (setq gnus-newsgroup-unreads
4232 (delq number gnus-newsgroup-unreads))
4233 (if gnus-newsgroup-auto-expire
4234 (push number gnus-newsgroup-expirable)
4235 (push (cons number gnus-low-score-mark)
4236 gnus-newsgroup-reads))))
4238 (when gnus-tmp-header
4239 ;; We may have an old dummy line to output before this
4241 (when (and gnus-tmp-dummy-line
4244 (mail-header-subject gnus-tmp-header)))
4245 (gnus-summary-insert-dummy-line
4246 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4247 (setq gnus-tmp-dummy-line nil))
4249 ;; Compute the mark.
4250 (setq gnus-tmp-unread (gnus-article-mark number))
4252 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4253 gnus-tmp-header gnus-tmp-level)
4254 gnus-newsgroup-data)
4256 ;; Actually insert the line.
4258 gnus-tmp-subject-or-nil
4260 ((and gnus-thread-ignore-subject
4261 gnus-tmp-prev-subject
4262 (not (inline (gnus-subject-equal
4263 gnus-tmp-prev-subject subject))))
4265 ((zerop gnus-tmp-level)
4266 (if (and (eq gnus-summary-make-false-root 'empty)
4267 (memq number gnus-tmp-gathered)
4268 gnus-tmp-prev-subject
4269 (inline (gnus-subject-equal
4270 gnus-tmp-prev-subject subject)))
4271 gnus-summary-same-subject
4273 (t gnus-summary-same-subject)))
4274 (if (and (eq gnus-summary-make-false-root 'adopt)
4275 (= gnus-tmp-level 1)
4276 (memq number gnus-tmp-gathered))
4277 (setq gnus-tmp-opening-bracket ?\<
4278 gnus-tmp-closing-bracket ?\>)
4279 (setq gnus-tmp-opening-bracket ?\[
4280 gnus-tmp-closing-bracket ?\]))
4282 gnus-tmp-indentation
4283 (aref gnus-thread-indent-array gnus-tmp-level)
4284 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4285 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4286 gnus-summary-default-score 0)
4288 (if (or (null gnus-summary-default-score)
4289 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4290 gnus-summary-zcore-fuzz))
4292 (if (< gnus-tmp-score gnus-summary-default-score)
4293 gnus-score-below-mark gnus-score-over-mark))
4295 (cond ((memq number gnus-newsgroup-processable)
4297 ((memq number gnus-newsgroup-cached)
4299 ((memq number gnus-newsgroup-replied)
4301 ((memq number gnus-newsgroup-forwarded)
4302 gnus-forwarded-mark)
4303 ((memq number gnus-newsgroup-saved)
4306 gnus-tmp-from (mail-header-from gnus-tmp-header)
4309 ((string-match "<[^>]+> *$" gnus-tmp-from)
4310 (setq beg-match (match-beginning 0))
4311 (or (and (string-match "^\".+\"" gnus-tmp-from)
4312 (substring gnus-tmp-from 1 (1- (match-end 0))))
4313 (substring gnus-tmp-from 0 beg-match)))
4314 ((string-match "(.+)" gnus-tmp-from)
4315 (substring gnus-tmp-from
4316 (1+ (match-beginning 0)) (1- (match-end 0))))
4318 (when (string= gnus-tmp-name "")
4319 (setq gnus-tmp-name gnus-tmp-from))
4320 (unless (numberp gnus-tmp-lines)
4321 (setq gnus-tmp-lines -1))
4322 (when (= gnus-tmp-lines -1)
4323 (setq gnus-tmp-lines "?"))
4324 (gnus-put-text-property
4326 (progn (eval gnus-summary-line-format-spec) (point))
4327 'gnus-number number)
4330 (gnus-run-hooks 'gnus-summary-update-hook)
4333 (setq gnus-tmp-prev-subject subject)))
4335 (when (nth 1 thread)
4336 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4337 (incf gnus-tmp-level)
4338 (setq threads (if thread-end nil (cdar thread)))
4340 (setq gnus-tmp-level 0)))))
4341 (gnus-message 7 "Generating summary...done"))
4343 (defun gnus-summary-prepare-unthreaded (headers)
4344 "Generate an unthreaded summary buffer based on HEADERS."
4345 (let (header number mark)
4350 ;; We may have to root out some bad articles...
4351 (when (memq (setq number (mail-header-number
4352 (setq header (pop headers))))
4353 gnus-newsgroup-limit)
4354 ;; Mark article as read when it has a low score.
4355 (when (and gnus-summary-mark-below
4356 (< (or (cdr (assq number gnus-newsgroup-scored))
4357 gnus-summary-default-score 0)
4358 gnus-summary-mark-below)
4359 (not (gnus-summary-article-ancient-p number)))
4360 (setq gnus-newsgroup-unreads
4361 (delq number gnus-newsgroup-unreads))
4362 (if gnus-newsgroup-auto-expire
4363 (push number gnus-newsgroup-expirable)
4364 (push (cons number gnus-low-score-mark)
4365 gnus-newsgroup-reads)))
4367 (setq mark (gnus-article-mark number))
4368 (push (gnus-data-make number mark (1+ (point)) header 0)
4369 gnus-newsgroup-data)
4370 (gnus-summary-insert-line
4372 mark (memq number gnus-newsgroup-replied)
4373 (memq number gnus-newsgroup-expirable)
4374 (mail-header-subject header) nil
4375 (cdr (assq number gnus-newsgroup-scored))
4376 (memq number gnus-newsgroup-processable))))))
4378 (defun gnus-summary-remove-list-identifiers ()
4379 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4380 (let ((regexp (if (consp gnus-list-identifiers)
4381 (mapconcat 'identity gnus-list-identifiers " *\\|")
4382 gnus-list-identifiers))
4385 (dolist (header gnus-newsgroup-headers)
4386 (setq subject (mail-header-subject header)
4388 (while (string-match
4389 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4392 (concat (substring subject 0 (match-beginning 2))
4393 (substring subject (match-end 0)))
4397 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4399 (concat (substring subject 0 (match-beginning 1))
4400 (substring subject (match-end 1)))))
4402 (mail-header-set-subject header subject))))))
4404 (defun gnus-fetch-headers (articles)
4405 "Fetch headers of ARTICLES."
4406 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4407 (gnus-message 5 "Fetching headers for %s..." name)
4409 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
4410 (if (eq 'nnimap (car (gnus-find-method-for-group name)))
4412 (setq gnus-headers-retrieved-by
4413 (gnus-retrieve-headers
4414 articles gnus-newsgroup-name
4415 ;; We might want to fetch old headers, but
4416 ;; not if there is only 1 article.
4418 (not (eq gnus-fetch-old-headers 'some))
4419 (not (numberp gnus-fetch-old-headers)))
4420 (> (length articles) 1))
4421 gnus-fetch-old-headers))))
4422 (gnus-get-newsgroup-headers-xover
4423 articles nil nil gnus-newsgroup-name t)
4424 (gnus-get-newsgroup-headers))
4425 (gnus-retrieve-parsed-headers
4426 articles gnus-newsgroup-name
4427 ;; We might want to fetch old headers, but
4428 ;; not if there is only 1 article.
4429 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4430 (not (numberp gnus-fetch-old-headers)))
4431 (> (length articles) 1))
4432 gnus-fetch-old-headers)))
4433 (gnus-message 5 "Fetching headers for %s...done" name))))
4435 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4436 "Select newsgroup GROUP.
4437 If READ-ALL is non-nil, all articles in the group are selected.
4438 If SELECT-ARTICLES, only select those articles from GROUP."
4439 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4440 ;;!!! Dirty hack; should be removed.
4441 (gnus-summary-ignore-duplicates
4442 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4444 gnus-summary-ignore-duplicates))
4445 (info (nth 2 entry))
4446 articles fetched-articles cached)
4448 (unless (gnus-check-server
4449 (setq gnus-current-select-method
4450 (gnus-find-method-for-group group)))
4451 (error "Couldn't open server"))
4453 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4454 (gnus-activate-group group) ; Or we can activate it...
4455 (progn ; Or we bug out.
4456 (when (equal major-mode 'gnus-summary-mode)
4457 (kill-buffer (current-buffer)))
4458 (error "Couldn't activate group %s: %s"
4459 group (gnus-status-message group))))
4461 (unless (gnus-request-group group t)
4462 (when (equal major-mode 'gnus-summary-mode)
4463 (kill-buffer (current-buffer)))
4464 (error "Couldn't request group %s: %s"
4465 group (gnus-status-message group)))
4467 (setq gnus-newsgroup-name group)
4468 (setq gnus-newsgroup-unselected nil)
4469 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4470 (gnus-summary-setup-default-charset)
4472 ;; Adjust and set lists of article marks.
4474 (gnus-adjust-marked-articles info))
4476 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4478 (if (gnus-virtual-group-p group)
4479 gnus-newsgroup-cached
4480 (gnus-cache-articles-in-group group)))
4482 (setq gnus-newsgroup-unreads
4483 (gnus-set-difference
4484 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4485 gnus-newsgroup-dormant))
4487 (setq gnus-newsgroup-processable nil)
4489 (gnus-update-read-articles group gnus-newsgroup-unreads)
4491 (if (setq articles select-articles)
4492 (setq gnus-newsgroup-unselected
4493 (gnus-sorted-intersection
4494 gnus-newsgroup-unreads
4495 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4496 (setq articles (gnus-articles-to-read group read-all)))
4500 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4502 ((eq articles 0) nil)
4504 ;; Init the dependencies hash table.
4505 (setq gnus-newsgroup-dependencies
4506 (gnus-make-hashtable (length articles)))
4507 (gnus-set-global-variables)
4508 ;; Retrieve the headers and read them in.
4509 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4511 ;; Suppress duplicates?
4512 (when gnus-suppress-duplicates
4513 (gnus-dup-suppress-articles))
4515 ;; Set the initial limit.
4516 (setq gnus-newsgroup-limit (copy-sequence articles))
4517 ;; Remove canceled articles from the list of unread articles.
4518 (setq gnus-newsgroup-unreads
4519 (gnus-set-sorted-intersection
4520 gnus-newsgroup-unreads
4521 (setq fetched-articles
4522 (mapcar (lambda (headers) (mail-header-number headers))
4523 gnus-newsgroup-headers))))
4524 ;; Removed marked articles that do not exist.
4525 (gnus-update-missing-marks
4526 (gnus-sorted-complement fetched-articles articles))
4528 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4530 (setq gnus-newsgroup-cached cached))
4532 ;; We might want to build some more threads first.
4533 (when (and gnus-fetch-old-headers
4534 (eq gnus-headers-retrieved-by 'nov))
4535 (if (eq gnus-fetch-old-headers 'invisible)
4536 (gnus-build-all-threads)
4537 (gnus-build-old-threads)))
4538 ;; Let the Gnus agent mark articles as read.
4540 (gnus-agent-get-undownloaded-list))
4541 ;; Remove list identifiers from subject
4542 (when gnus-list-identifiers
4543 (gnus-summary-remove-list-identifiers))
4544 ;; Check whether auto-expire is to be done in this group.
4545 (setq gnus-newsgroup-auto-expire
4546 (gnus-group-auto-expirable-p group))
4547 ;; Set up the article buffer now, if necessary.
4548 (unless gnus-single-article-buffer
4549 (gnus-article-setup-buffer))
4550 ;; First and last article in this newsgroup.
4551 (when gnus-newsgroup-headers
4552 (setq gnus-newsgroup-begin
4553 (mail-header-number (car gnus-newsgroup-headers))
4556 (gnus-last-element gnus-newsgroup-headers))))
4557 ;; GROUP is successfully selected.
4558 (or gnus-newsgroup-headers t)))))
4560 (defun gnus-articles-to-read (group &optional read-all)
4561 "Find out what articles the user wants to read."
4563 ;; Select all articles if `read-all' is non-nil, or if there
4564 ;; are no unread articles.
4566 (and (zerop (length gnus-newsgroup-marked))
4567 (zerop (length gnus-newsgroup-unreads)))
4568 (eq (gnus-group-find-parameter group 'display)
4571 (gnus-uncompress-range (gnus-active group))
4572 (gnus-cache-articles-in-group group))
4573 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4574 (copy-sequence gnus-newsgroup-unreads))
4576 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4577 (scored (length scored-list))
4578 (number (length articles))
4579 (marked (+ (length gnus-newsgroup-marked)
4580 (length gnus-newsgroup-dormant)))
4588 ((and (or (<= scored marked) (= scored number))
4589 (natnump gnus-large-newsgroup)
4590 (> number gnus-large-newsgroup))
4591 (let* ((cursor-in-echo-area nil)
4592 (input (read-from-minibuffer
4594 "How many articles from %s (max %d): "
4595 (gnus-limit-string gnus-newsgroup-name 35)
4597 (cons (number-to-string gnus-large-newsgroup)
4599 (if (string-match "^[ \t]*$" input)
4602 ((and (> scored marked) (< scored number)
4603 (> (- scored number) 20))
4606 (format "%s %s (%d scored, %d total): "
4607 "How many articles from"
4608 group scored number))))
4609 (if (string-match "^[ \t]*$" input)
4613 (message "Quit getting the articles to read")
4615 (setq select (if (stringp select) (string-to-number select) select))
4616 (if (or (null select) (zerop select))
4618 (if (and (not (zerop scored)) (<= (abs select) scored))
4620 (setq articles (sort scored-list '<))
4621 (setq number (length articles)))
4622 (setq articles (copy-sequence articles)))
4624 (when (< (abs select) number)
4626 ;; Select the N oldest articles.
4627 (setcdr (nthcdr (1- (abs select)) articles) nil)
4628 ;; Select the N most recent articles.
4629 (setq articles (nthcdr (- number select) articles))))
4630 (setq gnus-newsgroup-unselected
4631 (gnus-sorted-intersection
4632 gnus-newsgroup-unreads
4633 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4634 (when gnus-alter-articles-to-read-function
4635 (setq gnus-newsgroup-unreads
4637 (funcall gnus-alter-articles-to-read-function
4638 gnus-newsgroup-name gnus-newsgroup-unreads)
4642 (defun gnus-killed-articles (killed articles)
4645 (when (inline (gnus-member-of-range (car articles) killed))
4646 (push (car articles) out))
4647 (setq articles (cdr articles)))
4650 (defun gnus-uncompress-marks (marks)
4651 "Uncompress the mark ranges in MARKS."
4652 (let ((uncompressed '(score bookmark))
4655 (if (memq (caar marks) uncompressed)
4656 (push (car marks) out)
4657 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4658 (setq marks (cdr marks)))
4661 (defun gnus-adjust-marked-articles (info)
4662 "Set all article lists and remove all marks that are no longer valid."
4663 (let* ((marked-lists (gnus-info-marks info))
4664 (active (gnus-active (gnus-info-group info)))
4667 (types gnus-article-mark-lists)
4668 (uncompressed '(score bookmark killed))
4669 marks var articles article mark)
4672 (setq marks (pop marked-lists))
4673 (set (setq var (intern (format "gnus-newsgroup-%s"
4674 (car (rassq (setq mark (car marks))
4676 (if (memq (car marks) uncompressed) (cdr marks)
4677 (gnus-uncompress-range (cdr marks))))
4679 (setq articles (symbol-value var))
4681 ;; All articles have to be subsets of the active articles.
4683 ;; Adjust "simple" lists.
4684 ((memq mark '(tick dormant expire reply save))
4686 (when (or (< (setq article (pop articles)) min) (> article max))
4687 (set var (delq article (symbol-value var))))))
4689 ((memq mark uncompressed)
4690 (when (not (listp (cdr (symbol-value var))))
4691 (set var (list (symbol-value var))))
4692 (when (not (listp (cdr articles)))
4693 (setq articles (list articles)))
4695 (when (or (not (consp (setq article (pop articles))))
4696 (< (car article) min)
4697 (> (car article) max))
4698 (set var (delq article (symbol-value var))))))))))
4700 (defun gnus-update-missing-marks (missing)
4701 "Go through the list of MISSING articles and remove them from the mark lists."
4703 (let ((types gnus-article-mark-lists)
4705 ;; Go through all types.
4707 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4708 (when (symbol-value var)
4709 ;; This list has articles. So we delete all missing articles
4713 (set var (delq (pop m) (symbol-value var)))))))))
4715 (defun gnus-update-marks ()
4716 "Enter the various lists of marked articles into the newsgroup info list."
4717 (let ((types gnus-article-mark-lists)
4718 (info (gnus-get-info gnus-newsgroup-name))
4719 (uncompressed '(score bookmark killed))
4720 type list newmarked symbol delta-marks)
4722 ;; Add all marks lists to the list of marks lists.
4723 (while (setq type (pop types))
4724 (setq list (symbol-value
4726 (intern (format "gnus-newsgroup-%s"
4730 ;; Get rid of the entries of the articles that have the
4732 (when (and (eq (cdr type) 'score)
4736 (prev (cons nil list))
4739 (if (or (not (consp (car arts)))
4740 (= (cdar arts) gnus-summary-default-score))
4741 (setcdr prev (cdr arts))
4743 (setq arts (cdr arts)))
4744 (setq list (cdr all)))))
4746 (unless (memq (cdr type) uncompressed)
4747 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4749 (when (gnus-check-backend-function
4750 'request-set-mark gnus-newsgroup-name)
4751 ;; propagate flags to server, with the following exceptions:
4752 ;; uncompressed:s are not proper flags (they are cons cells)
4753 ;; cache is a internal gnus flag
4754 ;; download are local to one gnus installation (well)
4755 ;; unsend are for nndraft groups only
4756 ;; xxx: generality of this? this suits nnimap anyway
4757 (unless (memq (cdr type) (append '(cache download unsend)
4759 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4760 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4761 (add (gnus-remove-from-range
4762 (gnus-copy-sequence list) old)))
4764 (push (list add 'add (list (cdr type))) delta-marks))
4766 (push (list del 'del (list (cdr type))) delta-marks)))))
4769 (push (cons (cdr type) list) newmarked)))
4772 (unless (gnus-check-group gnus-newsgroup-name)
4773 (error "Can't open server for %s" gnus-newsgroup-name))
4774 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4776 ;; Enter these new marks into the info of the group.
4778 (setcar (nthcdr 3 info) newmarked)
4779 ;; Add the marks lists to the end of the info.
4781 (setcdr (nthcdr 2 info) (list newmarked))))
4783 ;; Cut off the end of the info if there's nothing else there.
4787 (when (nthcdr (decf i) info)
4788 (setcdr (nthcdr i info) nil)))))))
4790 (defun gnus-set-mode-line (where)
4791 "Set the mode line of the article or summary buffers.
4792 If WHERE is `summary', the summary mode line format will be used."
4793 ;; Is this mode line one we keep updated?
4794 (when (and (memq where gnus-updated-mode-lines)
4796 (intern (format "gnus-%s-mode-line-format-spec" where))))
4799 ;; We evaluate this in the summary buffer since these
4800 ;; variables are buffer-local to that buffer.
4801 (set-buffer gnus-summary-buffer)
4802 ;; We bind all these variables that are used in the `eval' form
4804 (let* ((mformat (symbol-value
4806 (format "gnus-%s-mode-line-format-spec" where))))
4807 (gnus-tmp-group-name (gnus-group-decoded-name
4808 gnus-newsgroup-name))
4809 (gnus-tmp-article-number (or gnus-current-article 0))
4810 (gnus-tmp-unread gnus-newsgroup-unreads)
4811 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4812 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4813 (gnus-tmp-unread-and-unselected
4814 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4815 (zerop gnus-tmp-unselected))
4817 ((zerop gnus-tmp-unselected)
4818 (format "{%d more}" gnus-tmp-unread-and-unticked))
4819 (t (format "{%d(+%d) more}"
4820 gnus-tmp-unread-and-unticked
4821 gnus-tmp-unselected))))
4823 (if (and gnus-current-headers
4824 (vectorp gnus-current-headers))
4825 (gnus-mode-string-quote
4826 (mail-header-subject gnus-current-headers))
4828 bufname-length max-len
4829 gnus-tmp-header);; passed as argument to any user-format-funcs
4830 (setq mode-string (eval mformat))
4831 (setq bufname-length (if (string-match "%b" mode-string)
4834 (if (eq where 'summary)
4836 (get-buffer gnus-article-buffer))))
4839 (setq max-len (max 4 (if gnus-mode-non-string-length
4841 gnus-mode-non-string-length
4843 (length mode-string))))
4844 ;; We might have to chop a bit of the string off...
4845 (when (> (length mode-string) max-len)
4847 (concat (gnus-truncate-string mode-string (- max-len 3))
4849 ;; Pad the mode string a bit.
4850 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4851 ;; Update the mode line.
4852 (setq mode-line-buffer-identification
4853 (gnus-mode-line-buffer-identification (list mode-string)))
4854 (set-buffer-modified-p t))))
4856 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4857 "Go through the HEADERS list and add all Xrefs to a hash table.
4858 The resulting hash table is returned, or nil if no Xrefs were found."
4859 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4860 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4861 (xref-hashtb (gnus-make-hashtable))
4862 start group entry number xrefs header)
4864 (setq header (pop headers))
4865 (when (and (setq xrefs (mail-header-xref header))
4866 (not (memq (setq number (mail-header-number header))
4869 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4870 (setq start (match-end 0))
4871 (setq group (if prefix
4872 (concat prefix (substring xrefs (match-beginning 1)
4874 (substring xrefs (match-beginning 1) (match-end 1))))
4876 (string-to-int (substring xrefs (match-beginning 2)
4878 (if (setq entry (gnus-gethash group xref-hashtb))
4879 (setcdr entry (cons number (cdr entry)))
4880 (gnus-sethash group (cons number nil) xref-hashtb)))))
4881 (and start xref-hashtb)))
4883 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4884 "Look through all the headers and mark the Xrefs as read."
4885 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4886 name entry info xref-hashtb idlist method nth4)
4888 (set-buffer gnus-group-buffer)
4889 (when (setq xref-hashtb
4890 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4893 (unless (string= from-newsgroup (setq name (symbol-name group)))
4894 (setq idlist (symbol-value group))
4895 ;; Dead groups are not updated.
4897 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4899 (when (stringp (setq nth4 (gnus-info-method info)))
4900 (setq nth4 (gnus-server-to-method nth4))))
4901 ;; Only do the xrefs if the group has the same
4902 ;; select method as the group we have just read.
4903 (or (gnus-methods-equal-p
4904 nth4 (gnus-find-method-for-group from-newsgroup))
4906 (equal nth4 (setq method (gnus-find-method-for-group
4908 (and (equal (car nth4) (car method))
4909 (equal (nth 1 nth4) (nth 1 method))))
4910 gnus-use-cross-reference
4911 (or (not (eq gnus-use-cross-reference t))
4913 ;; Only do cross-references on subscribed
4914 ;; groups, if that is what is wanted.
4915 (<= (gnus-info-level info) gnus-level-subscribed))
4916 (gnus-group-make-articles-read name idlist))))
4919 (defun gnus-compute-read-articles (group articles)
4920 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4921 (info (nth 2 entry))
4922 (active (gnus-active group))
4925 ;; First peel off all invalid article numbers.
4927 (let ((ids articles)
4929 (while (setq id (pop ids))
4930 (when (and first (> id (cdr active)))
4931 ;; We'll end up in this situation in one particular
4932 ;; obscure situation. If you re-scan a group and get
4933 ;; a new article that is cross-posted to a different
4934 ;; group that has not been re-scanned, you might get
4935 ;; crossposted article that has a higher number than
4936 ;; Gnus believes possible. So we re-activate this
4937 ;; group as well. This might mean doing the
4938 ;; crossposting thingy will *increase* the number
4939 ;; of articles in some groups. Tsk, tsk.
4940 (setq active (or (gnus-activate-group group) active)))
4941 (when (or (> id (cdr active))
4942 (< id (car active)))
4943 (setq articles (delq id articles))))))
4944 ;; If the read list is nil, we init it.
4946 (null (gnus-info-read info))
4948 (setq ninfo (cons 1 (1- (car active))))
4949 (setq ninfo (gnus-info-read info)))
4950 ;; Then we add the read articles to the range.
4952 ninfo (setq articles (sort articles '<))))))
4954 (defun gnus-group-make-articles-read (group articles)
4955 "Update the info of GROUP to say that ARTICLES are read."
4957 (entry (gnus-gethash group gnus-newsrc-hashtb))
4958 (info (nth 2 entry))
4959 (active (gnus-active group))
4962 (setq range (gnus-compute-read-articles group articles))
4964 (set-buffer gnus-group-buffer)
4967 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4968 (gnus-info-set-read ',info ',(gnus-info-read info))
4969 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4970 (gnus-group-update-group ,group t))))
4971 ;; Add the read articles to the range.
4972 (gnus-info-set-read info range)
4973 ;; Then we have to re-compute how many unread
4974 ;; articles there are in this group.
4978 (setq num (- (1+ (cdr active)) (car active))))
4979 ((not (listp (cdr range)))
4980 (setq num (- (cdr active) (- (1+ (cdr range))
4984 (if (numberp (car range))
4986 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4987 (setq range (cdr range)))
4988 (setq num (- (cdr active) num))))
4989 ;; Update the number of unread articles.
4991 ;; Update the group buffer.
4992 (gnus-group-update-group group t)))))
4994 (defvar gnus-newsgroup-none-id 0)
4996 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4997 (let ((cur nntp-server-buffer)
5000 (save-excursion (set-buffer gnus-summary-buffer)
5001 gnus-newsgroup-dependencies)))
5003 (mail-parse-charset gnus-newsgroup-charset)
5004 (mail-parse-ignored-charsets
5005 (save-excursion (condition-case nil
5006 (set-buffer gnus-summary-buffer)
5008 gnus-newsgroup-ignored-charsets)))
5010 (set-buffer nntp-server-buffer)
5011 ;; Translate all TAB characters into SPACE characters.
5012 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5013 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5014 (gnus-run-hooks 'gnus-parse-headers-hook)
5015 (let ((case-fold-search t)
5016 in-reply-to header p lines chars ctype)
5017 (goto-char (point-min))
5018 ;; Search to the beginning of the next header. Error messages
5019 ;; do not begin with 2 or 3.
5020 (while (re-search-forward "^[23][0-9]+ " nil t)
5023 ;; This implementation of this function, with nine
5024 ;; search-forwards instead of the one re-search-forward and
5025 ;; a case (which basically was the old function) is actually
5026 ;; about twice as fast, even though it looks messier. You
5027 ;; can't have everything, I guess. Speed and elegance
5028 ;; doesn't always go hand in hand.
5031 (make-full-mail-header
5037 (narrow-to-region (point)
5038 (or (and (search-forward "\n.\n" nil t)
5044 (if (search-forward "\nsubject: " nil t)
5045 (nnheader-header-value)
5050 (if (or (search-forward "\nfrom: " nil t)
5051 (search-forward "\nfrom:" nil t))
5052 (nnheader-header-value)
5057 (if (search-forward "\ndate: " nil t)
5058 (nnheader-header-value)
5063 (setq id (if (re-search-forward
5064 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5065 ;; We do it this way to make sure the Message-ID
5066 ;; is (somewhat) syntactically valid.
5067 (buffer-substring (match-beginning 1)
5069 ;; If there was no message-id, we just fake one
5070 ;; to make subsequent routines simpler.
5071 (nnheader-generate-fake-message-id))))
5075 (if (search-forward "\nreferences: " nil t)
5079 (nnheader-header-value)
5084 (search-backward ">" end t)
5087 (search-backward "<" end t)
5089 ;; Get the references from the in-reply-to header if there
5090 ;; were no references and the in-reply-to header looks
5092 (if (and (search-forward "\nin-reply-to: " nil t)
5093 (setq in-reply-to (nnheader-header-value))
5094 (string-match "<[^>]+>" in-reply-to))
5096 (setq ref (substring in-reply-to (match-beginning 0)
5098 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5099 (setq ref2 (substring in-reply-to (match-beginning 0)
5101 (when (> (length ref2) (length ref))
5108 (if (search-forward "\nchars: " nil t)
5109 (if (numberp (setq chars (ignore-errors (read cur))))
5115 (if (search-forward "\nlines: " nil t)
5116 (if (numberp (setq lines (ignore-errors (read cur))))
5122 (and (search-forward "\nxref: " nil t)
5123 (nnheader-header-value)))
5125 (when gnus-extra-headers
5126 (let ((extra gnus-extra-headers)
5130 (when (search-forward
5131 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5132 (push (cons (car extra) (nnheader-header-value)) out))
5136 (if (and (search-forward "\ncontent-type: " nil t)
5137 (setq ctype (nnheader-header-value)))
5138 (mime-entity-set-content-type-internal
5139 header (mime-parse-Content-Type ctype)))
5140 (when (equal id ref)
5143 (when gnus-alter-header-function
5144 (funcall gnus-alter-header-function header)
5145 (setq id (mail-header-id header)
5146 ref (gnus-parent-id (mail-header-references header))))
5149 (gnus-dependencies-add-header
5150 header dependencies force-new))
5151 (push header headers))
5152 (goto-char (point-max))
5154 (nreverse headers)))))
5156 ;; Goes through the xover lines and returns a list of vectors
5157 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5158 force-new dependencies
5159 group also-fetch-heads)
5160 "Parse the news overview data in the server buffer.
5161 Return a list of headers that match SEQUENCE (see
5162 `nntp-retrieve-headers')."
5163 ;; Get the Xref when the users reads the articles since most/some
5164 ;; NNTP servers do not include Xrefs when using XOVER.
5165 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5166 (let ((mail-parse-charset gnus-newsgroup-charset)
5167 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5168 (cur nntp-server-buffer)
5169 (dependencies (or dependencies gnus-newsgroup-dependencies))
5171 ((eq gnus-read-all-available-headers t)
5173 ((stringp gnus-read-all-available-headers)
5174 (string-match gnus-read-all-available-headers group))
5177 number headers header)
5179 (set-buffer nntp-server-buffer)
5180 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5181 ;; Allow the user to mangle the headers before parsing them.
5182 (gnus-run-hooks 'gnus-parse-headers-hook)
5183 (goto-char (point-min))
5186 (while (and (or sequence allp)
5188 (setq number (read cur))
5190 (while (and sequence
5191 (< (car sequence) number))
5192 (setq sequence (cdr sequence))))
5195 (eq number (car sequence))))
5197 (setq sequence (cdr sequence))
5198 (setq header (inline
5199 (gnus-nov-parse-line
5200 number dependencies force-new)))))
5201 (push header headers))
5204 (gnus-error 4 "Strange nov line (%d)"
5205 (count-lines (point-min) (point)))))
5207 ;; A common bug in inn is that if you have posted an article and
5208 ;; then retrieves the active file, it will answer correctly --
5209 ;; the new article is included. However, a NOV entry for the
5210 ;; article may not have been generated yet, so this may fail.
5211 ;; We work around this problem by retrieving the last few
5212 ;; headers using HEAD.
5213 (if (or (not also-fetch-heads)
5215 ;; We (probably) got all the headers.
5217 (let ((gnus-nov-is-evil t))
5220 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
5221 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
5222 (when (gnus-retrieve-headers sequence group)
5223 (gnus-get-newsgroup-headers))
5224 (gnus-retrieve-parsed-headers sequence group))))))))
5226 (defun gnus-article-get-xrefs ()
5227 "Fill in the Xref value in `gnus-current-headers', if necessary.
5228 This is meant to be called in `gnus-article-internal-prepare-hook'."
5229 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5230 gnus-current-headers)))
5231 (or (not gnus-use-cross-reference)
5233 (and (mail-header-xref headers)
5234 (not (string= (mail-header-xref headers) "")))
5235 (let ((case-fold-search t)
5238 (nnheader-narrow-to-headers)
5239 (goto-char (point-min))
5240 (when (or (and (not (eobp))
5241 (eq (downcase (char-after)) ?x)
5242 (looking-at "Xref:"))
5243 (search-forward "\nXref:" nil t))
5244 (goto-char (1+ (match-end 0)))
5245 (setq xref (buffer-substring (point)
5246 (progn (end-of-line) (point))))
5247 (mail-header-set-xref headers xref)))))))
5249 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5250 "Find article ID and insert the summary line for that article.
5251 OLD-HEADER can either be a header or a line number to insert
5252 the subject line on."
5253 (let* ((line (and (numberp old-header) old-header))
5254 (old-header (and (vectorp old-header) old-header))
5255 (header (cond ((and old-header use-old-header)
5258 (gnus-number-to-header id))
5259 (gnus-number-to-header id))
5261 (gnus-read-header id))))
5262 (number (and (numberp id) id))
5265 ;; Rebuild the thread that this article is part of and go to the
5266 ;; article we have fetched.
5267 (when (and (not gnus-show-threads)
5270 (setq d (gnus-data-find (mail-header-number old-header))))
5271 (goto-char (gnus-data-pos d))
5274 (- (gnus-point-at-bol)
5276 (1+ (gnus-point-at-eol))
5277 (gnus-delete-line))))))
5279 (mail-header-set-number header (mail-header-number old-header)))
5280 (setq gnus-newsgroup-sparse
5281 (delq (setq number (mail-header-number header))
5282 gnus-newsgroup-sparse))
5283 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5284 (push number gnus-newsgroup-limit)
5285 (gnus-rebuild-thread (mail-header-id header) line)
5286 (gnus-summary-goto-subject number nil t))
5287 (when (and (numberp number)
5289 ;; We have to update the boundaries even if we can't fetch the
5290 ;; article if ID is a number -- so that the next `P' or `N'
5291 ;; command will fetch the previous (or next) article even
5292 ;; if the one we tried to fetch this time has been canceled.
5293 (when (> number gnus-newsgroup-end)
5294 (setq gnus-newsgroup-end number))
5295 (when (< number gnus-newsgroup-begin)
5296 (setq gnus-newsgroup-begin number))
5297 (setq gnus-newsgroup-unselected
5298 (delq number gnus-newsgroup-unselected)))
5299 ;; Report back a success?
5300 (and header (mail-header-number header))))
5302 ;;; Process/prefix in the summary buffer
5304 (defun gnus-summary-work-articles (n)
5305 "Return a list of articles to be worked upon.
5306 The prefix argument, the list of process marked articles, and the
5307 current article will be taken into consideration."
5309 (set-buffer gnus-summary-buffer)
5312 ;; A numerical prefix has been given.
5313 (setq n (prefix-numeric-value n))
5314 (let ((backward (< n 0))
5315 (n (abs (prefix-numeric-value n)))
5320 (push (setq article (gnus-summary-article-number))
5323 (gnus-summary-find-prev nil article)
5324 (gnus-summary-find-next nil article)))
5326 (nreverse articles)))
5327 ((and (gnus-region-active-p) (mark))
5328 (message "region active")
5329 ;; Work on the region between point and mark.
5330 (let ((max (max (point) (mark)))
5333 (goto-char (min (point) (mark)))
5336 (push (setq article (gnus-summary-article-number)) articles)
5337 (gnus-summary-find-next nil article)
5339 (nreverse articles))))
5340 (gnus-newsgroup-processable
5341 ;; There are process-marked articles present.
5342 ;; Save current state.
5343 (gnus-summary-save-process-mark)
5345 (reverse gnus-newsgroup-processable))
5347 ;; Just return the current article.
5348 (list (gnus-summary-article-number))))))
5350 (defmacro gnus-summary-iterate (arg &rest forms)
5351 "Iterate over the process/prefixed articles and do FORMS.
5352 ARG is the interactive prefix given to the command. FORMS will be
5353 executed with point over the summary line of the articles."
5354 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5355 `(let ((,articles (gnus-summary-work-articles ,arg)))
5357 (gnus-summary-goto-subject (car ,articles))
5361 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5362 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5364 (defun gnus-summary-save-process-mark ()
5365 "Push the current set of process marked articles on the stack."
5367 (push (copy-sequence gnus-newsgroup-processable)
5368 gnus-newsgroup-process-stack))
5370 (defun gnus-summary-kill-process-mark ()
5371 "Push the current set of process marked articles on the stack and unmark."
5373 (gnus-summary-save-process-mark)
5374 (gnus-summary-unmark-all-processable))
5376 (defun gnus-summary-yank-process-mark ()
5377 "Pop the last process mark state off the stack and restore it."
5379 (unless gnus-newsgroup-process-stack
5380 (error "Empty mark stack"))
5381 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5383 (defun gnus-summary-process-mark-set (set)
5384 "Make SET into the current process marked articles."
5385 (gnus-summary-unmark-all-processable)
5387 (gnus-summary-set-process-mark (pop set))))
5389 ;;; Searching and stuff
5391 (defun gnus-summary-search-group (&optional backward use-level)
5392 "Search for next unread newsgroup.
5393 If optional argument BACKWARD is non-nil, search backward instead."
5395 (set-buffer gnus-group-buffer)
5396 (when (gnus-group-search-forward
5397 backward nil (if use-level (gnus-group-group-level) nil))
5398 (gnus-group-group-name))))
5400 (defun gnus-summary-best-group (&optional exclude-group)
5401 "Find the name of the best unread group.
5402 If EXCLUDE-GROUP, do not go to this group."
5404 (set-buffer gnus-group-buffer)
5406 (gnus-group-best-unread-group exclude-group))))
5408 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5409 (if backward (gnus-summary-find-prev)
5410 (let* ((dummy (gnus-summary-article-intangible-p))
5411 (article (or article (gnus-summary-article-number)))
5412 (arts (gnus-data-find-list article))
5414 (when (and (not dummy)
5415 (or (not gnus-summary-check-current)
5417 (not (gnus-data-unread-p (car arts)))))
5418 (setq arts (cdr arts)))
5423 (when (or (and undownloaded
5424 (eq gnus-undownloaded-mark
5425 (gnus-data-mark (car arts))))
5426 (gnus-data-unread-p (car arts)))
5427 (setq result (car arts)
5429 (setq arts (cdr arts)))
5432 (goto-char (gnus-data-pos result))
5433 (gnus-data-number result)))))
5435 (defun gnus-summary-find-prev (&optional unread article)
5436 (let* ((eobp (eobp))
5437 (article (or article (gnus-summary-article-number)))
5438 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5440 (when (and (not eobp)
5441 (or (not gnus-summary-check-current)
5443 (not (gnus-data-unread-p (car arts)))))
5444 (setq arts (cdr arts)))
5449 (when (gnus-data-unread-p (car arts))
5450 (setq result (car arts)
5452 (setq arts (cdr arts)))
5455 (goto-char (gnus-data-pos result))
5456 (gnus-data-number result))))
5458 (defun gnus-summary-find-subject (subject &optional unread backward article)
5459 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5460 (article (or article (gnus-summary-article-number)))
5461 (articles (gnus-data-list backward))
5462 (arts (gnus-data-find-list article articles))
5464 (when (or (not gnus-summary-check-current)
5466 (not (gnus-data-unread-p (car arts))))
5467 (setq arts (cdr arts)))
5469 (and (or (not unread)
5470 (gnus-data-unread-p (car arts)))
5471 (vectorp (gnus-data-header (car arts)))
5473 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5474 (setq result (car arts)
5476 (setq arts (cdr arts)))
5478 (goto-char (gnus-data-pos result))
5479 (gnus-data-number result))))
5481 (defun gnus-summary-search-forward (&optional unread subject backward)
5482 "Search forward for an article.
5483 If UNREAD, look for unread articles. If SUBJECT, look for
5484 articles with that subject. If BACKWARD, search backward instead."
5485 (cond (subject (gnus-summary-find-subject subject unread backward))
5486 (backward (gnus-summary-find-prev unread))
5487 (t (gnus-summary-find-next unread))))
5489 (defun gnus-recenter (&optional n)
5490 "Center point in window and redisplay frame.
5491 Also do horizontal recentering."
5493 (when (and gnus-auto-center-summary
5494 (not (eq gnus-auto-center-summary 'vertical)))
5495 (gnus-horizontal-recenter))
5498 (defun gnus-summary-recenter ()
5499 "Center point in the summary window.
5500 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5501 displayed, no centering will be performed."
5502 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5503 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5505 (let* ((top (cond ((< (window-height) 4) 0)
5506 ((< (window-height) 7) 1)
5507 (t (if (numberp gnus-auto-center-summary)
5508 gnus-auto-center-summary
5510 (height (1- (window-height)))
5511 (bottom (save-excursion (goto-char (point-max))
5512 (forward-line (- height))
5514 (window (get-buffer-window (current-buffer))))
5515 ;; The user has to want it.
5516 (when gnus-auto-center-summary
5517 (when (get-buffer-window gnus-article-buffer)
5518 ;; Only do recentering when the article buffer is displayed,
5519 ;; Set the window start to either `bottom', which is the biggest
5520 ;; possible valid number, or the second line from the top,
5521 ;; whichever is the least.
5522 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5523 (if (> bottom top-pos)
5524 ;; Keep the second line from the top visible
5525 (set-window-start window top-pos t)
5526 ;; Try to keep the bottom line visible; if it's partially
5527 ;; obscured, either scroll one more line to make it fully
5528 ;; visible, or revert to using TOP-POS.
5530 (goto-char (point-max))
5532 (let ((last-line-start (point)))
5534 (set-window-start window (point) t)
5535 (when (not (pos-visible-in-window-p last-line-start window))
5537 (set-window-start window (min (point) top-pos) t)))))))
5538 ;; Do horizontal recentering while we're at it.
5539 (when (and (get-buffer-window (current-buffer) t)
5540 (not (eq gnus-auto-center-summary 'vertical)))
5541 (let ((selected (selected-window)))
5542 (select-window (get-buffer-window (current-buffer) t))
5543 (gnus-summary-position-point)
5544 (gnus-horizontal-recenter)
5545 (select-window selected))))))
5547 (defun gnus-summary-jump-to-group (newsgroup)
5548 "Move point to NEWSGROUP in group mode buffer."
5549 ;; Keep update point of group mode buffer if visible.
5550 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5551 (save-window-excursion
5552 ;; Take care of tree window mode.
5553 (when (get-buffer-window gnus-group-buffer)
5554 (pop-to-buffer gnus-group-buffer))
5555 (gnus-group-jump-to-group newsgroup))
5557 ;; Take care of tree window mode.
5558 (if (get-buffer-window gnus-group-buffer)
5559 (pop-to-buffer gnus-group-buffer)
5560 (set-buffer gnus-group-buffer))
5561 (gnus-group-jump-to-group newsgroup))))
5563 ;; This function returns a list of article numbers based on the
5564 ;; difference between the ranges of read articles in this group and
5565 ;; the range of active articles.
5566 (defun gnus-list-of-unread-articles (group)
5567 (let* ((read (gnus-info-read (gnus-get-info group)))
5568 (active (or (gnus-active group) (gnus-activate-group group)))
5571 ;; If none are read, then all are unread.
5573 (setq first (car active))
5574 ;; If the range of read articles is a single range, then the
5575 ;; first unread article is the article after the last read
5576 ;; article. Sounds logical, doesn't it?
5577 (if (and (not (listp (cdr read)))
5578 (or (< (car read) (car active))
5579 (progn (setq read (list read))
5581 (setq first (max (car active) (1+ (cdr read))))
5582 ;; `read' is a list of ranges.
5583 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5586 (setq first (car active)))
5589 (while (< first nlast)
5591 (setq first (1+ first))))
5592 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5593 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5594 (setq read (cdr read)))))
5595 ;; And add the last unread articles.
5596 (while (<= first last)
5598 (setq first (1+ first)))
5599 ;; Return the list of unread articles.
5600 (delq 0 (nreverse unread))))
5602 (defun gnus-list-of-read-articles (group)
5603 "Return a list of unread, unticked and non-dormant articles."
5604 (let* ((info (gnus-get-info group))
5605 (marked (gnus-info-marks info))
5606 (active (gnus-active group)))
5608 (gnus-set-difference
5609 (gnus-sorted-complement
5610 (gnus-uncompress-range active)
5611 (gnus-list-of-unread-articles group))
5613 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5614 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5616 ;; Various summary commands
5618 (defun gnus-summary-select-article-buffer ()
5619 "Reconfigure windows to show article buffer."
5621 (if (not (gnus-buffer-live-p gnus-article-buffer))
5622 (error "There is no article buffer for this summary buffer")
5623 (gnus-configure-windows 'article)
5624 (select-window (get-buffer-window gnus-article-buffer))))
5626 (defun gnus-summary-universal-argument (arg)
5627 "Perform any operation on all articles that are process/prefixed."
5629 (let ((articles (gnus-summary-work-articles arg))
5636 (substitute-command-keys
5637 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5639 (gnus-error 1 "Undefined key")
5642 (gnus-summary-goto-subject (setq article (pop articles)))
5643 (let (gnus-newsgroup-processable)
5644 (command-execute func))
5645 (gnus-summary-remove-process-mark article)))))
5646 (gnus-summary-position-point))
5648 (defun gnus-summary-toggle-truncation (&optional arg)
5649 "Toggle truncation of summary lines.
5650 With arg, turn line truncation on iff arg is positive."
5652 (setq truncate-lines
5653 (if (null arg) (not truncate-lines)
5654 (> (prefix-numeric-value arg) 0)))
5657 (defun gnus-summary-reselect-current-group (&optional all rescan)
5658 "Exit and then reselect the current newsgroup.
5659 The prefix argument ALL means to select all articles."
5661 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5662 (error "Ephemeral groups can't be reselected"))
5663 (let ((current-subject (gnus-summary-article-number))
5664 (group gnus-newsgroup-name))
5665 (setq gnus-newsgroup-begin nil)
5667 ;; We have to adjust the point of group mode buffer because
5668 ;; point was moved to the next unread newsgroup by exiting.
5669 (gnus-summary-jump-to-group group)
5672 (save-window-excursion
5673 ;; Don't show group contents.
5674 (set-window-start (selected-window) (point-max))
5675 (gnus-group-get-new-news-this-group 1))))
5676 (gnus-group-read-group all t)
5677 (gnus-summary-goto-subject current-subject nil t)))
5679 (defun gnus-summary-rescan-group (&optional all)
5680 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5682 (gnus-summary-reselect-current-group all t))
5684 (defun gnus-summary-update-info (&optional non-destructive)
5686 (let ((group gnus-newsgroup-name))
5688 (when gnus-newsgroup-kill-headers
5689 (setq gnus-newsgroup-killed
5690 (gnus-compress-sequence
5692 (gnus-set-sorted-intersection
5693 (gnus-uncompress-range gnus-newsgroup-killed)
5694 (setq gnus-newsgroup-unselected
5695 (sort gnus-newsgroup-unselected '<)))
5696 (setq gnus-newsgroup-unreads
5697 (sort gnus-newsgroup-unreads '<)))
5699 (unless (listp (cdr gnus-newsgroup-killed))
5700 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5701 (let ((headers gnus-newsgroup-headers))
5702 ;; Set the new ranges of read articles.
5704 (set-buffer gnus-group-buffer)
5705 (gnus-undo-force-boundary))
5706 (gnus-update-read-articles
5707 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5708 ;; Set the current article marks.
5709 (let ((gnus-newsgroup-scored
5710 (if (and (not gnus-save-score)
5711 (not non-destructive))
5713 gnus-newsgroup-scored)))
5715 (gnus-update-marks)))
5716 ;; Do the cross-ref thing.
5717 (when gnus-use-cross-reference
5718 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5719 ;; Do not switch windows but change the buffer to work.
5720 (set-buffer gnus-group-buffer)
5721 (unless (gnus-ephemeral-group-p group)
5722 (gnus-group-update-group group)))))))
5724 (defun gnus-summary-save-newsrc (&optional force)
5725 "Save the current number of read/marked articles in the dribble buffer.
5726 The dribble buffer will then be saved.
5727 If FORCE (the prefix), also save the .newsrc file(s)."
5729 (gnus-summary-update-info t)
5731 (gnus-save-newsrc-file)
5732 (gnus-dribble-save)))
5734 (defun gnus-summary-exit (&optional temporary)
5735 "Exit reading current newsgroup, and then return to group selection mode.
5736 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5738 (gnus-set-global-variables)
5739 (gnus-kill-save-kill-buffer)
5740 (gnus-async-halt-prefetch)
5741 (let* ((group gnus-newsgroup-name)
5742 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5745 (buf (current-buffer)))
5747 ;; Do adaptive scoring, and possibly save score files.
5748 (when gnus-newsgroup-adaptive
5749 (gnus-score-adaptive))
5750 (when gnus-use-scoring
5752 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5753 ;; If we have several article buffers, we kill them at exit.
5754 (unless gnus-single-article-buffer
5755 (gnus-kill-buffer gnus-original-article-buffer)
5756 (setq gnus-article-current nil))
5757 (when gnus-use-cache
5758 (gnus-cache-possibly-remove-articles)
5759 (gnus-cache-save-buffers))
5760 (gnus-async-prefetch-remove-group group)
5761 (when gnus-suppress-duplicates
5762 (gnus-dup-enter-articles))
5763 (when gnus-use-trees
5764 (gnus-tree-close group))
5765 (when gnus-use-cache
5766 (gnus-cache-write-active))
5767 ;; Remove entries for this group.
5768 (nnmail-purge-split-history (gnus-group-real-name group))
5769 ;; Make all changes in this group permanent.
5771 (gnus-run-hooks 'gnus-exit-group-hook)
5772 (gnus-summary-update-info))
5773 (gnus-close-group group)
5774 ;; Make sure where we were, and go to next newsgroup.
5775 (set-buffer gnus-group-buffer)
5777 (gnus-group-jump-to-group group))
5778 (gnus-run-hooks 'gnus-summary-exit-hook)
5779 (unless (or quit-config
5780 ;; If this group has disappeared from the summary
5781 ;; buffer, don't skip forwards.
5782 (not (string= group (gnus-group-group-name))))
5783 (gnus-group-next-unread-group 1))
5784 (setq group-point (point))
5787 ;; If we have several article buffers, we kill them at exit.
5788 (unless gnus-single-article-buffer
5789 (gnus-kill-buffer gnus-article-buffer)
5790 (gnus-kill-buffer gnus-original-article-buffer)
5791 (setq gnus-article-current nil))
5793 (if (not gnus-kill-summary-on-exit)
5795 (gnus-deaden-summary)
5797 ;; We set all buffer-local variables to nil. It is unclear why
5798 ;; this is needed, but if we don't, buffer-local variables are
5799 ;; not garbage-collected, it seems. This would the lead to en
5800 ;; ever-growing Emacs.
5801 (gnus-summary-clear-local-variables)
5802 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5803 (gnus-summary-clear-local-variables))
5804 (when (get-buffer gnus-article-buffer)
5805 (bury-buffer gnus-article-buffer))
5806 ;; We clear the global counterparts of the buffer-local
5807 ;; variables as well, just to be on the safe side.
5808 (set-buffer gnus-group-buffer)
5809 (gnus-summary-clear-local-variables)
5810 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5811 (gnus-summary-clear-local-variables)))
5812 (setq gnus-current-select-method gnus-select-method)
5813 (pop-to-buffer gnus-group-buffer)
5814 (if (not quit-config)
5816 (goto-char group-point)
5817 (gnus-configure-windows 'group 'force)
5818 (unless (pos-visible-in-window-p)
5819 (forward-line (/ (static-if (featurep 'xemacs)
5820 (window-displayed-height)
5821 (1- (window-height)))
5823 (set-window-start (selected-window) (point))
5824 (goto-char group-point)))
5825 (gnus-handle-ephemeral-exit quit-config))
5826 ;; Return to group mode buffer.
5827 (when (eq mode 'gnus-summary-mode)
5828 (gnus-kill-buffer buf))
5829 ;; Clear the current group name.
5831 (setq gnus-newsgroup-name nil)))))
5833 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5834 (defun gnus-summary-exit-no-update (&optional no-questions)
5835 "Quit reading current newsgroup without updating read article info."
5837 (let* ((group gnus-newsgroup-name)
5838 (quit-config (gnus-group-quit-config group)))
5839 (when (or no-questions
5841 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5842 (gnus-async-halt-prefetch)
5844 (delq 'gnus-summary-expire-articles
5845 (copy-sequence gnus-summary-prepare-exit-hook)))
5846 ;; If we have several article buffers, we kill them at exit.
5847 (unless gnus-single-article-buffer
5848 (gnus-kill-buffer gnus-article-buffer)
5849 (gnus-kill-buffer gnus-original-article-buffer)
5850 (setq gnus-article-current nil))
5851 (if (not gnus-kill-summary-on-exit)
5852 (gnus-deaden-summary)
5853 (gnus-close-group group)
5854 (gnus-summary-clear-local-variables)
5855 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5856 (gnus-summary-clear-local-variables))
5857 (set-buffer gnus-group-buffer)
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-summary-buffer)
5862 (kill-buffer gnus-summary-buffer)))
5863 (unless gnus-single-article-buffer
5864 (setq gnus-article-current nil))
5865 (when gnus-use-trees
5866 (gnus-tree-close group))
5867 (gnus-async-prefetch-remove-group group)
5868 (when (get-buffer gnus-article-buffer)
5869 (bury-buffer gnus-article-buffer))
5870 ;; Return to the group buffer.
5871 (gnus-configure-windows 'group 'force)
5872 ;; Clear the current group name.
5873 (setq gnus-newsgroup-name nil)
5874 (when (equal (gnus-group-group-name) group)
5875 (gnus-group-next-unread-group 1))
5877 (gnus-handle-ephemeral-exit quit-config)))))
5879 (defun gnus-handle-ephemeral-exit (quit-config)
5880 "Handle movement when leaving an ephemeral group.
5881 The state which existed when entering the ephemeral is reset."
5882 (if (not (buffer-name (car quit-config)))
5883 (gnus-configure-windows 'group 'force)
5884 (set-buffer (car quit-config))
5885 (cond ((eq major-mode 'gnus-summary-mode)
5886 (gnus-set-global-variables))
5887 ((eq major-mode 'gnus-article-mode)
5889 ;; The `gnus-summary-buffer' variable may point
5890 ;; to the old summary buffer when using a single
5892 (unless (gnus-buffer-live-p gnus-summary-buffer)
5893 (set-buffer gnus-group-buffer))
5894 (set-buffer gnus-summary-buffer)
5895 (gnus-set-global-variables))))
5896 (if (or (eq (cdr quit-config) 'article)
5897 (eq (cdr quit-config) 'pick))
5899 ;; The current article may be from the ephemeral group
5900 ;; thus it is best that we reload this article
5901 (gnus-summary-show-article)
5902 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5903 (gnus-configure-windows 'pick 'force)
5904 (gnus-configure-windows (cdr quit-config) 'force)))
5905 (gnus-configure-windows (cdr quit-config) 'force))
5906 (when (eq major-mode 'gnus-summary-mode)
5907 (gnus-summary-next-subject 1 nil t)
5908 (gnus-summary-recenter)
5909 (gnus-summary-position-point))))
5911 (defun gnus-summary-preview-mime-message ()
5912 "MIME decode and play this message."
5914 (let ((gnus-break-pages nil)
5916 (gnus-summary-select-article gnus-show-all-headers t))
5917 (select-window (get-buffer-window gnus-article-buffer)))
5921 (defvar gnus-dead-summary-mode-map nil)
5923 (unless gnus-dead-summary-mode-map
5924 (setq gnus-dead-summary-mode-map (make-keymap))
5925 (suppress-keymap gnus-dead-summary-mode-map)
5926 (substitute-key-definition
5927 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5928 (let ((keys '("\C-d" "\r" "\177" [delete])))
5930 (define-key gnus-dead-summary-mode-map
5931 (pop keys) 'gnus-summary-wake-up-the-dead))))
5933 (defvar gnus-dead-summary-mode nil
5934 "Minor mode for Gnus summary buffers.")
5936 (defun gnus-dead-summary-mode (&optional arg)
5937 "Minor mode for Gnus summary buffers."
5939 (when (eq major-mode 'gnus-summary-mode)
5940 (make-local-variable 'gnus-dead-summary-mode)
5941 (setq gnus-dead-summary-mode
5942 (if (null arg) (not gnus-dead-summary-mode)
5943 (> (prefix-numeric-value arg) 0)))
5944 (when gnus-dead-summary-mode
5945 (gnus-add-minor-mode
5946 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5948 (defun gnus-deaden-summary ()
5949 "Make the current summary buffer into a dead summary buffer."
5950 ;; Kill any previous dead summary buffer.
5951 (when (and gnus-dead-summary
5952 (buffer-name gnus-dead-summary))
5954 (set-buffer gnus-dead-summary)
5955 (when gnus-dead-summary-mode
5956 (kill-buffer (current-buffer)))))
5957 ;; Make this the current dead summary.
5958 (setq gnus-dead-summary (current-buffer))
5959 (gnus-dead-summary-mode 1)
5960 (let ((name (buffer-name)))
5961 (when (string-match "Summary" name)
5963 (concat (substring name 0 (match-beginning 0)) "Dead "
5964 (substring name (match-beginning 0)))
5968 (defun gnus-kill-or-deaden-summary (buffer)
5969 "Kill or deaden the summary BUFFER."
5971 (when (and (buffer-name buffer)
5972 (not gnus-single-article-buffer))
5975 (gnus-kill-buffer gnus-article-buffer)
5976 (gnus-kill-buffer gnus-original-article-buffer)))
5977 (cond (gnus-kill-summary-on-exit
5978 (when (and gnus-use-trees
5979 (gnus-buffer-exists-p buffer))
5982 (gnus-tree-close gnus-newsgroup-name)))
5983 (gnus-kill-buffer buffer))
5984 ((gnus-buffer-exists-p buffer)
5987 (gnus-deaden-summary))))))
5989 (defun gnus-summary-wake-up-the-dead (&rest args)
5990 "Wake up the dead summary buffer."
5992 (gnus-dead-summary-mode -1)
5993 (let ((name (buffer-name)))
5994 (when (string-match "Dead " name)
5996 (concat (substring name 0 (match-beginning 0))
5997 (substring name (match-end 0)))
5999 (gnus-message 3 "This dead summary is now alive again"))
6001 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6002 (defun gnus-summary-fetch-faq (&optional faq-dir)
6003 "Fetch the FAQ for the current group.
6004 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6008 (when current-prefix-arg
6010 "Faq dir: " (and (listp gnus-group-faq-directory)
6011 (mapcar (lambda (file) (list file))
6012 gnus-group-faq-directory))))))
6013 (let (gnus-faq-buffer)
6014 (when (setq gnus-faq-buffer
6015 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6016 (gnus-configure-windows 'summary-faq))))
6018 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6019 (defun gnus-summary-describe-group (&optional force)
6020 "Describe the current newsgroup."
6022 (gnus-group-describe-group force gnus-newsgroup-name))
6024 (defun gnus-summary-describe-briefly ()
6025 "Describe summary mode commands briefly."
6027 (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")))
6029 ;; Walking around group mode buffer from summary mode.
6031 (defun gnus-summary-next-group (&optional no-article target-group backward)
6032 "Exit current newsgroup and then select next unread newsgroup.
6033 If prefix argument NO-ARTICLE is non-nil, no article is selected
6034 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6035 previous group instead."
6037 ;; Stop pre-fetching.
6038 (gnus-async-halt-prefetch)
6039 (let ((current-group gnus-newsgroup-name)
6040 (current-buffer (current-buffer))
6042 ;; First we semi-exit this group to update Xrefs and all variables.
6043 ;; We can't do a real exit, because the window conf must remain
6044 ;; the same in case the user is prompted for info, and we don't
6045 ;; want the window conf to change before that...
6046 (gnus-summary-exit t)
6047 (while (not entered)
6048 ;; Then we find what group we are supposed to enter.
6049 (set-buffer gnus-group-buffer)
6050 (gnus-group-jump-to-group current-group)
6053 (if (eq gnus-keep-same-level 'best)
6054 (gnus-summary-best-group gnus-newsgroup-name)
6055 (gnus-summary-search-group backward gnus-keep-same-level))))
6056 (if (not target-group)
6057 ;; There are no further groups, so we return to the group
6060 (gnus-message 5 "Returning to the group buffer")
6062 (when (gnus-buffer-live-p current-buffer)
6063 (set-buffer current-buffer)
6064 (gnus-summary-exit))
6065 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6066 ;; We try to enter the target group.
6067 (gnus-group-jump-to-group target-group)
6068 (let ((unreads (gnus-group-group-unread)))
6069 (if (and (or (eq t unreads)
6070 (and unreads (not (zerop unreads))))
6071 (gnus-summary-read-group
6072 target-group nil no-article
6073 (and (buffer-name current-buffer) current-buffer)
6076 (setq current-group target-group
6077 target-group nil)))))))
6079 (defun gnus-summary-prev-group (&optional no-article)
6080 "Exit current newsgroup and then select previous unread newsgroup.
6081 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6083 (gnus-summary-next-group no-article nil t))
6085 ;; Walking around summary lines.
6087 (defun gnus-summary-first-subject (&optional unread undownloaded)
6088 "Go to the first unread subject.
6089 If UNREAD is non-nil, go to the first unread article.
6090 Returns the article selected or nil if there are no unread articles."
6095 ((null gnus-newsgroup-data)
6096 (gnus-message 3 "No articles in the group")
6098 ;; Pick the first article.
6100 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6101 (gnus-data-number (car gnus-newsgroup-data)))
6102 ;; No unread articles.
6103 ((null gnus-newsgroup-unreads)
6104 (gnus-message 3 "No more unread articles")
6106 ;; Find the first unread article.
6108 (let ((data gnus-newsgroup-data))
6110 (and (not (and undownloaded
6111 (eq gnus-undownloaded-mark
6112 (gnus-data-mark (car data)))))
6113 (not (gnus-data-unread-p (car data)))))
6114 (setq data (cdr data)))
6116 (goto-char (gnus-data-pos (car data)))
6117 (gnus-data-number (car data))))))
6118 (gnus-summary-position-point)))
6120 (defun gnus-summary-next-subject (n &optional unread dont-display)
6121 "Go to next N'th summary line.
6122 If N is negative, go to the previous N'th subject line.
6123 If UNREAD is non-nil, only unread articles are selected.
6124 The difference between N and the actual number of steps taken is
6127 (let ((backward (< n 0))
6131 (gnus-summary-find-prev unread)
6132 (gnus-summary-find-next unread)))
6133 (unless (zerop (setq n (1- n)))
6134 (gnus-summary-show-thread)))
6136 (gnus-message 7 "No more%s articles"
6137 (if unread " unread" "")))
6138 (unless dont-display
6139 (gnus-summary-recenter)
6140 (gnus-summary-position-point))
6143 (defun gnus-summary-next-unread-subject (n)
6144 "Go to next N'th unread summary line."
6146 (gnus-summary-next-subject n t))
6148 (defun gnus-summary-prev-subject (n &optional unread)
6149 "Go to previous N'th summary line.
6150 If optional argument UNREAD is non-nil, only unread article is selected."
6152 (gnus-summary-next-subject (- n) unread))
6154 (defun gnus-summary-prev-unread-subject (n)
6155 "Go to previous N'th unread summary line."
6157 (gnus-summary-next-subject (- n) t))
6159 (defun gnus-summary-goto-subject (article &optional force silent)
6160 "Go the subject line of ARTICLE.
6161 If FORCE, also allow jumping to articles not currently shown."
6162 (interactive "nArticle number: ")
6164 (data (gnus-data-find article)))
6165 ;; We read in the article if we have to.
6168 (gnus-summary-insert-subject
6170 (if (or (numberp force) (vectorp force)) force)
6172 (setq data (gnus-data-find article)))
6177 (gnus-message 3 "Can't find article %d" article))
6179 (goto-char (gnus-data-pos data))
6180 (gnus-summary-position-point)
6183 ;; Walking around summary lines with displaying articles.
6185 (defun gnus-summary-expand-window (&optional arg)
6186 "Make the summary buffer take up the entire Emacs frame.
6187 Given a prefix, will force an `article' buffer configuration."
6190 (gnus-configure-windows 'article 'force)
6191 (gnus-configure-windows 'summary 'force)))
6193 (defun gnus-summary-display-article (article &optional all-header)
6194 "Display ARTICLE in article buffer."
6195 (when (gnus-buffer-live-p gnus-article-buffer)
6196 (with-current-buffer gnus-article-buffer
6197 (set-buffer-multibyte t)))
6198 (gnus-set-global-variables)
6199 (when (gnus-buffer-live-p gnus-article-buffer)
6200 (with-current-buffer gnus-article-buffer
6201 (setq gnus-article-charset gnus-newsgroup-charset)
6202 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6206 (if gnus-summary-display-article-function
6207 (funcall gnus-summary-display-article-function article all-header)
6208 (gnus-article-prepare article all-header))
6209 (with-current-buffer gnus-article-buffer
6210 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6212 (gnus-run-hooks 'gnus-select-article-hook)
6213 (when (and gnus-current-article
6214 (not (zerop gnus-current-article)))
6215 (gnus-summary-goto-subject gnus-current-article))
6216 (gnus-summary-recenter)
6217 (when (and gnus-use-trees gnus-show-threads)
6218 (gnus-possibly-generate-tree article)
6219 (gnus-highlight-selected-tree article))
6220 ;; Successfully display article.
6221 (gnus-article-set-window-start
6222 (cdr (assq article gnus-newsgroup-bookmarks))))))
6224 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6225 "Select the current article.
6226 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6227 non-nil, the article will be re-fetched even if it already present in
6228 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6230 ;; Make sure we are in the summary buffer to work around bbdb bug.
6231 (unless (eq major-mode 'gnus-summary-mode)
6232 (set-buffer gnus-summary-buffer))
6233 (let ((article (or article (gnus-summary-article-number)))
6234 (all-headers (not (not all-headers))) ;Must be T or NIL.
6235 gnus-summary-display-article-function)
6237 (gnus-summary-article-pseudo-p article)
6238 (error "This is a pseudo-article"))
6240 (set-buffer gnus-summary-buffer)
6241 (if (or (and gnus-single-article-buffer
6242 (or (null gnus-current-article)
6243 (null gnus-article-current)
6244 (null (get-buffer gnus-article-buffer))
6245 (not (eq article (cdr gnus-article-current)))
6246 (not (equal (car gnus-article-current)
6247 gnus-newsgroup-name))))
6248 (and (not gnus-single-article-buffer)
6249 (or (null gnus-current-article)
6250 (not (eq gnus-current-article article))))
6252 ;; The requested article is different from the current article.
6254 (gnus-summary-display-article article all-headers)
6255 (when (or all-headers gnus-show-all-headers)
6256 (gnus-article-show-all-headers))
6257 (gnus-article-set-window-start
6258 (cdr (assq article gnus-newsgroup-bookmarks)))
6260 (when (or all-headers gnus-show-all-headers)
6261 (gnus-article-show-all-headers))
6264 (defun gnus-summary-force-verify-and-decrypt ()
6266 (let ((mm-verify-option 'known)
6267 (mm-decrypt-option 'known))
6268 (gnus-summary-select-article nil 'force)))
6270 (defun gnus-summary-set-current-mark (&optional current-mark)
6271 "Obsolete function."
6274 (defun gnus-summary-next-article (&optional unread subject backward push)
6275 "Select the next article.
6276 If UNREAD, only unread articles are selected.
6277 If SUBJECT, only articles with SUBJECT are selected.
6278 If BACKWARD, the previous article is selected instead of the next."
6281 ;; Is there such an article?
6282 ((and (gnus-summary-search-forward unread subject backward)
6283 (or (gnus-summary-display-article (gnus-summary-article-number))
6284 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6285 (gnus-summary-position-point))
6286 ;; If not, we try the first unread, if that is wanted.
6288 gnus-auto-select-same
6289 (gnus-summary-first-unread-article))
6290 (gnus-summary-position-point)
6291 (gnus-message 6 "Wrapped"))
6292 ;; Try to get next/previous article not displayed in this group.
6293 ((and gnus-auto-extend-newsgroup
6294 (not unread) (not subject))
6295 (gnus-summary-goto-article
6296 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6297 nil (count-lines (point-min) (point))))
6298 ;; Go to next/previous group.
6300 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6301 (gnus-summary-jump-to-group gnus-newsgroup-name))
6302 (let ((cmd last-command-char)
6305 (set-buffer gnus-group-buffer)
6308 (if (eq gnus-keep-same-level 'best)
6309 (gnus-summary-best-group gnus-newsgroup-name)
6310 (gnus-summary-search-group backward gnus-keep-same-level))))
6311 ;; For some reason, the group window gets selected. We change
6313 (select-window (get-buffer-window (current-buffer)))
6314 ;; Select next unread newsgroup automagically.
6316 ((or (not gnus-auto-select-next)
6318 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6319 ((or (eq gnus-auto-select-next 'quietly)
6320 (and (eq gnus-auto-select-next 'slightly-quietly)
6322 (and (eq gnus-auto-select-next 'almost-quietly)
6323 (gnus-summary-last-article-p)))
6325 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6327 (gnus-message 7 "No more%s articles (%s)..."
6328 (if unread " unread" "")
6329 (if group (concat "selecting " group)
6331 (gnus-summary-next-group nil group backward)))
6333 (when (gnus-key-press-event-p last-input-event)
6334 (gnus-summary-walk-group-buffer
6335 gnus-newsgroup-name cmd unread backward point))))))))
6337 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6338 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6339 (?\C-p (gnus-group-prev-unread-group 1))))
6340 (cursor-in-echo-area t)
6341 keve key group ended)
6343 (set-buffer gnus-group-buffer)
6346 (if (eq gnus-keep-same-level 'best)
6347 (gnus-summary-best-group gnus-newsgroup-name)
6348 (gnus-summary-search-group backward gnus-keep-same-level))))
6351 5 "No more%s articles%s" (if unread " unread" "")
6353 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6354 (format " (Type %s for %s [%s])"
6355 (single-key-description cmd) group
6356 (car (gnus-gethash group gnus-newsrc-hashtb)))
6357 (format " (Type %s to exit %s)"
6358 (single-key-description cmd)
6359 gnus-newsgroup-name)))
6360 ;; Confirm auto selection.
6361 (setq key (car (setq keve (gnus-read-event-char))))
6364 ((assq key keystrokes)
6365 (let ((obuf (current-buffer)))
6366 (switch-to-buffer gnus-group-buffer)
6368 (gnus-group-jump-to-group group))
6369 (eval (cadr (assq key keystrokes)))
6370 (setq group (gnus-group-group-name))
6371 (switch-to-buffer obuf))
6375 (gnus-ephemeral-group-p gnus-newsgroup-name))
6377 (gnus-summary-next-group nil group backward)))
6379 (push (cdr keve) unread-command-events))))))
6381 (defun gnus-summary-next-unread-article ()
6382 "Select unread article after current one."
6384 (gnus-summary-next-article
6385 (or (not (eq gnus-summary-goto-unread 'never))
6386 (gnus-summary-last-article-p (gnus-summary-article-number)))
6387 (and gnus-auto-select-same
6388 (gnus-summary-article-subject))))
6390 (defun gnus-summary-prev-article (&optional unread subject)
6391 "Select the article after the current one.
6392 If UNREAD is non-nil, only unread articles are selected."
6394 (gnus-summary-next-article unread subject t))
6396 (defun gnus-summary-prev-unread-article ()
6397 "Select unread article before current one."
6399 (gnus-summary-prev-article
6400 (or (not (eq gnus-summary-goto-unread 'never))
6401 (gnus-summary-first-article-p (gnus-summary-article-number)))
6402 (and gnus-auto-select-same
6403 (gnus-summary-article-subject))))
6405 (defun gnus-summary-next-page (&optional lines circular)
6406 "Show next page of the selected article.
6407 If at the end of the current article, select the next article.
6408 LINES says how many lines should be scrolled up.
6410 If CIRCULAR is non-nil, go to the start of the article instead of
6411 selecting the next article when reaching the end of the current
6414 (setq gnus-summary-buffer (current-buffer))
6415 (gnus-set-global-variables)
6416 (let ((article (gnus-summary-article-number))
6417 (article-window (get-buffer-window gnus-article-buffer t))
6419 ;; If the buffer is empty, we have no article.
6421 (error "No article to select"))
6422 (gnus-configure-windows 'article)
6423 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6424 (if (and (eq gnus-summary-goto-unread 'never)
6425 (not (gnus-summary-last-article-p article)))
6426 (gnus-summary-next-article)
6427 (gnus-summary-next-unread-article))
6428 (if (or (null gnus-current-article)
6429 (null gnus-article-current)
6430 (/= article (cdr gnus-article-current))
6431 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6432 ;; Selected subject is different from current article's.
6433 (gnus-summary-display-article article)
6434 (when article-window
6435 (gnus-eval-in-buffer-window gnus-article-buffer
6436 (setq endp (gnus-article-next-page lines)))
6439 (gnus-summary-beginning-of-article))
6441 (gnus-message 3 "End of message"))
6443 (if (and (eq gnus-summary-goto-unread 'never)
6444 (not (gnus-summary-last-article-p article)))
6445 (gnus-summary-next-article)
6446 (gnus-summary-next-unread-article))))))))
6447 (gnus-summary-recenter)
6448 (gnus-summary-position-point)))
6450 (defun gnus-summary-prev-page (&optional lines move)
6451 "Show previous page of selected article.
6452 Argument LINES specifies lines to be scrolled down.
6453 If MOVE, move to the previous unread article if point is at
6454 the beginning of the buffer."
6456 (let ((article (gnus-summary-article-number))
6457 (article-window (get-buffer-window gnus-article-buffer t))
6459 (gnus-configure-windows 'article)
6460 (if (or (null gnus-current-article)
6461 (null gnus-article-current)
6462 (/= article (cdr gnus-article-current))
6463 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6464 ;; Selected subject is different from current article's.
6465 (gnus-summary-display-article article)
6466 (gnus-summary-recenter)
6467 (when article-window
6468 (gnus-eval-in-buffer-window gnus-article-buffer
6469 (setq endp (gnus-article-prev-page lines)))
6470 (when (and move endp)
6472 (gnus-message 3 "Beginning of message"))
6474 (if (and (eq gnus-summary-goto-unread 'never)
6475 (not (gnus-summary-first-article-p article)))
6476 (gnus-summary-prev-article)
6477 (gnus-summary-prev-unread-article))))))))
6478 (gnus-summary-position-point))
6480 (defun gnus-summary-prev-page-or-article (&optional lines)
6481 "Show previous page of selected article.
6482 Argument LINES specifies lines to be scrolled down.
6483 If at the beginning of the article, go to the next article."
6485 (gnus-summary-prev-page lines t))
6487 (defun gnus-summary-scroll-up (lines)
6488 "Scroll up (or down) one line current article.
6489 Argument LINES specifies lines to be scrolled up (or down if negative)."
6491 (gnus-configure-windows 'article)
6492 (gnus-summary-show-thread)
6493 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6494 (gnus-eval-in-buffer-window gnus-article-buffer
6496 (when (gnus-article-next-page lines)
6497 (gnus-message 3 "End of message")))
6499 (gnus-article-prev-page (- lines))))))
6500 (gnus-summary-recenter)
6501 (gnus-summary-position-point))
6503 (defun gnus-summary-scroll-down (lines)
6504 "Scroll down (or up) one line current article.
6505 Argument LINES specifies lines to be scrolled down (or up if negative)."
6507 (gnus-summary-scroll-up (- lines)))
6509 (defun gnus-summary-next-same-subject ()
6510 "Select next article which has the same subject as current one."
6512 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6514 (defun gnus-summary-prev-same-subject ()
6515 "Select previous article which has the same subject as current one."
6517 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6519 (defun gnus-summary-next-unread-same-subject ()
6520 "Select next unread article which has the same subject as current one."
6522 (gnus-summary-next-article t (gnus-summary-article-subject)))
6524 (defun gnus-summary-prev-unread-same-subject ()
6525 "Select previous unread article which has the same subject as current one."
6527 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6529 (defun gnus-summary-first-unread-article ()
6530 "Select the first unread article.
6531 Return nil if there are no unread articles."
6534 (when (gnus-summary-first-subject t)
6535 (gnus-summary-show-thread)
6536 (gnus-summary-first-subject t)
6537 (gnus-summary-display-article (gnus-summary-article-number)))
6538 (gnus-summary-position-point)))
6540 (defun gnus-summary-first-unread-subject ()
6541 "Place the point on the subject line of the first unread article.
6542 Return nil if there are no unread articles."
6545 (when (gnus-summary-first-subject t)
6546 (gnus-summary-show-thread)
6547 (gnus-summary-first-subject t))
6548 (gnus-summary-position-point)))
6550 (defun gnus-summary-first-article ()
6551 "Select the first article.
6552 Return nil if there are no articles."
6555 (when (gnus-summary-first-subject)
6556 (gnus-summary-show-thread)
6557 (gnus-summary-first-subject)
6558 (gnus-summary-display-article (gnus-summary-article-number)))
6559 (gnus-summary-position-point)))
6561 (defun gnus-summary-best-unread-article ()
6562 "Select the unread article with the highest score."
6564 (let ((best -1000000)
6565 (data gnus-newsgroup-data)
6568 (and (gnus-data-unread-p (car data))
6570 (gnus-summary-article-score (gnus-data-number (car data))))
6573 article (gnus-data-number (car data))))
6574 (setq data (cdr data)))
6577 (gnus-summary-goto-article article)
6578 (error "No unread articles"))
6579 (gnus-summary-position-point))))
6581 (defun gnus-summary-last-subject ()
6582 "Go to the last displayed subject line in the group."
6583 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6585 (gnus-summary-goto-subject article))))
6587 (defun gnus-summary-goto-article (article &optional all-headers force)
6588 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6589 If ALL-HEADERS is non-nil, no header lines are hidden.
6590 If FORCE, go to the article even if it isn't displayed. If FORCE
6591 is a number, it is the line the article is to be displayed on."
6595 "Article number or Message-ID: "
6596 (mapcar (lambda (number) (list (int-to-string number)))
6597 gnus-newsgroup-limit))
6601 (if (and (stringp article)
6602 (string-match "@" article))
6603 (gnus-summary-refer-article article)
6604 (when (stringp article)
6605 (setq article (string-to-number article)))
6606 (if (gnus-summary-goto-subject article force)
6607 (gnus-summary-display-article article all-headers)
6608 (gnus-message 4 "Couldn't go to article %s" article) nil))
6609 (gnus-summary-position-point)))
6611 (defun gnus-summary-goto-last-article ()
6612 "Go to the previously read article."
6615 (when gnus-last-article
6616 (gnus-summary-goto-article gnus-last-article nil t))
6617 (gnus-summary-position-point)))
6619 (defun gnus-summary-pop-article (number)
6620 "Pop one article off the history and go to the previous.
6621 NUMBER articles will be popped off."
6624 (setq gnus-newsgroup-history
6625 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6627 (gnus-summary-goto-article (car to) nil t)
6628 (error "Article history empty")))
6629 (gnus-summary-position-point))
6631 ;; Summary commands and functions for limiting the summary buffer.
6633 (defun gnus-summary-limit-to-articles (n)
6634 "Limit the summary buffer to the next N articles.
6635 If not given a prefix, use the process marked articles instead."
6638 (let ((articles (gnus-summary-work-articles n)))
6639 (setq gnus-newsgroup-processable nil)
6640 (gnus-summary-limit articles))
6641 (gnus-summary-position-point)))
6643 (defun gnus-summary-pop-limit (&optional total)
6644 "Restore the previous limit.
6645 If given a prefix, remove all limits."
6648 (setq gnus-newsgroup-limits
6649 (list (mapcar (lambda (h) (mail-header-number h))
6650 gnus-newsgroup-headers))))
6651 (unless gnus-newsgroup-limits
6652 (error "No limit to pop"))
6654 (gnus-summary-limit nil 'pop)
6655 (gnus-summary-position-point)))
6657 (defun gnus-summary-limit-to-subject (subject &optional header)
6658 "Limit the summary buffer to articles that have subjects that match a regexp."
6659 (interactive "sLimit to subject (regexp): ")
6661 (setq header "subject"))
6662 (when (not (equal "" subject))
6664 (let ((articles (gnus-summary-find-matching
6665 (or header "subject") subject 'all)))
6667 (error "Found no matches for \"%s\"" subject))
6668 (gnus-summary-limit articles))
6669 (gnus-summary-position-point))))
6671 (defun gnus-summary-limit-to-author (from)
6672 "Limit the summary buffer to articles that have authors that match a regexp."
6673 (interactive "sLimit to author (regexp): ")
6674 (gnus-summary-limit-to-subject from "from"))
6676 (defun gnus-summary-limit-to-age (age &optional younger-p)
6677 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6678 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6679 articles that are younger than AGE days."
6681 (let ((younger current-prefix-arg)
6684 (while (not days-got)
6685 (setq days (if younger
6686 (read-string "Limit to articles within (in days): ")
6687 (read-string "Limit to articles older than (in days): ")))
6688 (when (> (length days) 0)
6689 (setq days (read days)))
6692 (message "Please enter a number.")
6694 (list days younger)))
6696 (let ((data gnus-newsgroup-data)
6697 (cutoff (days-to-time age))
6698 articles d date is-younger)
6699 (while (setq d (pop data))
6700 (when (and (vectorp (gnus-data-header d))
6701 (setq date (mail-header-date (gnus-data-header d))))
6702 (setq is-younger (time-less-p
6703 (time-since (condition-case ()
6710 (push (gnus-data-number d) articles))))
6711 (gnus-summary-limit (nreverse articles)))
6712 (gnus-summary-position-point)))
6714 (defun gnus-summary-limit-to-extra (header regexp)
6715 "Limit the summary buffer to articles that match an 'extra' header."
6719 (gnus-completing-read
6720 (symbol-name (car gnus-extra-headers))
6721 "Limit extra header:"
6723 (cons (symbol-name x) x))
6728 (read-string (format "Limit to header %s (regexp): " header)))))
6729 (when (not (equal "" regexp))
6731 (let ((articles (gnus-summary-find-matching
6732 (cons 'extra header) regexp 'all)))
6734 (error "Found no matches for \"%s\"" regexp))
6735 (gnus-summary-limit articles))
6736 (gnus-summary-position-point))))
6738 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6740 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6742 (defun gnus-summary-limit-to-unread (&optional all)
6743 "Limit the summary buffer to articles that are not marked as read.
6744 If ALL is non-nil, limit strictly to unread articles."
6747 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6748 (gnus-summary-limit-to-marks
6749 ;; Concat all the marks that say that an article is read and have
6751 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6752 gnus-killed-mark gnus-kill-file-mark
6753 gnus-low-score-mark gnus-expirable-mark
6754 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6755 gnus-duplicate-mark gnus-souped-mark)
6758 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6759 (make-obsolete 'gnus-summary-delete-marked-with
6760 'gnus-summary-limit-exlude-marks)
6762 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6763 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6764 If REVERSE, limit the summary buffer to articles that are marked
6765 with MARKS. MARKS can either be a string of marks or a list of marks.
6766 Returns how many articles were removed."
6767 (interactive "sMarks: ")
6768 (gnus-summary-limit-to-marks marks t))
6770 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6771 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6772 If REVERSE (the prefix), limit the summary buffer to articles that are
6773 not marked with MARKS. MARKS can either be a string of marks or a
6775 Returns how many articles were removed."
6776 (interactive "sMarks: \nP")
6778 (let ((data gnus-newsgroup-data)
6779 (marks (if (listp marks) marks
6780 (append marks nil))) ; Transform to list.
6783 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6784 (memq (gnus-data-mark (car data)) marks))
6785 (push (gnus-data-number (car data)) articles))
6786 (setq data (cdr data)))
6787 (gnus-summary-limit articles))
6788 (gnus-summary-position-point)))
6790 (defun gnus-summary-limit-to-score (&optional score)
6791 "Limit to articles with score at or above SCORE."
6793 (setq score (if score
6794 (prefix-numeric-value score)
6795 (or gnus-summary-default-score 0)))
6796 (let ((data gnus-newsgroup-data)
6799 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6801 (push (gnus-data-number (car data)) articles))
6802 (setq data (cdr data)))
6804 (gnus-summary-limit articles)
6805 (gnus-summary-position-point))))
6807 (defun gnus-summary-limit-include-thread (id)
6808 "Display all the hidden articles that is in the thread with ID in it.
6809 When called interactively, ID is the Message-ID of the current
6811 (interactive (list (mail-header-id (gnus-summary-article-header))))
6812 (let ((articles (gnus-articles-in-thread
6813 (gnus-id-to-thread (gnus-root-id id)))))
6815 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6816 (gnus-summary-limit-include-matching-articles
6818 (regexp-quote (gnus-simplify-subject-re
6819 (mail-header-subject (gnus-id-to-header id)))))
6820 (gnus-summary-position-point))))
6822 (defun gnus-summary-limit-include-matching-articles (header regexp)
6823 "Display all the hidden articles that have HEADERs that match REGEXP."
6824 (interactive (list (read-string "Match on header: ")
6825 (read-string "Regexp: ")))
6826 (let ((articles (gnus-find-matching-articles header regexp)))
6828 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6829 (gnus-summary-position-point))))
6831 (defun gnus-summary-limit-include-dormant ()
6832 "Display all the hidden articles that are marked as dormant.
6833 Note that this command only works on a subset of the articles currently
6834 fetched for this group."
6836 (unless gnus-newsgroup-dormant
6837 (error "There are no dormant articles in this group"))
6839 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6840 (gnus-summary-position-point)))
6842 (defun gnus-summary-limit-exclude-dormant ()
6843 "Hide all dormant articles."
6846 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6847 (gnus-summary-position-point)))
6849 (defun gnus-summary-limit-exclude-childless-dormant ()
6850 "Hide all dormant articles that have no children."
6852 (let ((data (gnus-data-list t))
6853 articles d children)
6854 ;; Find all articles that are either not dormant or have
6856 (while (setq d (pop data))
6857 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6859 (gnus-article-children (gnus-data-number d)))
6862 (when (memq (car children) articles)
6867 (push (gnus-data-number d) articles)))
6870 (gnus-summary-limit articles)
6871 (gnus-summary-position-point))))
6873 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6874 "Mark all unread excluded articles as read.
6875 If ALL, mark even excluded ticked and dormants as read."
6877 (let ((articles (gnus-sorted-complement
6879 (mapcar (lambda (h) (mail-header-number h))
6880 gnus-newsgroup-headers)
6882 (sort gnus-newsgroup-limit '<)))
6884 (setq gnus-newsgroup-unreads
6885 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6887 (setq gnus-newsgroup-dormant nil
6888 gnus-newsgroup-marked nil
6889 gnus-newsgroup-reads
6891 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6892 gnus-newsgroup-reads))
6893 (while (setq article (pop articles))
6894 (unless (or (memq article gnus-newsgroup-dormant)
6895 (memq article gnus-newsgroup-marked))
6896 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6898 (defun gnus-summary-limit (articles &optional pop)
6900 ;; We pop the previous limit off the stack and use that.
6901 (setq articles (car gnus-newsgroup-limits)
6902 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6903 ;; We use the new limit, so we push the old limit on the stack.
6904 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6906 (setq gnus-newsgroup-limit articles)
6907 (let ((total (length gnus-newsgroup-data))
6908 (data (gnus-data-find-list (gnus-summary-article-number)))
6909 (gnus-summary-mark-below nil) ; Inhibit this.
6911 ;; This will do all the work of generating the new summary buffer
6912 ;; according to the new limit.
6913 (gnus-summary-prepare)
6914 ;; Hide any threads, possibly.
6915 (and gnus-show-threads
6916 gnus-thread-hide-subtree
6917 (gnus-summary-hide-all-threads))
6918 ;; Try to return to the article you were at, or one in the
6921 ;; We try to find some article after the current one.
6923 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6926 (setq data (cdr data))))
6928 ;; If there is no data, that means that we were after the last
6929 ;; article. The same goes when we can't find any articles
6930 ;; after the current one.
6931 (goto-char (point-max))
6932 (gnus-summary-find-prev))
6933 (gnus-set-mode-line 'summary)
6934 ;; We return how many articles were removed from the summary
6935 ;; buffer as a result of the new limit.
6936 (- total (length gnus-newsgroup-data))))
6938 (defsubst gnus-invisible-cut-children (threads)
6941 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6946 (defsubst gnus-cut-thread (thread)
6947 "Go forwards in the thread until we find an article that we want to display."
6948 (when (or (eq gnus-fetch-old-headers 'some)
6949 (eq gnus-fetch-old-headers 'invisible)
6950 (numberp gnus-fetch-old-headers)
6951 (eq gnus-build-sparse-threads 'some)
6952 (eq gnus-build-sparse-threads 'more))
6953 ;; Deal with old-fetched headers and sparse threads.
6957 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6958 (gnus-summary-article-ancient-p
6959 (mail-header-number (car thread))))
6960 (if (or (<= (length (cdr thread)) 1)
6961 (eq gnus-fetch-old-headers 'invisible))
6962 (setq gnus-newsgroup-limit
6963 (delq (mail-header-number (car thread))
6964 gnus-newsgroup-limit)
6965 thread (cadr thread))
6966 (when (gnus-invisible-cut-children (cdr thread))
6967 (let ((th (cdr thread)))
6969 (if (memq (mail-header-number (caar th))
6970 gnus-newsgroup-limit)
6971 (setq thread (car th)
6973 (setq th (cdr th))))))))))
6976 (defun gnus-cut-threads (threads)
6977 "Cut off all uninteresting articles from the beginning of threads."
6978 (when (or (eq gnus-fetch-old-headers 'some)
6979 (eq gnus-fetch-old-headers 'invisible)
6980 (numberp gnus-fetch-old-headers)
6981 (eq gnus-build-sparse-threads 'some)
6982 (eq gnus-build-sparse-threads 'more))
6985 (setcar th (gnus-cut-thread (car th)))
6986 (setq th (cdr th)))))
6987 ;; Remove nixed out threads.
6990 (defun gnus-summary-initial-limit (&optional show-if-empty)
6991 "Figure out what the initial limit is supposed to be on group entry.
6992 This entails weeding out unwanted dormants, low-scored articles,
6993 fetch-old-headers verbiage, and so on."
6994 ;; Most groups have nothing to remove.
6995 (if (or gnus-inhibit-limiting
6996 (and (null gnus-newsgroup-dormant)
6997 (not (eq gnus-fetch-old-headers 'some))
6998 (not (numberp gnus-fetch-old-headers))
6999 (not (eq gnus-fetch-old-headers 'invisible))
7000 (null gnus-summary-expunge-below)
7001 (not (eq gnus-build-sparse-threads 'some))
7002 (not (eq gnus-build-sparse-threads 'more))
7003 (null gnus-thread-expunge-below)
7004 (not gnus-use-nocem)))
7006 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7007 (setq gnus-newsgroup-limit nil)
7010 (unless (car (symbol-value node))
7011 ;; These threads have no parents -- they are roots.
7012 (let ((nodes (cdr (symbol-value node)))
7015 (if (and gnus-thread-expunge-below
7016 (< (gnus-thread-total-score (car nodes))
7017 gnus-thread-expunge-below))
7018 (gnus-expunge-thread (pop nodes))
7019 (setq thread (pop nodes))
7020 (gnus-summary-limit-children thread))))))
7021 gnus-newsgroup-dependencies)
7022 ;; If this limitation resulted in an empty group, we might
7023 ;; pop the previous limit and use it instead.
7024 (when (and (not gnus-newsgroup-limit)
7026 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7027 gnus-newsgroup-limit))
7029 (defun gnus-summary-limit-children (thread)
7030 "Return 1 if this subthread is visible and 0 if it is not."
7031 ;; First we get the number of visible children to this thread. This
7032 ;; is done by recursing down the thread using this function, so this
7033 ;; will really go down to a leaf article first, before slowly
7034 ;; working its way up towards the root.
7038 (apply '+ (mapcar 'gnus-summary-limit-children
7041 (number (mail-header-number (car thread)))
7044 (not (memq number gnus-newsgroup-marked))
7046 ;; If this article is dormant and has absolutely no visible
7047 ;; children, then this article isn't visible.
7048 (and (memq number gnus-newsgroup-dormant)
7050 ;; If this is "fetch-old-headered" and there is no
7051 ;; visible children, then we don't want this article.
7052 (and (or (eq gnus-fetch-old-headers 'some)
7053 (numberp gnus-fetch-old-headers))
7054 (gnus-summary-article-ancient-p number)
7056 ;; If this is "fetch-old-headered" and `invisible', then
7057 ;; we don't want this article.
7058 (and (eq gnus-fetch-old-headers 'invisible)
7059 (gnus-summary-article-ancient-p number))
7060 ;; If this is a sparsely inserted article with no children,
7061 ;; we don't want it.
7062 (and (eq gnus-build-sparse-threads 'some)
7063 (gnus-summary-article-sparse-p number)
7065 ;; If we use expunging, and this article is really
7066 ;; low-scored, then we don't want this article.
7067 (when (and gnus-summary-expunge-below
7069 (or (cdr (assq number gnus-newsgroup-scored))
7070 gnus-summary-default-score))
7071 gnus-summary-expunge-below))
7072 ;; We increase the expunge-tally here, but that has
7073 ;; nothing to do with the limits, really.
7074 (incf gnus-newsgroup-expunged-tally)
7075 ;; We also mark as read here, if that's wanted.
7076 (when (and gnus-summary-mark-below
7077 (< score gnus-summary-mark-below))
7078 (setq gnus-newsgroup-unreads
7079 (delq number gnus-newsgroup-unreads))
7080 (if gnus-newsgroup-auto-expire
7081 (push number gnus-newsgroup-expirable)
7082 (push (cons number gnus-low-score-mark)
7083 gnus-newsgroup-reads)))
7085 ;; Check NoCeM things.
7086 (if (and gnus-use-nocem
7087 (gnus-nocem-unwanted-article-p
7088 (mail-header-id (car thread))))
7090 (setq gnus-newsgroup-unreads
7091 (delq number gnus-newsgroup-unreads))
7093 ;; Nope, invisible article.
7095 ;; Ok, this article is to be visible, so we add it to the limit
7097 (push number gnus-newsgroup-limit)
7100 (defun gnus-expunge-thread (thread)
7101 "Mark all articles in THREAD as read."
7102 (let* ((number (mail-header-number (car thread))))
7103 (incf gnus-newsgroup-expunged-tally)
7104 ;; We also mark as read here, if that's wanted.
7105 (setq gnus-newsgroup-unreads
7106 (delq number gnus-newsgroup-unreads))
7107 (if gnus-newsgroup-auto-expire
7108 (push number gnus-newsgroup-expirable)
7109 (push (cons number gnus-low-score-mark)
7110 gnus-newsgroup-reads)))
7111 ;; Go recursively through all subthreads.
7112 (mapcar 'gnus-expunge-thread (cdr thread)))
7114 ;; Summary article oriented commands
7116 (defun gnus-summary-refer-parent-article (n)
7117 "Refer parent article N times.
7118 If N is negative, go to ancestor -N instead.
7119 The difference between N and the number of articles fetched is returned."
7123 (when (not (natnump n))
7128 (setq header (gnus-summary-article-header))
7129 (if (and (eq (mail-header-number header)
7130 (cdr gnus-article-current))
7131 (equal gnus-newsgroup-name
7132 (car gnus-article-current)))
7133 ;; If we try to find the parent of the currently
7134 ;; displayed article, then we take a look at the actual
7135 ;; References header, since this is slightly more
7136 ;; reliable than the References field we got from the
7139 (set-buffer gnus-original-article-buffer)
7140 (nnheader-narrow-to-headers)
7141 (unless (setq ref (message-fetch-field "references"))
7142 (setq ref (message-fetch-field "in-reply-to")))
7145 ;; It's not the current article, so we take a bet on
7146 ;; the value we got from the server.
7147 (mail-header-references header)))
7149 (not (equal ref "")))
7150 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7151 (gnus-message 1 "Couldn't find parent"))
7152 (gnus-message 1 "No references in article %d"
7153 (gnus-summary-article-number))
7156 (gnus-summary-position-point)
7159 (defun gnus-summary-refer-references ()
7160 "Fetch all articles mentioned in the References header.
7161 Return the number of articles fetched."
7163 (let ((ref (mail-header-references (gnus-summary-article-header)))
7164 (current (gnus-summary-article-number))
7168 (error "No References in the current article")
7169 ;; For each Message-ID in the References header...
7170 (while (string-match "<[^>]*>" ref)
7172 ;; ... fetch that article.
7173 (gnus-summary-refer-article
7174 (prog1 (match-string 0 ref)
7175 (setq ref (substring ref (match-end 0))))))
7176 (gnus-summary-goto-subject current)
7177 (gnus-summary-position-point)
7180 (defun gnus-summary-refer-thread (&optional limit)
7181 "Fetch all articles in the current thread.
7182 If LIMIT (the numerical prefix), fetch that many old headers instead
7183 of what's specified by the `gnus-refer-thread-limit' variable."
7185 (let ((id (mail-header-id (gnus-summary-article-header)))
7186 (limit (if limit (prefix-numeric-value limit)
7187 gnus-refer-thread-limit)))
7188 ;; We want to fetch LIMIT *old* headers, but we also have to
7189 ;; re-fetch all the headers in the current buffer, because many of
7190 ;; them may be undisplayed. So we adjust LIMIT.
7191 (when (numberp limit)
7192 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7193 (unless (eq gnus-fetch-old-headers 'invisible)
7194 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7195 ;; Retrieve the headers and read them in.
7196 (if (eq (gnus-retrieve-headers
7197 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7199 (gnus-build-all-threads)
7200 (error "Can't fetch thread from backends that don't support NOV"))
7201 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7202 (gnus-summary-limit-include-thread id)))
7204 (defun gnus-summary-refer-article (message-id)
7205 "Fetch an article specified by MESSAGE-ID."
7206 (interactive "sMessage-ID: ")
7207 (when (and (stringp message-id)
7208 (not (zerop (length message-id))))
7209 ;; Construct the correct Message-ID if necessary.
7210 ;; Suggested by tale@pawl.rpi.edu.
7211 (unless (string-match "^<" message-id)
7212 (setq message-id (concat "<" message-id)))
7213 (unless (string-match ">$" message-id)
7214 (setq message-id (concat message-id ">")))
7215 (let* ((header (gnus-id-to-header message-id))
7217 (gnus-summary-article-sparse-p
7218 (mail-header-number header))
7219 (memq (mail-header-number header)
7220 gnus-newsgroup-limit)))
7223 ;; If the article is present in the buffer we just go to it.
7225 (or (not (gnus-summary-article-sparse-p
7226 (mail-header-number header)))
7229 (gnus-summary-goto-article
7230 (mail-header-number header) nil t)
7232 (gnus-summary-update-article (mail-header-number header)))))
7234 ;; We fetch the article.
7236 (dolist (gnus-override-method (gnus-refer-article-methods))
7237 (gnus-check-server gnus-override-method)
7238 ;; Fetch the header, and display the article.
7239 (when (setq number (gnus-summary-insert-subject message-id))
7240 (gnus-summary-select-article nil nil nil number)
7242 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7244 (defun gnus-refer-article-methods ()
7245 "Return a list of referrable methods."
7247 ;; No method, so we default to current and native.
7248 ((null gnus-refer-article-method)
7249 (list gnus-current-select-method gnus-select-method))
7251 ((eq 'current gnus-refer-article-method)
7252 (list gnus-current-select-method))
7253 ;; List of select methods.
7254 ((not (and (symbolp (car gnus-refer-article-method))
7255 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7257 (dolist (method gnus-refer-article-method)
7258 (push (if (eq 'current method)
7259 gnus-current-select-method
7263 ;; One single select method.
7265 (list gnus-refer-article-method))))
7267 (defun gnus-summary-edit-parameters ()
7268 "Edit the group parameters of the current group."
7270 (gnus-group-edit-group gnus-newsgroup-name 'params))
7272 (defun gnus-summary-customize-parameters ()
7273 "Customize the group parameters of the current group."
7275 (gnus-group-customize gnus-newsgroup-name))
7277 (defun gnus-summary-enter-digest-group (&optional force)
7278 "Enter an nndoc group based on the current article.
7279 If FORCE, force a digest interpretation. If not, try
7280 to guess what the document format is."
7282 (let ((conf gnus-current-window-configuration))
7284 (gnus-summary-select-article))
7285 (setq gnus-current-window-configuration conf)
7286 (let* ((name (format "%s-%d"
7287 (gnus-group-prefixed-name
7288 gnus-newsgroup-name (list 'nndoc ""))
7290 (set-buffer gnus-summary-buffer)
7291 gnus-current-article)))
7292 (ogroup gnus-newsgroup-name)
7293 (params (append (gnus-info-params (gnus-get-info ogroup))
7294 (list (cons 'to-group ogroup))
7295 (list (cons 'save-article-group ogroup))))
7296 (case-fold-search t)
7297 (buf (current-buffer))
7300 (set-buffer gnus-original-article-buffer)
7301 ;; Have the digest group inherit the main mail address of
7302 ;; the parent article.
7303 (when (setq to-address (or (message-fetch-field "reply-to")
7304 (message-fetch-field "from")))
7305 (setq params (append
7306 (list (cons 'to-address
7307 (funcall gnus-decode-encoded-word-function
7309 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7310 (insert-buffer-substring gnus-original-article-buffer)
7311 ;; Remove lines that may lead nndoc to misinterpret the
7314 (goto-char (point-min))
7315 (or (search-forward "\n\n" nil t) (point)))
7316 (goto-char (point-min))
7317 (delete-matching-lines "^Path:\\|^From ")
7320 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7321 (gnus-newsgroup-ephemeral-ignored-charsets
7322 gnus-newsgroup-ignored-charsets))
7323 (gnus-group-read-ephemeral-group
7324 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7326 ,(if force 'mbox 'guess))) t))
7327 ;; Make all postings to this group go to the parent group.
7328 (nconc (gnus-info-params (gnus-get-info name))
7330 ;; Couldn't select this doc group.
7331 (switch-to-buffer buf)
7332 (gnus-set-global-variables)
7333 (gnus-configure-windows 'summary)
7334 (gnus-message 3 "Article couldn't be entered?"))
7335 (kill-buffer dig)))))
7337 (defun gnus-summary-read-document (n)
7338 "Open a new group based on the current article(s).
7339 This will allow you to read digests and other similar
7340 documents as newsgroups.
7341 Obeys the standard process/prefix convention."
7343 (let* ((articles (gnus-summary-work-articles n))
7344 (ogroup gnus-newsgroup-name)
7345 (params (append (gnus-info-params (gnus-get-info ogroup))
7346 (list (cons 'to-group ogroup))))
7347 article group egroup groups vgroup)
7348 (while (setq article (pop articles))
7349 (setq group (format "%s-%d" gnus-newsgroup-name article))
7350 (gnus-summary-remove-process-mark article)
7351 (when (gnus-summary-display-article article)
7354 (insert-buffer-substring gnus-original-article-buffer)
7355 ;; Remove some headers that may lead nndoc to make
7357 (message-narrow-to-head)
7358 (goto-char (point-min))
7359 (delete-matching-lines "^\\(Path\\):\\|^From ")
7362 (gnus-group-read-ephemeral-group
7363 group `(nndoc ,group (nndoc-address ,(current-buffer))
7364 (nndoc-article-type guess))
7367 ;; Make all postings to this group go to the parent group.
7368 (nconc (gnus-info-params (gnus-get-info egroup))
7370 (push egroup groups))
7371 ;; Couldn't select this doc group.
7372 (gnus-error 3 "Article couldn't be entered"))))))
7373 ;; Now we have selected all the documents.
7376 (error "None of the articles could be interpreted as documents"))
7377 ((gnus-group-read-ephemeral-group
7378 (setq vgroup (format
7379 "nnvirtual:%s-%s" gnus-newsgroup-name
7380 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7381 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7383 (cons (current-buffer) 'summary)))
7385 (error "Couldn't select virtual nndoc group")))))
7387 (defun gnus-summary-isearch-article (&optional regexp-p)
7388 "Do incremental search forward on the current article.
7389 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7391 (let* ((gnus-inhibit-treatment t)
7392 (old (gnus-summary-select-article)))
7393 (gnus-configure-windows 'article)
7394 (gnus-eval-in-buffer-window gnus-article-buffer
7398 (gnus-article-show-all-headers))
7399 (goto-char (point-min))
7400 (isearch-forward regexp-p)))))
7402 (defun gnus-summary-search-article-forward (regexp &optional backward)
7403 "Search for an article containing REGEXP forward.
7404 If BACKWARD, search backward instead."
7407 (format "Search article %s (regexp%s): "
7408 (if current-prefix-arg "backward" "forward")
7409 (if gnus-last-search-regexp
7410 (concat ", default " gnus-last-search-regexp)
7412 current-prefix-arg))
7413 (if (string-equal regexp "")
7414 (setq regexp (or gnus-last-search-regexp ""))
7415 (setq gnus-last-search-regexp regexp)
7416 (setq gnus-article-before-search gnus-current-article))
7417 ;; Intentionally set gnus-last-article.
7418 (setq gnus-last-article gnus-article-before-search)
7419 (let ((gnus-last-article gnus-last-article))
7420 (if (gnus-summary-search-article regexp backward)
7421 (gnus-summary-show-thread)
7422 (error "Search failed: \"%s\"" regexp))))
7424 (defun gnus-summary-search-article-backward (regexp)
7425 "Search for an article containing REGEXP backward."
7428 (format "Search article backward (regexp%s): "
7429 (if gnus-last-search-regexp
7430 (concat ", default " gnus-last-search-regexp)
7432 (gnus-summary-search-article-forward regexp 'backward))
7435 (defmacro gnus-summary-search-article-position-point (regexp backward)
7436 "Dehighlight the last matched text and goto the beginning position."
7437 (` (if (and gnus-summary-search-article-matched-data
7438 (let ((text (caddr gnus-summary-search-article-matched-data))
7439 (inhibit-read-only t)
7442 (goto-char (car gnus-summary-search-article-matched-data))
7443 (cadr gnus-summary-search-article-matched-data))
7445 (string-match (, regexp) text)))
7446 (if (, backward) (beginning-of-line) (end-of-line))
7447 (goto-char (if (, backward) (point-max) (point-min))))))
7449 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7450 "Place point where X-Face image is displayed."
7451 (if (featurep 'xemacs)
7452 (` (let ((end (if (search-forward "\n\n" nil t)
7453 (goto-char (1- (point)))
7456 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7457 (unless (and (re-search-forward "^From:" end t)
7458 (setq extent (extent-at (point)))
7459 (extent-begin-glyph extent))
7460 (goto-char (, opoint)))))
7461 (` (let ((end (if (search-forward "\n\n" nil t)
7462 (goto-char (1- (point)))
7464 (start (or (search-backward "\n\n" nil t) (point-min))))
7466 (or (text-property-any start end 'x-face-image t);; x-face-e21
7467 (text-property-any start end 'x-face-mule-bitmap-image t)
7470 (defmacro gnus-summary-search-article-highlight-matched-text
7471 (backward treated x-face)
7472 "Highlight matched text in the function `gnus-summary-search-article'."
7473 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7474 (end (set-marker (make-marker) (match-end 0)))
7475 (inhibit-read-only t)
7479 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7481 (lambda (item) (setq items (delq item items)))
7482 '(gnus-treat-buttonize
7483 gnus-treat-fill-article
7484 gnus-treat-fill-long-lines
7485 gnus-treat-emphasize
7486 gnus-treat-highlight-headers
7487 gnus-treat-highlight-citation
7488 gnus-treat-highlight-signature
7489 gnus-treat-overstrike
7490 gnus-treat-display-xface
7491 gnus-treat-buttonize-head
7492 gnus-treat-decode-article-as-default-mime-charset))
7493 (static-if (featurep 'xemacs)
7495 (cons '(x-face-mule-delete-x-face-field
7498 (gnus-treat-display-xface
7499 (when (, x-face) gnus-treat-display-xface)))
7500 (gnus-article-prepare-mime-display)))
7501 (goto-char (if (, backward) start end))
7503 (gnus-summary-search-article-highlight-goto-x-face (point)))
7504 (setq gnus-summary-search-article-matched-data
7505 (list start end (buffer-substring start end)))
7506 (unless (eq start end);; matched text has been deleted. :-<
7507 (put-text-property start end 'face
7508 (or (find-face 'isearch)
7509 'secondary-selection))))))
7512 (defun gnus-summary-search-article (regexp &optional backward)
7513 "Search for an article containing REGEXP.
7514 Optional argument BACKWARD means do search for backward.
7515 `gnus-select-article-hook' is not called during the search."
7516 ;; We have to require this here to make sure that the following
7517 ;; dynamic binding isn't shadowed by autoloading.
7518 (require 'gnus-async)
7520 (let ((gnus-select-article-hook nil) ;Disable hook.
7521 (gnus-article-prepare-hook nil)
7522 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7523 (gnus-use-article-prefetch nil)
7524 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7525 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7526 (sum (current-buffer))
7529 (gnus-save-hidden-threads
7530 (static-if (featurep 'xemacs)
7531 (let ((gnus-inhibit-treatment t))
7532 (setq treated (eq 'old (gnus-summary-select-article)))
7534 (not (and (gnus-buffer-live-p gnus-article-buffer)
7535 (window-live-p (get-buffer-window
7536 gnus-article-buffer t)))))
7537 (gnus-summary-select-article nil t)
7538 (setq treated nil)))
7539 (let ((gnus-inhibit-treatment t)
7540 (x-face-mule-delete-x-face-field 'never))
7541 (setq treated (eq 'old (gnus-summary-select-article)))
7544 (and (gnus-buffer-live-p gnus-article-buffer)
7545 (window-live-p (get-buffer-window
7546 gnus-article-buffer t))
7547 (or (not (string-match "^\\^X-Face:" regexp))
7548 (with-current-buffer gnus-article-buffer
7549 gnus-summary-search-article-matched-data)))))
7550 (gnus-summary-select-article nil t)
7551 (setq treated nil))))
7552 (set-buffer gnus-article-buffer)
7556 (gnus-article-show-all-headers)
7557 (gnus-summary-search-article-position-point regexp backward))
7558 (goto-char (if backward (point-max) (point-min))))
7560 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7562 (re-search-backward regexp nil t)
7563 (re-search-forward regexp nil t))
7564 ;; We found the regexp.
7566 (gnus-summary-search-article-highlight-matched-text
7567 backward treated (string-match "^\\^X-Face:" regexp))
7570 (/ (- 2 (window-height
7571 (get-buffer-window gnus-article-buffer t)))
7574 (get-buffer-window (current-buffer))
7577 (setq point (point)))
7578 ;; We didn't find it, so we go to the next article.
7581 (while (eq found 'not)
7582 (if (not (if backward (gnus-summary-find-prev)
7583 (gnus-summary-find-next)))
7584 ;; No more articles.
7586 ;; Select the next article and adjust point.
7587 (unless (gnus-summary-article-sparse-p
7588 (gnus-summary-article-number))
7590 (let ((gnus-inhibit-treatment t))
7591 (gnus-summary-select-article))
7593 (set-buffer gnus-article-buffer)
7595 (goto-char (if backward (point-max) (point-min))))))))
7596 (gnus-message 7 ""))
7597 ;; Return whether we found the regexp.
7598 (when (eq found 'found)
7600 (gnus-summary-show-thread)
7601 (gnus-summary-goto-subject gnus-current-article)
7602 (gnus-summary-position-point)
7605 (defun gnus-find-matching-articles (header regexp)
7606 "Return a list of all articles that match REGEXP on HEADER.
7607 This search includes all articles in the current group that Gnus has
7608 fetched headers for, whether they are displayed or not."
7609 (let ((articles nil)
7610 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7611 (case-fold-search t))
7612 (dolist (header gnus-newsgroup-headers)
7613 (when (string-match regexp (funcall func header))
7614 (push (mail-header-number header) articles)))
7615 (nreverse articles)))
7617 (defun gnus-summary-find-matching (header regexp &optional backward unread
7619 "Return a list of all articles that match REGEXP on HEADER.
7620 The search stars on the current article and goes forwards unless
7621 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7622 If UNREAD is non-nil, only unread articles will
7623 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7624 in the comparisons."
7625 (let ((case-fold-search (not not-case-fold))
7628 (if (eq (car header) 'extra)
7631 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7633 (error "%s is an invalid header" header))
7634 (unless (fboundp (intern (concat "mail-header-" header)))
7635 (error "%s is not a valid header" header))
7636 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7637 (dolist (d (if (eq backward 'all)
7639 (gnus-data-find-list
7640 (gnus-summary-article-number)
7641 (gnus-data-list backward))))
7642 (when (and (or (not unread) ; We want all articles...
7643 (gnus-data-unread-p d)) ; Or just unreads.
7644 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7645 (string-match regexp
7646 (funcall func (gnus-data-header d)))) ; Match.
7647 (push (gnus-data-number d) articles))) ; Success!
7648 (nreverse articles)))
7650 (defun gnus-summary-execute-command (header regexp command &optional backward)
7651 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7652 If HEADER is an empty string (or nil), the match is done on the entire
7653 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7655 (list (let ((completion-ignore-case t))
7658 (mapcar (lambda (header) (list (format "%s" header)))
7660 '("Number" "Subject" "From" "Lines" "Date"
7661 "Message-ID" "Xref" "References" "Body")
7662 gnus-extra-headers))
7663 nil 'require-match))
7664 (read-string "Regexp: ")
7665 (read-key-sequence "Command: ")
7666 current-prefix-arg))
7667 (when (equal header "Body")
7669 ;; Hidden thread subtrees must be searched as well.
7670 (gnus-summary-show-all-threads)
7671 ;; We don't want to change current point nor window configuration.
7673 (save-window-excursion
7674 (gnus-message 6 "Executing %s..." (key-description command))
7675 ;; We'd like to execute COMMAND interactively so as to give arguments.
7676 (gnus-execute header regexp
7677 `(call-interactively ',(key-binding command))
7679 (gnus-message 6 "Executing %s...done" (key-description command)))))
7681 (defun gnus-summary-beginning-of-article ()
7682 "Scroll the article back to the beginning."
7684 (gnus-summary-select-article)
7685 (gnus-configure-windows 'article)
7686 (gnus-eval-in-buffer-window gnus-article-buffer
7688 (goto-char (point-min))
7689 (when gnus-page-broken
7690 (gnus-narrow-to-page))))
7692 (defun gnus-summary-end-of-article ()
7693 "Scroll to the end of the article."
7695 (gnus-summary-select-article)
7696 (gnus-configure-windows 'article)
7697 (gnus-eval-in-buffer-window gnus-article-buffer
7699 (goto-char (point-max))
7701 (when gnus-page-broken
7702 (gnus-narrow-to-page))))
7704 (defun gnus-summary-print-article (&optional filename n)
7705 "Generate and print a PostScript image of the N next (mail) articles.
7707 If N is negative, print the N previous articles. If N is nil and articles
7708 have been marked with the process mark, print these instead.
7710 If the optional first argument FILENAME is nil, send the image to the
7711 printer. If FILENAME is a string, save the PostScript image in a file with
7712 that name. If FILENAME is a number, prompt the user for the name of the file
7714 (interactive (list (ps-print-preprint current-prefix-arg)))
7715 (dolist (article (gnus-summary-work-articles n))
7716 (gnus-summary-select-article nil nil 'pseudo article)
7717 (gnus-eval-in-buffer-window gnus-article-buffer
7718 (let ((buffer (generate-new-buffer " *print*")))
7721 (copy-to-buffer buffer (point-min) (point-max))
7723 (gnus-article-delete-invisible-text)
7724 (when (gnus-visual-p 'article-highlight 'highlight)
7725 ;; Copy-to-buffer doesn't copy overlay. So redo
7727 (let ((gnus-article-buffer buffer))
7728 (gnus-article-highlight-citation t)
7729 (gnus-article-highlight-signature)))
7730 (let ((ps-left-header
7733 (mail-header-subject gnus-current-headers) ")")
7735 (mail-header-from gnus-current-headers) ")")))
7738 "/pagenumberstring load"
7740 (mail-header-date gnus-current-headers) ")"))))
7741 (gnus-run-hooks 'gnus-ps-print-hook)
7744 (ps-spool-buffer-with-faces)
7745 (ps-spool-buffer)))))
7746 (kill-buffer buffer))))
7747 (gnus-summary-remove-process-mark article))
7748 (ps-despool filename))
7750 (defun gnus-summary-show-article (&optional arg)
7751 "Force re-fetching of the current article.
7752 If ARG (the prefix) is a number, show the article with the charset
7753 defined in `gnus-summary-show-article-charset-alist', or the charset
7755 If ARG (the prefix) is non-nil and not a number, show the raw article
7756 without any article massaging functions being run."
7760 (let ((gnus-newsgroup-charset
7761 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7762 (read-coding-system "Charset: ")))
7763 (gnus-newsgroup-ignored-charsets 'gnus-all))
7764 (gnus-summary-select-article nil 'force)
7765 (let ((deps gnus-newsgroup-dependencies)
7768 (set-buffer gnus-original-article-buffer)
7770 (message-narrow-to-head)
7771 (setq head (buffer-string)))
7773 (insert (format "211 %d Article retrieved.\n"
7774 (cdr gnus-article-current)))
7777 (let ((nntp-server-buffer (current-buffer)))
7778 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7779 (gnus-data-set-header
7780 (gnus-data-find (cdr gnus-article-current))
7782 (gnus-summary-update-article-line
7783 (cdr gnus-article-current) header))))
7785 ;; Select the article the normal way.
7786 (gnus-summary-select-article nil 'force))
7788 ;; We have to require this here to make sure that the following
7789 ;; dynamic binding isn't shadowed by autoloading.
7790 (require 'gnus-async)
7792 ;; Bind the article treatment functions to nil.
7793 (let ((gnus-have-all-headers t)
7794 gnus-article-prepare-hook
7795 gnus-article-decode-hook
7798 (gnus-inhibit-treatment t))
7799 (gnus-summary-select-article nil 'force))))
7800 (gnus-summary-goto-subject gnus-current-article)
7801 (gnus-summary-position-point))
7803 (defun gnus-summary-verbose-headers (&optional arg)
7804 "Toggle permanent full header display.
7805 If ARG is a positive number, turn header display on.
7806 If ARG is a negative number, turn header display off."
7808 (setq gnus-show-all-headers
7809 (cond ((or (not (numberp arg))
7811 (not gnus-show-all-headers))
7814 (gnus-summary-show-article))
7816 (defun gnus-summary-toggle-header (&optional arg)
7817 "Show the headers if they are hidden, or hide them if they are shown.
7818 If ARG is a positive number, show the entire header.
7819 If ARG is a negative number, hide the unwanted header lines."
7822 (set-buffer gnus-article-buffer)
7824 (let* ((buffer-read-only nil)
7825 (inhibit-point-motion-hooks t)
7831 (article-narrow-to-head)
7832 (gnus-article-hidden-text-p 'headers))))
7833 (goto-char (point-min))
7834 (when (search-forward "\n\n" nil t)
7835 (delete-region (point-min) (1- (point))))
7836 (goto-char (point-min))
7838 (set-buffer gnus-original-article-buffer)
7839 (goto-char (point-min))
7840 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7841 (insert-buffer-substring gnus-original-article-buffer 1 e)
7843 (narrow-to-region (point-min) (point))
7844 (article-decode-encoded-words)
7846 (let ((gnus-treat-hide-headers nil)
7847 (gnus-treat-hide-boring-headers nil))
7848 (setq gnus-article-wash-types
7849 (delq 'headers gnus-article-wash-types))
7850 (gnus-treat-article 'head))
7851 (gnus-treat-article 'head)))
7852 (gnus-set-mode-line 'article)))))
7854 (defun gnus-summary-show-all-headers ()
7855 "Make all header lines visible."
7857 (gnus-summary-toggle-header 1))
7859 (defun gnus-summary-toggle-mime (&optional arg)
7860 "Toggle MIME processing.
7861 If ARG is a positive number, turn MIME processing on."
7863 (setq gnus-show-mime
7865 (not gnus-show-mime)
7866 (> (prefix-numeric-value arg) 0)))
7867 (gnus-summary-select-article t 'force))
7869 (defun gnus-summary-caesar-message (&optional arg)
7870 "Caesar rotate the current article by 13.
7871 The numerical prefix specifies how many places to rotate each letter
7874 (gnus-summary-select-article)
7875 (let ((mail-header-separator ""))
7876 (gnus-eval-in-buffer-window gnus-article-buffer
7879 (let ((start (window-start))
7881 (message-caesar-buffer-body arg)
7882 (set-window-start (get-buffer-window (current-buffer)) start))))))
7884 (defun gnus-summary-stop-page-breaking ()
7885 "Stop page breaking in the current article."
7887 (gnus-summary-select-article)
7888 (gnus-eval-in-buffer-window gnus-article-buffer
7890 (when (gnus-visual-p 'page-marker)
7891 (let ((buffer-read-only nil))
7892 (gnus-remove-text-with-property 'gnus-prev)
7893 (gnus-remove-text-with-property 'gnus-next))
7894 (setq gnus-page-broken nil))))
7896 (defun gnus-summary-move-article (&optional n to-newsgroup
7897 select-method action)
7898 "Move the current article to a different newsgroup.
7899 If N is a positive number, move the N next articles.
7900 If N is a negative number, move the N previous articles.
7901 If N is nil and any articles have been marked with the process mark,
7902 move those articles instead.
7903 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7904 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7905 re-spool using this method.
7907 For this function to work, both the current newsgroup and the
7908 newsgroup that you want to move to have to support the `request-move'
7909 and `request-accept' functions.
7911 ACTION can be either `move' (the default), `crosspost' or `copy'."
7914 (setq action 'move))
7915 ;; Disable marking as read.
7916 (let (gnus-mark-article-hook)
7917 (save-window-excursion
7918 (gnus-summary-select-article)))
7919 ;; Check whether the source group supports the required functions.
7920 (cond ((and (eq action 'move)
7921 (not (gnus-check-backend-function
7922 'request-move-article gnus-newsgroup-name)))
7923 (error "The current group does not support article moving"))
7924 ((and (eq action 'crosspost)
7925 (not (gnus-check-backend-function
7926 'request-replace-article gnus-newsgroup-name)))
7927 (error "The current group does not support article editing")))
7928 (let ((articles (gnus-summary-work-articles n))
7929 (prefix (if (gnus-check-backend-function
7930 'request-move-article gnus-newsgroup-name)
7931 (gnus-group-real-prefix gnus-newsgroup-name)
7933 (names '((move "Move" "Moving")
7934 (copy "Copy" "Copying")
7935 (crosspost "Crosspost" "Crossposting")))
7936 (copy-buf (save-excursion
7937 (nnheader-set-temp-buffer " *copy article*")))
7938 (default-marks gnus-article-mark-lists)
7939 (no-expire-marks (delete '(expirable . expire)
7940 (copy-sequence gnus-article-mark-lists)))
7941 art-group to-method new-xref article to-groups)
7942 (unless (assq action names)
7943 (error "Unknown action %s" action))
7944 ;; Read the newsgroup name.
7945 (when (and (not to-newsgroup)
7946 (not select-method))
7948 (gnus-read-move-group-name
7949 (cadr (assq action names))
7950 (symbol-value (intern (format "gnus-current-%s-group" action)))
7952 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7953 (setq to-method (or select-method
7954 (gnus-server-to-method
7955 (gnus-group-method to-newsgroup))))
7956 ;; Check the method we are to move this article to...
7957 (unless (gnus-check-backend-function
7958 'request-accept-article (car to-method))
7959 (error "%s does not support article copying" (car to-method)))
7960 (unless (gnus-check-server to-method)
7961 (error "Can't open server %s" (car to-method)))
7962 (gnus-message 6 "%s to %s: %s..."
7963 (caddr (assq action names))
7964 (or (car select-method) to-newsgroup) articles)
7966 (setq article (pop articles))
7970 ;; Move the article.
7972 ;; Remove this article from future suppression.
7973 (gnus-dup-unsuppress-article article)
7974 (gnus-request-move-article
7975 article ; Article to move
7976 gnus-newsgroup-name ; From newsgroup
7977 (nth 1 (gnus-find-method-for-group
7978 gnus-newsgroup-name)) ; Server
7979 (list 'gnus-request-accept-article
7980 to-newsgroup (list 'quote select-method)
7981 (not articles) t) ; Accept form
7982 (not articles))) ; Only save nov last time
7983 ;; Copy the article.
7986 (set-buffer copy-buf)
7987 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7988 (gnus-request-accept-article
7989 to-newsgroup select-method (not articles) t))))
7990 ;; Crosspost the article.
7991 ((eq action 'crosspost)
7992 (let ((xref (message-tokenize-header
7993 (mail-header-xref (gnus-summary-article-header article))
7995 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7998 (setq xref (list (system-name))))
8001 (mapconcat 'identity
8002 (delete "Xref:" (delete new-xref xref))
8006 (set-buffer copy-buf)
8007 ;; First put the article in the destination group.
8008 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8009 (when (consp (setq art-group
8010 (gnus-request-accept-article
8011 to-newsgroup select-method (not articles))))
8012 (setq new-xref (concat new-xref " " (car art-group)
8013 ":" (cdr art-group)))
8014 ;; Now we have the new Xrefs header, so we insert
8015 ;; it and replace the new article.
8016 (nnheader-replace-header "Xref" new-xref)
8017 (gnus-request-replace-article
8018 (cdr art-group) to-newsgroup (current-buffer))
8022 (gnus-message 1 "Couldn't %s article %s: %s"
8023 (cadr (assq action names)) article
8024 (nnheader-get-report (car to-method))))
8025 ((eq art-group 'junk)
8026 (when (eq action 'move)
8027 (gnus-summary-mark-article article gnus-canceled-mark)
8028 (gnus-message 4 "Deleted article %s" article)))
8030 (let* ((pto-group (gnus-group-prefixed-name
8031 (car art-group) to-method))
8033 (gnus-gethash pto-group gnus-newsrc-hashtb))
8034 (info (nth 2 entry))
8035 (to-group (gnus-info-group info))
8037 ;; Update the group that has been moved to.
8039 (memq action '(move copy)))
8040 (unless (member to-group to-groups)
8041 (push to-group to-groups))
8043 (unless (memq article gnus-newsgroup-unreads)
8044 (push 'read to-marks)
8046 info (gnus-add-to-range (gnus-info-read info)
8047 (list (cdr art-group)))))
8049 ;; See whether the article is to be put in the cache.
8050 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8053 (to-article (cdr art-group)))
8055 ;; Enter the article into the cache in the new group,
8056 ;; if that is required.
8057 (when gnus-use-cache
8058 (gnus-cache-possibly-enter-article
8060 (let ((header (copy-sequence
8061 (gnus-summary-article-header article))))
8062 (mail-header-set-number header to-article)
8064 (memq article gnus-newsgroup-marked)
8065 (memq article gnus-newsgroup-dormant)
8066 (memq article gnus-newsgroup-unreads)))
8068 (when gnus-preserve-marks
8069 ;; Copy any marks over to the new group.
8070 (when (and (equal to-group gnus-newsgroup-name)
8071 (not (memq article gnus-newsgroup-unreads)))
8072 ;; Mark this article as read in this group.
8073 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8074 (setcdr (gnus-active to-group) to-article)
8075 (setcdr gnus-newsgroup-active to-article))
8078 (when (memq article (symbol-value
8079 (intern (format "gnus-newsgroup-%s"
8081 (push (cdar marks) to-marks)
8082 ;; If the other group is the same as this group,
8083 ;; then we have to add the mark to the list.
8084 (when (equal to-group gnus-newsgroup-name)
8085 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8088 (intern (format "gnus-newsgroup-%s"
8090 ;; Copy the marks to other group.
8091 (gnus-add-marked-articles
8092 to-group (cdar marks) (list to-article) info))
8093 (setq marks (cdr marks)))
8095 (gnus-request-set-mark to-group (list (list (list to-article)
8100 (concat "(gnus-group-set-info '"
8101 (gnus-prin1-to-string (gnus-get-info to-group))
8104 ;; Update the Xref header in this article to point to
8105 ;; the new crossposted article we have just created.
8106 (when (eq action 'crosspost)
8108 (set-buffer copy-buf)
8109 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8110 (nnheader-replace-header "Xref" new-xref)
8111 (gnus-request-replace-article
8112 article gnus-newsgroup-name (current-buffer)))))
8114 ;;;!!!Why is this necessary?
8115 (set-buffer gnus-summary-buffer)
8117 (gnus-summary-goto-subject article)
8118 (when (eq action 'move)
8119 (gnus-summary-mark-article article gnus-canceled-mark))))
8120 (gnus-summary-remove-process-mark article))
8121 ;; Re-activate all groups that have been moved to.
8124 (set-buffer gnus-group-buffer)
8125 (when (gnus-group-goto-group (car to-groups) t)
8126 (gnus-group-get-new-news-this-group 1 t))
8129 (gnus-kill-buffer copy-buf)
8130 (gnus-summary-position-point)
8131 (gnus-set-mode-line 'summary)))
8133 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8134 "Move the current article to a different newsgroup.
8135 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8136 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8137 re-spool using this method."
8139 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8141 (defun gnus-summary-crosspost-article (&optional n)
8142 "Crosspost the current article to some other group."
8144 (gnus-summary-move-article n nil nil 'crosspost))
8146 (defcustom gnus-summary-respool-default-method nil
8147 "Default method for respooling an article.
8148 If nil, use to the current newsgroup method."
8149 :type '(choice (gnus-select-method :value (nnml ""))
8151 :group 'gnus-summary-mail)
8153 (defun gnus-summary-respool-article (&optional n method)
8154 "Respool the current article.
8155 The article will be squeezed through the mail spooling process again,
8156 which means that it will be put in some mail newsgroup or other
8157 depending on `nnmail-split-methods'.
8158 If N is a positive number, respool the N next articles.
8159 If N is a negative number, respool the N previous articles.
8160 If N is nil and any articles have been marked with the process mark,
8161 respool those articles instead.
8163 Respooling can be done both from mail groups and \"real\" newsgroups.
8164 In the former case, the articles in question will be moved from the
8165 current group into whatever groups they are destined to. In the
8166 latter case, they will be copied into the relevant groups."
8168 (list current-prefix-arg
8169 (let* ((methods (gnus-methods-using 'respool))
8171 (symbol-name (or gnus-summary-respool-default-method
8172 (car (gnus-find-method-for-group
8173 gnus-newsgroup-name)))))
8175 (gnus-completing-read
8176 methname "What backend do you want to use when respooling?"
8177 methods nil t nil 'gnus-mail-method-history))
8180 ((zerop (length (setq ms (gnus-servers-using-backend
8182 (list (intern method) ""))
8186 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8187 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8190 (error "No method given for respooling"))
8191 (if (assoc (symbol-name
8192 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8193 (gnus-methods-using 'respool))
8194 (gnus-summary-move-article n nil method)
8195 (gnus-summary-copy-article n nil method)))
8197 (defun gnus-summary-import-article (file &optional edit)
8198 "Import an arbitrary file into a mail newsgroup."
8199 (interactive "fImport file: \nP")
8200 (let ((group gnus-newsgroup-name)
8201 (now (current-time))
8202 atts lines group-art)
8203 (unless (gnus-check-backend-function 'request-accept-article group)
8204 (error "%s does not support article importing" group))
8205 (or (file-readable-p file)
8206 (not (file-regular-p file))
8207 (error "Can't read %s" file))
8209 (set-buffer (gnus-get-buffer-create " *import file*"))
8211 (nnheader-insert-file-contents file)
8212 (goto-char (point-min))
8213 (unless (nnheader-article-p)
8214 ;; This doesn't look like an article, so we fudge some headers.
8215 (setq atts (file-attributes file)
8216 lines (count-lines (point-min) (point-max)))
8217 (insert "From: " (read-string "From: ") "\n"
8218 "Subject: " (read-string "Subject: ") "\n"
8219 "Date: " (message-make-date (nth 5 atts)) "\n"
8220 "Message-ID: " (message-make-message-id) "\n"
8221 "Lines: " (int-to-string lines) "\n"
8222 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8223 (setq group-art (gnus-request-accept-article group nil t))
8224 (kill-buffer (current-buffer)))
8225 (setq gnus-newsgroup-active (gnus-activate-group group))
8227 (gnus-summary-goto-article (cdr group-art) nil t)
8229 (gnus-summary-edit-article))))
8231 (defun gnus-summary-create-article ()
8232 "Create an article in a mail newsgroup."
8234 (let ((group gnus-newsgroup-name)
8235 (now (current-time))
8237 (unless (gnus-check-backend-function 'request-accept-article group)
8238 (error "%s does not support article importing" group))
8240 (set-buffer (gnus-get-buffer-create " *import file*"))
8242 (goto-char (point-min))
8243 ;; This doesn't look like an article, so we fudge some headers.
8244 (insert "From: " (read-string "From: ") "\n"
8245 "Subject: " (read-string "Subject: ") "\n"
8246 "Date: " (message-make-date now) "\n"
8247 "Message-ID: " (message-make-message-id) "\n")
8248 (setq group-art (gnus-request-accept-article group nil t))
8249 (kill-buffer (current-buffer)))
8250 (setq gnus-newsgroup-active (gnus-activate-group group))
8252 (gnus-summary-goto-article (cdr group-art) nil t)
8253 (gnus-summary-edit-article)))
8255 (defun gnus-summary-article-posted-p ()
8256 "Say whether the current (mail) article is available from news as well.
8257 This will be the case if the article has both been mailed and posted."
8259 (let ((id (mail-header-references (gnus-summary-article-header)))
8260 (gnus-override-method (car (gnus-refer-article-methods))))
8261 (if (gnus-request-head id "")
8262 (gnus-message 2 "The current message was found on %s"
8263 gnus-override-method)
8264 (gnus-message 2 "The current message couldn't be found on %s"
8265 gnus-override-method)
8268 (defun gnus-summary-expire-articles (&optional now)
8269 "Expire all articles that are marked as expirable in the current group."
8271 (when (gnus-check-backend-function
8272 'request-expire-articles gnus-newsgroup-name)
8273 ;; This backend supports expiry.
8274 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8275 (expirable (if total
8277 ;; We need to update the info for
8278 ;; this group for `gnus-list-of-read-articles'
8279 ;; to give us the right answer.
8280 (gnus-run-hooks 'gnus-exit-group-hook)
8281 (gnus-summary-update-info)
8282 (gnus-list-of-read-articles gnus-newsgroup-name))
8283 (setq gnus-newsgroup-expirable
8284 (sort gnus-newsgroup-expirable '<))))
8285 (expiry-wait (if now 'immediate
8286 (gnus-group-find-parameter
8287 gnus-newsgroup-name 'expiry-wait)))
8288 (nnmail-expiry-target
8289 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8290 nnmail-expiry-target))
8293 ;; There are expirable articles in this group, so we run them
8294 ;; through the expiry process.
8295 (gnus-message 6 "Expiring articles...")
8296 (unless (gnus-check-group gnus-newsgroup-name)
8297 (error "Can't open server for %s" gnus-newsgroup-name))
8298 ;; The list of articles that weren't expired is returned.
8301 (let ((nnmail-expiry-wait-function nil)
8302 (nnmail-expiry-wait expiry-wait))
8303 (setq es (gnus-request-expire-articles
8304 expirable gnus-newsgroup-name)))
8305 (setq es (gnus-request-expire-articles
8306 expirable gnus-newsgroup-name)))
8308 (setq gnus-newsgroup-expirable es))
8309 ;; We go through the old list of expirable, and mark all
8310 ;; really expired articles as nonexistent.
8311 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8312 (let ((gnus-use-cache nil))
8314 (unless (memq (car expirable) es)
8315 (when (gnus-data-find (car expirable))
8316 (gnus-summary-mark-article
8317 (car expirable) gnus-canceled-mark)))
8318 (setq expirable (cdr expirable))))))
8319 (gnus-message 6 "Expiring articles...done")))))
8321 (defun gnus-summary-expire-articles-now ()
8322 "Expunge all expirable articles in the current group.
8323 This means that *all* articles that are marked as expirable will be
8324 deleted forever, right now."
8326 (or gnus-expert-user
8328 "Are you really, really, really sure you want to delete all these messages? ")
8330 (gnus-summary-expire-articles t))
8332 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8333 (defun gnus-summary-delete-article (&optional n)
8334 "Delete the N next (mail) articles.
8335 This command actually deletes articles. This is not a marking
8336 command. The article will disappear forever from your life, never to
8338 If N is negative, delete backwards.
8339 If N is nil and articles have been marked with the process mark,
8340 delete these instead."
8342 (unless (gnus-check-backend-function 'request-expire-articles
8343 gnus-newsgroup-name)
8344 (error "The current newsgroup does not support article deletion"))
8345 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8346 (error "Couldn't open server"))
8347 ;; Compute the list of articles to delete.
8348 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8350 (if (and gnus-novice-user
8351 (not (gnus-yes-or-no-p
8352 (format "Do you really want to delete %s forever? "
8353 (if (> (length articles) 1)
8354 (format "these %s articles" (length articles))
8357 ;; Delete the articles.
8358 (setq not-deleted (gnus-request-expire-articles
8359 articles gnus-newsgroup-name 'force))
8361 (gnus-summary-remove-process-mark (car articles))
8362 ;; The backend might not have been able to delete the article
8364 (unless (memq (car articles) not-deleted)
8365 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8366 (setq articles (cdr articles)))
8368 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8369 (gnus-summary-position-point)
8370 (gnus-set-mode-line 'summary)
8373 (defun gnus-summary-edit-article (&optional force)
8374 "Edit the current article.
8375 This will have permanent effect only in mail groups.
8376 If FORCE is non-nil, allow editing of articles even in read-only
8380 (set-buffer gnus-summary-buffer)
8381 (let ((mail-parse-charset gnus-newsgroup-charset)
8382 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8383 (gnus-set-global-variables)
8384 (when (and (not force)
8385 (gnus-group-read-only-p))
8386 (error "The current newsgroup does not support article editing"))
8387 (gnus-summary-show-article t)
8388 (gnus-article-edit-article
8390 `(lambda (no-highlight)
8391 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8392 (message-options message-options)
8393 (message-options-set-recipient)
8394 (mail-parse-ignored-charsets
8395 ',gnus-newsgroup-ignored-charsets))
8396 (gnus-summary-edit-article-done
8397 ,(or (mail-header-references gnus-current-headers) "")
8398 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8400 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8402 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8404 "Make edits to the current article permanent."
8407 ;; The buffer restriction contains the entire article if it exists.
8408 (when (article-goto-body)
8409 (let ((lines (count-lines (point) (point-max)))
8410 (length (- (point-max) (point)))
8411 (case-fold-search t)
8412 (body (copy-marker (point))))
8413 (goto-char (point-min))
8414 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8415 (delete-region (match-beginning 1) (match-end 1))
8416 (insert (number-to-string length)))
8417 (goto-char (point-min))
8418 (when (re-search-forward
8419 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8420 (delete-region (match-beginning 1) (match-end 1))
8421 (insert (number-to-string length)))
8422 (goto-char (point-min))
8423 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8424 (delete-region (match-beginning 1) (match-end 1))
8425 (insert (number-to-string lines))))))
8426 ;; Replace the article.
8427 (let ((buf (current-buffer)))
8429 (insert-buffer-substring buf)
8431 (if (and (not read-only)
8432 (not (gnus-request-replace-article
8433 (cdr gnus-article-current) (car gnus-article-current)
8434 (current-buffer) t)))
8435 (error "Couldn't replace article")
8436 ;; Update the summary buffer.
8438 (equal (message-tokenize-header references " ")
8439 (message-tokenize-header
8440 (or (message-fetch-field "references") "") " ")))
8441 ;; We only have to update this line.
8444 (message-narrow-to-head)
8445 (let ((head (buffer-string))
8448 (insert (format "211 %d Article retrieved.\n"
8449 (cdr gnus-article-current)))
8452 (let ((nntp-server-buffer (current-buffer)))
8453 (setq header (car (gnus-get-newsgroup-headers
8455 (set-buffer gnus-summary-buffer)
8456 gnus-newsgroup-dependencies)
8459 (set-buffer gnus-summary-buffer)
8460 (gnus-data-set-header
8461 (gnus-data-find (cdr gnus-article-current))
8463 (gnus-summary-update-article-line
8464 (cdr gnus-article-current) header))))))
8466 (set-buffer (or buffer gnus-summary-buffer))
8467 (gnus-summary-update-article (cdr gnus-article-current)))
8468 ;; Prettify the article buffer again.
8469 (unless no-highlight
8471 (set-buffer gnus-article-buffer)
8472 ;;;!!! Fix this -- article should be rehighlighted.
8473 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8474 (set-buffer gnus-original-article-buffer)
8475 (gnus-request-article
8476 (cdr gnus-article-current)
8477 (car gnus-article-current) (current-buffer))))
8478 ;; Prettify the summary buffer line.
8479 (when (gnus-visual-p 'summary-highlight 'highlight)
8480 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8482 (defun gnus-summary-edit-wash (key)
8483 "Perform editing command KEY in the article buffer."
8487 (message "%s" (concat (this-command-keys) "- "))
8490 (gnus-summary-edit-article)
8491 (execute-kbd-macro (concat (this-command-keys) key))
8492 (gnus-article-edit-done))
8496 (defun gnus-summary-respool-query (&optional silent trace)
8497 "Query where the respool algorithm would put this article."
8499 (let (gnus-mark-article-hook)
8500 (gnus-summary-select-article)
8502 (set-buffer gnus-original-article-buffer)
8504 (message-narrow-to-head)
8505 (let ((groups (nnmail-article-group 'identity trace)))
8508 (message "This message would go to %s"
8509 (mapconcat 'car groups ", "))
8510 (message "This message would go to no groups"))
8513 (defun gnus-summary-respool-trace ()
8514 "Trace where the respool algorithm would put this article.
8515 Display a buffer showing all fancy splitting patterns which matched."
8517 (gnus-summary-respool-query nil t))
8519 ;; Summary marking commands.
8521 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8522 "Mark articles which has the same subject as read, and then select the next.
8523 If UNMARK is positive, remove any kind of mark.
8524 If UNMARK is negative, tick articles."
8527 (setq unmark (prefix-numeric-value unmark)))
8529 (gnus-summary-mark-same-subject
8530 (gnus-summary-article-subject) unmark)))
8531 ;; Select next unread article. If auto-select-same mode, should
8532 ;; select the first unread article.
8533 (gnus-summary-next-article t (and gnus-auto-select-same
8534 (gnus-summary-article-subject)))
8535 (gnus-message 7 "%d article%s marked as %s"
8536 count (if (= count 1) " is" "s are")
8537 (if unmark "unread" "read"))))
8539 (defun gnus-summary-kill-same-subject (&optional unmark)
8540 "Mark articles which has the same subject as read.
8541 If UNMARK is positive, remove any kind of mark.
8542 If UNMARK is negative, tick articles."
8545 (setq unmark (prefix-numeric-value unmark)))
8547 (gnus-summary-mark-same-subject
8548 (gnus-summary-article-subject) unmark)))
8549 ;; If marked as read, go to next unread subject.
8551 ;; Go to next unread subject.
8552 (gnus-summary-next-subject 1 t))
8553 (gnus-message 7 "%d articles are marked as %s"
8554 count (if unmark "unread" "read"))))
8556 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8557 "Mark articles with same SUBJECT as read, and return marked number.
8558 If optional argument UNMARK is positive, remove any kinds of marks.
8559 If optional argument UNMARK is negative, mark articles as unread instead."
8563 ((null unmark) ; Mark as read.
8566 (gnus-summary-mark-article-as-read gnus-killed-mark)
8567 (gnus-summary-show-thread) t)
8568 (gnus-summary-find-subject subject))
8569 (setq count (1+ count))))
8570 ((> unmark 0) ; Tick.
8573 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8574 (gnus-summary-show-thread) t)
8575 (gnus-summary-find-subject subject))
8576 (setq count (1+ count))))
8577 (t ; Mark as unread.
8580 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8581 (gnus-summary-show-thread) t)
8582 (gnus-summary-find-subject subject))
8583 (setq count (1+ count)))))
8584 (gnus-set-mode-line 'summary)
8585 ;; Return the number of marked articles.
8588 (defun gnus-summary-mark-as-processable (n &optional unmark)
8589 "Set the process mark on the next N articles.
8590 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8591 the process mark instead. The difference between N and the actual
8592 number of articles marked is returned."
8594 (if (and (null n) (gnus-region-active-p))
8595 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8596 (setq n (prefix-numeric-value n))
8597 (let ((backward (< n 0))
8602 (gnus-summary-remove-process-mark
8603 (gnus-summary-article-number))
8604 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8605 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8608 (gnus-message 7 "No more articles"))
8609 (gnus-summary-recenter)
8610 (gnus-summary-position-point)
8613 (defun gnus-summary-unmark-as-processable (n)
8614 "Remove the process mark from the next N articles.
8615 If N is negative, unmark backward instead. The difference between N and
8616 the actual number of articles unmarked is returned."
8618 (gnus-summary-mark-as-processable n t))
8620 (defun gnus-summary-unmark-all-processable ()
8621 "Remove the process mark from all articles."
8624 (while gnus-newsgroup-processable
8625 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8626 (gnus-summary-position-point))
8628 (defun gnus-summary-add-mark (article type)
8629 "Mark ARTICLE with a mark of TYPE."
8630 (let ((vtype (car (assq type gnus-article-mark-lists)))
8633 (error "No such mark type: %s" type)
8634 (setq var (intern (format "gnus-newsgroup-%s" type)))
8635 (set var (cons article (symbol-value var)))
8636 (if (memq type '(processable cached replied forwarded saved))
8637 (gnus-summary-update-secondary-mark article)
8638 ;;; !!! This is bobus. We should find out what primary
8639 ;;; !!! mark we want to set.
8640 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8642 (defun gnus-summary-mark-as-expirable (n)
8643 "Mark N articles forward as expirable.
8644 If N is negative, mark backward instead. The difference between N and
8645 the actual number of articles marked is returned."
8647 (gnus-summary-mark-forward n gnus-expirable-mark))
8649 (defun gnus-summary-mark-article-as-replied (article)
8650 "Mark ARTICLE as replied to and update the summary line.
8651 ARTICLE can also be a list of articles."
8652 (interactive (list (gnus-summary-article-number)))
8653 (let ((articles (if (listp article) article (list article))))
8654 (dolist (article articles)
8655 (push article gnus-newsgroup-replied)
8656 (let ((buffer-read-only nil))
8657 (when (gnus-summary-goto-subject article nil t)
8658 (gnus-summary-update-secondary-mark article))))))
8660 (defun gnus-summary-mark-article-as-forwarded (article)
8661 "Mark ARTICLE as forwarded and update the summary line.
8662 ARTICLE can also be a list of articles."
8663 (let ((articles (if (listp article) article (list article))))
8664 (dolist (article articles)
8665 (push article gnus-newsgroup-forwarded)
8666 (let ((buffer-read-only nil))
8667 (when (gnus-summary-goto-subject article nil t)
8668 (gnus-summary-update-secondary-mark article))))))
8670 (defun gnus-summary-set-bookmark (article)
8671 "Set a bookmark in current article."
8672 (interactive (list (gnus-summary-article-number)))
8673 (when (or (not (get-buffer gnus-article-buffer))
8674 (not gnus-current-article)
8675 (not gnus-article-current)
8676 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8677 (error "No current article selected"))
8678 ;; Remove old bookmark, if one exists.
8679 (let ((old (assq article gnus-newsgroup-bookmarks)))
8681 (setq gnus-newsgroup-bookmarks
8682 (delq old gnus-newsgroup-bookmarks))))
8683 ;; Set the new bookmark, which is on the form
8684 ;; (article-number . line-number-in-body).
8688 (set-buffer gnus-article-buffer)
8692 (goto-char (point-min))
8693 (search-forward "\n\n" nil t)
8696 gnus-newsgroup-bookmarks)
8697 (gnus-message 6 "A bookmark has been added to the current article."))
8699 (defun gnus-summary-remove-bookmark (article)
8700 "Remove the bookmark from the current article."
8701 (interactive (list (gnus-summary-article-number)))
8702 ;; Remove old bookmark, if one exists.
8703 (let ((old (assq article gnus-newsgroup-bookmarks)))
8706 (setq gnus-newsgroup-bookmarks
8707 (delq old gnus-newsgroup-bookmarks))
8708 (gnus-message 6 "Removed bookmark."))
8709 (gnus-message 6 "No bookmark in current article."))))
8711 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8712 (defun gnus-summary-mark-as-dormant (n)
8713 "Mark N articles forward as dormant.
8714 If N is negative, mark backward instead. The difference between N and
8715 the actual number of articles marked is returned."
8717 (gnus-summary-mark-forward n gnus-dormant-mark))
8719 (defun gnus-summary-set-process-mark (article)
8720 "Set the process mark on ARTICLE and update the summary line."
8721 (setq gnus-newsgroup-processable
8723 (delq article gnus-newsgroup-processable)))
8724 (when (gnus-summary-goto-subject article)
8725 (gnus-summary-show-thread)
8726 (gnus-summary-goto-subject article)
8727 (gnus-summary-update-secondary-mark article)))
8729 (defun gnus-summary-remove-process-mark (article)
8730 "Remove the process mark from ARTICLE and update the summary line."
8731 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8732 (when (gnus-summary-goto-subject article)
8733 (gnus-summary-show-thread)
8734 (gnus-summary-goto-subject article)
8735 (gnus-summary-update-secondary-mark article)))
8737 (defun gnus-summary-set-saved-mark (article)
8738 "Set the process mark on ARTICLE and update the summary line."
8739 (push article gnus-newsgroup-saved)
8740 (when (gnus-summary-goto-subject article)
8741 (gnus-summary-update-secondary-mark article)))
8743 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8744 "Mark N articles as read forwards.
8745 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8746 The difference between N and the actual number of articles marked is
8748 Iff NO-EXPIRE, auto-expiry will be inhibited."
8750 (gnus-summary-show-thread)
8751 (let ((backward (< n 0))
8752 (gnus-summary-goto-unread
8753 (and gnus-summary-goto-unread
8754 (not (eq gnus-summary-goto-unread 'never))
8755 (not (memq mark (list gnus-unread-mark
8756 gnus-ticked-mark gnus-dormant-mark)))))
8758 (mark (or mark gnus-del-mark)))
8760 (gnus-summary-mark-article nil mark no-expire)
8761 (zerop (gnus-summary-next-subject
8763 (and gnus-summary-goto-unread
8764 (not (eq gnus-summary-goto-unread 'never)))
8768 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8769 (gnus-summary-recenter)
8770 (gnus-summary-position-point)
8771 (gnus-set-mode-line 'summary)
8774 (defun gnus-summary-mark-article-as-read (mark)
8775 "Mark the current article quickly as read with MARK."
8776 (let ((article (gnus-summary-article-number)))
8777 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8778 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8779 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8780 (push (cons article mark) gnus-newsgroup-reads)
8781 ;; Possibly remove from cache, if that is used.
8782 (when gnus-use-cache
8783 (gnus-cache-enter-remove-article article))
8784 ;; Allow the backend to change the mark.
8785 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8786 ;; Check for auto-expiry.
8787 (when (and gnus-newsgroup-auto-expire
8788 (memq mark gnus-auto-expirable-marks))
8789 (setq mark gnus-expirable-mark)
8790 ;; Let the backend know about the mark change.
8791 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8792 (push article gnus-newsgroup-expirable))
8793 ;; Set the mark in the buffer.
8794 (gnus-summary-update-mark mark 'unread)
8797 (defun gnus-summary-mark-article-as-unread (mark)
8798 "Mark the current article quickly as unread with MARK."
8799 (let* ((article (gnus-summary-article-number))
8800 (old-mark (gnus-summary-article-mark article)))
8801 ;; Allow the backend to change the mark.
8802 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8803 (if (eq mark old-mark)
8807 (gnus-error 1 "Can't mark negative article numbers")
8809 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8810 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8811 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8812 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8813 (cond ((= mark gnus-ticked-mark)
8814 (push article gnus-newsgroup-marked))
8815 ((= mark gnus-dormant-mark)
8816 (push article gnus-newsgroup-dormant))
8818 (push article gnus-newsgroup-unreads)))
8819 (gnus-pull article gnus-newsgroup-reads)
8821 ;; See whether the article is to be put in the cache.
8823 (vectorp (gnus-summary-article-header article))
8825 (gnus-cache-possibly-enter-article
8826 gnus-newsgroup-name article
8827 (gnus-summary-article-header article)
8828 (= mark gnus-ticked-mark)
8829 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8832 (gnus-summary-update-mark mark 'unread)
8835 (defun gnus-summary-mark-article (&optional article mark no-expire)
8836 "Mark ARTICLE with MARK. MARK can be any character.
8837 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8838 `??' (dormant) and `?E' (expirable).
8839 If MARK is nil, then the default character `?r' is used.
8840 If ARTICLE is nil, then the article on the current line will be
8842 Iff NO-EXPIRE, auto-expiry will be inhibited."
8843 ;; The mark might be a string.
8844 (when (stringp mark)
8845 (setq mark (aref mark 0)))
8846 ;; If no mark is given, then we check auto-expiring.
8848 (setq mark gnus-del-mark))
8849 (when (and (not no-expire)
8850 gnus-newsgroup-auto-expire
8851 (memq mark gnus-auto-expirable-marks))
8852 (setq mark gnus-expirable-mark))
8853 (let ((article (or article (gnus-summary-article-number)))
8854 (old-mark (gnus-summary-article-mark article)))
8855 ;; Allow the backend to change the mark.
8856 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8857 (if (eq mark old-mark)
8860 (error "No article on current line"))
8861 (if (not (if (or (= mark gnus-unread-mark)
8862 (= mark gnus-ticked-mark)
8863 (= mark gnus-dormant-mark))
8864 (gnus-mark-article-as-unread article mark)
8865 (gnus-mark-article-as-read article mark)))
8867 ;; See whether the article is to be put in the cache.
8869 (not (= mark gnus-canceled-mark))
8870 (vectorp (gnus-summary-article-header article))
8872 (gnus-cache-possibly-enter-article
8873 gnus-newsgroup-name article
8874 (gnus-summary-article-header article)
8875 (= mark gnus-ticked-mark)
8876 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8878 (when (gnus-summary-goto-subject article nil t)
8879 (let ((buffer-read-only nil))
8880 (gnus-summary-show-thread)
8882 (gnus-summary-update-mark mark 'unread)
8885 (defun gnus-summary-update-secondary-mark (article)
8886 "Update the secondary (read, process, cache) mark."
8887 (gnus-summary-update-mark
8888 (cond ((memq article gnus-newsgroup-processable)
8890 ((memq article gnus-newsgroup-cached)
8892 ((memq article gnus-newsgroup-replied)
8894 ((memq article gnus-newsgroup-forwarded)
8895 gnus-forwarded-mark)
8896 ((memq article gnus-newsgroup-saved)
8900 (when (gnus-visual-p 'summary-highlight 'highlight)
8901 (gnus-run-hooks 'gnus-summary-update-hook))
8904 (defun gnus-summary-update-mark (mark type)
8905 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8906 (buffer-read-only nil))
8907 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8909 (when (looking-at "\r")
8911 (when (<= (+ forward (point)) (point-max))
8912 ;; Go to the right position on the line.
8913 (goto-char (+ forward (point)))
8914 ;; Replace the old mark with the new mark.
8915 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8916 ;; Optionally update the marks by some user rule.
8917 (when (eq type 'unread)
8919 (gnus-data-find (gnus-summary-article-number)) mark)
8920 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8922 (defun gnus-mark-article-as-read (article &optional mark)
8923 "Enter ARTICLE in the pertinent lists and remove it from others."
8924 ;; Make the article expirable.
8925 (let ((mark (or mark gnus-del-mark)))
8926 (if (= mark gnus-expirable-mark)
8927 (push article gnus-newsgroup-expirable)
8928 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8929 ;; Remove from unread and marked lists.
8930 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8931 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8932 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8933 (push (cons article mark) gnus-newsgroup-reads)
8934 ;; Possibly remove from cache, if that is used.
8935 (when gnus-use-cache
8936 (gnus-cache-enter-remove-article article))
8939 (defun gnus-mark-article-as-unread (article &optional mark)
8940 "Enter ARTICLE in the pertinent lists and remove it from others."
8941 (let ((mark (or mark gnus-ticked-mark)))
8944 (gnus-error 1 "Can't mark negative article numbers")
8946 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8947 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8948 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8949 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8951 ;; Unsuppress duplicates?
8952 (when gnus-suppress-duplicates
8953 (gnus-dup-unsuppress-article article))
8955 (cond ((= mark gnus-ticked-mark)
8956 (push article gnus-newsgroup-marked))
8957 ((= mark gnus-dormant-mark)
8958 (push article gnus-newsgroup-dormant))
8960 (push article gnus-newsgroup-unreads)))
8961 (gnus-pull article gnus-newsgroup-reads)
8964 (defalias 'gnus-summary-mark-as-unread-forward
8965 'gnus-summary-tick-article-forward)
8966 (make-obsolete 'gnus-summary-mark-as-unread-forward
8967 'gnus-summary-tick-article-forward)
8968 (defun gnus-summary-tick-article-forward (n)
8969 "Tick N articles forwards.
8970 If N is negative, tick backwards instead.
8971 The difference between N and the number of articles ticked is returned."
8973 (gnus-summary-mark-forward n gnus-ticked-mark))
8975 (defalias 'gnus-summary-mark-as-unread-backward
8976 'gnus-summary-tick-article-backward)
8977 (make-obsolete 'gnus-summary-mark-as-unread-backward
8978 'gnus-summary-tick-article-backward)
8979 (defun gnus-summary-tick-article-backward (n)
8980 "Tick N articles backwards.
8981 The difference between N and the number of articles ticked is returned."
8983 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8985 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8986 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8987 (defun gnus-summary-tick-article (&optional article clear-mark)
8988 "Mark current article as unread.
8989 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8990 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8992 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8995 (defun gnus-summary-mark-as-read-forward (n)
8996 "Mark N articles as read forwards.
8997 If N is negative, mark backwards instead.
8998 The difference between N and the actual number of articles marked is
9001 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9003 (defun gnus-summary-mark-as-read-backward (n)
9004 "Mark the N articles as read backwards.
9005 The difference between N and the actual number of articles marked is
9008 (gnus-summary-mark-forward
9009 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9011 (defun gnus-summary-mark-as-read (&optional article mark)
9012 "Mark current article as read.
9013 ARTICLE specifies the article to be marked as read.
9014 MARK specifies a string to be inserted at the beginning of the line."
9015 (gnus-summary-mark-article article mark))
9017 (defun gnus-summary-clear-mark-forward (n)
9018 "Clear marks from N articles forward.
9019 If N is negative, clear backward instead.
9020 The difference between N and the number of marks cleared is returned."
9022 (gnus-summary-mark-forward n gnus-unread-mark))
9024 (defun gnus-summary-clear-mark-backward (n)
9025 "Clear marks from N articles backward.
9026 The difference between N and the number of marks cleared is returned."
9028 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9030 (defun gnus-summary-mark-unread-as-read ()
9031 "Intended to be used by `gnus-summary-mark-article-hook'."
9032 (when (memq gnus-current-article gnus-newsgroup-unreads)
9033 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9035 (defun gnus-summary-mark-read-and-unread-as-read ()
9036 "Intended to be used by `gnus-summary-mark-article-hook'."
9037 (let ((mark (gnus-summary-article-mark)))
9038 (when (or (gnus-unread-mark-p mark)
9039 (gnus-read-mark-p mark))
9040 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9042 (defun gnus-summary-mark-unread-as-ticked ()
9043 "Intended to be used by `gnus-summary-mark-article-hook'."
9044 (when (memq gnus-current-article gnus-newsgroup-unreads)
9045 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9047 (defun gnus-summary-mark-region-as-read (point mark all)
9048 "Mark all unread articles between point and mark as read.
9049 If given a prefix, mark all articles between point and mark as read,
9050 even ticked and dormant ones."
9051 (interactive "r\nP")
9060 (memq (setq article (gnus-summary-article-number))
9061 gnus-newsgroup-unreads))
9062 (gnus-summary-mark-article article gnus-del-mark))
9064 (gnus-summary-find-next))))))
9066 (defun gnus-summary-mark-below (score mark)
9067 "Mark articles with score less than SCORE with MARK."
9068 (interactive "P\ncMark: ")
9069 (setq score (if score
9070 (prefix-numeric-value score)
9071 (or gnus-summary-default-score 0)))
9073 (set-buffer gnus-summary-buffer)
9074 (goto-char (point-min))
9077 (and (< (gnus-summary-article-score) score)
9078 (gnus-summary-mark-article nil mark))
9079 (gnus-summary-find-next)))))
9081 (defun gnus-summary-kill-below (&optional score)
9082 "Mark articles with score below SCORE as read."
9084 (gnus-summary-mark-below score gnus-killed-mark))
9086 (defun gnus-summary-clear-above (&optional score)
9087 "Clear all marks from articles with score above SCORE."
9089 (gnus-summary-mark-above score gnus-unread-mark))
9091 (defun gnus-summary-tick-above (&optional score)
9092 "Tick all articles with score above SCORE."
9094 (gnus-summary-mark-above score gnus-ticked-mark))
9096 (defun gnus-summary-mark-above (score mark)
9097 "Mark articles with score over SCORE with MARK."
9098 (interactive "P\ncMark: ")
9099 (setq score (if score
9100 (prefix-numeric-value score)
9101 (or gnus-summary-default-score 0)))
9103 (set-buffer gnus-summary-buffer)
9104 (goto-char (point-min))
9106 (when (> (gnus-summary-article-score) score)
9107 (gnus-summary-mark-article nil mark))
9109 (gnus-summary-find-next)))))
9111 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9112 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9113 (defun gnus-summary-limit-include-expunged (&optional no-error)
9114 "Display all the hidden articles that were expunged for low scores."
9116 (let ((buffer-read-only nil))
9117 (let ((scored gnus-newsgroup-scored)
9120 (unless (gnus-summary-article-header (caar scored))
9121 (and (setq h (gnus-number-to-header (caar scored)))
9122 (< (cdar scored) gnus-summary-expunge-below)
9124 (setq scored (cdr scored)))
9126 (when (not no-error)
9127 (error "No expunged articles hidden"))
9128 (goto-char (point-min))
9129 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9130 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9131 (mapcar (lambda (x) (push (mail-header-number x)
9132 gnus-newsgroup-limit))
9134 (gnus-summary-prepare-unthreaded (nreverse headers))
9135 (goto-char (point-min))
9136 (gnus-summary-position-point)
9139 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9140 "Mark all unread articles in this newsgroup as read.
9141 If prefix argument ALL is non-nil, ticked and dormant articles will
9142 also be marked as read.
9143 If QUIETLY is non-nil, no questions will be asked.
9144 If TO-HERE is non-nil, it should be a point in the buffer. All
9145 articles before (after, if REVERSE is set) this point will be marked as read.
9146 Note that this function will only catch up the unread article
9147 in the current summary buffer limitation.
9148 The number of articles marked as read is returned."
9153 (not gnus-interactive-catchup) ;Without confirmation?
9157 "Mark absolutely all articles as read? "
9158 "Mark all unread articles as read? ")))
9160 (not gnus-newsgroup-adaptive)
9161 (not gnus-newsgroup-auto-expire)
9162 (not gnus-suppress-duplicates)
9163 (or (not gnus-use-cache)
9164 (eq gnus-use-cache 'passive)))
9167 (setq gnus-newsgroup-marked nil
9168 gnus-newsgroup-dormant nil))
9169 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9170 ;; We actually mark all articles as canceled, which we
9171 ;; have to do when using auto-expiry or adaptive scoring.
9172 (gnus-summary-show-all-threads)
9173 (if (and to-here reverse)
9177 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9178 (gnus-summary-find-next (not all) nil nil t))))
9179 (when (gnus-summary-first-subject (not all) t)
9181 (if to-here (< (point) to-here) t)
9182 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9183 (gnus-summary-find-next (not all) nil nil t)))))
9184 (gnus-set-mode-line 'summary))
9186 (gnus-summary-position-point)))
9188 (defun gnus-summary-catchup-to-here (&optional all)
9189 "Mark all unticked articles before the current one as read.
9190 If ALL is non-nil, also mark ticked and dormant articles as read."
9193 (gnus-save-hidden-threads
9194 (let ((beg (point)))
9195 ;; We check that there are unread articles.
9196 (when (or all (gnus-summary-find-prev))
9197 (gnus-summary-catchup all t beg)))))
9198 (gnus-summary-position-point))
9200 (defun gnus-summary-catchup-from-here (&optional all)
9201 "Mark all unticked articles after the current one as read.
9202 If ALL is non-nil, also mark ticked and dormant articles as read."
9205 (gnus-save-hidden-threads
9206 (let ((beg (point)))
9207 ;; We check that there are unread articles.
9208 (when (or all (gnus-summary-find-next))
9209 (gnus-summary-catchup all t beg nil t)))))
9210 (gnus-summary-position-point))
9212 (defun gnus-summary-catchup-all (&optional quietly)
9213 "Mark all articles in this newsgroup as read."
9215 (gnus-summary-catchup t quietly))
9217 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9218 "Mark all unread articles in this group as read, then exit.
9219 If prefix argument ALL is non-nil, all articles are marked as read.
9220 If QUIETLY is non-nil, no questions will be asked."
9222 (when (gnus-summary-catchup all quietly nil 'fast)
9223 ;; Select next newsgroup or exit.
9224 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9225 (eq gnus-auto-select-next 'quietly))
9226 (gnus-summary-next-group nil)
9227 (gnus-summary-exit))))
9229 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9230 "Mark all articles in this newsgroup as read, and then exit."
9232 (gnus-summary-catchup-and-exit t quietly))
9234 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9235 "Mark all articles in this group as read and select the next group.
9236 If given a prefix, mark all articles, unread as well as ticked, as
9240 (gnus-summary-catchup all))
9241 (gnus-summary-next-group))
9247 (defmacro gnus-with-article (article &rest forms)
9248 "Select ARTICLE and perform FORMS in the original article buffer.
9249 Then replace the article with the result."
9251 ;; We don't want the article to be marked as read.
9252 (let (gnus-mark-article-hook)
9253 (gnus-summary-select-article t t nil ,article))
9254 (set-buffer gnus-original-article-buffer)
9256 (if (not (gnus-check-backend-function
9257 'request-replace-article (car gnus-article-current)))
9258 (gnus-message 5 "Read-only group; not replacing")
9259 (unless (gnus-request-replace-article
9260 ,article (car gnus-article-current)
9262 (error "Couldn't replace article")))
9263 ;; The cache and backlog have to be flushed somewhat.
9264 (when gnus-keep-backlog
9265 (gnus-backlog-remove-article
9266 (car gnus-article-current) (cdr gnus-article-current)))
9267 (when gnus-use-cache
9268 (gnus-cache-update-article
9269 (car gnus-article-current) (cdr gnus-article-current)))))
9271 (put 'gnus-with-article 'lisp-indent-function 1)
9272 (put 'gnus-with-article 'edebug-form-spec '(form body))
9274 ;; Thread-based commands.
9276 (defun gnus-summary-articles-in-thread (&optional article)
9277 "Return a list of all articles in the current thread.
9278 If ARTICLE is non-nil, return all articles in the thread that starts
9280 (let* ((article (or article (gnus-summary-article-number)))
9281 (data (gnus-data-find-list article))
9282 (top-level (gnus-data-level (car data)))
9284 (cond ((null gnus-thread-operation-ignore-subject)
9285 (gnus-simplify-subject-re
9286 (mail-header-subject (gnus-data-header (car data)))))
9287 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9288 (gnus-simplify-subject-fuzzy
9289 (mail-header-subject (gnus-data-header (car data)))))
9291 (end-point (save-excursion
9292 (if (gnus-summary-go-to-next-thread)
9293 (point) (point-max))))
9296 (< (gnus-data-pos (car data)) end-point))
9297 (when (or (not top-subject)
9298 (string= top-subject
9299 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9300 (gnus-simplify-subject-fuzzy
9301 (mail-header-subject
9302 (gnus-data-header (car data))))
9303 (gnus-simplify-subject-re
9304 (mail-header-subject
9305 (gnus-data-header (car data)))))))
9306 (push (gnus-data-number (car data)) articles))
9307 (unless (and (setq data (cdr data))
9308 (> (gnus-data-level (car data)) top-level))
9310 ;; Return the list of articles.
9311 (nreverse articles)))
9313 (defun gnus-summary-rethread-current ()
9314 "Rethread the thread the current article is part of."
9316 (let* ((gnus-show-threads t)
9317 (article (gnus-summary-article-number))
9318 (id (mail-header-id (gnus-summary-article-header)))
9319 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9321 (error "No article on the current line"))
9322 (gnus-rebuild-thread id)
9323 (gnus-summary-goto-subject article)))
9325 (defun gnus-summary-reparent-thread ()
9326 "Make the current article child of the marked (or previous) article.
9328 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9329 is non-nil or the Subject: of both articles are the same."
9331 (unless (not (gnus-group-read-only-p))
9332 (error "The current newsgroup does not support article editing"))
9333 (unless (<= (length gnus-newsgroup-processable) 1)
9334 (error "No more than one article may be marked"))
9335 (save-window-excursion
9336 (let ((gnus-article-buffer " *reparent*")
9337 (current-article (gnus-summary-article-number))
9338 ;; First grab the marked article, otherwise one line up.
9339 (parent-article (if (not (null gnus-newsgroup-processable))
9340 (car gnus-newsgroup-processable)
9342 (if (eq (forward-line -1) 0)
9343 (gnus-summary-article-number)
9344 (error "Beginning of summary buffer"))))))
9345 (unless (not (eq current-article parent-article))
9346 (error "An article may not be self-referential"))
9347 (let ((message-id (mail-header-id
9348 (gnus-summary-article-header parent-article))))
9349 (unless (and message-id (not (equal message-id "")))
9350 (error "No message-id in desired parent"))
9351 (gnus-with-article current-article
9353 (goto-char (point-min))
9354 (message-narrow-to-head)
9355 (if (re-search-forward "^References: " nil t)
9357 (re-search-forward "^[^ \t]" nil t)
9360 (insert " " message-id))
9361 (insert "References: " message-id "\n"))))
9362 (set-buffer gnus-summary-buffer)
9363 (gnus-summary-unmark-all-processable)
9364 (gnus-summary-update-article current-article)
9365 (gnus-summary-rethread-current)
9366 (gnus-message 3 "Article %d is now the child of article %d"
9367 current-article parent-article)))))
9369 (defun gnus-summary-toggle-threads (&optional arg)
9370 "Toggle showing conversation threads.
9371 If ARG is positive number, turn showing conversation threads on."
9373 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9374 (setq gnus-show-threads
9375 (if (null arg) (not gnus-show-threads)
9376 (> (prefix-numeric-value arg) 0)))
9377 (gnus-summary-prepare)
9378 (gnus-summary-goto-subject current)
9379 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9380 (gnus-summary-position-point)))
9382 (defun gnus-summary-show-all-threads ()
9386 (let ((buffer-read-only nil))
9387 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9388 (gnus-summary-position-point))
9390 (defun gnus-summary-show-thread ()
9391 "Show thread subtrees.
9392 Returns nil if no thread was there to be shown."
9394 (let ((buffer-read-only nil)
9396 ;; first goto end then to beg, to have point at beg after let
9397 (end (progn (end-of-line) (point)))
9398 (beg (progn (beginning-of-line) (point))))
9400 ;; Any hidden lines here?
9401 (search-forward "\r" end t)
9402 (subst-char-in-region beg end ?\^M ?\n t)
9404 (gnus-summary-position-point))))
9406 (defun gnus-summary-hide-all-threads ()
9407 "Hide all thread subtrees."
9410 (goto-char (point-min))
9411 (gnus-summary-hide-thread)
9412 (while (zerop (gnus-summary-next-thread 1 t))
9413 (gnus-summary-hide-thread)))
9414 (gnus-summary-position-point))
9416 (defun gnus-summary-hide-thread ()
9417 "Hide thread subtrees.
9418 Returns nil if no threads were there to be hidden."
9420 (let ((buffer-read-only nil)
9422 (article (gnus-summary-article-number)))
9424 ;; Go forward until either the buffer ends or the subthread
9426 (when (and (not (eobp))
9427 (or (zerop (gnus-summary-next-thread 1 t))
9428 (goto-char (point-max))))
9430 (if (and (> (point) start)
9431 (search-backward "\n" start t))
9433 (subst-char-in-region start (point) ?\n ?\^M)
9434 (gnus-summary-goto-subject article))
9438 (defun gnus-summary-go-to-next-thread (&optional previous)
9439 "Go to the same level (or less) next thread.
9440 If PREVIOUS is non-nil, go to previous thread instead.
9441 Return the article number moved to, or nil if moving was impossible."
9442 (let ((level (gnus-summary-thread-level))
9443 (way (if previous -1 1))
9446 (while (and (not (eobp))
9447 (< level (gnus-summary-thread-level)))
9455 (gnus-summary-article-number)
9458 (defun gnus-summary-next-thread (n &optional silent)
9459 "Go to the same level next N'th thread.
9460 If N is negative, search backward instead.
9461 Returns the difference between N and the number of skips actually
9464 If SILENT, don't output messages."
9466 (let ((backward (< n 0))
9469 (gnus-summary-go-to-next-thread backward))
9472 (gnus-summary-position-point))
9473 (when (and (not silent) (/= 0 n))
9474 (gnus-message 7 "No more threads"))
9477 (defun gnus-summary-prev-thread (n)
9478 "Go to the same level previous N'th thread.
9479 Returns the difference between N and the number of skips actually
9482 (gnus-summary-next-thread (- n)))
9484 (defun gnus-summary-go-down-thread ()
9485 "Go down one level in the current thread."
9486 (let ((children (gnus-summary-article-children)))
9488 (gnus-summary-goto-subject (car children)))))
9490 (defun gnus-summary-go-up-thread ()
9491 "Go up one level in the current thread."
9492 (let ((parent (gnus-summary-article-parent)))
9494 (gnus-summary-goto-subject parent))))
9496 (defun gnus-summary-down-thread (n)
9497 "Go down thread N steps.
9498 If N is negative, go up instead.
9499 Returns the difference between N and how many steps down that were
9505 (if up (gnus-summary-go-up-thread)
9506 (gnus-summary-go-down-thread)))
9508 (gnus-summary-position-point)
9510 (gnus-message 7 "Can't go further"))
9513 (defun gnus-summary-up-thread (n)
9514 "Go up thread N steps.
9515 If N is negative, go down instead.
9516 Returns the difference between N and how many steps down that were
9519 (gnus-summary-down-thread (- n)))
9521 (defun gnus-summary-top-thread ()
9522 "Go to the top of the thread."
9524 (while (gnus-summary-go-up-thread))
9525 (gnus-summary-article-number))
9527 (defun gnus-summary-kill-thread (&optional unmark)
9528 "Mark articles under current thread as read.
9529 If the prefix argument is positive, remove any kinds of marks.
9530 If the prefix argument is negative, tick articles instead."
9533 (setq unmark (prefix-numeric-value unmark)))
9534 (let ((articles (gnus-summary-articles-in-thread)))
9536 ;; Expand the thread.
9537 (gnus-summary-show-thread)
9538 ;; Mark all the articles.
9540 (gnus-summary-goto-subject (car articles))
9541 (cond ((null unmark)
9542 (gnus-summary-mark-article-as-read gnus-killed-mark))
9544 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9546 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9547 (setq articles (cdr articles))))
9548 ;; Hide killed subtrees.
9550 gnus-thread-hide-killed
9551 (gnus-summary-hide-thread))
9552 ;; If marked as read, go to next unread subject.
9554 ;; Go to next unread subject.
9555 (gnus-summary-next-subject 1 t)))
9556 (gnus-set-mode-line 'summary))
9558 ;; Summary sorting commands
9560 (defun gnus-summary-sort-by-number (&optional reverse)
9561 "Sort the summary buffer by article number.
9562 Argument REVERSE means reverse order."
9564 (gnus-summary-sort 'number reverse))
9566 (defun gnus-summary-sort-by-author (&optional reverse)
9567 "Sort the summary buffer by author name alphabetically.
9568 If `case-fold-search' is non-nil, case of letters is ignored.
9569 Argument REVERSE means reverse order."
9571 (gnus-summary-sort 'author reverse))
9573 (defun gnus-summary-sort-by-subject (&optional reverse)
9574 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9575 If `case-fold-search' is non-nil, case of letters is ignored.
9576 Argument REVERSE means reverse order."
9578 (gnus-summary-sort 'subject reverse))
9580 (defun gnus-summary-sort-by-date (&optional reverse)
9581 "Sort the summary buffer by date.
9582 Argument REVERSE means reverse order."
9584 (gnus-summary-sort 'date reverse))
9586 (defun gnus-summary-sort-by-score (&optional reverse)
9587 "Sort the summary buffer by score.
9588 Argument REVERSE means reverse order."
9590 (gnus-summary-sort 'score reverse))
9592 (defun gnus-summary-sort-by-lines (&optional reverse)
9593 "Sort the summary buffer by the number of lines.
9594 Argument REVERSE means reverse order."
9596 (gnus-summary-sort 'lines reverse))
9598 (defun gnus-summary-sort-by-chars (&optional reverse)
9599 "Sort the summary buffer by article length.
9600 Argument REVERSE means reverse order."
9602 (gnus-summary-sort 'chars reverse))
9604 (defun gnus-summary-sort-by-original (&optional reverse)
9605 "Sort the summary buffer using the default sorting method.
9606 Argument REVERSE means reverse order."
9608 (let* ((buffer-read-only)
9609 (gnus-summary-prepare-hook nil))
9610 ;; We do the sorting by regenerating the threads.
9611 (gnus-summary-prepare)
9612 ;; Hide subthreads if needed.
9613 (when (and gnus-show-threads gnus-thread-hide-subtree)
9614 (gnus-summary-hide-all-threads))))
9616 (defun gnus-summary-sort (predicate reverse)
9617 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9618 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9619 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9620 (gnus-thread-sort-functions
9625 (gnus-sort-gathered-threads-function
9626 gnus-thread-sort-functions)
9627 (gnus-article-sort-functions
9633 (gnus-summary-prepare-hook nil))
9634 ;; We do the sorting by regenerating the threads.
9635 (gnus-summary-prepare)
9636 ;; Hide subthreads if needed.
9637 (when (and gnus-show-threads gnus-thread-hide-subtree)
9638 (gnus-summary-hide-all-threads))))
9640 ;; Summary saving commands.
9642 (defun gnus-summary-save-article (&optional n not-saved)
9643 "Save the current article using the default saver function.
9644 If N is a positive number, save the N next articles.
9645 If N is a negative number, save the N previous articles.
9646 If N is nil and any articles have been marked with the process mark,
9647 save those articles instead.
9648 The variable `gnus-default-article-saver' specifies the saver function."
9650 (let* ((articles (gnus-summary-work-articles n))
9651 (save-buffer (save-excursion
9652 (nnheader-set-temp-buffer " *Gnus Save*")))
9653 (num (length articles))
9655 (dolist (article articles)
9656 (setq header (gnus-summary-article-header article))
9657 (if (not (vectorp header))
9658 ;; This is a pseudo-article.
9659 (if (assq 'name header)
9660 (gnus-copy-file (cdr (assq 'name header)))
9661 (gnus-message 1 "Article %d is unsaveable" article))
9662 ;; This is a real article.
9663 (save-window-excursion
9664 (gnus-summary-select-article t nil nil article))
9666 (set-buffer save-buffer)
9668 (insert-buffer-substring gnus-original-article-buffer))
9669 (setq file (gnus-article-save save-buffer file num))
9670 (gnus-summary-remove-process-mark article)
9672 (gnus-summary-set-saved-mark article))))
9673 (gnus-kill-buffer save-buffer)
9674 (gnus-summary-position-point)
9675 (gnus-set-mode-line 'summary)
9678 (defun gnus-summary-pipe-output (&optional arg)
9679 "Pipe the current article to a subprocess.
9680 If N is a positive number, pipe the N next articles.
9681 If N is a negative number, pipe the N previous articles.
9682 If N is nil and any articles have been marked with the process mark,
9683 pipe those articles instead."
9686 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9687 (gnus-summary-save-article arg t))
9688 (gnus-configure-windows 'pipe))
9690 (defun gnus-summary-save-article-mail (&optional arg)
9691 "Append the current article to an mail file.
9692 If N is a positive number, save the N next articles.
9693 If N is a negative number, save the N previous articles.
9694 If N is nil and any articles have been marked with the process mark,
9695 save those articles instead."
9698 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9699 (gnus-summary-save-article arg)))
9701 (defun gnus-summary-save-article-rmail (&optional arg)
9702 "Append the current article to an rmail file.
9703 If N is a positive number, save the N next articles.
9704 If N is a negative number, save the N previous articles.
9705 If N is nil and any articles have been marked with the process mark,
9706 save those articles instead."
9709 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9710 (gnus-summary-save-article arg)))
9712 (defun gnus-summary-save-article-file (&optional arg)
9713 "Append the current article to a file.
9714 If N is a positive number, save the N next articles.
9715 If N is a negative number, save the N previous articles.
9716 If N is nil and any articles have been marked with the process mark,
9717 save those articles instead."
9720 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9721 (gnus-summary-save-article arg)))
9723 (defun gnus-summary-write-article-file (&optional arg)
9724 "Write the current article to a file, deleting the previous file.
9725 If N is a positive number, save the N next articles.
9726 If N is a negative number, save the N previous articles.
9727 If N is nil and any articles have been marked with the process mark,
9728 save those articles instead."
9731 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9732 (gnus-summary-save-article arg)))
9734 (defun gnus-summary-save-article-body-file (&optional arg)
9735 "Append the current article body to a file.
9736 If N is a positive number, save the N next articles.
9737 If N is a negative number, save the N previous articles.
9738 If N is nil and any articles have been marked with the process mark,
9739 save those articles instead."
9742 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9743 (gnus-summary-save-article arg)))
9745 (defun gnus-summary-pipe-message (program)
9746 "Pipe the current article through PROGRAM."
9747 (interactive "sProgram: ")
9748 (gnus-summary-select-article)
9749 (let ((mail-header-separator ""))
9750 (gnus-eval-in-buffer-window gnus-article-buffer
9753 (let ((start (window-start))
9755 (message-pipe-buffer-body program)
9756 (set-window-start (get-buffer-window (current-buffer)) start))))))
9758 (defun gnus-get-split-value (methods)
9759 "Return a value based on the split METHODS."
9760 (let (split-name method result match)
9763 (set-buffer gnus-original-article-buffer)
9765 (nnheader-narrow-to-headers)
9766 (while (and methods (not split-name))
9767 (goto-char (point-min))
9768 (setq method (pop methods))
9769 (setq match (car method))
9772 ;; Regular expression.
9774 (re-search-forward match nil t)))
9775 ((gnus-functionp match)
9779 (setq result (funcall match gnus-newsgroup-name))))
9784 (setq result (eval match)))))
9785 (setq split-name (cdr method))
9786 (cond ((stringp result)
9787 (push (expand-file-name
9788 result gnus-article-save-directory)
9791 (setq split-name (append result split-name)))))))))
9792 (nreverse split-name)))
9794 (defun gnus-valid-move-group-p (group)
9797 (symbol-value group)
9798 (gnus-get-function (gnus-find-method-for-group
9799 (symbol-name group)) 'request-accept-article t)))
9801 (defun gnus-read-move-group-name (prompt default articles prefix)
9802 "Read a group name."
9803 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9804 (minibuffer-confirm-incomplete nil) ; XEmacs
9808 (if (> (length articles) 1)
9809 (format "these %d articles" (length articles))
9814 (gnus-completing-read default prom
9816 'gnus-valid-move-group-p
9818 'gnus-group-history))
9819 ((= 1 (length split-name))
9820 (gnus-completing-read (car split-name) prom
9822 'gnus-valid-move-group-p
9824 'gnus-group-history))
9826 (gnus-completing-read nil prom
9827 (mapcar (lambda (el) (list el))
9828 (nreverse split-name))
9830 'gnus-group-history))))
9831 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9833 (if (or (string= to-newsgroup "")
9834 (string= to-newsgroup prefix))
9835 (setq to-newsgroup default))
9836 (unless to-newsgroup
9837 (error "No group name entered"))
9838 (or (gnus-active to-newsgroup)
9839 (gnus-activate-group to-newsgroup nil nil to-method)
9840 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9842 (or (and (gnus-request-create-group to-newsgroup to-method)
9843 (gnus-activate-group
9844 to-newsgroup nil nil to-method)
9845 (gnus-subscribe-group to-newsgroup))
9846 (error "Couldn't create group %s" to-newsgroup)))
9847 (error "No such group: %s" to-newsgroup)))
9850 (defun gnus-summary-save-parts (type dir n &optional reverse)
9851 "Save parts matching TYPE to DIR.
9852 If REVERSE, save parts that do not match TYPE."
9854 (list (read-string "Save parts of type: "
9855 (or (car gnus-summary-save-parts-type-history)
9856 gnus-summary-save-parts-default-mime)
9857 'gnus-summary-save-parts-type-history)
9858 (setq gnus-summary-save-parts-last-directory
9859 (read-file-name "Save to directory: "
9860 gnus-summary-save-parts-last-directory
9862 current-prefix-arg))
9863 (gnus-summary-iterate n
9864 (let ((gnus-display-mime-function nil)
9865 (gnus-inhibit-treatment t))
9866 (gnus-summary-select-article))
9868 (set-buffer gnus-article-buffer)
9869 (let ((handles (or gnus-article-mime-handles
9870 (mm-dissect-buffer) (mm-uu-dissect))))
9872 (gnus-summary-save-parts-1 type dir handles reverse)
9873 (unless gnus-article-mime-handles ;; Don't destroy this case.
9874 (mm-destroy-parts handles)))))))
9876 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9877 (if (stringp (car handle))
9878 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9881 (not (string-match type (mm-handle-media-type handle)))
9882 (string-match type (mm-handle-media-type handle)))
9883 (let ((file (expand-file-name
9884 (file-name-nondirectory
9886 (mail-content-type-get
9887 (mm-handle-disposition handle) 'filename)
9888 (concat gnus-newsgroup-name
9889 "." (number-to-string
9890 (cdr gnus-article-current)))))
9892 (unless (file-exists-p file)
9893 (mm-save-part-to-file handle file))))))
9895 ;; Summary extract commands
9897 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9898 (let ((buffer-read-only nil)
9899 (article (gnus-summary-article-number))
9901 (unless (gnus-summary-goto-subject article)
9902 (error "No such article: %d" article))
9903 (gnus-summary-position-point)
9904 ;; If all commands are to be bunched up on one line, we collect
9906 (unless gnus-view-pseudos-separately
9907 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9910 (setq action (cdr (assq 'action (car ps))))
9911 (setq files (list (cdr (assq 'name (car ps)))))
9912 (while (and ps (cdr ps)
9913 (string= (or action "1")
9914 (or (cdr (assq 'action (cadr ps))) "2")))
9915 (push (cdr (assq 'name (cadr ps))) files)
9916 (setcdr ps (cddr ps)))
9918 (when (not (string-match "%s" action))
9921 (when (assq 'execute (car ps))
9922 (setcdr (assq 'execute (car ps))
9923 (funcall (if (string-match "%s" action)
9930 (gnus-quote-arg-for-sh-or-csh f)))
9932 (setq ps (cdr ps)))))
9933 (if (and gnus-view-pseudos (not not-view))
9935 (when (assq 'execute (car pslist))
9936 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9937 (eq gnus-view-pseudos 'not-confirm)))
9938 (setq pslist (cdr pslist)))
9941 (setq after-article (or (cdr (assq 'article (car pslist)))
9942 (gnus-summary-article-number)))
9943 (gnus-summary-goto-subject after-article)
9946 (insert " " (file-name-nondirectory
9947 (cdr (assq 'name (car pslist))))
9948 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9950 (forward-line -1) ; back to `b'
9951 (gnus-add-text-properties
9952 b (1- e) (list 'gnus-number gnus-reffed-article-number
9953 gnus-mouse-face-prop gnus-mouse-face))
9955 after-article gnus-reffed-article-number
9956 gnus-unread-mark b (car pslist) 0 (- e b))
9957 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9958 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9959 (setq pslist (cdr pslist)))))))
9961 (defun gnus-pseudos< (p1 p2)
9962 (let ((c1 (cdr (assq 'action p1)))
9963 (c2 (cdr (assq 'action p2))))
9964 (and c1 c2 (string< c1 c2))))
9966 (defun gnus-request-pseudo-article (props)
9967 (cond ((assq 'execute props)
9968 (gnus-execute-command (cdr (assq 'execute props)))))
9969 (let ((gnus-current-article (gnus-summary-article-number)))
9970 (gnus-run-hooks 'gnus-mark-article-hook)))
9972 (defun gnus-execute-command (command &optional automatic)
9974 (gnus-article-setup-buffer)
9975 (set-buffer gnus-article-buffer)
9976 (setq buffer-read-only nil)
9977 (let ((command (if automatic command
9978 (read-string "Command: " (cons command 0)))))
9980 (insert "$ " command "\n\n")
9981 (if gnus-view-pseudo-asynchronously
9982 (start-process "gnus-execute" (current-buffer) shell-file-name
9983 shell-command-switch command)
9984 (call-process shell-file-name nil t nil
9985 shell-command-switch command)))))
9987 ;; Summary kill commands.
9989 (defun gnus-summary-edit-global-kill (article)
9990 "Edit the \"global\" kill file."
9991 (interactive (list (gnus-summary-article-number)))
9992 (gnus-group-edit-global-kill article))
9994 (defun gnus-summary-edit-local-kill ()
9995 "Edit a local kill file applied to the current newsgroup."
9997 (setq gnus-current-headers (gnus-summary-article-header))
9998 (gnus-group-edit-local-kill
9999 (gnus-summary-article-number) gnus-newsgroup-name))
10001 ;;; Header reading.
10003 (defun gnus-read-header (id &optional header)
10004 "Read the headers of article ID and enter them into the Gnus system."
10005 (let ((group gnus-newsgroup-name)
10006 (gnus-override-method
10008 gnus-override-method
10009 (and (gnus-news-group-p gnus-newsgroup-name)
10010 (car (gnus-refer-article-methods)))))
10012 ;; First we check to see whether the header in question is already
10015 ;; This is a Message-ID.
10016 (setq header (or header (gnus-id-to-header id)))
10017 ;; This is an article number.
10018 (setq header (or header (gnus-summary-article-header id))))
10020 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10021 ;; We have found the header.
10023 ;; If this is a sparse article, we have to nix out its
10024 ;; previous entry in the thread hashtb.
10026 (gnus-summary-article-sparse-p (mail-header-number header)))
10027 (let* ((parent (gnus-parent-id (mail-header-references header)))
10028 (thread (and parent (gnus-id-to-thread parent))))
10030 (delq (assq header thread) thread))))
10031 ;; We have to really fetch the header to this article.
10033 (set-buffer nntp-server-buffer)
10034 (when (setq where (gnus-request-head id group))
10035 (nnheader-fold-continuation-lines)
10036 (goto-char (point-max))
10038 (goto-char (point-min))
10042 ((cdr where) (cdr where))
10043 (header (mail-header-number header))
10044 (t gnus-reffed-article-number))
10046 (insert " Article retrieved.\n"))
10047 (if (or (not where)
10048 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10049 () ; Malformed head.
10050 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10051 (when (and (stringp id)
10052 (not (string= (gnus-group-real-name group)
10054 ;; If we fetched by Message-ID and the article came
10055 ;; from a different group, we fudge some bogus article
10056 ;; numbers for this article.
10057 (mail-header-set-number header gnus-reffed-article-number))
10059 (set-buffer gnus-summary-buffer)
10060 (decf gnus-reffed-article-number)
10061 (gnus-remove-header (mail-header-number header))
10062 (push header gnus-newsgroup-headers)
10063 (setq gnus-current-headers header)
10064 (push (mail-header-number header) gnus-newsgroup-limit)))
10067 (defun gnus-remove-header (number)
10068 "Remove header NUMBER from `gnus-newsgroup-headers'."
10069 (if (and gnus-newsgroup-headers
10070 (= number (mail-header-number (car gnus-newsgroup-headers))))
10071 (pop gnus-newsgroup-headers)
10072 (let ((headers gnus-newsgroup-headers))
10073 (while (and (cdr headers)
10074 (not (= number (mail-header-number (cadr headers)))))
10076 (when (cdr headers)
10077 (setcdr headers (cddr headers))))))
10080 ;;; summary highlights
10083 (defun gnus-highlight-selected-summary ()
10084 "Highlight selected article in summary buffer."
10085 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10086 (when gnus-summary-selected-face
10088 (let* ((beg (progn (beginning-of-line) (point)))
10089 (end (progn (end-of-line) (point)))
10090 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10091 (from (if (get-text-property beg gnus-mouse-face-prop)
10093 (or (next-single-property-change
10094 beg gnus-mouse-face-prop nil end)
10099 (or (next-single-property-change
10100 from gnus-mouse-face-prop nil end)
10102 ;; If no mouse-face prop on line we will have to = from = end,
10103 ;; so we highlight the entire line instead.
10104 (when (= (+ to 2) from)
10107 (if gnus-newsgroup-selected-overlay
10108 ;; Move old overlay.
10110 gnus-newsgroup-selected-overlay from to (current-buffer))
10111 ;; Create new overlay.
10113 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10114 'face gnus-summary-selected-face))))))
10116 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10117 (defun gnus-summary-highlight-line ()
10118 "Highlight current line according to `gnus-summary-highlight'."
10119 (let* ((list gnus-summary-highlight)
10121 (end (progn (end-of-line) (point)))
10122 ;; now find out where the line starts and leave point there.
10123 (beg (progn (beginning-of-line) (point)))
10124 (article (gnus-summary-article-number))
10125 (score (or (cdr (assq (or article gnus-current-article)
10126 gnus-newsgroup-scored))
10127 gnus-summary-default-score 0))
10128 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10129 (inhibit-read-only t))
10130 ;; Eval the cars of the lists until we find a match.
10131 (let ((default gnus-summary-default-score)
10132 (default-high gnus-summary-default-high-score)
10133 (default-low gnus-summary-default-low-score))
10135 (not (eval (caar list))))
10136 (setq list (cdr list))))
10137 (let ((face (cdar list)))
10138 (unless (eq face (get-text-property beg 'face))
10139 (gnus-put-text-property-excluding-characters-with-faces
10141 (setq face (if (boundp face) (symbol-value face) face)))
10142 (when gnus-summary-highlight-line-function
10143 (funcall gnus-summary-highlight-line-function article face))))
10146 (defun gnus-update-read-articles (group unread &optional compute)
10147 "Update the list of read articles in GROUP."
10148 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10149 (entry (gnus-gethash group gnus-newsrc-hashtb))
10150 (info (nth 2 entry))
10152 (unread (sort (copy-sequence unread) '<))
10154 (if (or (not info) (not active))
10155 ;; There is no info on this group if it was, in fact,
10156 ;; killed. Gnus stores no information on killed groups, so
10157 ;; there's nothing to be done.
10158 ;; One could store the information somewhere temporarily,
10159 ;; perhaps... Hmmm...
10161 ;; Remove any negative articles numbers.
10162 (while (and unread (< (car unread) 0))
10163 (setq unread (cdr unread)))
10164 ;; Remove any expired article numbers
10165 (while (and unread (< (car unread) (car active)))
10166 (setq unread (cdr unread)))
10167 ;; Compute the ranges of read articles by looking at the list of
10168 ;; unread articles.
10170 (when (/= (car unread) prev)
10171 (push (if (= prev (1- (car unread))) prev
10172 (cons prev (1- (car unread))))
10174 (setq prev (1+ (car unread)))
10175 (setq unread (cdr unread)))
10176 (when (<= prev (cdr active))
10177 (push (cons prev (cdr active)) read))
10178 (setq read (if (> (length read) 1) (nreverse read) read))
10183 ;; Propagate the read marks to the backend.
10184 (when (gnus-check-backend-function 'request-set-mark group)
10185 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10186 (add (gnus-remove-from-range read (gnus-info-read info))))
10188 (unless (gnus-check-group group)
10189 (error "Can't open server for %s" group))
10190 (gnus-request-set-mark
10191 group (delq nil (list (if add (list add 'add '(read)))
10192 (if del (list del 'del '(read))))))
10194 `(gnus-request-set-mark
10197 (if del (list del 'add '(read)))
10198 (if add (list add 'del '(read))))))))))
10199 (set-buffer gnus-group-buffer)
10200 (gnus-undo-register
10202 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10203 (gnus-info-set-read ',info ',(gnus-info-read info))
10204 (gnus-get-unread-articles-in-group ',info
10205 (gnus-active ,group))
10206 (gnus-group-update-group ,group t)
10208 ;; Enter this list into the group info.
10209 (gnus-info-set-read info read)
10210 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10211 (gnus-get-unread-articles-in-group info (gnus-active group))
10214 (defun gnus-offer-save-summaries ()
10215 "Offer to save all active summary buffers."
10217 ;; Go through all buffers and find all summaries.
10218 (dolist (buffer (buffer-list))
10219 (when (and (setq buffer (buffer-name buffer))
10220 (string-match "Summary" buffer)
10222 (set-buffer buffer)
10223 ;; We check that this is, indeed, a summary buffer.
10224 (and (eq major-mode 'gnus-summary-mode)
10225 ;; Also make sure this isn't bogus.
10226 gnus-newsgroup-prepared
10227 ;; Also make sure that this isn't a
10228 ;; dead summary buffer.
10229 (not gnus-dead-summary-mode))))
10230 (push buffer buffers)))
10231 ;; Go through all these summary buffers and offer to save them.
10235 "Update summary buffer %s? "
10237 (switch-to-buffer buf)
10238 (gnus-summary-exit))
10242 ;;; @ for mime-partial
10245 (defun gnus-request-partial-message ()
10247 (let ((number (gnus-summary-article-number))
10248 (group gnus-newsgroup-name)
10249 (mother gnus-article-buffer))
10250 (set-buffer (get-buffer-create " *Partial Article*"))
10252 (setq mime-preview-buffer mother)
10253 (gnus-request-article-this-buffer number group)
10254 (mime-parse-buffer)
10257 (autoload 'mime-combine-message/partial-pieces-automatically
10259 "Internal method to combine message/partial messages automatically.")
10261 (mime-add-condition
10262 'action '((type . message)(subtype . partial)
10263 (major-mode . gnus-original-article-mode)
10264 (method . mime-combine-message/partial-pieces-automatically)
10265 (summary-buffer-exp . gnus-summary-buffer)
10266 (request-partial-message-method . gnus-request-partial-message)
10270 ;;; @ for message/rfc822
10273 (defun gnus-mime-extract-message/rfc822 (entity situation)
10274 (let (group article num cwin swin cur)
10276 (mime-insert-entity-content entity)
10277 (setq group (or (cdr (assq 'group situation))
10278 (completing-read "Group: "
10281 (gnus-read-active-file-p)
10282 gnus-newsgroup-name))
10283 article (gnus-request-accept-article group)))
10284 (when (and (consp article)
10285 (numberp (setq article (cdr article))))
10286 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10287 cwin (get-buffer-window (current-buffer) t))
10288 (save-window-excursion
10289 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10290 (select-window swin)
10291 (set-buffer gnus-summary-buffer))
10292 (setq cur gnus-current-article)
10294 (let (gnus-show-threads)
10295 (gnus-summary-goto-subject article t))
10296 (gnus-summary-clear-mark-forward 1)
10297 (gnus-summary-goto-subject cur))
10298 (when (and cwin (window-frame cwin))
10299 (select-frame (window-frame cwin)))
10300 (when (boundp 'mime-acting-situation-to-override)
10301 (set-alist 'mime-acting-situation-to-override
10304 (set-alist 'mime-acting-situation-to-override
10307 (save-current-buffer
10308 (set-buffer gnus-group-buffer)
10309 (gnus-activate-group ,group))
10310 (gnus-summary-goto-article ,cur
10311 gnus-show-all-headers)))
10312 (set-alist 'mime-acting-situation-to-override
10315 (mime-add-condition
10316 'action '((type . message)(subtype . rfc822)
10317 (major-mode . gnus-original-article-mode)
10318 (method . gnus-mime-extract-message/rfc822)
10322 (mime-add-condition
10323 'action '((type . message)(subtype . news)
10324 (major-mode . gnus-original-article-mode)
10325 (method . gnus-mime-extract-message/rfc822)
10329 (defun gnus-mime-extract-multipart (entity situation)
10330 (let ((children (mime-entity-children entity))
10331 mime-acting-situation-to-override
10334 (mime-play-entity (car children)
10335 (cons (assq 'mode situation)
10336 mime-acting-situation-to-override))
10337 (setq children (cdr children)))
10338 (if (setq f (cdr (assq 'after-method
10339 mime-acting-situation-to-override)))
10343 (mime-add-condition
10344 'action '((type . multipart)
10345 (method . gnus-mime-extract-multipart)
10354 (defun gnus-summary-setup-default-charset ()
10355 "Setup newsgroup default charset."
10356 (if (equal gnus-newsgroup-name "nndraft:drafts")
10357 (setq gnus-newsgroup-charset nil)
10358 (let* ((ignored-charsets
10359 (or gnus-newsgroup-ephemeral-ignored-charsets
10361 (and gnus-newsgroup-name
10362 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10363 gnus-newsgroup-ignored-charsets))))
10364 (setq gnus-newsgroup-charset
10365 (or gnus-newsgroup-ephemeral-charset
10366 (and gnus-newsgroup-name
10367 (gnus-parameter-charset gnus-newsgroup-name))
10368 gnus-default-charset))
10369 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10370 ignored-charsets))))
10376 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10377 "Display the current article buffer fully MIME-buttonized.
10378 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10379 treated as multipart/mixed."
10381 (require 'gnus-art)
10382 (let ((gnus-unbuttonized-mime-types nil)
10383 (gnus-mime-display-multipart-as-mixed show-all-parts))
10384 (gnus-summary-show-article)))
10386 (defun gnus-summary-repair-multipart (article)
10387 "Add a Content-Type header to a multipart article without one."
10388 (interactive (list (gnus-summary-article-number)))
10389 (gnus-with-article article
10390 (message-narrow-to-head)
10391 (message-remove-header "Mime-Version")
10392 (goto-char (point-max))
10393 (insert "Mime-Version: 1.0\n")
10395 (when (search-forward "\n--" nil t)
10396 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10397 (message-narrow-to-head)
10398 (message-remove-header "Content-Type")
10399 (goto-char (point-max))
10400 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10403 (let (gnus-mark-article-hook)
10404 (gnus-summary-select-article t t nil article)))
10406 (defun gnus-summary-toggle-display-buttonized ()
10407 "Toggle the buttonizing of the article buffer."
10409 (require 'gnus-art)
10410 (if (setq gnus-inhibit-mime-unbuttonizing
10411 (not gnus-inhibit-mime-unbuttonizing))
10412 (let ((gnus-unbuttonized-mime-types nil))
10413 (gnus-summary-show-article))
10414 (gnus-summary-show-article)))
10417 ;;; Intelli-mouse commmands
10420 (defun gnus-wheel-summary-scroll (event)
10422 (let ((amount (if (memq 'shift (event-modifiers event))
10423 (car gnus-wheel-scroll-amount)
10424 (cdr gnus-wheel-scroll-amount)))
10425 (direction (- (* (static-if (featurep 'xemacs)
10426 (event-button event)
10427 (cond ((eq 'mouse-4 (event-basic-type event))
10429 ((eq 'mouse-5 (event-basic-type event))
10433 (gnus-summary-scroll-up (* amount direction))
10434 (when (gnus-eval-in-buffer-window gnus-article-buffer
10437 (and (if (< 0 direction)
10438 (gnus-article-next-page 0)
10439 (gnus-article-prev-page 0)
10441 (if (setq edge (get-text-property
10442 (point-min) 'gnus-wheel-edge))
10443 (setq edge (* edge direction))
10446 (let ((buffer-read-only nil)
10447 (inhibit-read-only t))
10448 (put-text-property (point-min) (point-max)
10449 'gnus-wheel-edge direction)
10451 (or (> edge gnus-wheel-edge-resistance)
10452 (let ((buffer-read-only nil)
10453 (inhibit-read-only t))
10454 (put-text-property (point-min) (point-max)
10456 (* (1+ edge) direction))
10458 (eq last-command 'gnus-wheel-summary-scroll))))
10459 (gnus-summary-next-article nil nil (minusp direction)))))
10461 (defun gnus-wheel-install ()
10462 "Enable mouse wheel support on summary window."
10463 (when gnus-use-wheel
10465 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10467 (define-key gnus-summary-mode-map key
10468 'gnus-wheel-summary-scroll)))))
10470 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10473 ;;; Traditional PGP commmands
10476 (defun gnus-summary-decrypt-article (&optional force)
10477 "Decrypt the current article in traditional PGP way.
10478 This will have permanent effect only in mail groups.
10479 If FORCE is non-nil, allow editing of articles even in read-only
10482 (gnus-summary-select-article t)
10483 (gnus-eval-in-buffer-window gnus-article-buffer
10487 (goto-char (point-min))
10488 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10489 (error "Not a traditional PGP message!"))
10490 (let ((armor-start (match-beginning 0)))
10491 (if (and (pgg-decrypt-region armor-start (point-max))
10492 (or force (not (gnus-group-read-only-p))))
10493 (let ((inhibit-read-only t)
10495 (delete-region armor-start
10497 (re-search-forward "^-+END PGP" nil t)
10498 (beginning-of-line 2)
10500 (insert-buffer-substring pgg-output-buffer))))))))
10502 (defun gnus-summary-verify-article ()
10503 "Verify the current article in traditional PGP way."
10506 (set-buffer gnus-original-article-buffer)
10507 (goto-char (point-min))
10508 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10509 (error "Not a traditional PGP message!"))
10510 (re-search-forward "^-+END PGP" nil t)
10511 (beginning-of-line 2)
10512 (call-interactively (function pgg-verify-region))))
10515 ;;; Generic summary marking commands
10518 (defvar gnus-summary-marking-alist
10519 '((read gnus-del-mark "d")
10520 (unread gnus-unread-mark "u")
10521 (ticked gnus-ticked-mark "!")
10522 (dormant gnus-dormant-mark "?")
10523 (expirable gnus-expirable-mark "e"))
10524 "An alist of names/marks/keystrokes.")
10526 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10527 (defvar gnus-summary-mark-map)
10529 (defun gnus-summary-make-all-marking-commands ()
10530 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10531 (dolist (elem gnus-summary-marking-alist)
10532 (apply 'gnus-summary-make-marking-command elem)))
10534 (defun gnus-summary-make-marking-command (name mark keystroke)
10535 (let ((map (make-sparse-keymap)))
10536 (define-key gnus-summary-generic-mark-map keystroke map)
10537 (dolist (lway `((next "next" next nil "n")
10538 (next-unread "next unread" next t "N")
10539 (prev "previous" prev nil "p")
10540 (prev-unread "previous unread" prev t "P")
10541 (nomove "" nil nil ,keystroke)))
10542 (let ((func (gnus-summary-make-marking-command-1
10543 mark (car lway) lway name)))
10544 (setq func (eval func))
10545 (define-key map (nth 4 lway) func)))))
10547 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10549 (format "gnus-summary-put-mark-as-%s%s"
10550 name (if (eq way 'nomove)
10552 (concat "-" (symbol-name way)))))
10555 "Mark the current article as %s%s.
10556 If N, the prefix, then repeat N times.
10557 If N is negative, move in reverse order.
10558 The difference between N and the actual number of articles marked is
10560 name (car (cdr lway)))
10562 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10564 (defun gnus-summary-generic-mark (n mark move unread)
10565 "Mark N articles with MARK."
10566 (unless (eq major-mode 'gnus-summary-mode)
10567 (error "This command can only be used in the summary buffer"))
10568 (gnus-summary-show-thread)
10571 ((eq move 'next) 1)
10572 ((eq move 'prev) -1)
10574 (if (zerop nummove)
10578 nummove (* -1 nummove))))
10579 (while (and (> n 0)
10580 (gnus-summary-mark-article nil mark)
10581 (zerop (gnus-summary-next-subject nummove unread t)))
10584 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10585 (gnus-summary-recenter)
10586 (gnus-summary-position-point)
10587 (gnus-set-mode-line 'summary)
10590 (defun gnus-summary-insert-articles (articles)
10591 (when (setq articles
10592 (gnus-set-difference articles
10593 (mapcar (lambda (h) (mail-header-number h))
10594 gnus-newsgroup-headers)))
10595 (setq gnus-newsgroup-headers
10597 gnus-newsgroup-headers
10598 (gnus-fetch-headers articles)
10599 'gnus-article-sort-by-number))
10600 ;; Suppress duplicates?
10601 (when gnus-suppress-duplicates
10602 (gnus-dup-suppress-articles))
10604 ;; We might want to build some more threads first.
10605 (when (and gnus-fetch-old-headers
10606 (eq gnus-headers-retrieved-by 'nov))
10607 (if (eq gnus-fetch-old-headers 'invisible)
10608 (gnus-build-all-threads)
10609 (gnus-build-old-threads)))
10610 ;; Let the Gnus agent mark articles as read.
10612 (gnus-agent-get-undownloaded-list))
10613 ;; Remove list identifiers from subject
10614 (when gnus-list-identifiers
10615 (gnus-summary-remove-list-identifiers))
10616 ;; First and last article in this newsgroup.
10617 (when gnus-newsgroup-headers
10618 (setq gnus-newsgroup-begin
10619 (mail-header-number (car gnus-newsgroup-headers))
10621 (mail-header-number
10622 (gnus-last-element gnus-newsgroup-headers))))
10623 (when gnus-use-scoring
10624 (gnus-possibly-score-headers))))
10626 (defun gnus-summary-insert-old-articles (&optional all)
10627 "Insert all old articles in this group.
10628 If ALL is non-nil, already read articles become readable.
10629 If ALL is a number, fetch this number of articles."
10632 (let ((old (mapcar 'car gnus-newsgroup-data))
10633 (i (car gnus-newsgroup-active))
10635 (while (<= i (cdr gnus-newsgroup-active))
10636 (or (memq i old) (push i older))
10638 (setq len (length older))
10643 (setq older (subseq older 0 all))))
10646 (if (and (numberp gnus-large-newsgroup)
10647 (> len gnus-large-newsgroup))
10651 "How many articles from %s (default %d): "
10653 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10655 (unless (string-match "^[ \t]*$" input)
10656 (setq all (string-to-number input))
10658 (setq older (subseq older 0 all))))))))
10660 (message "No old news.")
10661 (gnus-summary-insert-articles older)
10662 (gnus-summary-limit (gnus-union older old))))
10663 (gnus-summary-position-point)))
10665 (defun gnus-summary-insert-new-articles ()
10666 "Insert all new articles in this group."
10669 (let ((old (mapcar 'car gnus-newsgroup-data))
10670 (old-active gnus-newsgroup-active)
10671 (nnmail-fetched-sources (list t))
10673 (setq gnus-newsgroup-active
10674 (gnus-activate-group gnus-newsgroup-name 'scan))
10675 (setq i (1+ (cdr old-active)))
10676 (while (<= i (cdr gnus-newsgroup-active))
10680 (message "No gnus is bad news.")
10681 (setq new (nreverse new))
10682 (gnus-summary-insert-articles new)
10683 (setq gnus-newsgroup-unreads
10684 (append gnus-newsgroup-unreads new))
10685 (gnus-summary-limit (gnus-union old new))))
10686 (gnus-summary-position-point)))
10688 (gnus-summary-make-all-marking-commands)
10690 (gnus-ems-redefine)
10692 (provide 'gnus-sum)
10694 (run-hooks 'gnus-sum-load-hook)
10696 ;;; gnus-sum.el ends here