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))
41 ;; (require 'gnus-art)
50 (autoload 'gnus-cache-articles-in-group "gnus-cache")
51 (autoload 'pgg-decrypt-region "pgg" nil t)
52 (autoload 'pgg-verify-region "pgg" nil t))
54 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
55 (autoload 'gnus-cache-write-active "gnus-cache")
56 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
57 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
58 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
59 (autoload 'mm-uu-dissect "mm-uu")
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include: `gnus-simplify-subject-re',
151 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
153 :type '(repeat function))
155 (defcustom gnus-simplify-ignored-prefixes nil
156 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
158 :type '(choice (const :tag "off" nil)
161 (defcustom gnus-build-sparse-threads nil
162 "*If non-nil, fill in the gaps in threads.
163 If `some', only fill in the gaps that are needed to tie loose threads
164 together. If `more', fill in all leaf nodes that Gnus can find. If
165 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
167 :type '(choice (const :tag "off" nil)
170 (sexp :menu-tag "all" t)))
172 (defcustom gnus-summary-thread-gathering-function
173 'gnus-gather-threads-by-subject
174 "*Function used for gathering loose threads.
175 There are two pre-defined functions: `gnus-gather-threads-by-subject',
176 which only takes Subjects into consideration; and
177 `gnus-gather-threads-by-references', which compared the References
178 headers of the articles to find matches."
180 :type '(radio (function-item gnus-gather-threads-by-subject)
181 (function-item gnus-gather-threads-by-references)
182 (function :tag "other")))
184 (defcustom gnus-summary-same-subject ""
185 "*String indicating that the current article has the same subject as the previous.
186 This variable will only be used if the value of
187 `gnus-summary-make-false-root' is `empty'."
188 :group 'gnus-summary-format
191 (defcustom gnus-summary-goto-unread t
192 "*If t, many commands will go to the next unread article.
193 This applies to marking commands as well as other commands that
194 \"naturally\" select the next article, like, for instance, `SPC' at
195 the end of an article.
197 If nil, the marking commands do NOT go to the next unread article
198 (they go to the next article instead). If `never', commands that
199 usually go to the next unread article, will go to the next article,
200 whether it is read or not."
201 :group 'gnus-summary-marks
202 :link '(custom-manual "(gnus)Setting Marks")
203 :type '(choice (const :tag "off" nil)
205 (sexp :menu-tag "on" t)))
207 (defcustom gnus-summary-default-score 0
208 "*Default article score level.
209 All scores generated by the score files will be added to this score.
210 If this variable is nil, scoring will be disabled."
211 :group 'gnus-score-default
212 :type '(choice (const :tag "disable")
215 (defcustom gnus-summary-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 If threads are hidden, you have to run the command
238 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
239 to expose hidden threads."
243 (defcustom gnus-thread-hide-killed t
244 "*If non-nil, hide killed threads automatically."
248 (defcustom gnus-thread-ignore-subject t
249 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
250 If nil, articles that have different subjects from their parents will
251 start separate threads."
255 (defcustom gnus-thread-operation-ignore-subject t
256 "*If non-nil, subjects will be ignored when doing thread commands.
257 This affects commands like `gnus-summary-kill-thread' and
258 `gnus-summary-lower-thread'.
260 If this variable is nil, articles in the same thread with different
261 subjects will not be included in the operation in question. If this
262 variable is `fuzzy', only articles that have subjects that are fuzzily
263 equal will be included."
265 :type '(choice (const :tag "off" nil)
269 (defcustom gnus-thread-indent-level 4
270 "*Number that says how much each sub-thread should be indented."
274 (defcustom gnus-auto-extend-newsgroup t
275 "*If non-nil, extend newsgroup forward and backward when requested."
276 :group 'gnus-summary-choose
279 (defcustom gnus-auto-select-first t
280 "*If nil, don't select the first unread article when entering a group.
281 If this variable is `best', select the highest-scored unread article
282 in the group. If t, select the first unread article.
284 This variable can also be a function to place point on a likely
285 subject line. Useful values include `gnus-summary-first-unread-subject',
286 `gnus-summary-first-unread-article' and
287 `gnus-summary-best-unread-article'.
289 If you want to prevent automatic selection of the first unread article
290 in some newsgroups, set the variable to nil in
291 `gnus-select-group-hook'."
292 :group 'gnus-group-select
293 :type '(choice (const :tag "none" nil)
295 (sexp :menu-tag "first" t)
296 (function-item gnus-summary-first-unread-subject)
297 (function-item gnus-summary-first-unread-article)
298 (function-item gnus-summary-best-unread-article)))
300 (defcustom gnus-dont-select-after-jump-to-other-group nil
301 "If non-nil, don't select the first unread article after entering the
302 other group by the command `gnus-summary-jump-to-other-group'. If nil,
303 it is depend on the value of `gnus-auto-select-first' whether to select
305 :group 'gnus-group-select
308 (defcustom gnus-auto-select-next t
309 "*If non-nil, offer to go to the next group from the end of the previous.
310 If the value is t and the next newsgroup is empty, Gnus will exit
311 summary mode and go back to group mode. If the value is neither nil
312 nor t, Gnus will select the following unread newsgroup. In
313 particular, if the value is the symbol `quietly', the next unread
314 newsgroup will be selected without any confirmation, and if it is
315 `almost-quietly', the next group will be selected without any
316 confirmation if you are located on the last article in the group.
317 Finally, if this variable is `slightly-quietly', the `Z n' command
318 will go to the next group without confirmation."
319 :group 'gnus-summary-maneuvering
320 :type '(choice (const :tag "off" nil)
322 (const almost-quietly)
323 (const slightly-quietly)
324 (sexp :menu-tag "on" t)))
326 (defcustom gnus-auto-select-same nil
327 "*If non-nil, select the next article with the same subject.
328 If there are no more articles with the same subject, go to
329 the first unread article."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-summary-check-current nil
334 "*If non-nil, consider the current article when moving.
335 The \"unread\" movement commands will stay on the same line if the
336 current article is unread."
337 :group 'gnus-summary-maneuvering
340 (defcustom gnus-auto-center-summary t
341 "*If non-nil, always center the current summary buffer.
342 In particular, if `vertical' do only vertical recentering. If non-nil
343 and non-`vertical', do both horizontal and vertical recentering."
344 :group 'gnus-summary-maneuvering
345 :type '(choice (const :tag "none" nil)
347 (integer :tag "height")
348 (sexp :menu-tag "both" t)))
350 (defcustom gnus-show-all-headers nil
351 "*If non-nil, don't hide any headers."
352 :group 'gnus-article-hiding
353 :group 'gnus-article-headers
356 (defcustom gnus-summary-ignore-duplicates nil
357 "*If non-nil, ignore articles with identical Message-ID headers."
361 (defcustom gnus-single-article-buffer t
362 "*If non-nil, display all articles in the same buffer.
363 If nil, each group will get its own article buffer."
364 :group 'gnus-article-various
367 (defcustom gnus-break-pages t
368 "*If non-nil, do page breaking on articles.
369 The page delimiter is specified by the `gnus-page-delimiter'
371 :group 'gnus-article-various
374 (defcustom gnus-show-mime t
375 "*If non-nil, do mime processing of articles.
376 The articles will simply be fed to the function given by
377 `gnus-article-display-method-for-mime'."
378 :group 'gnus-article-mime
381 (defcustom gnus-move-split-methods nil
382 "*Variable used to suggest where articles are to be moved to.
383 It uses the same syntax as the `gnus-split-methods' variable.
384 However, whereas `gnus-split-methods' specifies file names as targets,
385 this variable specifies group names."
386 :group 'gnus-summary-mail
387 :type '(repeat (choice (list :value (fun) function)
388 (cons :value ("" "") regexp (repeat string))
391 (defcustom gnus-unread-mark ? ;Whitespace
392 "*Mark used for unread articles."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ticked-mark ?!
397 "*Mark used for ticked articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-dormant-mark ??
402 "*Mark used for dormant articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-del-mark ?r
407 "*Mark used for del'd articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-read-mark ?R
412 "*Mark used for read articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-expirable-mark ?E
417 "*Mark used for expirable articles."
418 :group 'gnus-summary-marks
421 (defcustom gnus-killed-mark ?K
422 "*Mark used for killed articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-souped-mark ?F
427 "*Mark used for killed articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-kill-file-mark ?X
432 "*Mark used for articles killed by kill files."
433 :group 'gnus-summary-marks
436 (defcustom gnus-low-score-mark ?Y
437 "*Mark used for articles with a low score."
438 :group 'gnus-summary-marks
441 (defcustom gnus-catchup-mark ?C
442 "*Mark used for articles that are caught up."
443 :group 'gnus-summary-marks
446 (defcustom gnus-replied-mark ?A
447 "*Mark used for articles that have been replied to."
448 :group 'gnus-summary-marks
451 (defcustom gnus-cached-mark ?*
452 "*Mark used for articles that are in the cache."
453 :group 'gnus-summary-marks
456 (defcustom gnus-saved-mark ?S
457 "*Mark used for articles that have been saved to."
458 :group 'gnus-summary-marks
461 (defcustom gnus-no-mark ? ;Whitespace
462 "*Mark used for articles that have no other secondary mark."
463 :group 'gnus-summary-marks
466 (defcustom gnus-ancient-mark ?O
467 "*Mark used for ancient articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-sparse-mark ?Q
472 "*Mark used for sparsely reffed articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-canceled-mark ?G
477 "*Mark used for canceled articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-duplicate-mark ?M
482 "*Mark used for duplicate articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-undownloaded-mark ?@
487 "*Mark used for articles that weren't downloaded."
488 :group 'gnus-summary-marks
491 (defcustom gnus-downloadable-mark ?%
492 "*Mark used for articles that are to be downloaded."
493 :group 'gnus-summary-marks
496 (defcustom gnus-unsendable-mark ?=
497 "*Mark used for articles that won't be sent."
498 :group 'gnus-summary-marks
501 (defcustom gnus-score-over-mark ?+
502 "*Score mark used for articles with high scores."
503 :group 'gnus-summary-marks
506 (defcustom gnus-score-below-mark ?-
507 "*Score mark used for articles with low scores."
508 :group 'gnus-summary-marks
511 (defcustom gnus-empty-thread-mark ? ;Whitespace
512 "*There is no thread under the article."
513 :group 'gnus-summary-marks
516 (defcustom gnus-not-empty-thread-mark ?=
517 "*There is a thread under the article."
518 :group 'gnus-summary-marks
521 (defcustom gnus-view-pseudo-asynchronously nil
522 "*If non-nil, Gnus will view pseudo-articles asynchronously."
523 :group 'gnus-extract-view
526 (defcustom gnus-auto-expirable-marks
527 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
528 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
529 gnus-souped-mark gnus-duplicate-mark)
530 "*The list of marks converted into expiration if a group is auto-expirable."
533 :type '(repeat character))
535 (defcustom gnus-inhibit-user-auto-expire t
536 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
541 (defcustom gnus-view-pseudos nil
542 "*If `automatic', pseudo-articles will be viewed automatically.
543 If `not-confirm', pseudos will be viewed automatically, and the user
544 will not be asked to confirm the command."
545 :group 'gnus-extract-view
546 :type '(choice (const :tag "off" nil)
548 (const not-confirm)))
550 (defcustom gnus-view-pseudos-separately t
551 "*If non-nil, one pseudo-article will be created for each file to be viewed.
552 If nil, all files that use the same viewing command will be given as a
553 list of parameters to that command."
554 :group 'gnus-extract-view
557 (defcustom gnus-insert-pseudo-articles t
558 "*If non-nil, insert pseudo-articles when decoding articles."
559 :group 'gnus-extract-view
562 (defcustom gnus-summary-dummy-line-format
564 "*The format specification for the dummy roots in the summary buffer.
565 It works along the same lines as a normal formatting string,
566 with some simple extensions.
569 :group 'gnus-threading
572 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
573 "*The format specification for the summary mode line.
574 It works along the same lines as a normal formatting string,
575 with some simple extensions:
578 %p Unprefixed group name
579 %A Current article number
580 %z Current article score
582 %U Number of unread articles in the group
583 %e Number of unselected articles in the group
584 %Z A string with unread/unselected article counts
585 %g Shortish group name
586 %S Subject of the current article
588 %s Current score file name
589 %d Number of dormant articles
590 %r Number of articles that have been marked as read in this session
591 %E Number of articles expunged by the score files"
592 :group 'gnus-summary-format
595 (defcustom gnus-list-identifiers nil
596 "Regexp that matches list identifiers to be removed from subject.
597 This can also be a list of regexps."
599 :group 'gnus-summary-format
600 :group 'gnus-article-hiding
601 :type '(choice (const :tag "none" nil)
603 (repeat :value (".*") regexp)))
605 (defcustom gnus-summary-mark-below 0
606 "*Mark all articles with a score below this variable as read.
607 This variable is local to each summary buffer and usually set by the
609 :group 'gnus-score-default
612 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
613 "*List of functions used for sorting articles in the summary buffer.
614 This variable is only used when not using a threaded display."
615 :group 'gnus-summary-sort
616 :type '(repeat (choice (function-item gnus-article-sort-by-number)
617 (function-item gnus-article-sort-by-author)
618 (function-item gnus-article-sort-by-subject)
619 (function-item gnus-article-sort-by-date)
620 (function-item gnus-article-sort-by-score)
621 (function :tag "other"))))
623 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
624 "*List of functions used for sorting threads in the summary buffer.
625 By default, threads are sorted by article number.
627 Each function takes two threads and return non-nil if the first thread
628 should be sorted before the other. If you use more than one function,
629 the primary sort function should be the last. You should probably
630 always include `gnus-thread-sort-by-number' in the list of sorting
631 functions -- preferably first.
633 Ready-made functions include `gnus-thread-sort-by-number',
634 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
635 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
636 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
637 :group 'gnus-summary-sort
638 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
639 (function-item gnus-thread-sort-by-author)
640 (function-item gnus-thread-sort-by-subject)
641 (function-item gnus-thread-sort-by-date)
642 (function-item gnus-thread-sort-by-score)
643 (function-item gnus-thread-sort-by-total-score)
644 (function :tag "other"))))
646 (defcustom gnus-thread-score-function '+
647 "*Function used for calculating the total score of a thread.
649 The function is called with the scores of the article and each
650 subthread and should then return the score of the thread.
652 Some functions you can use are `+', `max', or `min'."
653 :group 'gnus-summary-sort
656 (defcustom gnus-summary-expunge-below nil
657 "All articles that have a score less than this variable will be expunged.
658 This variable is local to the summary buffers."
659 :group 'gnus-score-default
660 :type '(choice (const :tag "off" nil)
663 (defcustom gnus-thread-expunge-below nil
664 "All threads that have a total score less than this variable will be expunged.
665 See `gnus-thread-score-function' for en explanation of what a
668 This variable is local to the summary buffers."
669 :group 'gnus-threading
670 :group 'gnus-score-default
671 :type '(choice (const :tag "off" nil)
674 (defcustom gnus-summary-mode-hook nil
675 "*A hook for Gnus summary mode.
676 This hook is run before any variables are set in the summary buffer."
677 :options '(turn-on-gnus-mailing-list-mode)
678 :group 'gnus-summary-various
681 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
682 (when (featurep 'xemacs)
683 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
684 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
685 (add-hook 'gnus-summary-mode-hook
686 'gnus-xmas-switch-horizontal-scrollbar-off))
688 (defcustom gnus-summary-menu-hook nil
689 "*Hook run after the creation of the summary mode menu."
690 :group 'gnus-summary-visual
693 (defcustom gnus-summary-exit-hook nil
694 "*A hook called on exit from the summary buffer.
695 It will be called with point in the group buffer."
696 :group 'gnus-summary-exit
699 (defcustom gnus-summary-prepare-hook nil
700 "*A hook called after the summary buffer has been generated.
701 If you want to modify the summary buffer, you can use this hook."
702 :group 'gnus-summary-various
705 (defcustom gnus-summary-prepared-hook nil
706 "*A hook called as the last thing after the summary buffer has been generated."
707 :group 'gnus-summary-various
710 (defcustom gnus-summary-generate-hook nil
711 "*A hook run just before generating the summary buffer.
712 This hook is commonly used to customize threading variables and the
714 :group 'gnus-summary-various
717 (defcustom gnus-select-group-hook nil
718 "*A hook called when a newsgroup is selected.
720 If you'd like to simplify subjects like the
721 `gnus-summary-next-same-subject' command does, you can use the
724 (setq gnus-select-group-hook
727 (mapcar (lambda (header)
728 (mail-header-set-subject
730 (gnus-simplify-subject
731 (mail-header-subject header) 're-only)))
732 gnus-newsgroup-headers))))"
733 :group 'gnus-group-select
736 (defcustom gnus-select-article-hook nil
737 "*A hook called when an article is selected."
738 :group 'gnus-summary-choose
741 (defcustom gnus-visual-mark-article-hook
742 (list 'gnus-highlight-selected-summary)
743 "*Hook run after selecting an article in the summary buffer.
744 It is meant to be used for highlighting the article in some way. It
745 is not run if `gnus-visual' is nil."
746 :group 'gnus-summary-visual
749 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
750 "*A hook called before parsing the headers."
754 (defcustom gnus-exit-group-hook nil
755 "*A hook called when exiting summary mode.
756 This hook is not called from the non-updating exit commands like `Q'."
760 (defcustom gnus-summary-update-hook
761 (list 'gnus-summary-highlight-line)
762 "*A hook called when a summary line is changed.
763 The hook will not be called if `gnus-visual' is nil.
765 The default function `gnus-summary-highlight-line' will
766 highlight the line according to the `gnus-summary-highlight'
768 :group 'gnus-summary-visual
771 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
772 "*A hook called when an article is selected for the first time.
773 The hook is intended to mark an article as read (or unread)
774 automatically when it is selected."
775 :group 'gnus-summary-choose
778 (defcustom gnus-group-no-more-groups-hook nil
779 "*A hook run when returning to group mode having no more (unread) groups."
780 :group 'gnus-group-select
783 (defcustom gnus-ps-print-hook nil
784 "*A hook run before ps-printing something from Gnus."
788 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
789 "Face used for highlighting the current article in the summary buffer."
790 :group 'gnus-summary-visual
793 (defcustom gnus-summary-highlight
794 '(((= mark gnus-canceled-mark)
795 . gnus-summary-cancelled-face)
796 ((and (> score default)
797 (or (= mark gnus-dormant-mark)
798 (= mark gnus-ticked-mark)))
799 . gnus-summary-high-ticked-face)
800 ((and (< score default)
801 (or (= mark gnus-dormant-mark)
802 (= mark gnus-ticked-mark)))
803 . gnus-summary-low-ticked-face)
804 ((or (= mark gnus-dormant-mark)
805 (= mark gnus-ticked-mark))
806 . gnus-summary-normal-ticked-face)
807 ((and (> score default) (= mark gnus-ancient-mark))
808 . gnus-summary-high-ancient-face)
809 ((and (< score default) (= mark gnus-ancient-mark))
810 . gnus-summary-low-ancient-face)
811 ((= mark gnus-ancient-mark)
812 . gnus-summary-normal-ancient-face)
813 ((and (> score default) (= mark gnus-unread-mark))
814 . gnus-summary-high-unread-face)
815 ((and (< score default) (= mark gnus-unread-mark))
816 . gnus-summary-low-unread-face)
817 ((and (memq article gnus-newsgroup-incorporated)
818 (= mark gnus-unread-mark))
819 . gnus-summary-incorporated-face)
820 ((= mark gnus-unread-mark)
821 . gnus-summary-normal-unread-face)
822 ((and (> score default) (memq mark (list gnus-downloadable-mark
823 gnus-undownloaded-mark)))
824 . gnus-summary-high-unread-face)
825 ((and (< score default) (memq mark (list gnus-downloadable-mark
826 gnus-undownloaded-mark)))
827 . gnus-summary-low-unread-face)
828 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
829 . gnus-summary-normal-unread-face)
831 . gnus-summary-high-read-face)
833 . gnus-summary-low-read-face)
835 . gnus-summary-normal-read-face))
836 "*Controls the highlighting of summary buffer lines.
838 A list of (FORM . FACE) pairs. When deciding how a a particular
839 summary line should be displayed, each form is evaluated. The content
840 of the face field after the first true form is used. You can change
841 how those summary lines are displayed, by editing the face field.
843 You can use the following variables in the FORM field.
845 score: The articles score
846 default: The default article score.
847 below: The score below which articles are automatically marked as read.
848 mark: The articles mark."
849 :group 'gnus-summary-visual
850 :type '(repeat (cons (sexp :tag "Form" nil)
853 (defcustom gnus-alter-header-function nil
854 "Function called to allow alteration of article header structures.
855 The function is called with one parameter, the article header vector,
856 which it may alter in any way.")
858 (defvar gnus-decode-encoded-word-function
859 (mime-find-field-decoder 'From 'nov)
860 "Variable that says which function should be used to decode a string with encoded words.")
862 (defcustom gnus-extra-headers nil
863 "*Extra headers to parse."
866 :type '(repeat symbol))
868 (defcustom gnus-ignored-from-addresses
869 (and user-mail-address (regexp-quote user-mail-address))
870 "*Regexp of From headers that may be suppressed in favor of To headers."
875 (defcustom gnus-group-charset-alist
876 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
877 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
878 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
879 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
880 ("^relcom\\>" koi8-r)
882 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
883 ("^israel\\>" iso-8859-1)
885 ("^alt.chinese.text.big5\\>" chinese-big5)
886 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
887 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
889 "Alist of regexps (to match group names) and default charsets to be used when reading."
890 :type '(repeat (list (regexp :tag "Group")
891 (symbol :tag "Charset")))
892 :group 'gnus-charset)
894 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
895 "List of charsets that should be ignored.
896 When these charsets are used in the \"charset\" parameter, the
897 default charset will be used instead."
899 :type '(repeat symbol)
900 :group 'gnus-charset)
902 (defcustom gnus-group-ignored-charsets-alist
903 '(("alt\\.chinese\\.text" iso-8859-1))
904 "Alist of regexps (to match group names) and charsets that should be ignored.
905 When these charsets are used in the \"charset\" parameter, the
906 default charset will be used instead."
907 :type '(repeat (cons (regexp :tag "Group")
909 :group 'gnus-charset)
911 (defcustom gnus-group-highlight-words-alist nil
912 "Alist of group regexps and highlight regexps.
913 This variable uses the same syntax as `gnus-emphasis-alist'."
915 :type '(repeat (cons (regexp :tag "Group")
916 (repeat (list (regexp :tag "Highlight regexp")
917 (number :tag "Group for entire word" 0)
918 (number :tag "Group for displayed part" 0)
920 gnus-emphasis-highlight-words)))))
921 :group 'gnus-summary-visual)
923 (defcustom gnus-use-wheel nil
924 "Use Intelli-mouse on summary movement"
926 :group 'gnus-summary-maneuvering)
928 (defcustom gnus-wheel-scroll-amount '(5 . 1)
929 "Amount to scroll messages by spinning the mouse wheel.
930 This is actually a cons cell, where the first item is the amount to scroll
931 on a normal wheel event, and the second is the amount to scroll when the
932 wheel is moved with the shift key depressed."
933 :type '(cons (integer :tag "Shift") integer)
934 :group 'gnus-summary-maneuvering)
936 (defcustom gnus-wheel-edge-resistance 2
937 "How hard it should be to change the current article
938 by moving the mouse over the edge of the article window."
940 :group 'gnus-summary-maneuvering)
942 (defcustom gnus-summary-show-article-charset-alist
944 "Alist of number and charset.
945 The article will be shown with the charset corresponding to the
947 For example: ((1 . cn-gb-2312) (2 . big5))."
949 :type '(repeat (cons (number :tag "Argument" 1)
950 (symbol :tag "Charset")))
951 :group 'gnus-charset)
953 (defcustom gnus-preserve-marks t
954 "Whether marks are preserved when moving, copying and respooling messages."
957 :group 'gnus-summary-marks)
959 (defcustom gnus-alter-articles-to-read-function nil
960 "Function to be called to alter the list of articles to be selected."
962 :group 'gnus-summary)
964 (defcustom gnus-orphan-score nil
965 "*All orphans get this score added. Set in the score file."
966 :group 'gnus-score-default
967 :type '(choice (const nil)
970 (defcustom gnus-summary-save-parts-default-mime "image/.*"
971 "*A regexp to match MIME parts when saving multiple parts of a message
972 with gnus-summary-save-parts (X m). This regexp will be used by default
973 when prompting the user for which type of files to save."
978 (defcustom gnus-summary-save-parts-default-mime "image/.*"
979 "*A regexp to match MIME parts when saving multiple parts of a message
980 with gnus-summary-save-parts (X m). This regexp will be used by default
981 when prompting the user for which type of files to save."
986 ;;; Internal variables
988 (defvar gnus-article-mime-handles nil)
989 (defvar gnus-article-decoded-p nil)
990 (defvar gnus-article-charset nil)
991 (defvar gnus-article-ignored-charsets nil)
992 (defvar gnus-scores-exclude-files nil)
993 (defvar gnus-page-broken nil)
994 (defvar gnus-inhibit-mime-unbuttonizing nil)
996 (defvar gnus-original-article nil)
997 (defvar gnus-article-internal-prepare-hook nil)
998 (defvar gnus-newsgroup-process-stack nil)
1000 (defvar gnus-thread-indent-array nil)
1001 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1002 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1003 "Function called to sort the articles within a thread after it has been gathered together.")
1005 (defvar gnus-summary-save-parts-type-history nil)
1006 (defvar gnus-summary-save-parts-last-directory nil)
1008 (defvar gnus-summary-save-parts-type-history nil)
1009 (defvar gnus-summary-save-parts-last-directory nil)
1011 ;; Avoid highlighting in kill files.
1012 (defvar gnus-summary-inhibit-highlight nil)
1013 (defvar gnus-newsgroup-selected-overlay nil)
1014 (defvar gnus-inhibit-limiting nil)
1015 (defvar gnus-newsgroup-adaptive-score-file nil)
1016 (defvar gnus-current-score-file nil)
1017 (defvar gnus-current-move-group nil)
1018 (defvar gnus-current-copy-group nil)
1019 (defvar gnus-current-crosspost-group nil)
1021 (defvar gnus-newsgroup-dependencies nil)
1022 (defvar gnus-newsgroup-adaptive nil)
1023 (defvar gnus-summary-display-article-function nil)
1024 (defvar gnus-summary-highlight-line-function nil
1025 "Function called after highlighting a summary line.")
1027 (defvar gnus-summary-line-format-alist
1028 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1029 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1030 (?s gnus-tmp-subject-or-nil ?s)
1031 (?n gnus-tmp-name ?s)
1032 (?A (std11-address-string
1033 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1034 (?a (or (std11-full-name-string
1035 (car (mime-entity-read-field gnus-tmp-header 'From)))
1037 (?F gnus-tmp-from ?s)
1038 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1039 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1040 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1041 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1042 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1043 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1044 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1045 (?L gnus-tmp-lines ?d)
1046 (?I gnus-tmp-indentation ?s)
1047 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1048 (?R gnus-tmp-replied ?c)
1049 (?\[ gnus-tmp-opening-bracket ?c)
1050 (?\] gnus-tmp-closing-bracket ?c)
1051 (?\> (make-string gnus-tmp-level ? ) ?s)
1052 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1053 (?i gnus-tmp-score ?d)
1054 (?z gnus-tmp-score-char ?c)
1055 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1056 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1057 (?U gnus-tmp-unread ?c)
1058 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1059 (?t (gnus-summary-number-of-articles-in-thread
1060 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1062 (?e (gnus-summary-number-of-articles-in-thread
1063 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1065 (?u gnus-tmp-user-defined ?s)
1066 (?P (gnus-pick-line-number) ?d))
1067 "An alist of format specifications that can appear in summary lines.
1068 These are paired with what variables they correspond with, along with
1069 the type of the variable (string, integer, character, etc).")
1071 (defvar gnus-summary-dummy-line-format-alist
1072 `((?S gnus-tmp-subject ?s)
1073 (?N gnus-tmp-number ?d)
1074 (?u gnus-tmp-user-defined ?s)))
1076 (defvar gnus-summary-mode-line-format-alist
1077 `((?G gnus-tmp-group-name ?s)
1078 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1079 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1080 (?A gnus-tmp-article-number ?d)
1081 (?Z gnus-tmp-unread-and-unselected ?s)
1082 (?V gnus-version ?s)
1083 (?U gnus-tmp-unread-and-unticked ?d)
1084 (?S gnus-tmp-subject ?s)
1085 (?e gnus-tmp-unselected ?d)
1086 (?u gnus-tmp-user-defined ?s)
1087 (?d (length gnus-newsgroup-dormant) ?d)
1088 (?t (length gnus-newsgroup-marked) ?d)
1089 (?r (length gnus-newsgroup-reads) ?d)
1090 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1091 (?E gnus-newsgroup-expunged-tally ?d)
1092 (?s (gnus-current-score-file-nondirectory) ?s)))
1094 (defvar gnus-last-search-regexp nil
1095 "Default regexp for article search command.")
1097 (defvar gnus-summary-search-article-matched-data nil
1098 "Last matched data of article search command. It is the local variable
1099 in `gnus-article-buffer' which consists of the list of start position,
1100 end position and text.")
1102 (defvar gnus-last-shell-command nil
1103 "Default shell command on article.")
1105 (defvar gnus-newsgroup-begin nil)
1106 (defvar gnus-newsgroup-end nil)
1107 (defvar gnus-newsgroup-last-rmail nil)
1108 (defvar gnus-newsgroup-last-mail nil)
1109 (defvar gnus-newsgroup-last-folder nil)
1110 (defvar gnus-newsgroup-last-file nil)
1111 (defvar gnus-newsgroup-auto-expire nil)
1112 (defvar gnus-newsgroup-active nil)
1114 (defvar gnus-newsgroup-data nil)
1115 (defvar gnus-newsgroup-data-reverse nil)
1116 (defvar gnus-newsgroup-limit nil)
1117 (defvar gnus-newsgroup-limits nil)
1119 (defvar gnus-newsgroup-unreads nil
1120 "List of unread articles in the current newsgroup.")
1122 (defvar gnus-newsgroup-unselected nil
1123 "List of unselected unread articles in the current newsgroup.")
1125 (defvar gnus-newsgroup-reads nil
1126 "Alist of read articles and article marks in the current newsgroup.")
1128 (defvar gnus-newsgroup-expunged-tally nil)
1130 (defvar gnus-newsgroup-marked nil
1131 "List of ticked articles in the current newsgroup (a subset of unread art).")
1133 (defvar gnus-newsgroup-killed nil
1134 "List of ranges of articles that have been through the scoring process.")
1136 (defvar gnus-newsgroup-cached nil
1137 "List of articles that come from the article cache.")
1139 (defvar gnus-newsgroup-saved nil
1140 "List of articles that have been saved.")
1142 (defvar gnus-newsgroup-kill-headers nil)
1144 (defvar gnus-newsgroup-replied nil
1145 "List of articles that have been replied to in the current newsgroup.")
1147 (defvar gnus-newsgroup-expirable nil
1148 "List of articles in the current newsgroup that can be expired.")
1150 (defvar gnus-newsgroup-processable nil
1151 "List of articles in the current newsgroup that can be processed.")
1153 (defvar gnus-newsgroup-downloadable nil
1154 "List of articles in the current newsgroup that can be processed.")
1156 (defvar gnus-newsgroup-undownloaded nil
1157 "List of articles in the current newsgroup that haven't been downloaded..")
1159 (defvar gnus-newsgroup-unsendable nil
1160 "List of articles in the current newsgroup that won't be sent.")
1162 (defvar gnus-newsgroup-bookmarks nil
1163 "List of articles in the current newsgroup that have bookmarks.")
1165 (defvar gnus-newsgroup-dormant nil
1166 "List of dormant articles in the current newsgroup.")
1168 (defvar gnus-newsgroup-scored nil
1169 "List of scored articles in the current newsgroup.")
1171 (defvar gnus-newsgroup-incorporated nil
1172 "List of incorporated articles in the current newsgroup.")
1174 (defvar gnus-newsgroup-headers nil
1175 "List of article headers in the current newsgroup.")
1177 (defvar gnus-newsgroup-threads nil)
1179 (defvar gnus-newsgroup-prepared nil
1180 "Whether the current group has been prepared properly.")
1182 (defvar gnus-newsgroup-ancient nil
1183 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1185 (defvar gnus-newsgroup-sparse nil)
1187 (defvar gnus-current-article nil)
1188 (defvar gnus-article-current nil)
1189 (defvar gnus-current-headers nil)
1190 (defvar gnus-have-all-headers nil)
1191 (defvar gnus-last-article nil)
1192 (defvar gnus-newsgroup-history nil)
1193 (defvar gnus-newsgroup-charset nil)
1194 (defvar gnus-newsgroup-ephemeral-charset nil)
1195 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1197 (defvar gnus-article-before-search nil)
1199 (defconst gnus-summary-local-variables
1200 '(gnus-newsgroup-name
1201 gnus-newsgroup-begin gnus-newsgroup-end
1202 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1203 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1204 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1205 gnus-newsgroup-unselected gnus-newsgroup-marked
1206 gnus-newsgroup-reads gnus-newsgroup-saved
1207 gnus-newsgroup-replied gnus-newsgroup-expirable
1208 gnus-newsgroup-processable gnus-newsgroup-killed
1209 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1210 gnus-newsgroup-unsendable
1211 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1212 gnus-newsgroup-headers gnus-newsgroup-threads
1213 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1214 gnus-current-article gnus-current-headers gnus-have-all-headers
1215 gnus-last-article gnus-article-internal-prepare-hook
1216 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1217 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1218 gnus-thread-expunge-below
1219 gnus-score-alist gnus-current-score-file
1220 (gnus-summary-expunge-below . global)
1221 (gnus-summary-mark-below . global)
1222 (gnus-orphan-score . global)
1223 gnus-newsgroup-active gnus-scores-exclude-files
1224 gnus-newsgroup-history gnus-newsgroup-ancient
1225 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1226 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1227 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1228 (gnus-newsgroup-expunged-tally . 0)
1229 gnus-cache-removable-articles gnus-newsgroup-cached
1230 gnus-newsgroup-data gnus-newsgroup-data-reverse
1231 gnus-newsgroup-limit gnus-newsgroup-limits
1232 gnus-newsgroup-charset
1233 gnus-newsgroup-incorporated)
1234 "Variables that are buffer-local to the summary buffers.")
1236 (defvar gnus-newsgroup-variables nil
1237 "Variables that have separate values in the newsgroups.")
1239 ;; Byte-compiler warning.
1240 (eval-when-compile (defvar gnus-article-mode-map))
1242 ;; Subject simplification.
1244 (defun gnus-simplify-whitespace (str)
1245 "Remove excessive whitespace from STR."
1248 (while (string-match "[ \t][ \t]+" mystr)
1249 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1251 (substring mystr (match-end 0)))))
1253 (when (string-match "^[ \t]+" mystr)
1254 (setq mystr (substring mystr (match-end 0))))
1256 (when (string-match "[ \t]+$" mystr)
1257 (setq mystr (substring mystr 0 (match-beginning 0))))
1260 (defsubst gnus-simplify-subject-re (subject)
1261 "Remove \"Re:\" from subject lines."
1262 (if (string-match message-subject-re-regexp subject)
1263 (substring subject (match-end 0))
1266 (defun gnus-simplify-subject (subject &optional re-only)
1267 "Remove `Re:' and words in parentheses.
1268 If RE-ONLY is non-nil, strip leading `Re:'s only."
1269 (let ((case-fold-search t)) ;Ignore case.
1270 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1271 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1272 (setq subject (substring subject (match-end 0))))
1273 ;; Remove uninteresting prefixes.
1274 (when (and (not re-only)
1275 gnus-simplify-ignored-prefixes
1276 (string-match gnus-simplify-ignored-prefixes subject))
1277 (setq subject (substring subject (match-end 0))))
1278 ;; Remove words in parentheses from end.
1280 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1281 (setq subject (substring subject 0 (match-beginning 0)))))
1282 ;; Return subject string.
1285 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1287 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1288 (goto-char (point-min))
1289 (while (re-search-forward regexp nil t)
1290 (replace-match (or newtext ""))))
1292 (defun gnus-simplify-buffer-fuzzy ()
1293 "Simplify string in the buffer fuzzily.
1294 The string in the accessible portion of the current buffer is simplified.
1295 It is assumed to be a single-line subject.
1296 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1297 matter is removed. Additional things can be deleted by setting
1298 `gnus-simplify-subject-fuzzy-regexp'."
1299 (let ((case-fold-search t)
1301 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1303 (while (not (eq modified-tick (buffer-modified-tick)))
1304 (setq modified-tick (buffer-modified-tick))
1306 ((listp gnus-simplify-subject-fuzzy-regexp)
1307 (mapcar 'gnus-simplify-buffer-fuzzy-step
1308 gnus-simplify-subject-fuzzy-regexp))
1309 (gnus-simplify-subject-fuzzy-regexp
1310 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1311 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1312 (gnus-simplify-buffer-fuzzy-step
1313 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1314 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1316 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1317 (gnus-simplify-buffer-fuzzy-step " +" " ")
1318 (gnus-simplify-buffer-fuzzy-step " $")
1319 (gnus-simplify-buffer-fuzzy-step "^ +")))
1321 (defun gnus-simplify-subject-fuzzy (subject)
1322 "Simplify a subject string fuzzily.
1323 See `gnus-simplify-buffer-fuzzy' for details."
1325 (gnus-set-work-buffer)
1326 (let ((case-fold-search t))
1327 ;; Remove uninteresting prefixes.
1328 (when (and gnus-simplify-ignored-prefixes
1329 (string-match gnus-simplify-ignored-prefixes subject))
1330 (setq subject (substring subject (match-end 0))))
1332 (inline (gnus-simplify-buffer-fuzzy))
1335 (defsubst gnus-simplify-subject-fully (subject)
1336 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1338 (gnus-simplify-subject-functions
1339 (gnus-map-function gnus-simplify-subject-functions subject))
1340 ((null gnus-summary-gather-subject-limit)
1341 (gnus-simplify-subject-re subject))
1342 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1343 (gnus-simplify-subject-fuzzy subject))
1344 ((numberp gnus-summary-gather-subject-limit)
1345 (gnus-limit-string (gnus-simplify-subject-re subject)
1346 gnus-summary-gather-subject-limit))
1350 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1351 "Check whether two subjects are equal.
1352 If optional argument simple-first is t, first argument is already
1355 ((null simple-first)
1356 (equal (gnus-simplify-subject-fully s1)
1357 (gnus-simplify-subject-fully s2)))
1360 (gnus-simplify-subject-fully s2)))))
1362 (defun gnus-summary-bubble-group ()
1363 "Increase the score of the current group.
1364 This is a handy function to add to `gnus-summary-exit-hook' to
1365 increase the score of each group you read."
1366 (gnus-group-add-score gnus-newsgroup-name))
1370 ;;; Gnus summary mode
1373 (put 'gnus-summary-mode 'mode-class 'special)
1375 (defvar gnus-article-commands-menu)
1378 ;; Non-orthogonal keys
1380 (gnus-define-keys gnus-summary-mode-map
1381 " " gnus-summary-next-page
1382 "\177" gnus-summary-prev-page
1383 [delete] gnus-summary-prev-page
1384 [backspace] gnus-summary-prev-page
1385 "\r" gnus-summary-scroll-up
1386 "\M-\r" gnus-summary-scroll-down
1387 "n" gnus-summary-next-unread-article
1388 "p" gnus-summary-prev-unread-article
1389 "N" gnus-summary-next-article
1390 "P" gnus-summary-prev-article
1391 "\M-\C-n" gnus-summary-next-same-subject
1392 "\M-\C-p" gnus-summary-prev-same-subject
1393 "\M-n" gnus-summary-next-unread-subject
1394 "\M-p" gnus-summary-prev-unread-subject
1395 "." gnus-summary-first-unread-article
1396 "," gnus-summary-best-unread-article
1397 "\M-s" gnus-summary-search-article-forward
1398 "\M-r" gnus-summary-search-article-backward
1399 "<" gnus-summary-beginning-of-article
1400 ">" gnus-summary-end-of-article
1401 "j" gnus-summary-goto-article
1402 "^" gnus-summary-refer-parent-article
1403 "\M-^" gnus-summary-refer-article
1404 "u" gnus-summary-tick-article-forward
1405 "!" gnus-summary-tick-article-forward
1406 "U" gnus-summary-tick-article-backward
1407 "d" gnus-summary-mark-as-read-forward
1408 "D" gnus-summary-mark-as-read-backward
1409 "E" gnus-summary-mark-as-expirable
1410 "\M-u" gnus-summary-clear-mark-forward
1411 "\M-U" gnus-summary-clear-mark-backward
1412 "k" gnus-summary-kill-same-subject-and-select
1413 "\C-k" gnus-summary-kill-same-subject
1414 "\M-\C-k" gnus-summary-kill-thread
1415 "\M-\C-l" gnus-summary-lower-thread
1416 "e" gnus-summary-edit-article
1417 "#" gnus-summary-mark-as-processable
1418 "\M-#" gnus-summary-unmark-as-processable
1419 "\M-\C-t" gnus-summary-toggle-threads
1420 "\M-\C-s" gnus-summary-show-thread
1421 "\M-\C-h" gnus-summary-hide-thread
1422 "\M-\C-f" gnus-summary-next-thread
1423 "\M-\C-b" gnus-summary-prev-thread
1424 [(meta down)] gnus-summary-next-thread
1425 [(meta up)] gnus-summary-prev-thread
1426 "\M-\C-u" gnus-summary-up-thread
1427 "\M-\C-d" gnus-summary-down-thread
1428 "&" gnus-summary-execute-command
1429 "c" gnus-summary-catchup-and-exit
1430 "\C-w" gnus-summary-mark-region-as-read
1431 "\C-t" gnus-summary-toggle-truncation
1432 "?" gnus-summary-mark-as-dormant
1433 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1434 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1435 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1436 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1437 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1438 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1439 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1440 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1441 "=" gnus-summary-expand-window
1442 "\C-x\C-s" gnus-summary-reselect-current-group
1443 "\M-g" gnus-summary-rescan-group
1444 "w" gnus-summary-stop-page-breaking
1445 "\C-c\C-r" gnus-summary-caesar-message
1446 "\M-t" gnus-summary-toggle-mime
1447 "f" gnus-summary-followup
1448 "F" gnus-summary-followup-with-original
1449 "C" gnus-summary-cancel-article
1450 "r" gnus-summary-reply
1451 "R" gnus-summary-reply-with-original
1452 "\C-c\C-f" gnus-summary-mail-forward
1453 "o" gnus-summary-save-article
1454 "\C-o" gnus-summary-save-article-mail
1455 "|" gnus-summary-pipe-output
1456 "\M-k" gnus-summary-edit-local-kill
1457 "\M-K" gnus-summary-edit-global-kill
1459 "\C-c\C-d" gnus-summary-describe-group
1460 "q" gnus-summary-exit
1461 "Q" gnus-summary-exit-no-update
1462 "\C-c\C-i" gnus-info-find-node
1463 gnus-mouse-2 gnus-mouse-pick-article
1464 "m" gnus-summary-mail-other-window
1465 "a" gnus-summary-post-news
1466 "x" gnus-summary-limit-to-unread
1467 "s" gnus-summary-isearch-article
1468 "t" gnus-article-toggle-headers
1469 "g" gnus-summary-show-article
1470 "l" gnus-summary-goto-last-article
1471 "v" gnus-summary-preview-mime-message
1472 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1473 "\C-d" gnus-summary-enter-digest-group
1474 "\M-\C-d" gnus-summary-read-document
1475 "\M-\C-e" gnus-summary-edit-parameters
1476 "\M-\C-a" gnus-summary-customize-parameters
1478 "*" gnus-cache-enter-article
1479 "\M-*" gnus-cache-remove-article
1480 "\M-&" gnus-summary-universal-argument
1481 "\C-l" gnus-recenter
1482 "I" gnus-summary-increase-score
1483 "L" gnus-summary-lower-score
1484 "\M-i" gnus-symbolic-argument
1485 "h" gnus-summary-select-article-buffer
1487 "V" gnus-summary-score-map
1488 "X" gnus-uu-extract-map
1489 "S" gnus-summary-send-map)
1491 ;; Sort of orthogonal keymap
1492 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1493 "t" gnus-summary-tick-article-forward
1494 "!" gnus-summary-tick-article-forward
1495 "d" gnus-summary-mark-as-read-forward
1496 "r" gnus-summary-mark-as-read-forward
1497 "c" gnus-summary-clear-mark-forward
1498 " " gnus-summary-clear-mark-forward
1499 "e" gnus-summary-mark-as-expirable
1500 "x" gnus-summary-mark-as-expirable
1501 "?" gnus-summary-mark-as-dormant
1502 "b" gnus-summary-set-bookmark
1503 "B" gnus-summary-remove-bookmark
1504 "#" gnus-summary-mark-as-processable
1505 "\M-#" gnus-summary-unmark-as-processable
1506 "S" gnus-summary-limit-include-expunged
1507 "C" gnus-summary-catchup
1508 "H" gnus-summary-catchup-to-here
1509 "\C-c" gnus-summary-catchup-all
1510 "k" gnus-summary-kill-same-subject-and-select
1511 "K" gnus-summary-kill-same-subject
1512 "P" gnus-uu-mark-map)
1514 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1515 "c" gnus-summary-clear-above
1516 "u" gnus-summary-tick-above
1517 "m" gnus-summary-mark-above
1518 "k" gnus-summary-kill-below)
1520 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1521 "/" gnus-summary-limit-to-subject
1522 "n" gnus-summary-limit-to-articles
1523 "w" gnus-summary-pop-limit
1524 "s" gnus-summary-limit-to-subject
1525 "a" gnus-summary-limit-to-author
1526 "u" gnus-summary-limit-to-unread
1527 "m" gnus-summary-limit-to-marks
1528 "M" gnus-summary-limit-exclude-marks
1529 "v" gnus-summary-limit-to-score
1530 "*" gnus-summary-limit-include-cached
1531 "D" gnus-summary-limit-include-dormant
1532 "T" gnus-summary-limit-include-thread
1533 "d" gnus-summary-limit-exclude-dormant
1534 "t" gnus-summary-limit-to-age
1535 "x" gnus-summary-limit-to-extra
1536 "E" gnus-summary-limit-include-expunged
1537 "c" gnus-summary-limit-exclude-childless-dormant
1538 "C" gnus-summary-limit-mark-excluded-as-read)
1540 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1541 "n" gnus-summary-next-unread-article
1542 "p" gnus-summary-prev-unread-article
1543 "N" gnus-summary-next-article
1544 "P" gnus-summary-prev-article
1545 "\C-n" gnus-summary-next-same-subject
1546 "\C-p" gnus-summary-prev-same-subject
1547 "\M-n" gnus-summary-next-unread-subject
1548 "\M-p" gnus-summary-prev-unread-subject
1549 "f" gnus-summary-first-unread-article
1550 "b" gnus-summary-best-unread-article
1551 "j" gnus-summary-goto-article
1552 "g" gnus-summary-goto-subject
1553 "l" gnus-summary-goto-last-article
1554 "o" gnus-summary-pop-article)
1556 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1557 "k" gnus-summary-kill-thread
1558 "l" gnus-summary-lower-thread
1559 "i" gnus-summary-raise-thread
1560 "T" gnus-summary-toggle-threads
1561 "t" gnus-summary-rethread-current
1562 "^" gnus-summary-reparent-thread
1563 "s" gnus-summary-show-thread
1564 "S" gnus-summary-show-all-threads
1565 "h" gnus-summary-hide-thread
1566 "H" gnus-summary-hide-all-threads
1567 "n" gnus-summary-next-thread
1568 "p" gnus-summary-prev-thread
1569 "u" gnus-summary-up-thread
1570 "o" gnus-summary-top-thread
1571 "d" gnus-summary-down-thread
1572 "#" gnus-uu-mark-thread
1573 "\M-#" gnus-uu-unmark-thread)
1575 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1576 "g" gnus-summary-prepare
1577 "c" gnus-summary-insert-cached-articles)
1579 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1580 "c" gnus-summary-catchup-and-exit
1581 "C" gnus-summary-catchup-all-and-exit
1582 "E" gnus-summary-exit-no-update
1583 "J" gnus-summary-jump-to-other-group
1584 "Q" gnus-summary-exit
1585 "Z" gnus-summary-exit
1586 "n" gnus-summary-catchup-and-goto-next-group
1587 "R" gnus-summary-reselect-current-group
1588 "G" gnus-summary-rescan-group
1589 "N" gnus-summary-next-group
1590 "s" gnus-summary-save-newsrc
1591 "P" gnus-summary-prev-group)
1593 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1594 " " gnus-summary-next-page
1595 "n" gnus-summary-next-page
1596 "\177" gnus-summary-prev-page
1597 [delete] gnus-summary-prev-page
1598 "p" gnus-summary-prev-page
1599 "\r" gnus-summary-scroll-up
1600 "\M-\r" gnus-summary-scroll-down
1601 "<" gnus-summary-beginning-of-article
1602 ">" gnus-summary-end-of-article
1603 "b" gnus-summary-beginning-of-article
1604 "e" gnus-summary-end-of-article
1605 "^" gnus-summary-refer-parent-article
1606 "r" gnus-summary-refer-parent-article
1607 "D" gnus-summary-enter-digest-group
1608 "R" gnus-summary-refer-references
1609 "T" gnus-summary-refer-thread
1610 "g" gnus-summary-show-article
1611 "s" gnus-summary-isearch-article
1612 "P" gnus-summary-print-article
1613 "M" gnus-mailing-list-insinuate
1614 "t" gnus-article-babel)
1616 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1617 "b" gnus-article-add-buttons
1618 "B" gnus-article-add-buttons-to-head
1619 "o" gnus-article-treat-overstrike
1620 "e" gnus-article-emphasize
1621 "w" gnus-article-fill-cited-article
1622 "Q" gnus-article-fill-long-lines
1623 "C" gnus-article-capitalize-sentences
1624 "c" gnus-article-remove-cr
1625 "Z" gnus-article-decode-HZ
1626 "f" gnus-article-display-x-face
1627 "l" gnus-summary-stop-page-breaking
1628 "r" gnus-summary-caesar-message
1629 "t" gnus-article-toggle-headers
1630 "v" gnus-summary-verbose-headers
1631 "m" gnus-summary-toggle-mime
1632 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1633 "p" gnus-article-verify-x-pgp-sig
1634 "d" gnus-article-treat-dumbquotes
1635 "s" gnus-smiley-display)
1637 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1638 "a" gnus-article-hide
1639 "h" gnus-article-toggle-headers
1640 "b" gnus-article-hide-boring-headers
1641 "s" gnus-article-hide-signature
1642 "c" gnus-article-hide-citation
1643 "C" gnus-article-hide-citation-in-followups
1644 "l" gnus-article-hide-list-identifiers
1645 "p" gnus-article-hide-pgp
1646 "B" gnus-article-strip-banner
1647 "P" gnus-article-hide-pem
1648 "\C-c" gnus-article-hide-citation-maybe)
1650 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1651 "a" gnus-article-highlight
1652 "h" gnus-article-highlight-headers
1653 "c" gnus-article-highlight-citation
1654 "s" gnus-article-highlight-signature)
1656 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1657 "z" gnus-article-date-ut
1658 "u" gnus-article-date-ut
1659 "l" gnus-article-date-local
1660 "p" gnus-article-date-english
1661 "e" gnus-article-date-lapsed
1662 "o" gnus-article-date-original
1663 "i" gnus-article-date-iso8601
1664 "s" gnus-article-date-user)
1666 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1667 "t" gnus-article-remove-trailing-blank-lines
1668 "l" gnus-article-strip-leading-blank-lines
1669 "m" gnus-article-strip-multiple-blank-lines
1670 "a" gnus-article-strip-blank-lines
1671 "A" gnus-article-strip-all-blank-lines
1672 "s" gnus-article-strip-leading-space
1673 "e" gnus-article-strip-trailing-space
1674 "w" gnus-article-remove-leading-whitespace)
1676 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1678 "f" gnus-summary-fetch-faq
1679 "d" gnus-summary-describe-group
1680 "h" gnus-summary-describe-briefly
1681 "i" gnus-info-find-node)
1683 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1684 "e" gnus-summary-expire-articles
1685 "\M-\C-e" gnus-summary-expire-articles-now
1686 "\177" gnus-summary-delete-article
1687 [delete] gnus-summary-delete-article
1688 [backspace] gnus-summary-delete-article
1689 "m" gnus-summary-move-article
1690 "r" gnus-summary-respool-article
1691 "w" gnus-summary-edit-article
1692 "c" gnus-summary-copy-article
1693 "B" gnus-summary-crosspost-article
1694 "q" gnus-summary-respool-query
1695 "t" gnus-summary-respool-trace
1696 "i" gnus-summary-import-article
1697 "p" gnus-summary-article-posted-p)
1699 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1700 "o" gnus-summary-save-article
1701 "m" gnus-summary-save-article-mail
1702 "F" gnus-summary-write-article-file
1703 "r" gnus-summary-save-article-rmail
1704 "f" gnus-summary-save-article-file
1705 "b" gnus-summary-save-article-body-file
1706 "h" gnus-summary-save-article-folder
1707 "v" gnus-summary-save-article-vm
1708 "p" gnus-summary-pipe-output
1709 "s" gnus-soup-add-article)
1711 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1712 "b" gnus-summary-display-buttonized
1713 "m" gnus-summary-repair-multipart
1714 "v" gnus-article-view-part
1715 "o" gnus-article-save-part
1716 "c" gnus-article-copy-part
1717 "C" gnus-article-view-part-as-charset
1718 "e" gnus-article-externalize-part
1719 "E" gnus-article-encrypt-body
1720 "i" gnus-article-inline-part
1721 "|" gnus-article-pipe-part))
1723 (defun gnus-summary-make-menu-bar ()
1724 (gnus-turn-off-edit-menu 'summary)
1726 (unless (boundp 'gnus-summary-misc-menu)
1729 gnus-summary-kill-menu gnus-summary-mode-map ""
1734 ["Customize" gnus-score-customize t])
1735 (gnus-make-score-map 'increase)
1736 (gnus-make-score-map 'lower)
1738 ["Kill below" gnus-summary-kill-below t]
1739 ["Mark above" gnus-summary-mark-above t]
1740 ["Tick above" gnus-summary-tick-above t]
1741 ["Clear above" gnus-summary-clear-above t])
1742 ["Current score" gnus-summary-current-score t]
1743 ["Set score" gnus-summary-set-score t]
1744 ["Switch current score file..." gnus-score-change-score-file t]
1745 ["Set mark below..." gnus-score-set-mark-below t]
1746 ["Set expunge below..." gnus-score-set-expunge-below t]
1747 ["Edit current score file" gnus-score-edit-current-scores t]
1748 ["Edit score file" gnus-score-edit-file t]
1749 ["Trace score" gnus-score-find-trace t]
1750 ["Find words" gnus-score-find-favourite-words t]
1751 ["Rescore buffer" gnus-summary-rescore t]
1752 ["Increase score..." gnus-summary-increase-score t]
1753 ["Lower score..." gnus-summary-lower-score t]))))
1755 ;; Define both the Article menu in the summary buffer and the equivalent
1756 ;; Commands menu in the article buffer here for consistency.
1759 ["All" gnus-article-hide t]
1760 ["Headers" gnus-article-toggle-headers t]
1761 ["Signature" gnus-article-hide-signature t]
1762 ["Citation" gnus-article-hide-citation t]
1763 ["List identifiers" gnus-article-hide-list-identifiers t]
1764 ["PGP" gnus-article-hide-pgp t]
1765 ["Banner" gnus-article-strip-banner t]
1766 ["Boring headers" gnus-article-hide-boring-headers t])
1768 ["All" gnus-article-highlight t]
1769 ["Headers" gnus-article-highlight-headers t]
1770 ["Signature" gnus-article-highlight-signature t]
1771 ["Citation" gnus-article-highlight-citation t])
1773 ["Local" gnus-article-date-local t]
1774 ["ISO8601" gnus-article-date-iso8601 t]
1775 ["UT" gnus-article-date-ut t]
1776 ["Original" gnus-article-date-original t]
1777 ["Lapsed" gnus-article-date-lapsed t]
1778 ["User-defined" gnus-article-date-user t])
1781 ["Leading" gnus-article-strip-leading-blank-lines t]
1782 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1783 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1784 ["All of the above" gnus-article-strip-blank-lines t]
1785 ["All" gnus-article-strip-all-blank-lines t]
1786 ["Leading space" gnus-article-strip-leading-space t]
1787 ["Trailing space" gnus-article-strip-trailing-space t]
1788 ["Leading space in headers"
1789 gnus-article-remove-leading-whitespace t])
1790 ["Overstrike" gnus-article-treat-overstrike t]
1791 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1792 ["Emphasis" gnus-article-emphasize t]
1793 ["Word wrap" gnus-article-fill-cited-article t]
1794 ["Fill long lines" gnus-article-fill-long-lines t]
1795 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1796 ["CR" gnus-article-remove-cr t]
1797 ["Show X-Face" gnus-article-display-x-face t]
1798 ["Rot 13" gnus-summary-caesar-message
1799 ,@(if (featurep 'xemacs) '(t)
1800 '(:help "\"Caesar rotate\" article by 13"))]
1801 ["Unix pipe" gnus-summary-pipe-message t]
1802 ["Add buttons" gnus-article-add-buttons t]
1803 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1804 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1805 ["Toggle MIME" gnus-summary-toggle-mime t]
1806 ["Verbose header" gnus-summary-verbose-headers t]
1807 ["Toggle header" gnus-summary-toggle-header t]
1808 ["Toggle smileys" gnus-smiley-display t]
1809 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1810 ["HZ" gnus-article-decode-HZ t])
1812 ["Save in default format" gnus-summary-save-article
1813 ,@(if (featurep 'xemacs) '(t)
1814 '(:help "Save article using default method"))]
1815 ["Save in file" gnus-summary-save-article-file
1816 ,@(if (featurep 'xemacs) '(t)
1817 '(:help "Save article in file"))]
1818 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1819 ["Save in MH folder" gnus-summary-save-article-folder t]
1820 ["Save in VM folder" gnus-summary-save-article-vm t]
1821 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1822 ["Save body in file" gnus-summary-save-article-body-file t]
1823 ["Pipe through a filter" gnus-summary-pipe-output t]
1824 ["Add to SOUP packet" gnus-soup-add-article t]
1825 ["Print" gnus-summary-print-article t])
1827 ["Respool article..." gnus-summary-respool-article t]
1828 ["Move article..." gnus-summary-move-article
1829 (gnus-check-backend-function
1830 'request-move-article gnus-newsgroup-name)]
1831 ["Copy article..." gnus-summary-copy-article t]
1832 ["Crosspost article..." gnus-summary-crosspost-article
1833 (gnus-check-backend-function
1834 'request-replace-article gnus-newsgroup-name)]
1835 ["Import file..." gnus-summary-import-article t]
1836 ["Check if posted" gnus-summary-article-posted-p t]
1837 ["Edit article" gnus-summary-edit-article
1838 (not (gnus-group-read-only-p))]
1839 ["Delete article" gnus-summary-delete-article
1840 (gnus-check-backend-function
1841 'request-expire-articles gnus-newsgroup-name)]
1842 ["Query respool" gnus-summary-respool-query t]
1843 ["Trace respool" gnus-summary-respool-trace t]
1844 ["Delete expirable articles" gnus-summary-expire-articles-now
1845 (gnus-check-backend-function
1846 'request-expire-articles gnus-newsgroup-name)])
1848 ["Uudecode" gnus-uu-decode-uu
1849 ,@(if (featurep 'xemacs) '(t)
1850 '(:help "Decode uuencoded article(s)"))]
1851 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1852 ["Unshar" gnus-uu-decode-unshar t]
1853 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1854 ["Save" gnus-uu-decode-save t]
1855 ["Binhex" gnus-uu-decode-binhex t]
1856 ["Postscript" gnus-uu-decode-postscript t])
1858 ["Enter article" gnus-cache-enter-article t]
1859 ["Remove article" gnus-cache-remove-article t])
1860 ["Translate" gnus-article-babel t]
1861 ["Select article buffer" gnus-summary-select-article-buffer t]
1862 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1863 ["Isearch article..." gnus-summary-isearch-article t]
1864 ["Beginning of the article" gnus-summary-beginning-of-article t]
1865 ["End of the article" gnus-summary-end-of-article t]
1866 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1867 ["Fetch referenced articles" gnus-summary-refer-references t]
1868 ["Fetch current thread" gnus-summary-refer-thread t]
1869 ["Fetch article with id..." gnus-summary-refer-article t]
1870 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1871 ["Redisplay" gnus-summary-show-article t])))
1873 gnus-summary-article-menu gnus-summary-mode-map ""
1874 (cons "Article" innards))
1876 (if (not (keymapp gnus-summary-article-menu))
1878 gnus-article-commands-menu gnus-article-mode-map ""
1879 (cons "Commands" innards))
1880 ;; in Emacs, don't share menu.
1881 (setq gnus-article-commands-menu
1882 (copy-keymap gnus-summary-article-menu))
1883 (define-key gnus-article-mode-map [menu-bar commands]
1884 (cons "Commands" gnus-article-commands-menu))))
1887 gnus-summary-thread-menu gnus-summary-mode-map ""
1889 ["Toggle threading" gnus-summary-toggle-threads t]
1890 ["Hide threads" gnus-summary-hide-all-threads t]
1891 ["Show threads" gnus-summary-show-all-threads t]
1892 ["Hide thread" gnus-summary-hide-thread t]
1893 ["Show thread" gnus-summary-show-thread t]
1894 ["Go to next thread" gnus-summary-next-thread t]
1895 ["Go to previous thread" gnus-summary-prev-thread t]
1896 ["Go down thread" gnus-summary-down-thread t]
1897 ["Go up thread" gnus-summary-up-thread t]
1898 ["Top of thread" gnus-summary-top-thread t]
1899 ["Mark thread as read" gnus-summary-kill-thread t]
1900 ["Lower thread score" gnus-summary-lower-thread t]
1901 ["Raise thread score" gnus-summary-raise-thread t]
1902 ["Rethread current" gnus-summary-rethread-current t]))
1905 gnus-summary-post-menu gnus-summary-mode-map ""
1907 ["Post an article" gnus-summary-post-news
1908 ,@(if (featurep 'xemacs) '(t)
1909 '(:help "Post an article"))]
1910 ["Followup" gnus-summary-followup
1911 ,@(if (featurep 'xemacs) '(t)
1912 '(:help "Post followup to this article"))]
1913 ["Followup and yank" gnus-summary-followup-with-original
1914 ,@(if (featurep 'xemacs) '(t)
1915 '(:help "Post followup to this article, quoting its contents"))]
1916 ["Supersede article" gnus-summary-supersede-article t]
1917 ["Cancel article" gnus-summary-cancel-article
1918 ,@(if (featurep 'xemacs) '(t)
1919 '(:help "Cancel an article you posted"))]
1920 ["Reply" gnus-summary-reply t]
1921 ["Reply and yank" gnus-summary-reply-with-original t]
1922 ["Wide reply" gnus-summary-wide-reply t]
1923 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1924 ,@(if (featurep 'xemacs) '(t)
1925 '(:help "Mail a reply, quoting this article"))]
1926 ["Mail forward" gnus-summary-mail-forward t]
1927 ["Post forward" gnus-summary-post-forward t]
1928 ["Digest and mail" gnus-uu-digest-mail-forward t]
1929 ["Digest and post" gnus-uu-digest-post-forward t]
1930 ["Resend message" gnus-summary-resend-message t]
1931 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1932 ["Send a mail" gnus-summary-mail-other-window t]
1933 ["Uuencode and post" gnus-uu-post-news
1934 ,@(if (featurep 'xemacs) '(t)
1935 '(:help "Post a uuencoded article"))]
1936 ["Followup via news" gnus-summary-followup-to-mail t]
1937 ["Followup via news and yank"
1938 gnus-summary-followup-to-mail-with-original t]
1940 ;;["Send" gnus-summary-send-draft t]
1941 ;;["Send bounced" gnus-resend-bounced-mail t])
1945 gnus-summary-misc-menu gnus-summary-mode-map ""
1948 ["Mark as read" gnus-summary-mark-as-read-forward t]
1949 ["Mark same subject and select"
1950 gnus-summary-kill-same-subject-and-select t]
1951 ["Mark same subject" gnus-summary-kill-same-subject t]
1952 ["Catchup" gnus-summary-catchup
1953 ,@(if (featurep 'xemacs) '(t)
1954 '(:help "Mark unread articles in this group as read"))]
1955 ["Catchup all" gnus-summary-catchup-all t]
1956 ["Catchup to here" gnus-summary-catchup-to-here t]
1957 ["Catchup region" gnus-summary-mark-region-as-read t]
1958 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1960 ["Tick" gnus-summary-tick-article-forward t]
1961 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1962 ["Remove marks" gnus-summary-clear-mark-forward t]
1963 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1964 ["Set bookmark" gnus-summary-set-bookmark t]
1965 ["Remove bookmark" gnus-summary-remove-bookmark t])
1967 ["Marks..." gnus-summary-limit-to-marks t]
1968 ["Subject..." gnus-summary-limit-to-subject t]
1969 ["Author..." gnus-summary-limit-to-author t]
1970 ["Age..." gnus-summary-limit-to-age t]
1971 ["Extra..." gnus-summary-limit-to-extra t]
1972 ["Score" gnus-summary-limit-to-score t]
1973 ["Unread" gnus-summary-limit-to-unread t]
1974 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1975 ["Articles" gnus-summary-limit-to-articles t]
1976 ["Pop limit" gnus-summary-pop-limit t]
1977 ["Show dormant" gnus-summary-limit-include-dormant t]
1978 ["Hide childless dormant"
1979 gnus-summary-limit-exclude-childless-dormant t]
1980 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1981 ["Hide marked" gnus-summary-limit-exclude-marks t]
1982 ["Show expunged" gnus-summary-show-all-expunged t])
1984 ["Set mark" gnus-summary-mark-as-processable t]
1985 ["Remove mark" gnus-summary-unmark-as-processable t]
1986 ["Remove all marks" gnus-summary-unmark-all-processable t]
1987 ["Mark above" gnus-uu-mark-over t]
1988 ["Mark series" gnus-uu-mark-series t]
1989 ["Mark region" gnus-uu-mark-region t]
1990 ["Unmark region" gnus-uu-unmark-region t]
1991 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1992 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1993 ["Mark all" gnus-uu-mark-all t]
1994 ["Mark buffer" gnus-uu-mark-buffer t]
1995 ["Mark sparse" gnus-uu-mark-sparse t]
1996 ["Mark thread" gnus-uu-mark-thread t]
1997 ["Unmark thread" gnus-uu-unmark-thread t]
1998 ("Process Mark Sets"
1999 ["Kill" gnus-summary-kill-process-mark t]
2000 ["Yank" gnus-summary-yank-process-mark
2001 gnus-newsgroup-process-stack]
2002 ["Save" gnus-summary-save-process-mark t]))
2004 ["Page forward" gnus-summary-next-page
2005 ,@(if (featurep 'xemacs) '(t)
2006 '(:help "Show next page of article"))]
2007 ["Page backward" gnus-summary-prev-page
2008 ,@(if (featurep 'xemacs) '(t)
2009 '(:help "Show previous page of article"))]
2010 ["Line forward" gnus-summary-scroll-up t])
2012 ["Next unread article" gnus-summary-next-unread-article t]
2013 ["Previous unread article" gnus-summary-prev-unread-article t]
2014 ["Next article" gnus-summary-next-article t]
2015 ["Previous article" gnus-summary-prev-article t]
2016 ["Next unread subject" gnus-summary-next-unread-subject t]
2017 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2018 ["Next article same subject" gnus-summary-next-same-subject t]
2019 ["Previous article same subject" gnus-summary-prev-same-subject t]
2020 ["First unread article" gnus-summary-first-unread-article t]
2021 ["Best unread article" gnus-summary-best-unread-article t]
2022 ["Go to subject number..." gnus-summary-goto-subject t]
2023 ["Go to article number..." gnus-summary-goto-article t]
2024 ["Go to the last article" gnus-summary-goto-last-article t]
2025 ["Pop article off history" gnus-summary-pop-article t])
2027 ["Sort by number" gnus-summary-sort-by-number t]
2028 ["Sort by author" gnus-summary-sort-by-author t]
2029 ["Sort by subject" gnus-summary-sort-by-subject t]
2030 ["Sort by date" gnus-summary-sort-by-date t]
2031 ["Sort by score" gnus-summary-sort-by-score t]
2032 ["Sort by lines" gnus-summary-sort-by-lines t]
2033 ["Sort by characters" gnus-summary-sort-by-chars t])
2035 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2036 ["Describe group" gnus-summary-describe-group t]
2037 ["Read manual" gnus-info-find-node t])
2039 ["Pick and read" gnus-pick-mode t]
2040 ["Binary" gnus-binary-mode t])
2042 ["Regenerate" gnus-summary-prepare t]
2043 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2044 ["Toggle threading" gnus-summary-toggle-threads t])
2045 ["Filter articles..." gnus-summary-execute-command t]
2046 ["Run command on subjects..." gnus-summary-universal-argument t]
2047 ["Search articles forward..." gnus-summary-search-article-forward t]
2048 ["Search articles backward..." gnus-summary-search-article-backward t]
2049 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2050 ["Expand window" gnus-summary-expand-window t]
2051 ["Expire expirable articles" gnus-summary-expire-articles
2052 (gnus-check-backend-function
2053 'request-expire-articles gnus-newsgroup-name)]
2054 ["Edit local kill file" gnus-summary-edit-local-kill t]
2055 ["Edit main kill file" gnus-summary-edit-global-kill t]
2056 ["Edit group parameters" gnus-summary-edit-parameters t]
2057 ["Customize group parameters" gnus-summary-customize-parameters t]
2058 ["Send a bug report" gnus-bug t]
2060 ["Catchup and exit" gnus-summary-catchup-and-exit
2061 ,@(if (featurep 'xemacs) '(t)
2062 '(:help "Mark unread articles in this group as read, then exit"))]
2063 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2064 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2065 ["Exit group" gnus-summary-exit
2066 ,@(if (featurep 'xemacs) '(t)
2067 '(:help "Exit current group, return to group selection mode"))]
2068 ["Exit group without updating" gnus-summary-exit-no-update t]
2069 ["Exit and goto next group" gnus-summary-next-group t]
2070 ["Exit and goto prev group" gnus-summary-prev-group t]
2071 ["Reselect group" gnus-summary-reselect-current-group t]
2072 ["Rescan group" gnus-summary-rescan-group t]
2073 ["Update dribble" gnus-summary-save-newsrc t])))
2075 (gnus-run-hooks 'gnus-summary-menu-hook)))
2077 (defvar gnus-summary-tool-bar-map nil)
2079 ;; Emacs 21 tool bar. Should be no-op otherwise.
2080 (defun gnus-summary-make-tool-bar ()
2081 (if (and (fboundp 'tool-bar-add-item-from-menu)
2082 (default-value 'tool-bar-mode)
2083 (not gnus-summary-tool-bar-map))
2084 (setq gnus-summary-tool-bar-map
2085 (let ((tool-bar-map (make-sparse-keymap))
2086 (load-path (mm-image-load-path)))
2087 (tool-bar-add-item-from-menu
2088 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2089 (tool-bar-add-item-from-menu
2090 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2091 (tool-bar-add-item-from-menu
2092 'gnus-summary-post-news "post" gnus-summary-mode-map)
2093 (tool-bar-add-item-from-menu
2094 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2095 (tool-bar-add-item-from-menu
2096 'gnus-summary-followup "followup" gnus-summary-mode-map)
2097 (tool-bar-add-item-from-menu
2098 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2099 (tool-bar-add-item-from-menu
2100 'gnus-summary-reply "reply" gnus-summary-mode-map)
2101 (tool-bar-add-item-from-menu
2102 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2103 (tool-bar-add-item-from-menu
2104 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2105 (tool-bar-add-item-from-menu
2106 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2107 (tool-bar-add-item-from-menu
2108 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2109 (tool-bar-add-item-from-menu
2110 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2111 (tool-bar-add-item-from-menu
2112 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2113 (tool-bar-add-item-from-menu
2114 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2115 (tool-bar-add-item-from-menu
2116 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2118 (if gnus-summary-tool-bar-map
2119 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2121 (defun gnus-score-set-default (var value)
2122 "A version of set that updates the GNU Emacs menu-bar."
2124 ;; It is the message that forces the active status to be updated.
2127 (defun gnus-make-score-map (type)
2128 "Make a summary score map of type TYPE."
2131 (let ((headers '(("author" "from" string)
2132 ("subject" "subject" string)
2133 ("article body" "body" string)
2134 ("article head" "head" string)
2135 ("xref" "xref" string)
2136 ("extra header" "extra" string)
2137 ("lines" "lines" number)
2138 ("followups to author" "followup" string)))
2139 (types '((number ("less than" <)
2142 (string ("substring" s)
2146 (perms '(("temporary" (current-time-string))
2154 (if (eq type 'lower)
2159 (setq header (car headers))
2165 (let ((ts (cdr (assoc (nth 2 header) types)))
2181 'gnus-summary-score-entry
2183 (if (or (string= (nth 1 header)
2185 (string= (nth 1 header)
2188 (list 'gnus-summary-header
2190 (list 'quote (nth 1 (car ts)))
2191 (list 'gnus-score-delta-default
2198 (list (nreverse outp))))
2201 (list (nreverse outt))))
2203 (setq headers (cdr headers)))
2204 (list (nreverse outh))))))))
2208 (defun gnus-summary-mode (&optional group)
2209 "Major mode for reading articles.
2211 All normal editing commands are switched off.
2212 \\<gnus-summary-mode-map>
2213 Each line in this buffer represents one article. To read an
2214 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2215 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2218 You can also post articles and send mail from this buffer. To
2219 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2220 of an article, type `\\[gnus-summary-reply]'.
2222 There are approx. one gazillion commands you can execute in this
2223 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2225 The following commands are available:
2227 \\{gnus-summary-mode-map}"
2229 (kill-all-local-variables)
2230 (when (gnus-visual-p 'summary-menu 'menu)
2231 (gnus-summary-make-menu-bar)
2232 (gnus-summary-make-tool-bar))
2233 (gnus-summary-make-local-variables)
2234 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2235 (gnus-summary-make-local-variables))
2236 (gnus-make-thread-indent-array)
2237 (gnus-simplify-mode-line)
2238 (setq major-mode 'gnus-summary-mode)
2239 (setq mode-name "Summary")
2240 (make-local-variable 'minor-mode-alist)
2241 (use-local-map gnus-summary-mode-map)
2242 (buffer-disable-undo)
2243 (setq buffer-read-only t) ;Disable modification
2244 (setq truncate-lines t)
2245 (setq selective-display t)
2246 (setq selective-display-ellipses t) ;Display `...'
2247 (gnus-summary-set-display-table)
2248 (gnus-set-default-directory)
2249 (setq gnus-newsgroup-name group)
2250 (unless (gnus-news-group-p group)
2251 (setq gnus-newsgroup-incorporated
2252 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2253 (make-local-variable 'gnus-summary-line-format)
2254 (make-local-variable 'gnus-summary-line-format-spec)
2255 (make-local-variable 'gnus-summary-dummy-line-format)
2256 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2257 (make-local-variable 'gnus-summary-mark-positions)
2258 (make-local-hook 'pre-command-hook)
2259 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2260 (gnus-run-hooks 'gnus-summary-mode-hook)
2261 (turn-on-gnus-mailing-list-mode)
2262 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2263 (gnus-update-summary-mark-positions))
2265 (defun gnus-summary-make-local-variables ()
2266 "Make all the local summary buffer variables."
2268 (dolist (local gnus-summary-local-variables)
2271 (if (eq (cdr local) 'global)
2272 ;; Copy the global value of the variable.
2273 (setq global (symbol-value (car local)))
2274 ;; Use the value from the list.
2275 (setq global (eval (cdr local))))
2276 (set (make-local-variable (car local)) global))
2277 ;; Simple nil-valued local variable.
2278 (set (make-local-variable local) nil)))))
2280 (defun gnus-summary-clear-local-variables ()
2281 (let ((locals gnus-summary-local-variables))
2283 (if (consp (car locals))
2284 (and (vectorp (caar locals))
2285 (set (caar locals) nil))
2286 (and (vectorp (car locals))
2287 (set (car locals) nil)))
2288 (setq locals (cdr locals)))))
2290 ;; Summary data functions.
2292 (defmacro gnus-data-number (data)
2295 (defmacro gnus-data-set-number (data number)
2296 `(setcar ,data ,number))
2298 (defmacro gnus-data-mark (data)
2301 (defmacro gnus-data-set-mark (data mark)
2302 `(setcar (nthcdr 1 ,data) ,mark))
2304 (defmacro gnus-data-pos (data)
2307 (defmacro gnus-data-set-pos (data pos)
2308 `(setcar (nthcdr 2 ,data) ,pos))
2310 (defmacro gnus-data-header (data)
2313 (defmacro gnus-data-set-header (data header)
2314 `(setcar (nthcdr 3 ,data) ,header))
2316 (defmacro gnus-data-level (data)
2319 (defmacro gnus-data-unread-p (data)
2320 `(= (nth 1 ,data) gnus-unread-mark))
2322 (defmacro gnus-data-read-p (data)
2323 `(/= (nth 1 ,data) gnus-unread-mark))
2325 (defmacro gnus-data-pseudo-p (data)
2326 `(consp (nth 3 ,data)))
2328 (defmacro gnus-data-find (number)
2329 `(assq ,number gnus-newsgroup-data))
2331 (defmacro gnus-data-find-list (number &optional data)
2332 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2333 (memq (assq ,number bdata)
2336 (defmacro gnus-data-make (number mark pos header level)
2337 `(list ,number ,mark ,pos ,header ,level))
2339 (defun gnus-data-enter (after-article number mark pos header level offset)
2340 (let ((data (gnus-data-find-list after-article)))
2342 (error "No such article: %d" after-article))
2343 (setcdr data (cons (gnus-data-make number mark pos header level)
2345 (setq gnus-newsgroup-data-reverse nil)
2346 (gnus-data-update-list (cddr data) offset)))
2348 (defun gnus-data-enter-list (after-article list &optional offset)
2350 (let ((data (and after-article (gnus-data-find-list after-article)))
2354 (let ((odata gnus-newsgroup-data))
2355 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2357 (gnus-data-update-list odata offset)))
2358 ;; Find the last element in the list to be spliced into the main
2361 (setq list (cdr list)))
2364 (setcdr list gnus-newsgroup-data)
2365 (setq gnus-newsgroup-data ilist)
2367 (gnus-data-update-list (cdr list) offset)))
2368 (setcdr list (cdr data))
2371 (gnus-data-update-list (cdr list) offset))))
2372 (setq gnus-newsgroup-data-reverse nil))))
2374 (defun gnus-data-remove (article &optional offset)
2375 (let ((data gnus-newsgroup-data))
2376 (if (= (gnus-data-number (car data)) article)
2378 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2379 gnus-newsgroup-data-reverse nil)
2381 (gnus-data-update-list gnus-newsgroup-data offset)))
2383 (when (= (gnus-data-number (cadr data)) article)
2384 (setcdr data (cddr data))
2386 (gnus-data-update-list (cdr data) offset))
2388 gnus-newsgroup-data-reverse nil))
2389 (setq data (cdr data))))))
2391 (defmacro gnus-data-list (backward)
2393 (or gnus-newsgroup-data-reverse
2394 (setq gnus-newsgroup-data-reverse
2395 (reverse gnus-newsgroup-data)))
2396 gnus-newsgroup-data))
2398 (defun gnus-data-update-list (data offset)
2399 "Add OFFSET to the POS of all data entries in DATA."
2400 (setq gnus-newsgroup-data-reverse nil)
2402 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2403 (setq data (cdr data))))
2405 (defun gnus-summary-article-pseudo-p (article)
2406 "Say whether this article is a pseudo article or not."
2407 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2409 (defmacro gnus-summary-article-sparse-p (article)
2410 "Say whether this article is a sparse article or not."
2411 `(memq ,article gnus-newsgroup-sparse))
2413 (defmacro gnus-summary-article-ancient-p (article)
2414 "Say whether this article is a sparse article or not."
2415 `(memq ,article gnus-newsgroup-ancient))
2417 (defun gnus-article-parent-p (number)
2418 "Say whether this article is a parent or not."
2419 (let ((data (gnus-data-find-list number)))
2420 (and (cdr data) ; There has to be an article after...
2421 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2422 (gnus-data-level (nth 1 data))))))
2424 (defun gnus-article-children (number)
2425 "Return a list of all children to NUMBER."
2426 (let* ((data (gnus-data-find-list number))
2427 (level (gnus-data-level (car data)))
2429 (setq data (cdr data))
2431 (= (gnus-data-level (car data)) (1+ level)))
2432 (push (gnus-data-number (car data)) children)
2433 (setq data (cdr data)))
2436 (defmacro gnus-summary-skip-intangible ()
2437 "If the current article is intangible, then jump to a different article."
2438 '(let ((to (get-text-property (point) 'gnus-intangible)))
2439 (and to (gnus-summary-goto-subject to))))
2441 (defmacro gnus-summary-article-intangible-p ()
2442 "Say whether this article is intangible or not."
2443 '(get-text-property (point) 'gnus-intangible))
2445 (defun gnus-article-read-p (article)
2446 "Say whether ARTICLE is read or not."
2447 (not (or (memq article gnus-newsgroup-marked)
2448 (memq article gnus-newsgroup-unreads)
2449 (memq article gnus-newsgroup-unselected)
2450 (memq article gnus-newsgroup-dormant))))
2452 ;; Some summary mode macros.
2454 (defmacro gnus-summary-article-number ()
2455 "The article number of the article on the current line.
2456 If there isn's an article number here, then we return the current
2459 (gnus-summary-skip-intangible)
2460 (or (get-text-property (point) 'gnus-number)
2461 (gnus-summary-last-subject))))
2463 (defmacro gnus-summary-article-header (&optional number)
2464 "Return the header of article NUMBER."
2465 `(gnus-data-header (gnus-data-find
2466 ,(or number '(gnus-summary-article-number)))))
2468 (defmacro gnus-summary-thread-level (&optional number)
2469 "Return the level of thread that starts with article NUMBER."
2470 `(if (and (eq gnus-summary-make-false-root 'dummy)
2471 (get-text-property (point) 'gnus-intangible))
2473 (gnus-data-level (gnus-data-find
2474 ,(or number '(gnus-summary-article-number))))))
2476 (defmacro gnus-summary-article-mark (&optional number)
2477 "Return the mark of article NUMBER."
2478 `(gnus-data-mark (gnus-data-find
2479 ,(or number '(gnus-summary-article-number)))))
2481 (defmacro gnus-summary-article-pos (&optional number)
2482 "Return the position of the line of article NUMBER."
2483 `(gnus-data-pos (gnus-data-find
2484 ,(or number '(gnus-summary-article-number)))))
2486 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2487 (defmacro gnus-summary-article-subject (&optional number)
2488 "Return current subject string or nil if nothing."
2491 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2492 '(gnus-data-header (assq (gnus-summary-article-number)
2493 gnus-newsgroup-data)))))
2496 (mail-header-subject headers))))
2498 (defmacro gnus-summary-article-score (&optional number)
2499 "Return current article score."
2500 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2501 gnus-newsgroup-scored))
2502 gnus-summary-default-score 0))
2504 (defun gnus-summary-article-children (&optional number)
2505 "Return a list of article numbers that are children of article NUMBER."
2506 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2507 (level (gnus-data-level (car data)))
2509 (while (and (setq data (cdr data))
2510 (> (setq l (gnus-data-level (car data))) level))
2511 (and (= (1+ level) l)
2512 (push (gnus-data-number (car data))
2514 (nreverse children)))
2516 (defun gnus-summary-article-parent (&optional number)
2517 "Return the article number of the parent of article NUMBER."
2518 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2519 (gnus-data-list t)))
2520 (level (gnus-data-level (car data))))
2522 () ; This is a root.
2523 ;; We search until we find an article with a level less than
2524 ;; this one. That function has to be the parent.
2525 (while (and (setq data (cdr data))
2526 (not (< (gnus-data-level (car data)) level))))
2527 (and data (gnus-data-number (car data))))))
2529 (defun gnus-unread-mark-p (mark)
2530 "Say whether MARK is the unread mark."
2531 (= mark gnus-unread-mark))
2533 (defun gnus-read-mark-p (mark)
2534 "Say whether MARK is one of the marks that mark as read.
2535 This is all marks except unread, ticked, dormant, and expirable."
2536 (not (or (= mark gnus-unread-mark)
2537 (= mark gnus-ticked-mark)
2538 (= mark gnus-dormant-mark)
2539 (= mark gnus-expirable-mark))))
2541 (defmacro gnus-article-mark (number)
2542 "Return the MARK of article NUMBER.
2543 This macro should only be used when computing the mark the \"first\"
2544 time; i.e., when generating the summary lines. After that,
2545 `gnus-summary-article-mark' should be used to examine the
2548 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2549 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2550 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2551 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2552 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2553 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2554 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2555 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2556 gnus-ancient-mark))))
2558 ;; Saving hidden threads.
2560 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2561 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2563 (defmacro gnus-save-hidden-threads (&rest forms)
2564 "Save hidden threads, eval FORMS, and restore the hidden threads."
2565 (let ((config (make-symbol "config")))
2566 `(let ((,config (gnus-hidden-threads-configuration)))
2570 (gnus-restore-hidden-threads-configuration ,config)))))
2572 (defun gnus-data-compute-positions ()
2573 "Compute the positions of all articles."
2574 (setq gnus-newsgroup-data-reverse nil)
2575 (let ((data gnus-newsgroup-data))
2577 (gnus-save-hidden-threads
2578 (gnus-summary-show-all-threads)
2579 (goto-char (point-min))
2581 (while (get-text-property (point) 'gnus-intangible)
2583 (gnus-data-set-pos (car data) (+ (point) 3))
2584 (setq data (cdr data))
2585 (forward-line 1))))))
2587 (defun gnus-hidden-threads-configuration ()
2588 "Return the current hidden threads configuration."
2591 (goto-char (point-min))
2592 (while (search-forward "\r" nil t)
2593 (push (1- (point)) config))
2596 (defun gnus-restore-hidden-threads-configuration (config)
2597 "Restore hidden threads configuration from CONFIG."
2599 (let (point buffer-read-only)
2600 (while (setq point (pop config))
2601 (when (and (< point (point-max))
2603 (eq (char-after) ?\n))
2604 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2606 ;; Various summary mode internalish functions.
2608 (defun gnus-mouse-pick-article (e)
2611 (gnus-summary-next-page nil t))
2613 (defun gnus-summary-set-display-table ()
2614 "Change the display table.
2615 Odd characters have a tendency to mess
2616 up nicely formatted displays - we make all possible glyphs
2617 display only a single character."
2619 ;; We start from the standard display table, if any.
2620 (let ((table (or (copy-sequence standard-display-table)
2621 (make-display-table)))
2623 ;; Nix out all the control chars...
2624 (while (>= (setq i (1- i)) 0)
2625 (aset table i [??]))
2626 ;; ... but not newline and cr, of course. (cr is necessary for the
2627 ;; selective display).
2628 (aset table ?\n nil)
2629 (aset table ?\r nil)
2630 ;; We keep TAB as well.
2631 (aset table ?\t nil)
2632 ;; We nix out any glyphs over 126 that are not set already.
2634 (while (>= (setq i (1- i)) 127)
2635 ;; Only modify if the entry is nil.
2636 (unless (aref table i)
2637 (aset table i [??]))))
2638 (setq buffer-display-table table)))
2640 (defun gnus-summary-buffer-name (group)
2641 "Return the summary buffer name of GROUP."
2642 (concat "*Summary " group "*"))
2644 (defun gnus-summary-setup-buffer (group)
2645 "Initialize summary buffer."
2646 (let ((buffer (gnus-summary-buffer-name group)))
2647 (if (get-buffer buffer)
2650 (setq gnus-summary-buffer (current-buffer))
2651 (not gnus-newsgroup-prepared))
2652 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2653 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2654 (gnus-summary-mode group)
2656 (gnus-carpal-setup-buffer 'summary))
2657 (unless gnus-single-article-buffer
2658 (make-local-variable 'gnus-article-buffer)
2659 (make-local-variable 'gnus-article-current)
2660 (make-local-variable 'gnus-original-article-buffer))
2661 (setq gnus-newsgroup-name group)
2662 ;; Set any local variables in the group parameters.
2663 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2666 (defun gnus-set-global-variables ()
2667 "Set the global equivalents of the buffer-local variables.
2668 They are set to the latest values they had. These reflect the summary
2669 buffer that was in action when the last article was fetched."
2670 (when (eq major-mode 'gnus-summary-mode)
2671 (setq gnus-summary-buffer (current-buffer))
2672 (let ((name gnus-newsgroup-name)
2673 (marked gnus-newsgroup-marked)
2674 (unread gnus-newsgroup-unreads)
2675 (headers gnus-current-headers)
2676 (data gnus-newsgroup-data)
2677 (summary gnus-summary-buffer)
2678 (article-buffer gnus-article-buffer)
2679 (original gnus-original-article-buffer)
2680 (gac gnus-article-current)
2681 (reffed gnus-reffed-article-number)
2682 (score-file gnus-current-score-file)
2683 (default-charset gnus-newsgroup-charset)
2685 (let ((locals gnus-newsgroup-variables))
2687 (if (consp (car locals))
2688 (push (eval (caar locals)) vlist)
2689 (push (eval (car locals)) vlist))
2690 (setq locals (cdr locals)))
2691 (setq vlist (nreverse vlist)))
2693 (set-buffer gnus-group-buffer)
2694 (setq gnus-newsgroup-name name
2695 gnus-newsgroup-marked marked
2696 gnus-newsgroup-unreads unread
2697 gnus-current-headers headers
2698 gnus-newsgroup-data data
2699 gnus-article-current gac
2700 gnus-summary-buffer summary
2701 gnus-article-buffer article-buffer
2702 gnus-original-article-buffer original
2703 gnus-reffed-article-number reffed
2704 gnus-current-score-file score-file
2705 gnus-newsgroup-charset default-charset)
2706 (let ((locals gnus-newsgroup-variables))
2708 (if (consp (car locals))
2709 (set (caar locals) (pop vlist))
2710 (set (car locals) (pop vlist)))
2711 (setq locals (cdr locals))))
2712 ;; The article buffer also has local variables.
2713 (when (gnus-buffer-live-p gnus-article-buffer)
2714 (set-buffer gnus-article-buffer)
2715 (setq gnus-summary-buffer summary))))))
2717 (defun gnus-summary-article-unread-p (article)
2718 "Say whether ARTICLE is unread or not."
2719 (memq article gnus-newsgroup-unreads))
2721 (defun gnus-summary-first-article-p (&optional article)
2722 "Return whether ARTICLE is the first article in the buffer."
2723 (if (not (setq article (or article (gnus-summary-article-number))))
2725 (eq article (caar gnus-newsgroup-data))))
2727 (defun gnus-summary-last-article-p (&optional article)
2728 "Return whether ARTICLE is the last article in the buffer."
2729 (if (not (setq article (or article (gnus-summary-article-number))))
2730 ;; All non-existent numbers are the last article. :-)
2732 (not (cdr (gnus-data-find-list article)))))
2734 (defun gnus-make-thread-indent-array ()
2736 (unless (and gnus-thread-indent-array
2737 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2738 (setq gnus-thread-indent-array (make-vector 201 "")
2739 gnus-thread-indent-array-level gnus-thread-indent-level)
2741 (aset gnus-thread-indent-array n
2742 (make-string (* n gnus-thread-indent-level) ? ))
2745 (defun gnus-update-summary-mark-positions ()
2746 "Compute where the summary marks are to go."
2748 (when (gnus-buffer-exists-p gnus-summary-buffer)
2749 (set-buffer gnus-summary-buffer))
2750 (let ((gnus-replied-mark 129)
2751 (gnus-score-below-mark 130)
2752 (gnus-score-over-mark 130)
2753 (gnus-download-mark 131)
2754 (spec gnus-summary-line-format-spec)
2757 (gnus-set-work-buffer)
2758 (let ((gnus-summary-line-format-spec spec)
2759 (gnus-newsgroup-downloadable '((0 . t))))
2760 (gnus-summary-insert-line
2761 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2762 0 nil 128 t nil "" nil 1)
2763 (goto-char (point-min))
2764 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2766 (goto-char (point-min))
2767 (push (cons 'replied (and (search-forward "\201" nil t)
2770 (goto-char (point-min))
2771 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2773 (goto-char (point-min))
2774 (push (cons 'download
2775 (and (search-forward "\203" nil t) (- (point) 2)))
2777 (setq gnus-summary-mark-positions pos))))
2779 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2780 "Insert a dummy root in the summary buffer."
2782 (gnus-add-text-properties
2783 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2784 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2786 (defun gnus-summary-from-or-to-or-newsgroups (header)
2787 (let ((to (cdr (assq 'To (mail-header-extra header))))
2788 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2789 (default-mime-charset (with-current-buffer gnus-summary-buffer
2790 default-mime-charset)))
2793 gnus-ignored-from-addresses
2794 (string-match gnus-ignored-from-addresses
2795 (mail-header-from header)))
2797 (or (car (funcall gnus-extract-address-components
2799 gnus-decode-encoded-word-function to)))
2800 (funcall gnus-decode-encoded-word-function to))))
2802 gnus-ignored-from-addresses
2803 (string-match gnus-ignored-from-addresses
2804 (mail-header-from header)))
2805 (concat "=> " newsgroups))
2807 (or (car (funcall gnus-extract-address-components
2808 (mail-header-from header)))
2809 (mail-header-from header))))))
2811 (defun gnus-summary-insert-line (gnus-tmp-header
2812 gnus-tmp-level gnus-tmp-current
2813 gnus-tmp-unread gnus-tmp-replied
2814 gnus-tmp-expirable gnus-tmp-subject-or-nil
2815 &optional gnus-tmp-dummy gnus-tmp-score
2817 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2818 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2819 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2820 (gnus-tmp-score-char
2821 (if (or (null gnus-summary-default-score)
2822 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2823 gnus-summary-zcore-fuzz))
2825 (if (< gnus-tmp-score gnus-summary-default-score)
2826 gnus-score-below-mark gnus-score-over-mark)))
2828 (cond (gnus-tmp-process gnus-process-mark)
2829 ((memq gnus-tmp-current gnus-newsgroup-cached)
2831 (gnus-tmp-replied gnus-replied-mark)
2832 ((memq gnus-tmp-current gnus-newsgroup-saved)
2835 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2838 ((string-match "<[^>]+> *$" gnus-tmp-from)
2839 (let ((beg (match-beginning 0)))
2840 (or (and (string-match "^\".+\"" gnus-tmp-from)
2841 (substring gnus-tmp-from 1 (1- (match-end 0))))
2842 (substring gnus-tmp-from 0 beg))))
2843 ((string-match "(.+)" gnus-tmp-from)
2844 (substring gnus-tmp-from
2845 (1+ (match-beginning 0)) (1- (match-end 0))))
2847 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2848 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2849 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2850 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2851 (buffer-read-only nil))
2852 (when (string= gnus-tmp-name "")
2853 (setq gnus-tmp-name gnus-tmp-from))
2854 (unless (numberp gnus-tmp-lines)
2855 (setq gnus-tmp-lines 0))
2856 (gnus-put-text-property-excluding-characters-with-faces
2858 (progn (eval gnus-summary-line-format-spec) (point))
2859 'gnus-number gnus-tmp-number)
2860 (when (gnus-visual-p 'summary-highlight 'highlight)
2862 (gnus-run-hooks 'gnus-summary-update-hook)
2865 (defun gnus-summary-update-line (&optional dont-update)
2866 "Update summary line after change."
2867 (when (and gnus-summary-default-score
2868 (not gnus-summary-inhibit-highlight))
2869 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2870 (article (gnus-summary-article-number))
2871 (score (gnus-summary-article-score article)))
2873 (if (and gnus-summary-mark-below
2874 (< (gnus-summary-article-score)
2875 gnus-summary-mark-below))
2876 ;; This article has a low score, so we mark it as read.
2877 (when (memq article gnus-newsgroup-unreads)
2878 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2879 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2880 ;; This article was previously marked as read on account
2881 ;; of a low score, but now it has risen, so we mark it as
2883 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2884 (gnus-summary-update-mark
2885 (if (or (null gnus-summary-default-score)
2886 (<= (abs (- score gnus-summary-default-score))
2887 gnus-summary-zcore-fuzz))
2889 (if (< score gnus-summary-default-score)
2890 gnus-score-below-mark gnus-score-over-mark))
2892 ;; Do visual highlighting.
2893 (when (gnus-visual-p 'summary-highlight 'highlight)
2894 (gnus-run-hooks 'gnus-summary-update-hook)))))
2896 (defvar gnus-tmp-new-adopts nil)
2898 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2899 "Return the number of articles in THREAD.
2900 This may be 0 in some cases -- if none of the articles in
2901 the thread are to be displayed."
2903 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2905 ((not (listp thread))
2907 ((and (consp thread) (cdr thread))
2910 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2913 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2916 (when (and level (zerop level) gnus-tmp-new-adopts)
2919 'gnus-summary-number-of-articles-in-thread
2920 gnus-tmp-new-adopts))))
2922 (if (> number 1) gnus-not-empty-thread-mark
2923 gnus-empty-thread-mark)
2926 (defun gnus-summary-set-local-parameters (group)
2927 "Go through the local params of GROUP and set all variable specs in that list."
2928 (let ((params (gnus-group-find-parameter group))
2931 (setq elem (car params)
2932 params (cdr params))
2933 (and (consp elem) ; Has to be a cons.
2934 (consp (cdr elem)) ; The cdr has to be a list.
2935 (symbolp (car elem)) ; Has to be a symbol in there.
2936 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2937 (ignore-errors ; So we set it.
2938 (make-local-variable (car elem))
2939 (set (car elem) (eval (nth 1 elem))))))))
2941 (defun gnus-summary-read-group (group &optional show-all no-article
2942 kill-buffer no-display backward
2944 "Start reading news in newsgroup GROUP.
2945 If SHOW-ALL is non-nil, already read articles are also listed.
2946 If NO-ARTICLE is non-nil, no article is selected initially.
2947 If NO-DISPLAY, don't generate a summary buffer."
2951 (let ((gnus-auto-select-next nil))
2952 (or (gnus-summary-read-group-1
2953 group show-all no-article
2954 kill-buffer no-display
2957 select-articles nil)))))
2958 (eq gnus-auto-select-next 'quietly))
2959 (set-buffer gnus-group-buffer)
2960 ;; The entry function called above goes to the next
2961 ;; group automatically, so we go two groups back
2962 ;; if we are searching for the previous group.
2964 (gnus-group-prev-unread-group 2))
2965 (if (not (equal group (gnus-group-group-name)))
2966 (setq group (gnus-group-group-name))
2970 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2971 "Directly jump to the other GROUP from summary buffer.
2972 If SHOW-ALL is non-nil, already read articles are also listed."
2974 (if (eq gnus-summary-buffer (current-buffer))
2975 (list (completing-read
2976 "Group: " gnus-active-hashtb nil t
2977 (when (and gnus-newsgroup-name
2978 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2979 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2980 'gnus-group-history)
2982 (error "%s must be invoked from a gnus summary buffer." this-command)))
2983 (unless (or (zerop (length group))
2984 (and gnus-newsgroup-name
2985 (string-equal gnus-newsgroup-name group)))
2987 (gnus-summary-read-group group show-all
2988 gnus-dont-select-after-jump-to-other-group)))
2990 (defun gnus-summary-read-group-1 (group show-all no-article
2991 kill-buffer no-display
2992 &optional select-articles)
2993 ;; Killed foreign groups can't be entered.
2994 ;; (when (and (not (gnus-group-native-p group))
2995 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
2996 ;; (error "Dead non-native groups can't be entered"))
2997 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2998 (let* ((new-group (gnus-summary-setup-buffer group))
2999 (quit-config (gnus-group-quit-config group))
3000 (did-select (and new-group (gnus-select-newsgroup
3001 group show-all select-articles))))
3003 ;; This summary buffer exists already, so we just select it.
3005 (gnus-set-global-variables)
3007 (gnus-kill-or-deaden-summary kill-buffer))
3008 (gnus-configure-windows 'summary 'force)
3009 (gnus-set-mode-line 'summary)
3010 (gnus-summary-position-point)
3013 ;; We couldn't select this group.
3015 (when (and (eq major-mode 'gnus-summary-mode)
3016 (not (equal (current-buffer) kill-buffer)))
3017 (kill-buffer (current-buffer))
3018 (if (not quit-config)
3020 ;; Update the info -- marks might need to be removed,
3022 (gnus-summary-update-info)
3023 (set-buffer gnus-group-buffer)
3024 (gnus-group-jump-to-group group)
3025 (gnus-group-next-unread-group 1))
3026 (gnus-handle-ephemeral-exit quit-config)))
3027 (let ((grpinfo (gnus-get-info group)))
3028 (if (null (gnus-info-read grpinfo))
3029 (gnus-message 3 "Group %s contains no messages" group)
3030 (gnus-message 3 "Can't select group")))
3032 ;; The user did a `C-g' while prompting for number of articles,
3033 ;; so we exit this group.
3034 ((eq did-select 'quit)
3035 (and (eq major-mode 'gnus-summary-mode)
3036 (not (equal (current-buffer) kill-buffer))
3037 (kill-buffer (current-buffer)))
3039 (gnus-kill-or-deaden-summary kill-buffer))
3040 (if (not quit-config)
3042 (set-buffer gnus-group-buffer)
3043 (gnus-group-jump-to-group group)
3044 (gnus-group-next-unread-group 1)
3045 (gnus-configure-windows 'group 'force))
3046 (gnus-handle-ephemeral-exit quit-config))
3047 ;; Finally signal the quit.
3049 ;; The group was successfully selected.
3051 (gnus-set-global-variables)
3052 ;; Save the active value in effect when the group was entered.
3053 (setq gnus-newsgroup-active
3055 (gnus-active gnus-newsgroup-name)))
3056 ;; You can change the summary buffer in some way with this hook.
3057 (gnus-run-hooks 'gnus-select-group-hook)
3058 (gnus-update-format-specifications
3059 nil 'summary 'summary-mode 'summary-dummy)
3060 (gnus-update-summary-mark-positions)
3061 ;; Do score processing.
3062 (when gnus-use-scoring
3063 (gnus-possibly-score-headers))
3064 ;; Check whether to fill in the gaps in the threads.
3065 (when gnus-build-sparse-threads
3066 (gnus-build-sparse-threads))
3067 ;; Find the initial limit.
3068 (if gnus-show-threads
3070 (let ((gnus-newsgroup-dormant nil))
3071 (gnus-summary-initial-limit show-all))
3072 (gnus-summary-initial-limit show-all))
3073 ;; When untreaded, all articles are always shown.
3074 (setq gnus-newsgroup-limit
3076 (lambda (header) (mail-header-number header))
3077 gnus-newsgroup-headers)))
3078 ;; Generate the summary buffer.
3080 (gnus-summary-prepare))
3081 (when gnus-use-trees
3082 (gnus-tree-open group)
3083 (setq gnus-summary-highlight-line-function
3084 'gnus-tree-highlight-article))
3085 ;; If the summary buffer is empty, but there are some low-scored
3086 ;; articles or some excluded dormants, we include these in the
3088 (when (and (zerop (buffer-size))
3090 (cond (gnus-newsgroup-dormant
3091 (gnus-summary-limit-include-dormant))
3092 ((and gnus-newsgroup-scored show-all)
3093 (gnus-summary-limit-include-expunged t))))
3094 ;; Function `gnus-apply-kill-file' must be called in this hook.
3095 (gnus-run-hooks 'gnus-apply-kill-hook)
3096 (if (and (zerop (buffer-size))
3099 ;; This newsgroup is empty.
3100 (gnus-summary-catchup-and-exit nil t)
3101 (gnus-message 6 "No unread news")
3103 (gnus-kill-or-deaden-summary kill-buffer))
3104 ;; Return nil from this function.
3106 ;; Hide conversation thread subtrees. We cannot do this in
3107 ;; gnus-summary-prepare-hook since kill processing may not
3108 ;; work with hidden articles.
3109 (and gnus-show-threads
3110 gnus-thread-hide-subtree
3111 (gnus-summary-hide-all-threads))
3113 (gnus-kill-or-deaden-summary kill-buffer))
3114 ;; Show first unread article if requested.
3115 (if (and (not no-article)
3117 gnus-newsgroup-unreads
3118 gnus-auto-select-first)
3120 (gnus-configure-windows 'summary)
3122 ((eq gnus-auto-select-first 'best)
3123 (gnus-summary-best-unread-article))
3124 ((eq gnus-auto-select-first t)
3125 (gnus-summary-first-unread-article))
3126 ((gnus-functionp gnus-auto-select-first)
3127 (funcall gnus-auto-select-first))))
3128 ;; Don't select any articles, just move point to the first
3129 ;; article in the group.
3130 (goto-char (point-min))
3131 (gnus-summary-position-point)
3132 (gnus-configure-windows 'summary 'force)
3133 (gnus-set-mode-line 'summary))
3134 (when (get-buffer-window gnus-group-buffer t)
3135 ;; Gotta use windows, because recenter does weird stuff if
3136 ;; the current buffer ain't the displayed window.
3137 (let ((owin (selected-window)))
3138 (select-window (get-buffer-window gnus-group-buffer t))
3139 (when (gnus-group-goto-group group)
3141 (select-window owin)))
3142 ;; Mark this buffer as "prepared".
3143 (setq gnus-newsgroup-prepared t)
3144 (gnus-run-hooks 'gnus-summary-prepared-hook)
3147 (defun gnus-summary-prepare ()
3148 "Generate the summary buffer."
3150 (let ((buffer-read-only nil))
3152 (setq gnus-newsgroup-data nil
3153 gnus-newsgroup-data-reverse nil)
3154 (gnus-run-hooks 'gnus-summary-generate-hook)
3155 ;; Generate the buffer, either with threads or without.
3156 (when gnus-newsgroup-headers
3157 (gnus-summary-prepare-threads
3158 (if gnus-show-threads
3159 (gnus-sort-gathered-threads
3160 (funcall gnus-summary-thread-gathering-function
3162 (gnus-cut-threads (gnus-make-threads)))))
3163 ;; Unthreaded display.
3164 (gnus-sort-articles gnus-newsgroup-headers))))
3165 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3166 ;; Call hooks for modifying summary buffer.
3167 (goto-char (point-min))
3168 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3170 (defsubst gnus-general-simplify-subject (subject)
3171 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3174 ;; Truncate the subject.
3175 (gnus-simplify-subject-functions
3176 (gnus-map-function gnus-simplify-subject-functions subject))
3177 ((numberp gnus-summary-gather-subject-limit)
3178 (setq subject (gnus-simplify-subject-re subject))
3179 (if (> (length subject) gnus-summary-gather-subject-limit)
3180 (substring subject 0 gnus-summary-gather-subject-limit)
3182 ;; Fuzzily simplify it.
3183 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3184 (gnus-simplify-subject-fuzzy subject))
3185 ;; Just remove the leading "Re:".
3187 (gnus-simplify-subject-re subject))))
3189 (if (and gnus-summary-gather-exclude-subject
3190 (string-match gnus-summary-gather-exclude-subject subject))
3191 nil ; This article shouldn't be gathered
3194 (defun gnus-summary-simplify-subject-query ()
3195 "Query where the respool algorithm would put this article."
3197 (gnus-summary-select-article)
3199 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3201 (defun gnus-gather-threads-by-subject (threads)
3202 "Gather threads by looking at Subject headers."
3203 (if (not gnus-summary-make-false-root)
3205 (let ((hashtb (gnus-make-hashtable 1024))
3208 subject hthread whole-subject)
3210 (setq subject (gnus-general-simplify-subject
3211 (setq whole-subject (mail-header-subject
3214 (if (setq hthread (gnus-gethash subject hashtb))
3216 ;; We enter a dummy root into the thread, if we
3217 ;; haven't done that already.
3218 (unless (stringp (caar hthread))
3219 (setcar hthread (list whole-subject (car hthread))))
3220 ;; We add this new gathered thread to this gathered
3222 (setcdr (car hthread)
3223 (nconc (cdar hthread) (list (car threads))))
3224 ;; Remove it from the list of threads.
3225 (setcdr prev (cdr threads))
3226 (setq threads prev))
3227 ;; Enter this thread into the hash table.
3228 (gnus-sethash subject threads hashtb)))
3230 (setq threads (cdr threads)))
3233 (defun gnus-gather-threads-by-references (threads)
3234 "Gather threads by looking at References headers."
3235 (let ((idhashtb (gnus-make-hashtable 1024))
3236 (thhashtb (gnus-make-hashtable 1024))
3239 ids references id gthread gid entered ref)
3241 (when (setq references (mail-header-references (caar threads)))
3242 (setq id (mail-header-id (caar threads))
3243 ids (gnus-split-references references)
3245 (while (setq ref (pop ids))
3246 (setq ids (delete ref ids))
3247 (if (not (setq gid (gnus-gethash ref idhashtb)))
3249 (gnus-sethash ref id idhashtb)
3250 (gnus-sethash id threads thhashtb))
3251 (setq gthread (gnus-gethash gid thhashtb))
3253 ;; We enter a dummy root into the thread, if we
3254 ;; haven't done that already.
3255 (unless (stringp (caar gthread))
3256 (setcar gthread (list (mail-header-subject (caar gthread))
3258 ;; We add this new gathered thread to this gathered
3260 (setcdr (car gthread)
3261 (nconc (cdar gthread) (list (car threads)))))
3262 ;; Add it into the thread hash table.
3263 (gnus-sethash id gthread thhashtb)
3265 ;; Remove it from the list of threads.
3266 (setcdr prev (cdr threads))
3267 (setq threads prev))))
3269 (setq threads (cdr threads)))
3272 (defun gnus-sort-gathered-threads (threads)
3273 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3274 (let ((result threads))
3276 (when (stringp (caar threads))
3277 (setcdr (car threads)
3278 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3279 (setq threads (cdr threads)))
3282 (defun gnus-thread-loop-p (root thread)
3283 "Say whether ROOT is in THREAD."
3284 (let ((stack (list thread))
3287 (while (setq thread (pop stack))
3288 (setq th (cdr thread))
3290 (not (eq (caar th) root)))
3293 ;; We have found a loop.
3295 (setcdr thread (delq (car th) (cdr thread)))
3296 (if (boundp (setq ref-dep (intern "none"
3297 gnus-newsgroup-dependencies)))
3298 (setcdr (symbol-value ref-dep)
3299 (nconc (cdr (symbol-value ref-dep))
3301 (set ref-dep (list nil (car th))))
3304 ;; Push all the subthreads onto the stack.
3305 (push (cdr thread) stack)))
3308 (defun gnus-make-threads ()
3309 "Go through the dependency hashtb and find the roots. Return all threads."
3311 (while (catch 'infloop
3314 ;; Deal with self-referencing References loops.
3315 (when (and (car (symbol-value refs))
3322 (car (symbol-value refs)) thread))
3323 (cdr (symbol-value refs)))))))
3326 (unless (car (symbol-value refs))
3327 ;; These threads do not refer back to any other articles,
3328 ;; so they're roots.
3329 (setq threads (append (cdr (symbol-value refs)) threads))))
3330 gnus-newsgroup-dependencies)))
3333 ;; Build the thread tree.
3334 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3335 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3337 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3338 if it was already present.
3340 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3341 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3342 Message-IDs will be renamed be renamed to a unique Message-ID before
3345 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3346 (let* ((id (mail-header-id header))
3347 (id-dep (and id (intern id dependencies)))
3348 ref ref-dep ref-header)
3349 ;; Enter this `header' in the `dependencies' table.
3353 ;; The first two cases do the normal part: enter a new `header'
3354 ;; in the `dependencies' table.
3355 ((not (boundp id-dep))
3356 (set id-dep (list header)))
3357 ((null (car (symbol-value id-dep)))
3358 (setcar (symbol-value id-dep) header))
3360 ;; From here the `header' was already present in the
3361 ;; `dependencies' table.
3363 ;; Overrides an existing entry;
3364 ;; just set the header part of the entry.
3365 (setcar (symbol-value id-dep) header))
3367 ;; Renames the existing `header' to a unique Message-ID.
3368 ((not gnus-summary-ignore-duplicates)
3369 ;; An article with this Message-ID has already been seen.
3370 ;; We rename the Message-ID.
3371 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3373 (mail-header-set-id header id))
3375 ;; The last case ignores an existing entry, except it adds any
3376 ;; additional Xrefs (in case the two articles came from different
3378 ;; Also sets `header' to `nil' meaning that the `dependencies'
3379 ;; table was *not* modified.
3381 (mail-header-set-xref
3382 (car (symbol-value id-dep))
3383 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3385 (or (mail-header-xref header) "")))
3389 ;; First check if that we are not creating a References loop.
3390 (setq ref (gnus-parent-id (mail-header-references header)))
3392 (setq ref-dep (intern-soft ref dependencies))
3394 (setq ref-header (car (symbol-value ref-dep))))
3395 (if (string= id ref)
3396 ;; Yuk! This is a reference loop. Make the article be a
3399 (mail-header-set-references (car (symbol-value id-dep)) "none")
3401 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3402 (setq ref (gnus-parent-id (mail-header-references header)))
3403 (setq ref-dep (intern (or ref "none") dependencies))
3404 (if (boundp ref-dep)
3405 (setcdr (symbol-value ref-dep)
3406 (nconc (cdr (symbol-value ref-dep))
3407 (list (symbol-value id-dep))))
3408 (set ref-dep (list nil (symbol-value id-dep)))))
3411 (defun gnus-build-sparse-threads ()
3412 (let ((headers gnus-newsgroup-headers)
3413 (mail-parse-charset gnus-newsgroup-charset)
3414 (gnus-summary-ignore-duplicates t)
3415 header references generation relations
3416 subject child end new-child date)
3417 ;; First we create an alist of generations/relations, where
3418 ;; generations is how much we trust the relation, and the relation
3420 (gnus-message 7 "Making sparse threads...")
3422 (nnheader-set-temp-buffer " *gnus sparse threads*")
3423 (while (setq header (pop headers))
3424 (when (and (setq references (mail-header-references header))
3425 (not (string= references "")))
3427 (setq child (mail-header-id header)
3428 subject (mail-header-subject header)
3429 date (mail-header-date header)
3431 (while (search-backward ">" nil t)
3432 (setq end (1+ (point)))
3433 (when (search-backward "<" nil t)
3434 (setq new-child (buffer-substring (point) end))
3435 (push (list (incf generation)
3436 child (setq child new-child)
3440 (push (list (1+ generation) child nil subject) relations))
3442 (kill-buffer (current-buffer)))
3443 ;; Sort over trustworthiness.
3446 (when (gnus-dependencies-add-header
3447 (make-full-mail-header-from-decoded-header
3448 gnus-reffed-article-number
3449 (nth 3 relation) "" (or (nth 4 relation) "")
3451 (or (nth 2 relation) "") 0 0 "")
3452 gnus-newsgroup-dependencies nil)
3453 (push gnus-reffed-article-number gnus-newsgroup-limit)
3454 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3455 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3456 gnus-newsgroup-reads)
3457 (decf gnus-reffed-article-number)))
3458 (sort relations 'car-less-than-car))
3459 (gnus-message 7 "Making sparse threads...done")))
3461 (defun gnus-build-old-threads ()
3462 ;; Look at all the articles that refer back to old articles, and
3463 ;; fetch the headers for the articles that aren't there. This will
3464 ;; build complete threads - if the roots haven't been expired by the
3466 (let ((mail-parse-charset gnus-newsgroup-charset)
3470 (when (not (car (symbol-value refs)))
3471 (setq heads (cdr (symbol-value refs)))
3473 (if (memq (mail-header-number (caar heads))
3474 gnus-newsgroup-dormant)
3475 (setq heads (cdr heads))
3476 (setq id (symbol-name refs))
3477 (while (and (setq id (gnus-build-get-header id))
3478 (not (car (gnus-id-to-thread id)))))
3479 (setq heads nil)))))
3480 gnus-newsgroup-dependencies)))
3482 ;; This function has to be called with point after the article number
3483 ;; on the beginning of the line.
3484 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3485 (let ((eol (gnus-point-at-eol))
3486 (buffer (current-buffer))
3489 ;; overview: [num subject from date id refs chars lines misc]
3492 (narrow-to-region (point) eol)
3497 (make-full-mail-header
3499 (nnheader-nov-field) ; subject
3500 (nnheader-nov-field) ; from
3501 (nnheader-nov-field) ; date
3502 (nnheader-nov-read-message-id) ; id
3503 (nnheader-nov-field) ; refs
3504 (nnheader-nov-read-integer) ; chars
3505 (nnheader-nov-read-integer) ; lines
3507 (if (looking-at "Xref: ")
3508 (goto-char (match-end 0)))
3509 (nnheader-nov-field)) ; Xref
3510 (nnheader-nov-parse-extra)))) ; extra
3514 (when gnus-alter-header-function
3515 (funcall gnus-alter-header-function header))
3516 (gnus-dependencies-add-header header dependencies force-new)))
3518 (defun gnus-build-get-header (id)
3519 "Look through the buffer of NOV lines and find the header to ID.
3520 Enter this line into the dependencies hash table, and return
3521 the id of the parent article (if any)."
3522 (let ((deps gnus-newsgroup-dependencies)
3526 (set-buffer nntp-server-buffer)
3527 (let ((case-fold-search nil))
3528 (goto-char (point-min))
3529 (while (and (not found)
3530 (search-forward id nil t))
3532 (setq found (looking-at
3533 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3534 (regexp-quote id))))
3535 (or found (beginning-of-line 2)))
3539 (setq header (gnus-nov-parse-line
3540 (read (current-buffer)) deps))
3541 (gnus-parent-id (mail-header-references header))))))
3543 (let ((number (mail-header-number header)))
3544 (push number gnus-newsgroup-limit)
3545 (push header gnus-newsgroup-headers)
3546 (if (memq number gnus-newsgroup-unselected)
3548 (push number gnus-newsgroup-unreads)
3549 (setq gnus-newsgroup-unselected
3550 (delq number gnus-newsgroup-unselected)))
3551 (push number gnus-newsgroup-ancient)))))))
3553 (defun gnus-build-all-threads ()
3554 "Read all the headers."
3555 (let ((gnus-summary-ignore-duplicates t)
3556 (mail-parse-charset gnus-newsgroup-charset)
3557 (dependencies gnus-newsgroup-dependencies)
3560 (set-buffer nntp-server-buffer)
3561 (let ((case-fold-search nil))
3562 (goto-char (point-min))
3565 (setq article (read (current-buffer))
3566 header (gnus-nov-parse-line article dependencies)))
3569 (set-buffer gnus-summary-buffer)
3570 (push header gnus-newsgroup-headers)
3571 (if (memq (setq article (mail-header-number header))
3572 gnus-newsgroup-unselected)
3574 (push article gnus-newsgroup-unreads)
3575 (setq gnus-newsgroup-unselected
3576 (delq article gnus-newsgroup-unselected)))
3577 (push article gnus-newsgroup-ancient)))
3578 (forward-line 1)))))))
3580 (defun gnus-summary-update-article-line (article header)
3581 "Update the line for ARTICLE using HEADERS."
3582 (let* ((id (mail-header-id header))
3583 (thread (gnus-id-to-thread id)))
3585 (error "Article in no thread"))
3586 ;; Update the thread.
3587 (setcar thread header)
3588 (gnus-summary-goto-subject article)
3589 (let* ((datal (gnus-data-find-list article))
3591 (length (when (cdr datal)
3592 (- (gnus-data-pos data)
3593 (gnus-data-pos (cadr datal)))))
3594 (buffer-read-only nil)
3595 (level (gnus-summary-thread-level)))
3597 (gnus-summary-insert-line
3598 header level nil (gnus-article-mark article)
3599 (memq article gnus-newsgroup-replied)
3600 (memq article gnus-newsgroup-expirable)
3601 ;; Only insert the Subject string when it's different
3602 ;; from the previous Subject string.
3607 (mail-header-subject
3610 (gnus-data-find-list
3612 (gnus-data-list t)))))
3613 ;; Error on the side of excessive subjects.
3615 (mail-header-subject header)))
3617 (mail-header-subject header))
3618 nil (cdr (assq article gnus-newsgroup-scored))
3619 (memq article gnus-newsgroup-processable))
3621 (gnus-data-update-list
3622 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3624 (defun gnus-summary-update-article (article &optional iheader)
3625 "Update ARTICLE in the summary buffer."
3626 (set-buffer gnus-summary-buffer)
3627 (let* ((header (gnus-summary-article-header article))
3628 (id (mail-header-id header))
3629 (data (gnus-data-find article))
3630 (thread (gnus-id-to-thread id))
3631 (references (mail-header-references header))
3635 (when (and references
3636 (not (equal "" references)))
3639 (buffer-read-only nil)
3645 (delq thread parent)))
3646 (if (gnus-summary-insert-subject id header)
3647 ;; Set the (possibly) new article number in the data structure.
3648 (gnus-data-set-number data (gnus-id-to-article id))
3652 (defun gnus-rebuild-thread (id &optional line)
3653 "Rebuild the thread containing ID.
3654 If LINE, insert the rebuilt thread starting on line LINE."
3655 (let ((buffer-read-only nil)
3656 old-pos current thread data)
3657 (if (not gnus-show-threads)
3658 (setq thread (list (car (gnus-id-to-thread id))))
3659 ;; Get the thread this article is part of.
3660 (setq thread (gnus-remove-thread id)))
3661 (setq old-pos (gnus-point-at-bol))
3662 (setq current (save-excursion
3663 (and (zerop (forward-line -1))
3664 (gnus-summary-article-number))))
3665 ;; If this is a gathered thread, we have to go some re-gathering.
3666 (when (stringp (car thread))
3667 (let ((subject (car thread))
3669 (setq thread (cdr thread))
3671 (unless (memq (setq thr (gnus-id-to-thread
3673 (mail-header-id (caar thread)))))
3676 (setq thread (cdr thread)))
3677 ;; We now have all (unique) roots.
3678 (if (= (length roots) 1)
3679 ;; All the loose roots are now one solid root.
3680 (setq thread (car roots))
3681 (setq thread (cons subject (gnus-sort-threads roots))))))
3683 ;; We then insert this thread into the summary buffer.
3685 (goto-char (point-min))
3686 (forward-line (1- line)))
3687 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3688 (if gnus-show-threads
3689 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3690 (gnus-summary-prepare-unthreaded thread))
3691 (setq data (nreverse gnus-newsgroup-data))
3692 (setq threads gnus-newsgroup-threads))
3693 ;; We splice the new data into the data structure.
3694 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3695 ;;!!! then we want to insert at the beginning of the buffer.
3696 ;;!!! That happens to be true with Gnus now, but that may
3697 ;;!!! change in the future. Perhaps.
3698 (gnus-data-enter-list
3699 (if line nil current) data (- (point) old-pos))
3700 (setq gnus-newsgroup-threads
3701 (nconc threads gnus-newsgroup-threads))
3702 (gnus-data-compute-positions))))
3704 (defun gnus-number-to-header (number)
3705 "Return the header for article NUMBER."
3706 (let ((headers gnus-newsgroup-headers))
3708 (not (= number (mail-header-number (car headers)))))
3713 (defun gnus-parent-headers (in-headers &optional generation)
3714 "Return the headers of the GENERATIONeth parent of HEADERS."
3716 (setq generation 1))
3718 (headers in-headers)
3721 (not (zerop generation))
3722 (setq references (mail-header-references headers)))
3723 (setq headers (if (and references
3724 (setq parent (gnus-parent-id references)))
3725 (car (gnus-id-to-thread parent))
3728 (and (not (eq headers in-headers))
3731 (defun gnus-id-to-thread (id)
3732 "Return the (sub-)thread where ID appears."
3733 (gnus-gethash id gnus-newsgroup-dependencies))
3735 (defun gnus-id-to-article (id)
3736 "Return the article number of ID."
3737 (let ((thread (gnus-id-to-thread id)))
3740 (mail-header-number (car thread)))))
3742 (defun gnus-id-to-header (id)
3743 "Return the article headers of ID."
3744 (car (gnus-id-to-thread id)))
3746 (defun gnus-article-displayed-root-p (article)
3747 "Say whether ARTICLE is a root(ish) article."
3748 (let ((level (gnus-summary-thread-level article))
3749 (refs (mail-header-references (gnus-summary-article-header article)))
3755 ((null (gnus-parent-id refs)) t)
3757 (null (setq particle (gnus-id-to-article
3758 (gnus-parent-id refs))))
3759 (null (gnus-summary-thread-level particle)))))))
3761 (defun gnus-root-id (id)
3762 "Return the id of the root of the thread where ID appears."
3764 (while (and id (setq prev (car (gnus-id-to-thread id))))
3766 id (gnus-parent-id (mail-header-references prev))))
3769 (defun gnus-articles-in-thread (thread)
3770 "Return the list of articles in THREAD."
3771 (cons (mail-header-number (car thread))
3772 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3774 (defun gnus-remove-thread (id &optional dont-remove)
3775 "Remove the thread that has ID in it."
3776 (let (headers thread last-id)
3777 ;; First go up in this thread until we find the root.
3778 (setq last-id (gnus-root-id id)
3779 headers (message-flatten-list (gnus-id-to-thread last-id)))
3780 ;; We have now found the real root of this thread. It might have
3781 ;; been gathered into some loose thread, so we have to search
3782 ;; through the threads to find the thread we wanted.
3783 (let ((threads gnus-newsgroup-threads)
3786 (setq sub (car threads))
3787 (if (stringp (car sub))
3788 ;; This is a gathered thread, so we look at the roots
3789 ;; below it to find whether this article is in this
3792 (setq sub (cdr sub))
3794 (when (member (caar sub) headers)
3795 (setq thread (car threads)
3798 (setq sub (cdr sub))))
3799 ;; It's an ordinary thread, so we check it.
3800 (when (eq (car sub) (car headers))
3803 (setq threads (cdr threads)))
3804 ;; If this article is in no thread, then it's a root.
3807 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3808 (setq thread (gnus-id-to-thread last-id)))
3811 thread ; We return this thread.
3813 (if (stringp (car thread))
3815 ;; If we use dummy roots, then we have to remove the
3816 ;; dummy root as well.
3817 (when (eq gnus-summary-make-false-root 'dummy)
3818 ;; We go to the dummy root by going to
3819 ;; the first sub-"thread", and then one line up.
3820 (gnus-summary-goto-article
3821 (mail-header-number (caadr thread)))
3824 (gnus-data-compute-positions))
3825 (setq thread (cdr thread))
3827 (gnus-remove-thread-1 (car thread))
3828 (setq thread (cdr thread))))
3829 (gnus-remove-thread-1 thread))))))))
3831 (defun gnus-remove-thread-1 (thread)
3832 "Remove the thread THREAD recursively."
3833 (let ((number (mail-header-number (pop thread)))
3835 (setq thread (reverse thread))
3837 (gnus-remove-thread-1 (pop thread)))
3838 (when (setq d (gnus-data-find number))
3839 (goto-char (gnus-data-pos d))
3840 (gnus-summary-show-thread)
3843 (- (gnus-point-at-bol)
3845 (1+ (gnus-point-at-eol))
3846 (gnus-delete-line)))))))
3848 (defun gnus-sort-threads-1 (threads func)
3849 (sort (mapcar (lambda (thread)
3852 (gnus-sort-threads-1 (cdr thread) func))))
3855 (defun gnus-sort-threads (threads)
3857 (if (not gnus-thread-sort-functions)
3859 (gnus-message 8 "Sorting threads...")
3861 (gnus-sort-threads-1
3863 (gnus-make-sort-function gnus-thread-sort-functions))
3864 (gnus-message 8 "Sorting threads...done"))))
3866 (defun gnus-sort-articles (articles)
3868 (when gnus-article-sort-functions
3869 (gnus-message 7 "Sorting articles...")
3871 (setq gnus-newsgroup-headers
3872 (sort articles (gnus-make-sort-function
3873 gnus-article-sort-functions)))
3874 (gnus-message 7 "Sorting articles...done"))))
3876 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3877 (defmacro gnus-thread-header (thread)
3878 "Return header of first article in THREAD.
3879 Note that THREAD must never, ever be anything else than a variable -
3880 using some other form will lead to serious barfage."
3881 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3882 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3883 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3886 (defsubst gnus-article-sort-by-number (h1 h2)
3887 "Sort articles by article number."
3888 (< (mail-header-number h1)
3889 (mail-header-number h2)))
3891 (defun gnus-thread-sort-by-number (h1 h2)
3892 "Sort threads by root article number."
3893 (gnus-article-sort-by-number
3894 (gnus-thread-header h1) (gnus-thread-header h2)))
3896 (defsubst gnus-article-sort-by-lines (h1 h2)
3897 "Sort articles by article Lines header."
3898 (< (mail-header-lines h1)
3899 (mail-header-lines h2)))
3901 (defun gnus-thread-sort-by-lines (h1 h2)
3902 "Sort threads by root article Lines header."
3903 (gnus-article-sort-by-lines
3904 (gnus-thread-header h1) (gnus-thread-header h2)))
3906 (defsubst gnus-article-sort-by-chars (h1 h2)
3907 "Sort articles by octet length."
3908 (< (mail-header-chars h1)
3909 (mail-header-chars h2)))
3911 (defun gnus-thread-sort-by-chars (h1 h2)
3912 "Sort threads by root article octet length."
3913 (gnus-article-sort-by-chars
3914 (gnus-thread-header h1) (gnus-thread-header h2)))
3916 (defsubst gnus-article-sort-by-author (h1 h2)
3917 "Sort articles by root author."
3919 (let ((addr (car (mime-entity-read-field h1 'From))))
3920 (or (std11-full-name-string addr)
3921 (std11-address-string addr)
3923 (let ((addr (car (mime-entity-read-field h2 'From))))
3924 (or (std11-full-name-string addr)
3925 (std11-address-string addr)
3929 (defun gnus-thread-sort-by-author (h1 h2)
3930 "Sort threads by root author."
3931 (gnus-article-sort-by-author
3932 (gnus-thread-header h1) (gnus-thread-header h2)))
3934 (defsubst gnus-article-sort-by-subject (h1 h2)
3935 "Sort articles by root subject."
3937 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3938 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3940 (defun gnus-thread-sort-by-subject (h1 h2)
3941 "Sort threads by root subject."
3942 (gnus-article-sort-by-subject
3943 (gnus-thread-header h1) (gnus-thread-header h2)))
3945 (defsubst gnus-article-sort-by-date (h1 h2)
3946 "Sort articles by root article date."
3948 (gnus-date-get-time (mail-header-date h1))
3949 (gnus-date-get-time (mail-header-date h2))))
3951 (defun gnus-thread-sort-by-date (h1 h2)
3952 "Sort threads by root article date."
3953 (gnus-article-sort-by-date
3954 (gnus-thread-header h1) (gnus-thread-header h2)))
3956 (defsubst gnus-article-sort-by-score (h1 h2)
3957 "Sort articles by root article score.
3958 Unscored articles will be counted as having a score of zero."
3959 (> (or (cdr (assq (mail-header-number h1)
3960 gnus-newsgroup-scored))
3961 gnus-summary-default-score 0)
3962 (or (cdr (assq (mail-header-number h2)
3963 gnus-newsgroup-scored))
3964 gnus-summary-default-score 0)))
3966 (defun gnus-thread-sort-by-score (h1 h2)
3967 "Sort threads by root article score."
3968 (gnus-article-sort-by-score
3969 (gnus-thread-header h1) (gnus-thread-header h2)))
3971 (defun gnus-thread-sort-by-total-score (h1 h2)
3972 "Sort threads by the sum of all scores in the thread.
3973 Unscored articles will be counted as having a score of zero."
3974 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3976 (defun gnus-thread-total-score (thread)
3977 ;; This function find the total score of THREAD.
3978 (cond ((null thread)
3981 (if (stringp (car thread))
3982 (apply gnus-thread-score-function 0
3983 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3984 (gnus-thread-total-score-1 thread)))
3986 (gnus-thread-total-score-1 (list thread)))))
3988 (defun gnus-thread-total-score-1 (root)
3989 ;; This function find the total score of the thread below ROOT.
3990 (setq root (car root))
3991 (apply gnus-thread-score-function
3993 (mapcar 'gnus-thread-total-score
3994 (cdr (gnus-id-to-thread (mail-header-id root))))
3995 (when (> (mail-header-number root) 0)
3996 (list (or (cdr (assq (mail-header-number root)
3997 gnus-newsgroup-scored))
3998 gnus-summary-default-score 0))))
3999 (list gnus-summary-default-score)
4002 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4003 (defvar gnus-tmp-prev-subject nil)
4004 (defvar gnus-tmp-false-parent nil)
4005 (defvar gnus-tmp-root-expunged nil)
4006 (defvar gnus-tmp-dummy-line nil)
4008 (eval-when-compile (defvar gnus-tmp-header))
4009 (defun gnus-extra-header (type &optional header)
4010 "Return the extra header of TYPE."
4011 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4014 (defun gnus-summary-prepare-threads (threads)
4015 "Prepare summary buffer from THREADS and indentation LEVEL.
4016 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4017 or a straight list of headers."
4018 (gnus-message 7 "Generating summary...")
4020 (setq gnus-newsgroup-threads threads)
4023 (let ((gnus-tmp-level 0)
4024 (default-score (or gnus-summary-default-score 0))
4025 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4026 thread number subject stack state gnus-tmp-gathered beg-match
4027 new-roots gnus-tmp-new-adopts thread-end
4028 gnus-tmp-header gnus-tmp-unread
4029 gnus-tmp-replied gnus-tmp-subject-or-nil
4030 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4031 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4032 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4034 (setq gnus-tmp-prev-subject nil)
4036 (if (vectorp (car threads))
4037 ;; If this is a straight (sic) list of headers, then a
4038 ;; threaded summary display isn't required, so we just create
4039 ;; an unthreaded one.
4040 (gnus-summary-prepare-unthreaded threads)
4042 ;; Do the threaded display.
4044 (while (or threads stack gnus-tmp-new-adopts new-roots)
4046 (if (and (= gnus-tmp-level 0)
4049 (not gnus-tmp-false-parent)
4050 (or gnus-tmp-new-adopts new-roots))
4051 (if gnus-tmp-new-adopts
4052 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4053 thread (list (car gnus-tmp-new-adopts))
4054 gnus-tmp-header (caar thread)
4055 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4057 (setq thread (list (car new-roots))
4058 gnus-tmp-header (caar thread)
4059 new-roots (cdr new-roots))))
4062 ;; If there are some threads, we do them before the
4063 ;; threads on the stack.
4064 (setq thread threads
4065 gnus-tmp-header (caar thread))
4066 ;; There were no current threads, so we pop something off
4068 (setq state (car stack)
4069 gnus-tmp-level (car state)
4072 gnus-tmp-header (caar thread))))
4074 (setq gnus-tmp-false-parent nil)
4075 (setq gnus-tmp-root-expunged nil)
4076 (setq thread-end nil)
4078 (if (stringp gnus-tmp-header)
4079 ;; The header is a dummy root.
4081 ((eq gnus-summary-make-false-root 'adopt)
4082 ;; We let the first article adopt the rest.
4083 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4085 (setq gnus-tmp-gathered
4087 (lambda (h) (mail-header-number (car h)))
4090 (setq thread (cons (list (caar thread)
4093 (setq gnus-tmp-level -1
4094 gnus-tmp-false-parent t))
4095 ((eq gnus-summary-make-false-root 'empty)
4096 ;; We print adopted articles with empty subject fields.
4097 (setq gnus-tmp-gathered
4099 (lambda (h) (mail-header-number (car h)))
4102 (setq gnus-tmp-level -1))
4103 ((eq gnus-summary-make-false-root 'dummy)
4104 ;; We remember that we probably want to output a dummy
4106 (setq gnus-tmp-dummy-line gnus-tmp-header)
4107 (setq gnus-tmp-prev-subject gnus-tmp-header))
4109 ;; We do not make a root for the gathered
4110 ;; sub-threads at all.
4111 (setq gnus-tmp-level -1)))
4113 (setq number (mail-header-number gnus-tmp-header)
4114 subject (mail-header-subject gnus-tmp-header))
4117 ;; If the thread has changed subject, we might want to make
4118 ;; this subthread into a root.
4119 ((and (null gnus-thread-ignore-subject)
4120 (not (zerop gnus-tmp-level))
4121 gnus-tmp-prev-subject
4123 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4124 (setq new-roots (nconc new-roots (list (car thread)))
4126 gnus-tmp-header nil))
4127 ;; If the article lies outside the current limit,
4128 ;; then we do not display it.
4129 ((not (memq number gnus-newsgroup-limit))
4130 (setq gnus-tmp-gathered
4132 (lambda (h) (mail-header-number (car h)))
4135 (setq gnus-tmp-new-adopts (if (cdar thread)
4136 (append gnus-tmp-new-adopts
4138 gnus-tmp-new-adopts)
4140 gnus-tmp-header nil)
4141 (when (zerop gnus-tmp-level)
4142 (setq gnus-tmp-root-expunged t)))
4143 ;; Perhaps this article is to be marked as read?
4144 ((and gnus-summary-mark-below
4145 (< (or (cdr (assq number gnus-newsgroup-scored))
4147 gnus-summary-mark-below)
4148 ;; Don't touch sparse articles.
4149 (not (gnus-summary-article-sparse-p number))
4150 (not (gnus-summary-article-ancient-p number)))
4151 (setq gnus-newsgroup-unreads
4152 (delq number gnus-newsgroup-unreads))
4153 (if gnus-newsgroup-auto-expire
4154 (push number gnus-newsgroup-expirable)
4155 (push (cons number gnus-low-score-mark)
4156 gnus-newsgroup-reads))))
4158 (when gnus-tmp-header
4159 ;; We may have an old dummy line to output before this
4161 (when (and gnus-tmp-dummy-line
4164 (mail-header-subject gnus-tmp-header)))
4165 (gnus-summary-insert-dummy-line
4166 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4167 (setq gnus-tmp-dummy-line nil))
4169 ;; Compute the mark.
4170 (setq gnus-tmp-unread (gnus-article-mark number))
4172 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4173 gnus-tmp-header gnus-tmp-level)
4174 gnus-newsgroup-data)
4176 ;; Actually insert the line.
4178 gnus-tmp-subject-or-nil
4180 ((and gnus-thread-ignore-subject
4181 gnus-tmp-prev-subject
4182 (not (inline (gnus-subject-equal
4183 gnus-tmp-prev-subject subject))))
4185 ((zerop gnus-tmp-level)
4186 (if (and (eq gnus-summary-make-false-root 'empty)
4187 (memq number gnus-tmp-gathered)
4188 gnus-tmp-prev-subject
4189 (inline (gnus-subject-equal
4190 gnus-tmp-prev-subject subject)))
4191 gnus-summary-same-subject
4193 (t gnus-summary-same-subject)))
4194 (if (and (eq gnus-summary-make-false-root 'adopt)
4195 (= gnus-tmp-level 1)
4196 (memq number gnus-tmp-gathered))
4197 (setq gnus-tmp-opening-bracket ?\<
4198 gnus-tmp-closing-bracket ?\>)
4199 (setq gnus-tmp-opening-bracket ?\[
4200 gnus-tmp-closing-bracket ?\]))
4202 gnus-tmp-indentation
4203 (aref gnus-thread-indent-array gnus-tmp-level)
4204 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4205 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4206 gnus-summary-default-score 0)
4208 (if (or (null gnus-summary-default-score)
4209 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4210 gnus-summary-zcore-fuzz))
4212 (if (< gnus-tmp-score gnus-summary-default-score)
4213 gnus-score-below-mark gnus-score-over-mark))
4215 (cond ((memq number gnus-newsgroup-processable)
4217 ((memq number gnus-newsgroup-cached)
4219 ((memq number gnus-newsgroup-replied)
4221 ((memq number gnus-newsgroup-saved)
4224 gnus-tmp-from (mail-header-from gnus-tmp-header)
4227 ((string-match "<[^>]+> *$" gnus-tmp-from)
4228 (setq beg-match (match-beginning 0))
4229 (or (and (string-match "^\".+\"" gnus-tmp-from)
4230 (substring gnus-tmp-from 1 (1- (match-end 0))))
4231 (substring gnus-tmp-from 0 beg-match)))
4232 ((string-match "(.+)" gnus-tmp-from)
4233 (substring gnus-tmp-from
4234 (1+ (match-beginning 0)) (1- (match-end 0))))
4236 (when (string= gnus-tmp-name "")
4237 (setq gnus-tmp-name gnus-tmp-from))
4238 (unless (numberp gnus-tmp-lines)
4239 (setq gnus-tmp-lines 0))
4240 (gnus-put-text-property
4242 (progn (eval gnus-summary-line-format-spec) (point))
4243 'gnus-number number)
4246 (gnus-run-hooks 'gnus-summary-update-hook)
4249 (setq gnus-tmp-prev-subject subject)))
4251 (when (nth 1 thread)
4252 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4253 (incf gnus-tmp-level)
4254 (setq threads (if thread-end nil (cdar thread)))
4256 (setq gnus-tmp-level 0)))))
4257 (gnus-message 7 "Generating summary...done"))
4259 (defun gnus-summary-prepare-unthreaded (headers)
4260 "Generate an unthreaded summary buffer based on HEADERS."
4261 (let (header number mark)
4266 ;; We may have to root out some bad articles...
4267 (when (memq (setq number (mail-header-number
4268 (setq header (pop headers))))
4269 gnus-newsgroup-limit)
4270 ;; Mark article as read when it has a low score.
4271 (when (and gnus-summary-mark-below
4272 (< (or (cdr (assq number gnus-newsgroup-scored))
4273 gnus-summary-default-score 0)
4274 gnus-summary-mark-below)
4275 (not (gnus-summary-article-ancient-p number)))
4276 (setq gnus-newsgroup-unreads
4277 (delq number gnus-newsgroup-unreads))
4278 (if gnus-newsgroup-auto-expire
4279 (push number gnus-newsgroup-expirable)
4280 (push (cons number gnus-low-score-mark)
4281 gnus-newsgroup-reads)))
4283 (setq mark (gnus-article-mark number))
4284 (push (gnus-data-make number mark (1+ (point)) header 0)
4285 gnus-newsgroup-data)
4286 (gnus-summary-insert-line
4288 mark (memq number gnus-newsgroup-replied)
4289 (memq number gnus-newsgroup-expirable)
4290 (mail-header-subject header) nil
4291 (cdr (assq number gnus-newsgroup-scored))
4292 (memq number gnus-newsgroup-processable))))))
4294 (defun gnus-summary-remove-list-identifiers ()
4295 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4296 (let ((regexp (if (consp gnus-list-identifiers)
4297 (mapconcat 'identity gnus-list-identifiers " *\\|")
4298 gnus-list-identifiers))
4301 (dolist (header gnus-newsgroup-headers)
4302 (setq subject (mail-header-subject header)
4304 (while (string-match
4305 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4308 (concat (substring subject 0 (match-beginning 2))
4309 (substring subject (match-end 0)))
4313 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4315 (concat (substring subject 0 (match-beginning 1))
4316 (substring subject (match-end 1)))))
4318 (mail-header-set-subject header subject))))))
4320 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4321 "Select newsgroup GROUP.
4322 If READ-ALL is non-nil, all articles in the group are selected.
4323 If SELECT-ARTICLES, only select those articles from GROUP."
4324 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4325 ;;!!! Dirty hack; should be removed.
4326 (gnus-summary-ignore-duplicates
4327 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4329 gnus-summary-ignore-duplicates))
4330 (info (nth 2 entry))
4331 articles fetched-articles cached)
4333 (unless (gnus-check-server
4334 (setq gnus-current-select-method
4335 (gnus-find-method-for-group group)))
4336 (error "Couldn't open server"))
4338 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4339 (gnus-activate-group group) ; Or we can activate it...
4340 (progn ; Or we bug out.
4341 (when (equal major-mode 'gnus-summary-mode)
4342 (kill-buffer (current-buffer)))
4343 (error "Couldn't activate group %s: %s"
4344 group (gnus-status-message group))))
4346 (unless (gnus-request-group group t)
4347 (when (equal major-mode 'gnus-summary-mode)
4348 (kill-buffer (current-buffer)))
4349 (error "Couldn't request group %s: %s"
4350 group (gnus-status-message group)))
4352 (setq gnus-newsgroup-name group)
4353 (setq gnus-newsgroup-unselected nil)
4354 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4355 (gnus-summary-setup-default-charset)
4357 ;; Adjust and set lists of article marks.
4359 (gnus-adjust-marked-articles info))
4361 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4363 (if (gnus-virtual-group-p group)
4364 gnus-newsgroup-cached
4365 (gnus-cache-articles-in-group group)))
4367 (setq gnus-newsgroup-unreads
4368 (gnus-set-difference
4369 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4370 gnus-newsgroup-dormant))
4372 (setq gnus-newsgroup-processable nil)
4374 (gnus-update-read-articles group gnus-newsgroup-unreads)
4376 (if (setq articles select-articles)
4377 (setq gnus-newsgroup-unselected
4378 (gnus-sorted-intersection
4379 gnus-newsgroup-unreads
4380 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4381 (setq articles (gnus-articles-to-read group read-all)))
4385 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4387 ((eq articles 0) nil)
4389 ;; Init the dependencies hash table.
4390 (setq gnus-newsgroup-dependencies
4391 (gnus-make-hashtable (length articles)))
4392 (gnus-set-global-variables)
4393 ;; Retrieve the headers and read them in.
4394 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4395 (setq gnus-newsgroup-headers
4396 (gnus-retrieve-parsed-headers
4397 articles gnus-newsgroup-name
4398 ;; We might want to fetch old headers, but
4399 ;; not if there is only 1 article.
4400 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4401 (not (numberp gnus-fetch-old-headers)))
4402 (> (length articles) 1))
4403 gnus-fetch-old-headers)))
4404 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4406 ;; Suppress duplicates?
4407 (when gnus-suppress-duplicates
4408 (gnus-dup-suppress-articles))
4410 ;; Set the initial limit.
4411 (setq gnus-newsgroup-limit (copy-sequence articles))
4412 ;; Remove canceled articles from the list of unread articles.
4413 (setq gnus-newsgroup-unreads
4414 (gnus-set-sorted-intersection
4415 gnus-newsgroup-unreads
4416 (setq fetched-articles
4417 (mapcar (lambda (headers) (mail-header-number headers))
4418 gnus-newsgroup-headers))))
4419 ;; Removed marked articles that do not exist.
4420 (gnus-update-missing-marks
4421 (gnus-sorted-complement fetched-articles articles))
4423 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4425 (setq gnus-newsgroup-cached cached))
4427 ;; We might want to build some more threads first.
4428 (when (and gnus-fetch-old-headers
4429 (eq gnus-headers-retrieved-by 'nov))
4430 (if (eq gnus-fetch-old-headers 'invisible)
4431 (gnus-build-all-threads)
4432 (gnus-build-old-threads)))
4433 ;; Let the Gnus agent mark articles as read.
4435 (gnus-agent-get-undownloaded-list))
4436 ;; Remove list identifiers from subject
4437 (when gnus-list-identifiers
4438 (gnus-summary-remove-list-identifiers))
4439 ;; Check whether auto-expire is to be done in this group.
4440 (setq gnus-newsgroup-auto-expire
4441 (gnus-group-auto-expirable-p group))
4442 ;; Set up the article buffer now, if necessary.
4443 (unless gnus-single-article-buffer
4444 (gnus-article-setup-buffer))
4445 ;; First and last article in this newsgroup.
4446 (when gnus-newsgroup-headers
4447 (setq gnus-newsgroup-begin
4448 (mail-header-number (car gnus-newsgroup-headers))
4451 (gnus-last-element gnus-newsgroup-headers))))
4452 ;; GROUP is successfully selected.
4453 (or gnus-newsgroup-headers t)))))
4455 (defun gnus-articles-to-read (group &optional read-all)
4456 "Find out what articles the user wants to read."
4458 ;; Select all articles if `read-all' is non-nil, or if there
4459 ;; are no unread articles.
4461 (and (zerop (length gnus-newsgroup-marked))
4462 (zerop (length gnus-newsgroup-unreads)))
4463 (eq (gnus-group-find-parameter group 'display)
4466 (gnus-uncompress-range (gnus-active group))
4467 (gnus-cache-articles-in-group group))
4468 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4469 (copy-sequence gnus-newsgroup-unreads))
4471 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4472 (scored (length scored-list))
4473 (number (length articles))
4474 (marked (+ (length gnus-newsgroup-marked)
4475 (length gnus-newsgroup-dormant)))
4483 ((and (or (<= scored marked) (= scored number))
4484 (natnump gnus-large-newsgroup)
4485 (> number gnus-large-newsgroup))
4486 (let* ((cursor-in-echo-area nil)
4487 (input (read-from-minibuffer
4489 "How many articles from %s (max %d): "
4490 (gnus-limit-string gnus-newsgroup-name 35)
4492 (cons (number-to-string gnus-large-newsgroup)
4494 (if (string-match "^[ \t]*$" input)
4497 ((and (> scored marked) (< scored number)
4498 (> (- scored number) 20))
4501 (format "%s %s (%d scored, %d total): "
4502 "How many articles from"
4503 group scored number))))
4504 (if (string-match "^[ \t]*$" input)
4508 (message "Quit getting the articles to read")
4510 (setq select (if (stringp select) (string-to-number select) select))
4511 (if (or (null select) (zerop select))
4513 (if (and (not (zerop scored)) (<= (abs select) scored))
4515 (setq articles (sort scored-list '<))
4516 (setq number (length articles)))
4517 (setq articles (copy-sequence articles)))
4519 (when (< (abs select) number)
4521 ;; Select the N oldest articles.
4522 (setcdr (nthcdr (1- (abs select)) articles) nil)
4523 ;; Select the N most recent articles.
4524 (setq articles (nthcdr (- number select) articles))))
4525 (setq gnus-newsgroup-unselected
4526 (gnus-sorted-intersection
4527 gnus-newsgroup-unreads
4528 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4529 (when gnus-alter-articles-to-read-function
4530 (setq gnus-newsgroup-unreads
4532 (funcall gnus-alter-articles-to-read-function
4533 gnus-newsgroup-name gnus-newsgroup-unreads)
4537 (defun gnus-killed-articles (killed articles)
4540 (when (inline (gnus-member-of-range (car articles) killed))
4541 (push (car articles) out))
4542 (setq articles (cdr articles)))
4545 (defun gnus-uncompress-marks (marks)
4546 "Uncompress the mark ranges in MARKS."
4547 (let ((uncompressed '(score bookmark))
4550 (if (memq (caar marks) uncompressed)
4551 (push (car marks) out)
4552 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4553 (setq marks (cdr marks)))
4556 (defun gnus-adjust-marked-articles (info)
4557 "Set all article lists and remove all marks that are no longer valid."
4558 (let* ((marked-lists (gnus-info-marks info))
4559 (active (gnus-active (gnus-info-group info)))
4562 (types gnus-article-mark-lists)
4563 (uncompressed '(score bookmark killed))
4564 marks var articles article mark)
4567 (setq marks (pop marked-lists))
4568 (set (setq var (intern (format "gnus-newsgroup-%s"
4569 (car (rassq (setq mark (car marks))
4571 (if (memq (car marks) uncompressed) (cdr marks)
4572 (gnus-uncompress-range (cdr marks))))
4574 (setq articles (symbol-value var))
4576 ;; All articles have to be subsets of the active articles.
4578 ;; Adjust "simple" lists.
4579 ((memq mark '(tick dormant expire reply save))
4581 (when (or (< (setq article (pop articles)) min) (> article max))
4582 (set var (delq article (symbol-value var))))))
4584 ((memq mark uncompressed)
4585 (when (not (listp (cdr (symbol-value var))))
4586 (set var (list (symbol-value var))))
4587 (when (not (listp (cdr articles)))
4588 (setq articles (list articles)))
4590 (when (or (not (consp (setq article (pop articles))))
4591 (< (car article) min)
4592 (> (car article) max))
4593 (set var (delq article (symbol-value var))))))))))
4595 (defun gnus-update-missing-marks (missing)
4596 "Go through the list of MISSING articles and remove them from the mark lists."
4598 (let ((types gnus-article-mark-lists)
4600 ;; Go through all types.
4602 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4603 (when (symbol-value var)
4604 ;; This list has articles. So we delete all missing articles
4608 (set var (delq (pop m) (symbol-value var)))))))))
4610 (defun gnus-update-marks ()
4611 "Enter the various lists of marked articles into the newsgroup info list."
4612 (let ((types gnus-article-mark-lists)
4613 (info (gnus-get-info gnus-newsgroup-name))
4614 (uncompressed '(score bookmark killed))
4615 type list newmarked symbol delta-marks)
4617 ;; Add all marks lists to the list of marks lists.
4618 (while (setq type (pop types))
4619 (setq list (symbol-value
4621 (intern (format "gnus-newsgroup-%s"
4625 ;; Get rid of the entries of the articles that have the
4627 (when (and (eq (cdr type) 'score)
4631 (prev (cons nil list))
4634 (if (or (not (consp (car arts)))
4635 (= (cdar arts) gnus-summary-default-score))
4636 (setcdr prev (cdr arts))
4638 (setq arts (cdr arts)))
4639 (setq list (cdr all)))))
4641 (unless (memq (cdr type) uncompressed)
4642 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4644 (when (gnus-check-backend-function
4645 'request-set-mark gnus-newsgroup-name)
4646 ;; propagate flags to server, with the following exceptions:
4647 ;; uncompressed:s are not proper flags (they are cons cells)
4648 ;; cache is a internal gnus flag
4649 ;; download are local to one gnus installation (well)
4650 ;; unsend are for nndraft groups only
4651 ;; xxx: generality of this? this suits nnimap anyway
4652 (unless (memq (cdr type) (append '(cache download unsend)
4654 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4655 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4656 (add (gnus-remove-from-range
4657 (gnus-copy-sequence list) old)))
4659 (push (list add 'add (list (cdr type))) delta-marks))
4661 (push (list del 'del (list (cdr type))) delta-marks)))))
4664 (push (cons (cdr type) list) newmarked)))
4667 (unless (gnus-check-group gnus-newsgroup-name)
4668 (error "Can't open server for %s" gnus-newsgroup-name))
4669 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4671 ;; Enter these new marks into the info of the group.
4673 (setcar (nthcdr 3 info) newmarked)
4674 ;; Add the marks lists to the end of the info.
4676 (setcdr (nthcdr 2 info) (list newmarked))))
4678 ;; Cut off the end of the info if there's nothing else there.
4682 (when (nthcdr (decf i) info)
4683 (setcdr (nthcdr i info) nil)))))))
4685 (defun gnus-set-mode-line (where)
4686 "Set the mode line of the article or summary buffers.
4687 If WHERE is `summary', the summary mode line format will be used."
4688 ;; Is this mode line one we keep updated?
4689 (when (and (memq where gnus-updated-mode-lines)
4691 (intern (format "gnus-%s-mode-line-format-spec" where))))
4694 ;; We evaluate this in the summary buffer since these
4695 ;; variables are buffer-local to that buffer.
4696 (set-buffer gnus-summary-buffer)
4697 ;; We bind all these variables that are used in the `eval' form
4699 (let* ((mformat (symbol-value
4701 (format "gnus-%s-mode-line-format-spec" where))))
4702 (gnus-tmp-group-name (gnus-group-name-decode
4704 (gnus-group-name-charset
4706 gnus-newsgroup-name)))
4707 (gnus-tmp-article-number (or gnus-current-article 0))
4708 (gnus-tmp-unread gnus-newsgroup-unreads)
4709 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4710 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4711 (gnus-tmp-unread-and-unselected
4712 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4713 (zerop gnus-tmp-unselected))
4715 ((zerop gnus-tmp-unselected)
4716 (format "{%d more}" gnus-tmp-unread-and-unticked))
4717 (t (format "{%d(+%d) more}"
4718 gnus-tmp-unread-and-unticked
4719 gnus-tmp-unselected))))
4721 (if (and gnus-current-headers
4722 (vectorp gnus-current-headers))
4723 (gnus-mode-string-quote
4724 (mail-header-subject gnus-current-headers))
4726 bufname-length max-len
4727 gnus-tmp-header);; passed as argument to any user-format-funcs
4728 (setq mode-string (eval mformat))
4729 (setq bufname-length (if (string-match "%b" mode-string)
4732 (if (eq where 'summary)
4734 (get-buffer gnus-article-buffer))))
4737 (setq max-len (max 4 (if gnus-mode-non-string-length
4739 gnus-mode-non-string-length
4741 (length mode-string))))
4742 ;; We might have to chop a bit of the string off...
4743 (when (> (length mode-string) max-len)
4745 (concat (gnus-truncate-string mode-string (- max-len 3))
4747 ;; Pad the mode string a bit.
4748 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4749 ;; Update the mode line.
4750 (setq mode-line-buffer-identification
4751 (gnus-mode-line-buffer-identification (list mode-string)))
4752 (set-buffer-modified-p t))))
4754 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4755 "Go through the HEADERS list and add all Xrefs to a hash table.
4756 The resulting hash table is returned, or nil if no Xrefs were found."
4757 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4758 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4759 (xref-hashtb (gnus-make-hashtable))
4760 start group entry number xrefs header)
4762 (setq header (pop headers))
4763 (when (and (setq xrefs (mail-header-xref header))
4764 (not (memq (setq number (mail-header-number header))
4767 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4768 (setq start (match-end 0))
4769 (setq group (if prefix
4770 (concat prefix (substring xrefs (match-beginning 1)
4772 (substring xrefs (match-beginning 1) (match-end 1))))
4774 (string-to-int (substring xrefs (match-beginning 2)
4776 (if (setq entry (gnus-gethash group xref-hashtb))
4777 (setcdr entry (cons number (cdr entry)))
4778 (gnus-sethash group (cons number nil) xref-hashtb)))))
4779 (and start xref-hashtb)))
4781 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4782 "Look through all the headers and mark the Xrefs as read."
4783 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4784 name entry info xref-hashtb idlist method nth4)
4786 (set-buffer gnus-group-buffer)
4787 (when (setq xref-hashtb
4788 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4791 (unless (string= from-newsgroup (setq name (symbol-name group)))
4792 (setq idlist (symbol-value group))
4793 ;; Dead groups are not updated.
4795 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4797 (when (stringp (setq nth4 (gnus-info-method info)))
4798 (setq nth4 (gnus-server-to-method nth4))))
4799 ;; Only do the xrefs if the group has the same
4800 ;; select method as the group we have just read.
4801 (or (gnus-methods-equal-p
4802 nth4 (gnus-find-method-for-group from-newsgroup))
4804 (equal nth4 (setq method (gnus-find-method-for-group
4806 (and (equal (car nth4) (car method))
4807 (equal (nth 1 nth4) (nth 1 method))))
4808 gnus-use-cross-reference
4809 (or (not (eq gnus-use-cross-reference t))
4811 ;; Only do cross-references on subscribed
4812 ;; groups, if that is what is wanted.
4813 (<= (gnus-info-level info) gnus-level-subscribed))
4814 (gnus-group-make-articles-read name idlist))))
4817 (defun gnus-compute-read-articles (group articles)
4818 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4819 (info (nth 2 entry))
4820 (active (gnus-active group))
4823 ;; First peel off all invalid article numbers.
4825 (let ((ids articles)
4827 (while (setq id (pop ids))
4828 (when (and first (> id (cdr active)))
4829 ;; We'll end up in this situation in one particular
4830 ;; obscure situation. If you re-scan a group and get
4831 ;; a new article that is cross-posted to a different
4832 ;; group that has not been re-scanned, you might get
4833 ;; crossposted article that has a higher number than
4834 ;; Gnus believes possible. So we re-activate this
4835 ;; group as well. This might mean doing the
4836 ;; crossposting thingy will *increase* the number
4837 ;; of articles in some groups. Tsk, tsk.
4838 (setq active (or (gnus-activate-group group) active)))
4839 (when (or (> id (cdr active))
4840 (< id (car active)))
4841 (setq articles (delq id articles))))))
4842 ;; If the read list is nil, we init it.
4844 (null (gnus-info-read info))
4846 (setq ninfo (cons 1 (1- (car active))))
4847 (setq ninfo (gnus-info-read info)))
4848 ;; Then we add the read articles to the range.
4850 ninfo (setq articles (sort articles '<))))))
4852 (defun gnus-group-make-articles-read (group articles)
4853 "Update the info of GROUP to say that ARTICLES are read."
4855 (entry (gnus-gethash group gnus-newsrc-hashtb))
4856 (info (nth 2 entry))
4857 (active (gnus-active group))
4860 (setq range (gnus-compute-read-articles group articles))
4862 (set-buffer gnus-group-buffer)
4865 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4866 (gnus-info-set-read ',info ',(gnus-info-read info))
4867 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4868 (gnus-group-update-group ,group t))))
4869 ;; Add the read articles to the range.
4870 (gnus-info-set-read info range)
4871 ;; Then we have to re-compute how many unread
4872 ;; articles there are in this group.
4876 (setq num (- (1+ (cdr active)) (car active))))
4877 ((not (listp (cdr range)))
4878 (setq num (- (cdr active) (- (1+ (cdr range))
4882 (if (numberp (car range))
4884 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4885 (setq range (cdr range)))
4886 (setq num (- (cdr active) num))))
4887 ;; Update the number of unread articles.
4889 ;; Update the group buffer.
4890 (gnus-group-update-group group t)))))
4892 (defvar gnus-newsgroup-none-id 0)
4894 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4895 (let ((cur nntp-server-buffer)
4898 (save-excursion (set-buffer gnus-summary-buffer)
4899 gnus-newsgroup-dependencies)))
4901 (mail-parse-charset gnus-newsgroup-charset)
4902 (mail-parse-ignored-charsets
4903 (save-excursion (condition-case nil
4904 (set-buffer gnus-summary-buffer)
4906 gnus-newsgroup-ignored-charsets)))
4908 (set-buffer nntp-server-buffer)
4909 ;; Translate all TAB characters into SPACE characters.
4910 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4911 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4912 (gnus-run-hooks 'gnus-parse-headers-hook)
4913 (let ((case-fold-search t)
4914 in-reply-to header p lines chars ctype)
4915 (goto-char (point-min))
4916 ;; Search to the beginning of the next header. Error messages
4917 ;; do not begin with 2 or 3.
4918 (while (re-search-forward "^[23][0-9]+ " nil t)
4921 ;; This implementation of this function, with nine
4922 ;; search-forwards instead of the one re-search-forward and
4923 ;; a case (which basically was the old function) is actually
4924 ;; about twice as fast, even though it looks messier. You
4925 ;; can't have everything, I guess. Speed and elegance
4926 ;; doesn't always go hand in hand.
4929 (make-full-mail-header
4935 (narrow-to-region (point)
4936 (or (and (search-forward "\n.\n" nil t)
4942 (if (search-forward "\nsubject: " nil t)
4943 (nnheader-header-value)
4948 (if (or (search-forward "\nfrom: " nil t)
4949 (search-forward "\nfrom:" nil t))
4950 (nnheader-header-value)
4955 (if (search-forward "\ndate: " nil t)
4956 (nnheader-header-value)
4961 (setq id (if (re-search-forward
4962 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4963 ;; We do it this way to make sure the Message-ID
4964 ;; is (somewhat) syntactically valid.
4965 (buffer-substring (match-beginning 1)
4967 ;; If there was no message-id, we just fake one
4968 ;; to make subsequent routines simpler.
4969 (nnheader-generate-fake-message-id))))
4973 (if (search-forward "\nreferences: " nil t)
4977 (nnheader-header-value)
4982 (search-backward ">" end t)
4985 (search-backward "<" end t)
4987 ;; Get the references from the in-reply-to header if there
4988 ;; were no references and the in-reply-to header looks
4990 (if (and (search-forward "\nin-reply-to: " nil t)
4991 (setq in-reply-to (nnheader-header-value))
4992 (string-match "<[^>]+>" in-reply-to))
4994 (setq ref (substring in-reply-to (match-beginning 0)
4996 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4997 (setq ref2 (substring in-reply-to (match-beginning 0)
4999 (when (> (length ref2) (length ref))
5006 (if (search-forward "\nchars: " nil t)
5007 (if (numberp (setq chars (ignore-errors (read cur))))
5013 (if (search-forward "\nlines: " nil t)
5014 (if (numberp (setq lines (ignore-errors (read cur))))
5020 (and (search-forward "\nxref: " nil t)
5021 (nnheader-header-value)))
5023 (when gnus-extra-headers
5024 (let ((extra gnus-extra-headers)
5028 (when (search-forward
5029 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5030 (push (cons (car extra) (nnheader-header-value)) out))
5034 (if (and (search-forward "\ncontent-type: " nil t)
5035 (setq ctype (nnheader-header-value)))
5036 (mime-entity-set-content-type-internal
5037 header (mime-parse-Content-Type ctype)))
5038 (when (equal id ref)
5041 (when gnus-alter-header-function
5042 (funcall gnus-alter-header-function header)
5043 (setq id (mail-header-id header)
5044 ref (gnus-parent-id (mail-header-references header))))
5047 (gnus-dependencies-add-header
5048 header dependencies force-new))
5049 (push header headers))
5050 (goto-char (point-max))
5052 (nreverse headers)))))
5054 ;; Goes through the xover lines and returns a list of vectors
5055 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5056 force-new dependencies
5057 group also-fetch-heads)
5058 "Parse the news overview data in the server buffer.
5059 Return a list of headers that match SEQUENCE (see
5060 `nntp-retrieve-headers')."
5061 ;; Get the Xref when the users reads the articles since most/some
5062 ;; NNTP servers do not include Xrefs when using XOVER.
5063 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5064 (let ((mail-parse-charset gnus-newsgroup-charset)
5065 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5066 (cur nntp-server-buffer)
5067 (dependencies (or dependencies gnus-newsgroup-dependencies))
5068 number headers header)
5070 (set-buffer nntp-server-buffer)
5071 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5072 ;; Allow the user to mangle the headers before parsing them.
5073 (gnus-run-hooks 'gnus-parse-headers-hook)
5074 (goto-char (point-min))
5077 (while (and sequence (not (eobp)))
5078 (setq number (read cur))
5079 (while (and sequence
5080 (< (car sequence) number))
5081 (setq sequence (cdr sequence)))
5083 (eq number (car sequence))
5085 (setq sequence (cdr sequence))
5086 (setq header (inline
5087 (gnus-nov-parse-line
5088 number dependencies force-new))))
5089 (push header headers))
5092 (gnus-error 4 "Strange nov line (%d)"
5093 (count-lines (point-min) (point)))))
5095 ;; A common bug in inn is that if you have posted an article and
5096 ;; then retrieves the active file, it will answer correctly --
5097 ;; the new article is included. However, a NOV entry for the
5098 ;; article may not have been generated yet, so this may fail.
5099 ;; We work around this problem by retrieving the last few
5100 ;; headers using HEAD.
5101 (if (or (not also-fetch-heads)
5103 ;; We (probably) got all the headers.
5105 (let ((gnus-nov-is-evil t))
5108 (gnus-retrieve-parsed-headers sequence group)
5111 (defun gnus-article-get-xrefs ()
5112 "Fill in the Xref value in `gnus-current-headers', if necessary.
5113 This is meant to be called in `gnus-article-internal-prepare-hook'."
5114 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5115 gnus-current-headers)))
5116 (or (not gnus-use-cross-reference)
5118 (and (mail-header-xref headers)
5119 (not (string= (mail-header-xref headers) "")))
5120 (let ((case-fold-search t)
5123 (nnheader-narrow-to-headers)
5124 (goto-char (point-min))
5125 (when (or (and (not (eobp))
5126 (eq (downcase (char-after)) ?x)
5127 (looking-at "Xref:"))
5128 (search-forward "\nXref:" nil t))
5129 (goto-char (1+ (match-end 0)))
5130 (setq xref (buffer-substring (point)
5131 (progn (end-of-line) (point))))
5132 (mail-header-set-xref headers xref)))))))
5134 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5135 "Find article ID and insert the summary line for that article.
5136 OLD-HEADER can either be a header or a line number to insert
5137 the subject line on."
5138 (let* ((line (and (numberp old-header) old-header))
5139 (old-header (and (vectorp old-header) old-header))
5140 (header (cond ((and old-header use-old-header)
5143 (gnus-number-to-header id))
5144 (gnus-number-to-header id))
5146 (gnus-read-header id))))
5147 (number (and (numberp id) id))
5150 ;; Rebuild the thread that this article is part of and go to the
5151 ;; article we have fetched.
5152 (when (and (not gnus-show-threads)
5155 (setq d (gnus-data-find (mail-header-number old-header))))
5156 (goto-char (gnus-data-pos d))
5159 (- (gnus-point-at-bol)
5161 (1+ (gnus-point-at-eol))
5162 (gnus-delete-line))))))
5164 (mail-header-set-number header (mail-header-number old-header)))
5165 (setq gnus-newsgroup-sparse
5166 (delq (setq number (mail-header-number header))
5167 gnus-newsgroup-sparse))
5168 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5169 (push number gnus-newsgroup-limit)
5170 (gnus-rebuild-thread (mail-header-id header) line)
5171 (gnus-summary-goto-subject number nil t))
5172 (when (and (numberp number)
5174 ;; We have to update the boundaries even if we can't fetch the
5175 ;; article if ID is a number -- so that the next `P' or `N'
5176 ;; command will fetch the previous (or next) article even
5177 ;; if the one we tried to fetch this time has been canceled.
5178 (when (> number gnus-newsgroup-end)
5179 (setq gnus-newsgroup-end number))
5180 (when (< number gnus-newsgroup-begin)
5181 (setq gnus-newsgroup-begin number))
5182 (setq gnus-newsgroup-unselected
5183 (delq number gnus-newsgroup-unselected)))
5184 ;; Report back a success?
5185 (and header (mail-header-number header))))
5187 ;;; Process/prefix in the summary buffer
5189 (defun gnus-summary-work-articles (n)
5190 "Return a list of articles to be worked upon.
5191 The prefix argument, the list of process marked articles, and the
5192 current article will be taken into consideration."
5194 (set-buffer gnus-summary-buffer)
5197 ;; A numerical prefix has been given.
5198 (setq n (prefix-numeric-value n))
5199 (let ((backward (< n 0))
5200 (n (abs (prefix-numeric-value n)))
5205 (push (setq article (gnus-summary-article-number))
5208 (gnus-summary-find-prev nil article)
5209 (gnus-summary-find-next nil article)))
5211 (nreverse articles)))
5212 ((and (gnus-region-active-p) (mark))
5213 (message "region active")
5214 ;; Work on the region between point and mark.
5215 (let ((max (max (point) (mark)))
5218 (goto-char (min (point) (mark)))
5221 (push (setq article (gnus-summary-article-number)) articles)
5222 (gnus-summary-find-next nil article)
5224 (nreverse articles))))
5225 (gnus-newsgroup-processable
5226 ;; There are process-marked articles present.
5227 ;; Save current state.
5228 (gnus-summary-save-process-mark)
5230 (reverse gnus-newsgroup-processable))
5232 ;; Just return the current article.
5233 (list (gnus-summary-article-number))))))
5235 (defmacro gnus-summary-iterate (arg &rest forms)
5236 "Iterate over the process/prefixed articles and do FORMS.
5237 ARG is the interactive prefix given to the command. FORMS will be
5238 executed with point over the summary line of the articles."
5239 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5240 `(let ((,articles (gnus-summary-work-articles ,arg)))
5242 (gnus-summary-goto-subject (car ,articles))
5246 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5247 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5249 (defun gnus-summary-save-process-mark ()
5250 "Push the current set of process marked articles on the stack."
5252 (push (copy-sequence gnus-newsgroup-processable)
5253 gnus-newsgroup-process-stack))
5255 (defun gnus-summary-kill-process-mark ()
5256 "Push the current set of process marked articles on the stack and unmark."
5258 (gnus-summary-save-process-mark)
5259 (gnus-summary-unmark-all-processable))
5261 (defun gnus-summary-yank-process-mark ()
5262 "Pop the last process mark state off the stack and restore it."
5264 (unless gnus-newsgroup-process-stack
5265 (error "Empty mark stack"))
5266 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5268 (defun gnus-summary-process-mark-set (set)
5269 "Make SET into the current process marked articles."
5270 (gnus-summary-unmark-all-processable)
5272 (gnus-summary-set-process-mark (pop set))))
5274 ;;; Searching and stuff
5276 (defun gnus-summary-search-group (&optional backward use-level)
5277 "Search for next unread newsgroup.
5278 If optional argument BACKWARD is non-nil, search backward instead."
5280 (set-buffer gnus-group-buffer)
5281 (when (gnus-group-search-forward
5282 backward nil (if use-level (gnus-group-group-level) nil))
5283 (gnus-group-group-name))))
5285 (defun gnus-summary-best-group (&optional exclude-group)
5286 "Find the name of the best unread group.
5287 If EXCLUDE-GROUP, do not go to this group."
5289 (set-buffer gnus-group-buffer)
5291 (gnus-group-best-unread-group exclude-group))))
5293 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5294 (if backward (gnus-summary-find-prev)
5295 (let* ((dummy (gnus-summary-article-intangible-p))
5296 (article (or article (gnus-summary-article-number)))
5297 (arts (gnus-data-find-list article))
5299 (when (and (not dummy)
5300 (or (not gnus-summary-check-current)
5302 (not (gnus-data-unread-p (car arts)))))
5303 (setq arts (cdr arts)))
5308 (when (or (and undownloaded
5309 (eq gnus-undownloaded-mark
5310 (gnus-data-mark (car arts))))
5311 (gnus-data-unread-p (car arts)))
5312 (setq result (car arts)
5314 (setq arts (cdr arts)))
5317 (goto-char (gnus-data-pos result))
5318 (gnus-data-number result)))))
5320 (defun gnus-summary-find-prev (&optional unread article)
5321 (let* ((eobp (eobp))
5322 (article (or article (gnus-summary-article-number)))
5323 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5325 (when (and (not eobp)
5326 (or (not gnus-summary-check-current)
5328 (not (gnus-data-unread-p (car arts)))))
5329 (setq arts (cdr arts)))
5334 (when (gnus-data-unread-p (car arts))
5335 (setq result (car arts)
5337 (setq arts (cdr arts)))
5340 (goto-char (gnus-data-pos result))
5341 (gnus-data-number result))))
5343 (defun gnus-summary-find-subject (subject &optional unread backward article)
5344 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5345 (article (or article (gnus-summary-article-number)))
5346 (articles (gnus-data-list backward))
5347 (arts (gnus-data-find-list article articles))
5349 (when (or (not gnus-summary-check-current)
5351 (not (gnus-data-unread-p (car arts))))
5352 (setq arts (cdr arts)))
5354 (and (or (not unread)
5355 (gnus-data-unread-p (car arts)))
5356 (vectorp (gnus-data-header (car arts)))
5358 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5359 (setq result (car arts)
5361 (setq arts (cdr arts)))
5363 (goto-char (gnus-data-pos result))
5364 (gnus-data-number result))))
5366 (defun gnus-summary-search-forward (&optional unread subject backward)
5367 "Search forward for an article.
5368 If UNREAD, look for unread articles. If SUBJECT, look for
5369 articles with that subject. If BACKWARD, search backward instead."
5370 (cond (subject (gnus-summary-find-subject subject unread backward))
5371 (backward (gnus-summary-find-prev unread))
5372 (t (gnus-summary-find-next unread))))
5374 (defun gnus-recenter (&optional n)
5375 "Center point in window and redisplay frame.
5376 Also do horizontal recentering."
5378 (when (and gnus-auto-center-summary
5379 (not (eq gnus-auto-center-summary 'vertical)))
5380 (gnus-horizontal-recenter))
5383 (defun gnus-summary-recenter ()
5384 "Center point in the summary window.
5385 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5386 displayed, no centering will be performed."
5387 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5388 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5390 (let* ((top (cond ((< (window-height) 4) 0)
5391 ((< (window-height) 7) 1)
5392 (t (if (numberp gnus-auto-center-summary)
5393 gnus-auto-center-summary
5395 (height (1- (window-height)))
5396 (bottom (save-excursion (goto-char (point-max))
5397 (forward-line (- height))
5399 (window (get-buffer-window (current-buffer))))
5400 ;; The user has to want it.
5401 (when gnus-auto-center-summary
5402 (when (get-buffer-window gnus-article-buffer)
5403 ;; Only do recentering when the article buffer is displayed,
5404 ;; Set the window start to either `bottom', which is the biggest
5405 ;; possible valid number, or the second line from the top,
5406 ;; whichever is the least.
5407 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5408 (if (> bottom top-pos)
5409 ;; Keep the second line from the top visible
5410 (set-window-start window top-pos t)
5411 ;; Try to keep the bottom line visible; if it's partially
5412 ;; obscured, either scroll one more line to make it fully
5413 ;; visible, or revert to using TOP-POS.
5415 (goto-char (point-max))
5417 (let ((last-line-start (point)))
5419 (set-window-start window (point) t)
5420 (when (not (pos-visible-in-window-p last-line-start window))
5422 (set-window-start window (min (point) top-pos) t)))))))
5423 ;; Do horizontal recentering while we're at it.
5424 (when (and (get-buffer-window (current-buffer) t)
5425 (not (eq gnus-auto-center-summary 'vertical)))
5426 (let ((selected (selected-window)))
5427 (select-window (get-buffer-window (current-buffer) t))
5428 (gnus-summary-position-point)
5429 (gnus-horizontal-recenter)
5430 (select-window selected))))))
5432 (defun gnus-summary-jump-to-group (newsgroup)
5433 "Move point to NEWSGROUP in group mode buffer."
5434 ;; Keep update point of group mode buffer if visible.
5435 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5436 (save-window-excursion
5437 ;; Take care of tree window mode.
5438 (when (get-buffer-window gnus-group-buffer)
5439 (pop-to-buffer gnus-group-buffer))
5440 (gnus-group-jump-to-group newsgroup))
5442 ;; Take care of tree window mode.
5443 (if (get-buffer-window gnus-group-buffer)
5444 (pop-to-buffer gnus-group-buffer)
5445 (set-buffer gnus-group-buffer))
5446 (gnus-group-jump-to-group newsgroup))))
5448 ;; This function returns a list of article numbers based on the
5449 ;; difference between the ranges of read articles in this group and
5450 ;; the range of active articles.
5451 (defun gnus-list-of-unread-articles (group)
5452 (let* ((read (gnus-info-read (gnus-get-info group)))
5453 (active (or (gnus-active group) (gnus-activate-group group)))
5456 ;; If none are read, then all are unread.
5458 (setq first (car active))
5459 ;; If the range of read articles is a single range, then the
5460 ;; first unread article is the article after the last read
5461 ;; article. Sounds logical, doesn't it?
5462 (if (and (not (listp (cdr read)))
5463 (or (< (car read) (car active))
5464 (progn (setq read (list read))
5466 (setq first (max (car active) (1+ (cdr read))))
5467 ;; `read' is a list of ranges.
5468 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5471 (setq first (car active)))
5474 (while (< first nlast)
5476 (setq first (1+ first))))
5477 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5478 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5479 (setq read (cdr read)))))
5480 ;; And add the last unread articles.
5481 (while (<= first last)
5483 (setq first (1+ first)))
5484 ;; Return the list of unread articles.
5485 (delq 0 (nreverse unread))))
5487 (defun gnus-list-of-read-articles (group)
5488 "Return a list of unread, unticked and non-dormant articles."
5489 (let* ((info (gnus-get-info group))
5490 (marked (gnus-info-marks info))
5491 (active (gnus-active group)))
5493 (gnus-set-difference
5494 (gnus-sorted-complement
5495 (gnus-uncompress-range active)
5496 (gnus-list-of-unread-articles group))
5498 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5499 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5501 ;; Various summary commands
5503 (defun gnus-summary-select-article-buffer ()
5504 "Reconfigure windows to show article buffer."
5506 (if (not (gnus-buffer-live-p gnus-article-buffer))
5507 (error "There is no article buffer for this summary buffer")
5508 (gnus-configure-windows 'article)
5509 (select-window (get-buffer-window gnus-article-buffer))))
5511 (defun gnus-summary-universal-argument (arg)
5512 "Perform any operation on all articles that are process/prefixed."
5514 (let ((articles (gnus-summary-work-articles arg))
5521 (substitute-command-keys
5522 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5524 (gnus-error 1 "Undefined key")
5527 (gnus-summary-goto-subject (setq article (pop articles)))
5528 (let (gnus-newsgroup-processable)
5529 (command-execute func))
5530 (gnus-summary-remove-process-mark article)))))
5531 (gnus-summary-position-point))
5533 (defun gnus-summary-toggle-truncation (&optional arg)
5534 "Toggle truncation of summary lines.
5535 With arg, turn line truncation on iff arg is positive."
5537 (setq truncate-lines
5538 (if (null arg) (not truncate-lines)
5539 (> (prefix-numeric-value arg) 0)))
5542 (defun gnus-summary-reselect-current-group (&optional all rescan)
5543 "Exit and then reselect the current newsgroup.
5544 The prefix argument ALL means to select all articles."
5546 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5547 (error "Ephemeral groups can't be reselected"))
5548 (let ((current-subject (gnus-summary-article-number))
5549 (group gnus-newsgroup-name))
5550 (setq gnus-newsgroup-begin nil)
5552 ;; We have to adjust the point of group mode buffer because
5553 ;; point was moved to the next unread newsgroup by exiting.
5554 (gnus-summary-jump-to-group group)
5557 (save-window-excursion
5558 ;; Don't show group contents.
5559 (set-window-start (selected-window) (point-max))
5560 (gnus-group-get-new-news-this-group 1))))
5561 (gnus-group-read-group all t)
5562 (gnus-summary-goto-subject current-subject nil t)))
5564 (defun gnus-summary-rescan-group (&optional all)
5565 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5567 (gnus-summary-reselect-current-group all t))
5569 (defun gnus-summary-update-info (&optional non-destructive)
5571 (let ((group gnus-newsgroup-name))
5573 (when gnus-newsgroup-kill-headers
5574 (setq gnus-newsgroup-killed
5575 (gnus-compress-sequence
5577 (gnus-set-sorted-intersection
5578 (gnus-uncompress-range gnus-newsgroup-killed)
5579 (setq gnus-newsgroup-unselected
5580 (sort gnus-newsgroup-unselected '<)))
5581 (setq gnus-newsgroup-unreads
5582 (sort gnus-newsgroup-unreads '<)))
5584 (unless (listp (cdr gnus-newsgroup-killed))
5585 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5586 (let ((headers gnus-newsgroup-headers))
5587 ;; Set the new ranges of read articles.
5589 (set-buffer gnus-group-buffer)
5590 (gnus-undo-force-boundary))
5591 (gnus-update-read-articles
5592 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5593 ;; Set the current article marks.
5594 (let ((gnus-newsgroup-scored
5595 (if (and (not gnus-save-score)
5596 (not non-destructive))
5598 gnus-newsgroup-scored)))
5600 (gnus-update-marks)))
5601 ;; Do the cross-ref thing.
5602 (when gnus-use-cross-reference
5603 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5604 ;; Do not switch windows but change the buffer to work.
5605 (set-buffer gnus-group-buffer)
5606 (unless (gnus-ephemeral-group-p group)
5607 (gnus-group-update-group group)))))))
5609 (defun gnus-summary-save-newsrc (&optional force)
5610 "Save the current number of read/marked articles in the dribble buffer.
5611 The dribble buffer will then be saved.
5612 If FORCE (the prefix), also save the .newsrc file(s)."
5614 (gnus-summary-update-info t)
5616 (gnus-save-newsrc-file)
5617 (gnus-dribble-save)))
5619 (defun gnus-summary-exit (&optional temporary)
5620 "Exit reading current newsgroup, and then return to group selection mode.
5621 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5623 (gnus-set-global-variables)
5624 (gnus-kill-save-kill-buffer)
5625 (gnus-async-halt-prefetch)
5626 (let* ((group gnus-newsgroup-name)
5627 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5630 (buf (current-buffer)))
5632 ;; Do adaptive scoring, and possibly save score files.
5633 (when gnus-newsgroup-adaptive
5634 (gnus-score-adaptive))
5635 (when gnus-use-scoring
5637 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5638 ;; If we have several article buffers, we kill them at exit.
5639 (unless gnus-single-article-buffer
5640 (gnus-kill-buffer gnus-original-article-buffer)
5641 (setq gnus-article-current nil))
5642 (when gnus-use-cache
5643 (gnus-cache-possibly-remove-articles)
5644 (gnus-cache-save-buffers))
5645 (gnus-async-prefetch-remove-group group)
5646 (when gnus-suppress-duplicates
5647 (gnus-dup-enter-articles))
5648 (when gnus-use-trees
5649 (gnus-tree-close group))
5650 (when gnus-use-cache
5651 (gnus-cache-write-active))
5652 ;; Remove entries for this group.
5653 (nnmail-purge-split-history (gnus-group-real-name group))
5654 ;; Make all changes in this group permanent.
5656 (gnus-run-hooks 'gnus-exit-group-hook)
5657 (gnus-summary-update-info))
5658 (gnus-close-group group)
5659 ;; Make sure where we were, and go to next newsgroup.
5660 (set-buffer gnus-group-buffer)
5662 (gnus-group-jump-to-group group))
5663 (gnus-run-hooks 'gnus-summary-exit-hook)
5664 (unless (or quit-config
5665 ;; If this group has disappeared from the summary
5666 ;; buffer, don't skip forwards.
5667 (not (string= group (gnus-group-group-name))))
5668 (gnus-group-next-unread-group 1))
5669 (setq group-point (point))
5672 ;; If we have several article buffers, we kill them at exit.
5673 (unless gnus-single-article-buffer
5674 (gnus-kill-buffer gnus-article-buffer)
5675 (gnus-kill-buffer gnus-original-article-buffer)
5676 (setq gnus-article-current nil))
5678 (if (not gnus-kill-summary-on-exit)
5679 (gnus-deaden-summary)
5680 ;; We set all buffer-local variables to nil. It is unclear why
5681 ;; this is needed, but if we don't, buffer-local variables are
5682 ;; not garbage-collected, it seems. This would the lead to en
5683 ;; ever-growing Emacs.
5684 (gnus-summary-clear-local-variables)
5685 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5686 (gnus-summary-clear-local-variables))
5687 (when (get-buffer gnus-article-buffer)
5688 (bury-buffer gnus-article-buffer))
5689 ;; We clear the global counterparts of the buffer-local
5690 ;; variables as well, just to be on the safe side.
5691 (set-buffer gnus-group-buffer)
5692 (gnus-summary-clear-local-variables)
5693 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5694 (gnus-summary-clear-local-variables))
5695 ;; Return to group mode buffer.
5696 (when (eq mode 'gnus-summary-mode)
5697 (gnus-kill-buffer buf)))
5698 (setq gnus-current-select-method gnus-select-method)
5699 (pop-to-buffer gnus-group-buffer)
5700 (if (not quit-config)
5702 (goto-char group-point)
5703 (gnus-configure-windows 'group 'force)
5704 (unless (pos-visible-in-window-p)
5705 (forward-line (/ (static-if (featurep 'xemacs)
5706 (window-displayed-height)
5707 (1- (window-height)))
5709 (set-window-start (selected-window) (point))
5710 (goto-char group-point)))
5711 (gnus-handle-ephemeral-exit quit-config))
5712 ;; Clear the current group name.
5714 (setq gnus-newsgroup-name nil)))))
5716 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5717 (defun gnus-summary-exit-no-update (&optional no-questions)
5718 "Quit reading current newsgroup without updating read article info."
5720 (let* ((group gnus-newsgroup-name)
5721 (quit-config (gnus-group-quit-config group)))
5722 (when (or no-questions
5724 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5725 (gnus-async-halt-prefetch)
5727 (delq 'gnus-summary-expire-articles
5728 (copy-sequence gnus-summary-prepare-exit-hook)))
5729 ;; If we have several article buffers, we kill them at exit.
5730 (unless gnus-single-article-buffer
5731 (gnus-kill-buffer gnus-article-buffer)
5732 (gnus-kill-buffer gnus-original-article-buffer)
5733 (setq gnus-article-current nil))
5734 (if (not gnus-kill-summary-on-exit)
5735 (gnus-deaden-summary)
5736 (gnus-close-group group)
5737 (gnus-summary-clear-local-variables)
5738 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5739 (gnus-summary-clear-local-variables))
5740 (set-buffer gnus-group-buffer)
5741 (gnus-summary-clear-local-variables)
5742 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5743 (gnus-summary-clear-local-variables))
5744 (when (get-buffer gnus-summary-buffer)
5745 (kill-buffer gnus-summary-buffer)))
5746 (unless gnus-single-article-buffer
5747 (setq gnus-article-current nil))
5748 (when gnus-use-trees
5749 (gnus-tree-close group))
5750 (gnus-async-prefetch-remove-group group)
5751 (when (get-buffer gnus-article-buffer)
5752 (bury-buffer gnus-article-buffer))
5753 ;; Return to the group buffer.
5754 (gnus-configure-windows 'group 'force)
5755 ;; Clear the current group name.
5756 (setq gnus-newsgroup-name nil)
5757 (when (equal (gnus-group-group-name) group)
5758 (gnus-group-next-unread-group 1))
5760 (gnus-handle-ephemeral-exit quit-config)))))
5762 (defun gnus-handle-ephemeral-exit (quit-config)
5763 "Handle movement when leaving an ephemeral group.
5764 The state which existed when entering the ephemeral is reset."
5765 (if (not (buffer-name (car quit-config)))
5766 (gnus-configure-windows 'group 'force)
5767 (set-buffer (car quit-config))
5768 (cond ((eq major-mode 'gnus-summary-mode)
5769 (gnus-set-global-variables))
5770 ((eq major-mode 'gnus-article-mode)
5772 ;; The `gnus-summary-buffer' variable may point
5773 ;; to the old summary buffer when using a single
5775 (unless (gnus-buffer-live-p gnus-summary-buffer)
5776 (set-buffer gnus-group-buffer))
5777 (set-buffer gnus-summary-buffer)
5778 (gnus-set-global-variables))))
5779 (if (or (eq (cdr quit-config) 'article)
5780 (eq (cdr quit-config) 'pick))
5782 ;; The current article may be from the ephemeral group
5783 ;; thus it is best that we reload this article
5784 (gnus-summary-show-article)
5785 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5786 (gnus-configure-windows 'pick 'force)
5787 (gnus-configure-windows (cdr quit-config) 'force)))
5788 (gnus-configure-windows (cdr quit-config) 'force))
5789 (when (eq major-mode 'gnus-summary-mode)
5790 (gnus-summary-next-subject 1 nil t)
5791 (gnus-summary-recenter)
5792 (gnus-summary-position-point))))
5794 (defun gnus-summary-preview-mime-message ()
5795 "MIME decode and play this message."
5797 (let ((gnus-break-pages nil)
5799 (gnus-summary-select-article gnus-show-all-headers t))
5800 (select-window (get-buffer-window gnus-article-buffer)))
5804 (defvar gnus-dead-summary-mode-map nil)
5806 (unless gnus-dead-summary-mode-map
5807 (setq gnus-dead-summary-mode-map (make-keymap))
5808 (suppress-keymap gnus-dead-summary-mode-map)
5809 (substitute-key-definition
5810 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5811 (let ((keys '("\C-d" "\r" "\177" [delete])))
5813 (define-key gnus-dead-summary-mode-map
5814 (pop keys) 'gnus-summary-wake-up-the-dead))))
5816 (defvar gnus-dead-summary-mode nil
5817 "Minor mode for Gnus summary buffers.")
5819 (defun gnus-dead-summary-mode (&optional arg)
5820 "Minor mode for Gnus summary buffers."
5822 (when (eq major-mode 'gnus-summary-mode)
5823 (make-local-variable 'gnus-dead-summary-mode)
5824 (setq gnus-dead-summary-mode
5825 (if (null arg) (not gnus-dead-summary-mode)
5826 (> (prefix-numeric-value arg) 0)))
5827 (when gnus-dead-summary-mode
5828 (gnus-add-minor-mode
5829 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5831 (defun gnus-deaden-summary ()
5832 "Make the current summary buffer into a dead summary buffer."
5833 ;; Kill any previous dead summary buffer.
5834 (when (and gnus-dead-summary
5835 (buffer-name gnus-dead-summary))
5837 (set-buffer gnus-dead-summary)
5838 (when gnus-dead-summary-mode
5839 (kill-buffer (current-buffer)))))
5840 ;; Make this the current dead summary.
5841 (setq gnus-dead-summary (current-buffer))
5842 (gnus-dead-summary-mode 1)
5843 (let ((name (buffer-name)))
5844 (when (string-match "Summary" name)
5846 (concat (substring name 0 (match-beginning 0)) "Dead "
5847 (substring name (match-beginning 0)))
5851 (defun gnus-kill-or-deaden-summary (buffer)
5852 "Kill or deaden the summary BUFFER."
5854 (when (and (buffer-name buffer)
5855 (not gnus-single-article-buffer))
5858 (gnus-kill-buffer gnus-article-buffer)
5859 (gnus-kill-buffer gnus-original-article-buffer)))
5860 (cond (gnus-kill-summary-on-exit
5861 (when (and gnus-use-trees
5862 (gnus-buffer-exists-p buffer))
5865 (gnus-tree-close gnus-newsgroup-name)))
5866 (gnus-kill-buffer buffer))
5867 ((gnus-buffer-exists-p buffer)
5870 (gnus-deaden-summary))))))
5872 (defun gnus-summary-wake-up-the-dead (&rest args)
5873 "Wake up the dead summary buffer."
5875 (gnus-dead-summary-mode -1)
5876 (let ((name (buffer-name)))
5877 (when (string-match "Dead " name)
5879 (concat (substring name 0 (match-beginning 0))
5880 (substring name (match-end 0)))
5882 (gnus-message 3 "This dead summary is now alive again"))
5884 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5885 (defun gnus-summary-fetch-faq (&optional faq-dir)
5886 "Fetch the FAQ for the current group.
5887 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5891 (when current-prefix-arg
5893 "Faq dir: " (and (listp gnus-group-faq-directory)
5894 (mapcar (lambda (file) (list file))
5895 gnus-group-faq-directory))))))
5896 (let (gnus-faq-buffer)
5897 (when (setq gnus-faq-buffer
5898 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5899 (gnus-configure-windows 'summary-faq))))
5901 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5902 (defun gnus-summary-describe-group (&optional force)
5903 "Describe the current newsgroup."
5905 (gnus-group-describe-group force gnus-newsgroup-name))
5907 (defun gnus-summary-describe-briefly ()
5908 "Describe summary mode commands briefly."
5910 (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")))
5912 ;; Walking around group mode buffer from summary mode.
5914 (defun gnus-summary-next-group (&optional no-article target-group backward)
5915 "Exit current newsgroup and then select next unread newsgroup.
5916 If prefix argument NO-ARTICLE is non-nil, no article is selected
5917 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5918 previous group instead."
5920 ;; Stop pre-fetching.
5921 (gnus-async-halt-prefetch)
5922 (let ((current-group gnus-newsgroup-name)
5923 (current-buffer (current-buffer))
5925 ;; First we semi-exit this group to update Xrefs and all variables.
5926 ;; We can't do a real exit, because the window conf must remain
5927 ;; the same in case the user is prompted for info, and we don't
5928 ;; want the window conf to change before that...
5929 (gnus-summary-exit t)
5930 (while (not entered)
5931 ;; Then we find what group we are supposed to enter.
5932 (set-buffer gnus-group-buffer)
5933 (gnus-group-jump-to-group current-group)
5936 (if (eq gnus-keep-same-level 'best)
5937 (gnus-summary-best-group gnus-newsgroup-name)
5938 (gnus-summary-search-group backward gnus-keep-same-level))))
5939 (if (not target-group)
5940 ;; There are no further groups, so we return to the group
5943 (gnus-message 5 "Returning to the group buffer")
5945 (when (gnus-buffer-live-p current-buffer)
5946 (set-buffer current-buffer)
5947 (gnus-summary-exit))
5948 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5949 ;; We try to enter the target group.
5950 (gnus-group-jump-to-group target-group)
5951 (let ((unreads (gnus-group-group-unread)))
5952 (if (and (or (eq t unreads)
5953 (and unreads (not (zerop unreads))))
5954 (gnus-summary-read-group
5955 target-group nil no-article
5956 (and (buffer-name current-buffer) current-buffer)
5959 (setq current-group target-group
5960 target-group nil)))))))
5962 (defun gnus-summary-prev-group (&optional no-article)
5963 "Exit current newsgroup and then select previous unread newsgroup.
5964 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5966 (gnus-summary-next-group no-article nil t))
5968 ;; Walking around summary lines.
5970 (defun gnus-summary-first-subject (&optional unread undownloaded)
5971 "Go to the first unread subject.
5972 If UNREAD is non-nil, go to the first unread article.
5973 Returns the article selected or nil if there are no unread articles."
5978 ((null gnus-newsgroup-data)
5979 (gnus-message 3 "No articles in the group")
5981 ;; Pick the first article.
5983 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5984 (gnus-data-number (car gnus-newsgroup-data)))
5985 ;; No unread articles.
5986 ((null gnus-newsgroup-unreads)
5987 (gnus-message 3 "No more unread articles")
5989 ;; Find the first unread article.
5991 (let ((data gnus-newsgroup-data))
5993 (and (not (and undownloaded
5994 (eq gnus-undownloaded-mark
5995 (gnus-data-mark (car data)))))
5996 (not (gnus-data-unread-p (car data)))))
5997 (setq data (cdr data)))
5999 (goto-char (gnus-data-pos (car data)))
6000 (gnus-data-number (car data))))))
6001 (gnus-summary-position-point)))
6003 (defun gnus-summary-next-subject (n &optional unread dont-display)
6004 "Go to next N'th summary line.
6005 If N is negative, go to the previous N'th subject line.
6006 If UNREAD is non-nil, only unread articles are selected.
6007 The difference between N and the actual number of steps taken is
6010 (let ((backward (< n 0))
6014 (gnus-summary-find-prev unread)
6015 (gnus-summary-find-next unread)))
6016 (unless (zerop (setq n (1- n)))
6017 (gnus-summary-show-thread)))
6019 (gnus-message 7 "No more%s articles"
6020 (if unread " unread" "")))
6021 (unless dont-display
6022 (gnus-summary-recenter)
6023 (gnus-summary-position-point))
6026 (defun gnus-summary-next-unread-subject (n)
6027 "Go to next N'th unread summary line."
6029 (gnus-summary-next-subject n t))
6031 (defun gnus-summary-prev-subject (n &optional unread)
6032 "Go to previous N'th summary line.
6033 If optional argument UNREAD is non-nil, only unread article is selected."
6035 (gnus-summary-next-subject (- n) unread))
6037 (defun gnus-summary-prev-unread-subject (n)
6038 "Go to previous N'th unread summary line."
6040 (gnus-summary-next-subject (- n) t))
6042 (defun gnus-summary-goto-subject (article &optional force silent)
6043 "Go the subject line of ARTICLE.
6044 If FORCE, also allow jumping to articles not currently shown."
6045 (interactive "nArticle number: ")
6047 (data (gnus-data-find article)))
6048 ;; We read in the article if we have to.
6051 (gnus-summary-insert-subject
6053 (if (or (numberp force) (vectorp force)) force)
6055 (setq data (gnus-data-find article)))
6060 (gnus-message 3 "Can't find article %d" article))
6062 (goto-char (gnus-data-pos data))
6063 (gnus-summary-position-point)
6066 ;; Walking around summary lines with displaying articles.
6068 (defun gnus-summary-expand-window (&optional arg)
6069 "Make the summary buffer take up the entire Emacs frame.
6070 Given a prefix, will force an `article' buffer configuration."
6073 (gnus-configure-windows 'article 'force)
6074 (gnus-configure-windows 'summary 'force)))
6076 (defun gnus-summary-display-article (article &optional all-header)
6077 "Display ARTICLE in article buffer."
6078 (when (gnus-buffer-live-p gnus-article-buffer)
6079 (with-current-buffer gnus-article-buffer
6080 (set-buffer-multibyte t)))
6081 (gnus-set-global-variables)
6082 (when (gnus-buffer-live-p gnus-article-buffer)
6083 (with-current-buffer gnus-article-buffer
6084 (setq gnus-article-charset gnus-newsgroup-charset)
6085 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6089 (if gnus-summary-display-article-function
6090 (funcall gnus-summary-display-article-function article all-header)
6091 (gnus-article-prepare article all-header))
6092 (with-current-buffer gnus-article-buffer
6093 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6095 (gnus-run-hooks 'gnus-select-article-hook)
6096 (when (and gnus-current-article
6097 (not (zerop gnus-current-article)))
6098 (gnus-summary-goto-subject gnus-current-article))
6099 (gnus-summary-recenter)
6100 (when (and gnus-use-trees gnus-show-threads)
6101 (gnus-possibly-generate-tree article)
6102 (gnus-highlight-selected-tree article))
6103 ;; Successfully display article.
6104 (gnus-article-set-window-start
6105 (cdr (assq article gnus-newsgroup-bookmarks))))))
6107 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6108 "Select the current article.
6109 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6110 non-nil, the article will be re-fetched even if it already present in
6111 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6113 ;; Make sure we are in the summary buffer to work around bbdb bug.
6114 (unless (eq major-mode 'gnus-summary-mode)
6115 (set-buffer gnus-summary-buffer))
6116 (let ((article (or article (gnus-summary-article-number)))
6117 (all-headers (not (not all-headers))) ;Must be T or NIL.
6118 gnus-summary-display-article-function)
6120 (gnus-summary-article-pseudo-p article)
6121 (error "This is a pseudo-article"))
6123 (set-buffer gnus-summary-buffer)
6124 (if (or (and gnus-single-article-buffer
6125 (or (null gnus-current-article)
6126 (null gnus-article-current)
6127 (null (get-buffer gnus-article-buffer))
6128 (not (eq article (cdr gnus-article-current)))
6129 (not (equal (car gnus-article-current)
6130 gnus-newsgroup-name))))
6131 (and (not gnus-single-article-buffer)
6132 (or (null gnus-current-article)
6133 (not (eq gnus-current-article article))))
6135 ;; The requested article is different from the current article.
6137 (gnus-summary-display-article article all-headers)
6138 (when (or all-headers gnus-show-all-headers)
6139 (gnus-article-show-all-headers))
6140 (gnus-article-set-window-start
6141 (cdr (assq article gnus-newsgroup-bookmarks)))
6143 (when (or all-headers gnus-show-all-headers)
6144 (gnus-article-show-all-headers))
6147 (defun gnus-summary-force-verify-and-decrypt ()
6149 (let ((mm-verify-option 'known)
6150 (mm-decrypt-option 'known))
6151 (gnus-summary-select-article nil 'force)))
6153 (defun gnus-summary-set-current-mark (&optional current-mark)
6154 "Obsolete function."
6157 (defun gnus-summary-next-article (&optional unread subject backward push)
6158 "Select the next article.
6159 If UNREAD, only unread articles are selected.
6160 If SUBJECT, only articles with SUBJECT are selected.
6161 If BACKWARD, the previous article is selected instead of the next."
6164 ;; Is there such an article?
6165 ((and (gnus-summary-search-forward unread subject backward)
6166 (or (gnus-summary-display-article (gnus-summary-article-number))
6167 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6168 (gnus-summary-position-point))
6169 ;; If not, we try the first unread, if that is wanted.
6171 gnus-auto-select-same
6172 (gnus-summary-first-unread-article))
6173 (gnus-summary-position-point)
6174 (gnus-message 6 "Wrapped"))
6175 ;; Try to get next/previous article not displayed in this group.
6176 ((and gnus-auto-extend-newsgroup
6177 (not unread) (not subject))
6178 (gnus-summary-goto-article
6179 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6180 nil (count-lines (point-min) (point))))
6181 ;; Go to next/previous group.
6183 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6184 (gnus-summary-jump-to-group gnus-newsgroup-name))
6185 (let ((cmd last-command-char)
6188 (set-buffer gnus-group-buffer)
6191 (if (eq gnus-keep-same-level 'best)
6192 (gnus-summary-best-group gnus-newsgroup-name)
6193 (gnus-summary-search-group backward gnus-keep-same-level))))
6194 ;; For some reason, the group window gets selected. We change
6196 (select-window (get-buffer-window (current-buffer)))
6197 ;; Select next unread newsgroup automagically.
6199 ((or (not gnus-auto-select-next)
6201 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6202 ((or (eq gnus-auto-select-next 'quietly)
6203 (and (eq gnus-auto-select-next 'slightly-quietly)
6205 (and (eq gnus-auto-select-next 'almost-quietly)
6206 (gnus-summary-last-article-p)))
6208 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6210 (gnus-message 7 "No more%s articles (%s)..."
6211 (if unread " unread" "")
6212 (if group (concat "selecting " group)
6214 (gnus-summary-next-group nil group backward)))
6216 (when (gnus-key-press-event-p last-input-event)
6217 (gnus-summary-walk-group-buffer
6218 gnus-newsgroup-name cmd unread backward point))))))))
6220 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6221 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6222 (?\C-p (gnus-group-prev-unread-group 1))))
6223 (cursor-in-echo-area t)
6224 keve key group ended)
6226 (set-buffer gnus-group-buffer)
6229 (if (eq gnus-keep-same-level 'best)
6230 (gnus-summary-best-group gnus-newsgroup-name)
6231 (gnus-summary-search-group backward gnus-keep-same-level))))
6234 5 "No more%s articles%s" (if unread " unread" "")
6236 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6237 (format " (Type %s for %s [%s])"
6238 (single-key-description cmd) group
6239 (car (gnus-gethash group gnus-newsrc-hashtb)))
6240 (format " (Type %s to exit %s)"
6241 (single-key-description cmd)
6242 gnus-newsgroup-name)))
6243 ;; Confirm auto selection.
6244 (setq key (car (setq keve (gnus-read-event-char))))
6247 ((assq key keystrokes)
6248 (let ((obuf (current-buffer)))
6249 (switch-to-buffer gnus-group-buffer)
6251 (gnus-group-jump-to-group group))
6252 (eval (cadr (assq key keystrokes)))
6253 (setq group (gnus-group-group-name))
6254 (switch-to-buffer obuf))
6258 (gnus-ephemeral-group-p gnus-newsgroup-name))
6260 (gnus-summary-next-group nil group backward)))
6262 (push (cdr keve) unread-command-events))))))
6264 (defun gnus-summary-next-unread-article ()
6265 "Select unread article after current one."
6267 (gnus-summary-next-article
6268 (or (not (eq gnus-summary-goto-unread 'never))
6269 (gnus-summary-last-article-p (gnus-summary-article-number)))
6270 (and gnus-auto-select-same
6271 (gnus-summary-article-subject))))
6273 (defun gnus-summary-prev-article (&optional unread subject)
6274 "Select the article after the current one.
6275 If UNREAD is non-nil, only unread articles are selected."
6277 (gnus-summary-next-article unread subject t))
6279 (defun gnus-summary-prev-unread-article ()
6280 "Select unread article before current one."
6282 (gnus-summary-prev-article
6283 (or (not (eq gnus-summary-goto-unread 'never))
6284 (gnus-summary-first-article-p (gnus-summary-article-number)))
6285 (and gnus-auto-select-same
6286 (gnus-summary-article-subject))))
6288 (defun gnus-summary-next-page (&optional lines circular)
6289 "Show next page of the selected article.
6290 If at the end of the current article, select the next article.
6291 LINES says how many lines should be scrolled up.
6293 If CIRCULAR is non-nil, go to the start of the article instead of
6294 selecting the next article when reaching the end of the current
6297 (setq gnus-summary-buffer (current-buffer))
6298 (gnus-set-global-variables)
6299 (let ((article (gnus-summary-article-number))
6300 (article-window (get-buffer-window gnus-article-buffer t))
6302 ;; If the buffer is empty, we have no article.
6304 (error "No article to select"))
6305 (gnus-configure-windows 'article)
6306 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6307 (if (and (eq gnus-summary-goto-unread 'never)
6308 (not (gnus-summary-last-article-p article)))
6309 (gnus-summary-next-article)
6310 (gnus-summary-next-unread-article))
6311 (if (or (null gnus-current-article)
6312 (null gnus-article-current)
6313 (/= article (cdr gnus-article-current))
6314 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6315 ;; Selected subject is different from current article's.
6316 (gnus-summary-display-article article)
6317 (when article-window
6318 (gnus-eval-in-buffer-window gnus-article-buffer
6319 (setq endp (gnus-article-next-page lines)))
6322 (gnus-summary-beginning-of-article))
6324 (gnus-message 3 "End of message"))
6326 (if (and (eq gnus-summary-goto-unread 'never)
6327 (not (gnus-summary-last-article-p article)))
6328 (gnus-summary-next-article)
6329 (gnus-summary-next-unread-article))))))))
6330 (gnus-summary-recenter)
6331 (gnus-summary-position-point)))
6333 (defun gnus-summary-prev-page (&optional lines move)
6334 "Show previous page of selected article.
6335 Argument LINES specifies lines to be scrolled down.
6336 If MOVE, move to the previous unread article if point is at
6337 the beginning of the buffer."
6339 (let ((article (gnus-summary-article-number))
6340 (article-window (get-buffer-window gnus-article-buffer t))
6342 (gnus-configure-windows 'article)
6343 (if (or (null gnus-current-article)
6344 (null gnus-article-current)
6345 (/= article (cdr gnus-article-current))
6346 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6347 ;; Selected subject is different from current article's.
6348 (gnus-summary-display-article article)
6349 (gnus-summary-recenter)
6350 (when article-window
6351 (gnus-eval-in-buffer-window gnus-article-buffer
6352 (setq endp (gnus-article-prev-page lines)))
6353 (when (and move endp)
6355 (gnus-message 3 "Beginning of message"))
6357 (if (and (eq gnus-summary-goto-unread 'never)
6358 (not (gnus-summary-first-article-p article)))
6359 (gnus-summary-prev-article)
6360 (gnus-summary-prev-unread-article))))))))
6361 (gnus-summary-position-point))
6363 (defun gnus-summary-prev-page-or-article (&optional lines)
6364 "Show previous page of selected article.
6365 Argument LINES specifies lines to be scrolled down.
6366 If at the beginning of the article, go to the next article."
6368 (gnus-summary-prev-page lines t))
6370 (defun gnus-summary-scroll-up (lines)
6371 "Scroll up (or down) one line current article.
6372 Argument LINES specifies lines to be scrolled up (or down if negative)."
6374 (gnus-configure-windows 'article)
6375 (gnus-summary-show-thread)
6376 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6377 (gnus-eval-in-buffer-window gnus-article-buffer
6379 (when (gnus-article-next-page lines)
6380 (gnus-message 3 "End of message")))
6382 (gnus-article-prev-page (- lines))))))
6383 (gnus-summary-recenter)
6384 (gnus-summary-position-point))
6386 (defun gnus-summary-scroll-down (lines)
6387 "Scroll down (or up) one line current article.
6388 Argument LINES specifies lines to be scrolled down (or up if negative)."
6390 (gnus-summary-scroll-up (- lines)))
6392 (defun gnus-summary-next-same-subject ()
6393 "Select next article which has the same subject as current one."
6395 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6397 (defun gnus-summary-prev-same-subject ()
6398 "Select previous article which has the same subject as current one."
6400 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6402 (defun gnus-summary-next-unread-same-subject ()
6403 "Select next unread article which has the same subject as current one."
6405 (gnus-summary-next-article t (gnus-summary-article-subject)))
6407 (defun gnus-summary-prev-unread-same-subject ()
6408 "Select previous unread article which has the same subject as current one."
6410 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6412 (defun gnus-summary-first-unread-article ()
6413 "Select the first unread article.
6414 Return nil if there are no unread articles."
6417 (when (gnus-summary-first-subject t)
6418 (gnus-summary-show-thread)
6419 (gnus-summary-first-subject t)
6420 (gnus-summary-display-article (gnus-summary-article-number)))
6421 (gnus-summary-position-point)))
6423 (defun gnus-summary-first-unread-subject ()
6424 "Place the point on the subject line of the first unread article.
6425 Return nil if there are no unread articles."
6428 (when (gnus-summary-first-subject t)
6429 (gnus-summary-show-thread)
6430 (gnus-summary-first-subject t))
6431 (gnus-summary-position-point)))
6433 (defun gnus-summary-first-article ()
6434 "Select the first article.
6435 Return nil if there are no articles."
6438 (when (gnus-summary-first-subject)
6439 (gnus-summary-show-thread)
6440 (gnus-summary-first-subject)
6441 (gnus-summary-display-article (gnus-summary-article-number)))
6442 (gnus-summary-position-point)))
6444 (defun gnus-summary-best-unread-article ()
6445 "Select the unread article with the highest score."
6447 (let ((best -1000000)
6448 (data gnus-newsgroup-data)
6451 (and (gnus-data-unread-p (car data))
6453 (gnus-summary-article-score (gnus-data-number (car data))))
6456 article (gnus-data-number (car data))))
6457 (setq data (cdr data)))
6460 (gnus-summary-goto-article article)
6461 (error "No unread articles"))
6462 (gnus-summary-position-point))))
6464 (defun gnus-summary-last-subject ()
6465 "Go to the last displayed subject line in the group."
6466 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6468 (gnus-summary-goto-subject article))))
6470 (defun gnus-summary-goto-article (article &optional all-headers force)
6471 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6472 If ALL-HEADERS is non-nil, no header lines are hidden.
6473 If FORCE, go to the article even if it isn't displayed. If FORCE
6474 is a number, it is the line the article is to be displayed on."
6478 "Article number or Message-ID: "
6479 (mapcar (lambda (number) (list (int-to-string number)))
6480 gnus-newsgroup-limit))
6484 (if (and (stringp article)
6485 (string-match "@" article))
6486 (gnus-summary-refer-article article)
6487 (when (stringp article)
6488 (setq article (string-to-number article)))
6489 (if (gnus-summary-goto-subject article force)
6490 (gnus-summary-display-article article all-headers)
6491 (gnus-message 4 "Couldn't go to article %s" article) nil))
6492 (gnus-summary-position-point)))
6494 (defun gnus-summary-goto-last-article ()
6495 "Go to the previously read article."
6498 (when gnus-last-article
6499 (gnus-summary-goto-article gnus-last-article nil t))
6500 (gnus-summary-position-point)))
6502 (defun gnus-summary-pop-article (number)
6503 "Pop one article off the history and go to the previous.
6504 NUMBER articles will be popped off."
6507 (setq gnus-newsgroup-history
6508 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6510 (gnus-summary-goto-article (car to) nil t)
6511 (error "Article history empty")))
6512 (gnus-summary-position-point))
6514 ;; Summary commands and functions for limiting the summary buffer.
6516 (defun gnus-summary-limit-to-articles (n)
6517 "Limit the summary buffer to the next N articles.
6518 If not given a prefix, use the process marked articles instead."
6521 (let ((articles (gnus-summary-work-articles n)))
6522 (setq gnus-newsgroup-processable nil)
6523 (gnus-summary-limit articles))
6524 (gnus-summary-position-point)))
6526 (defun gnus-summary-pop-limit (&optional total)
6527 "Restore the previous limit.
6528 If given a prefix, remove all limits."
6531 (setq gnus-newsgroup-limits
6532 (list (mapcar (lambda (h) (mail-header-number h))
6533 gnus-newsgroup-headers))))
6534 (unless gnus-newsgroup-limits
6535 (error "No limit to pop"))
6537 (gnus-summary-limit nil 'pop)
6538 (gnus-summary-position-point)))
6540 (defun gnus-summary-limit-to-subject (subject &optional header)
6541 "Limit the summary buffer to articles that have subjects that match a regexp."
6542 (interactive "sLimit to subject (regexp): ")
6544 (setq header "subject"))
6545 (when (not (equal "" subject))
6547 (let ((articles (gnus-summary-find-matching
6548 (or header "subject") subject 'all)))
6550 (error "Found no matches for \"%s\"" subject))
6551 (gnus-summary-limit articles))
6552 (gnus-summary-position-point))))
6554 (defun gnus-summary-limit-to-author (from)
6555 "Limit the summary buffer to articles that have authors that match a regexp."
6556 (interactive "sLimit to author (regexp): ")
6557 (gnus-summary-limit-to-subject from "from"))
6559 (defun gnus-summary-limit-to-age (age &optional younger-p)
6560 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6561 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6562 articles that are younger than AGE days."
6564 (let ((younger current-prefix-arg)
6567 (while (not days-got)
6568 (setq days (if younger
6569 (read-string "Limit to articles within (in days): ")
6570 (read-string "Limit to articles older than (in days): ")))
6571 (when (> (length days) 0)
6572 (setq days (read days)))
6575 (message "Please enter a number.")
6577 (list days younger)))
6579 (let ((data gnus-newsgroup-data)
6580 (cutoff (days-to-time age))
6581 articles d date is-younger)
6582 (while (setq d (pop data))
6583 (when (and (vectorp (gnus-data-header d))
6584 (setq date (mail-header-date (gnus-data-header d))))
6585 (setq is-younger (time-less-p
6586 (time-since (condition-case ()
6593 (push (gnus-data-number d) articles))))
6594 (gnus-summary-limit (nreverse articles)))
6595 (gnus-summary-position-point)))
6597 (defun gnus-summary-limit-to-extra (header regexp)
6598 "Limit the summary buffer to articles that match an 'extra' header."
6602 (gnus-completing-read
6603 (symbol-name (car gnus-extra-headers))
6604 "Limit extra header:"
6606 (cons (symbol-name x) x))
6611 (read-string (format "Limit to header %s (regexp): " header)))))
6612 (when (not (equal "" regexp))
6614 (let ((articles (gnus-summary-find-matching
6615 (cons 'extra header) regexp 'all)))
6617 (error "Found no matches for \"%s\"" regexp))
6618 (gnus-summary-limit articles))
6619 (gnus-summary-position-point))))
6621 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6623 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6625 (defun gnus-summary-limit-to-unread (&optional all)
6626 "Limit the summary buffer to articles that are not marked as read.
6627 If ALL is non-nil, limit strictly to unread articles."
6630 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6631 (gnus-summary-limit-to-marks
6632 ;; Concat all the marks that say that an article is read and have
6634 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6635 gnus-killed-mark gnus-kill-file-mark
6636 gnus-low-score-mark gnus-expirable-mark
6637 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6638 gnus-duplicate-mark gnus-souped-mark)
6641 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6642 (make-obsolete 'gnus-summary-delete-marked-with
6643 'gnus-summary-limit-exlude-marks)
6645 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6646 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6647 If REVERSE, limit the summary buffer to articles that are marked
6648 with MARKS. MARKS can either be a string of marks or a list of marks.
6649 Returns how many articles were removed."
6650 (interactive "sMarks: ")
6651 (gnus-summary-limit-to-marks marks t))
6653 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6654 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6655 If REVERSE (the prefix), limit the summary buffer to articles that are
6656 not marked with MARKS. MARKS can either be a string of marks or a
6658 Returns how many articles were removed."
6659 (interactive "sMarks: \nP")
6661 (let ((data gnus-newsgroup-data)
6662 (marks (if (listp marks) marks
6663 (append marks nil))) ; Transform to list.
6666 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6667 (memq (gnus-data-mark (car data)) marks))
6668 (push (gnus-data-number (car data)) articles))
6669 (setq data (cdr data)))
6670 (gnus-summary-limit articles))
6671 (gnus-summary-position-point)))
6673 (defun gnus-summary-limit-to-score (&optional score)
6674 "Limit to articles with score at or above SCORE."
6676 (setq score (if score
6677 (prefix-numeric-value score)
6678 (or gnus-summary-default-score 0)))
6679 (let ((data gnus-newsgroup-data)
6682 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6684 (push (gnus-data-number (car data)) articles))
6685 (setq data (cdr data)))
6687 (gnus-summary-limit articles)
6688 (gnus-summary-position-point))))
6690 (defun gnus-summary-limit-include-thread (id)
6691 "Display all the hidden articles that in the current thread."
6692 (interactive (list (mail-header-id (gnus-summary-article-header))))
6693 (let ((articles (gnus-articles-in-thread
6694 (gnus-id-to-thread (gnus-root-id id)))))
6696 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6697 (gnus-summary-position-point))))
6699 (defun gnus-summary-limit-include-dormant ()
6700 "Display all the hidden articles that are marked as dormant.
6701 Note that this command only works on a subset of the articles currently
6702 fetched for this group."
6704 (unless gnus-newsgroup-dormant
6705 (error "There are no dormant articles in this group"))
6707 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6708 (gnus-summary-position-point)))
6710 (defun gnus-summary-limit-exclude-dormant ()
6711 "Hide all dormant articles."
6714 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6715 (gnus-summary-position-point)))
6717 (defun gnus-summary-limit-exclude-childless-dormant ()
6718 "Hide all dormant articles that have no children."
6720 (let ((data (gnus-data-list t))
6721 articles d children)
6722 ;; Find all articles that are either not dormant or have
6724 (while (setq d (pop data))
6725 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6727 (gnus-article-children (gnus-data-number d)))
6730 (when (memq (car children) articles)
6735 (push (gnus-data-number d) articles)))
6738 (gnus-summary-limit articles)
6739 (gnus-summary-position-point))))
6741 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6742 "Mark all unread excluded articles as read.
6743 If ALL, mark even excluded ticked and dormants as read."
6745 (let ((articles (gnus-sorted-complement
6747 (mapcar (lambda (h) (mail-header-number h))
6748 gnus-newsgroup-headers)
6750 (sort gnus-newsgroup-limit '<)))
6752 (setq gnus-newsgroup-unreads
6753 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6755 (setq gnus-newsgroup-dormant nil
6756 gnus-newsgroup-marked nil
6757 gnus-newsgroup-reads
6759 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6760 gnus-newsgroup-reads))
6761 (while (setq article (pop articles))
6762 (unless (or (memq article gnus-newsgroup-dormant)
6763 (memq article gnus-newsgroup-marked))
6764 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6766 (defun gnus-summary-limit (articles &optional pop)
6768 ;; We pop the previous limit off the stack and use that.
6769 (setq articles (car gnus-newsgroup-limits)
6770 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6771 ;; We use the new limit, so we push the old limit on the stack.
6772 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6774 (setq gnus-newsgroup-limit articles)
6775 (let ((total (length gnus-newsgroup-data))
6776 (data (gnus-data-find-list (gnus-summary-article-number)))
6777 (gnus-summary-mark-below nil) ; Inhibit this.
6779 ;; This will do all the work of generating the new summary buffer
6780 ;; according to the new limit.
6781 (gnus-summary-prepare)
6782 ;; Hide any threads, possibly.
6783 (and gnus-show-threads
6784 gnus-thread-hide-subtree
6785 (gnus-summary-hide-all-threads))
6786 ;; Try to return to the article you were at, or one in the
6789 ;; We try to find some article after the current one.
6791 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6794 (setq data (cdr data))))
6796 ;; If there is no data, that means that we were after the last
6797 ;; article. The same goes when we can't find any articles
6798 ;; after the current one.
6799 (goto-char (point-max))
6800 (gnus-summary-find-prev))
6801 (gnus-set-mode-line 'summary)
6802 ;; We return how many articles were removed from the summary
6803 ;; buffer as a result of the new limit.
6804 (- total (length gnus-newsgroup-data))))
6806 (defsubst gnus-invisible-cut-children (threads)
6809 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6814 (defsubst gnus-cut-thread (thread)
6815 "Go forwards in the thread until we find an article that we want to display."
6816 (when (or (eq gnus-fetch-old-headers 'some)
6817 (eq gnus-fetch-old-headers 'invisible)
6818 (numberp gnus-fetch-old-headers)
6819 (eq gnus-build-sparse-threads 'some)
6820 (eq gnus-build-sparse-threads 'more))
6821 ;; Deal with old-fetched headers and sparse threads.
6825 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6826 (gnus-summary-article-ancient-p
6827 (mail-header-number (car thread))))
6828 (if (or (<= (length (cdr thread)) 1)
6829 (eq gnus-fetch-old-headers 'invisible))
6830 (setq gnus-newsgroup-limit
6831 (delq (mail-header-number (car thread))
6832 gnus-newsgroup-limit)
6833 thread (cadr thread))
6834 (when (gnus-invisible-cut-children (cdr thread))
6835 (let ((th (cdr thread)))
6837 (if (memq (mail-header-number (caar th))
6838 gnus-newsgroup-limit)
6839 (setq thread (car th)
6841 (setq th (cdr th))))))))))
6844 (defun gnus-cut-threads (threads)
6845 "Cut off all uninteresting articles from the beginning of threads."
6846 (when (or (eq gnus-fetch-old-headers 'some)
6847 (eq gnus-fetch-old-headers 'invisible)
6848 (numberp gnus-fetch-old-headers)
6849 (eq gnus-build-sparse-threads 'some)
6850 (eq gnus-build-sparse-threads 'more))
6853 (setcar th (gnus-cut-thread (car th)))
6854 (setq th (cdr th)))))
6855 ;; Remove nixed out threads.
6858 (defun gnus-summary-initial-limit (&optional show-if-empty)
6859 "Figure out what the initial limit is supposed to be on group entry.
6860 This entails weeding out unwanted dormants, low-scored articles,
6861 fetch-old-headers verbiage, and so on."
6862 ;; Most groups have nothing to remove.
6863 (if (or gnus-inhibit-limiting
6864 (and (null gnus-newsgroup-dormant)
6865 (not (eq gnus-fetch-old-headers 'some))
6866 (not (numberp gnus-fetch-old-headers))
6867 (not (eq gnus-fetch-old-headers 'invisible))
6868 (null gnus-summary-expunge-below)
6869 (not (eq gnus-build-sparse-threads 'some))
6870 (not (eq gnus-build-sparse-threads 'more))
6871 (null gnus-thread-expunge-below)
6872 (not gnus-use-nocem)))
6874 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6875 (setq gnus-newsgroup-limit nil)
6878 (unless (car (symbol-value node))
6879 ;; These threads have no parents -- they are roots.
6880 (let ((nodes (cdr (symbol-value node)))
6883 (if (and gnus-thread-expunge-below
6884 (< (gnus-thread-total-score (car nodes))
6885 gnus-thread-expunge-below))
6886 (gnus-expunge-thread (pop nodes))
6887 (setq thread (pop nodes))
6888 (gnus-summary-limit-children thread))))))
6889 gnus-newsgroup-dependencies)
6890 ;; If this limitation resulted in an empty group, we might
6891 ;; pop the previous limit and use it instead.
6892 (when (and (not gnus-newsgroup-limit)
6894 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6895 gnus-newsgroup-limit))
6897 (defun gnus-summary-limit-children (thread)
6898 "Return 1 if this subthread is visible and 0 if it is not."
6899 ;; First we get the number of visible children to this thread. This
6900 ;; is done by recursing down the thread using this function, so this
6901 ;; will really go down to a leaf article first, before slowly
6902 ;; working its way up towards the root.
6906 (apply '+ (mapcar 'gnus-summary-limit-children
6909 (number (mail-header-number (car thread)))
6912 (not (memq number gnus-newsgroup-marked))
6914 ;; If this article is dormant and has absolutely no visible
6915 ;; children, then this article isn't visible.
6916 (and (memq number gnus-newsgroup-dormant)
6918 ;; If this is "fetch-old-headered" and there is no
6919 ;; visible children, then we don't want this article.
6920 (and (or (eq gnus-fetch-old-headers 'some)
6921 (numberp gnus-fetch-old-headers))
6922 (gnus-summary-article-ancient-p number)
6924 ;; If this is "fetch-old-headered" and `invisible', then
6925 ;; we don't want this article.
6926 (and (eq gnus-fetch-old-headers 'invisible)
6927 (gnus-summary-article-ancient-p number))
6928 ;; If this is a sparsely inserted article with no children,
6929 ;; we don't want it.
6930 (and (eq gnus-build-sparse-threads 'some)
6931 (gnus-summary-article-sparse-p number)
6933 ;; If we use expunging, and this article is really
6934 ;; low-scored, then we don't want this article.
6935 (when (and gnus-summary-expunge-below
6937 (or (cdr (assq number gnus-newsgroup-scored))
6938 gnus-summary-default-score))
6939 gnus-summary-expunge-below))
6940 ;; We increase the expunge-tally here, but that has
6941 ;; nothing to do with the limits, really.
6942 (incf gnus-newsgroup-expunged-tally)
6943 ;; We also mark as read here, if that's wanted.
6944 (when (and gnus-summary-mark-below
6945 (< score gnus-summary-mark-below))
6946 (setq gnus-newsgroup-unreads
6947 (delq number gnus-newsgroup-unreads))
6948 (if gnus-newsgroup-auto-expire
6949 (push number gnus-newsgroup-expirable)
6950 (push (cons number gnus-low-score-mark)
6951 gnus-newsgroup-reads)))
6953 ;; Check NoCeM things.
6954 (if (and gnus-use-nocem
6955 (gnus-nocem-unwanted-article-p
6956 (mail-header-id (car thread))))
6958 (setq gnus-newsgroup-unreads
6959 (delq number gnus-newsgroup-unreads))
6961 ;; Nope, invisible article.
6963 ;; Ok, this article is to be visible, so we add it to the limit
6965 (push number gnus-newsgroup-limit)
6968 (defun gnus-expunge-thread (thread)
6969 "Mark all articles in THREAD as read."
6970 (let* ((number (mail-header-number (car thread))))
6971 (incf gnus-newsgroup-expunged-tally)
6972 ;; We also mark as read here, if that's wanted.
6973 (setq gnus-newsgroup-unreads
6974 (delq number gnus-newsgroup-unreads))
6975 (if gnus-newsgroup-auto-expire
6976 (push number gnus-newsgroup-expirable)
6977 (push (cons number gnus-low-score-mark)
6978 gnus-newsgroup-reads)))
6979 ;; Go recursively through all subthreads.
6980 (mapcar 'gnus-expunge-thread (cdr thread)))
6982 ;; Summary article oriented commands
6984 (defun gnus-summary-refer-parent-article (n)
6985 "Refer parent article N times.
6986 If N is negative, go to ancestor -N instead.
6987 The difference between N and the number of articles fetched is returned."
6991 (when (not (natnump n))
6996 (setq header (gnus-summary-article-header))
6997 (if (and (eq (mail-header-number header)
6998 (cdr gnus-article-current))
6999 (equal gnus-newsgroup-name
7000 (car gnus-article-current)))
7001 ;; If we try to find the parent of the currently
7002 ;; displayed article, then we take a look at the actual
7003 ;; References header, since this is slightly more
7004 ;; reliable than the References field we got from the
7007 (set-buffer gnus-original-article-buffer)
7008 (nnheader-narrow-to-headers)
7009 (unless (setq ref (message-fetch-field "references"))
7010 (setq ref (message-fetch-field "in-reply-to")))
7013 ;; It's not the current article, so we take a bet on
7014 ;; the value we got from the server.
7015 (mail-header-references header)))
7017 (not (equal ref "")))
7018 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7019 (gnus-message 1 "Couldn't find parent"))
7020 (gnus-message 1 "No references in article %d"
7021 (gnus-summary-article-number))
7024 (gnus-summary-position-point)
7027 (defun gnus-summary-refer-references ()
7028 "Fetch all articles mentioned in the References header.
7029 Return the number of articles fetched."
7031 (let ((ref (mail-header-references (gnus-summary-article-header)))
7032 (current (gnus-summary-article-number))
7036 (error "No References in the current article")
7037 ;; For each Message-ID in the References header...
7038 (while (string-match "<[^>]*>" ref)
7040 ;; ... fetch that article.
7041 (gnus-summary-refer-article
7042 (prog1 (match-string 0 ref)
7043 (setq ref (substring ref (match-end 0))))))
7044 (gnus-summary-goto-subject current)
7045 (gnus-summary-position-point)
7048 (defun gnus-summary-refer-thread (&optional limit)
7049 "Fetch all articles in the current thread.
7050 If LIMIT (the numerical prefix), fetch that many old headers instead
7051 of what's specified by the `gnus-refer-thread-limit' variable."
7053 (let ((id (mail-header-id (gnus-summary-article-header)))
7054 (limit (if limit (prefix-numeric-value limit)
7055 gnus-refer-thread-limit)))
7056 ;; We want to fetch LIMIT *old* headers, but we also have to
7057 ;; re-fetch all the headers in the current buffer, because many of
7058 ;; them may be undisplayed. So we adjust LIMIT.
7059 (when (numberp limit)
7060 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7061 (unless (eq gnus-fetch-old-headers 'invisible)
7062 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7063 ;; Retrieve the headers and read them in.
7064 (if (eq (gnus-retrieve-headers
7065 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7067 (gnus-build-all-threads)
7068 (error "Can't fetch thread from backends that don't support NOV"))
7069 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7070 (gnus-summary-limit-include-thread id)))
7072 (defun gnus-summary-refer-article (message-id)
7073 "Fetch an article specified by MESSAGE-ID."
7074 (interactive "sMessage-ID: ")
7075 (when (and (stringp message-id)
7076 (not (zerop (length message-id))))
7077 ;; Construct the correct Message-ID if necessary.
7078 ;; Suggested by tale@pawl.rpi.edu.
7079 (unless (string-match "^<" message-id)
7080 (setq message-id (concat "<" message-id)))
7081 (unless (string-match ">$" message-id)
7082 (setq message-id (concat message-id ">")))
7083 (let* ((header (gnus-id-to-header message-id))
7085 (gnus-summary-article-sparse-p
7086 (mail-header-number header))
7087 (memq (mail-header-number header)
7088 gnus-newsgroup-limit)))
7091 ;; If the article is present in the buffer we just go to it.
7093 (or (not (gnus-summary-article-sparse-p
7094 (mail-header-number header)))
7097 (gnus-summary-goto-article
7098 (mail-header-number header) nil t)
7100 (gnus-summary-update-article (mail-header-number header)))))
7102 ;; We fetch the article.
7104 (dolist (gnus-override-method (gnus-refer-article-methods))
7105 (gnus-check-server gnus-override-method)
7106 ;; Fetch the header, and display the article.
7107 (when (setq number (gnus-summary-insert-subject message-id))
7108 (gnus-summary-select-article nil nil nil number)
7110 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7112 (defun gnus-refer-article-methods ()
7113 "Return a list of referrable methods."
7115 ;; No method, so we default to current and native.
7116 ((null gnus-refer-article-method)
7117 (list gnus-current-select-method gnus-select-method))
7119 ((eq 'current gnus-refer-article-method)
7120 (list gnus-current-select-method))
7121 ;; List of select methods.
7122 ((not (and (symbolp (car gnus-refer-article-method))
7123 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7125 (dolist (method gnus-refer-article-method)
7126 (push (if (eq 'current method)
7127 gnus-current-select-method
7131 ;; One single select method.
7133 (list gnus-refer-article-method))))
7135 (defun gnus-summary-edit-parameters ()
7136 "Edit the group parameters of the current group."
7138 (gnus-group-edit-group gnus-newsgroup-name 'params))
7140 (defun gnus-summary-customize-parameters ()
7141 "Customize the group parameters of the current group."
7143 (gnus-group-customize gnus-newsgroup-name))
7145 (defun gnus-summary-enter-digest-group (&optional force)
7146 "Enter an nndoc group based on the current article.
7147 If FORCE, force a digest interpretation. If not, try
7148 to guess what the document format is."
7150 (let ((conf gnus-current-window-configuration))
7152 (gnus-summary-select-article))
7153 (setq gnus-current-window-configuration conf)
7154 (let* ((name (format "%s-%d"
7155 (gnus-group-prefixed-name
7156 gnus-newsgroup-name (list 'nndoc ""))
7158 (set-buffer gnus-summary-buffer)
7159 gnus-current-article)))
7160 (ogroup gnus-newsgroup-name)
7161 (params (append (gnus-info-params (gnus-get-info ogroup))
7162 (list (cons 'to-group ogroup))
7163 (list (cons 'save-article-group ogroup))))
7164 (case-fold-search t)
7165 (buf (current-buffer))
7168 (set-buffer gnus-original-article-buffer)
7169 ;; Have the digest group inherit the main mail address of
7170 ;; the parent article.
7171 (when (setq to-address (or (message-fetch-field "reply-to")
7172 (message-fetch-field "from")))
7173 (setq params (append
7174 (list (cons 'to-address
7175 (funcall gnus-decode-encoded-word-function
7177 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7178 (insert-buffer-substring gnus-original-article-buffer)
7179 ;; Remove lines that may lead nndoc to misinterpret the
7182 (goto-char (point-min))
7183 (or (search-forward "\n\n" nil t) (point)))
7184 (goto-char (point-min))
7185 (delete-matching-lines "^Path:\\|^From ")
7188 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7189 (gnus-newsgroup-ephemeral-ignored-charsets
7190 gnus-newsgroup-ignored-charsets))
7191 (gnus-group-read-ephemeral-group
7192 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7194 ,(if force 'mbox 'guess))) t))
7195 ;; Make all postings to this group go to the parent group.
7196 (nconc (gnus-info-params (gnus-get-info name))
7198 ;; Couldn't select this doc group.
7199 (switch-to-buffer buf)
7200 (gnus-set-global-variables)
7201 (gnus-configure-windows 'summary)
7202 (gnus-message 3 "Article couldn't be entered?"))
7203 (kill-buffer dig)))))
7205 (defun gnus-summary-read-document (n)
7206 "Open a new group based on the current article(s).
7207 This will allow you to read digests and other similar
7208 documents as newsgroups.
7209 Obeys the standard process/prefix convention."
7211 (let* ((articles (gnus-summary-work-articles n))
7212 (ogroup gnus-newsgroup-name)
7213 (params (append (gnus-info-params (gnus-get-info ogroup))
7214 (list (cons 'to-group ogroup))))
7215 article group egroup groups vgroup)
7216 (while (setq article (pop articles))
7217 (setq group (format "%s-%d" gnus-newsgroup-name article))
7218 (gnus-summary-remove-process-mark article)
7219 (when (gnus-summary-display-article article)
7222 (insert-buffer-substring gnus-original-article-buffer)
7223 ;; Remove some headers that may lead nndoc to make
7225 (message-narrow-to-head)
7226 (goto-char (point-min))
7227 (delete-matching-lines "^\\(Path\\):\\|^From ")
7230 (gnus-group-read-ephemeral-group
7231 group `(nndoc ,group (nndoc-address ,(current-buffer))
7232 (nndoc-article-type guess))
7235 ;; Make all postings to this group go to the parent group.
7236 (nconc (gnus-info-params (gnus-get-info egroup))
7238 (push egroup groups))
7239 ;; Couldn't select this doc group.
7240 (gnus-error 3 "Article couldn't be entered"))))))
7241 ;; Now we have selected all the documents.
7244 (error "None of the articles could be interpreted as documents"))
7245 ((gnus-group-read-ephemeral-group
7246 (setq vgroup (format
7247 "nnvirtual:%s-%s" gnus-newsgroup-name
7248 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7249 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7251 (cons (current-buffer) 'summary)))
7253 (error "Couldn't select virtual nndoc group")))))
7255 (defun gnus-summary-isearch-article (&optional regexp-p)
7256 "Do incremental search forward on the current article.
7257 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7259 (let* ((gnus-inhibit-treatment t)
7260 (old (gnus-summary-select-article)))
7261 (gnus-configure-windows 'article)
7262 (gnus-eval-in-buffer-window gnus-article-buffer
7266 (gnus-article-show-all-headers))
7267 (goto-char (point-min))
7268 (isearch-forward regexp-p)))))
7270 (defun gnus-summary-search-article-forward (regexp &optional backward)
7271 "Search for an article containing REGEXP forward.
7272 If BACKWARD, search backward instead."
7275 (format "Search article %s (regexp%s): "
7276 (if current-prefix-arg "backward" "forward")
7277 (if gnus-last-search-regexp
7278 (concat ", default " gnus-last-search-regexp)
7280 current-prefix-arg))
7281 (if (string-equal regexp "")
7282 (setq regexp (or gnus-last-search-regexp ""))
7283 (setq gnus-last-search-regexp regexp)
7284 (setq gnus-article-before-search gnus-current-article))
7285 ;; Intentionally set gnus-last-article.
7286 (setq gnus-last-article gnus-article-before-search)
7287 (let ((gnus-last-article gnus-last-article))
7288 (if (gnus-summary-search-article regexp backward)
7289 (gnus-summary-show-thread)
7290 (error "Search failed: \"%s\"" regexp))))
7292 (defun gnus-summary-search-article-backward (regexp)
7293 "Search for an article containing REGEXP backward."
7296 (format "Search article backward (regexp%s): "
7297 (if gnus-last-search-regexp
7298 (concat ", default " gnus-last-search-regexp)
7300 (gnus-summary-search-article-forward regexp 'backward))
7303 (defmacro gnus-summary-search-article-position-point (regexp backward)
7304 "Dehighlight the last matched text and goto the beginning position."
7305 (` (if (and gnus-summary-search-article-matched-data
7306 (let ((text (caddr gnus-summary-search-article-matched-data))
7307 (inhibit-read-only t)
7310 (goto-char (car gnus-summary-search-article-matched-data))
7311 (cadr gnus-summary-search-article-matched-data))
7313 (string-match (, regexp) text)))
7314 (if (, backward) (beginning-of-line) (end-of-line))
7315 (goto-char (if (, backward) (point-max) (point-min))))))
7317 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7318 "Place point where X-Face image is displayed."
7319 (if (featurep 'xemacs)
7320 (` (let ((end (if (search-forward "\n\n" nil t)
7321 (goto-char (1- (point)))
7324 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7325 (unless (and (re-search-forward "^From:" end t)
7326 (setq extent (extent-at (point)))
7327 (extent-begin-glyph extent))
7328 (goto-char (, opoint)))))
7329 (` (let ((end (if (search-forward "\n\n" nil t)
7330 (goto-char (1- (point)))
7332 (start (or (search-backward "\n\n" nil t) (point-min))))
7334 (or (text-property-any start end 'x-face-image t);; x-face-e21
7335 (text-property-any start end 'x-face-mule-bitmap-image t)
7338 (defmacro gnus-summary-search-article-highlight-matched-text
7339 (backward treated x-face)
7340 "Highlight matched text in the function `gnus-summary-search-article'."
7341 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7342 (end (set-marker (make-marker) (match-end 0)))
7343 (inhibit-read-only t)
7347 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7349 (lambda (item) (setq items (delq item items)))
7350 '(gnus-treat-buttonize
7351 gnus-treat-fill-article
7352 gnus-treat-fill-long-lines
7353 gnus-treat-emphasize
7354 gnus-treat-highlight-headers
7355 gnus-treat-highlight-citation
7356 gnus-treat-highlight-signature
7357 gnus-treat-overstrike
7358 gnus-treat-display-xface
7359 gnus-treat-buttonize-head
7360 gnus-treat-decode-article-as-default-mime-charset))
7361 (static-if (featurep 'xemacs)
7363 (cons '(x-face-mule-delete-x-face-field
7366 (gnus-treat-display-xface
7367 (when (, x-face) gnus-treat-display-xface)))
7368 (gnus-article-prepare-mime-display)))
7369 (goto-char (if (, backward) start end))
7371 (gnus-summary-search-article-highlight-goto-x-face (point)))
7372 (setq gnus-summary-search-article-matched-data
7373 (list start end (buffer-substring start end)))
7374 (unless (eq start end);; matched text has been deleted. :-<
7375 (put-text-property start end 'face
7376 (or (find-face 'isearch)
7377 'secondary-selection))))))
7380 (defun gnus-summary-search-article (regexp &optional backward)
7381 "Search for an article containing REGEXP.
7382 Optional argument BACKWARD means do search for backward.
7383 `gnus-select-article-hook' is not called during the search."
7384 ;; We have to require this here to make sure that the following
7385 ;; dynamic binding isn't shadowed by autoloading.
7386 (require 'gnus-async)
7388 (let ((gnus-select-article-hook nil) ;Disable hook.
7389 (gnus-article-display-hook nil)
7390 (gnus-article-prepare-hook nil)
7391 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7392 (gnus-use-article-prefetch nil)
7393 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7394 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7395 (sum (current-buffer))
7398 (gnus-save-hidden-threads
7399 (static-if (featurep 'xemacs)
7400 (let ((gnus-inhibit-treatment t))
7401 (setq treated (eq 'old (gnus-summary-select-article)))
7403 (not (and (gnus-buffer-live-p gnus-article-buffer)
7404 (window-live-p (get-buffer-window
7405 gnus-article-buffer t)))))
7406 (gnus-summary-select-article nil t)
7407 (setq treated nil)))
7408 (let ((gnus-inhibit-treatment t)
7409 (x-face-mule-delete-x-face-field 'never))
7410 (setq treated (eq 'old (gnus-summary-select-article)))
7413 (and (gnus-buffer-live-p gnus-article-buffer)
7414 (window-live-p (get-buffer-window
7415 gnus-article-buffer t))
7416 (or (not (string-match "^\\^X-Face:" regexp))
7417 (with-current-buffer gnus-article-buffer
7418 gnus-summary-search-article-matched-data)))))
7419 (gnus-summary-select-article nil t)
7420 (setq treated nil))))
7421 (set-buffer gnus-article-buffer)
7425 (gnus-article-show-all-headers)
7426 (gnus-summary-search-article-position-point regexp backward))
7427 (goto-char (if backward (point-max) (point-min))))
7429 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7431 (re-search-backward regexp nil t)
7432 (re-search-forward regexp nil t))
7433 ;; We found the regexp.
7435 (gnus-summary-search-article-highlight-matched-text
7436 backward treated (string-match "^\\^X-Face:" regexp))
7439 (/ (- 2 (window-height
7440 (get-buffer-window gnus-article-buffer t)))
7443 (get-buffer-window (current-buffer))
7446 (setq point (point)))
7447 ;; We didn't find it, so we go to the next article.
7450 (while (eq found 'not)
7451 (if (not (if backward (gnus-summary-find-prev)
7452 (gnus-summary-find-next)))
7453 ;; No more articles.
7455 ;; Select the next article and adjust point.
7456 (unless (gnus-summary-article-sparse-p
7457 (gnus-summary-article-number))
7459 (let ((gnus-inhibit-treatment t))
7460 (gnus-summary-select-article))
7462 (set-buffer gnus-article-buffer)
7464 (goto-char (if backward (point-max) (point-min))))))))
7465 (gnus-message 7 ""))
7466 ;; Return whether we found the regexp.
7467 (when (eq found 'found)
7469 (gnus-summary-show-thread)
7470 (gnus-summary-goto-subject gnus-current-article)
7471 (gnus-summary-position-point)
7474 (defun gnus-summary-find-matching (header regexp &optional backward unread
7476 "Return a list of all articles that match REGEXP on HEADER.
7477 The search stars on the current article and goes forwards unless
7478 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7479 If UNREAD is non-nil, only unread articles will
7480 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7481 in the comparisons."
7482 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7483 (gnus-data-find-list
7484 (gnus-summary-article-number) (gnus-data-list backward))))
7485 (case-fold-search (not not-case-fold))
7488 (if (eq (car header) 'extra)
7491 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7493 (error "%s is an invalid header" header))
7494 (unless (fboundp (intern (concat "mail-header-" header)))
7495 (error "%s is not a valid header" header))
7496 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7499 (and (or (not unread) ; We want all articles...
7500 (gnus-data-unread-p d)) ; Or just unreads.
7501 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7502 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7503 (push (gnus-data-number d) articles)) ; Success!
7504 (setq data (cdr data)))
7505 (nreverse articles)))
7507 (defun gnus-summary-execute-command (header regexp command &optional backward)
7508 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7509 If HEADER is an empty string (or nil), the match is done on the entire
7510 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7512 (list (let ((completion-ignore-case t))
7515 (mapcar (lambda (string) (list string))
7516 '("Number" "Subject" "From" "Lines" "Date"
7517 "Message-ID" "Xref" "References" "Body"))
7518 nil 'require-match))
7519 (read-string "Regexp: ")
7520 (read-key-sequence "Command: ")
7521 current-prefix-arg))
7522 (when (equal header "Body")
7524 ;; Hidden thread subtrees must be searched as well.
7525 (gnus-summary-show-all-threads)
7526 ;; We don't want to change current point nor window configuration.
7528 (save-window-excursion
7529 (gnus-message 6 "Executing %s..." (key-description command))
7530 ;; We'd like to execute COMMAND interactively so as to give arguments.
7531 (gnus-execute header regexp
7532 `(call-interactively ',(key-binding command))
7534 (gnus-message 6 "Executing %s...done" (key-description command)))))
7536 (defun gnus-summary-beginning-of-article ()
7537 "Scroll the article back to the beginning."
7539 (gnus-summary-select-article)
7540 (gnus-configure-windows 'article)
7541 (gnus-eval-in-buffer-window gnus-article-buffer
7543 (goto-char (point-min))
7544 (when gnus-page-broken
7545 (gnus-narrow-to-page))))
7547 (defun gnus-summary-end-of-article ()
7548 "Scroll to the end of the article."
7550 (gnus-summary-select-article)
7551 (gnus-configure-windows 'article)
7552 (gnus-eval-in-buffer-window gnus-article-buffer
7554 (goto-char (point-max))
7556 (when gnus-page-broken
7557 (gnus-narrow-to-page))))
7559 (defun gnus-summary-print-article (&optional filename n)
7560 "Generate and print a PostScript image of the N next (mail) articles.
7562 If N is negative, print the N previous articles. If N is nil and articles
7563 have been marked with the process mark, print these instead.
7565 If the optional first argument FILENAME is nil, send the image to the
7566 printer. If FILENAME is a string, save the PostScript image in a file with
7567 that name. If FILENAME is a number, prompt the user for the name of the file
7569 (interactive (list (ps-print-preprint current-prefix-arg)))
7570 (dolist (article (gnus-summary-work-articles n))
7571 (gnus-summary-select-article nil nil 'pseudo article)
7572 (gnus-eval-in-buffer-window gnus-article-buffer
7573 (let ((buffer (generate-new-buffer " *print*")))
7576 (copy-to-buffer buffer (point-min) (point-max))
7578 (gnus-article-delete-invisible-text)
7579 (when (gnus-visual-p 'article-highlight 'highlight)
7580 ;; Copy-to-buffer doesn't copy overlay. So redo
7582 (let ((gnus-article-buffer buffer))
7583 (gnus-article-highlight-citation t)
7584 (gnus-article-highlight-signature)))
7585 (let ((ps-left-header
7588 (mail-header-subject gnus-current-headers) ")")
7590 (mail-header-from gnus-current-headers) ")")))
7593 "/pagenumberstring load"
7595 (mail-header-date gnus-current-headers) ")"))))
7596 (gnus-run-hooks 'gnus-ps-print-hook)
7598 (ps-spool-buffer-with-faces))))
7599 (kill-buffer buffer))))
7600 (gnus-summary-remove-process-mark article))
7601 (ps-despool filename))
7603 (defun gnus-summary-show-article (&optional arg)
7604 "Force re-fetching of the current article.
7605 If ARG (the prefix) is a number, show the article with the charset
7606 defined in `gnus-summary-show-article-charset-alist', or the charset
7608 If ARG (the prefix) is non-nil and not a number, show the raw article
7609 without any article massaging functions being run."
7613 (let ((gnus-newsgroup-charset
7614 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7615 (read-coding-system "Charset: ")))
7616 (gnus-newsgroup-ignored-charsets 'gnus-all))
7617 (gnus-summary-select-article nil 'force)
7618 (let ((deps gnus-newsgroup-dependencies)
7621 (set-buffer gnus-original-article-buffer)
7623 (message-narrow-to-head)
7624 (setq head (buffer-string)))
7626 (insert (format "211 %d Article retrieved.\n"
7627 (cdr gnus-article-current)))
7630 (let ((nntp-server-buffer (current-buffer)))
7631 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7632 (gnus-data-set-header
7633 (gnus-data-find (cdr gnus-article-current))
7635 (gnus-summary-update-article-line
7636 (cdr gnus-article-current) header))))
7638 ;; Select the article the normal way.
7639 (gnus-summary-select-article nil 'force))
7641 ;; We have to require this here to make sure that the following
7642 ;; dynamic binding isn't shadowed by autoloading.
7643 (require 'gnus-async)
7645 ;; Bind the article treatment functions to nil.
7646 (let ((gnus-have-all-headers t)
7647 gnus-article-display-hook
7648 gnus-article-prepare-hook
7649 gnus-article-decode-hook
7652 (gnus-summary-select-article nil 'force))))
7653 (gnus-summary-goto-subject gnus-current-article)
7654 (gnus-summary-position-point))
7656 (defun gnus-summary-verbose-headers (&optional arg)
7657 "Toggle permanent full header display.
7658 If ARG is a positive number, turn header display on.
7659 If ARG is a negative number, turn header display off."
7661 (setq gnus-show-all-headers
7662 (cond ((or (not (numberp arg))
7664 (not gnus-show-all-headers))
7667 (gnus-summary-show-article))
7669 (defun gnus-summary-toggle-header (&optional arg)
7670 "Show the headers if they are hidden, or hide them if they are shown.
7671 If ARG is a positive number, show the entire header.
7672 If ARG is a negative number, hide the unwanted header lines."
7675 (set-buffer gnus-article-buffer)
7677 (let* ((buffer-read-only nil)
7678 (inhibit-point-motion-hooks t)
7684 (article-narrow-to-head)
7685 (gnus-article-hidden-text-p 'headers))))
7686 (goto-char (point-min))
7687 (when (search-forward "\n\n" nil t)
7688 (delete-region (point-min) (1- (point))))
7689 (goto-char (point-min))
7691 (set-buffer gnus-original-article-buffer)
7692 (goto-char (point-min))
7693 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7694 (insert-buffer-substring gnus-original-article-buffer 1 e)
7696 (narrow-to-region (point-min) (point))
7697 (article-decode-encoded-words)
7699 (let ((gnus-treat-hide-headers nil)
7700 (gnus-treat-hide-boring-headers nil))
7701 (setq gnus-article-wash-types
7702 (delq 'headers gnus-article-wash-types))
7703 (gnus-treat-article 'head))
7704 (gnus-treat-article 'head)))
7705 (gnus-set-mode-line 'article)))))
7707 (defun gnus-summary-show-all-headers ()
7708 "Make all header lines visible."
7710 (gnus-article-show-all-headers))
7712 (defun gnus-summary-toggle-mime (&optional arg)
7713 "Toggle MIME processing.
7714 If ARG is a positive number, turn MIME processing on."
7716 (setq gnus-show-mime
7718 (not gnus-show-mime)
7719 (> (prefix-numeric-value arg) 0)))
7720 (gnus-summary-select-article t 'force))
7722 (defun gnus-summary-caesar-message (&optional arg)
7723 "Caesar rotate the current article by 13.
7724 The numerical prefix specifies how many places to rotate each letter
7727 (gnus-summary-select-article)
7728 (let ((mail-header-separator ""))
7729 (gnus-eval-in-buffer-window gnus-article-buffer
7732 (let ((start (window-start))
7734 (message-caesar-buffer-body arg)
7735 (set-window-start (get-buffer-window (current-buffer)) start))))))
7737 (defun gnus-summary-stop-page-breaking ()
7738 "Stop page breaking in the current article."
7740 (gnus-summary-select-article)
7741 (gnus-eval-in-buffer-window gnus-article-buffer
7743 (when (gnus-visual-p 'page-marker)
7744 (let ((buffer-read-only nil))
7745 (gnus-remove-text-with-property 'gnus-prev)
7746 (gnus-remove-text-with-property 'gnus-next))
7747 (setq gnus-page-broken nil))))
7749 (defun gnus-summary-move-article (&optional n to-newsgroup
7750 select-method action)
7751 "Move the current article to a different newsgroup.
7752 If N is a positive number, move the N next articles.
7753 If N is a negative number, move the N previous articles.
7754 If N is nil and any articles have been marked with the process mark,
7755 move those articles instead.
7756 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7757 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7758 re-spool using this method.
7760 For this function to work, both the current newsgroup and the
7761 newsgroup that you want to move to have to support the `request-move'
7762 and `request-accept' functions.
7764 ACTION can be either `move' (the default), `crosspost' or `copy'."
7767 (setq action 'move))
7768 ;; Disable marking as read.
7769 (let (gnus-mark-article-hook)
7770 (save-window-excursion
7771 (gnus-summary-select-article)))
7772 ;; Check whether the source group supports the required functions.
7773 (cond ((and (eq action 'move)
7774 (not (gnus-check-backend-function
7775 'request-move-article gnus-newsgroup-name)))
7776 (error "The current group does not support article moving"))
7777 ((and (eq action 'crosspost)
7778 (not (gnus-check-backend-function
7779 'request-replace-article gnus-newsgroup-name)))
7780 (error "The current group does not support article editing")))
7781 (let ((articles (gnus-summary-work-articles n))
7782 (prefix (if (gnus-check-backend-function
7783 'request-move-article gnus-newsgroup-name)
7784 (gnus-group-real-prefix gnus-newsgroup-name)
7786 (names '((move "Move" "Moving")
7787 (copy "Copy" "Copying")
7788 (crosspost "Crosspost" "Crossposting")))
7789 (copy-buf (save-excursion
7790 (nnheader-set-temp-buffer " *copy article*")))
7791 (default-marks gnus-article-mark-lists)
7792 (no-expire-marks (delete '(expirable . expire)
7793 (copy-sequence gnus-article-mark-lists)))
7794 art-group to-method new-xref article to-groups)
7795 (unless (assq action names)
7796 (error "Unknown action %s" action))
7797 ;; Read the newsgroup name.
7798 (when (and (not to-newsgroup)
7799 (not select-method))
7801 (gnus-read-move-group-name
7802 (cadr (assq action names))
7803 (symbol-value (intern (format "gnus-current-%s-group" action)))
7805 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7806 (setq to-method (or select-method
7807 (gnus-server-to-method
7808 (gnus-group-method to-newsgroup))))
7809 ;; Check the method we are to move this article to...
7810 (unless (gnus-check-backend-function
7811 'request-accept-article (car to-method))
7812 (error "%s does not support article copying" (car to-method)))
7813 (unless (gnus-check-server to-method)
7814 (error "Can't open server %s" (car to-method)))
7815 (gnus-message 6 "%s to %s: %s..."
7816 (caddr (assq action names))
7817 (or (car select-method) to-newsgroup) articles)
7819 (setq article (pop articles))
7823 ;; Move the article.
7825 ;; Remove this article from future suppression.
7826 (gnus-dup-unsuppress-article article)
7827 (gnus-request-move-article
7828 article ; Article to move
7829 gnus-newsgroup-name ; From newsgroup
7830 (nth 1 (gnus-find-method-for-group
7831 gnus-newsgroup-name)) ; Server
7832 (list 'gnus-request-accept-article
7833 to-newsgroup (list 'quote select-method)
7834 (not articles) t) ; Accept form
7835 (not articles))) ; Only save nov last time
7836 ;; Copy the article.
7839 (set-buffer copy-buf)
7840 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7841 (gnus-request-accept-article
7842 to-newsgroup select-method (not articles) t))))
7843 ;; Crosspost the article.
7844 ((eq action 'crosspost)
7845 (let ((xref (message-tokenize-header
7846 (mail-header-xref (gnus-summary-article-header article))
7848 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7851 (setq xref (list (system-name))))
7854 (mapconcat 'identity
7855 (delete "Xref:" (delete new-xref xref))
7859 (set-buffer copy-buf)
7860 ;; First put the article in the destination group.
7861 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7862 (when (consp (setq art-group
7863 (gnus-request-accept-article
7864 to-newsgroup select-method (not articles))))
7865 (setq new-xref (concat new-xref " " (car art-group)
7866 ":" (cdr art-group)))
7867 ;; Now we have the new Xrefs header, so we insert
7868 ;; it and replace the new article.
7869 (nnheader-replace-header "Xref" new-xref)
7870 (gnus-request-replace-article
7871 (cdr art-group) to-newsgroup (current-buffer))
7875 (gnus-message 1 "Couldn't %s article %s: %s"
7876 (cadr (assq action names)) article
7877 (nnheader-get-report (car to-method))))
7878 ((eq art-group 'junk)
7879 (when (eq action 'move)
7880 (gnus-summary-mark-article article gnus-canceled-mark)
7881 (gnus-message 4 "Deleted article %s" article)))
7883 (let* ((pto-group (gnus-group-prefixed-name
7884 (car art-group) to-method))
7886 (gnus-gethash pto-group gnus-newsrc-hashtb))
7887 (info (nth 2 entry))
7888 (to-group (gnus-info-group info))
7890 ;; Update the group that has been moved to.
7892 (memq action '(move copy)))
7893 (unless (member to-group to-groups)
7894 (push to-group to-groups))
7896 (unless (memq article gnus-newsgroup-unreads)
7897 (push 'read to-marks)
7899 info (gnus-add-to-range (gnus-info-read info)
7900 (list (cdr art-group)))))
7902 ;; See whether the article is to be put in the cache.
7903 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7906 (to-article (cdr art-group)))
7908 ;; Enter the article into the cache in the new group,
7909 ;; if that is required.
7910 (when gnus-use-cache
7911 (gnus-cache-possibly-enter-article
7913 (let ((header (copy-sequence
7914 (gnus-summary-article-header article))))
7915 (mail-header-set-number header to-article)
7917 (memq article gnus-newsgroup-marked)
7918 (memq article gnus-newsgroup-dormant)
7919 (memq article gnus-newsgroup-unreads)))
7921 (when gnus-preserve-marks
7922 ;; Copy any marks over to the new group.
7923 (when (and (equal to-group gnus-newsgroup-name)
7924 (not (memq article gnus-newsgroup-unreads)))
7925 ;; Mark this article as read in this group.
7926 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7927 (setcdr (gnus-active to-group) to-article)
7928 (setcdr gnus-newsgroup-active to-article))
7931 (when (memq article (symbol-value
7932 (intern (format "gnus-newsgroup-%s"
7934 (push (cdar marks) to-marks)
7935 ;; If the other group is the same as this group,
7936 ;; then we have to add the mark to the list.
7937 (when (equal to-group gnus-newsgroup-name)
7938 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7941 (intern (format "gnus-newsgroup-%s"
7943 ;; Copy the marks to other group.
7944 (gnus-add-marked-articles
7945 to-group (cdar marks) (list to-article) info))
7946 (setq marks (cdr marks)))
7948 (gnus-request-set-mark to-group (list (list (list to-article)
7953 (concat "(gnus-group-set-info '"
7954 (gnus-prin1-to-string (gnus-get-info to-group))
7957 ;; Update the Xref header in this article to point to
7958 ;; the new crossposted article we have just created.
7959 (when (eq action 'crosspost)
7961 (set-buffer copy-buf)
7962 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7963 (nnheader-replace-header "Xref" new-xref)
7964 (gnus-request-replace-article
7965 article gnus-newsgroup-name (current-buffer)))))
7967 ;;;!!!Why is this necessary?
7968 (set-buffer gnus-summary-buffer)
7970 (gnus-summary-goto-subject article)
7971 (when (eq action 'move)
7972 (gnus-summary-mark-article article gnus-canceled-mark))))
7973 (gnus-summary-remove-process-mark article))
7974 ;; Re-activate all groups that have been moved to.
7977 (set-buffer gnus-group-buffer)
7978 (when (gnus-group-goto-group (car to-groups) t)
7979 (gnus-group-get-new-news-this-group 1 t))
7982 (gnus-kill-buffer copy-buf)
7983 (gnus-summary-position-point)
7984 (gnus-set-mode-line 'summary)))
7986 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7987 "Move the current article to a different newsgroup.
7988 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7989 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7990 re-spool using this method."
7992 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7994 (defun gnus-summary-crosspost-article (&optional n)
7995 "Crosspost the current article to some other group."
7997 (gnus-summary-move-article n nil nil 'crosspost))
7999 (defcustom gnus-summary-respool-default-method nil
8000 "Default method for respooling an article.
8001 If nil, use to the current newsgroup method."
8002 :type '(choice (gnus-select-method :value (nnml ""))
8004 :group 'gnus-summary-mail)
8006 (defun gnus-summary-respool-article (&optional n method)
8007 "Respool the current article.
8008 The article will be squeezed through the mail spooling process again,
8009 which means that it will be put in some mail newsgroup or other
8010 depending on `nnmail-split-methods'.
8011 If N is a positive number, respool the N next articles.
8012 If N is a negative number, respool the N previous articles.
8013 If N is nil and any articles have been marked with the process mark,
8014 respool those articles instead.
8016 Respooling can be done both from mail groups and \"real\" newsgroups.
8017 In the former case, the articles in question will be moved from the
8018 current group into whatever groups they are destined to. In the
8019 latter case, they will be copied into the relevant groups."
8021 (list current-prefix-arg
8022 (let* ((methods (gnus-methods-using 'respool))
8024 (symbol-name (or gnus-summary-respool-default-method
8025 (car (gnus-find-method-for-group
8026 gnus-newsgroup-name)))))
8028 (gnus-completing-read
8029 methname "What backend do you want to use when respooling?"
8030 methods nil t nil 'gnus-mail-method-history))
8033 ((zerop (length (setq ms (gnus-servers-using-backend
8035 (list (intern method) ""))
8039 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8040 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8043 (error "No method given for respooling"))
8044 (if (assoc (symbol-name
8045 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8046 (gnus-methods-using 'respool))
8047 (gnus-summary-move-article n nil method)
8048 (gnus-summary-copy-article n nil method)))
8050 (defun gnus-summary-import-article (file)
8051 "Import an arbitrary file into a mail newsgroup."
8052 (interactive "fImport file: ")
8053 (let ((group gnus-newsgroup-name)
8054 (now (current-time))
8056 (unless (gnus-check-backend-function 'request-accept-article group)
8057 (error "%s does not support article importing" group))
8058 (or (file-readable-p file)
8059 (not (file-regular-p file))
8060 (error "Can't read %s" file))
8062 (set-buffer (gnus-get-buffer-create " *import file*"))
8064 (nnheader-insert-file-contents file)
8065 (goto-char (point-min))
8066 (unless (nnheader-article-p)
8067 ;; This doesn't look like an article, so we fudge some headers.
8068 (setq atts (file-attributes file)
8069 lines (count-lines (point-min) (point-max)))
8070 (insert "From: " (read-string "From: ") "\n"
8071 "Subject: " (read-string "Subject: ") "\n"
8072 "Date: " (message-make-date (nth 5 atts))
8074 "Message-ID: " (message-make-message-id) "\n"
8075 "Lines: " (int-to-string lines) "\n"
8076 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8077 (gnus-request-accept-article group nil t)
8078 (kill-buffer (current-buffer)))))
8080 (defun gnus-summary-article-posted-p ()
8081 "Say whether the current (mail) article is available from news as well.
8082 This will be the case if the article has both been mailed and posted."
8084 (let ((id (mail-header-references (gnus-summary-article-header)))
8085 (gnus-override-method (car (gnus-refer-article-methods))))
8086 (if (gnus-request-head id "")
8087 (gnus-message 2 "The current message was found on %s"
8088 gnus-override-method)
8089 (gnus-message 2 "The current message couldn't be found on %s"
8090 gnus-override-method)
8093 (defun gnus-summary-expire-articles (&optional now)
8094 "Expire all articles that are marked as expirable in the current group."
8096 (when (gnus-check-backend-function
8097 'request-expire-articles gnus-newsgroup-name)
8098 ;; This backend supports expiry.
8099 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8100 (expirable (if total
8102 ;; We need to update the info for
8103 ;; this group for `gnus-list-of-read-articles'
8104 ;; to give us the right answer.
8105 (gnus-run-hooks 'gnus-exit-group-hook)
8106 (gnus-summary-update-info)
8107 (gnus-list-of-read-articles gnus-newsgroup-name))
8108 (setq gnus-newsgroup-expirable
8109 (sort gnus-newsgroup-expirable '<))))
8110 (expiry-wait (if now 'immediate
8111 (gnus-group-find-parameter
8112 gnus-newsgroup-name 'expiry-wait)))
8113 (nnmail-expiry-target
8114 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8115 nnmail-expiry-target))
8118 ;; There are expirable articles in this group, so we run them
8119 ;; through the expiry process.
8120 (gnus-message 6 "Expiring articles...")
8121 (unless (gnus-check-group gnus-newsgroup-name)
8122 (error "Can't open server for %s" gnus-newsgroup-name))
8123 ;; The list of articles that weren't expired is returned.
8126 (let ((nnmail-expiry-wait-function nil)
8127 (nnmail-expiry-wait expiry-wait))
8128 (setq es (gnus-request-expire-articles
8129 expirable gnus-newsgroup-name)))
8130 (setq es (gnus-request-expire-articles
8131 expirable gnus-newsgroup-name)))
8133 (setq gnus-newsgroup-expirable es))
8134 ;; We go through the old list of expirable, and mark all
8135 ;; really expired articles as nonexistent.
8136 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8137 (let ((gnus-use-cache nil))
8139 (unless (memq (car expirable) es)
8140 (when (gnus-data-find (car expirable))
8141 (gnus-summary-mark-article
8142 (car expirable) gnus-canceled-mark)))
8143 (setq expirable (cdr expirable))))))
8144 (gnus-message 6 "Expiring articles...done")))))
8146 (defun gnus-summary-expire-articles-now ()
8147 "Expunge all expirable articles in the current group.
8148 This means that *all* articles that are marked as expirable will be
8149 deleted forever, right now."
8151 (or gnus-expert-user
8153 "Are you really, really, really sure you want to delete all these messages? ")
8155 (gnus-summary-expire-articles t))
8157 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8158 (defun gnus-summary-delete-article (&optional n)
8159 "Delete the N next (mail) articles.
8160 This command actually deletes articles. This is not a marking
8161 command. The article will disappear forever from your life, never to
8163 If N is negative, delete backwards.
8164 If N is nil and articles have been marked with the process mark,
8165 delete these instead."
8167 (unless (gnus-check-backend-function 'request-expire-articles
8168 gnus-newsgroup-name)
8169 (error "The current newsgroup does not support article deletion"))
8170 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8171 (error "Couldn't open server"))
8172 ;; Compute the list of articles to delete.
8173 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8175 (if (and gnus-novice-user
8176 (not (gnus-yes-or-no-p
8177 (format "Do you really want to delete %s forever? "
8178 (if (> (length articles) 1)
8179 (format "these %s articles" (length articles))
8182 ;; Delete the articles.
8183 (setq not-deleted (gnus-request-expire-articles
8184 articles gnus-newsgroup-name 'force))
8186 (gnus-summary-remove-process-mark (car articles))
8187 ;; The backend might not have been able to delete the article
8189 (unless (memq (car articles) not-deleted)
8190 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8191 (setq articles (cdr articles)))
8193 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8194 (gnus-summary-position-point)
8195 (gnus-set-mode-line 'summary)
8198 (defun gnus-summary-edit-article (&optional force)
8199 "Edit the current article.
8200 This will have permanent effect only in mail groups.
8201 If FORCE is non-nil, allow editing of articles even in read-only
8205 (set-buffer gnus-summary-buffer)
8206 (let ((mail-parse-charset gnus-newsgroup-charset)
8207 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8208 (gnus-set-global-variables)
8209 (when (and (not force)
8210 (gnus-group-read-only-p))
8211 (error "The current newsgroup does not support article editing"))
8212 (gnus-summary-show-article t)
8213 (gnus-article-edit-article
8215 `(lambda (no-highlight)
8216 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8217 (message-options message-options)
8218 (message-options-set-recipient)
8219 (mail-parse-ignored-charsets
8220 ',gnus-newsgroup-ignored-charsets))
8221 (gnus-summary-edit-article-done
8222 ,(or (mail-header-references gnus-current-headers) "")
8223 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8225 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8227 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8229 "Make edits to the current article permanent."
8232 ;; The buffer restriction contains the entire article if it exists.
8233 (when (article-goto-body)
8234 (let ((lines (count-lines (point) (point-max)))
8235 (length (- (point-max) (point)))
8236 (case-fold-search t)
8237 (body (copy-marker (point))))
8238 (goto-char (point-min))
8239 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8240 (delete-region (match-beginning 1) (match-end 1))
8241 (insert (number-to-string length)))
8242 (goto-char (point-min))
8243 (when (re-search-forward
8244 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8245 (delete-region (match-beginning 1) (match-end 1))
8246 (insert (number-to-string length)))
8247 (goto-char (point-min))
8248 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8249 (delete-region (match-beginning 1) (match-end 1))
8250 (insert (number-to-string lines))))))
8251 ;; Replace the article.
8252 (let ((buf (current-buffer)))
8254 (insert-buffer-substring buf)
8256 (if (and (not read-only)
8257 (not (gnus-request-replace-article
8258 (cdr gnus-article-current) (car gnus-article-current)
8259 (current-buffer) t)))
8260 (error "Couldn't replace article")
8261 ;; Update the summary buffer.
8263 (equal (message-tokenize-header references " ")
8264 (message-tokenize-header
8265 (or (message-fetch-field "references") "") " ")))
8266 ;; We only have to update this line.
8269 (message-narrow-to-head)
8270 (let ((head (buffer-string))
8273 (insert (format "211 %d Article retrieved.\n"
8274 (cdr gnus-article-current)))
8277 (let ((nntp-server-buffer (current-buffer)))
8278 (setq header (car (gnus-get-newsgroup-headers
8280 (set-buffer gnus-summary-buffer)
8281 gnus-newsgroup-dependencies)
8284 (set-buffer gnus-summary-buffer)
8285 (gnus-data-set-header
8286 (gnus-data-find (cdr gnus-article-current))
8288 (gnus-summary-update-article-line
8289 (cdr gnus-article-current) header))))))
8291 (set-buffer (or buffer gnus-summary-buffer))
8292 (gnus-summary-update-article (cdr gnus-article-current)))
8293 ;; Prettify the article buffer again.
8294 (unless no-highlight
8296 (set-buffer gnus-article-buffer)
8297 ;;;!!! Fix this -- article should be rehighlighted.
8298 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8299 (set-buffer gnus-original-article-buffer)
8300 (gnus-request-article
8301 (cdr gnus-article-current)
8302 (car gnus-article-current) (current-buffer))))
8303 ;; Prettify the summary buffer line.
8304 (when (gnus-visual-p 'summary-highlight 'highlight)
8305 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8307 (defun gnus-summary-edit-wash (key)
8308 "Perform editing command KEY in the article buffer."
8312 (message "%s" (concat (this-command-keys) "- "))
8315 (gnus-summary-edit-article)
8316 (execute-kbd-macro (concat (this-command-keys) key))
8317 (gnus-article-edit-done))
8321 (defun gnus-summary-respool-query (&optional silent trace)
8322 "Query where the respool algorithm would put this article."
8324 (let (gnus-mark-article-hook)
8325 (gnus-summary-select-article)
8327 (set-buffer gnus-original-article-buffer)
8329 (message-narrow-to-head)
8330 (let ((groups (nnmail-article-group 'identity trace)))
8333 (message "This message would go to %s"
8334 (mapconcat 'car groups ", "))
8335 (message "This message would go to no groups"))
8338 (defun gnus-summary-respool-trace ()
8339 "Trace where the respool algorithm would put this article.
8340 Display a buffer showing all fancy splitting patterns which matched."
8342 (gnus-summary-respool-query nil t))
8344 ;; Summary marking commands.
8346 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8347 "Mark articles which has the same subject as read, and then select the next.
8348 If UNMARK is positive, remove any kind of mark.
8349 If UNMARK is negative, tick articles."
8352 (setq unmark (prefix-numeric-value unmark)))
8354 (gnus-summary-mark-same-subject
8355 (gnus-summary-article-subject) unmark)))
8356 ;; Select next unread article. If auto-select-same mode, should
8357 ;; select the first unread article.
8358 (gnus-summary-next-article t (and gnus-auto-select-same
8359 (gnus-summary-article-subject)))
8360 (gnus-message 7 "%d article%s marked as %s"
8361 count (if (= count 1) " is" "s are")
8362 (if unmark "unread" "read"))))
8364 (defun gnus-summary-kill-same-subject (&optional unmark)
8365 "Mark articles which has the same subject as read.
8366 If UNMARK is positive, remove any kind of mark.
8367 If UNMARK is negative, tick articles."
8370 (setq unmark (prefix-numeric-value unmark)))
8372 (gnus-summary-mark-same-subject
8373 (gnus-summary-article-subject) unmark)))
8374 ;; If marked as read, go to next unread subject.
8376 ;; Go to next unread subject.
8377 (gnus-summary-next-subject 1 t))
8378 (gnus-message 7 "%d articles are marked as %s"
8379 count (if unmark "unread" "read"))))
8381 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8382 "Mark articles with same SUBJECT as read, and return marked number.
8383 If optional argument UNMARK is positive, remove any kinds of marks.
8384 If optional argument UNMARK is negative, mark articles as unread instead."
8388 ((null unmark) ; Mark as read.
8391 (gnus-summary-mark-article-as-read gnus-killed-mark)
8392 (gnus-summary-show-thread) t)
8393 (gnus-summary-find-subject subject))
8394 (setq count (1+ count))))
8395 ((> unmark 0) ; Tick.
8398 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8399 (gnus-summary-show-thread) t)
8400 (gnus-summary-find-subject subject))
8401 (setq count (1+ count))))
8402 (t ; Mark as unread.
8405 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8406 (gnus-summary-show-thread) t)
8407 (gnus-summary-find-subject subject))
8408 (setq count (1+ count)))))
8409 (gnus-set-mode-line 'summary)
8410 ;; Return the number of marked articles.
8413 (defun gnus-summary-mark-as-processable (n &optional unmark)
8414 "Set the process mark on the next N articles.
8415 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8416 the process mark instead. The difference between N and the actual
8417 number of articles marked is returned."
8419 (if (and (null n) (gnus-region-active-p))
8420 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8421 (setq n (prefix-numeric-value n))
8422 (let ((backward (< n 0))
8427 (gnus-summary-remove-process-mark
8428 (gnus-summary-article-number))
8429 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8430 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8433 (gnus-message 7 "No more articles"))
8434 (gnus-summary-recenter)
8435 (gnus-summary-position-point)
8438 (defun gnus-summary-unmark-as-processable (n)
8439 "Remove the process mark from the next N articles.
8440 If N is negative, unmark backward instead. The difference between N and
8441 the actual number of articles unmarked is returned."
8443 (gnus-summary-mark-as-processable n t))
8445 (defun gnus-summary-unmark-all-processable ()
8446 "Remove the process mark from all articles."
8449 (while gnus-newsgroup-processable
8450 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8451 (gnus-summary-position-point))
8453 (defun gnus-summary-add-mark (article type)
8454 "Mark ARTICLE with a mark of TYPE."
8455 (let ((vtype (car (assq type gnus-article-mark-lists)))
8458 (error "No such mark type: %s" type)
8459 (setq var (intern (format "gnus-newsgroup-%s" type)))
8460 (set var (cons article (symbol-value var)))
8461 (if (memq type '(processable cached replied saved))
8462 (gnus-summary-update-secondary-mark article)
8463 ;;; !!! This is bobus. We should find out what primary
8464 ;;; !!! mark we want to set.
8465 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8467 (defun gnus-summary-mark-as-expirable (n)
8468 "Mark N articles forward as expirable.
8469 If N is negative, mark backward instead. The difference between N and
8470 the actual number of articles marked is returned."
8472 (gnus-summary-mark-forward n gnus-expirable-mark))
8474 (defun gnus-summary-mark-article-as-replied (article)
8475 "Mark ARTICLE replied and update the summary line."
8476 (push article gnus-newsgroup-replied)
8477 (let ((buffer-read-only nil))
8478 (when (gnus-summary-goto-subject article nil t)
8479 (gnus-summary-update-secondary-mark article))))
8481 (defun gnus-summary-set-bookmark (article)
8482 "Set a bookmark in current article."
8483 (interactive (list (gnus-summary-article-number)))
8484 (when (or (not (get-buffer gnus-article-buffer))
8485 (not gnus-current-article)
8486 (not gnus-article-current)
8487 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8488 (error "No current article selected"))
8489 ;; Remove old bookmark, if one exists.
8490 (let ((old (assq article gnus-newsgroup-bookmarks)))
8492 (setq gnus-newsgroup-bookmarks
8493 (delq old gnus-newsgroup-bookmarks))))
8494 ;; Set the new bookmark, which is on the form
8495 ;; (article-number . line-number-in-body).
8499 (set-buffer gnus-article-buffer)
8503 (goto-char (point-min))
8504 (search-forward "\n\n" nil t)
8507 gnus-newsgroup-bookmarks)
8508 (gnus-message 6 "A bookmark has been added to the current article."))
8510 (defun gnus-summary-remove-bookmark (article)
8511 "Remove the bookmark from the current article."
8512 (interactive (list (gnus-summary-article-number)))
8513 ;; Remove old bookmark, if one exists.
8514 (let ((old (assq article gnus-newsgroup-bookmarks)))
8517 (setq gnus-newsgroup-bookmarks
8518 (delq old gnus-newsgroup-bookmarks))
8519 (gnus-message 6 "Removed bookmark."))
8520 (gnus-message 6 "No bookmark in current article."))))
8522 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8523 (defun gnus-summary-mark-as-dormant (n)
8524 "Mark N articles forward as dormant.
8525 If N is negative, mark backward instead. The difference between N and
8526 the actual number of articles marked is returned."
8528 (gnus-summary-mark-forward n gnus-dormant-mark))
8530 (defun gnus-summary-set-process-mark (article)
8531 "Set the process mark on ARTICLE and update the summary line."
8532 (setq gnus-newsgroup-processable
8534 (delq article gnus-newsgroup-processable)))
8535 (when (gnus-summary-goto-subject article)
8536 (gnus-summary-show-thread)
8537 (gnus-summary-goto-subject article)
8538 (gnus-summary-update-secondary-mark article)))
8540 (defun gnus-summary-remove-process-mark (article)
8541 "Remove the process mark from ARTICLE and update the summary line."
8542 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8543 (when (gnus-summary-goto-subject article)
8544 (gnus-summary-show-thread)
8545 (gnus-summary-goto-subject article)
8546 (gnus-summary-update-secondary-mark article)))
8548 (defun gnus-summary-set-saved-mark (article)
8549 "Set the process mark on ARTICLE and update the summary line."
8550 (push article gnus-newsgroup-saved)
8551 (when (gnus-summary-goto-subject article)
8552 (gnus-summary-update-secondary-mark article)))
8554 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8555 "Mark N articles as read forwards.
8556 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8557 The difference between N and the actual number of articles marked is
8559 Iff NO-EXPIRE, auto-expiry will be inhibited."
8561 (gnus-summary-show-thread)
8562 (let ((backward (< n 0))
8563 (gnus-summary-goto-unread
8564 (and gnus-summary-goto-unread
8565 (not (eq gnus-summary-goto-unread 'never))
8566 (not (memq mark (list gnus-unread-mark
8567 gnus-ticked-mark gnus-dormant-mark)))))
8569 (mark (or mark gnus-del-mark)))
8571 (gnus-summary-mark-article nil mark no-expire)
8572 (zerop (gnus-summary-next-subject
8574 (and gnus-summary-goto-unread
8575 (not (eq gnus-summary-goto-unread 'never)))
8579 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8580 (gnus-summary-recenter)
8581 (gnus-summary-position-point)
8582 (gnus-set-mode-line 'summary)
8585 (defun gnus-summary-mark-article-as-read (mark)
8586 "Mark the current article quickly as read with MARK."
8587 (let ((article (gnus-summary-article-number)))
8588 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8589 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8590 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8591 (push (cons article mark) gnus-newsgroup-reads)
8592 ;; Possibly remove from cache, if that is used.
8593 (when gnus-use-cache
8594 (gnus-cache-enter-remove-article article))
8595 ;; Allow the backend to change the mark.
8596 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8597 ;; Check for auto-expiry.
8598 (when (and gnus-newsgroup-auto-expire
8599 (memq mark gnus-auto-expirable-marks))
8600 (setq mark gnus-expirable-mark)
8601 ;; Let the backend know about the mark change.
8602 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8603 (push article gnus-newsgroup-expirable))
8604 ;; Set the mark in the buffer.
8605 (gnus-summary-update-mark mark 'unread)
8608 (defun gnus-summary-mark-article-as-unread (mark)
8609 "Mark the current article quickly as unread with MARK."
8610 (let* ((article (gnus-summary-article-number))
8611 (old-mark (gnus-summary-article-mark article)))
8612 ;; Allow the backend to change the mark.
8613 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8614 (if (eq mark old-mark)
8618 (gnus-error 1 "Can't mark negative article numbers")
8620 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8621 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8622 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8623 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8624 (cond ((= mark gnus-ticked-mark)
8625 (push article gnus-newsgroup-marked))
8626 ((= mark gnus-dormant-mark)
8627 (push article gnus-newsgroup-dormant))
8629 (push article gnus-newsgroup-unreads)))
8630 (gnus-pull article gnus-newsgroup-reads)
8632 ;; See whether the article is to be put in the cache.
8634 (vectorp (gnus-summary-article-header article))
8636 (gnus-cache-possibly-enter-article
8637 gnus-newsgroup-name article
8638 (gnus-summary-article-header article)
8639 (= mark gnus-ticked-mark)
8640 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8643 (gnus-summary-update-mark mark 'unread)
8646 (defun gnus-summary-mark-article (&optional article mark no-expire)
8647 "Mark ARTICLE with MARK. MARK can be any character.
8648 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8649 `??' (dormant) and `?E' (expirable).
8650 If MARK is nil, then the default character `?r' is used.
8651 If ARTICLE is nil, then the article on the current line will be
8653 Iff NO-EXPIRE, auto-expiry will be inhibited."
8654 ;; The mark might be a string.
8655 (when (stringp mark)
8656 (setq mark (aref mark 0)))
8657 ;; If no mark is given, then we check auto-expiring.
8659 (setq mark gnus-del-mark))
8660 (when (and (not no-expire)
8661 gnus-newsgroup-auto-expire
8662 (memq mark gnus-auto-expirable-marks))
8663 (setq mark gnus-expirable-mark))
8664 (let ((article (or article (gnus-summary-article-number)))
8665 (old-mark (gnus-summary-article-mark article)))
8666 ;; Allow the backend to change the mark.
8667 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8668 (if (eq mark old-mark)
8671 (error "No article on current line"))
8672 (if (not (if (or (= mark gnus-unread-mark)
8673 (= mark gnus-ticked-mark)
8674 (= mark gnus-dormant-mark))
8675 (gnus-mark-article-as-unread article mark)
8676 (gnus-mark-article-as-read article mark)))
8678 ;; See whether the article is to be put in the cache.
8680 (not (= mark gnus-canceled-mark))
8681 (vectorp (gnus-summary-article-header article))
8683 (gnus-cache-possibly-enter-article
8684 gnus-newsgroup-name article
8685 (gnus-summary-article-header article)
8686 (= mark gnus-ticked-mark)
8687 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8689 (when (gnus-summary-goto-subject article nil t)
8690 (let ((buffer-read-only nil))
8691 (gnus-summary-show-thread)
8693 (gnus-summary-update-mark mark 'unread)
8696 (defun gnus-summary-update-secondary-mark (article)
8697 "Update the secondary (read, process, cache) mark."
8698 (gnus-summary-update-mark
8699 (cond ((memq article gnus-newsgroup-processable)
8701 ((memq article gnus-newsgroup-cached)
8703 ((memq article gnus-newsgroup-replied)
8705 ((memq article gnus-newsgroup-saved)
8709 (when (gnus-visual-p 'summary-highlight 'highlight)
8710 (gnus-run-hooks 'gnus-summary-update-hook))
8713 (defun gnus-summary-update-mark (mark type)
8714 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8715 (buffer-read-only nil))
8716 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8718 (when (looking-at "\r")
8720 (when (<= (+ forward (point)) (point-max))
8721 ;; Go to the right position on the line.
8722 (goto-char (+ forward (point)))
8723 ;; Replace the old mark with the new mark.
8724 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8725 ;; Optionally update the marks by some user rule.
8726 (when (eq type 'unread)
8728 (gnus-data-find (gnus-summary-article-number)) mark)
8729 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8731 (defun gnus-mark-article-as-read (article &optional mark)
8732 "Enter ARTICLE in the pertinent lists and remove it from others."
8733 ;; Make the article expirable.
8734 (let ((mark (or mark gnus-del-mark)))
8735 (if (= mark gnus-expirable-mark)
8736 (push article gnus-newsgroup-expirable)
8737 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8738 ;; Remove from unread and marked lists.
8739 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8740 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8741 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8742 (push (cons article mark) gnus-newsgroup-reads)
8743 ;; Possibly remove from cache, if that is used.
8744 (when gnus-use-cache
8745 (gnus-cache-enter-remove-article article))
8748 (defun gnus-mark-article-as-unread (article &optional mark)
8749 "Enter ARTICLE in the pertinent lists and remove it from others."
8750 (let ((mark (or mark gnus-ticked-mark)))
8753 (gnus-error 1 "Can't mark negative article numbers")
8755 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8756 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8757 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8758 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8760 ;; Unsuppress duplicates?
8761 (when gnus-suppress-duplicates
8762 (gnus-dup-unsuppress-article article))
8764 (cond ((= mark gnus-ticked-mark)
8765 (push article gnus-newsgroup-marked))
8766 ((= mark gnus-dormant-mark)
8767 (push article gnus-newsgroup-dormant))
8769 (push article gnus-newsgroup-unreads)))
8770 (gnus-pull article gnus-newsgroup-reads)
8773 (defalias 'gnus-summary-mark-as-unread-forward
8774 'gnus-summary-tick-article-forward)
8775 (make-obsolete 'gnus-summary-mark-as-unread-forward
8776 'gnus-summary-tick-article-forward)
8777 (defun gnus-summary-tick-article-forward (n)
8778 "Tick N articles forwards.
8779 If N is negative, tick backwards instead.
8780 The difference between N and the number of articles ticked is returned."
8782 (gnus-summary-mark-forward n gnus-ticked-mark))
8784 (defalias 'gnus-summary-mark-as-unread-backward
8785 'gnus-summary-tick-article-backward)
8786 (make-obsolete 'gnus-summary-mark-as-unread-backward
8787 'gnus-summary-tick-article-backward)
8788 (defun gnus-summary-tick-article-backward (n)
8789 "Tick N articles backwards.
8790 The difference between N and the number of articles ticked is returned."
8792 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8794 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8795 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8796 (defun gnus-summary-tick-article (&optional article clear-mark)
8797 "Mark current article as unread.
8798 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8799 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8801 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8804 (defun gnus-summary-mark-as-read-forward (n)
8805 "Mark N articles as read forwards.
8806 If N is negative, mark backwards instead.
8807 The difference between N and the actual number of articles marked is
8810 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8812 (defun gnus-summary-mark-as-read-backward (n)
8813 "Mark the N articles as read backwards.
8814 The difference between N and the actual number of articles marked is
8817 (gnus-summary-mark-forward
8818 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8820 (defun gnus-summary-mark-as-read (&optional article mark)
8821 "Mark current article as read.
8822 ARTICLE specifies the article to be marked as read.
8823 MARK specifies a string to be inserted at the beginning of the line."
8824 (gnus-summary-mark-article article mark))
8826 (defun gnus-summary-clear-mark-forward (n)
8827 "Clear marks from N articles forward.
8828 If N is negative, clear backward instead.
8829 The difference between N and the number of marks cleared is returned."
8831 (gnus-summary-mark-forward n gnus-unread-mark))
8833 (defun gnus-summary-clear-mark-backward (n)
8834 "Clear marks from N articles backward.
8835 The difference between N and the number of marks cleared is returned."
8837 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8839 (defun gnus-summary-mark-unread-as-read ()
8840 "Intended to be used by `gnus-summary-mark-article-hook'."
8841 (when (memq gnus-current-article gnus-newsgroup-unreads)
8842 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8844 (defun gnus-summary-mark-read-and-unread-as-read ()
8845 "Intended to be used by `gnus-summary-mark-article-hook'."
8846 (let ((mark (gnus-summary-article-mark)))
8847 (when (or (gnus-unread-mark-p mark)
8848 (gnus-read-mark-p mark))
8849 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8851 (defun gnus-summary-mark-unread-as-ticked ()
8852 "Intended to be used by `gnus-summary-mark-article-hook'."
8853 (when (memq gnus-current-article gnus-newsgroup-unreads)
8854 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8856 (defun gnus-summary-mark-region-as-read (point mark all)
8857 "Mark all unread articles between point and mark as read.
8858 If given a prefix, mark all articles between point and mark as read,
8859 even ticked and dormant ones."
8860 (interactive "r\nP")
8869 (memq (setq article (gnus-summary-article-number))
8870 gnus-newsgroup-unreads))
8871 (gnus-summary-mark-article article gnus-del-mark))
8873 (gnus-summary-find-next))))))
8875 (defun gnus-summary-mark-below (score mark)
8876 "Mark articles with score less than SCORE with MARK."
8877 (interactive "P\ncMark: ")
8878 (setq score (if score
8879 (prefix-numeric-value score)
8880 (or gnus-summary-default-score 0)))
8882 (set-buffer gnus-summary-buffer)
8883 (goto-char (point-min))
8886 (and (< (gnus-summary-article-score) score)
8887 (gnus-summary-mark-article nil mark))
8888 (gnus-summary-find-next)))))
8890 (defun gnus-summary-kill-below (&optional score)
8891 "Mark articles with score below SCORE as read."
8893 (gnus-summary-mark-below score gnus-killed-mark))
8895 (defun gnus-summary-clear-above (&optional score)
8896 "Clear all marks from articles with score above SCORE."
8898 (gnus-summary-mark-above score gnus-unread-mark))
8900 (defun gnus-summary-tick-above (&optional score)
8901 "Tick all articles with score above SCORE."
8903 (gnus-summary-mark-above score gnus-ticked-mark))
8905 (defun gnus-summary-mark-above (score mark)
8906 "Mark articles with score over SCORE with MARK."
8907 (interactive "P\ncMark: ")
8908 (setq score (if score
8909 (prefix-numeric-value score)
8910 (or gnus-summary-default-score 0)))
8912 (set-buffer gnus-summary-buffer)
8913 (goto-char (point-min))
8915 (when (> (gnus-summary-article-score) score)
8916 (gnus-summary-mark-article nil mark))
8918 (gnus-summary-find-next)))))
8920 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8921 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8922 (defun gnus-summary-limit-include-expunged (&optional no-error)
8923 "Display all the hidden articles that were expunged for low scores."
8925 (let ((buffer-read-only nil))
8926 (let ((scored gnus-newsgroup-scored)
8929 (unless (gnus-number-to-header (caar scored))
8930 (and (setq h (gnus-summary-article-header (caar scored)))
8931 (< (cdar scored) gnus-summary-expunge-below)
8933 (setq scored (cdr scored)))
8935 (when (not no-error)
8936 (error "No expunged articles hidden"))
8937 (goto-char (point-min))
8938 (gnus-summary-prepare-unthreaded (nreverse headers))
8939 (goto-char (point-min))
8940 (gnus-summary-position-point)
8943 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8944 "Mark all unread articles in this newsgroup as read.
8945 If prefix argument ALL is non-nil, ticked and dormant articles will
8946 also be marked as read.
8947 If QUIETLY is non-nil, no questions will be asked.
8948 If TO-HERE is non-nil, it should be a point in the buffer. All
8949 articles before this point will be marked as read.
8950 Note that this function will only catch up the unread article
8951 in the current summary buffer limitation.
8952 The number of articles marked as read is returned."
8957 (not gnus-interactive-catchup) ;Without confirmation?
8961 "Mark absolutely all articles as read? "
8962 "Mark all unread articles as read? ")))
8964 (not gnus-newsgroup-adaptive)
8965 (not gnus-newsgroup-auto-expire)
8966 (not gnus-suppress-duplicates)
8967 (or (not gnus-use-cache)
8968 (eq gnus-use-cache 'passive)))
8971 (setq gnus-newsgroup-marked nil
8972 gnus-newsgroup-dormant nil))
8973 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8974 ;; We actually mark all articles as canceled, which we
8975 ;; have to do when using auto-expiry or adaptive scoring.
8976 (gnus-summary-show-all-threads)
8977 (when (gnus-summary-first-subject (not all) t)
8979 (if to-here (< (point) to-here) t)
8980 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8981 (gnus-summary-find-next (not all) nil nil t))))
8982 (gnus-set-mode-line 'summary))
8984 (gnus-summary-position-point)))
8986 (defun gnus-summary-catchup-to-here (&optional all)
8987 "Mark all unticked articles before the current one as read.
8988 If ALL is non-nil, also mark ticked and dormant articles as read."
8991 (gnus-save-hidden-threads
8992 (let ((beg (point)))
8993 ;; We check that there are unread articles.
8994 (when (or all (gnus-summary-find-prev))
8995 (gnus-summary-catchup all t beg)))))
8996 (gnus-summary-position-point))
8998 (defun gnus-summary-catchup-all (&optional quietly)
8999 "Mark all articles in this newsgroup as read."
9001 (gnus-summary-catchup t quietly))
9003 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9004 "Mark all unread articles in this group as read, then exit.
9005 If prefix argument ALL is non-nil, all articles are marked as read."
9007 (when (gnus-summary-catchup all quietly nil 'fast)
9008 ;; Select next newsgroup or exit.
9009 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9010 (eq gnus-auto-select-next 'quietly))
9011 (gnus-summary-next-group nil)
9012 (gnus-summary-exit))))
9014 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9015 "Mark all articles in this newsgroup as read, and then exit."
9017 (gnus-summary-catchup-and-exit t quietly))
9019 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9020 "Mark all articles in this group as read and select the next group.
9021 If given a prefix, mark all articles, unread as well as ticked, as
9025 (gnus-summary-catchup all))
9026 (gnus-summary-next-group))
9032 (defmacro gnus-with-article (article &rest forms)
9033 "Select ARTICLE and perform FORMS in the original article buffer.
9034 Then replace the article with the result."
9036 ;; We don't want the article to be marked as read.
9037 (let (gnus-mark-article-hook)
9038 (gnus-summary-select-article t t nil ,article))
9039 (set-buffer gnus-original-article-buffer)
9041 (if (not (gnus-check-backend-function
9042 'request-replace-article (car gnus-article-current)))
9043 (gnus-message 5 "Read-only group; not replacing")
9044 (unless (gnus-request-replace-article
9045 ,article (car gnus-article-current)
9047 (error "Couldn't replace article")))
9048 ;; The cache and backlog have to be flushed somewhat.
9049 (when gnus-keep-backlog
9050 (gnus-backlog-remove-article
9051 (car gnus-article-current) (cdr gnus-article-current)))
9052 (when gnus-use-cache
9053 (gnus-cache-update-article
9054 (car gnus-article-current) (cdr gnus-article-current)))))
9056 (put 'gnus-with-article 'lisp-indent-function 1)
9057 (put 'gnus-with-article 'edebug-form-spec '(form body))
9059 ;; Thread-based commands.
9061 (defun gnus-summary-articles-in-thread (&optional article)
9062 "Return a list of all articles in the current thread.
9063 If ARTICLE is non-nil, return all articles in the thread that starts
9065 (let* ((article (or article (gnus-summary-article-number)))
9066 (data (gnus-data-find-list article))
9067 (top-level (gnus-data-level (car data)))
9069 (cond ((null gnus-thread-operation-ignore-subject)
9070 (gnus-simplify-subject-re
9071 (mail-header-subject (gnus-data-header (car data)))))
9072 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9073 (gnus-simplify-subject-fuzzy
9074 (mail-header-subject (gnus-data-header (car data)))))
9076 (end-point (save-excursion
9077 (if (gnus-summary-go-to-next-thread)
9078 (point) (point-max))))
9081 (< (gnus-data-pos (car data)) end-point))
9082 (when (or (not top-subject)
9083 (string= top-subject
9084 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9085 (gnus-simplify-subject-fuzzy
9086 (mail-header-subject
9087 (gnus-data-header (car data))))
9088 (gnus-simplify-subject-re
9089 (mail-header-subject
9090 (gnus-data-header (car data)))))))
9091 (push (gnus-data-number (car data)) articles))
9092 (unless (and (setq data (cdr data))
9093 (> (gnus-data-level (car data)) top-level))
9095 ;; Return the list of articles.
9096 (nreverse articles)))
9098 (defun gnus-summary-rethread-current ()
9099 "Rethread the thread the current article is part of."
9101 (let* ((gnus-show-threads t)
9102 (article (gnus-summary-article-number))
9103 (id (mail-header-id (gnus-summary-article-header)))
9104 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9106 (error "No article on the current line"))
9107 (gnus-rebuild-thread id)
9108 (gnus-summary-goto-subject article)))
9110 (defun gnus-summary-reparent-thread ()
9111 "Make the current article child of the marked (or previous) article.
9113 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9114 is non-nil or the Subject: of both articles are the same."
9116 (unless (not (gnus-group-read-only-p))
9117 (error "The current newsgroup does not support article editing"))
9118 (unless (<= (length gnus-newsgroup-processable) 1)
9119 (error "No more than one article may be marked"))
9120 (save-window-excursion
9121 (let ((gnus-article-buffer " *reparent*")
9122 (current-article (gnus-summary-article-number))
9123 ;; First grab the marked article, otherwise one line up.
9124 (parent-article (if (not (null gnus-newsgroup-processable))
9125 (car gnus-newsgroup-processable)
9127 (if (eq (forward-line -1) 0)
9128 (gnus-summary-article-number)
9129 (error "Beginning of summary buffer"))))))
9130 (unless (not (eq current-article parent-article))
9131 (error "An article may not be self-referential"))
9132 (let ((message-id (mail-header-id
9133 (gnus-summary-article-header parent-article))))
9134 (unless (and message-id (not (equal message-id "")))
9135 (error "No message-id in desired parent"))
9136 (gnus-with-article current-article
9138 (goto-char (point-min))
9139 (message-narrow-to-head)
9140 (if (re-search-forward "^References: " nil t)
9142 (re-search-forward "^[^ \t]" nil t)
9145 (insert " " message-id))
9146 (insert "References: " message-id "\n"))))
9147 (set-buffer gnus-summary-buffer)
9148 (gnus-summary-unmark-all-processable)
9149 (gnus-summary-update-article current-article)
9150 (gnus-summary-rethread-current)
9151 (gnus-message 3 "Article %d is now the child of article %d"
9152 current-article parent-article)))))
9154 (defun gnus-summary-toggle-threads (&optional arg)
9155 "Toggle showing conversation threads.
9156 If ARG is positive number, turn showing conversation threads on."
9158 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9159 (setq gnus-show-threads
9160 (if (null arg) (not gnus-show-threads)
9161 (> (prefix-numeric-value arg) 0)))
9162 (gnus-summary-prepare)
9163 (gnus-summary-goto-subject current)
9164 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9165 (gnus-summary-position-point)))
9167 (defun gnus-summary-show-all-threads ()
9171 (let ((buffer-read-only nil))
9172 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9173 (gnus-summary-position-point))
9175 (defun gnus-summary-show-thread ()
9176 "Show thread subtrees.
9177 Returns nil if no thread was there to be shown."
9179 (let ((buffer-read-only nil)
9181 ;; first goto end then to beg, to have point at beg after let
9182 (end (progn (end-of-line) (point)))
9183 (beg (progn (beginning-of-line) (point))))
9185 ;; Any hidden lines here?
9186 (search-forward "\r" end t)
9187 (subst-char-in-region beg end ?\^M ?\n t)
9189 (gnus-summary-position-point))))
9191 (defun gnus-summary-hide-all-threads ()
9192 "Hide all thread subtrees."
9195 (goto-char (point-min))
9196 (gnus-summary-hide-thread)
9197 (while (zerop (gnus-summary-next-thread 1 t))
9198 (gnus-summary-hide-thread)))
9199 (gnus-summary-position-point))
9201 (defun gnus-summary-hide-thread ()
9202 "Hide thread subtrees.
9203 Returns nil if no threads were there to be hidden."
9205 (let ((buffer-read-only nil)
9207 (article (gnus-summary-article-number)))
9209 ;; Go forward until either the buffer ends or the subthread
9211 (when (and (not (eobp))
9212 (or (zerop (gnus-summary-next-thread 1 t))
9213 (goto-char (point-max))))
9215 (if (and (> (point) start)
9216 (search-backward "\n" start t))
9218 (subst-char-in-region start (point) ?\n ?\^M)
9219 (gnus-summary-goto-subject article))
9223 (defun gnus-summary-go-to-next-thread (&optional previous)
9224 "Go to the same level (or less) next thread.
9225 If PREVIOUS is non-nil, go to previous thread instead.
9226 Return the article number moved to, or nil if moving was impossible."
9227 (let ((level (gnus-summary-thread-level))
9228 (way (if previous -1 1))
9231 (while (and (not (eobp))
9232 (< level (gnus-summary-thread-level)))
9240 (gnus-summary-article-number)
9243 (defun gnus-summary-next-thread (n &optional silent)
9244 "Go to the same level next N'th thread.
9245 If N is negative, search backward instead.
9246 Returns the difference between N and the number of skips actually
9249 If SILENT, don't output messages."
9251 (let ((backward (< n 0))
9254 (gnus-summary-go-to-next-thread backward))
9257 (gnus-summary-position-point))
9258 (when (and (not silent) (/= 0 n))
9259 (gnus-message 7 "No more threads"))
9262 (defun gnus-summary-prev-thread (n)
9263 "Go to the same level previous N'th thread.
9264 Returns the difference between N and the number of skips actually
9267 (gnus-summary-next-thread (- n)))
9269 (defun gnus-summary-go-down-thread ()
9270 "Go down one level in the current thread."
9271 (let ((children (gnus-summary-article-children)))
9273 (gnus-summary-goto-subject (car children)))))
9275 (defun gnus-summary-go-up-thread ()
9276 "Go up one level in the current thread."
9277 (let ((parent (gnus-summary-article-parent)))
9279 (gnus-summary-goto-subject parent))))
9281 (defun gnus-summary-down-thread (n)
9282 "Go down thread N steps.
9283 If N is negative, go up instead.
9284 Returns the difference between N and how many steps down that were
9290 (if up (gnus-summary-go-up-thread)
9291 (gnus-summary-go-down-thread)))
9293 (gnus-summary-position-point)
9295 (gnus-message 7 "Can't go further"))
9298 (defun gnus-summary-up-thread (n)
9299 "Go up thread N steps.
9300 If N is negative, go up instead.
9301 Returns the difference between N and how many steps down that were
9304 (gnus-summary-down-thread (- n)))
9306 (defun gnus-summary-top-thread ()
9307 "Go to the top of the thread."
9309 (while (gnus-summary-go-up-thread))
9310 (gnus-summary-article-number))
9312 (defun gnus-summary-kill-thread (&optional unmark)
9313 "Mark articles under current thread as read.
9314 If the prefix argument is positive, remove any kinds of marks.
9315 If the prefix argument is negative, tick articles instead."
9318 (setq unmark (prefix-numeric-value unmark)))
9319 (let ((articles (gnus-summary-articles-in-thread)))
9321 ;; Expand the thread.
9322 (gnus-summary-show-thread)
9323 ;; Mark all the articles.
9325 (gnus-summary-goto-subject (car articles))
9326 (cond ((null unmark)
9327 (gnus-summary-mark-article-as-read gnus-killed-mark))
9329 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9331 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9332 (setq articles (cdr articles))))
9333 ;; Hide killed subtrees.
9335 gnus-thread-hide-killed
9336 (gnus-summary-hide-thread))
9337 ;; If marked as read, go to next unread subject.
9339 ;; Go to next unread subject.
9340 (gnus-summary-next-subject 1 t)))
9341 (gnus-set-mode-line 'summary))
9343 ;; Summary sorting commands
9345 (defun gnus-summary-sort-by-number (&optional reverse)
9346 "Sort the summary buffer by article number.
9347 Argument REVERSE means reverse order."
9349 (gnus-summary-sort 'number reverse))
9351 (defun gnus-summary-sort-by-author (&optional reverse)
9352 "Sort the summary buffer by author name alphabetically.
9353 If `case-fold-search' is non-nil, case of letters is ignored.
9354 Argument REVERSE means reverse order."
9356 (gnus-summary-sort 'author reverse))
9358 (defun gnus-summary-sort-by-subject (&optional reverse)
9359 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9360 If `case-fold-search' is non-nil, case of letters is ignored.
9361 Argument REVERSE means reverse order."
9363 (gnus-summary-sort 'subject reverse))
9365 (defun gnus-summary-sort-by-date (&optional reverse)
9366 "Sort the summary buffer by date.
9367 Argument REVERSE means reverse order."
9369 (gnus-summary-sort 'date reverse))
9371 (defun gnus-summary-sort-by-score (&optional reverse)
9372 "Sort the summary buffer by score.
9373 Argument REVERSE means reverse order."
9375 (gnus-summary-sort 'score reverse))
9377 (defun gnus-summary-sort-by-lines (&optional reverse)
9378 "Sort the summary buffer by the number of lines.
9379 Argument REVERSE means reverse order."
9381 (gnus-summary-sort 'lines reverse))
9383 (defun gnus-summary-sort-by-chars (&optional reverse)
9384 "Sort the summary buffer by article length.
9385 Argument REVERSE means reverse order."
9387 (gnus-summary-sort 'chars reverse))
9389 (defun gnus-summary-sort (predicate reverse)
9390 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9391 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9392 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9393 (gnus-thread-sort-functions
9398 (gnus-sort-gathered-threads-function
9399 gnus-thread-sort-functions)
9400 (gnus-article-sort-functions
9406 (gnus-summary-prepare-hook nil))
9407 ;; We do the sorting by regenerating the threads.
9408 (gnus-summary-prepare)
9409 ;; Hide subthreads if needed.
9410 (when (and gnus-show-threads gnus-thread-hide-subtree)
9411 (gnus-summary-hide-all-threads))))
9413 ;; Summary saving commands.
9415 (defun gnus-summary-save-article (&optional n not-saved)
9416 "Save the current article using the default saver function.
9417 If N is a positive number, save the N next articles.
9418 If N is a negative number, save the N previous articles.
9419 If N is nil and any articles have been marked with the process mark,
9420 save those articles instead.
9421 The variable `gnus-default-article-saver' specifies the saver function."
9423 (let* ((articles (gnus-summary-work-articles n))
9424 (save-buffer (save-excursion
9425 (nnheader-set-temp-buffer " *Gnus Save*")))
9426 (num (length articles))
9428 (dolist (article articles)
9429 (setq header (gnus-summary-article-header article))
9430 (if (not (vectorp header))
9431 ;; This is a pseudo-article.
9432 (if (assq 'name header)
9433 (gnus-copy-file (cdr (assq 'name header)))
9434 (gnus-message 1 "Article %d is unsaveable" article))
9435 ;; This is a real article.
9436 (save-window-excursion
9437 (gnus-summary-select-article t nil nil article))
9439 (set-buffer save-buffer)
9441 (insert-buffer-substring gnus-original-article-buffer))
9442 (setq file (gnus-article-save save-buffer file num))
9443 (gnus-summary-remove-process-mark article)
9445 (gnus-summary-set-saved-mark article))))
9446 (gnus-kill-buffer save-buffer)
9447 (gnus-summary-position-point)
9448 (gnus-set-mode-line 'summary)
9451 (defun gnus-summary-pipe-output (&optional arg)
9452 "Pipe the current article to a subprocess.
9453 If N is a positive number, pipe the N next articles.
9454 If N is a negative number, pipe the N previous articles.
9455 If N is nil and any articles have been marked with the process mark,
9456 pipe those articles instead."
9459 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9460 (gnus-summary-save-article arg t))
9461 (gnus-configure-windows 'pipe))
9463 (defun gnus-summary-save-article-mail (&optional arg)
9464 "Append the current article to an mail file.
9465 If N is a positive number, save the N next articles.
9466 If N is a negative number, save the N previous articles.
9467 If N is nil and any articles have been marked with the process mark,
9468 save those articles instead."
9471 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9472 (gnus-summary-save-article arg)))
9474 (defun gnus-summary-save-article-rmail (&optional arg)
9475 "Append the current article to an rmail file.
9476 If N is a positive number, save the N next articles.
9477 If N is a negative number, save the N previous articles.
9478 If N is nil and any articles have been marked with the process mark,
9479 save those articles instead."
9482 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9483 (gnus-summary-save-article arg)))
9485 (defun gnus-summary-save-article-file (&optional arg)
9486 "Append the current article to a file.
9487 If N is a positive number, save the N next articles.
9488 If N is a negative number, save the N previous articles.
9489 If N is nil and any articles have been marked with the process mark,
9490 save those articles instead."
9493 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9494 (gnus-summary-save-article arg)))
9496 (defun gnus-summary-write-article-file (&optional arg)
9497 "Write the current article to a file, deleting the previous file.
9498 If N is a positive number, save the N next articles.
9499 If N is a negative number, save the N previous articles.
9500 If N is nil and any articles have been marked with the process mark,
9501 save those articles instead."
9504 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9505 (gnus-summary-save-article arg)))
9507 (defun gnus-summary-save-article-body-file (&optional arg)
9508 "Append the current article body to a file.
9509 If N is a positive number, save the N next articles.
9510 If N is a negative number, save the N previous articles.
9511 If N is nil and any articles have been marked with the process mark,
9512 save those articles instead."
9515 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9516 (gnus-summary-save-article arg)))
9518 (defun gnus-summary-pipe-message (program)
9519 "Pipe the current article through PROGRAM."
9520 (interactive "sProgram: ")
9521 (gnus-summary-select-article)
9522 (let ((mail-header-separator ""))
9523 (gnus-eval-in-buffer-window gnus-article-buffer
9526 (let ((start (window-start))
9528 (message-pipe-buffer-body program)
9529 (set-window-start (get-buffer-window (current-buffer)) start))))))
9531 (defun gnus-get-split-value (methods)
9532 "Return a value based on the split METHODS."
9533 (let (split-name method result match)
9536 (set-buffer gnus-original-article-buffer)
9538 (nnheader-narrow-to-headers)
9539 (while (and methods (not split-name))
9540 (goto-char (point-min))
9541 (setq method (pop methods))
9542 (setq match (car method))
9545 ;; Regular expression.
9547 (re-search-forward match nil t)))
9548 ((gnus-functionp match)
9552 (setq result (funcall match gnus-newsgroup-name))))
9557 (setq result (eval match)))))
9558 (setq split-name (cdr method))
9559 (cond ((stringp result)
9560 (push (expand-file-name
9561 result gnus-article-save-directory)
9564 (setq split-name (append result split-name)))))))))
9565 (nreverse split-name)))
9567 (defun gnus-valid-move-group-p (group)
9570 (symbol-value group)
9571 (gnus-get-function (gnus-find-method-for-group
9572 (symbol-name group)) 'request-accept-article t)))
9574 (defun gnus-read-move-group-name (prompt default articles prefix)
9575 "Read a group name."
9576 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9577 (minibuffer-confirm-incomplete nil) ; XEmacs
9581 (if (> (length articles) 1)
9582 (format "these %d articles" (length articles))
9587 (gnus-completing-read default prom
9589 'gnus-valid-move-group-p
9591 'gnus-group-history))
9592 ((= 1 (length split-name))
9593 (gnus-completing-read (car split-name) prom
9595 'gnus-valid-move-group-p
9597 'gnus-group-history))
9599 (gnus-completing-read nil prom
9600 (mapcar (lambda (el) (list el))
9601 (nreverse split-name))
9603 'gnus-group-history))))
9604 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9606 (if (or (string= to-newsgroup "")
9607 (string= to-newsgroup prefix))
9608 (setq to-newsgroup default))
9609 (unless to-newsgroup
9610 (error "No group name entered"))
9611 (or (gnus-active to-newsgroup)
9612 (gnus-activate-group to-newsgroup nil nil to-method)
9613 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9615 (or (and (gnus-request-create-group to-newsgroup to-method)
9616 (gnus-activate-group
9617 to-newsgroup nil nil to-method)
9618 (gnus-subscribe-group to-newsgroup))
9619 (error "Couldn't create group %s" to-newsgroup)))
9620 (error "No such group: %s" to-newsgroup)))
9623 (defun gnus-summary-save-parts (type dir n &optional reverse)
9624 "Save parts matching TYPE to DIR.
9625 If REVERSE, save parts that do not match TYPE."
9627 (list (read-string "Save parts of type: "
9628 (or (car gnus-summary-save-parts-type-history)
9629 gnus-summary-save-parts-default-mime)
9630 'gnus-summary-save-parts-type-history)
9631 (setq gnus-summary-save-parts-last-directory
9632 (read-file-name "Save to directory: "
9633 gnus-summary-save-parts-last-directory
9635 current-prefix-arg))
9636 (gnus-summary-iterate n
9637 (let ((gnus-display-mime-function nil)
9638 (gnus-inhibit-treatment t))
9639 (gnus-summary-select-article))
9641 (set-buffer gnus-article-buffer)
9642 (let ((handles (or gnus-article-mime-handles
9643 (mm-dissect-buffer) (mm-uu-dissect))))
9645 (gnus-summary-save-parts-1 type dir handles reverse)
9646 (unless gnus-article-mime-handles ;; Don't destroy this case.
9647 (mm-destroy-parts handles)))))))
9649 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9650 (if (stringp (car handle))
9651 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9654 (not (string-match type (mm-handle-media-type handle)))
9655 (string-match type (mm-handle-media-type handle)))
9656 (let ((file (expand-file-name
9657 (file-name-nondirectory
9659 (mail-content-type-get
9660 (mm-handle-disposition handle) 'filename)
9661 (concat gnus-newsgroup-name
9662 "." (number-to-string
9663 (cdr gnus-article-current)))))
9665 (unless (file-exists-p file)
9666 (mm-save-part-to-file handle file))))))
9668 ;; Summary extract commands
9670 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9671 (let ((buffer-read-only nil)
9672 (article (gnus-summary-article-number))
9674 (unless (gnus-summary-goto-subject article)
9675 (error "No such article: %d" article))
9676 (gnus-summary-position-point)
9677 ;; If all commands are to be bunched up on one line, we collect
9679 (unless gnus-view-pseudos-separately
9680 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9683 (setq action (cdr (assq 'action (car ps))))
9684 (setq files (list (cdr (assq 'name (car ps)))))
9685 (while (and ps (cdr ps)
9686 (string= (or action "1")
9687 (or (cdr (assq 'action (cadr ps))) "2")))
9688 (push (cdr (assq 'name (cadr ps))) files)
9689 (setcdr ps (cddr ps)))
9691 (when (not (string-match "%s" action))
9694 (when (assq 'execute (car ps))
9695 (setcdr (assq 'execute (car ps))
9696 (funcall (if (string-match "%s" action)
9703 (gnus-quote-arg-for-sh-or-csh f)))
9705 (setq ps (cdr ps)))))
9706 (if (and gnus-view-pseudos (not not-view))
9708 (when (assq 'execute (car pslist))
9709 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9710 (eq gnus-view-pseudos 'not-confirm)))
9711 (setq pslist (cdr pslist)))
9714 (setq after-article (or (cdr (assq 'article (car pslist)))
9715 (gnus-summary-article-number)))
9716 (gnus-summary-goto-subject after-article)
9719 (insert " " (file-name-nondirectory
9720 (cdr (assq 'name (car pslist))))
9721 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9723 (forward-line -1) ; back to `b'
9724 (gnus-add-text-properties
9725 b (1- e) (list 'gnus-number gnus-reffed-article-number
9726 gnus-mouse-face-prop gnus-mouse-face))
9728 after-article gnus-reffed-article-number
9729 gnus-unread-mark b (car pslist) 0 (- e b))
9730 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9731 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9732 (setq pslist (cdr pslist)))))))
9734 (defun gnus-pseudos< (p1 p2)
9735 (let ((c1 (cdr (assq 'action p1)))
9736 (c2 (cdr (assq 'action p2))))
9737 (and c1 c2 (string< c1 c2))))
9739 (defun gnus-request-pseudo-article (props)
9740 (cond ((assq 'execute props)
9741 (gnus-execute-command (cdr (assq 'execute props)))))
9742 (let ((gnus-current-article (gnus-summary-article-number)))
9743 (gnus-run-hooks 'gnus-mark-article-hook)))
9745 (defun gnus-execute-command (command &optional automatic)
9747 (gnus-article-setup-buffer)
9748 (set-buffer gnus-article-buffer)
9749 (setq buffer-read-only nil)
9750 (let ((command (if automatic command
9751 (read-string "Command: " (cons command 0)))))
9753 (insert "$ " command "\n\n")
9754 (if gnus-view-pseudo-asynchronously
9755 (start-process "gnus-execute" (current-buffer) shell-file-name
9756 shell-command-switch command)
9757 (call-process shell-file-name nil t nil
9758 shell-command-switch command)))))
9760 ;; Summary kill commands.
9762 (defun gnus-summary-edit-global-kill (article)
9763 "Edit the \"global\" kill file."
9764 (interactive (list (gnus-summary-article-number)))
9765 (gnus-group-edit-global-kill article))
9767 (defun gnus-summary-edit-local-kill ()
9768 "Edit a local kill file applied to the current newsgroup."
9770 (setq gnus-current-headers (gnus-summary-article-header))
9771 (gnus-group-edit-local-kill
9772 (gnus-summary-article-number) gnus-newsgroup-name))
9776 (defun gnus-read-header (id &optional header)
9777 "Read the headers of article ID and enter them into the Gnus system."
9778 (let ((group gnus-newsgroup-name)
9779 (gnus-override-method
9781 gnus-override-method
9782 (and (gnus-news-group-p gnus-newsgroup-name)
9783 (car (gnus-refer-article-methods)))))
9785 ;; First we check to see whether the header in question is already
9788 ;; This is a Message-ID.
9789 (setq header (or header (gnus-id-to-header id)))
9790 ;; This is an article number.
9791 (setq header (or header (gnus-summary-article-header id))))
9793 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9794 ;; We have found the header.
9796 ;; If this is a sparse article, we have to nix out its
9797 ;; previous entry in the thread hashtb.
9799 (gnus-summary-article-sparse-p (mail-header-number header)))
9800 (let* ((parent (gnus-parent-id (mail-header-references header)))
9801 (thread (and parent (gnus-id-to-thread parent))))
9803 (delq (assq header thread) thread))))
9804 ;; We have to really fetch the header to this article.
9806 (set-buffer nntp-server-buffer)
9807 (when (setq where (gnus-request-head id group))
9808 (nnheader-fold-continuation-lines)
9809 (goto-char (point-max))
9811 (goto-char (point-min))
9815 ((cdr where) (cdr where))
9816 (header (mail-header-number header))
9817 (t gnus-reffed-article-number))
9819 (insert " Article retrieved.\n"))
9821 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9822 () ; Malformed head.
9823 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9824 (when (and (stringp id)
9825 (not (string= (gnus-group-real-name group)
9827 ;; If we fetched by Message-ID and the article came
9828 ;; from a different group, we fudge some bogus article
9829 ;; numbers for this article.
9830 (mail-header-set-number header gnus-reffed-article-number))
9832 (set-buffer gnus-summary-buffer)
9833 (decf gnus-reffed-article-number)
9834 (gnus-remove-header (mail-header-number header))
9835 (push header gnus-newsgroup-headers)
9836 (setq gnus-current-headers header)
9837 (push (mail-header-number header) gnus-newsgroup-limit)))
9840 (defun gnus-remove-header (number)
9841 "Remove header NUMBER from `gnus-newsgroup-headers'."
9842 (if (and gnus-newsgroup-headers
9843 (= number (mail-header-number (car gnus-newsgroup-headers))))
9844 (pop gnus-newsgroup-headers)
9845 (let ((headers gnus-newsgroup-headers))
9846 (while (and (cdr headers)
9847 (not (= number (mail-header-number (cadr headers)))))
9850 (setcdr headers (cddr headers))))))
9853 ;;; summary highlights
9856 (defun gnus-highlight-selected-summary ()
9857 "Highlight selected article in summary buffer."
9858 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9859 (when gnus-summary-selected-face
9861 (let* ((beg (progn (beginning-of-line) (point)))
9862 (end (progn (end-of-line) (point)))
9863 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9864 (from (if (get-text-property beg gnus-mouse-face-prop)
9866 (or (next-single-property-change
9867 beg gnus-mouse-face-prop nil end)
9872 (or (next-single-property-change
9873 from gnus-mouse-face-prop nil end)
9875 ;; If no mouse-face prop on line we will have to = from = end,
9876 ;; so we highlight the entire line instead.
9877 (when (= (+ to 2) from)
9880 (if gnus-newsgroup-selected-overlay
9881 ;; Move old overlay.
9883 gnus-newsgroup-selected-overlay from to (current-buffer))
9884 ;; Create new overlay.
9886 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9887 'face gnus-summary-selected-face))))))
9889 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9890 (defun gnus-summary-highlight-line ()
9891 "Highlight current line according to `gnus-summary-highlight'."
9892 (let* ((list gnus-summary-highlight)
9894 (end (progn (end-of-line) (point)))
9895 ;; now find out where the line starts and leave point there.
9896 (beg (progn (beginning-of-line) (point)))
9897 (article (gnus-summary-article-number))
9898 (score (or (cdr (assq (or article gnus-current-article)
9899 gnus-newsgroup-scored))
9900 gnus-summary-default-score 0))
9901 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9902 (inhibit-read-only t))
9903 ;; Eval the cars of the lists until we find a match.
9904 (let ((default gnus-summary-default-score))
9906 (not (eval (caar list))))
9907 (setq list (cdr list))))
9908 (let ((face (cdar list)))
9909 (unless (eq face (get-text-property beg 'face))
9910 (gnus-put-text-property-excluding-characters-with-faces
9912 (setq face (if (boundp face) (symbol-value face) face)))
9913 (when gnus-summary-highlight-line-function
9914 (funcall gnus-summary-highlight-line-function article face))))
9917 (defun gnus-update-read-articles (group unread &optional compute)
9918 "Update the list of read articles in GROUP."
9919 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9920 (entry (gnus-gethash group gnus-newsrc-hashtb))
9921 (info (nth 2 entry))
9923 (unread (sort (copy-sequence unread) '<))
9925 (if (or (not info) (not active))
9926 ;; There is no info on this group if it was, in fact,
9927 ;; killed. Gnus stores no information on killed groups, so
9928 ;; there's nothing to be done.
9929 ;; One could store the information somewhere temporarily,
9930 ;; perhaps... Hmmm...
9932 ;; Remove any negative articles numbers.
9933 (while (and unread (< (car unread) 0))
9934 (setq unread (cdr unread)))
9935 ;; Remove any expired article numbers
9936 (while (and unread (< (car unread) (car active)))
9937 (setq unread (cdr unread)))
9938 ;; Compute the ranges of read articles by looking at the list of
9941 (when (/= (car unread) prev)
9942 (push (if (= prev (1- (car unread))) prev
9943 (cons prev (1- (car unread))))
9945 (setq prev (1+ (car unread)))
9946 (setq unread (cdr unread)))
9947 (when (<= prev (cdr active))
9948 (push (cons prev (cdr active)) read))
9949 (setq read (if (> (length read) 1) (nreverse read) read))
9954 ;; Propagate the read marks to the backend.
9955 (when (gnus-check-backend-function 'request-set-mark group)
9956 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9957 (add (gnus-remove-from-range read (gnus-info-read info))))
9959 (unless (gnus-check-group group)
9960 (error "Can't open server for %s" group))
9961 (gnus-request-set-mark
9962 group (delq nil (list (if add (list add 'add '(read)))
9963 (if del (list del 'del '(read))))))
9965 `(gnus-request-set-mark
9968 (if del (list del 'add '(read)))
9969 (if add (list add 'del '(read))))))))))
9970 (set-buffer gnus-group-buffer)
9973 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9974 (gnus-info-set-read ',info ',(gnus-info-read info))
9975 (gnus-get-unread-articles-in-group ',info
9976 (gnus-active ,group))
9977 (gnus-group-update-group ,group t)
9979 ;; Enter this list into the group info.
9980 (gnus-info-set-read info read)
9981 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9982 (gnus-get-unread-articles-in-group info (gnus-active group))
9985 (defun gnus-offer-save-summaries ()
9986 "Offer to save all active summary buffers."
9988 (let ((buflist (buffer-list))
9990 ;; Go through all buffers and find all summaries.
9992 (and (setq bufname (buffer-name (car buflist)))
9993 (string-match "Summary" bufname)
9995 (set-buffer bufname)
9996 ;; We check that this is, indeed, a summary buffer.
9997 (and (eq major-mode 'gnus-summary-mode)
9998 ;; Also make sure this isn't bogus.
9999 gnus-newsgroup-prepared
10000 ;; Also make sure that this isn't a dead summary buffer.
10001 (not gnus-dead-summary-mode)))
10002 (push bufname buffers))
10003 (setq buflist (cdr buflist)))
10004 ;; Go through all these summary buffers and offer to save them.
10007 "Update summary buffer %s? "
10009 (switch-to-buffer buf)
10010 (gnus-summary-exit))
10014 ;;; @ for mime-partial
10017 (defun gnus-request-partial-message ()
10019 (let ((number (gnus-summary-article-number))
10020 (group gnus-newsgroup-name)
10021 (mother gnus-article-buffer))
10022 (set-buffer (get-buffer-create " *Partial Article*"))
10024 (setq mime-preview-buffer mother)
10025 (gnus-request-article-this-buffer number group)
10026 (mime-parse-buffer)
10029 (autoload 'mime-combine-message/partial-pieces-automatically
10031 "Internal method to combine message/partial messages automatically.")
10033 (mime-add-condition
10034 'action '((type . message)(subtype . partial)
10035 (major-mode . gnus-original-article-mode)
10036 (method . mime-combine-message/partial-pieces-automatically)
10037 (summary-buffer-exp . gnus-summary-buffer)
10038 (request-partial-message-method . gnus-request-partial-message)
10042 ;;; @ for message/rfc822
10045 (defun gnus-mime-extract-message/rfc822 (entity situation)
10046 (let (group article num cwin swin cur)
10048 (mime-insert-entity-content entity)
10049 (setq group (or (cdr (assq 'group situation))
10050 (completing-read "Group: "
10053 (gnus-read-active-file-p)
10054 gnus-newsgroup-name))
10055 article (gnus-request-accept-article group)))
10056 (when (and (consp article)
10057 (numberp (setq article (cdr article))))
10058 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10059 cwin (get-buffer-window (current-buffer) t))
10060 (save-window-excursion
10061 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10062 (select-window swin)
10063 (set-buffer gnus-summary-buffer))
10064 (setq cur gnus-current-article)
10066 (let (gnus-show-threads)
10067 (gnus-summary-goto-subject article t))
10068 (gnus-summary-clear-mark-forward 1)
10069 (gnus-summary-goto-subject cur))
10070 (when (and cwin (window-frame cwin))
10071 (select-frame (window-frame cwin)))
10072 (when (boundp 'mime-acting-situation-to-override)
10073 (set-alist 'mime-acting-situation-to-override
10076 (set-alist 'mime-acting-situation-to-override
10079 (save-current-buffer
10080 (set-buffer gnus-group-buffer)
10081 (gnus-activate-group ,group))
10082 (gnus-summary-goto-article ,cur
10083 gnus-show-all-headers)))
10084 (set-alist 'mime-acting-situation-to-override
10087 (mime-add-condition
10088 'action '((type . message)(subtype . rfc822)
10089 (major-mode . gnus-original-article-mode)
10090 (method . gnus-mime-extract-message/rfc822)
10094 (mime-add-condition
10095 'action '((type . message)(subtype . news)
10096 (major-mode . gnus-original-article-mode)
10097 (method . gnus-mime-extract-message/rfc822)
10101 (defun gnus-mime-extract-multipart (entity situation)
10102 (let ((children (mime-entity-children entity))
10103 mime-acting-situation-to-override
10106 (mime-play-entity (car children)
10107 (cons (assq 'mode situation)
10108 mime-acting-situation-to-override))
10109 (setq children (cdr children)))
10110 (if (setq f (cdr (assq 'after-method
10111 mime-acting-situation-to-override)))
10115 (mime-add-condition
10116 'action '((type . multipart)
10117 (method . gnus-mime-extract-multipart)
10126 (defun gnus-summary-setup-default-charset ()
10127 "Setup newsgroup default charset."
10128 (if (equal gnus-newsgroup-name "nndraft:drafts")
10129 (setq gnus-newsgroup-charset nil)
10130 (let* ((name (and gnus-newsgroup-name
10131 (gnus-group-real-name gnus-newsgroup-name)))
10133 (or gnus-newsgroup-ephemeral-ignored-charsets
10135 (and gnus-newsgroup-name
10136 (or (gnus-group-find-parameter gnus-newsgroup-name
10137 'ignored-charsets t)
10138 (let ((alist gnus-group-ignored-charsets-alist)
10139 elem (charsets nil))
10140 (while (setq elem (pop alist))
10142 (string-match (car elem) name))
10144 charsets (cdr elem))))
10146 gnus-newsgroup-ignored-charsets))))
10147 (setq gnus-newsgroup-charset
10148 (or gnus-newsgroup-ephemeral-charset
10149 (and gnus-newsgroup-name
10150 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
10151 (let ((alist gnus-group-charset-alist)
10153 (while (setq elem (pop alist))
10155 (string-match (car elem) name))
10157 charset (cadr elem))))
10159 gnus-default-charset))
10160 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10161 ignored-charsets))))
10167 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10168 "Display the current article buffer fully MIME-buttonized.
10169 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10170 treated as multipart/mixed."
10172 (require 'gnus-art)
10173 (let ((gnus-unbuttonized-mime-types nil)
10174 (gnus-mime-display-multipart-as-mixed show-all-parts))
10175 (gnus-summary-show-article)))
10177 (defun gnus-summary-repair-multipart (article)
10178 "Add a Content-Type header to a multipart article without one."
10179 (interactive (list (gnus-summary-article-number)))
10180 (gnus-with-article article
10181 (message-narrow-to-head)
10182 (message-remove-header "Mime-Version")
10183 (goto-char (point-max))
10184 (insert "Mime-Version: 1.0\n")
10186 (when (search-forward "\n--" nil t)
10187 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10188 (message-narrow-to-head)
10189 (message-remove-header "Content-Type")
10190 (goto-char (point-max))
10191 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10194 (let (gnus-mark-article-hook)
10195 (gnus-summary-select-article t t nil article)))
10197 (defun gnus-summary-toggle-display-buttonized ()
10198 "Toggle the buttonizing of the article buffer."
10200 (require 'gnus-art)
10201 (if (setq gnus-inhibit-mime-unbuttonizing
10202 (not gnus-inhibit-mime-unbuttonizing))
10203 (let ((gnus-unbuttonized-mime-types nil))
10204 (gnus-summary-show-article))
10205 (gnus-summary-show-article)))
10208 ;;; Intelli-mouse commmands
10211 (defun gnus-wheel-summary-scroll (event)
10213 (let ((amount (if (memq 'shift (event-modifiers event))
10214 (car gnus-wheel-scroll-amount)
10215 (cdr gnus-wheel-scroll-amount)))
10216 (direction (- (* (static-if (featurep 'xemacs)
10217 (event-button event)
10218 (cond ((eq 'mouse-4 (event-basic-type event))
10220 ((eq 'mouse-5 (event-basic-type event))
10224 (gnus-summary-scroll-up (* amount direction))
10225 (when (gnus-eval-in-buffer-window gnus-article-buffer
10228 (and (if (< 0 direction)
10229 (gnus-article-next-page 0)
10230 (gnus-article-prev-page 0)
10232 (if (setq edge (get-text-property
10233 (point-min) 'gnus-wheel-edge))
10234 (setq edge (* edge direction))
10237 (let ((buffer-read-only nil)
10238 (inhibit-read-only t))
10239 (put-text-property (point-min) (point-max)
10240 'gnus-wheel-edge direction)
10242 (or (> edge gnus-wheel-edge-resistance)
10243 (let ((buffer-read-only nil)
10244 (inhibit-read-only t))
10245 (put-text-property (point-min) (point-max)
10247 (* (1+ edge) direction))
10249 (eq last-command 'gnus-wheel-summary-scroll))))
10250 (gnus-summary-next-article nil nil (minusp direction)))))
10252 (defun gnus-wheel-install ()
10253 "Enable mouse wheel support on summary window."
10254 (when gnus-use-wheel
10256 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10258 (define-key gnus-summary-mode-map key
10259 'gnus-wheel-summary-scroll)))))
10261 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10264 ;;; Traditional PGP commmands
10267 (defun gnus-summary-decrypt-article (&optional force)
10268 "Decrypt the current article in traditional PGP way.
10269 This will have permanent effect only in mail groups.
10270 If FORCE is non-nil, allow editing of articles even in read-only
10273 (gnus-summary-select-article t)
10274 (gnus-eval-in-buffer-window gnus-article-buffer
10278 (goto-char (point-min))
10279 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10280 (error "Not a traditional PGP message!"))
10281 (let ((armor-start (match-beginning 0)))
10282 (if (and (pgg-decrypt-region armor-start (point-max))
10283 (or force (not (gnus-group-read-only-p))))
10284 (let ((inhibit-read-only t)
10286 (delete-region armor-start
10288 (re-search-forward "^-+END PGP" nil t)
10289 (beginning-of-line 2)
10291 (insert-buffer-substring pgg-output-buffer))))))))
10293 (defun gnus-summary-verify-article ()
10294 "Verify the current article in traditional PGP way."
10297 (set-buffer gnus-original-article-buffer)
10298 (goto-char (point-min))
10299 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10300 (error "Not a traditional PGP message!"))
10301 (re-search-forward "^-+END PGP" nil t)
10302 (beginning-of-line 2)
10303 (call-interactively (function pgg-verify-region))))
10306 ;;; Generic summary marking commands
10309 (defvar gnus-summary-marking-alist
10310 '((read gnus-del-mark "d")
10311 (unread gnus-unread-mark "u")
10312 (ticked gnus-ticked-mark "!")
10313 (dormant gnus-dormant-mark "?")
10314 (expirable gnus-expirable-mark "e"))
10315 "An alist of names/marks/keystrokes.")
10317 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10318 (defvar gnus-summary-mark-map)
10320 (defun gnus-summary-make-all-marking-commands ()
10321 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10322 (dolist (elem gnus-summary-marking-alist)
10323 (apply 'gnus-summary-make-marking-command elem)))
10325 (defun gnus-summary-make-marking-command (name mark keystroke)
10326 (let ((map (make-sparse-keymap)))
10327 (define-key gnus-summary-generic-mark-map keystroke map)
10328 (dolist (lway `((next "next" next nil "n")
10329 (next-unread "next unread" next t "N")
10330 (prev "previous" prev nil "p")
10331 (prev-unread "previous unread" prev t "P")
10332 (nomove "" nil nil ,keystroke)))
10333 (let ((func (gnus-summary-make-marking-command-1
10334 mark (car lway) lway name)))
10335 (setq func (eval func))
10336 (define-key map (nth 4 lway) func)))))
10338 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10340 (format "gnus-summary-put-mark-as-%s%s"
10341 name (if (eq way 'nomove)
10343 (concat "-" (symbol-name way)))))
10346 "Mark the current article as %s%s.
10347 If N, the prefix, then repeat N times.
10348 If N is negative, move in reverse order.
10349 The difference between N and the actual number of articles marked is
10351 name (car (cdr lway)))
10353 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10355 (defun gnus-summary-generic-mark (n mark move unread)
10356 "Mark N articles with MARK."
10357 (unless (eq major-mode 'gnus-summary-mode)
10358 (error "This command can only be used in the summary buffer"))
10359 (gnus-summary-show-thread)
10362 ((eq move 'next) 1)
10363 ((eq move 'prev) -1)
10365 (if (zerop nummove)
10369 nummove (* -1 nummove))))
10370 (while (and (> n 0)
10371 (gnus-summary-mark-article nil mark)
10372 (zerop (gnus-summary-next-subject nummove unread t)))
10375 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10376 (gnus-summary-recenter)
10377 (gnus-summary-position-point)
10378 (gnus-set-mode-line 'summary)
10381 (gnus-summary-make-all-marking-commands)
10383 (gnus-ems-redefine)
10385 (provide 'gnus-sum)
10387 (run-hooks 'gnus-sum-load-hook)
10389 ;;; gnus-sum.el ends here