1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
38 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (defcustom gnus-kill-summary-on-exit t
41 "*If non-nil, kill the summary buffer when you exit from it.
42 If nil, the summary will become a \"*Dead Summary*\" buffer, and
43 it will be killed sometime later."
44 :group 'gnus-summary-exit
47 (defcustom gnus-fetch-old-headers nil
48 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
49 If an unread article in the group refers to an older, already read (or
50 just marked as read) article, the old article will not normally be
51 displayed in the Summary buffer. If this variable is non-nil, Gnus
52 will attempt to grab the headers to the old articles, and thereby
53 build complete threads. If it has the value `some', only enough
54 headers to connect otherwise loose threads will be displayed. This
55 variable can also be a number. In that case, no more than that number
56 of old headers will be fetched. If it has the value `invisible', all
57 old headers will be fetched, but none will be displayed.
59 The server has to support NOV for any of this to work."
61 :type '(choice (const :tag "off" nil)
64 (sexp :menu-tag "other" t)))
66 (defcustom gnus-refer-thread-limit 200
67 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
68 If t, fetch all the available old headers."
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-summary-make-false-root 'adopt
74 "*nil means that Gnus won't gather loose threads.
75 If the root of a thread has expired or been read in a previous
76 session, the information necessary to build a complete thread has been
77 lost. Instead of having many small sub-threads from this original thread
78 scattered all over the summary buffer, Gnus can gather them.
80 If non-nil, Gnus will try to gather all loose sub-threads from an
81 original thread into one large thread.
83 If this variable is non-nil, it should be one of `none', `adopt',
86 If this variable is `none', Gnus will not make a false root, but just
87 present the sub-threads after another.
88 If this variable is `dummy', Gnus will create a dummy root that will
89 have all the sub-threads as children.
90 If this variable is `adopt', Gnus will make one of the \"children\"
91 the parent and mark all the step-children as such.
92 If this variable is `empty', the \"children\" are printed with empty
93 subject fields. (Or rather, they will be printed with a string
94 given by the `gnus-summary-same-subject' variable.)"
96 :type '(choice (const :tag "off" nil)
102 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
103 "*A regexp to match subjects to be excluded from loose thread gathering.
104 As loose thread gathering is done on subjects only, that means that
105 there can be many false gatherings performed. By rooting out certain
106 common subjects, gathering might become saner."
110 (defcustom gnus-summary-gather-subject-limit nil
111 "*Maximum length of subject comparisons when gathering loose threads.
112 Use nil to compare full subjects. Setting this variable to a low
113 number will help gather threads that have been corrupted by
114 newsreaders chopping off subject lines, but it might also mean that
115 unrelated articles that have subject that happen to begin with the
116 same few characters will be incorrectly gathered.
118 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
121 :type '(choice (const :tag "off" nil)
123 (sexp :menu-tag "on" t)))
125 (defcustom gnus-simplify-subject-functions nil
126 "List of functions taking a string argument that simplify subjects.
127 The functions are applied recursively.
129 Useful functions to put in this list include: `gnus-simplify-subject-re',
130 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
132 :type '(repeat function))
134 (defcustom gnus-simplify-ignored-prefixes nil
135 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
137 :type '(choice (const :tag "off" nil)
140 (defcustom gnus-build-sparse-threads nil
141 "*If non-nil, fill in the gaps in threads.
142 If `some', only fill in the gaps that are needed to tie loose threads
143 together. If `more', fill in all leaf nodes that Gnus can find. If
144 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
146 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "all" t)))
151 (defcustom gnus-summary-thread-gathering-function
152 'gnus-gather-threads-by-subject
153 "*Function used for gathering loose threads.
154 There are two pre-defined functions: `gnus-gather-threads-by-subject',
155 which only takes Subjects into consideration; and
156 `gnus-gather-threads-by-references', which compared the References
157 headers of the articles to find matches."
159 :type '(radio (function-item gnus-gather-threads-by-subject)
160 (function-item gnus-gather-threads-by-references)
161 (function :tag "other")))
163 (defcustom gnus-summary-same-subject ""
164 "*String indicating that the current article has the same subject as the previous.
165 This variable will only be used if the value of
166 `gnus-summary-make-false-root' is `empty'."
167 :group 'gnus-summary-format
170 (defcustom gnus-summary-goto-unread t
171 "*If t, marking commands will go to the next unread article.
172 If `never', commands that usually go to the next unread article, will
173 go to the next article, whether it is read or not.
174 If nil, only the marking commands will go to the next (un)read article."
175 :group 'gnus-summary-marks
176 :link '(custom-manual "(gnus)Setting Marks")
177 :type '(choice (const :tag "off" nil)
179 (sexp :menu-tag "on" t)))
181 (defcustom gnus-summary-default-score 0
182 "*Default article score level.
183 All scores generated by the score files will be added to this score.
184 If this variable is nil, scoring will be disabled."
185 :group 'gnus-score-default
186 :type '(choice (const :tag "disable")
189 (defcustom gnus-summary-zcore-fuzz 0
190 "*Fuzziness factor for the zcore in the summary buffer.
191 Articles with scores closer than this to `gnus-summary-default-score'
193 :group 'gnus-summary-format
196 (defcustom gnus-simplify-subject-fuzzy-regexp nil
197 "*Strings to be removed when doing fuzzy matches.
198 This can either be a regular expression or list of regular expressions
199 that will be removed from subject strings if fuzzy subject
200 simplification is selected."
202 :type '(repeat regexp))
204 (defcustom gnus-show-threads t
205 "*If non-nil, display threads in summary mode."
209 (defcustom gnus-thread-hide-subtree nil
210 "*If non-nil, hide all threads initially.
211 If threads are hidden, you have to run the command
212 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
213 to expose hidden threads."
217 (defcustom gnus-thread-hide-killed t
218 "*If non-nil, hide killed threads automatically."
222 (defcustom gnus-thread-ignore-subject t
223 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
224 If nil, articles that have different subjects from their parents will
225 start separate threads."
229 (defcustom gnus-thread-operation-ignore-subject t
230 "*If non-nil, subjects will be ignored when doing thread commands.
231 This affects commands like `gnus-summary-kill-thread' and
232 `gnus-summary-lower-thread'.
234 If this variable is nil, articles in the same thread with different
235 subjects will not be included in the operation in question. If this
236 variable is `fuzzy', only articles that have subjects that are fuzzily
237 equal will be included."
239 :type '(choice (const :tag "off" nil)
243 (defcustom gnus-thread-indent-level 4
244 "*Number that says how much each sub-thread should be indented."
248 (defcustom gnus-auto-extend-newsgroup t
249 "*If non-nil, extend newsgroup forward and backward when requested."
250 :group 'gnus-summary-choose
253 (defcustom gnus-auto-select-first t
254 "*If nil, don't select the first unread article when entering a group.
255 If this variable is `best', select the highest-scored unread article
256 in the group. If t, select the first unread article.
258 This variable can also be a function to place point on a likely
259 subject line. Useful values include `gnus-summary-first-unread-subject',
260 `gnus-summary-first-unread-article' and
261 `gnus-summary-best-unread-article'.
263 If you want to prevent automatic selection of the first unread article
264 in some newsgroups, set the variable to nil in
265 `gnus-select-group-hook'."
266 :group 'gnus-group-select
267 :type '(choice (const :tag "none" nil)
269 (sexp :menu-tag "first" t)
270 (function-item gnus-summary-first-unread-subject)
271 (function-item gnus-summary-first-unread-article)
272 (function-item gnus-summary-best-unread-article)))
274 (defcustom gnus-auto-select-next t
275 "*If non-nil, offer to go to the next group from the end of the previous.
276 If the value is t and the next newsgroup is empty, Gnus will exit
277 summary mode and go back to group mode. If the value is neither nil
278 nor t, Gnus will select the following unread newsgroup. In
279 particular, if the value is the symbol `quietly', the next unread
280 newsgroup will be selected without any confirmation, and if it is
281 `almost-quietly', the next group will be selected without any
282 confirmation if you are located on the last article in the group.
283 Finally, if this variable is `slightly-quietly', the `Z n' command
284 will go to the next group without confirmation."
285 :group 'gnus-summary-maneuvering
286 :type '(choice (const :tag "off" nil)
288 (const almost-quietly)
289 (const slightly-quietly)
290 (sexp :menu-tag "on" t)))
292 (defcustom gnus-auto-select-same nil
293 "*If non-nil, select the next article with the same subject.
294 If there are no more articles with the same subject, go to
295 the first unread article."
296 :group 'gnus-summary-maneuvering
299 (defcustom gnus-summary-check-current nil
300 "*If non-nil, consider the current article when moving.
301 The \"unread\" movement commands will stay on the same line if the
302 current article is unread."
303 :group 'gnus-summary-maneuvering
306 (defcustom gnus-auto-center-summary t
307 "*If non-nil, always center the current summary buffer.
308 In particular, if `vertical' do only vertical recentering. If non-nil
309 and non-`vertical', do both horizontal and vertical recentering."
310 :group 'gnus-summary-maneuvering
311 :type '(choice (const :tag "none" nil)
313 (sexp :menu-tag "both" t)))
315 (defcustom gnus-show-all-headers nil
316 "*If non-nil, don't hide any headers."
317 :group 'gnus-article-hiding
318 :group 'gnus-article-headers
321 (defcustom gnus-summary-ignore-duplicates nil
322 "*If non-nil, ignore articles with identical Message-ID headers."
326 (defcustom gnus-single-article-buffer t
327 "*If non-nil, display all articles in the same buffer.
328 If nil, each group will get its own article buffer."
329 :group 'gnus-article-various
332 (defcustom gnus-break-pages t
333 "*If non-nil, do page breaking on articles.
334 The page delimiter is specified by the `gnus-page-delimiter'
336 :group 'gnus-article-various
339 (defcustom gnus-move-split-methods nil
340 "*Variable used to suggest where articles are to be moved to.
341 It uses the same syntax as the `gnus-split-methods' variable."
342 :group 'gnus-summary-mail
343 :type '(repeat (choice (list :value (fun) function)
344 (cons :value ("" "") regexp (repeat string))
347 (defcustom gnus-unread-mark ?
348 "*Mark used for unread articles."
349 :group 'gnus-summary-marks
352 (defcustom gnus-ticked-mark ?!
353 "*Mark used for ticked articles."
354 :group 'gnus-summary-marks
357 (defcustom gnus-dormant-mark ??
358 "*Mark used for dormant articles."
359 :group 'gnus-summary-marks
362 (defcustom gnus-del-mark ?r
363 "*Mark used for del'd articles."
364 :group 'gnus-summary-marks
367 (defcustom gnus-read-mark ?R
368 "*Mark used for read articles."
369 :group 'gnus-summary-marks
372 (defcustom gnus-expirable-mark ?E
373 "*Mark used for expirable articles."
374 :group 'gnus-summary-marks
377 (defcustom gnus-killed-mark ?K
378 "*Mark used for killed articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-souped-mark ?F
383 "*Mark used for killed articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-kill-file-mark ?X
388 "*Mark used for articles killed by kill files."
389 :group 'gnus-summary-marks
392 (defcustom gnus-low-score-mark ?Y
393 "*Mark used for articles with a low score."
394 :group 'gnus-summary-marks
397 (defcustom gnus-catchup-mark ?C
398 "*Mark used for articles that are caught up."
399 :group 'gnus-summary-marks
402 (defcustom gnus-replied-mark ?A
403 "*Mark used for articles that have been replied to."
404 :group 'gnus-summary-marks
407 (defcustom gnus-cached-mark ?*
408 "*Mark used for articles that are in the cache."
409 :group 'gnus-summary-marks
412 (defcustom gnus-saved-mark ?S
413 "*Mark used for articles that have been saved to."
414 :group 'gnus-summary-marks
417 (defcustom gnus-ancient-mark ?O
418 "*Mark used for ancient articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-sparse-mark ?Q
423 "*Mark used for sparsely reffed articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-canceled-mark ?G
428 "*Mark used for canceled articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-duplicate-mark ?M
433 "*Mark used for duplicate articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-undownloaded-mark ?@
438 "*Mark used for articles that weren't downloaded."
439 :group 'gnus-summary-marks
442 (defcustom gnus-downloadable-mark ?%
443 "*Mark used for articles that are to be downloaded."
444 :group 'gnus-summary-marks
447 (defcustom gnus-unsendable-mark ?=
448 "*Mark used for articles that won't be sent."
449 :group 'gnus-summary-marks
452 (defcustom gnus-score-over-mark ?+
453 "*Score mark used for articles with high scores."
454 :group 'gnus-summary-marks
457 (defcustom gnus-score-below-mark ?-
458 "*Score mark used for articles with low scores."
459 :group 'gnus-summary-marks
462 (defcustom gnus-empty-thread-mark ?
463 "*There is no thread under the article."
464 :group 'gnus-summary-marks
467 (defcustom gnus-not-empty-thread-mark ?=
468 "*There is a thread under the article."
469 :group 'gnus-summary-marks
472 (defcustom gnus-view-pseudo-asynchronously nil
473 "*If non-nil, Gnus will view pseudo-articles asynchronously."
474 :group 'gnus-extract-view
477 (defcustom gnus-view-pseudos nil
478 "*If `automatic', pseudo-articles will be viewed automatically.
479 If `not-confirm', pseudos will be viewed automatically, and the user
480 will not be asked to confirm the command."
481 :group 'gnus-extract-view
482 :type '(choice (const :tag "off" nil)
484 (const not-confirm)))
486 (defcustom gnus-view-pseudos-separately t
487 "*If non-nil, one pseudo-article will be created for each file to be viewed.
488 If nil, all files that use the same viewing command will be given as a
489 list of parameters to that command."
490 :group 'gnus-extract-view
493 (defcustom gnus-insert-pseudo-articles t
494 "*If non-nil, insert pseudo-articles when decoding articles."
495 :group 'gnus-extract-view
498 (defcustom gnus-summary-dummy-line-format
500 "*The format specification for the dummy roots in the summary buffer.
501 It works along the same lines as a normal formatting string,
502 with some simple extensions.
505 :group 'gnus-threading
508 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
509 "*The format specification for the summary mode line.
510 It works along the same lines as a normal formatting string,
511 with some simple extensions:
514 %p Unprefixed group name
515 %A Current article number
516 %z Current article score
518 %U Number of unread articles in the group
519 %e Number of unselected articles in the group
520 %Z A string with unread/unselected article counts
521 %g Shortish group name
522 %S Subject of the current article
524 %s Current score file name
525 %d Number of dormant articles
526 %r Number of articles that have been marked as read in this session
527 %E Number of articles expunged by the score files"
528 :group 'gnus-summary-format
531 (defcustom gnus-summary-mark-below 0
532 "*Mark all articles with a score below this variable as read.
533 This variable is local to each summary buffer and usually set by the
535 :group 'gnus-score-default
538 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
539 "*List of functions used for sorting articles in the summary buffer.
540 This variable is only used when not using a threaded display."
541 :group 'gnus-summary-sort
542 :type '(repeat (choice (function-item gnus-article-sort-by-number)
543 (function-item gnus-article-sort-by-author)
544 (function-item gnus-article-sort-by-subject)
545 (function-item gnus-article-sort-by-date)
546 (function-item gnus-article-sort-by-score)
547 (function :tag "other"))))
549 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
550 "*List of functions used for sorting threads in the summary buffer.
551 By default, threads are sorted by article number.
553 Each function takes two threads and return non-nil if the first thread
554 should be sorted before the other. If you use more than one function,
555 the primary sort function should be the last. You should probably
556 always include `gnus-thread-sort-by-number' in the list of sorting
557 functions -- preferably first.
559 Ready-made functions include `gnus-thread-sort-by-number',
560 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
561 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
562 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
563 :group 'gnus-summary-sort
564 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
565 (function-item gnus-thread-sort-by-author)
566 (function-item gnus-thread-sort-by-subject)
567 (function-item gnus-thread-sort-by-date)
568 (function-item gnus-thread-sort-by-score)
569 (function-item gnus-thread-sort-by-total-score)
570 (function :tag "other"))))
572 (defcustom gnus-thread-score-function '+
573 "*Function used for calculating the total score of a thread.
575 The function is called with the scores of the article and each
576 subthread and should then return the score of the thread.
578 Some functions you can use are `+', `max', or `min'."
579 :group 'gnus-summary-sort
582 (defcustom gnus-summary-expunge-below nil
583 "All articles that have a score less than this variable will be expunged.
584 This variable is local to the summary buffers."
585 :group 'gnus-score-default
586 :type '(choice (const :tag "off" nil)
589 (defcustom gnus-thread-expunge-below nil
590 "All threads that have a total score less than this variable will be expunged.
591 See `gnus-thread-score-function' for en explanation of what a
594 This variable is local to the summary buffers."
595 :group 'gnus-treading
596 :group 'gnus-score-default
597 :type '(choice (const :tag "off" nil)
600 (defcustom gnus-summary-mode-hook nil
601 "*A hook for Gnus summary mode.
602 This hook is run before any variables are set in the summary buffer."
603 :group 'gnus-summary-various
606 (defcustom gnus-summary-menu-hook nil
607 "*Hook run after the creation of the summary mode menu."
608 :group 'gnus-summary-visual
611 (defcustom gnus-summary-exit-hook nil
612 "*A hook called on exit from the summary buffer.
613 It will be called with point in the group buffer."
614 :group 'gnus-summary-exit
617 (defcustom gnus-summary-prepare-hook nil
618 "*A hook called after the summary buffer has been generated.
619 If you want to modify the summary buffer, you can use this hook."
620 :group 'gnus-summary-various
623 (defcustom gnus-summary-prepared-hook nil
624 "*A hook called as the last thing after the summary buffer has been generated."
625 :group 'gnus-summary-various
628 (defcustom gnus-summary-generate-hook nil
629 "*A hook run just before generating the summary buffer.
630 This hook is commonly used to customize threading variables and the
632 :group 'gnus-summary-various
635 (defcustom gnus-select-group-hook nil
636 "*A hook called when a newsgroup is selected.
638 If you'd like to simplify subjects like the
639 `gnus-summary-next-same-subject' command does, you can use the
642 (setq gnus-select-group-hook
645 (mapcar (lambda (header)
646 (mail-header-set-subject
648 (gnus-simplify-subject
649 (mail-header-subject header) 're-only)))
650 gnus-newsgroup-headers))))"
651 :group 'gnus-group-select
654 (defcustom gnus-select-article-hook nil
655 "*A hook called when an article is selected."
656 :group 'gnus-summary-choose
659 (defcustom gnus-visual-mark-article-hook
660 (list 'gnus-highlight-selected-summary)
661 "*Hook run after selecting an article in the summary buffer.
662 It is meant to be used for highlighting the article in some way. It
663 is not run if `gnus-visual' is nil."
664 :group 'gnus-summary-visual
667 (defcustom gnus-parse-headers-hook nil
668 "*A hook called before parsing the headers."
672 (defcustom gnus-exit-group-hook nil
673 "*A hook called when exiting (not quitting) summary mode."
677 (defcustom gnus-summary-update-hook
678 (list 'gnus-summary-highlight-line)
679 "*A hook called when a summary line is changed.
680 The hook will not be called if `gnus-visual' is nil.
682 The default function `gnus-summary-highlight-line' will
683 highlight the line according to the `gnus-summary-highlight'
685 :group 'gnus-summary-visual
688 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
689 "*A hook called when an article is selected for the first time.
690 The hook is intended to mark an article as read (or unread)
691 automatically when it is selected."
692 :group 'gnus-summary-choose
695 (defcustom gnus-group-no-more-groups-hook nil
696 "*A hook run when returning to group mode having no more (unread) groups."
697 :group 'gnus-group-select
700 (defcustom gnus-ps-print-hook nil
701 "*A hook run before ps-printing something from Gnus."
705 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
706 "Face used for highlighting the current article in the summary buffer."
707 :group 'gnus-summary-visual
710 (defcustom gnus-summary-highlight
711 '(((= mark gnus-canceled-mark)
712 . gnus-summary-cancelled-face)
713 ((and (> score default)
714 (or (= mark gnus-dormant-mark)
715 (= mark gnus-ticked-mark)))
716 . gnus-summary-high-ticked-face)
717 ((and (< score default)
718 (or (= mark gnus-dormant-mark)
719 (= mark gnus-ticked-mark)))
720 . gnus-summary-low-ticked-face)
721 ((or (= mark gnus-dormant-mark)
722 (= mark gnus-ticked-mark))
723 . gnus-summary-normal-ticked-face)
724 ((and (> score default) (= mark gnus-ancient-mark))
725 . gnus-summary-high-ancient-face)
726 ((and (< score default) (= mark gnus-ancient-mark))
727 . gnus-summary-low-ancient-face)
728 ((= mark gnus-ancient-mark)
729 . gnus-summary-normal-ancient-face)
730 ((and (> score default) (= mark gnus-unread-mark))
731 . gnus-summary-high-unread-face)
732 ((and (< score default) (= mark gnus-unread-mark))
733 . gnus-summary-low-unread-face)
734 ((= mark gnus-unread-mark)
735 . gnus-summary-normal-unread-face)
736 ((and (> score default) (memq mark (list gnus-downloadable-mark
737 gnus-undownloaded-mark)))
738 . gnus-summary-high-unread-face)
739 ((and (< score default) (memq mark (list gnus-downloadable-mark
740 gnus-undownloaded-mark)))
741 . gnus-summary-low-unread-face)
742 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
743 . gnus-summary-normal-unread-face)
745 . gnus-summary-high-read-face)
747 . gnus-summary-low-read-face)
749 . gnus-summary-normal-read-face))
750 "*Controls the highlighting of summary buffer lines.
752 A list of (FORM . FACE) pairs. When deciding how a a particular
753 summary line should be displayed, each form is evaluated. The content
754 of the face field after the first true form is used. You can change
755 how those summary lines are displayed, by editing the face field.
757 You can use the following variables in the FORM field.
759 score: The articles score
760 default: The default article score.
761 below: The score below which articles are automatically marked as read.
762 mark: The articles mark."
763 :group 'gnus-summary-visual
764 :type '(repeat (cons (sexp :tag "Form" nil)
767 (defcustom gnus-alter-header-function nil
768 "Function called to allow alteration of article header structures.
769 The function is called with one parameter, the article header vector,
770 which it may alter in any way.")
772 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
773 "Variable that says which function should be used to decode a string with encoded words.")
775 ;;; Internal variables
777 (defvar gnus-article-mime-handles nil)
778 (defvar gnus-article-decoded-p nil)
779 (defvar gnus-scores-exclude-files nil)
780 (defvar gnus-page-broken nil)
782 (defvar gnus-original-article nil)
783 (defvar gnus-article-internal-prepare-hook nil)
784 (defvar gnus-newsgroup-process-stack nil)
786 (defvar gnus-thread-indent-array nil)
787 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
789 ;; Avoid highlighting in kill files.
790 (defvar gnus-summary-inhibit-highlight nil)
791 (defvar gnus-newsgroup-selected-overlay nil)
792 (defvar gnus-inhibit-limiting nil)
793 (defvar gnus-newsgroup-adaptive-score-file nil)
794 (defvar gnus-current-score-file nil)
795 (defvar gnus-current-move-group nil)
796 (defvar gnus-current-copy-group nil)
797 (defvar gnus-current-crosspost-group nil)
799 (defvar gnus-newsgroup-dependencies nil)
800 (defvar gnus-newsgroup-adaptive nil)
801 (defvar gnus-summary-display-article-function nil)
802 (defvar gnus-summary-highlight-line-function nil
803 "Function called after highlighting a summary line.")
805 (defvar gnus-summary-line-format-alist
806 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
807 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
808 (?s gnus-tmp-subject-or-nil ?s)
809 (?n gnus-tmp-name ?s)
810 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
812 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
814 (?F gnus-tmp-from ?s)
815 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
816 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
817 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
818 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
819 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
820 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
821 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
822 (?L gnus-tmp-lines ?d)
823 (?I gnus-tmp-indentation ?s)
824 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
825 (?R gnus-tmp-replied ?c)
826 (?\[ gnus-tmp-opening-bracket ?c)
827 (?\] gnus-tmp-closing-bracket ?c)
828 (?\> (make-string gnus-tmp-level ? ) ?s)
829 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
830 (?i gnus-tmp-score ?d)
831 (?z gnus-tmp-score-char ?c)
832 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
833 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
834 (?U gnus-tmp-unread ?c)
835 (?t (gnus-summary-number-of-articles-in-thread
836 (and (boundp 'thread) (car thread)) gnus-tmp-level)
838 (?e (gnus-summary-number-of-articles-in-thread
839 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
841 (?u gnus-tmp-user-defined ?s)
842 (?P (gnus-pick-line-number) ?d))
843 "An alist of format specifications that can appear in summary lines,
844 and what variables they correspond with, along with the type of the
845 variable (string, integer, character, etc).")
847 (defvar gnus-summary-dummy-line-format-alist
848 `((?S gnus-tmp-subject ?s)
849 (?N gnus-tmp-number ?d)
850 (?u gnus-tmp-user-defined ?s)))
852 (defvar gnus-summary-mode-line-format-alist
853 `((?G gnus-tmp-group-name ?s)
854 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
855 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
856 (?A gnus-tmp-article-number ?d)
857 (?Z gnus-tmp-unread-and-unselected ?s)
859 (?U gnus-tmp-unread-and-unticked ?d)
860 (?S gnus-tmp-subject ?s)
861 (?e gnus-tmp-unselected ?d)
862 (?u gnus-tmp-user-defined ?s)
863 (?d (length gnus-newsgroup-dormant) ?d)
864 (?t (length gnus-newsgroup-marked) ?d)
865 (?r (length gnus-newsgroup-reads) ?d)
866 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
867 (?E gnus-newsgroup-expunged-tally ?d)
868 (?s (gnus-current-score-file-nondirectory) ?s)))
870 (defvar gnus-last-search-regexp nil
871 "Default regexp for article search command.")
873 (defvar gnus-last-shell-command nil
874 "Default shell command on article.")
876 (defvar gnus-newsgroup-begin nil)
877 (defvar gnus-newsgroup-end nil)
878 (defvar gnus-newsgroup-last-rmail nil)
879 (defvar gnus-newsgroup-last-mail nil)
880 (defvar gnus-newsgroup-last-folder nil)
881 (defvar gnus-newsgroup-last-file nil)
882 (defvar gnus-newsgroup-auto-expire nil)
883 (defvar gnus-newsgroup-active nil)
885 (defvar gnus-newsgroup-data nil)
886 (defvar gnus-newsgroup-data-reverse nil)
887 (defvar gnus-newsgroup-limit nil)
888 (defvar gnus-newsgroup-limits nil)
890 (defvar gnus-newsgroup-unreads nil
891 "List of unread articles in the current newsgroup.")
893 (defvar gnus-newsgroup-unselected nil
894 "List of unselected unread articles in the current newsgroup.")
896 (defvar gnus-newsgroup-reads nil
897 "Alist of read articles and article marks in the current newsgroup.")
899 (defvar gnus-newsgroup-expunged-tally nil)
901 (defvar gnus-newsgroup-marked nil
902 "List of ticked articles in the current newsgroup (a subset of unread art).")
904 (defvar gnus-newsgroup-killed nil
905 "List of ranges of articles that have been through the scoring process.")
907 (defvar gnus-newsgroup-cached nil
908 "List of articles that come from the article cache.")
910 (defvar gnus-newsgroup-saved nil
911 "List of articles that have been saved.")
913 (defvar gnus-newsgroup-kill-headers nil)
915 (defvar gnus-newsgroup-replied nil
916 "List of articles that have been replied to in the current newsgroup.")
918 (defvar gnus-newsgroup-expirable nil
919 "List of articles in the current newsgroup that can be expired.")
921 (defvar gnus-newsgroup-processable nil
922 "List of articles in the current newsgroup that can be processed.")
924 (defvar gnus-newsgroup-downloadable nil
925 "List of articles in the current newsgroup that can be processed.")
927 (defvar gnus-newsgroup-undownloaded nil
928 "List of articles in the current newsgroup that haven't been downloaded..")
930 (defvar gnus-newsgroup-unsendable nil
931 "List of articles in the current newsgroup that won't be sent.")
933 (defvar gnus-newsgroup-bookmarks nil
934 "List of articles in the current newsgroup that have bookmarks.")
936 (defvar gnus-newsgroup-dormant nil
937 "List of dormant articles in the current newsgroup.")
939 (defvar gnus-newsgroup-scored nil
940 "List of scored articles in the current newsgroup.")
942 (defvar gnus-newsgroup-headers nil
943 "List of article headers in the current newsgroup.")
945 (defvar gnus-newsgroup-threads nil)
947 (defvar gnus-newsgroup-prepared nil
948 "Whether the current group has been prepared properly.")
950 (defvar gnus-newsgroup-ancient nil
951 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
953 (defvar gnus-newsgroup-sparse nil)
955 (defvar gnus-current-article nil)
956 (defvar gnus-article-current nil)
957 (defvar gnus-current-headers nil)
958 (defvar gnus-have-all-headers nil)
959 (defvar gnus-last-article nil)
960 (defvar gnus-newsgroup-history nil)
962 (defconst gnus-summary-local-variables
963 '(gnus-newsgroup-name
964 gnus-newsgroup-begin gnus-newsgroup-end
965 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
966 gnus-newsgroup-last-folder gnus-newsgroup-last-file
967 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
968 gnus-newsgroup-unselected gnus-newsgroup-marked
969 gnus-newsgroup-reads gnus-newsgroup-saved
970 gnus-newsgroup-replied gnus-newsgroup-expirable
971 gnus-newsgroup-processable gnus-newsgroup-killed
972 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
973 gnus-newsgroup-unsendable
974 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
975 gnus-newsgroup-headers gnus-newsgroup-threads
976 gnus-newsgroup-prepared gnus-summary-highlight-line-function
977 gnus-current-article gnus-current-headers gnus-have-all-headers
978 gnus-last-article gnus-article-internal-prepare-hook
979 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
980 gnus-newsgroup-scored gnus-newsgroup-kill-headers
981 gnus-thread-expunge-below
982 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
983 (gnus-summary-mark-below . global)
984 gnus-newsgroup-active gnus-scores-exclude-files
985 gnus-newsgroup-history gnus-newsgroup-ancient
986 gnus-newsgroup-sparse gnus-newsgroup-process-stack
987 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
988 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
989 (gnus-newsgroup-expunged-tally . 0)
990 gnus-cache-removable-articles gnus-newsgroup-cached
991 gnus-newsgroup-data gnus-newsgroup-data-reverse
992 gnus-newsgroup-limit gnus-newsgroup-limits)
993 "Variables that are buffer-local to the summary buffers.")
995 ;; Byte-compiler warning.
996 (defvar gnus-article-mode-map)
1000 (defvar gnus-encoded-word-method-alist
1001 '(("chinese" mail-decode-encoded-word-string rfc1843-decode-string)
1002 (".*" mail-decode-encoded-word-string))
1003 "Alist of regexps (to match group names) and lists of functions to be applied.")
1005 (defun gnus-multi-decode-encoded-word-string (string)
1006 "Apply the functions from `gnus-encoded-word-method-alist' that match."
1007 (let ((alist gnus-encoded-word-method-alist)
1009 (while (setq elem (pop alist))
1010 (when (string-match (car elem) gnus-newsgroup-name)
1013 (setq string (funcall (pop elem) string)))
1017 ;; Subject simplification.
1019 (defun gnus-simplify-whitespace (str)
1020 "Remove excessive whitespace."
1023 (while (string-match "[ \t][ \t]+" mystr)
1024 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1026 (substring mystr (match-end 0)))))
1028 (when (string-match "^[ \t]+" mystr)
1029 (setq mystr (substring mystr (match-end 0))))
1031 (when (string-match "[ \t]+$" mystr)
1032 (setq mystr (substring mystr 0 (match-beginning 0))))
1035 (defsubst gnus-simplify-subject-re (subject)
1036 "Remove \"Re:\" from subject lines."
1037 (if (string-match "^[Rr][Ee]: *" subject)
1038 (substring subject (match-end 0))
1041 (defun gnus-simplify-subject (subject &optional re-only)
1042 "Remove `Re:' and words in parentheses.
1043 If RE-ONLY is non-nil, strip leading `Re:'s only."
1044 (let ((case-fold-search t)) ;Ignore case.
1045 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1046 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1047 (setq subject (substring subject (match-end 0))))
1048 ;; Remove uninteresting prefixes.
1049 (when (and (not re-only)
1050 gnus-simplify-ignored-prefixes
1051 (string-match gnus-simplify-ignored-prefixes subject))
1052 (setq subject (substring subject (match-end 0))))
1053 ;; Remove words in parentheses from end.
1055 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1056 (setq subject (substring subject 0 (match-beginning 0)))))
1057 ;; Return subject string.
1060 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1062 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1063 (goto-char (point-min))
1064 (while (re-search-forward regexp nil t)
1065 (replace-match (or newtext ""))))
1067 (defun gnus-simplify-buffer-fuzzy ()
1068 "Simplify string in the buffer fuzzily.
1069 The string in the accessible portion of the current buffer is simplified.
1070 It is assumed to be a single-line subject.
1071 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1072 matter is removed. Additional things can be deleted by setting
1073 gnus-simplify-subject-fuzzy-regexp."
1074 (let ((case-fold-search t)
1076 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1078 (while (not (eq modified-tick (buffer-modified-tick)))
1079 (setq modified-tick (buffer-modified-tick))
1081 ((listp gnus-simplify-subject-fuzzy-regexp)
1082 (mapcar 'gnus-simplify-buffer-fuzzy-step
1083 gnus-simplify-subject-fuzzy-regexp))
1084 (gnus-simplify-subject-fuzzy-regexp
1085 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1086 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1087 (gnus-simplify-buffer-fuzzy-step
1088 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1089 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1091 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1092 (gnus-simplify-buffer-fuzzy-step " +" " ")
1093 (gnus-simplify-buffer-fuzzy-step " $")
1094 (gnus-simplify-buffer-fuzzy-step "^ +")))
1096 (defun gnus-simplify-subject-fuzzy (subject)
1097 "Simplify a subject string fuzzily.
1098 See `gnus-simplify-buffer-fuzzy' for details."
1100 (gnus-set-work-buffer)
1101 (let ((case-fold-search t))
1102 ;; Remove uninteresting prefixes.
1103 (when (and gnus-simplify-ignored-prefixes
1104 (string-match gnus-simplify-ignored-prefixes subject))
1105 (setq subject (substring subject (match-end 0))))
1107 (inline (gnus-simplify-buffer-fuzzy))
1110 (defsubst gnus-simplify-subject-fully (subject)
1111 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1113 (gnus-simplify-subject-functions
1114 (gnus-map-function gnus-simplify-subject-functions subject))
1115 ((null gnus-summary-gather-subject-limit)
1116 (gnus-simplify-subject-re subject))
1117 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1118 (gnus-simplify-subject-fuzzy subject))
1119 ((numberp gnus-summary-gather-subject-limit)
1120 (gnus-limit-string (gnus-simplify-subject-re subject)
1121 gnus-summary-gather-subject-limit))
1125 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1126 "Check whether two subjects are equal.
1127 If optional argument simple-first is t, first argument is already
1130 ((null simple-first)
1131 (equal (gnus-simplify-subject-fully s1)
1132 (gnus-simplify-subject-fully s2)))
1135 (gnus-simplify-subject-fully s2)))))
1137 (defun gnus-summary-bubble-group ()
1138 "Increase the score of the current group.
1139 This is a handy function to add to `gnus-summary-exit-hook' to
1140 increase the score of each group you read."
1141 (gnus-group-add-score gnus-newsgroup-name))
1145 ;;; Gnus summary mode
1148 (put 'gnus-summary-mode 'mode-class 'special)
1151 ;; Non-orthogonal keys
1153 (gnus-define-keys gnus-summary-mode-map
1154 " " gnus-summary-next-page
1155 "\177" gnus-summary-prev-page
1156 [delete] gnus-summary-prev-page
1157 [backspace] gnus-summary-prev-page
1158 "\r" gnus-summary-scroll-up
1159 "\M-\r" gnus-summary-scroll-down
1160 "n" gnus-summary-next-unread-article
1161 "p" gnus-summary-prev-unread-article
1162 "N" gnus-summary-next-article
1163 "P" gnus-summary-prev-article
1164 "\M-\C-n" gnus-summary-next-same-subject
1165 "\M-\C-p" gnus-summary-prev-same-subject
1166 "\M-n" gnus-summary-next-unread-subject
1167 "\M-p" gnus-summary-prev-unread-subject
1168 "." gnus-summary-first-unread-article
1169 "," gnus-summary-best-unread-article
1170 "\M-s" gnus-summary-search-article-forward
1171 "\M-r" gnus-summary-search-article-backward
1172 "<" gnus-summary-beginning-of-article
1173 ">" gnus-summary-end-of-article
1174 "j" gnus-summary-goto-article
1175 "^" gnus-summary-refer-parent-article
1176 "\M-^" gnus-summary-refer-article
1177 "u" gnus-summary-tick-article-forward
1178 "!" gnus-summary-tick-article-forward
1179 "U" gnus-summary-tick-article-backward
1180 "d" gnus-summary-mark-as-read-forward
1181 "D" gnus-summary-mark-as-read-backward
1182 "E" gnus-summary-mark-as-expirable
1183 "\M-u" gnus-summary-clear-mark-forward
1184 "\M-U" gnus-summary-clear-mark-backward
1185 "k" gnus-summary-kill-same-subject-and-select
1186 "\C-k" gnus-summary-kill-same-subject
1187 "\M-\C-k" gnus-summary-kill-thread
1188 "\M-\C-l" gnus-summary-lower-thread
1189 "e" gnus-summary-edit-article
1190 "#" gnus-summary-mark-as-processable
1191 "\M-#" gnus-summary-unmark-as-processable
1192 "\M-\C-t" gnus-summary-toggle-threads
1193 "\M-\C-s" gnus-summary-show-thread
1194 "\M-\C-h" gnus-summary-hide-thread
1195 "\M-\C-f" gnus-summary-next-thread
1196 "\M-\C-b" gnus-summary-prev-thread
1197 "\M-\C-u" gnus-summary-up-thread
1198 "\M-\C-d" gnus-summary-down-thread
1199 "&" gnus-summary-execute-command
1200 "c" gnus-summary-catchup-and-exit
1201 "\C-w" gnus-summary-mark-region-as-read
1202 "\C-t" gnus-summary-toggle-truncation
1203 "?" gnus-summary-mark-as-dormant
1204 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1205 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1206 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1207 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1208 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1209 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1210 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1211 "=" gnus-summary-expand-window
1212 "\C-x\C-s" gnus-summary-reselect-current-group
1213 "\M-g" gnus-summary-rescan-group
1214 "w" gnus-summary-stop-page-breaking
1215 "\C-c\C-r" gnus-summary-caesar-message
1216 "f" gnus-summary-followup
1217 "F" gnus-summary-followup-with-original
1218 "C" gnus-summary-cancel-article
1219 "r" gnus-summary-reply
1220 "R" gnus-summary-reply-with-original
1221 "\C-c\C-f" gnus-summary-mail-forward
1222 "o" gnus-summary-save-article
1223 "\C-o" gnus-summary-save-article-mail
1224 "|" gnus-summary-pipe-output
1225 "\M-k" gnus-summary-edit-local-kill
1226 "\M-K" gnus-summary-edit-global-kill
1228 "\C-c\C-d" gnus-summary-describe-group
1229 "q" gnus-summary-exit
1230 "Q" gnus-summary-exit-no-update
1231 "\C-c\C-i" gnus-info-find-node
1232 gnus-mouse-2 gnus-mouse-pick-article
1233 "m" gnus-summary-mail-other-window
1234 "a" gnus-summary-post-news
1235 "x" gnus-summary-limit-to-unread
1236 "s" gnus-summary-isearch-article
1237 "t" gnus-article-hide-headers
1238 "g" gnus-summary-show-article
1239 "l" gnus-summary-goto-last-article
1240 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1241 "\C-d" gnus-summary-enter-digest-group
1242 "\M-\C-d" gnus-summary-read-document
1243 "\M-\C-e" gnus-summary-edit-parameters
1245 "*" gnus-cache-enter-article
1246 "\M-*" gnus-cache-remove-article
1247 "\M-&" gnus-summary-universal-argument
1248 "\C-l" gnus-recenter
1249 "I" gnus-summary-increase-score
1250 "L" gnus-summary-lower-score
1251 "\M-i" gnus-symbolic-argument
1252 "h" gnus-summary-select-article-buffer
1253 "b" gnus-article-view-part
1255 "V" gnus-summary-score-map
1256 "X" gnus-uu-extract-map
1257 "S" gnus-summary-send-map)
1259 ;; Sort of orthogonal keymap
1260 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1261 "t" gnus-summary-tick-article-forward
1262 "!" gnus-summary-tick-article-forward
1263 "d" gnus-summary-mark-as-read-forward
1264 "r" gnus-summary-mark-as-read-forward
1265 "c" gnus-summary-clear-mark-forward
1266 " " gnus-summary-clear-mark-forward
1267 "e" gnus-summary-mark-as-expirable
1268 "x" gnus-summary-mark-as-expirable
1269 "?" gnus-summary-mark-as-dormant
1270 "b" gnus-summary-set-bookmark
1271 "B" gnus-summary-remove-bookmark
1272 "#" gnus-summary-mark-as-processable
1273 "\M-#" gnus-summary-unmark-as-processable
1274 "S" gnus-summary-limit-include-expunged
1275 "C" gnus-summary-catchup
1276 "H" gnus-summary-catchup-to-here
1277 "\C-c" gnus-summary-catchup-all
1278 "k" gnus-summary-kill-same-subject-and-select
1279 "K" gnus-summary-kill-same-subject
1280 "P" gnus-uu-mark-map)
1282 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1283 "c" gnus-summary-clear-above
1284 "u" gnus-summary-tick-above
1285 "m" gnus-summary-mark-above
1286 "k" gnus-summary-kill-below)
1288 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1289 "/" gnus-summary-limit-to-subject
1290 "n" gnus-summary-limit-to-articles
1291 "w" gnus-summary-pop-limit
1292 "s" gnus-summary-limit-to-subject
1293 "a" gnus-summary-limit-to-author
1294 "u" gnus-summary-limit-to-unread
1295 "m" gnus-summary-limit-to-marks
1296 "v" gnus-summary-limit-to-score
1297 "*" gnus-summary-limit-include-cached
1298 "D" gnus-summary-limit-include-dormant
1299 "T" gnus-summary-limit-include-thread
1300 "d" gnus-summary-limit-exclude-dormant
1301 "t" gnus-summary-limit-to-age
1302 "E" gnus-summary-limit-include-expunged
1303 "c" gnus-summary-limit-exclude-childless-dormant
1304 "C" gnus-summary-limit-mark-excluded-as-read)
1306 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1307 "n" gnus-summary-next-unread-article
1308 "p" gnus-summary-prev-unread-article
1309 "N" gnus-summary-next-article
1310 "P" gnus-summary-prev-article
1311 "\C-n" gnus-summary-next-same-subject
1312 "\C-p" gnus-summary-prev-same-subject
1313 "\M-n" gnus-summary-next-unread-subject
1314 "\M-p" gnus-summary-prev-unread-subject
1315 "f" gnus-summary-first-unread-article
1316 "b" gnus-summary-best-unread-article
1317 "j" gnus-summary-goto-article
1318 "g" gnus-summary-goto-subject
1319 "l" gnus-summary-goto-last-article
1320 "o" gnus-summary-pop-article)
1322 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1323 "k" gnus-summary-kill-thread
1324 "l" gnus-summary-lower-thread
1325 "i" gnus-summary-raise-thread
1326 "T" gnus-summary-toggle-threads
1327 "t" gnus-summary-rethread-current
1328 "^" gnus-summary-reparent-thread
1329 "s" gnus-summary-show-thread
1330 "S" gnus-summary-show-all-threads
1331 "h" gnus-summary-hide-thread
1332 "H" gnus-summary-hide-all-threads
1333 "n" gnus-summary-next-thread
1334 "p" gnus-summary-prev-thread
1335 "u" gnus-summary-up-thread
1336 "o" gnus-summary-top-thread
1337 "d" gnus-summary-down-thread
1338 "#" gnus-uu-mark-thread
1339 "\M-#" gnus-uu-unmark-thread)
1341 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1342 "g" gnus-summary-prepare
1343 "c" gnus-summary-insert-cached-articles)
1345 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1346 "c" gnus-summary-catchup-and-exit
1347 "C" gnus-summary-catchup-all-and-exit
1348 "E" gnus-summary-exit-no-update
1349 "Q" gnus-summary-exit
1350 "Z" gnus-summary-exit
1351 "n" gnus-summary-catchup-and-goto-next-group
1352 "R" gnus-summary-reselect-current-group
1353 "G" gnus-summary-rescan-group
1354 "N" gnus-summary-next-group
1355 "s" gnus-summary-save-newsrc
1356 "P" gnus-summary-prev-group)
1358 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1359 " " gnus-summary-next-page
1360 "n" gnus-summary-next-page
1361 "\177" gnus-summary-prev-page
1362 [delete] gnus-summary-prev-page
1363 "p" gnus-summary-prev-page
1364 "\r" gnus-summary-scroll-up
1365 "\M-\r" gnus-summary-scroll-down
1366 "<" gnus-summary-beginning-of-article
1367 ">" gnus-summary-end-of-article
1368 "b" gnus-summary-beginning-of-article
1369 "e" gnus-summary-end-of-article
1370 "^" gnus-summary-refer-parent-article
1371 "r" gnus-summary-refer-parent-article
1372 "R" gnus-summary-refer-references
1373 "T" gnus-summary-refer-thread
1374 "g" gnus-summary-show-article
1375 "s" gnus-summary-isearch-article
1376 "P" gnus-summary-print-article)
1378 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1379 "b" gnus-article-add-buttons
1380 "B" gnus-article-add-buttons-to-head
1381 "o" gnus-article-treat-overstrike
1382 "e" gnus-article-emphasize
1383 "w" gnus-article-fill-cited-article
1384 "c" gnus-article-remove-cr
1385 "q" gnus-article-de-quoted-unreadable
1386 "f" gnus-article-display-x-face
1387 "l" gnus-summary-stop-page-breaking
1388 "r" gnus-summary-caesar-message
1389 "t" gnus-article-hide-headers
1390 "v" gnus-summary-verbose-headers
1391 "h" gnus-article-treat-html
1392 "d" gnus-article-treat-dumbquotes)
1394 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1395 "a" gnus-article-hide
1396 "h" gnus-article-hide-headers
1397 "b" gnus-article-hide-boring-headers
1398 "s" gnus-article-hide-signature
1399 "c" gnus-article-hide-citation
1400 "C" gnus-article-hide-citation-in-followups
1401 "p" gnus-article-hide-pgp
1402 "P" gnus-article-hide-pem
1403 "\C-c" gnus-article-hide-citation-maybe)
1405 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1406 "a" gnus-article-highlight
1407 "h" gnus-article-highlight-headers
1408 "c" gnus-article-highlight-citation
1409 "s" gnus-article-highlight-signature)
1411 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1412 "w" gnus-article-decode-mime-words
1413 "c" gnus-article-decode-charset
1414 "v" gnus-mime-view-all-parts
1415 "b" gnus-article-view-part)
1417 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1418 "z" gnus-article-date-ut
1419 "u" gnus-article-date-ut
1420 "l" gnus-article-date-local
1421 "e" gnus-article-date-lapsed
1422 "o" gnus-article-date-original
1423 "i" gnus-article-date-iso8601
1424 "s" gnus-article-date-user)
1426 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1427 "t" gnus-article-remove-trailing-blank-lines
1428 "l" gnus-article-strip-leading-blank-lines
1429 "m" gnus-article-strip-multiple-blank-lines
1430 "a" gnus-article-strip-blank-lines
1431 "A" gnus-article-strip-all-blank-lines
1432 "s" gnus-article-strip-leading-space)
1434 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1436 "f" gnus-summary-fetch-faq
1437 "d" gnus-summary-describe-group
1438 "h" gnus-summary-describe-briefly
1439 "i" gnus-info-find-node)
1441 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1442 "e" gnus-summary-expire-articles
1443 "\M-\C-e" gnus-summary-expire-articles-now
1444 "\177" gnus-summary-delete-article
1445 [delete] gnus-summary-delete-article
1446 "m" gnus-summary-move-article
1447 "r" gnus-summary-respool-article
1448 "w" gnus-summary-edit-article
1449 "c" gnus-summary-copy-article
1450 "B" gnus-summary-crosspost-article
1451 "q" gnus-summary-respool-query
1452 "t" gnus-summary-respool-trace
1453 "i" gnus-summary-import-article
1454 "p" gnus-summary-article-posted-p)
1456 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1457 "o" gnus-summary-save-article
1458 "m" gnus-summary-save-article-mail
1459 "F" gnus-summary-write-article-file
1460 "r" gnus-summary-save-article-rmail
1461 "f" gnus-summary-save-article-file
1462 "b" gnus-summary-save-article-body-file
1463 "h" gnus-summary-save-article-folder
1464 "v" gnus-summary-save-article-vm
1465 "p" gnus-summary-pipe-output
1466 "s" gnus-soup-add-article))
1468 (defun gnus-summary-make-menu-bar ()
1469 (gnus-turn-off-edit-menu 'summary)
1471 (unless (boundp 'gnus-summary-misc-menu)
1474 gnus-summary-kill-menu gnus-summary-mode-map ""
1479 ["Enter score..." gnus-summary-score-entry t]
1480 ["Customize" gnus-score-customize t])
1481 (gnus-make-score-map 'increase)
1482 (gnus-make-score-map 'lower)
1484 ["Kill below" gnus-summary-kill-below t]
1485 ["Mark above" gnus-summary-mark-above t]
1486 ["Tick above" gnus-summary-tick-above t]
1487 ["Clear above" gnus-summary-clear-above t])
1488 ["Current score" gnus-summary-current-score t]
1489 ["Set score" gnus-summary-set-score t]
1490 ["Switch current score file..." gnus-score-change-score-file t]
1491 ["Set mark below..." gnus-score-set-mark-below t]
1492 ["Set expunge below..." gnus-score-set-expunge-below t]
1493 ["Edit current score file" gnus-score-edit-current-scores t]
1494 ["Edit score file" gnus-score-edit-file t]
1495 ["Trace score" gnus-score-find-trace t]
1496 ["Find words" gnus-score-find-favourite-words t]
1497 ["Rescore buffer" gnus-summary-rescore t]
1498 ["Increase score..." gnus-summary-increase-score t]
1499 ["Lower score..." gnus-summary-lower-score t]))))
1501 ;; Define both the Article menu in the summary buffer and the equivalent
1502 ;; Commands menu in the article buffer here for consistency.
1505 ["All" gnus-article-hide t]
1506 ["Headers" gnus-article-hide-headers t]
1507 ["Signature" gnus-article-hide-signature t]
1508 ["Citation" gnus-article-hide-citation t]
1509 ["PGP" gnus-article-hide-pgp t]
1510 ["Boring headers" gnus-article-hide-boring-headers t])
1512 ["All" gnus-article-highlight t]
1513 ["Headers" gnus-article-highlight-headers t]
1514 ["Signature" gnus-article-highlight-signature t]
1515 ["Citation" gnus-article-highlight-citation t])
1517 ["Words" gnus-article-decode-mime-words t]
1518 ["Charset" gnus-article-decode-charset t]
1519 ["QP" gnus-article-de-quoted-unreadable t]
1520 ["View all" gnus-mime-view-all-parts t])
1522 ["Local" gnus-article-date-local t]
1523 ["ISO8601" gnus-article-date-iso8601 t]
1524 ["UT" gnus-article-date-ut t]
1525 ["Original" gnus-article-date-original t]
1526 ["Lapsed" gnus-article-date-lapsed t]
1527 ["User-defined" gnus-article-date-user t])
1530 ["Leading" gnus-article-strip-leading-blank-lines t]
1531 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1532 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1533 ["All of the above" gnus-article-strip-blank-lines t]
1534 ["All" gnus-article-strip-all-blank-lines t]
1535 ["Leading space" gnus-article-strip-leading-space t])
1536 ["Overstrike" gnus-article-treat-overstrike t]
1537 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1538 ["Emphasis" gnus-article-emphasize t]
1539 ["Word wrap" gnus-article-fill-cited-article t]
1540 ["CR" gnus-article-remove-cr t]
1541 ["Show X-Face" gnus-article-display-x-face t]
1542 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1543 ["UnHTMLize" gnus-article-treat-html t]
1544 ["Rot 13" gnus-summary-caesar-message t]
1545 ["Unix pipe" gnus-summary-pipe-message t]
1546 ["Add buttons" gnus-article-add-buttons t]
1547 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1548 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1549 ["Verbose header" gnus-summary-verbose-headers t]
1550 ["Toggle header" gnus-summary-toggle-header t])
1552 ["Save in default format" gnus-summary-save-article t]
1553 ["Save in file" gnus-summary-save-article-file t]
1554 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1555 ["Save in MH folder" gnus-summary-save-article-folder t]
1556 ["Save in VM folder" gnus-summary-save-article-vm t]
1557 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1558 ["Save body in file" gnus-summary-save-article-body-file t]
1559 ["Pipe through a filter" gnus-summary-pipe-output t]
1560 ["Add to SOUP packet" gnus-soup-add-article t]
1561 ["Print" gnus-summary-print-article t])
1563 ["Respool article..." gnus-summary-respool-article t]
1564 ["Move article..." gnus-summary-move-article
1565 (gnus-check-backend-function
1566 'request-move-article gnus-newsgroup-name)]
1567 ["Copy article..." gnus-summary-copy-article t]
1568 ["Crosspost article..." gnus-summary-crosspost-article
1569 (gnus-check-backend-function
1570 'request-replace-article gnus-newsgroup-name)]
1571 ["Import file..." gnus-summary-import-article t]
1572 ["Check if posted" gnus-summary-article-posted-p t]
1573 ["Edit article" gnus-summary-edit-article
1574 (not (gnus-group-read-only-p))]
1575 ["Delete article" gnus-summary-delete-article
1576 (gnus-check-backend-function
1577 'request-expire-articles gnus-newsgroup-name)]
1578 ["Query respool" gnus-summary-respool-query t]
1579 ["Trace respool" gnus-summary-respool-trace t]
1580 ["Delete expirable articles" gnus-summary-expire-articles-now
1581 (gnus-check-backend-function
1582 'request-expire-articles gnus-newsgroup-name)])
1584 ["Uudecode" gnus-uu-decode-uu t]
1585 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1586 ["Unshar" gnus-uu-decode-unshar t]
1587 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1588 ["Save" gnus-uu-decode-save t]
1589 ["Binhex" gnus-uu-decode-binhex t]
1590 ["Postscript" gnus-uu-decode-postscript t])
1592 ["Enter article" gnus-cache-enter-article t]
1593 ["Remove article" gnus-cache-remove-article t])
1594 ["Select article buffer" gnus-summary-select-article-buffer t]
1595 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1596 ["Isearch article..." gnus-summary-isearch-article t]
1597 ["Beginning of the article" gnus-summary-beginning-of-article t]
1598 ["End of the article" gnus-summary-end-of-article t]
1599 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1600 ["Fetch referenced articles" gnus-summary-refer-references t]
1601 ["Fetch current thread" gnus-summary-refer-thread t]
1602 ["Fetch article with id..." gnus-summary-refer-article t]
1603 ["Redisplay" gnus-summary-show-article t])))
1605 gnus-summary-article-menu gnus-summary-mode-map ""
1606 (cons "Article" innards))
1609 gnus-article-commands-menu gnus-article-mode-map ""
1610 (cons "Commands" innards)))
1613 gnus-summary-thread-menu gnus-summary-mode-map ""
1615 ["Toggle threading" gnus-summary-toggle-threads t]
1616 ["Hide threads" gnus-summary-hide-all-threads t]
1617 ["Show threads" gnus-summary-show-all-threads t]
1618 ["Hide thread" gnus-summary-hide-thread t]
1619 ["Show thread" gnus-summary-show-thread t]
1620 ["Go to next thread" gnus-summary-next-thread t]
1621 ["Go to previous thread" gnus-summary-prev-thread t]
1622 ["Go down thread" gnus-summary-down-thread t]
1623 ["Go up thread" gnus-summary-up-thread t]
1624 ["Top of thread" gnus-summary-top-thread t]
1625 ["Mark thread as read" gnus-summary-kill-thread t]
1626 ["Lower thread score" gnus-summary-lower-thread t]
1627 ["Raise thread score" gnus-summary-raise-thread t]
1628 ["Rethread current" gnus-summary-rethread-current t]
1632 gnus-summary-post-menu gnus-summary-mode-map ""
1634 ["Post an article" gnus-summary-post-news t]
1635 ["Followup" gnus-summary-followup t]
1636 ["Followup and yank" gnus-summary-followup-with-original t]
1637 ["Supersede article" gnus-summary-supersede-article t]
1638 ["Cancel article" gnus-summary-cancel-article t]
1639 ["Reply" gnus-summary-reply t]
1640 ["Reply and yank" gnus-summary-reply-with-original t]
1641 ["Wide reply" gnus-summary-wide-reply t]
1642 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1643 ["Mail forward" gnus-summary-mail-forward t]
1644 ["Post forward" gnus-summary-post-forward t]
1645 ["Digest and mail" gnus-uu-digest-mail-forward t]
1646 ["Digest and post" gnus-uu-digest-post-forward t]
1647 ["Resend message" gnus-summary-resend-message t]
1648 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1649 ["Send a mail" gnus-summary-mail-other-window t]
1650 ["Uuencode and post" gnus-uu-post-news t]
1651 ["Followup via news" gnus-summary-followup-to-mail t]
1652 ["Followup via news and yank"
1653 gnus-summary-followup-to-mail-with-original t]
1655 ;;["Send" gnus-summary-send-draft t]
1656 ;;["Send bounced" gnus-resend-bounced-mail t])
1660 gnus-summary-misc-menu gnus-summary-mode-map ""
1663 ["Mark as read" gnus-summary-mark-as-read-forward t]
1664 ["Mark same subject and select"
1665 gnus-summary-kill-same-subject-and-select t]
1666 ["Mark same subject" gnus-summary-kill-same-subject t]
1667 ["Catchup" gnus-summary-catchup t]
1668 ["Catchup all" gnus-summary-catchup-all t]
1669 ["Catchup to here" gnus-summary-catchup-to-here t]
1670 ["Catchup region" gnus-summary-mark-region-as-read t]
1671 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1673 ["Tick" gnus-summary-tick-article-forward t]
1674 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1675 ["Remove marks" gnus-summary-clear-mark-forward t]
1676 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1677 ["Set bookmark" gnus-summary-set-bookmark t]
1678 ["Remove bookmark" gnus-summary-remove-bookmark t])
1680 ["Marks..." gnus-summary-limit-to-marks t]
1681 ["Subject..." gnus-summary-limit-to-subject t]
1682 ["Author..." gnus-summary-limit-to-author t]
1683 ["Age..." gnus-summary-limit-to-age t]
1684 ["Score" gnus-summary-limit-to-score t]
1685 ["Unread" gnus-summary-limit-to-unread t]
1686 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1687 ["Articles" gnus-summary-limit-to-articles t]
1688 ["Pop limit" gnus-summary-pop-limit t]
1689 ["Show dormant" gnus-summary-limit-include-dormant t]
1690 ["Hide childless dormant"
1691 gnus-summary-limit-exclude-childless-dormant t]
1692 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1693 ["Show expunged" gnus-summary-show-all-expunged t])
1695 ["Set mark" gnus-summary-mark-as-processable t]
1696 ["Remove mark" gnus-summary-unmark-as-processable t]
1697 ["Remove all marks" gnus-summary-unmark-all-processable t]
1698 ["Mark above" gnus-uu-mark-over t]
1699 ["Mark series" gnus-uu-mark-series t]
1700 ["Mark region" gnus-uu-mark-region t]
1701 ["Unmark region" gnus-uu-unmark-region t]
1702 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1703 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1704 ["Mark all" gnus-uu-mark-all t]
1705 ["Mark buffer" gnus-uu-mark-buffer t]
1706 ["Mark sparse" gnus-uu-mark-sparse t]
1707 ["Mark thread" gnus-uu-mark-thread t]
1708 ["Unmark thread" gnus-uu-unmark-thread t]
1709 ("Process Mark Sets"
1710 ["Kill" gnus-summary-kill-process-mark t]
1711 ["Yank" gnus-summary-yank-process-mark
1712 gnus-newsgroup-process-stack]
1713 ["Save" gnus-summary-save-process-mark t]))
1715 ["Page forward" gnus-summary-next-page t]
1716 ["Page backward" gnus-summary-prev-page t]
1717 ["Line forward" gnus-summary-scroll-up t])
1719 ["Next unread article" gnus-summary-next-unread-article t]
1720 ["Previous unread article" gnus-summary-prev-unread-article t]
1721 ["Next article" gnus-summary-next-article t]
1722 ["Previous article" gnus-summary-prev-article t]
1723 ["Next unread subject" gnus-summary-next-unread-subject t]
1724 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1725 ["Next article same subject" gnus-summary-next-same-subject t]
1726 ["Previous article same subject" gnus-summary-prev-same-subject t]
1727 ["First unread article" gnus-summary-first-unread-article t]
1728 ["Best unread article" gnus-summary-best-unread-article t]
1729 ["Go to subject number..." gnus-summary-goto-subject t]
1730 ["Go to article number..." gnus-summary-goto-article t]
1731 ["Go to the last article" gnus-summary-goto-last-article t]
1732 ["Pop article off history" gnus-summary-pop-article t])
1734 ["Sort by number" gnus-summary-sort-by-number t]
1735 ["Sort by author" gnus-summary-sort-by-author t]
1736 ["Sort by subject" gnus-summary-sort-by-subject t]
1737 ["Sort by date" gnus-summary-sort-by-date t]
1738 ["Sort by score" gnus-summary-sort-by-score t]
1739 ["Sort by lines" gnus-summary-sort-by-lines t])
1741 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1742 ["Describe group" gnus-summary-describe-group t]
1743 ["Read manual" gnus-info-find-node t])
1745 ["Pick and read" gnus-pick-mode t]
1746 ["Binary" gnus-binary-mode t])
1748 ["Regenerate" gnus-summary-prepare t]
1749 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1750 ["Toggle threading" gnus-summary-toggle-threads t])
1751 ["Filter articles..." gnus-summary-execute-command t]
1752 ["Run command on subjects..." gnus-summary-universal-argument t]
1753 ["Search articles forward..." gnus-summary-search-article-forward t]
1754 ["Search articles backward..." gnus-summary-search-article-backward t]
1755 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1756 ["Expand window" gnus-summary-expand-window t]
1757 ["Expire expirable articles" gnus-summary-expire-articles
1758 (gnus-check-backend-function
1759 'request-expire-articles gnus-newsgroup-name)]
1760 ["Edit local kill file" gnus-summary-edit-local-kill t]
1761 ["Edit main kill file" gnus-summary-edit-global-kill t]
1762 ["Edit group parameters" gnus-summary-edit-parameters t]
1763 ["Send a bug report" gnus-bug t]
1765 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1766 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1767 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1768 ["Exit group" gnus-summary-exit t]
1769 ["Exit group without updating" gnus-summary-exit-no-update t]
1770 ["Exit and goto next group" gnus-summary-next-group t]
1771 ["Exit and goto prev group" gnus-summary-prev-group t]
1772 ["Reselect group" gnus-summary-reselect-current-group t]
1773 ["Rescan group" gnus-summary-rescan-group t]
1774 ["Update dribble" gnus-summary-save-newsrc t])))
1776 (gnus-run-hooks 'gnus-summary-menu-hook)))
1778 (defun gnus-score-set-default (var value)
1779 "A version of set that updates the GNU Emacs menu-bar."
1781 ;; It is the message that forces the active status to be updated.
1784 (defun gnus-make-score-map (type)
1785 "Make a summary score map of type TYPE."
1788 (let ((headers '(("author" "from" string)
1789 ("subject" "subject" string)
1790 ("article body" "body" string)
1791 ("article head" "head" string)
1792 ("xref" "xref" string)
1793 ("lines" "lines" number)
1794 ("followups to author" "followup" string)))
1795 (types '((number ("less than" <)
1798 (string ("substring" s)
1802 (perms '(("temporary" (current-time-string))
1810 (if (eq type 'lower)
1815 (setq header (car headers))
1821 (let ((ts (cdr (assoc (nth 2 header) types)))
1837 'gnus-summary-score-entry
1839 (if (or (string= (nth 1 header)
1841 (string= (nth 1 header)
1844 (list 'gnus-summary-header
1846 (list 'quote (nth 1 (car ts)))
1847 (list 'gnus-score-default nil)
1853 (list (nreverse outp))))
1856 (list (nreverse outt))))
1858 (setq headers (cdr headers)))
1859 (list (nreverse outh))))))))
1863 (defun gnus-summary-mode (&optional group)
1864 "Major mode for reading articles.
1866 All normal editing commands are switched off.
1867 \\<gnus-summary-mode-map>
1868 Each line in this buffer represents one article. To read an
1869 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1870 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1873 You can also post articles and send mail from this buffer. To
1874 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1875 of an article, type `\\[gnus-summary-reply]'.
1877 There are approx. one gazillion commands you can execute in this
1878 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1880 The following commands are available:
1882 \\{gnus-summary-mode-map}"
1884 (when (gnus-visual-p 'summary-menu 'menu)
1885 (gnus-summary-make-menu-bar))
1886 (kill-all-local-variables)
1887 (gnus-summary-make-local-variables)
1888 (gnus-make-thread-indent-array)
1889 (gnus-simplify-mode-line)
1890 (setq major-mode 'gnus-summary-mode)
1891 (setq mode-name "Summary")
1892 (make-local-variable 'minor-mode-alist)
1893 (use-local-map gnus-summary-mode-map)
1894 (buffer-disable-undo)
1895 (setq buffer-read-only t) ;Disable modification
1896 (setq truncate-lines t)
1897 (setq selective-display t)
1898 (setq selective-display-ellipses t) ;Display `...'
1899 (gnus-summary-set-display-table)
1900 (gnus-set-default-directory)
1901 (setq gnus-newsgroup-name group)
1902 (make-local-variable 'gnus-summary-line-format)
1903 (make-local-variable 'gnus-summary-line-format-spec)
1904 (make-local-variable 'gnus-summary-dummy-line-format)
1905 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1906 (make-local-variable 'gnus-summary-mark-positions)
1907 (make-local-hook 'post-command-hook)
1908 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1909 (make-local-hook 'pre-command-hook)
1910 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1911 (gnus-run-hooks 'gnus-summary-mode-hook)
1912 (mm-enable-multibyte)
1913 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1914 (gnus-update-summary-mark-positions))
1916 (defun gnus-summary-make-local-variables ()
1917 "Make all the local summary buffer variables."
1918 (let ((locals gnus-summary-local-variables)
1920 (while (setq local (pop locals))
1923 (if (eq (cdr local) 'global)
1924 ;; Copy the global value of the variable.
1925 (setq global (symbol-value (car local)))
1926 ;; Use the value from the list.
1927 (setq global (eval (cdr local))))
1928 (make-local-variable (car local))
1929 (set (car local) global))
1930 ;; Simple nil-valued local variable.
1931 (make-local-variable local)
1934 (defun gnus-summary-clear-local-variables ()
1935 (let ((locals gnus-summary-local-variables))
1937 (if (consp (car locals))
1938 (and (vectorp (caar locals))
1939 (set (caar locals) nil))
1940 (and (vectorp (car locals))
1941 (set (car locals) nil)))
1942 (setq locals (cdr locals)))))
1944 ;; Summary data functions.
1946 (defmacro gnus-data-number (data)
1949 (defmacro gnus-data-set-number (data number)
1950 `(setcar ,data ,number))
1952 (defmacro gnus-data-mark (data)
1955 (defmacro gnus-data-set-mark (data mark)
1956 `(setcar (nthcdr 1 ,data) ,mark))
1958 (defmacro gnus-data-pos (data)
1961 (defmacro gnus-data-set-pos (data pos)
1962 `(setcar (nthcdr 2 ,data) ,pos))
1964 (defmacro gnus-data-header (data)
1967 (defmacro gnus-data-set-header (data header)
1968 `(setf (nth 3 ,data) ,header))
1970 (defmacro gnus-data-level (data)
1973 (defmacro gnus-data-unread-p (data)
1974 `(= (nth 1 ,data) gnus-unread-mark))
1976 (defmacro gnus-data-read-p (data)
1977 `(/= (nth 1 ,data) gnus-unread-mark))
1979 (defmacro gnus-data-pseudo-p (data)
1980 `(consp (nth 3 ,data)))
1982 (defmacro gnus-data-find (number)
1983 `(assq ,number gnus-newsgroup-data))
1985 (defmacro gnus-data-find-list (number &optional data)
1986 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1987 (memq (assq ,number bdata)
1990 (defmacro gnus-data-make (number mark pos header level)
1991 `(list ,number ,mark ,pos ,header ,level))
1993 (defun gnus-data-enter (after-article number mark pos header level offset)
1994 (let ((data (gnus-data-find-list after-article)))
1996 (error "No such article: %d" after-article))
1997 (setcdr data (cons (gnus-data-make number mark pos header level)
1999 (setq gnus-newsgroup-data-reverse nil)
2000 (gnus-data-update-list (cddr data) offset)))
2002 (defun gnus-data-enter-list (after-article list &optional offset)
2004 (let ((data (and after-article (gnus-data-find-list after-article)))
2008 (let ((odata gnus-newsgroup-data))
2009 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2011 (gnus-data-update-list odata offset)))
2012 ;; Find the last element in the list to be spliced into the main
2015 (setq list (cdr list)))
2018 (setcdr list gnus-newsgroup-data)
2019 (setq gnus-newsgroup-data ilist)
2021 (gnus-data-update-list (cdr list) offset)))
2022 (setcdr list (cdr data))
2025 (gnus-data-update-list (cdr list) offset))))
2026 (setq gnus-newsgroup-data-reverse nil))))
2028 (defun gnus-data-remove (article &optional offset)
2029 (let ((data gnus-newsgroup-data))
2030 (if (= (gnus-data-number (car data)) article)
2032 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2033 gnus-newsgroup-data-reverse nil)
2035 (gnus-data-update-list gnus-newsgroup-data offset)))
2037 (when (= (gnus-data-number (cadr data)) article)
2038 (setcdr data (cddr data))
2040 (gnus-data-update-list (cdr data) offset))
2042 gnus-newsgroup-data-reverse nil))
2043 (setq data (cdr data))))))
2045 (defmacro gnus-data-list (backward)
2047 (or gnus-newsgroup-data-reverse
2048 (setq gnus-newsgroup-data-reverse
2049 (reverse gnus-newsgroup-data)))
2050 gnus-newsgroup-data))
2052 (defun gnus-data-update-list (data offset)
2053 "Add OFFSET to the POS of all data entries in DATA."
2054 (setq gnus-newsgroup-data-reverse nil)
2056 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2057 (setq data (cdr data))))
2059 (defun gnus-summary-article-pseudo-p (article)
2060 "Say whether this article is a pseudo article or not."
2061 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2063 (defmacro gnus-summary-article-sparse-p (article)
2064 "Say whether this article is a sparse article or not."
2065 `(memq ,article gnus-newsgroup-sparse))
2067 (defmacro gnus-summary-article-ancient-p (article)
2068 "Say whether this article is a sparse article or not."
2069 `(memq ,article gnus-newsgroup-ancient))
2071 (defun gnus-article-parent-p (number)
2072 "Say whether this article is a parent or not."
2073 (let ((data (gnus-data-find-list number)))
2074 (and (cdr data) ; There has to be an article after...
2075 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2076 (gnus-data-level (nth 1 data))))))
2078 (defun gnus-article-children (number)
2079 "Return a list of all children to NUMBER."
2080 (let* ((data (gnus-data-find-list number))
2081 (level (gnus-data-level (car data)))
2083 (setq data (cdr data))
2085 (= (gnus-data-level (car data)) (1+ level)))
2086 (push (gnus-data-number (car data)) children)
2087 (setq data (cdr data)))
2090 (defmacro gnus-summary-skip-intangible ()
2091 "If the current article is intangible, then jump to a different article."
2092 '(let ((to (get-text-property (point) 'gnus-intangible)))
2093 (and to (gnus-summary-goto-subject to))))
2095 (defmacro gnus-summary-article-intangible-p ()
2096 "Say whether this article is intangible or not."
2097 '(get-text-property (point) 'gnus-intangible))
2099 (defun gnus-article-read-p (article)
2100 "Say whether ARTICLE is read or not."
2101 (not (or (memq article gnus-newsgroup-marked)
2102 (memq article gnus-newsgroup-unreads)
2103 (memq article gnus-newsgroup-unselected)
2104 (memq article gnus-newsgroup-dormant))))
2106 ;; Some summary mode macros.
2108 (defmacro gnus-summary-article-number ()
2109 "The article number of the article on the current line.
2110 If there isn's an article number here, then we return the current
2113 (gnus-summary-skip-intangible)
2114 (or (get-text-property (point) 'gnus-number)
2115 (gnus-summary-last-subject))))
2117 (defmacro gnus-summary-article-header (&optional number)
2118 "Return the header of article NUMBER."
2119 `(gnus-data-header (gnus-data-find
2120 ,(or number '(gnus-summary-article-number)))))
2122 (defmacro gnus-summary-thread-level (&optional number)
2123 "Return the level of thread that starts with article NUMBER."
2124 `(if (and (eq gnus-summary-make-false-root 'dummy)
2125 (get-text-property (point) 'gnus-intangible))
2127 (gnus-data-level (gnus-data-find
2128 ,(or number '(gnus-summary-article-number))))))
2130 (defmacro gnus-summary-article-mark (&optional number)
2131 "Return the mark of article NUMBER."
2132 `(gnus-data-mark (gnus-data-find
2133 ,(or number '(gnus-summary-article-number)))))
2135 (defmacro gnus-summary-article-pos (&optional number)
2136 "Return the position of the line of article NUMBER."
2137 `(gnus-data-pos (gnus-data-find
2138 ,(or number '(gnus-summary-article-number)))))
2140 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2141 (defmacro gnus-summary-article-subject (&optional number)
2142 "Return current subject string or nil if nothing."
2145 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2146 '(gnus-data-header (assq (gnus-summary-article-number)
2147 gnus-newsgroup-data)))))
2150 (mail-header-subject headers))))
2152 (defmacro gnus-summary-article-score (&optional number)
2153 "Return current article score."
2154 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2155 gnus-newsgroup-scored))
2156 gnus-summary-default-score 0))
2158 (defun gnus-summary-article-children (&optional number)
2159 "Return a list of article numbers that are children of article NUMBER."
2160 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2161 (level (gnus-data-level (car data)))
2163 (while (and (setq data (cdr data))
2164 (> (setq l (gnus-data-level (car data))) level))
2165 (and (= (1+ level) l)
2166 (push (gnus-data-number (car data))
2168 (nreverse children)))
2170 (defun gnus-summary-article-parent (&optional number)
2171 "Return the article number of the parent of article NUMBER."
2172 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2173 (gnus-data-list t)))
2174 (level (gnus-data-level (car data))))
2176 () ; This is a root.
2177 ;; We search until we find an article with a level less than
2178 ;; this one. That function has to be the parent.
2179 (while (and (setq data (cdr data))
2180 (not (< (gnus-data-level (car data)) level))))
2181 (and data (gnus-data-number (car data))))))
2183 (defun gnus-unread-mark-p (mark)
2184 "Say whether MARK is the unread mark."
2185 (= mark gnus-unread-mark))
2187 (defun gnus-read-mark-p (mark)
2188 "Say whether MARK is one of the marks that mark as read.
2189 This is all marks except unread, ticked, dormant, and expirable."
2190 (not (or (= mark gnus-unread-mark)
2191 (= mark gnus-ticked-mark)
2192 (= mark gnus-dormant-mark)
2193 (= mark gnus-expirable-mark))))
2195 (defmacro gnus-article-mark (number)
2196 "Return the MARK of article NUMBER.
2197 This macro should only be used when computing the mark the \"first\"
2198 time; i.e., when generating the summary lines. After that,
2199 `gnus-summary-article-mark' should be used to examine the
2202 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2203 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2204 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2205 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2206 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2207 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2208 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2209 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2210 gnus-ancient-mark))))
2212 ;; Saving hidden threads.
2214 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2215 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2217 (defmacro gnus-save-hidden-threads (&rest forms)
2218 "Save hidden threads, eval FORMS, and restore the hidden threads."
2219 (let ((config (make-symbol "config")))
2220 `(let ((,config (gnus-hidden-threads-configuration)))
2224 (gnus-restore-hidden-threads-configuration ,config)))))
2226 (defun gnus-data-compute-positions ()
2227 "Compute the positions of all articles."
2228 (setq gnus-newsgroup-data-reverse nil)
2229 (let ((data gnus-newsgroup-data))
2231 (gnus-save-hidden-threads
2232 (gnus-summary-show-all-threads)
2233 (goto-char (point-min))
2235 (while (get-text-property (point) 'gnus-intangible)
2237 (gnus-data-set-pos (car data) (+ (point) 3))
2238 (setq data (cdr data))
2239 (forward-line 1))))))
2241 (defun gnus-hidden-threads-configuration ()
2242 "Return the current hidden threads configuration."
2245 (goto-char (point-min))
2246 (while (search-forward "\r" nil t)
2247 (push (1- (point)) config))
2250 (defun gnus-restore-hidden-threads-configuration (config)
2251 "Restore hidden threads configuration from CONFIG."
2252 (let (point buffer-read-only)
2253 (while (setq point (pop config))
2254 (when (and (< point (point-max))
2256 (eq (char-after) ?\n))
2257 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2259 ;; Various summary mode internalish functions.
2261 (defun gnus-mouse-pick-article (e)
2264 (gnus-summary-next-page nil t))
2266 (defun gnus-summary-set-display-table ()
2267 ;; Change the display table. Odd characters have a tendency to mess
2268 ;; up nicely formatted displays - we make all possible glyphs
2269 ;; display only a single character.
2271 ;; We start from the standard display table, if any.
2272 (let ((table (or (copy-sequence standard-display-table)
2273 (make-display-table)))
2275 ;; Nix out all the control chars...
2276 (while (>= (setq i (1- i)) 0)
2277 (aset table i [??]))
2278 ;; ... but not newline and cr, of course. (cr is necessary for the
2279 ;; selective display).
2280 (aset table ?\n nil)
2281 (aset table ?\r nil)
2282 ;; We keep TAB as well.
2283 (aset table ?\t nil)
2284 ;; We nix out any glyphs over 126 that are not set already.
2286 (while (>= (setq i (1- i)) 127)
2287 ;; Only modify if the entry is nil.
2288 (unless (aref table i)
2289 (aset table i [??]))))
2290 (setq buffer-display-table table)))
2292 (defun gnus-summary-setup-buffer (group)
2293 "Initialize summary buffer."
2294 (let ((buffer (concat "*Summary " group "*")))
2295 (if (get-buffer buffer)
2298 (setq gnus-summary-buffer (current-buffer))
2299 (not gnus-newsgroup-prepared))
2300 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2301 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2302 (gnus-summary-mode group)
2304 (gnus-carpal-setup-buffer 'summary))
2305 (unless gnus-single-article-buffer
2306 (make-local-variable 'gnus-article-buffer)
2307 (make-local-variable 'gnus-article-current)
2308 (make-local-variable 'gnus-original-article-buffer))
2309 (setq gnus-newsgroup-name group)
2312 (defun gnus-set-global-variables ()
2313 ;; Set the global equivalents of the summary buffer-local variables
2314 ;; to the latest values they had. These reflect the summary buffer
2315 ;; that was in action when the last article was fetched.
2316 (when (eq major-mode 'gnus-summary-mode)
2317 (setq gnus-summary-buffer (current-buffer))
2318 (let ((name gnus-newsgroup-name)
2319 (marked gnus-newsgroup-marked)
2320 (unread gnus-newsgroup-unreads)
2321 (headers gnus-current-headers)
2322 (data gnus-newsgroup-data)
2323 (summary gnus-summary-buffer)
2324 (article-buffer gnus-article-buffer)
2325 (original gnus-original-article-buffer)
2326 (gac gnus-article-current)
2327 (reffed gnus-reffed-article-number)
2328 (score-file gnus-current-score-file))
2330 (set-buffer gnus-group-buffer)
2331 (setq gnus-newsgroup-name name
2332 gnus-newsgroup-marked marked
2333 gnus-newsgroup-unreads unread
2334 gnus-current-headers headers
2335 gnus-newsgroup-data data
2336 gnus-article-current gac
2337 gnus-summary-buffer summary
2338 gnus-article-buffer article-buffer
2339 gnus-original-article-buffer original
2340 gnus-reffed-article-number reffed
2341 gnus-current-score-file score-file)
2342 ;; The article buffer also has local variables.
2343 (when (gnus-buffer-live-p gnus-article-buffer)
2344 (set-buffer gnus-article-buffer)
2345 (setq gnus-summary-buffer summary))))))
2347 (defun gnus-summary-article-unread-p (article)
2348 "Say whether ARTICLE is unread or not."
2349 (memq article gnus-newsgroup-unreads))
2351 (defun gnus-summary-first-article-p (&optional article)
2352 "Return whether ARTICLE is the first article in the buffer."
2353 (if (not (setq article (or article (gnus-summary-article-number))))
2355 (eq article (caar gnus-newsgroup-data))))
2357 (defun gnus-summary-last-article-p (&optional article)
2358 "Return whether ARTICLE is the last article in the buffer."
2359 (if (not (setq article (or article (gnus-summary-article-number))))
2360 t ; All non-existent numbers are the last article. :-)
2361 (not (cdr (gnus-data-find-list article)))))
2363 (defun gnus-make-thread-indent-array ()
2365 (unless (and gnus-thread-indent-array
2366 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2367 (setq gnus-thread-indent-array (make-vector 201 "")
2368 gnus-thread-indent-array-level gnus-thread-indent-level)
2370 (aset gnus-thread-indent-array n
2371 (make-string (* n gnus-thread-indent-level) ? ))
2374 (defun gnus-update-summary-mark-positions ()
2375 "Compute where the summary marks are to go."
2377 (when (gnus-buffer-exists-p gnus-summary-buffer)
2378 (set-buffer gnus-summary-buffer))
2379 (let ((gnus-replied-mark 129)
2380 (gnus-score-below-mark 130)
2381 (gnus-score-over-mark 130)
2382 (gnus-download-mark 131)
2383 (spec gnus-summary-line-format-spec)
2386 (gnus-set-work-buffer)
2387 (let ((gnus-summary-line-format-spec spec)
2388 (gnus-newsgroup-downloadable '((0 . t))))
2389 (gnus-summary-insert-line
2390 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2391 (goto-char (point-min))
2392 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2394 (goto-char (point-min))
2395 (push (cons 'replied (and (search-forward "\201" nil t)
2398 (goto-char (point-min))
2399 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2401 (goto-char (point-min))
2402 (push (cons 'download
2403 (and (search-forward "\203" nil t) (- (point) 2)))
2405 (setq gnus-summary-mark-positions pos))))
2407 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2408 "Insert a dummy root in the summary buffer."
2410 (gnus-add-text-properties
2411 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2412 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2414 (defun gnus-summary-insert-line (gnus-tmp-header
2415 gnus-tmp-level gnus-tmp-current
2416 gnus-tmp-unread gnus-tmp-replied
2417 gnus-tmp-expirable gnus-tmp-subject-or-nil
2418 &optional gnus-tmp-dummy gnus-tmp-score
2420 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2421 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2422 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2423 (gnus-tmp-score-char
2424 (if (or (null gnus-summary-default-score)
2425 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2426 gnus-summary-zcore-fuzz))
2428 (if (< gnus-tmp-score gnus-summary-default-score)
2429 gnus-score-below-mark gnus-score-over-mark)))
2431 (cond (gnus-tmp-process gnus-process-mark)
2432 ((memq gnus-tmp-current gnus-newsgroup-cached)
2434 (gnus-tmp-replied gnus-replied-mark)
2435 ((memq gnus-tmp-current gnus-newsgroup-saved)
2437 (t gnus-unread-mark)))
2438 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2441 ((string-match "<[^>]+> *$" gnus-tmp-from)
2442 (let ((beg (match-beginning 0)))
2443 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2444 (substring gnus-tmp-from (1+ (match-beginning 0))
2445 (1- (match-end 0))))
2446 (substring gnus-tmp-from 0 beg))))
2447 ((string-match "(.+)" gnus-tmp-from)
2448 (substring gnus-tmp-from
2449 (1+ (match-beginning 0)) (1- (match-end 0))))
2451 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2452 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2453 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2454 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2455 (buffer-read-only nil))
2456 (when (string= gnus-tmp-name "")
2457 (setq gnus-tmp-name gnus-tmp-from))
2458 (unless (numberp gnus-tmp-lines)
2459 (setq gnus-tmp-lines 0))
2460 (gnus-put-text-property
2462 (progn (eval gnus-summary-line-format-spec) (point))
2463 'gnus-number gnus-tmp-number)
2464 (when (gnus-visual-p 'summary-highlight 'highlight)
2466 (gnus-run-hooks 'gnus-summary-update-hook)
2469 (defun gnus-summary-update-line (&optional dont-update)
2470 ;; Update summary line after change.
2471 (when (and gnus-summary-default-score
2472 (not gnus-summary-inhibit-highlight))
2473 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2474 (article (gnus-summary-article-number))
2475 (score (gnus-summary-article-score article)))
2477 (if (and gnus-summary-mark-below
2478 (< (gnus-summary-article-score)
2479 gnus-summary-mark-below))
2480 ;; This article has a low score, so we mark it as read.
2481 (when (memq article gnus-newsgroup-unreads)
2482 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2483 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2484 ;; This article was previously marked as read on account
2485 ;; of a low score, but now it has risen, so we mark it as
2487 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2488 (gnus-summary-update-mark
2489 (if (or (null gnus-summary-default-score)
2490 (<= (abs (- score gnus-summary-default-score))
2491 gnus-summary-zcore-fuzz))
2493 (if (< score gnus-summary-default-score)
2494 gnus-score-below-mark gnus-score-over-mark))
2496 ;; Do visual highlighting.
2497 (when (gnus-visual-p 'summary-highlight 'highlight)
2498 (gnus-run-hooks 'gnus-summary-update-hook)))))
2500 (defvar gnus-tmp-new-adopts nil)
2502 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2503 "Return the number of articles in THREAD.
2504 This may be 0 in some cases -- if none of the articles in
2505 the thread are to be displayed."
2507 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2509 ((not (listp thread))
2511 ((and (consp thread) (cdr thread))
2514 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2517 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2520 (when (and level (zerop level) gnus-tmp-new-adopts)
2523 'gnus-summary-number-of-articles-in-thread
2524 gnus-tmp-new-adopts))))
2526 (if (> number 1) gnus-not-empty-thread-mark
2527 gnus-empty-thread-mark)
2530 (defun gnus-summary-set-local-parameters (group)
2531 "Go through the local params of GROUP and set all variable specs in that list."
2532 (let ((params (gnus-group-find-parameter group))
2535 (setq elem (car params)
2536 params (cdr params))
2537 (and (consp elem) ; Has to be a cons.
2538 (consp (cdr elem)) ; The cdr has to be a list.
2539 (symbolp (car elem)) ; Has to be a symbol in there.
2540 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2541 (ignore-errors ; So we set it.
2542 (make-local-variable (car elem))
2543 (set (car elem) (eval (nth 1 elem))))))))
2545 (defun gnus-summary-read-group (group &optional show-all no-article
2546 kill-buffer no-display backward
2548 "Start reading news in newsgroup GROUP.
2549 If SHOW-ALL is non-nil, already read articles are also listed.
2550 If NO-ARTICLE is non-nil, no article is selected initially.
2551 If NO-DISPLAY, don't generate a summary buffer."
2555 (let ((gnus-auto-select-next nil))
2556 (or (gnus-summary-read-group-1
2557 group show-all no-article
2558 kill-buffer no-display
2561 select-articles nil)))))
2562 (eq gnus-auto-select-next 'quietly))
2563 (set-buffer gnus-group-buffer)
2564 ;; The entry function called above goes to the next
2565 ;; group automatically, so we go two groups back
2566 ;; if we are searching for the previous group.
2568 (gnus-group-prev-unread-group 2))
2569 (if (not (equal group (gnus-group-group-name)))
2570 (setq group (gnus-group-group-name))
2574 (defun gnus-summary-read-group-1 (group show-all no-article
2575 kill-buffer no-display
2576 &optional select-articles)
2577 ;; Killed foreign groups can't be entered.
2578 (when (and (not (gnus-group-native-p group))
2579 (not (gnus-gethash group gnus-newsrc-hashtb)))
2580 (error "Dead non-native groups can't be entered"))
2581 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2582 (let* ((new-group (gnus-summary-setup-buffer group))
2583 (quit-config (gnus-group-quit-config group))
2584 (did-select (and new-group (gnus-select-newsgroup
2585 group show-all select-articles))))
2587 ;; This summary buffer exists already, so we just select it.
2589 (gnus-set-global-variables)
2591 (gnus-kill-or-deaden-summary kill-buffer))
2592 (gnus-configure-windows 'summary 'force)
2593 (gnus-set-mode-line 'summary)
2594 (gnus-summary-position-point)
2597 ;; We couldn't select this group.
2599 (when (and (eq major-mode 'gnus-summary-mode)
2600 (not (equal (current-buffer) kill-buffer)))
2601 (kill-buffer (current-buffer))
2602 (if (not quit-config)
2604 ;; Update the info -- marks might need to be removed,
2606 (gnus-summary-update-info)
2607 (set-buffer gnus-group-buffer)
2608 (gnus-group-jump-to-group group)
2609 (gnus-group-next-unread-group 1))
2610 (gnus-handle-ephemeral-exit quit-config)))
2611 (gnus-message 3 "Can't select group")
2613 ;; The user did a `C-g' while prompting for number of articles,
2614 ;; so we exit this group.
2615 ((eq did-select 'quit)
2616 (and (eq major-mode 'gnus-summary-mode)
2617 (not (equal (current-buffer) kill-buffer))
2618 (kill-buffer (current-buffer)))
2620 (gnus-kill-or-deaden-summary kill-buffer))
2621 (if (not quit-config)
2623 (set-buffer gnus-group-buffer)
2624 (gnus-group-jump-to-group group)
2625 (gnus-group-next-unread-group 1)
2626 (gnus-configure-windows 'group 'force))
2627 (gnus-handle-ephemeral-exit quit-config))
2628 ;; Finally signal the quit.
2630 ;; The group was successfully selected.
2632 (gnus-set-global-variables)
2633 ;; Save the active value in effect when the group was entered.
2634 (setq gnus-newsgroup-active
2636 (gnus-active gnus-newsgroup-name)))
2637 ;; You can change the summary buffer in some way with this hook.
2638 (gnus-run-hooks 'gnus-select-group-hook)
2639 ;; Set any local variables in the group parameters.
2640 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2641 (gnus-update-format-specifications
2642 nil 'summary 'summary-mode 'summary-dummy)
2643 ;; Do score processing.
2644 (when gnus-use-scoring
2645 (gnus-possibly-score-headers))
2646 ;; Check whether to fill in the gaps in the threads.
2647 (when gnus-build-sparse-threads
2648 (gnus-build-sparse-threads))
2649 ;; Find the initial limit.
2650 (if gnus-show-threads
2652 (let ((gnus-newsgroup-dormant nil))
2653 (gnus-summary-initial-limit show-all))
2654 (gnus-summary-initial-limit show-all))
2655 (setq gnus-newsgroup-limit
2657 (lambda (header) (mail-header-number header))
2658 gnus-newsgroup-headers)))
2659 ;; Generate the summary buffer.
2661 (gnus-summary-prepare))
2662 (when gnus-use-trees
2663 (gnus-tree-open group)
2664 (setq gnus-summary-highlight-line-function
2665 'gnus-tree-highlight-article))
2666 ;; If the summary buffer is empty, but there are some low-scored
2667 ;; articles or some excluded dormants, we include these in the
2669 (when (and (zerop (buffer-size))
2671 (cond (gnus-newsgroup-dormant
2672 (gnus-summary-limit-include-dormant))
2673 ((and gnus-newsgroup-scored show-all)
2674 (gnus-summary-limit-include-expunged t))))
2675 ;; Function `gnus-apply-kill-file' must be called in this hook.
2676 (gnus-run-hooks 'gnus-apply-kill-hook)
2677 (if (and (zerop (buffer-size))
2680 ;; This newsgroup is empty.
2681 (gnus-summary-catchup-and-exit nil t)
2682 (gnus-message 6 "No unread news")
2684 (gnus-kill-or-deaden-summary kill-buffer))
2685 ;; Return nil from this function.
2687 ;; Hide conversation thread subtrees. We cannot do this in
2688 ;; gnus-summary-prepare-hook since kill processing may not
2689 ;; work with hidden articles.
2690 (and gnus-show-threads
2691 gnus-thread-hide-subtree
2692 (gnus-summary-hide-all-threads))
2694 (gnus-kill-or-deaden-summary kill-buffer))
2695 ;; Show first unread article if requested.
2696 (if (and (not no-article)
2698 gnus-newsgroup-unreads
2699 gnus-auto-select-first)
2701 (gnus-configure-windows 'summary)
2703 ((eq gnus-auto-select-first 'best)
2704 (gnus-summary-best-unread-article))
2705 ((eq gnus-auto-select-first t)
2706 (gnus-summary-first-unread-article))
2707 ((gnus-functionp gnus-auto-select-first)
2708 (funcall gnus-auto-select-first))))
2709 ;; Don't select any articles, just move point to the first
2710 ;; article in the group.
2711 (goto-char (point-min))
2712 (gnus-summary-position-point)
2713 (gnus-configure-windows 'summary 'force)
2714 (gnus-set-mode-line 'summary))
2715 (when (get-buffer-window gnus-group-buffer t)
2716 ;; Gotta use windows, because recenter does weird stuff if
2717 ;; the current buffer ain't the displayed window.
2718 (let ((owin (selected-window)))
2719 (select-window (get-buffer-window gnus-group-buffer t))
2720 (when (gnus-group-goto-group group)
2722 (select-window owin)))
2723 ;; Mark this buffer as "prepared".
2724 (setq gnus-newsgroup-prepared t)
2725 (gnus-run-hooks 'gnus-summary-prepared-hook)
2728 (defun gnus-summary-prepare ()
2729 "Generate the summary buffer."
2731 (let ((buffer-read-only nil))
2733 (setq gnus-newsgroup-data nil
2734 gnus-newsgroup-data-reverse nil)
2735 (gnus-run-hooks 'gnus-summary-generate-hook)
2736 ;; Generate the buffer, either with threads or without.
2737 (when gnus-newsgroup-headers
2738 (gnus-summary-prepare-threads
2739 (if gnus-show-threads
2740 (gnus-sort-gathered-threads
2741 (funcall gnus-summary-thread-gathering-function
2743 (gnus-cut-threads (gnus-make-threads)))))
2744 ;; Unthreaded display.
2745 (gnus-sort-articles gnus-newsgroup-headers))))
2746 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2747 ;; Call hooks for modifying summary buffer.
2748 (goto-char (point-min))
2749 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2751 (defsubst gnus-general-simplify-subject (subject)
2752 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2755 ;; Truncate the subject.
2756 (gnus-simplify-subject-functions
2757 (gnus-map-function gnus-simplify-subject-functions subject))
2758 ((numberp gnus-summary-gather-subject-limit)
2759 (setq subject (gnus-simplify-subject-re subject))
2760 (if (> (length subject) gnus-summary-gather-subject-limit)
2761 (substring subject 0 gnus-summary-gather-subject-limit)
2763 ;; Fuzzily simplify it.
2764 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2765 (gnus-simplify-subject-fuzzy subject))
2766 ;; Just remove the leading "Re:".
2768 (gnus-simplify-subject-re subject))))
2770 (if (and gnus-summary-gather-exclude-subject
2771 (string-match gnus-summary-gather-exclude-subject subject))
2772 nil ; This article shouldn't be gathered
2775 (defun gnus-summary-simplify-subject-query ()
2776 "Query where the respool algorithm would put this article."
2778 (gnus-summary-select-article)
2779 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2781 (defun gnus-gather-threads-by-subject (threads)
2782 "Gather threads by looking at Subject headers."
2783 (if (not gnus-summary-make-false-root)
2785 (let ((hashtb (gnus-make-hashtable 1024))
2788 subject hthread whole-subject)
2790 (setq subject (gnus-general-simplify-subject
2791 (setq whole-subject (mail-header-subject
2794 (if (setq hthread (gnus-gethash subject hashtb))
2796 ;; We enter a dummy root into the thread, if we
2797 ;; haven't done that already.
2798 (unless (stringp (caar hthread))
2799 (setcar hthread (list whole-subject (car hthread))))
2800 ;; We add this new gathered thread to this gathered
2802 (setcdr (car hthread)
2803 (nconc (cdar hthread) (list (car threads))))
2804 ;; Remove it from the list of threads.
2805 (setcdr prev (cdr threads))
2806 (setq threads prev))
2807 ;; Enter this thread into the hash table.
2808 (gnus-sethash subject threads hashtb)))
2810 (setq threads (cdr threads)))
2813 (defun gnus-gather-threads-by-references (threads)
2814 "Gather threads by looking at References headers."
2815 (let ((idhashtb (gnus-make-hashtable 1024))
2816 (thhashtb (gnus-make-hashtable 1024))
2819 ids references id gthread gid entered ref)
2821 (when (setq references (mail-header-references (caar threads)))
2822 (setq id (mail-header-id (caar threads))
2823 ids (gnus-split-references references)
2825 (while (setq ref (pop ids))
2826 (setq ids (delete ref ids))
2827 (if (not (setq gid (gnus-gethash ref idhashtb)))
2829 (gnus-sethash ref id idhashtb)
2830 (gnus-sethash id threads thhashtb))
2831 (setq gthread (gnus-gethash gid thhashtb))
2833 ;; We enter a dummy root into the thread, if we
2834 ;; haven't done that already.
2835 (unless (stringp (caar gthread))
2836 (setcar gthread (list (mail-header-subject (caar gthread))
2838 ;; We add this new gathered thread to this gathered
2840 (setcdr (car gthread)
2841 (nconc (cdar gthread) (list (car threads)))))
2842 ;; Add it into the thread hash table.
2843 (gnus-sethash id gthread thhashtb)
2845 ;; Remove it from the list of threads.
2846 (setcdr prev (cdr threads))
2847 (setq threads prev))))
2849 (setq threads (cdr threads)))
2852 (defun gnus-sort-gathered-threads (threads)
2853 "Sort subtreads inside each gathered thread by article number."
2854 (let ((result threads))
2856 (when (stringp (caar threads))
2857 (setcdr (car threads)
2858 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2859 (setq threads (cdr threads)))
2862 (defun gnus-thread-loop-p (root thread)
2863 "Say whether ROOT is in THREAD."
2864 (let ((stack (list thread))
2867 (while (setq thread (pop stack))
2868 (setq th (cdr thread))
2870 (not (eq (caar th) root)))
2873 ;; We have found a loop.
2875 (setcdr thread (delq (car th) (cdr thread)))
2876 (if (boundp (setq ref-dep (intern "none"
2877 gnus-newsgroup-dependencies)))
2878 (setcdr (symbol-value ref-dep)
2879 (nconc (cdr (symbol-value ref-dep))
2881 (set ref-dep (list nil (car th))))
2884 ;; Push all the subthreads onto the stack.
2885 (push (cdr thread) stack)))
2888 (defun gnus-make-threads ()
2889 "Go through the dependency hashtb and find the roots. Return all threads."
2891 (while (catch 'infloop
2894 ;; Deal with self-referencing References loops.
2895 (when (and (car (symbol-value refs))
2902 (car (symbol-value refs)) thread))
2903 (cdr (symbol-value refs)))))))
2906 (unless (car (symbol-value refs))
2907 ;; These threads do not refer back to any other articles,
2908 ;; so they're roots.
2909 (setq threads (append (cdr (symbol-value refs)) threads))))
2910 gnus-newsgroup-dependencies)))
2913 ;; Build the thread tree.
2914 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2915 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2917 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2918 if it was already present.
2920 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2921 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2922 Message-IDs will be renamed be renamed to a unique Message-ID before
2925 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2926 (let* ((id (mail-header-id header))
2927 (id-dep (and id (intern id dependencies)))
2928 ref ref-dep ref-header)
2929 ;; Enter this `header' in the `dependencies' table.
2933 ;; The first two cases do the normal part: enter a new `header'
2934 ;; in the `dependencies' table.
2935 ((not (boundp id-dep))
2936 (set id-dep (list header)))
2937 ((null (car (symbol-value id-dep)))
2938 (setcar (symbol-value id-dep) header))
2940 ;; From here the `header' was already present in the
2941 ;; `dependencies' table.
2943 ;; Overrides an existing entry;
2944 ;; just set the header part of the entry.
2945 (setcar (symbol-value id-dep) header))
2947 ;; Renames the existing `header' to a unique Message-ID.
2948 ((not gnus-summary-ignore-duplicates)
2949 ;; An article with this Message-ID has already been seen.
2950 ;; We rename the Message-ID.
2951 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2953 (mail-header-set-id header id))
2955 ;; The last case ignores an existing entry, except it adds any
2956 ;; additional Xrefs (in case the two articles came from different
2958 ;; Also sets `header' to `nil' meaning that the `dependencies'
2959 ;; table was *not* modified.
2961 (mail-header-set-xref
2962 (car (symbol-value id-dep))
2963 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2965 (or (mail-header-xref header) "")))
2969 ;; First check if that we are not creating a References loop.
2970 (setq ref (gnus-parent-id (mail-header-references header)))
2972 (setq ref-dep (intern-soft ref dependencies))
2974 (setq ref-header (car (symbol-value ref-dep))))
2975 (if (string= id ref)
2976 ;; Yuk! This is a reference loop. Make the article be a
2979 (mail-header-set-references (car (symbol-value id-dep)) "none")
2981 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2982 (setq ref (gnus-parent-id (mail-header-references header)))
2983 (setq ref-dep (intern (or ref "none") dependencies))
2984 (if (boundp ref-dep)
2985 (setcdr (symbol-value ref-dep)
2986 (nconc (cdr (symbol-value ref-dep))
2987 (list (symbol-value id-dep))))
2988 (set ref-dep (list nil (symbol-value id-dep)))))
2991 (defun gnus-build-sparse-threads ()
2992 (let ((headers gnus-newsgroup-headers)
2993 (gnus-summary-ignore-duplicates t)
2994 header references generation relations
2995 subject child end new-child date)
2996 ;; First we create an alist of generations/relations, where
2997 ;; generations is how much we trust the relation, and the relation
2999 (gnus-message 7 "Making sparse threads...")
3001 (nnheader-set-temp-buffer " *gnus sparse threads*")
3002 (while (setq header (pop headers))
3003 (when (and (setq references (mail-header-references header))
3004 (not (string= references "")))
3006 (setq child (mail-header-id header)
3007 subject (mail-header-subject header)
3008 date (mail-header-date header)
3010 (while (search-backward ">" nil t)
3011 (setq end (1+ (point)))
3012 (when (search-backward "<" nil t)
3013 (setq new-child (buffer-substring (point) end))
3014 (push (list (incf generation)
3015 child (setq child new-child)
3019 (push (list (1+ generation) child nil subject) relations))
3021 (kill-buffer (current-buffer)))
3022 ;; Sort over trustworthiness.
3025 (when (gnus-dependencies-add-header
3026 (make-full-mail-header
3027 gnus-reffed-article-number
3028 (nth 3 relation) "" (or (nth 4 relation) "")
3030 (or (nth 2 relation) "") 0 0 "")
3031 gnus-newsgroup-dependencies nil)
3032 (push gnus-reffed-article-number gnus-newsgroup-limit)
3033 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3034 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3035 gnus-newsgroup-reads)
3036 (decf gnus-reffed-article-number)))
3037 (sort relations 'car-less-than-car))
3038 (gnus-message 7 "Making sparse threads...done")))
3040 (defun gnus-build-old-threads ()
3041 ;; Look at all the articles that refer back to old articles, and
3042 ;; fetch the headers for the articles that aren't there. This will
3043 ;; build complete threads - if the roots haven't been expired by the
3048 (when (not (car (symbol-value refs)))
3049 (setq heads (cdr (symbol-value refs)))
3051 (if (memq (mail-header-number (caar heads))
3052 gnus-newsgroup-dormant)
3053 (setq heads (cdr heads))
3054 (setq id (symbol-name refs))
3055 (while (and (setq id (gnus-build-get-header id))
3056 (not (car (gnus-id-to-thread id)))))
3057 (setq heads nil)))))
3058 gnus-newsgroup-dependencies)))
3060 ;; The following macros and functions were written by Felix Lee
3061 ;; <flee@cse.psu.edu>.
3063 (defmacro gnus-nov-read-integer ()
3065 (if (eq (char-after) ?\t)
3067 (let ((num (ignore-errors (read buffer))))
3068 (if (numberp num) num 0)))
3070 (search-forward "\t" eol 'move))))
3072 (defmacro gnus-nov-skip-field ()
3073 '(search-forward "\t" eol 'move))
3075 (defmacro gnus-nov-field ()
3076 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3078 ;; This function has to be called with point after the article number
3079 ;; on the beginning of the line.
3080 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3081 (let ((eol (gnus-point-at-eol))
3082 (buffer (current-buffer))
3085 ;; overview: [num subject from date id refs chars lines misc]
3088 (narrow-to-region (point) eol)
3093 (make-full-mail-header
3095 (funcall gnus-decode-encoded-word-function
3096 (gnus-nov-field)) ; subject
3097 (funcall gnus-decode-encoded-word-function
3098 (gnus-nov-field)) ; from
3099 (gnus-nov-field) ; date
3100 (or (gnus-nov-field)
3101 (nnheader-generate-fake-message-id)) ; id
3102 (gnus-nov-field) ; refs
3103 (gnus-nov-read-integer) ; chars
3104 (gnus-nov-read-integer) ; lines
3105 (unless (eq (char-after) ?\n)
3106 (gnus-nov-field))))) ; misc
3110 (when gnus-alter-header-function
3111 (funcall gnus-alter-header-function header))
3112 (gnus-dependencies-add-header header dependencies force-new)))
3114 (defun gnus-build-get-header (id)
3115 ;; Look through the buffer of NOV lines and find the header to
3116 ;; ID. Enter this line into the dependencies hash table, and return
3117 ;; the id of the parent article (if any).
3118 (let ((deps gnus-newsgroup-dependencies)
3122 (set-buffer nntp-server-buffer)
3123 (let ((case-fold-search nil))
3124 (goto-char (point-min))
3125 (while (and (not found)
3126 (search-forward id nil t))
3128 (setq found (looking-at
3129 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3130 (regexp-quote id))))
3131 (or found (beginning-of-line 2)))
3135 (setq header (gnus-nov-parse-line
3136 (read (current-buffer)) deps))
3137 (gnus-parent-id (mail-header-references header))))))
3139 (let ((number (mail-header-number header)))
3140 (push number gnus-newsgroup-limit)
3141 (push header gnus-newsgroup-headers)
3142 (if (memq number gnus-newsgroup-unselected)
3144 (push number gnus-newsgroup-unreads)
3145 (setq gnus-newsgroup-unselected
3146 (delq number gnus-newsgroup-unselected)))
3147 (push number gnus-newsgroup-ancient)))))))
3149 (defun gnus-build-all-threads ()
3150 "Read all the headers."
3151 (let ((gnus-summary-ignore-duplicates t)
3152 (dependencies gnus-newsgroup-dependencies)
3155 (set-buffer nntp-server-buffer)
3156 (let ((case-fold-search nil))
3157 (goto-char (point-min))
3160 (setq article (read (current-buffer))
3161 header (gnus-nov-parse-line
3162 article dependencies)))
3165 (set-buffer gnus-summary-buffer)
3166 (push header gnus-newsgroup-headers)
3167 (if (memq (setq article (mail-header-number header))
3168 gnus-newsgroup-unselected)
3170 (push article gnus-newsgroup-unreads)
3171 (setq gnus-newsgroup-unselected
3172 (delq article gnus-newsgroup-unselected)))
3173 (push article gnus-newsgroup-ancient)))
3174 (forward-line 1)))))))
3176 (defun gnus-summary-update-article-line (article header)
3177 "Update the line for ARTICLE using HEADERS."
3178 (let* ((id (mail-header-id header))
3179 (thread (gnus-id-to-thread id)))
3181 (error "Article in no thread"))
3182 ;; Update the thread.
3183 (setcar thread header)
3184 (gnus-summary-goto-subject article)
3185 (let* ((datal (gnus-data-find-list article))
3187 (length (when (cdr datal)
3188 (- (gnus-data-pos data)
3189 (gnus-data-pos (cadr datal)))))
3190 (buffer-read-only nil)
3191 (level (gnus-summary-thread-level)))
3193 (gnus-summary-insert-line
3194 header level nil (gnus-article-mark article)
3195 (memq article gnus-newsgroup-replied)
3196 (memq article gnus-newsgroup-expirable)
3197 ;; Only insert the Subject string when it's different
3198 ;; from the previous Subject string.
3199 (if (gnus-subject-equal
3201 (mail-header-subject
3204 (gnus-data-find-list
3206 (gnus-data-list t)))))
3207 ;; Error on the side of excessive subjects.
3209 (mail-header-subject header))
3211 (mail-header-subject header))
3212 nil (cdr (assq article gnus-newsgroup-scored))
3213 (memq article gnus-newsgroup-processable))
3215 (gnus-data-update-list
3216 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3218 (defun gnus-summary-update-article (article &optional iheader)
3219 "Update ARTICLE in the summary buffer."
3220 (set-buffer gnus-summary-buffer)
3221 (let* ((header (gnus-summary-article-header article))
3222 (id (mail-header-id header))
3223 (data (gnus-data-find article))
3224 (thread (gnus-id-to-thread id))
3225 (references (mail-header-references header))
3229 (when (and references
3230 (not (equal "" references)))
3233 (buffer-read-only nil)
3239 (delq thread parent)))
3240 (if (gnus-summary-insert-subject id header)
3241 ;; Set the (possibly) new article number in the data structure.
3242 (gnus-data-set-number data (gnus-id-to-article id))
3246 (defun gnus-rebuild-thread (id &optional line)
3247 "Rebuild the thread containing ID.
3248 If LINE, insert the rebuilt thread starting on line LINE."
3249 (let ((buffer-read-only nil)
3250 old-pos current thread data)
3251 (if (not gnus-show-threads)
3252 (setq thread (list (car (gnus-id-to-thread id))))
3253 ;; Get the thread this article is part of.
3254 (setq thread (gnus-remove-thread id)))
3255 (setq old-pos (gnus-point-at-bol))
3256 (setq current (save-excursion
3257 (and (zerop (forward-line -1))
3258 (gnus-summary-article-number))))
3259 ;; If this is a gathered thread, we have to go some re-gathering.
3260 (when (stringp (car thread))
3261 (let ((subject (car thread))
3263 (setq thread (cdr thread))
3265 (unless (memq (setq thr (gnus-id-to-thread
3267 (mail-header-id (caar thread)))))
3270 (setq thread (cdr thread)))
3271 ;; We now have all (unique) roots.
3272 (if (= (length roots) 1)
3273 ;; All the loose roots are now one solid root.
3274 (setq thread (car roots))
3275 (setq thread (cons subject (gnus-sort-threads roots))))))
3277 ;; We then insert this thread into the summary buffer.
3279 (goto-char (point-min))
3280 (forward-line (1- line)))
3281 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3282 (if gnus-show-threads
3283 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3284 (gnus-summary-prepare-unthreaded thread))
3285 (setq data (nreverse gnus-newsgroup-data))
3286 (setq threads gnus-newsgroup-threads))
3287 ;; We splice the new data into the data structure.
3288 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3289 ;;!!! then we want to insert at the beginning of the buffer.
3290 ;;!!! That happens to be true with Gnus now, but that may
3291 ;;!!! change in the future. Perhaps.
3292 (gnus-data-enter-list
3293 (if line nil current) data (- (point) old-pos))
3294 (setq gnus-newsgroup-threads
3295 (nconc threads gnus-newsgroup-threads))
3296 (gnus-data-compute-positions))))
3298 (defun gnus-number-to-header (number)
3299 "Return the header for article NUMBER."
3300 (let ((headers gnus-newsgroup-headers))
3302 (not (= number (mail-header-number (car headers)))))
3307 (defun gnus-parent-headers (in-headers &optional generation)
3308 "Return the headers of the GENERATIONeth parent of HEADERS."
3310 (setq generation 1))
3312 (headers in-headers)
3315 (not (zerop generation))
3316 (setq references (mail-header-references headers)))
3317 (setq headers (if (and references
3318 (setq parent (gnus-parent-id references)))
3319 (car (gnus-id-to-thread parent))
3322 (and (not (eq headers in-headers))
3325 (defun gnus-id-to-thread (id)
3326 "Return the (sub-)thread where ID appears."
3327 (gnus-gethash id gnus-newsgroup-dependencies))
3329 (defun gnus-id-to-article (id)
3330 "Return the article number of ID."
3331 (let ((thread (gnus-id-to-thread id)))
3334 (mail-header-number (car thread)))))
3336 (defun gnus-id-to-header (id)
3337 "Return the article headers of ID."
3338 (car (gnus-id-to-thread id)))
3340 (defun gnus-article-displayed-root-p (article)
3341 "Say whether ARTICLE is a root(ish) article."
3342 (let ((level (gnus-summary-thread-level article))
3343 (refs (mail-header-references (gnus-summary-article-header article)))
3349 ((null (gnus-parent-id refs)) t)
3351 (null (setq particle (gnus-id-to-article
3352 (gnus-parent-id refs))))
3353 (null (gnus-summary-thread-level particle)))))))
3355 (defun gnus-root-id (id)
3356 "Return the id of the root of the thread where ID appears."
3358 (while (and id (setq prev (car (gnus-id-to-thread id))))
3360 id (gnus-parent-id (mail-header-references prev))))
3363 (defun gnus-articles-in-thread (thread)
3364 "Return the list of articles in THREAD."
3365 (cons (mail-header-number (car thread))
3366 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3368 (defun gnus-remove-thread (id &optional dont-remove)
3369 "Remove the thread that has ID in it."
3370 (let (headers thread last-id)
3371 ;; First go up in this thread until we find the root.
3372 (setq last-id (gnus-root-id id)
3373 headers (message-flatten-list (gnus-id-to-thread last-id)))
3374 ;; We have now found the real root of this thread. It might have
3375 ;; been gathered into some loose thread, so we have to search
3376 ;; through the threads to find the thread we wanted.
3377 (let ((threads gnus-newsgroup-threads)
3380 (setq sub (car threads))
3381 (if (stringp (car sub))
3382 ;; This is a gathered thread, so we look at the roots
3383 ;; below it to find whether this article is in this
3386 (setq sub (cdr sub))
3388 (when (member (caar sub) headers)
3389 (setq thread (car threads)
3392 (setq sub (cdr sub))))
3393 ;; It's an ordinary thread, so we check it.
3394 (when (eq (car sub) (car headers))
3397 (setq threads (cdr threads)))
3398 ;; If this article is in no thread, then it's a root.
3401 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3402 (setq thread (gnus-id-to-thread last-id)))
3405 thread ; We return this thread.
3407 (if (stringp (car thread))
3409 ;; If we use dummy roots, then we have to remove the
3410 ;; dummy root as well.
3411 (when (eq gnus-summary-make-false-root 'dummy)
3412 ;; We go to the dummy root by going to
3413 ;; the first sub-"thread", and then one line up.
3414 (gnus-summary-goto-article
3415 (mail-header-number (caadr thread)))
3418 (gnus-data-compute-positions))
3419 (setq thread (cdr thread))
3421 (gnus-remove-thread-1 (car thread))
3422 (setq thread (cdr thread))))
3423 (gnus-summary-show-all-threads)
3424 (gnus-remove-thread-1 thread))))))))
3426 (defun gnus-remove-thread-1 (thread)
3427 "Remove the thread THREAD recursively."
3428 (let ((number (mail-header-number (pop thread)))
3430 (setq thread (reverse thread))
3432 (gnus-remove-thread-1 (pop thread)))
3433 (when (setq d (gnus-data-find number))
3434 (goto-char (gnus-data-pos d))
3437 (- (gnus-point-at-bol)
3439 (1+ (gnus-point-at-eol))
3440 (gnus-delete-line)))))))
3442 (defun gnus-sort-threads (threads)
3444 (if (not gnus-thread-sort-functions)
3446 (gnus-message 8 "Sorting threads...")
3448 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3449 (gnus-message 8 "Sorting threads...done"))))
3451 (defun gnus-sort-articles (articles)
3453 (when gnus-article-sort-functions
3454 (gnus-message 7 "Sorting articles...")
3456 (setq gnus-newsgroup-headers
3457 (sort articles (gnus-make-sort-function
3458 gnus-article-sort-functions)))
3459 (gnus-message 7 "Sorting articles...done"))))
3461 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3462 (defmacro gnus-thread-header (thread)
3463 ;; Return header of first article in THREAD.
3464 ;; Note that THREAD must never, ever be anything else than a variable -
3465 ;; using some other form will lead to serious barfage.
3466 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3467 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3468 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3471 (defsubst gnus-article-sort-by-number (h1 h2)
3472 "Sort articles by article number."
3473 (< (mail-header-number h1)
3474 (mail-header-number h2)))
3476 (defun gnus-thread-sort-by-number (h1 h2)
3477 "Sort threads by root article number."
3478 (gnus-article-sort-by-number
3479 (gnus-thread-header h1) (gnus-thread-header h2)))
3481 (defsubst gnus-article-sort-by-lines (h1 h2)
3482 "Sort articles by article Lines header."
3483 (< (mail-header-lines h1)
3484 (mail-header-lines h2)))
3486 (defun gnus-thread-sort-by-lines (h1 h2)
3487 "Sort threads by root article Lines header."
3488 (gnus-article-sort-by-lines
3489 (gnus-thread-header h1) (gnus-thread-header h2)))
3491 (defsubst gnus-article-sort-by-author (h1 h2)
3492 "Sort articles by root author."
3494 (let ((extract (funcall
3495 gnus-extract-address-components
3496 (mail-header-from h1))))
3497 (or (car extract) (cadr extract) ""))
3498 (let ((extract (funcall
3499 gnus-extract-address-components
3500 (mail-header-from h2))))
3501 (or (car extract) (cadr extract) ""))))
3503 (defun gnus-thread-sort-by-author (h1 h2)
3504 "Sort threads by root author."
3505 (gnus-article-sort-by-author
3506 (gnus-thread-header h1) (gnus-thread-header h2)))
3508 (defsubst gnus-article-sort-by-subject (h1 h2)
3509 "Sort articles by root subject."
3511 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3512 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3514 (defun gnus-thread-sort-by-subject (h1 h2)
3515 "Sort threads by root subject."
3516 (gnus-article-sort-by-subject
3517 (gnus-thread-header h1) (gnus-thread-header h2)))
3519 (defsubst gnus-article-sort-by-date (h1 h2)
3520 "Sort articles by root article date."
3522 (gnus-date-get-time (mail-header-date h1))
3523 (gnus-date-get-time (mail-header-date h2))))
3525 (defun gnus-thread-sort-by-date (h1 h2)
3526 "Sort threads by root article date."
3527 (gnus-article-sort-by-date
3528 (gnus-thread-header h1) (gnus-thread-header h2)))
3530 (defsubst gnus-article-sort-by-score (h1 h2)
3531 "Sort articles by root article score.
3532 Unscored articles will be counted as having a score of zero."
3533 (> (or (cdr (assq (mail-header-number h1)
3534 gnus-newsgroup-scored))
3535 gnus-summary-default-score 0)
3536 (or (cdr (assq (mail-header-number h2)
3537 gnus-newsgroup-scored))
3538 gnus-summary-default-score 0)))
3540 (defun gnus-thread-sort-by-score (h1 h2)
3541 "Sort threads by root article score."
3542 (gnus-article-sort-by-score
3543 (gnus-thread-header h1) (gnus-thread-header h2)))
3545 (defun gnus-thread-sort-by-total-score (h1 h2)
3546 "Sort threads by the sum of all scores in the thread.
3547 Unscored articles will be counted as having a score of zero."
3548 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3550 (defun gnus-thread-total-score (thread)
3551 ;; This function find the total score of THREAD.
3552 (cond ((null thread)
3555 (if (stringp (car thread))
3556 (apply gnus-thread-score-function 0
3557 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3558 (gnus-thread-total-score-1 thread)))
3560 (gnus-thread-total-score-1 (list thread)))))
3562 (defun gnus-thread-total-score-1 (root)
3563 ;; This function find the total score of the thread below ROOT.
3564 (setq root (car root))
3565 (apply gnus-thread-score-function
3567 (mapcar 'gnus-thread-total-score
3568 (cdr (gnus-id-to-thread (mail-header-id root))))
3569 (when (> (mail-header-number root) 0)
3570 (list (or (cdr (assq (mail-header-number root)
3571 gnus-newsgroup-scored))
3572 gnus-summary-default-score 0))))
3573 (list gnus-summary-default-score)
3576 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3577 (defvar gnus-tmp-prev-subject nil)
3578 (defvar gnus-tmp-false-parent nil)
3579 (defvar gnus-tmp-root-expunged nil)
3580 (defvar gnus-tmp-dummy-line nil)
3582 (defun gnus-summary-prepare-threads (threads)
3583 "Prepare summary buffer from THREADS and indentation LEVEL.
3584 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3585 or a straight list of headers."
3586 (gnus-message 7 "Generating summary...")
3588 (setq gnus-newsgroup-threads threads)
3591 (let ((gnus-tmp-level 0)
3592 (default-score (or gnus-summary-default-score 0))
3593 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3594 thread number subject stack state gnus-tmp-gathered beg-match
3595 new-roots gnus-tmp-new-adopts thread-end
3596 gnus-tmp-header gnus-tmp-unread
3597 gnus-tmp-replied gnus-tmp-subject-or-nil
3598 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3599 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3600 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3602 (setq gnus-tmp-prev-subject nil)
3604 (if (vectorp (car threads))
3605 ;; If this is a straight (sic) list of headers, then a
3606 ;; threaded summary display isn't required, so we just create
3607 ;; an unthreaded one.
3608 (gnus-summary-prepare-unthreaded threads)
3610 ;; Do the threaded display.
3612 (while (or threads stack gnus-tmp-new-adopts new-roots)
3614 (if (and (= gnus-tmp-level 0)
3617 (not gnus-tmp-false-parent)
3618 (or gnus-tmp-new-adopts new-roots))
3619 (if gnus-tmp-new-adopts
3620 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3621 thread (list (car gnus-tmp-new-adopts))
3622 gnus-tmp-header (caar thread)
3623 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3625 (setq thread (list (car new-roots))
3626 gnus-tmp-header (caar thread)
3627 new-roots (cdr new-roots))))
3630 ;; If there are some threads, we do them before the
3631 ;; threads on the stack.
3632 (setq thread threads
3633 gnus-tmp-header (caar thread))
3634 ;; There were no current threads, so we pop something off
3636 (setq state (car stack)
3637 gnus-tmp-level (car state)
3640 gnus-tmp-header (caar thread))))
3642 (setq gnus-tmp-false-parent nil)
3643 (setq gnus-tmp-root-expunged nil)
3644 (setq thread-end nil)
3646 (if (stringp gnus-tmp-header)
3647 ;; The header is a dummy root.
3649 ((eq gnus-summary-make-false-root 'adopt)
3650 ;; We let the first article adopt the rest.
3651 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3653 (setq gnus-tmp-gathered
3655 (lambda (h) (mail-header-number (car h)))
3658 (setq thread (cons (list (caar thread)
3661 (setq gnus-tmp-level -1
3662 gnus-tmp-false-parent t))
3663 ((eq gnus-summary-make-false-root 'empty)
3664 ;; We print adopted articles with empty subject fields.
3665 (setq gnus-tmp-gathered
3667 (lambda (h) (mail-header-number (car h)))
3670 (setq gnus-tmp-level -1))
3671 ((eq gnus-summary-make-false-root 'dummy)
3672 ;; We remember that we probably want to output a dummy
3674 (setq gnus-tmp-dummy-line gnus-tmp-header)
3675 (setq gnus-tmp-prev-subject gnus-tmp-header))
3677 ;; We do not make a root for the gathered
3678 ;; sub-threads at all.
3679 (setq gnus-tmp-level -1)))
3681 (setq number (mail-header-number gnus-tmp-header)
3682 subject (mail-header-subject gnus-tmp-header))
3685 ;; If the thread has changed subject, we might want to make
3686 ;; this subthread into a root.
3687 ((and (null gnus-thread-ignore-subject)
3688 (not (zerop gnus-tmp-level))
3689 gnus-tmp-prev-subject
3691 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3692 (setq new-roots (nconc new-roots (list (car thread)))
3694 gnus-tmp-header nil))
3695 ;; If the article lies outside the current limit,
3696 ;; then we do not display it.
3697 ((not (memq number gnus-newsgroup-limit))
3698 (setq gnus-tmp-gathered
3700 (lambda (h) (mail-header-number (car h)))
3703 (setq gnus-tmp-new-adopts (if (cdar thread)
3704 (append gnus-tmp-new-adopts
3706 gnus-tmp-new-adopts)
3708 gnus-tmp-header nil)
3709 (when (zerop gnus-tmp-level)
3710 (setq gnus-tmp-root-expunged t)))
3711 ;; Perhaps this article is to be marked as read?
3712 ((and gnus-summary-mark-below
3713 (< (or (cdr (assq number gnus-newsgroup-scored))
3715 gnus-summary-mark-below)
3716 ;; Don't touch sparse articles.
3717 (not (gnus-summary-article-sparse-p number))
3718 (not (gnus-summary-article-ancient-p number)))
3719 (setq gnus-newsgroup-unreads
3720 (delq number gnus-newsgroup-unreads))
3721 (if gnus-newsgroup-auto-expire
3722 (push number gnus-newsgroup-expirable)
3723 (push (cons number gnus-low-score-mark)
3724 gnus-newsgroup-reads))))
3726 (when gnus-tmp-header
3727 ;; We may have an old dummy line to output before this
3729 (when (and gnus-tmp-dummy-line
3732 (mail-header-subject gnus-tmp-header)))
3733 (gnus-summary-insert-dummy-line
3734 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3735 (setq gnus-tmp-dummy-line nil))
3737 ;; Compute the mark.
3738 (setq gnus-tmp-unread (gnus-article-mark number))
3740 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3741 gnus-tmp-header gnus-tmp-level)
3742 gnus-newsgroup-data)
3744 ;; Actually insert the line.
3746 gnus-tmp-subject-or-nil
3748 ((and gnus-thread-ignore-subject
3749 gnus-tmp-prev-subject
3750 (not (inline (gnus-subject-equal
3751 gnus-tmp-prev-subject subject))))
3753 ((zerop gnus-tmp-level)
3754 (if (and (eq gnus-summary-make-false-root 'empty)
3755 (memq number gnus-tmp-gathered)
3756 gnus-tmp-prev-subject
3757 (inline (gnus-subject-equal
3758 gnus-tmp-prev-subject subject)))
3759 gnus-summary-same-subject
3761 (t gnus-summary-same-subject)))
3762 (if (and (eq gnus-summary-make-false-root 'adopt)
3763 (= gnus-tmp-level 1)
3764 (memq number gnus-tmp-gathered))
3765 (setq gnus-tmp-opening-bracket ?\<
3766 gnus-tmp-closing-bracket ?\>)
3767 (setq gnus-tmp-opening-bracket ?\[
3768 gnus-tmp-closing-bracket ?\]))
3770 gnus-tmp-indentation
3771 (aref gnus-thread-indent-array gnus-tmp-level)
3772 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3773 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3774 gnus-summary-default-score 0)
3776 (if (or (null gnus-summary-default-score)
3777 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3778 gnus-summary-zcore-fuzz))
3780 (if (< gnus-tmp-score gnus-summary-default-score)
3781 gnus-score-below-mark gnus-score-over-mark))
3783 (cond ((memq number gnus-newsgroup-processable)
3785 ((memq number gnus-newsgroup-cached)
3787 ((memq number gnus-newsgroup-replied)
3789 ((memq number gnus-newsgroup-saved)
3791 (t gnus-unread-mark))
3792 gnus-tmp-from (mail-header-from gnus-tmp-header)
3795 ((string-match "<[^>]+> *$" gnus-tmp-from)
3796 (setq beg-match (match-beginning 0))
3797 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3798 (substring gnus-tmp-from (1+ (match-beginning 0))
3799 (1- (match-end 0))))
3800 (substring gnus-tmp-from 0 beg-match)))
3801 ((string-match "(.+)" gnus-tmp-from)
3802 (substring gnus-tmp-from
3803 (1+ (match-beginning 0)) (1- (match-end 0))))
3805 (when (string= gnus-tmp-name "")
3806 (setq gnus-tmp-name gnus-tmp-from))
3807 (unless (numberp gnus-tmp-lines)
3808 (setq gnus-tmp-lines 0))
3809 (gnus-put-text-property
3811 (progn (eval gnus-summary-line-format-spec) (point))
3812 'gnus-number number)
3815 (gnus-run-hooks 'gnus-summary-update-hook)
3818 (setq gnus-tmp-prev-subject subject)))
3820 (when (nth 1 thread)
3821 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3822 (incf gnus-tmp-level)
3823 (setq threads (if thread-end nil (cdar thread)))
3825 (setq gnus-tmp-level 0)))))
3826 (gnus-message 7 "Generating summary...done"))
3828 (defun gnus-summary-prepare-unthreaded (headers)
3829 "Generate an unthreaded summary buffer based on HEADERS."
3830 (let (header number mark)
3835 ;; We may have to root out some bad articles...
3836 (when (memq (setq number (mail-header-number
3837 (setq header (pop headers))))
3838 gnus-newsgroup-limit)
3839 ;; Mark article as read when it has a low score.
3840 (when (and gnus-summary-mark-below
3841 (< (or (cdr (assq number gnus-newsgroup-scored))
3842 gnus-summary-default-score 0)
3843 gnus-summary-mark-below)
3844 (not (gnus-summary-article-ancient-p number)))
3845 (setq gnus-newsgroup-unreads
3846 (delq number gnus-newsgroup-unreads))
3847 (if gnus-newsgroup-auto-expire
3848 (push number gnus-newsgroup-expirable)
3849 (push (cons number gnus-low-score-mark)
3850 gnus-newsgroup-reads)))
3852 (setq mark (gnus-article-mark number))
3853 (push (gnus-data-make number mark (1+ (point)) header 0)
3854 gnus-newsgroup-data)
3855 (gnus-summary-insert-line
3857 mark (memq number gnus-newsgroup-replied)
3858 (memq number gnus-newsgroup-expirable)
3859 (mail-header-subject header) nil
3860 (cdr (assq number gnus-newsgroup-scored))
3861 (memq number gnus-newsgroup-processable))))))
3863 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3864 "Select newsgroup GROUP.
3865 If READ-ALL is non-nil, all articles in the group are selected.
3866 If SELECT-ARTICLES, only select those articles from GROUP."
3867 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3868 ;;!!! Dirty hack; should be removed.
3869 (gnus-summary-ignore-duplicates
3870 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3872 gnus-summary-ignore-duplicates))
3873 (info (nth 2 entry))
3874 articles fetched-articles cached)
3876 (unless (gnus-check-server
3877 (setq gnus-current-select-method
3878 (gnus-find-method-for-group group)))
3879 (error "Couldn't open server"))
3881 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3882 (gnus-activate-group group) ; Or we can activate it...
3883 (progn ; Or we bug out.
3884 (when (equal major-mode 'gnus-summary-mode)
3885 (kill-buffer (current-buffer)))
3886 (error "Couldn't request group %s: %s"
3887 group (gnus-status-message group))))
3889 (unless (gnus-request-group group t)
3890 (when (equal major-mode 'gnus-summary-mode)
3891 (kill-buffer (current-buffer)))
3892 (error "Couldn't request group %s: %s"
3893 group (gnus-status-message group)))
3895 (setq gnus-newsgroup-name group)
3896 (setq gnus-newsgroup-unselected nil)
3897 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3899 ;; Adjust and set lists of article marks.
3901 (gnus-adjust-marked-articles info))
3903 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3904 (when (gnus-virtual-group-p group)
3905 (setq cached gnus-newsgroup-cached))
3907 (setq gnus-newsgroup-unreads
3908 (gnus-set-difference
3909 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3910 gnus-newsgroup-dormant))
3912 (setq gnus-newsgroup-processable nil)
3914 (gnus-update-read-articles group gnus-newsgroup-unreads)
3916 (if (setq articles select-articles)
3917 (setq gnus-newsgroup-unselected
3918 (gnus-sorted-intersection
3919 gnus-newsgroup-unreads
3920 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3921 (setq articles (gnus-articles-to-read group read-all)))
3925 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3927 ((eq articles 0) nil)
3929 ;; Init the dependencies hash table.
3930 (setq gnus-newsgroup-dependencies
3931 (gnus-make-hashtable (length articles)))
3932 (gnus-set-global-variables)
3933 ;; Retrieve the headers and read them in.
3934 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3935 (setq gnus-newsgroup-headers
3937 (setq gnus-headers-retrieved-by
3938 (gnus-retrieve-headers
3939 articles gnus-newsgroup-name
3940 ;; We might want to fetch old headers, but
3941 ;; not if there is only 1 article.
3943 (not (eq gnus-fetch-old-headers 'some))
3944 (not (numberp gnus-fetch-old-headers)))
3945 (> (length articles) 1))
3946 gnus-fetch-old-headers))))
3947 (gnus-get-newsgroup-headers-xover
3948 articles nil nil gnus-newsgroup-name t)
3949 (gnus-get-newsgroup-headers)))
3950 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3952 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3954 (setq gnus-newsgroup-cached cached))
3956 ;; Suppress duplicates?
3957 (when gnus-suppress-duplicates
3958 (gnus-dup-suppress-articles))
3960 ;; Set the initial limit.
3961 (setq gnus-newsgroup-limit (copy-sequence articles))
3962 ;; Remove canceled articles from the list of unread articles.
3963 (setq gnus-newsgroup-unreads
3964 (gnus-set-sorted-intersection
3965 gnus-newsgroup-unreads
3966 (setq fetched-articles
3967 (mapcar (lambda (headers) (mail-header-number headers))
3968 gnus-newsgroup-headers))))
3969 ;; Removed marked articles that do not exist.
3970 (gnus-update-missing-marks
3971 (gnus-sorted-complement fetched-articles articles))
3972 ;; We might want to build some more threads first.
3973 (when (and gnus-fetch-old-headers
3974 (eq gnus-headers-retrieved-by 'nov))
3975 (if (eq gnus-fetch-old-headers 'invisible)
3976 (gnus-build-all-threads)
3977 (gnus-build-old-threads)))
3978 ;; Let the Gnus agent mark articles as read.
3980 (gnus-agent-get-undownloaded-list))
3981 ;; Check whether auto-expire is to be done in this group.
3982 (setq gnus-newsgroup-auto-expire
3983 (gnus-group-auto-expirable-p group))
3984 ;; Set up the article buffer now, if necessary.
3985 (unless gnus-single-article-buffer
3986 (gnus-article-setup-buffer))
3987 ;; First and last article in this newsgroup.
3988 (when gnus-newsgroup-headers
3989 (setq gnus-newsgroup-begin
3990 (mail-header-number (car gnus-newsgroup-headers))
3993 (gnus-last-element gnus-newsgroup-headers))))
3994 ;; GROUP is successfully selected.
3995 (or gnus-newsgroup-headers t)))))
3997 (defun gnus-articles-to-read (group &optional read-all)
3998 ;; Find out what articles the user wants to read.
4000 ;; Select all articles if `read-all' is non-nil, or if there
4001 ;; are no unread articles.
4003 (and (zerop (length gnus-newsgroup-marked))
4004 (zerop (length gnus-newsgroup-unreads)))
4005 (eq (gnus-group-find-parameter group 'display)
4007 (gnus-uncompress-range (gnus-active group))
4008 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4009 (copy-sequence gnus-newsgroup-unreads))
4011 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4012 (scored (length scored-list))
4013 (number (length articles))
4014 (marked (+ (length gnus-newsgroup-marked)
4015 (length gnus-newsgroup-dormant)))
4023 ((and (or (<= scored marked) (= scored number))
4024 (numberp gnus-large-newsgroup)
4025 (> number gnus-large-newsgroup))
4029 "How many articles from %s (default %d): "
4030 (gnus-limit-string gnus-newsgroup-name 35)
4032 (if (string-match "^[ \t]*$" input) number input)))
4033 ((and (> scored marked) (< scored number)
4034 (> (- scored number) 20))
4037 (format "%s %s (%d scored, %d total): "
4038 "How many articles from"
4039 group scored number))))
4040 (if (string-match "^[ \t]*$" input)
4044 (setq select (if (stringp select) (string-to-number select) select))
4045 (if (or (null select) (zerop select))
4047 (if (and (not (zerop scored)) (<= (abs select) scored))
4049 (setq articles (sort scored-list '<))
4050 (setq number (length articles)))
4051 (setq articles (copy-sequence articles)))
4053 (when (< (abs select) number)
4055 ;; Select the N oldest articles.
4056 (setcdr (nthcdr (1- (abs select)) articles) nil)
4057 ;; Select the N most recent articles.
4058 (setq articles (nthcdr (- number select) articles))))
4059 (setq gnus-newsgroup-unselected
4060 (gnus-sorted-intersection
4061 gnus-newsgroup-unreads
4062 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4065 (defun gnus-killed-articles (killed articles)
4068 (when (inline (gnus-member-of-range (car articles) killed))
4069 (push (car articles) out))
4070 (setq articles (cdr articles)))
4073 (defun gnus-uncompress-marks (marks)
4074 "Uncompress the mark ranges in MARKS."
4075 (let ((uncompressed '(score bookmark))
4078 (if (memq (caar marks) uncompressed)
4079 (push (car marks) out)
4080 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4081 (setq marks (cdr marks)))
4084 (defun gnus-adjust-marked-articles (info)
4085 "Set all article lists and remove all marks that are no longer legal."
4086 (let* ((marked-lists (gnus-info-marks info))
4087 (active (gnus-active (gnus-info-group info)))
4090 (types gnus-article-mark-lists)
4091 (uncompressed '(score bookmark killed))
4092 marks var articles article mark)
4095 (setq marks (pop marked-lists))
4096 (set (setq var (intern (format "gnus-newsgroup-%s"
4097 (car (rassq (setq mark (car marks))
4099 (if (memq (car marks) uncompressed) (cdr marks)
4100 (gnus-uncompress-range (cdr marks))))
4102 (setq articles (symbol-value var))
4104 ;; All articles have to be subsets of the active articles.
4106 ;; Adjust "simple" lists.
4107 ((memq mark '(tick dormant expire reply save))
4109 (when (or (< (setq article (pop articles)) min) (> article max))
4110 (set var (delq article (symbol-value var))))))
4112 ((memq mark uncompressed)
4113 (when (not (listp (cdr (symbol-value var))))
4114 (set var (list (symbol-value var))))
4115 (when (not (listp (cdr articles)))
4116 (setq articles (list articles)))
4118 (when (or (not (consp (setq article (pop articles))))
4119 (< (car article) min)
4120 (> (car article) max))
4121 (set var (delq article (symbol-value var))))))))))
4123 (defun gnus-update-missing-marks (missing)
4124 "Go through the list of MISSING articles and remove them from the mark lists."
4126 (let ((types gnus-article-mark-lists)
4128 ;; Go through all types.
4130 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4131 (when (symbol-value var)
4132 ;; This list has articles. So we delete all missing articles
4136 (set var (delq (pop m) (symbol-value var)))))))))
4138 (defun gnus-update-marks ()
4139 "Enter the various lists of marked articles into the newsgroup info list."
4140 (let ((types gnus-article-mark-lists)
4141 (info (gnus-get-info gnus-newsgroup-name))
4142 (uncompressed '(score bookmark killed))
4143 type list newmarked symbol delta-marks)
4145 ;; Add all marks lists that are non-nil to the list of marks lists.
4146 (while (setq type (pop types))
4147 (when (setq list (symbol-value
4149 (intern (format "gnus-newsgroup-%s"
4152 ;; Get rid of the entries of the articles that have the
4154 (when (and (eq (cdr type) 'score)
4158 (prev (cons nil list))
4161 (if (or (not (consp (car arts)))
4162 (= (cdar arts) gnus-summary-default-score))
4163 (setcdr prev (cdr arts))
4165 (setq arts (cdr arts)))
4166 (setq list (cdr all))))
4168 (push (cons (cdr type)
4169 (if (memq (cdr type) uncompressed) list
4170 (gnus-compress-sequence
4171 (set symbol (sort list '<)) t)))
4174 ;; Enter these new marks into the info of the group.
4176 (setcar (nthcdr 3 info) newmarked)
4177 ;; Add the marks lists to the end of the info.
4179 (setcdr (nthcdr 2 info) (list newmarked))))
4181 ;; Cut off the end of the info if there's nothing else there.
4185 (when (nthcdr (decf i) info)
4186 (setcdr (nthcdr i info) nil)))))))
4188 (defun gnus-set-mode-line (where)
4189 "This function sets the mode line of the article or summary buffers.
4190 If WHERE is `summary', the summary mode line format will be used."
4191 ;; Is this mode line one we keep updated?
4192 (when (memq where gnus-updated-mode-lines)
4195 ;; We evaluate this in the summary buffer since these
4196 ;; variables are buffer-local to that buffer.
4197 (set-buffer gnus-summary-buffer)
4198 ;; We bind all these variables that are used in the `eval' form
4200 (let* ((mformat (symbol-value
4202 (format "gnus-%s-mode-line-format-spec" where))))
4203 (gnus-tmp-group-name gnus-newsgroup-name)
4204 (gnus-tmp-article-number (or gnus-current-article 0))
4205 (gnus-tmp-unread gnus-newsgroup-unreads)
4206 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4207 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4208 (gnus-tmp-unread-and-unselected
4209 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4210 (zerop gnus-tmp-unselected))
4212 ((zerop gnus-tmp-unselected)
4213 (format "{%d more}" gnus-tmp-unread-and-unticked))
4214 (t (format "{%d(+%d) more}"
4215 gnus-tmp-unread-and-unticked
4216 gnus-tmp-unselected))))
4218 (if (and gnus-current-headers
4219 (vectorp gnus-current-headers))
4220 (gnus-mode-string-quote
4221 (mail-header-subject gnus-current-headers))
4223 bufname-length max-len
4224 gnus-tmp-header);; passed as argument to any user-format-funcs
4225 (setq mode-string (eval mformat))
4226 (setq bufname-length (if (string-match "%b" mode-string)
4229 (if (eq where 'summary)
4231 (get-buffer gnus-article-buffer))))
4234 (setq max-len (max 4 (if gnus-mode-non-string-length
4236 gnus-mode-non-string-length
4238 (length mode-string))))
4239 ;; We might have to chop a bit of the string off...
4240 (when (> (length mode-string) max-len)
4242 (concat (truncate-string mode-string (- max-len 3))
4244 ;; Pad the mode string a bit.
4245 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4246 ;; Update the mode line.
4247 (setq mode-line-buffer-identification
4248 (gnus-mode-line-buffer-identification (list mode-string)))
4249 (set-buffer-modified-p t))))
4251 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4252 "Go through the HEADERS list and add all Xrefs to a hash table.
4253 The resulting hash table is returned, or nil if no Xrefs were found."
4254 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4255 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4256 (xref-hashtb (gnus-make-hashtable))
4257 start group entry number xrefs header)
4259 (setq header (pop headers))
4260 (when (and (setq xrefs (mail-header-xref header))
4261 (not (memq (setq number (mail-header-number header))
4264 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4265 (setq start (match-end 0))
4266 (setq group (if prefix
4267 (concat prefix (substring xrefs (match-beginning 1)
4269 (substring xrefs (match-beginning 1) (match-end 1))))
4271 (string-to-int (substring xrefs (match-beginning 2)
4273 (if (setq entry (gnus-gethash group xref-hashtb))
4274 (setcdr entry (cons number (cdr entry)))
4275 (gnus-sethash group (cons number nil) xref-hashtb)))))
4276 (and start xref-hashtb)))
4278 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4279 "Look through all the headers and mark the Xrefs as read."
4280 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4281 name entry info xref-hashtb idlist method nth4)
4283 (set-buffer gnus-group-buffer)
4284 (when (setq xref-hashtb
4285 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4288 (unless (string= from-newsgroup (setq name (symbol-name group)))
4289 (setq idlist (symbol-value group))
4290 ;; Dead groups are not updated.
4292 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4294 (when (stringp (setq nth4 (gnus-info-method info)))
4295 (setq nth4 (gnus-server-to-method nth4))))
4296 ;; Only do the xrefs if the group has the same
4297 ;; select method as the group we have just read.
4298 (or (gnus-methods-equal-p
4299 nth4 (gnus-find-method-for-group from-newsgroup))
4301 (equal nth4 (setq method (gnus-find-method-for-group
4303 (and (equal (car nth4) (car method))
4304 (equal (nth 1 nth4) (nth 1 method))))
4305 gnus-use-cross-reference
4306 (or (not (eq gnus-use-cross-reference t))
4308 ;; Only do cross-references on subscribed
4309 ;; groups, if that is what is wanted.
4310 (<= (gnus-info-level info) gnus-level-subscribed))
4311 (gnus-group-make-articles-read name idlist))))
4314 (defun gnus-compute-read-articles (group articles)
4315 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4316 (info (nth 2 entry))
4317 (active (gnus-active group))
4320 ;; First peel off all illegal article numbers.
4322 (let ((ids articles)
4324 (while (setq id (pop ids))
4325 (when (and first (> id (cdr active)))
4326 ;; We'll end up in this situation in one particular
4327 ;; obscure situation. If you re-scan a group and get
4328 ;; a new article that is cross-posted to a different
4329 ;; group that has not been re-scanned, you might get
4330 ;; crossposted article that has a higher number than
4331 ;; Gnus believes possible. So we re-activate this
4332 ;; group as well. This might mean doing the
4333 ;; crossposting thingy will *increase* the number
4334 ;; of articles in some groups. Tsk, tsk.
4335 (setq active (or (gnus-activate-group group) active)))
4336 (when (or (> id (cdr active))
4337 (< id (car active)))
4338 (setq articles (delq id articles))))))
4339 ;; If the read list is nil, we init it.
4341 (null (gnus-info-read info))
4343 (setq ninfo (cons 1 (1- (car active))))
4344 (setq ninfo (gnus-info-read info)))
4345 ;; Then we add the read articles to the range.
4347 ninfo (setq articles (sort articles '<))))))
4349 (defun gnus-group-make-articles-read (group articles)
4350 "Update the info of GROUP to say that ARTICLES are read."
4352 (entry (gnus-gethash group gnus-newsrc-hashtb))
4353 (info (nth 2 entry))
4354 (active (gnus-active group))
4357 (setq range (gnus-compute-read-articles group articles))
4359 (set-buffer gnus-group-buffer)
4362 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4363 (gnus-info-set-read ',info ',(gnus-info-read info))
4364 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4365 (gnus-group-update-group ,group t))))
4366 ;; Add the read articles to the range.
4367 (gnus-info-set-read info range)
4368 ;; Then we have to re-compute how many unread
4369 ;; articles there are in this group.
4373 (setq num (- (1+ (cdr active)) (car active))))
4374 ((not (listp (cdr range)))
4375 (setq num (- (cdr active) (- (1+ (cdr range))
4379 (if (numberp (car range))
4381 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4382 (setq range (cdr range)))
4383 (setq num (- (cdr active) num))))
4384 ;; Update the number of unread articles.
4386 ;; Update the group buffer.
4387 (gnus-group-update-group group t)))))
4389 (defun gnus-methods-equal-p (m1 m2)
4390 (let ((m1 (or m1 gnus-select-method))
4391 (m2 (or m2 gnus-select-method)))
4393 (and (eq (car m1) (car m2))
4394 (or (not (memq 'address (assoc (symbol-name (car m1))
4395 gnus-valid-select-methods)))
4396 (equal (nth 1 m1) (nth 1 m2)))))))
4398 (defvar gnus-newsgroup-none-id 0)
4400 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4401 (let ((cur nntp-server-buffer)
4404 (save-excursion (set-buffer gnus-summary-buffer)
4405 gnus-newsgroup-dependencies)))
4408 (set-buffer nntp-server-buffer)
4409 ;; Translate all TAB characters into SPACE characters.
4410 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4411 (gnus-run-hooks 'gnus-parse-headers-hook)
4412 (let ((case-fold-search t)
4413 in-reply-to header p lines chars)
4414 (goto-char (point-min))
4415 ;; Search to the beginning of the next header. Error messages
4416 ;; do not begin with 2 or 3.
4417 (while (re-search-forward "^[23][0-9]+ " nil t)
4420 ;; This implementation of this function, with nine
4421 ;; search-forwards instead of the one re-search-forward and
4422 ;; a case (which basically was the old function) is actually
4423 ;; about twice as fast, even though it looks messier. You
4424 ;; can't have everything, I guess. Speed and elegance
4425 ;; doesn't always go hand in hand.
4434 (narrow-to-region (point)
4435 (or (and (search-forward "\n.\n" nil t)
4441 (if (search-forward "\nsubject: " nil t)
4442 (funcall gnus-decode-encoded-word-function
4443 (nnheader-header-value))
4448 (if (search-forward "\nfrom: " nil t)
4449 (funcall gnus-decode-encoded-word-function
4450 (nnheader-header-value))
4455 (if (search-forward "\ndate: " nil t)
4456 (nnheader-header-value) ""))
4460 (setq id (if (re-search-forward
4461 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4462 ;; We do it this way to make sure the Message-ID
4463 ;; is (somewhat) syntactically valid.
4464 (buffer-substring (match-beginning 1)
4466 ;; If there was no message-id, we just fake one
4467 ;; to make subsequent routines simpler.
4468 (nnheader-generate-fake-message-id))))
4472 (if (search-forward "\nreferences: " nil t)
4476 (nnheader-header-value)
4481 (search-backward ">" end t)
4484 (search-backward "<" end t)
4486 ;; Get the references from the in-reply-to header if there
4487 ;; were no references and the in-reply-to header looks
4489 (if (and (search-forward "\nin-reply-to: " nil t)
4490 (setq in-reply-to (nnheader-header-value))
4491 (string-match "<[^>]+>" in-reply-to))
4493 (setq ref (substring in-reply-to (match-beginning 0)
4495 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4496 (setq ref2 (substring in-reply-to (match-beginning 0)
4498 (when (> (length ref2) (length ref))
4505 (if (search-forward "\nchars: " nil t)
4506 (if (numberp (setq chars (ignore-errors (read cur))))
4512 (if (search-forward "\nlines: " nil t)
4513 (if (numberp (setq lines (ignore-errors (read cur))))
4519 (and (search-forward "\nxref: " nil t)
4520 (nnheader-header-value)))))
4521 (when (equal id ref)
4524 (when gnus-alter-header-function
4525 (funcall gnus-alter-header-function header)
4526 (setq id (mail-header-id header)
4527 ref (gnus-parent-id (mail-header-references header))))
4530 (gnus-dependencies-add-header
4531 header dependencies force-new))
4532 (push header headers))
4533 (goto-char (point-max))
4535 (nreverse headers)))))
4537 ;; Goes through the xover lines and returns a list of vectors
4538 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4539 force-new dependencies
4540 group also-fetch-heads)
4541 "Parse the news overview data in the server buffer, and return a
4542 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4543 ;; Get the Xref when the users reads the articles since most/some
4544 ;; NNTP servers do not include Xrefs when using XOVER.
4545 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4546 (let ((cur nntp-server-buffer)
4547 (dependencies (or dependencies gnus-newsgroup-dependencies))
4548 number headers header)
4550 (set-buffer nntp-server-buffer)
4551 ;; Allow the user to mangle the headers before parsing them.
4552 (gnus-run-hooks 'gnus-parse-headers-hook)
4553 (goto-char (point-min))
4556 (while (and sequence (not (eobp)))
4557 (setq number (read cur))
4558 (while (and sequence
4559 (< (car sequence) number))
4560 (setq sequence (cdr sequence)))
4562 (eq number (car sequence))
4564 (setq sequence (cdr sequence))
4565 (setq header (inline
4566 (gnus-nov-parse-line
4567 number dependencies force-new))))
4568 (push header headers))
4571 (gnus-error 4 "Strange nov line (%d)"
4572 (count-lines (point-min) (point)))))
4574 ;; A common bug in inn is that if you have posted an article and
4575 ;; then retrieves the active file, it will answer correctly --
4576 ;; the new article is included. However, a NOV entry for the
4577 ;; article may not have been generated yet, so this may fail.
4578 ;; We work around this problem by retrieving the last few
4579 ;; headers using HEAD.
4580 (if (or (not also-fetch-heads)
4582 ;; We (probably) got all the headers.
4584 (let ((gnus-nov-is-evil t))
4587 (when (gnus-retrieve-headers sequence group)
4588 (gnus-get-newsgroup-headers))))))))
4590 (defun gnus-article-get-xrefs ()
4591 "Fill in the Xref value in `gnus-current-headers', if necessary.
4592 This is meant to be called in `gnus-article-internal-prepare-hook'."
4593 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4594 gnus-current-headers)))
4595 (or (not gnus-use-cross-reference)
4597 (and (mail-header-xref headers)
4598 (not (string= (mail-header-xref headers) "")))
4599 (let ((case-fold-search t)
4602 (nnheader-narrow-to-headers)
4603 (goto-char (point-min))
4604 (when (or (and (eq (downcase (char-after)) ?x)
4605 (looking-at "Xref:"))
4606 (search-forward "\nXref:" nil t))
4607 (goto-char (1+ (match-end 0)))
4608 (setq xref (buffer-substring (point)
4609 (progn (end-of-line) (point))))
4610 (mail-header-set-xref headers xref)))))))
4612 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4613 "Find article ID and insert the summary line for that article.
4614 OLD-HEADER can either be a header or a line number to insert
4615 the subject line on."
4616 (let* ((line (and (numberp old-header) old-header))
4617 (old-header (and (vectorp old-header) old-header))
4618 (header (cond ((and old-header use-old-header)
4621 (gnus-number-to-header id))
4622 (gnus-number-to-header id))
4624 (gnus-read-header id))))
4625 (number (and (numberp id) id))
4628 ;; Rebuild the thread that this article is part of and go to the
4629 ;; article we have fetched.
4630 (when (and (not gnus-show-threads)
4633 (setq d (gnus-data-find (mail-header-number old-header))))
4634 (goto-char (gnus-data-pos d))
4637 (- (gnus-point-at-bol)
4639 (1+ (gnus-point-at-eol))
4640 (gnus-delete-line))))))
4642 (mail-header-set-number header (mail-header-number old-header)))
4643 (setq gnus-newsgroup-sparse
4644 (delq (setq number (mail-header-number header))
4645 gnus-newsgroup-sparse))
4646 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4647 (push number gnus-newsgroup-limit)
4648 (gnus-rebuild-thread (mail-header-id header) line)
4649 (gnus-summary-goto-subject number nil t))
4650 (when (and (numberp number)
4652 ;; We have to update the boundaries even if we can't fetch the
4653 ;; article if ID is a number -- so that the next `P' or `N'
4654 ;; command will fetch the previous (or next) article even
4655 ;; if the one we tried to fetch this time has been canceled.
4656 (when (> number gnus-newsgroup-end)
4657 (setq gnus-newsgroup-end number))
4658 (when (< number gnus-newsgroup-begin)
4659 (setq gnus-newsgroup-begin number))
4660 (setq gnus-newsgroup-unselected
4661 (delq number gnus-newsgroup-unselected)))
4662 ;; Report back a success?
4663 (and header (mail-header-number header))))
4665 ;;; Process/prefix in the summary buffer
4667 (defun gnus-summary-work-articles (n)
4668 "Return a list of articles to be worked upon.
4669 The prefix argument, the list of process marked articles, and the
4670 current article will be taken into consideration."
4672 (set-buffer gnus-summary-buffer)
4675 ;; A numerical prefix has been given.
4676 (setq n (prefix-numeric-value n))
4677 (let ((backward (< n 0))
4678 (n (abs (prefix-numeric-value n)))
4683 (push (setq article (gnus-summary-article-number))
4686 (gnus-summary-find-prev nil article)
4687 (gnus-summary-find-next nil article)))
4689 (nreverse articles)))
4690 ((and (gnus-region-active-p) (mark))
4691 (message "region active")
4692 ;; Work on the region between point and mark.
4693 (let ((max (max (point) (mark)))
4696 (goto-char (min (min (point) (mark))))
4699 (push (setq article (gnus-summary-article-number)) articles)
4700 (gnus-summary-find-next nil article)
4702 (nreverse articles))))
4703 (gnus-newsgroup-processable
4704 ;; There are process-marked articles present.
4705 ;; Save current state.
4706 (gnus-summary-save-process-mark)
4708 (reverse gnus-newsgroup-processable))
4710 ;; Just return the current article.
4711 (list (gnus-summary-article-number))))))
4713 (defmacro gnus-summary-iterate (arg &rest forms)
4714 "Iterate over the process/prefixed articles and do FORMS.
4715 ARG is the interactive prefix given to the command. FORMS will be
4716 executed with point over the summary line of the articles."
4717 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4718 `(let ((,articles (gnus-summary-work-articles ,arg)))
4720 (gnus-summary-goto-subject (car ,articles))
4723 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4724 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4726 (defun gnus-summary-save-process-mark ()
4727 "Push the current set of process marked articles on the stack."
4729 (push (copy-sequence gnus-newsgroup-processable)
4730 gnus-newsgroup-process-stack))
4732 (defun gnus-summary-kill-process-mark ()
4733 "Push the current set of process marked articles on the stack and unmark."
4735 (gnus-summary-save-process-mark)
4736 (gnus-summary-unmark-all-processable))
4738 (defun gnus-summary-yank-process-mark ()
4739 "Pop the last process mark state off the stack and restore it."
4741 (unless gnus-newsgroup-process-stack
4742 (error "Empty mark stack"))
4743 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4745 (defun gnus-summary-process-mark-set (set)
4746 "Make SET into the current process marked articles."
4747 (gnus-summary-unmark-all-processable)
4749 (gnus-summary-set-process-mark (pop set))))
4751 ;;; Searching and stuff
4753 (defun gnus-summary-search-group (&optional backward use-level)
4754 "Search for next unread newsgroup.
4755 If optional argument BACKWARD is non-nil, search backward instead."
4757 (set-buffer gnus-group-buffer)
4758 (when (gnus-group-search-forward
4759 backward nil (if use-level (gnus-group-group-level) nil))
4760 (gnus-group-group-name))))
4762 (defun gnus-summary-best-group (&optional exclude-group)
4763 "Find the name of the best unread group.
4764 If EXCLUDE-GROUP, do not go to this group."
4766 (set-buffer gnus-group-buffer)
4768 (gnus-group-best-unread-group exclude-group))))
4770 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4771 (if backward (gnus-summary-find-prev)
4772 (let* ((dummy (gnus-summary-article-intangible-p))
4773 (article (or article (gnus-summary-article-number)))
4774 (arts (gnus-data-find-list article))
4776 (when (and (not dummy)
4777 (or (not gnus-summary-check-current)
4779 (not (gnus-data-unread-p (car arts)))))
4780 (setq arts (cdr arts)))
4785 (when (or (and undownloaded
4786 (eq gnus-undownloaded-mark
4787 (gnus-data-mark (car arts))))
4788 (gnus-data-unread-p (car arts)))
4789 (setq result (car arts)
4791 (setq arts (cdr arts)))
4794 (goto-char (gnus-data-pos result))
4795 (gnus-data-number result)))))
4797 (defun gnus-summary-find-prev (&optional unread article)
4798 (let* ((eobp (eobp))
4799 (article (or article (gnus-summary-article-number)))
4800 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4802 (when (and (not eobp)
4803 (or (not gnus-summary-check-current)
4805 (not (gnus-data-unread-p (car arts)))))
4806 (setq arts (cdr arts)))
4811 (when (gnus-data-unread-p (car arts))
4812 (setq result (car arts)
4814 (setq arts (cdr arts)))
4817 (goto-char (gnus-data-pos result))
4818 (gnus-data-number result))))
4820 (defun gnus-summary-find-subject (subject &optional unread backward article)
4821 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4822 (article (or article (gnus-summary-article-number)))
4823 (articles (gnus-data-list backward))
4824 (arts (gnus-data-find-list article articles))
4826 (when (or (not gnus-summary-check-current)
4828 (not (gnus-data-unread-p (car arts))))
4829 (setq arts (cdr arts)))
4831 (and (or (not unread)
4832 (gnus-data-unread-p (car arts)))
4833 (vectorp (gnus-data-header (car arts)))
4835 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4836 (setq result (car arts)
4838 (setq arts (cdr arts)))
4840 (goto-char (gnus-data-pos result))
4841 (gnus-data-number result))))
4843 (defun gnus-summary-search-forward (&optional unread subject backward)
4844 "Search forward for an article.
4845 If UNREAD, look for unread articles. If SUBJECT, look for
4846 articles with that subject. If BACKWARD, search backward instead."
4847 (cond (subject (gnus-summary-find-subject subject unread backward))
4848 (backward (gnus-summary-find-prev unread))
4849 (t (gnus-summary-find-next unread))))
4851 (defun gnus-recenter (&optional n)
4852 "Center point in window and redisplay frame.
4853 Also do horizontal recentering."
4855 (when (and gnus-auto-center-summary
4856 (not (eq gnus-auto-center-summary 'vertical)))
4857 (gnus-horizontal-recenter))
4860 (defun gnus-summary-recenter ()
4861 "Center point in the summary window.
4862 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4863 displayed, no centering will be performed."
4864 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4865 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4866 (let* ((top (cond ((< (window-height) 4) 0)
4867 ((< (window-height) 7) 1)
4869 (height (1- (window-height)))
4870 (bottom (save-excursion (goto-char (point-max))
4871 (forward-line (- height))
4873 (window (get-buffer-window (current-buffer))))
4874 ;; The user has to want it.
4875 (when gnus-auto-center-summary
4876 (when (get-buffer-window gnus-article-buffer)
4877 ;; Only do recentering when the article buffer is displayed,
4878 ;; Set the window start to either `bottom', which is the biggest
4879 ;; possible valid number, or the second line from the top,
4880 ;; whichever is the least.
4882 window (min bottom (save-excursion
4883 (forward-line (- top)) (point)))))
4884 ;; Do horizontal recentering while we're at it.
4885 (when (and (get-buffer-window (current-buffer) t)
4886 (not (eq gnus-auto-center-summary 'vertical)))
4887 (let ((selected (selected-window)))
4888 (select-window (get-buffer-window (current-buffer) t))
4889 (gnus-summary-position-point)
4890 (gnus-horizontal-recenter)
4891 (select-window selected))))))
4893 (defun gnus-summary-jump-to-group (newsgroup)
4894 "Move point to NEWSGROUP in group mode buffer."
4895 ;; Keep update point of group mode buffer if visible.
4896 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4897 (save-window-excursion
4898 ;; Take care of tree window mode.
4899 (when (get-buffer-window gnus-group-buffer)
4900 (pop-to-buffer gnus-group-buffer))
4901 (gnus-group-jump-to-group newsgroup))
4903 ;; Take care of tree window mode.
4904 (if (get-buffer-window gnus-group-buffer)
4905 (pop-to-buffer gnus-group-buffer)
4906 (set-buffer gnus-group-buffer))
4907 (gnus-group-jump-to-group newsgroup))))
4909 ;; This function returns a list of article numbers based on the
4910 ;; difference between the ranges of read articles in this group and
4911 ;; the range of active articles.
4912 (defun gnus-list-of-unread-articles (group)
4913 (let* ((read (gnus-info-read (gnus-get-info group)))
4914 (active (or (gnus-active group) (gnus-activate-group group)))
4917 ;; If none are read, then all are unread.
4919 (setq first (car active))
4920 ;; If the range of read articles is a single range, then the
4921 ;; first unread article is the article after the last read
4922 ;; article. Sounds logical, doesn't it?
4923 (if (not (listp (cdr read)))
4924 (setq first (max (car active) (1+ (cdr read))))
4925 ;; `read' is a list of ranges.
4926 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4929 (setq first (car active)))
4932 (while (< first nlast)
4934 (setq first (1+ first))))
4935 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4936 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4937 (setq read (cdr read)))))
4938 ;; And add the last unread articles.
4939 (while (<= first last)
4941 (setq first (1+ first)))
4942 ;; Return the list of unread articles.
4943 (delq 0 (nreverse unread))))
4945 (defun gnus-list-of-read-articles (group)
4946 "Return a list of unread, unticked and non-dormant articles."
4947 (let* ((info (gnus-get-info group))
4948 (marked (gnus-info-marks info))
4949 (active (gnus-active group)))
4951 (gnus-set-difference
4952 (gnus-sorted-complement
4953 (gnus-uncompress-range active)
4954 (gnus-list-of-unread-articles group))
4956 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4957 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4959 ;; Various summary commands
4961 (defun gnus-summary-select-article-buffer ()
4962 "Reconfigure windows to show article buffer."
4964 (if (not (gnus-buffer-live-p gnus-article-buffer))
4965 (error "There is no article buffer for this summary buffer")
4966 (gnus-configure-windows 'article)
4967 (select-window (get-buffer-window gnus-article-buffer))))
4969 (defun gnus-summary-universal-argument (arg)
4970 "Perform any operation on all articles that are process/prefixed."
4972 (let ((articles (gnus-summary-work-articles arg))
4979 (substitute-command-keys
4980 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4983 (gnus-error 1 "Undefined key")
4986 (gnus-summary-goto-subject (setq article (pop articles)))
4987 (let (gnus-newsgroup-processable)
4988 (command-execute func))
4989 (gnus-summary-remove-process-mark article)))))
4990 (gnus-summary-position-point))
4992 (defun gnus-summary-toggle-truncation (&optional arg)
4993 "Toggle truncation of summary lines.
4994 With arg, turn line truncation on iff arg is positive."
4996 (setq truncate-lines
4997 (if (null arg) (not truncate-lines)
4998 (> (prefix-numeric-value arg) 0)))
5001 (defun gnus-summary-reselect-current-group (&optional all rescan)
5002 "Exit and then reselect the current newsgroup.
5003 The prefix argument ALL means to select all articles."
5005 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5006 (error "Ephemeral groups can't be reselected"))
5007 (let ((current-subject (gnus-summary-article-number))
5008 (group gnus-newsgroup-name))
5009 (setq gnus-newsgroup-begin nil)
5011 ;; We have to adjust the point of group mode buffer because
5012 ;; point was moved to the next unread newsgroup by exiting.
5013 (gnus-summary-jump-to-group group)
5016 (gnus-group-get-new-news-this-group 1)))
5017 (gnus-group-read-group all t)
5018 (gnus-summary-goto-subject current-subject nil t)))
5020 (defun gnus-summary-rescan-group (&optional all)
5021 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5023 (gnus-summary-reselect-current-group all t))
5025 (defun gnus-summary-update-info (&optional non-destructive)
5027 (let ((group gnus-newsgroup-name))
5029 (when gnus-newsgroup-kill-headers
5030 (setq gnus-newsgroup-killed
5031 (gnus-compress-sequence
5033 (gnus-set-sorted-intersection
5034 (gnus-uncompress-range gnus-newsgroup-killed)
5035 (setq gnus-newsgroup-unselected
5036 (sort gnus-newsgroup-unselected '<)))
5037 (setq gnus-newsgroup-unreads
5038 (sort gnus-newsgroup-unreads '<)))
5040 (unless (listp (cdr gnus-newsgroup-killed))
5041 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5042 (let ((headers gnus-newsgroup-headers))
5043 ;; Set the new ranges of read articles.
5045 (set-buffer gnus-group-buffer)
5046 (gnus-undo-force-boundary))
5047 (gnus-update-read-articles
5048 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5049 ;; Set the current article marks.
5050 (let ((gnus-newsgroup-scored
5051 (if (and (not gnus-save-score)
5052 (not non-destructive))
5054 gnus-newsgroup-scored)))
5056 (gnus-update-marks)))
5057 ;; Do the cross-ref thing.
5058 (when gnus-use-cross-reference
5059 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5060 ;; Do not switch windows but change the buffer to work.
5061 (set-buffer gnus-group-buffer)
5062 (unless (gnus-ephemeral-group-p group)
5063 (gnus-group-update-group group)))))))
5065 (defun gnus-summary-save-newsrc (&optional force)
5066 "Save the current number of read/marked articles in the dribble buffer.
5067 The dribble buffer will then be saved.
5068 If FORCE (the prefix), also save the .newsrc file(s)."
5070 (gnus-summary-update-info t)
5072 (gnus-save-newsrc-file)
5073 (gnus-dribble-save)))
5075 (defun gnus-summary-exit (&optional temporary)
5076 "Exit reading current newsgroup, and then return to group selection mode.
5077 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5079 (gnus-set-global-variables)
5080 (gnus-kill-save-kill-buffer)
5081 (gnus-async-halt-prefetch)
5082 (let* ((group gnus-newsgroup-name)
5083 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5086 (buf (current-buffer)))
5087 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5088 ;; If we have several article buffers, we kill them at exit.
5089 (unless gnus-single-article-buffer
5090 (gnus-kill-buffer gnus-original-article-buffer)
5091 (setq gnus-article-current nil))
5092 (when gnus-use-cache
5093 (gnus-cache-possibly-remove-articles)
5094 (gnus-cache-save-buffers))
5095 (gnus-async-prefetch-remove-group group)
5096 (when gnus-suppress-duplicates
5097 (gnus-dup-enter-articles))
5098 (when gnus-use-trees
5099 (gnus-tree-close group))
5100 ;; Remove entries for this group.
5101 (nnmail-purge-split-history (gnus-group-real-name group))
5102 ;; Make all changes in this group permanent.
5104 (gnus-run-hooks 'gnus-exit-group-hook)
5105 (gnus-summary-update-info)
5106 ;; Do adaptive scoring, and possibly save score files.
5107 (when gnus-newsgroup-adaptive
5108 (gnus-score-adaptive))
5109 (when gnus-use-scoring
5111 (gnus-close-group group)
5112 ;; Make sure where we were, and go to next newsgroup.
5113 (set-buffer gnus-group-buffer)
5115 (gnus-group-jump-to-group group))
5116 (gnus-run-hooks 'gnus-summary-exit-hook)
5117 (unless (or quit-config
5118 ;; If this group has disappeared from the summary
5119 ;; buffer, don't skip forwards.
5120 (not (string= group (gnus-group-group-name))))
5121 (gnus-group-next-unread-group 1))
5122 (setq group-point (point))
5125 (when (gnus-buffer-live-p gnus-article-buffer)
5127 (set-buffer gnus-article-buffer)
5128 (mm-destroy-parts gnus-article-mime-handles)))
5129 ;; If we have several article buffers, we kill them at exit.
5130 (unless gnus-single-article-buffer
5131 (gnus-kill-buffer gnus-article-buffer)
5132 (gnus-kill-buffer gnus-original-article-buffer)
5133 (setq gnus-article-current nil))
5135 (if (not gnus-kill-summary-on-exit)
5136 (gnus-deaden-summary)
5137 ;; We set all buffer-local variables to nil. It is unclear why
5138 ;; this is needed, but if we don't, buffer-local variables are
5139 ;; not garbage-collected, it seems. This would the lead to en
5140 ;; ever-growing Emacs.
5141 (gnus-summary-clear-local-variables)
5142 (when (get-buffer gnus-article-buffer)
5143 (bury-buffer gnus-article-buffer))
5144 ;; We clear the global counterparts of the buffer-local
5145 ;; variables as well, just to be on the safe side.
5146 (set-buffer gnus-group-buffer)
5147 (gnus-summary-clear-local-variables)
5148 ;; Return to group mode buffer.
5149 (when (eq mode 'gnus-summary-mode)
5150 (gnus-kill-buffer buf)))
5151 (setq gnus-current-select-method gnus-select-method)
5152 (pop-to-buffer gnus-group-buffer)
5153 (if (not quit-config)
5155 (goto-char group-point)
5156 (gnus-configure-windows 'group 'force))
5157 (gnus-handle-ephemeral-exit quit-config))
5158 ;; Clear the current group name.
5160 (setq gnus-newsgroup-name nil)))))
5162 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5163 (defun gnus-summary-exit-no-update (&optional no-questions)
5164 "Quit reading current newsgroup without updating read article info."
5166 (let* ((group gnus-newsgroup-name)
5167 (quit-config (gnus-group-quit-config group)))
5168 (when (or no-questions
5170 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5171 (gnus-async-halt-prefetch)
5172 (gnus-run-hooks (delq 'gnus-summary-expire-articles
5173 (copy-list gnus-summary-prepare-exit-hook)))
5174 (when (gnus-buffer-live-p gnus-article-buffer)
5176 (set-buffer gnus-article-buffer)
5177 (mm-destroy-parts gnus-article-mime-handles)))
5178 ;; If we have several article buffers, we kill them at exit.
5179 (unless gnus-single-article-buffer
5180 (gnus-kill-buffer gnus-article-buffer)
5181 (gnus-kill-buffer gnus-original-article-buffer)
5182 (setq gnus-article-current nil))
5183 (if (not gnus-kill-summary-on-exit)
5184 (gnus-deaden-summary)
5185 (gnus-close-group group)
5186 (gnus-summary-clear-local-variables)
5187 (set-buffer gnus-group-buffer)
5188 (gnus-summary-clear-local-variables)
5189 (when (get-buffer gnus-summary-buffer)
5190 (kill-buffer gnus-summary-buffer)))
5191 (unless gnus-single-article-buffer
5192 (setq gnus-article-current nil))
5193 (when gnus-use-trees
5194 (gnus-tree-close group))
5195 (gnus-async-prefetch-remove-group group)
5196 (when (get-buffer gnus-article-buffer)
5197 (bury-buffer gnus-article-buffer))
5198 ;; Return to the group buffer.
5199 (gnus-configure-windows 'group 'force)
5200 ;; Clear the current group name.
5201 (setq gnus-newsgroup-name nil)
5202 (when (equal (gnus-group-group-name) group)
5203 (gnus-group-next-unread-group 1))
5205 (gnus-handle-ephemeral-exit quit-config)))))
5207 (defun gnus-handle-ephemeral-exit (quit-config)
5208 "Handle movement when leaving an ephemeral group.
5209 The state which existed when entering the ephemeral is reset."
5210 (if (not (buffer-name (car quit-config)))
5211 (gnus-configure-windows 'group 'force)
5212 (set-buffer (car quit-config))
5213 (cond ((eq major-mode 'gnus-summary-mode)
5214 (gnus-set-global-variables))
5215 ((eq major-mode 'gnus-article-mode)
5217 ;; The `gnus-summary-buffer' variable may point
5218 ;; to the old summary buffer when using a single
5220 (unless (gnus-buffer-live-p gnus-summary-buffer)
5221 (set-buffer gnus-group-buffer))
5222 (set-buffer gnus-summary-buffer)
5223 (gnus-set-global-variables))))
5224 (if (or (eq (cdr quit-config) 'article)
5225 (eq (cdr quit-config) 'pick))
5227 ;; The current article may be from the ephemeral group
5228 ;; thus it is best that we reload this article
5229 (gnus-summary-show-article)
5230 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5231 (gnus-configure-windows 'pick 'force)
5232 (gnus-configure-windows (cdr quit-config) 'force)))
5233 (gnus-configure-windows (cdr quit-config) 'force))
5234 (when (eq major-mode 'gnus-summary-mode)
5235 (gnus-summary-next-subject 1 nil t)
5236 (gnus-summary-recenter)
5237 (gnus-summary-position-point))))
5241 (defvar gnus-dead-summary-mode-map nil)
5243 (unless gnus-dead-summary-mode-map
5244 (setq gnus-dead-summary-mode-map (make-keymap))
5245 (suppress-keymap gnus-dead-summary-mode-map)
5246 (substitute-key-definition
5247 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5248 (let ((keys '("\C-d" "\r" "\177" [delete])))
5250 (define-key gnus-dead-summary-mode-map
5251 (pop keys) 'gnus-summary-wake-up-the-dead))))
5253 (defvar gnus-dead-summary-mode nil
5254 "Minor mode for Gnus summary buffers.")
5256 (defun gnus-dead-summary-mode (&optional arg)
5257 "Minor mode for Gnus summary buffers."
5259 (when (eq major-mode 'gnus-summary-mode)
5260 (make-local-variable 'gnus-dead-summary-mode)
5261 (setq gnus-dead-summary-mode
5262 (if (null arg) (not gnus-dead-summary-mode)
5263 (> (prefix-numeric-value arg) 0)))
5264 (when gnus-dead-summary-mode
5265 (gnus-add-minor-mode
5266 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5268 (defun gnus-deaden-summary ()
5269 "Make the current summary buffer into a dead summary buffer."
5270 ;; Kill any previous dead summary buffer.
5271 (when (and gnus-dead-summary
5272 (buffer-name gnus-dead-summary))
5274 (set-buffer gnus-dead-summary)
5275 (when gnus-dead-summary-mode
5276 (kill-buffer (current-buffer)))))
5277 ;; Make this the current dead summary.
5278 (setq gnus-dead-summary (current-buffer))
5279 (gnus-dead-summary-mode 1)
5280 (let ((name (buffer-name)))
5281 (when (string-match "Summary" name)
5283 (concat (substring name 0 (match-beginning 0)) "Dead "
5284 (substring name (match-beginning 0)))
5287 (defun gnus-kill-or-deaden-summary (buffer)
5288 "Kill or deaden the summary BUFFER."
5290 (when (and (buffer-name buffer)
5291 (not gnus-single-article-buffer))
5294 (gnus-kill-buffer gnus-article-buffer)
5295 (gnus-kill-buffer gnus-original-article-buffer)))
5296 (cond (gnus-kill-summary-on-exit
5297 (when (and gnus-use-trees
5298 (gnus-buffer-exists-p buffer))
5301 (gnus-tree-close gnus-newsgroup-name)))
5302 (gnus-kill-buffer buffer))
5303 ((gnus-buffer-exists-p buffer)
5306 (gnus-deaden-summary))))))
5308 (defun gnus-summary-wake-up-the-dead (&rest args)
5309 "Wake up the dead summary buffer."
5311 (gnus-dead-summary-mode -1)
5312 (let ((name (buffer-name)))
5313 (when (string-match "Dead " name)
5315 (concat (substring name 0 (match-beginning 0))
5316 (substring name (match-end 0)))
5318 (gnus-message 3 "This dead summary is now alive again"))
5320 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5321 (defun gnus-summary-fetch-faq (&optional faq-dir)
5322 "Fetch the FAQ for the current group.
5323 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5327 (when current-prefix-arg
5329 "Faq dir: " (and (listp gnus-group-faq-directory)
5330 (mapcar (lambda (file) (list file))
5331 gnus-group-faq-directory))))))
5332 (let (gnus-faq-buffer)
5333 (when (setq gnus-faq-buffer
5334 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5335 (gnus-configure-windows 'summary-faq))))
5337 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5338 (defun gnus-summary-describe-group (&optional force)
5339 "Describe the current newsgroup."
5341 (gnus-group-describe-group force gnus-newsgroup-name))
5343 (defun gnus-summary-describe-briefly ()
5344 "Describe summary mode commands briefly."
5347 (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")))
5349 ;; Walking around group mode buffer from summary mode.
5351 (defun gnus-summary-next-group (&optional no-article target-group backward)
5352 "Exit current newsgroup and then select next unread newsgroup.
5353 If prefix argument NO-ARTICLE is non-nil, no article is selected
5354 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5355 previous group instead."
5357 ;; Stop pre-fetching.
5358 (gnus-async-halt-prefetch)
5359 (let ((current-group gnus-newsgroup-name)
5360 (current-buffer (current-buffer))
5362 ;; First we semi-exit this group to update Xrefs and all variables.
5363 ;; We can't do a real exit, because the window conf must remain
5364 ;; the same in case the user is prompted for info, and we don't
5365 ;; want the window conf to change before that...
5366 (gnus-summary-exit t)
5367 (while (not entered)
5368 ;; Then we find what group we are supposed to enter.
5369 (set-buffer gnus-group-buffer)
5370 (gnus-group-jump-to-group current-group)
5373 (if (eq gnus-keep-same-level 'best)
5374 (gnus-summary-best-group gnus-newsgroup-name)
5375 (gnus-summary-search-group backward gnus-keep-same-level))))
5376 (if (not target-group)
5377 ;; There are no further groups, so we return to the group
5380 (gnus-message 5 "Returning to the group buffer")
5382 (when (gnus-buffer-live-p current-buffer)
5383 (set-buffer current-buffer)
5384 (gnus-summary-exit))
5385 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5386 ;; We try to enter the target group.
5387 (gnus-group-jump-to-group target-group)
5388 (let ((unreads (gnus-group-group-unread)))
5389 (if (and (or (eq t unreads)
5390 (and unreads (not (zerop unreads))))
5391 (gnus-summary-read-group
5392 target-group nil no-article
5393 (and (buffer-name current-buffer) current-buffer)
5396 (setq current-group target-group
5397 target-group nil)))))))
5399 (defun gnus-summary-prev-group (&optional no-article)
5400 "Exit current newsgroup and then select previous unread newsgroup.
5401 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5403 (gnus-summary-next-group no-article nil t))
5405 ;; Walking around summary lines.
5407 (defun gnus-summary-first-subject (&optional unread undownloaded)
5408 "Go to the first unread subject.
5409 If UNREAD is non-nil, go to the first unread article.
5410 Returns the article selected or nil if there are no unread articles."
5415 ((null gnus-newsgroup-data)
5416 (gnus-message 3 "No articles in the group")
5418 ;; Pick the first article.
5420 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5421 (gnus-data-number (car gnus-newsgroup-data)))
5422 ;; No unread articles.
5423 ((null gnus-newsgroup-unreads)
5424 (gnus-message 3 "No more unread articles")
5426 ;; Find the first unread article.
5428 (let ((data gnus-newsgroup-data))
5430 (and (not (and undownloaded
5431 (eq gnus-undownloaded-mark
5432 (gnus-data-mark (car data)))))
5433 (not (gnus-data-unread-p (car data)))))
5434 (setq data (cdr data)))
5436 (goto-char (gnus-data-pos (car data)))
5437 (gnus-data-number (car data))))))
5438 (gnus-summary-position-point)))
5440 (defun gnus-summary-next-subject (n &optional unread dont-display)
5441 "Go to next N'th summary line.
5442 If N is negative, go to the previous N'th subject line.
5443 If UNREAD is non-nil, only unread articles are selected.
5444 The difference between N and the actual number of steps taken is
5447 (let ((backward (< n 0))
5451 (gnus-summary-find-prev unread)
5452 (gnus-summary-find-next unread)))
5453 (gnus-summary-show-thread)
5456 (gnus-message 7 "No more%s articles"
5457 (if unread " unread" "")))
5458 (unless dont-display
5459 (gnus-summary-recenter)
5460 (gnus-summary-position-point))
5463 (defun gnus-summary-next-unread-subject (n)
5464 "Go to next N'th unread summary line."
5466 (gnus-summary-next-subject n t))
5468 (defun gnus-summary-prev-subject (n &optional unread)
5469 "Go to previous N'th summary line.
5470 If optional argument UNREAD is non-nil, only unread article is selected."
5472 (gnus-summary-next-subject (- n) unread))
5474 (defun gnus-summary-prev-unread-subject (n)
5475 "Go to previous N'th unread summary line."
5477 (gnus-summary-next-subject (- n) t))
5479 (defun gnus-summary-goto-subject (article &optional force silent)
5480 "Go the subject line of ARTICLE.
5481 If FORCE, also allow jumping to articles not currently shown."
5482 (interactive "nArticle number: ")
5484 (data (gnus-data-find article)))
5485 ;; We read in the article if we have to.
5488 (gnus-summary-insert-subject
5490 (if (or (numberp force) (vectorp force)) force)
5492 (setq data (gnus-data-find article)))
5497 (gnus-message 3 "Can't find article %d" article))
5499 (goto-char (gnus-data-pos data))
5500 (gnus-summary-position-point)
5503 ;; Walking around summary lines with displaying articles.
5505 (defun gnus-summary-expand-window (&optional arg)
5506 "Make the summary buffer take up the entire Emacs frame.
5507 Given a prefix, will force an `article' buffer configuration."
5510 (gnus-configure-windows 'article 'force)
5511 (gnus-configure-windows 'summary 'force)))
5513 (defun gnus-summary-display-article (article &optional all-header)
5514 "Display ARTICLE in article buffer."
5515 (gnus-set-global-variables)
5519 (if gnus-summary-display-article-function
5520 (funcall gnus-summary-display-article-function article all-header)
5521 (gnus-article-prepare article all-header))
5522 (gnus-run-hooks 'gnus-select-article-hook)
5523 (when (and gnus-current-article
5524 (not (zerop gnus-current-article)))
5525 (gnus-summary-goto-subject gnus-current-article))
5526 (gnus-summary-recenter)
5527 (when (and gnus-use-trees gnus-show-threads)
5528 (gnus-possibly-generate-tree article)
5529 (gnus-highlight-selected-tree article))
5530 ;; Successfully display article.
5531 (gnus-article-set-window-start
5532 (cdr (assq article gnus-newsgroup-bookmarks))))))
5534 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5535 "Select the current article.
5536 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5537 non-nil, the article will be re-fetched even if it already present in
5538 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5540 ;; Make sure we are in the summary buffer to work around bbdb bug.
5541 (unless (eq major-mode 'gnus-summary-mode)
5542 (set-buffer gnus-summary-buffer))
5543 (let ((article (or article (gnus-summary-article-number)))
5544 (all-headers (not (not all-headers))) ;Must be T or NIL.
5545 gnus-summary-display-article-function
5548 (gnus-summary-article-pseudo-p article)
5549 (error "This is a pseudo-article"))
5552 (set-buffer gnus-summary-buffer)
5553 (if (or (and gnus-single-article-buffer
5554 (or (null gnus-current-article)
5555 (null gnus-article-current)
5556 (null (get-buffer gnus-article-buffer))
5557 (not (eq article (cdr gnus-article-current)))
5558 (not (equal (car gnus-article-current)
5559 gnus-newsgroup-name))))
5560 (and (not gnus-single-article-buffer)
5561 (or (null gnus-current-article)
5562 (not (eq gnus-current-article article))))
5564 ;; The requested article is different from the current article.
5566 (gnus-summary-display-article article all-headers)
5568 (when (or all-headers gnus-show-all-headers)
5569 (gnus-article-show-all-headers))
5572 (gnus-article-set-window-start
5573 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5575 (defun gnus-summary-set-current-mark (&optional current-mark)
5576 "Obsolete function."
5579 (defun gnus-summary-next-article (&optional unread subject backward push)
5580 "Select the next article.
5581 If UNREAD, only unread articles are selected.
5582 If SUBJECT, only articles with SUBJECT are selected.
5583 If BACKWARD, the previous article is selected instead of the next."
5586 ;; Is there such an article?
5587 ((and (gnus-summary-search-forward unread subject backward)
5588 (or (gnus-summary-display-article (gnus-summary-article-number))
5589 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5590 (gnus-summary-position-point))
5591 ;; If not, we try the first unread, if that is wanted.
5593 gnus-auto-select-same
5594 (gnus-summary-first-unread-article))
5595 (gnus-summary-position-point)
5596 (gnus-message 6 "Wrapped"))
5597 ;; Try to get next/previous article not displayed in this group.
5598 ((and gnus-auto-extend-newsgroup
5599 (not unread) (not subject))
5600 (gnus-summary-goto-article
5601 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5602 nil (count-lines (point-min) (point))))
5603 ;; Go to next/previous group.
5605 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5606 (gnus-summary-jump-to-group gnus-newsgroup-name))
5607 (let ((cmd last-command-char)
5610 (set-buffer gnus-group-buffer)
5613 (if (eq gnus-keep-same-level 'best)
5614 (gnus-summary-best-group gnus-newsgroup-name)
5615 (gnus-summary-search-group backward gnus-keep-same-level))))
5616 ;; For some reason, the group window gets selected. We change
5618 (select-window (get-buffer-window (current-buffer)))
5619 ;; Select next unread newsgroup automagically.
5621 ((or (not gnus-auto-select-next)
5623 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5624 ((or (eq gnus-auto-select-next 'quietly)
5625 (and (eq gnus-auto-select-next 'slightly-quietly)
5627 (and (eq gnus-auto-select-next 'almost-quietly)
5628 (gnus-summary-last-article-p)))
5630 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5632 (gnus-message 7 "No more%s articles (%s)..."
5633 (if unread " unread" "")
5634 (if group (concat "selecting " group)
5636 (gnus-summary-next-group nil group backward)))
5638 (when (gnus-key-press-event-p last-input-event)
5639 (gnus-summary-walk-group-buffer
5640 gnus-newsgroup-name cmd unread backward point))))))))
5642 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5643 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5644 (?\C-p (gnus-group-prev-unread-group 1))))
5645 (cursor-in-echo-area t)
5646 keve key group ended)
5648 (set-buffer gnus-group-buffer)
5651 (if (eq gnus-keep-same-level 'best)
5652 (gnus-summary-best-group gnus-newsgroup-name)
5653 (gnus-summary-search-group backward gnus-keep-same-level))))
5656 5 "No more%s articles%s" (if unread " unread" "")
5658 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5659 (format " (Type %s for %s [%s])"
5660 (single-key-description cmd) group
5661 (car (gnus-gethash group gnus-newsrc-hashtb)))
5662 (format " (Type %s to exit %s)"
5663 (single-key-description cmd)
5664 gnus-newsgroup-name)))
5665 ;; Confirm auto selection.
5666 (setq key (car (setq keve (gnus-read-event-char))))
5669 ((assq key keystrokes)
5670 (let ((obuf (current-buffer)))
5671 (switch-to-buffer gnus-group-buffer)
5673 (gnus-group-jump-to-group group))
5674 (eval (cadr (assq key keystrokes)))
5675 (setq group (gnus-group-group-name))
5676 (switch-to-buffer obuf))
5680 (gnus-ephemeral-group-p gnus-newsgroup-name))
5682 (gnus-summary-next-group nil group backward)))
5684 (push (cdr keve) unread-command-events))))))
5686 (defun gnus-summary-next-unread-article ()
5687 "Select unread article after current one."
5689 (gnus-summary-next-article
5690 (or (not (eq gnus-summary-goto-unread 'never))
5691 (gnus-summary-last-article-p (gnus-summary-article-number)))
5692 (and gnus-auto-select-same
5693 (gnus-summary-article-subject))))
5695 (defun gnus-summary-prev-article (&optional unread subject)
5696 "Select the article after the current one.
5697 If UNREAD is non-nil, only unread articles are selected."
5699 (gnus-summary-next-article unread subject t))
5701 (defun gnus-summary-prev-unread-article ()
5702 "Select unread article before current one."
5704 (gnus-summary-prev-article
5705 (or (not (eq gnus-summary-goto-unread 'never))
5706 (gnus-summary-first-article-p (gnus-summary-article-number)))
5707 (and gnus-auto-select-same
5708 (gnus-summary-article-subject))))
5710 (defun gnus-summary-next-page (&optional lines circular)
5711 "Show next page of the selected article.
5712 If at the end of the current article, select the next article.
5713 LINES says how many lines should be scrolled up.
5715 If CIRCULAR is non-nil, go to the start of the article instead of
5716 selecting the next article when reaching the end of the current
5719 (setq gnus-summary-buffer (current-buffer))
5720 (gnus-set-global-variables)
5721 (let ((article (gnus-summary-article-number))
5722 (article-window (get-buffer-window gnus-article-buffer t))
5724 ;; If the buffer is empty, we have no article.
5726 (error "No article to select"))
5727 (gnus-configure-windows 'article)
5728 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5729 (if (and (eq gnus-summary-goto-unread 'never)
5730 (not (gnus-summary-last-article-p article)))
5731 (gnus-summary-next-article)
5732 (gnus-summary-next-unread-article))
5733 (if (or (null gnus-current-article)
5734 (null gnus-article-current)
5735 (/= article (cdr gnus-article-current))
5736 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5737 ;; Selected subject is different from current article's.
5738 (gnus-summary-display-article article)
5739 (when article-window
5740 (gnus-eval-in-buffer-window gnus-article-buffer
5741 (setq endp (gnus-article-next-page lines)))
5744 (gnus-summary-beginning-of-article))
5746 (gnus-message 3 "End of message"))
5748 (if (and (eq gnus-summary-goto-unread 'never)
5749 (not (gnus-summary-last-article-p article)))
5750 (gnus-summary-next-article)
5751 (gnus-summary-next-unread-article))))))))
5752 (gnus-summary-recenter)
5753 (gnus-summary-position-point)))
5755 (defun gnus-summary-prev-page (&optional lines move)
5756 "Show previous page of selected article.
5757 Argument LINES specifies lines to be scrolled down.
5758 If MOVE, move to the previous unread article if point is at
5759 the beginning of the buffer."
5761 (let ((article (gnus-summary-article-number))
5762 (article-window (get-buffer-window gnus-article-buffer t))
5764 (gnus-configure-windows 'article)
5765 (if (or (null gnus-current-article)
5766 (null gnus-article-current)
5767 (/= article (cdr gnus-article-current))
5768 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5769 ;; Selected subject is different from current article's.
5770 (gnus-summary-display-article article)
5771 (gnus-summary-recenter)
5772 (when article-window
5773 (gnus-eval-in-buffer-window gnus-article-buffer
5774 (setq endp (gnus-article-prev-page lines)))
5775 (when (and move endp)
5777 (gnus-message 3 "Beginning of message"))
5779 (if (and (eq gnus-summary-goto-unread 'never)
5780 (not (gnus-summary-first-article-p article)))
5781 (gnus-summary-prev-article)
5782 (gnus-summary-prev-unread-article))))))))
5783 (gnus-summary-position-point))
5785 (defun gnus-summary-prev-page-or-article (&optional lines)
5786 "Show previous page of selected article.
5787 Argument LINES specifies lines to be scrolled down.
5788 If at the beginning of the article, go to the next article."
5790 (gnus-summary-prev-page lines t))
5792 (defun gnus-summary-scroll-up (lines)
5793 "Scroll up (or down) one line current article.
5794 Argument LINES specifies lines to be scrolled up (or down if negative)."
5796 (gnus-configure-windows 'article)
5797 (gnus-summary-show-thread)
5798 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5799 (gnus-eval-in-buffer-window gnus-article-buffer
5801 (when (gnus-article-next-page lines)
5802 (gnus-message 3 "End of message")))
5804 (gnus-article-prev-page (- lines))))))
5805 (gnus-summary-recenter)
5806 (gnus-summary-position-point))
5808 (defun gnus-summary-scroll-down (lines)
5809 "Scroll down (or up) one line current article.
5810 Argument LINES specifies lines to be scrolled down (or up if negative)."
5812 (gnus-summary-scroll-up (- lines)))
5814 (defun gnus-summary-next-same-subject ()
5815 "Select next article which has the same subject as current one."
5817 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5819 (defun gnus-summary-prev-same-subject ()
5820 "Select previous article which has the same subject as current one."
5822 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5824 (defun gnus-summary-next-unread-same-subject ()
5825 "Select next unread article which has the same subject as current one."
5827 (gnus-summary-next-article t (gnus-summary-article-subject)))
5829 (defun gnus-summary-prev-unread-same-subject ()
5830 "Select previous unread article which has the same subject as current one."
5832 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5834 (defun gnus-summary-first-unread-article ()
5835 "Select the first unread article.
5836 Return nil if there are no unread articles."
5839 (when (gnus-summary-first-subject t)
5840 (gnus-summary-show-thread)
5841 (gnus-summary-first-subject t)
5842 (gnus-summary-display-article (gnus-summary-article-number)))
5843 (gnus-summary-position-point)))
5845 (defun gnus-summary-first-unread-subject ()
5846 "Place the point on the subject line of the first unread article.
5847 Return nil if there are no unread articles."
5850 (when (gnus-summary-first-subject t)
5851 (gnus-summary-show-thread)
5852 (gnus-summary-first-subject t))
5853 (gnus-summary-position-point)))
5855 (defun gnus-summary-first-article ()
5856 "Select the first article.
5857 Return nil if there are no articles."
5860 (when (gnus-summary-first-subject)
5861 (gnus-summary-show-thread)
5862 (gnus-summary-first-subject)
5863 (gnus-summary-display-article (gnus-summary-article-number)))
5864 (gnus-summary-position-point)))
5866 (defun gnus-summary-best-unread-article ()
5867 "Select the unread article with the highest score."
5869 (let ((best -1000000)
5870 (data gnus-newsgroup-data)
5873 (and (gnus-data-unread-p (car data))
5875 (gnus-summary-article-score (gnus-data-number (car data))))
5878 article (gnus-data-number (car data))))
5879 (setq data (cdr data)))
5882 (gnus-summary-goto-article article)
5883 (error "No unread articles"))
5884 (gnus-summary-position-point))))
5886 (defun gnus-summary-last-subject ()
5887 "Go to the last displayed subject line in the group."
5888 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5890 (gnus-summary-goto-subject article))))
5892 (defun gnus-summary-goto-article (article &optional all-headers force)
5893 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5894 If ALL-HEADERS is non-nil, no header lines are hidden.
5895 If FORCE, go to the article even if it isn't displayed. If FORCE
5896 is a number, it is the line the article is to be displayed on."
5900 "Article number or Message-ID: "
5901 (mapcar (lambda (number) (list (int-to-string number)))
5902 gnus-newsgroup-limit))
5906 (if (and (stringp article)
5907 (string-match "@" article))
5908 (gnus-summary-refer-article article)
5909 (when (stringp article)
5910 (setq article (string-to-number article)))
5911 (if (gnus-summary-goto-subject article force)
5912 (gnus-summary-display-article article all-headers)
5913 (gnus-message 4 "Couldn't go to article %s" article) nil))
5914 (gnus-summary-position-point)))
5916 (defun gnus-summary-goto-last-article ()
5917 "Go to the previously read article."
5920 (when gnus-last-article
5921 (gnus-summary-goto-article gnus-last-article nil t))
5922 (gnus-summary-position-point)))
5924 (defun gnus-summary-pop-article (number)
5925 "Pop one article off the history and go to the previous.
5926 NUMBER articles will be popped off."
5929 (setq gnus-newsgroup-history
5930 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5932 (gnus-summary-goto-article (car to) nil t)
5933 (error "Article history empty")))
5934 (gnus-summary-position-point))
5936 ;; Summary commands and functions for limiting the summary buffer.
5938 (defun gnus-summary-limit-to-articles (n)
5939 "Limit the summary buffer to the next N articles.
5940 If not given a prefix, use the process marked articles instead."
5943 (let ((articles (gnus-summary-work-articles n)))
5944 (setq gnus-newsgroup-processable nil)
5945 (gnus-summary-limit articles))
5946 (gnus-summary-position-point)))
5948 (defun gnus-summary-pop-limit (&optional total)
5949 "Restore the previous limit.
5950 If given a prefix, remove all limits."
5953 (setq gnus-newsgroup-limits
5954 (list (mapcar (lambda (h) (mail-header-number h))
5955 gnus-newsgroup-headers))))
5956 (unless gnus-newsgroup-limits
5957 (error "No limit to pop"))
5959 (gnus-summary-limit nil 'pop)
5960 (gnus-summary-position-point)))
5962 (defun gnus-summary-limit-to-subject (subject &optional header)
5963 "Limit the summary buffer to articles that have subjects that match a regexp."
5964 (interactive "sLimit to subject (regexp): ")
5966 (setq header "subject"))
5967 (when (not (equal "" subject))
5969 (let ((articles (gnus-summary-find-matching
5970 (or header "subject") subject 'all)))
5972 (error "Found no matches for \"%s\"" subject))
5973 (gnus-summary-limit articles))
5974 (gnus-summary-position-point))))
5976 (defun gnus-summary-limit-to-author (from)
5977 "Limit the summary buffer to articles that have authors that match a regexp."
5978 (interactive "sLimit to author (regexp): ")
5979 (gnus-summary-limit-to-subject from "from"))
5981 (defun gnus-summary-limit-to-age (age &optional younger-p)
5982 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5983 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5984 articles that are younger than AGE days."
5985 (interactive "nTime in days: \nP")
5987 (let ((data gnus-newsgroup-data)
5988 (cutoff (days-to-time age))
5989 articles d date is-younger)
5990 (while (setq d (pop data))
5991 (when (and (vectorp (gnus-data-header d))
5992 (setq date (mail-header-date (gnus-data-header d))))
5993 (setq is-younger (time-less-p
5994 (time-since (date-to-time date))
5999 (push (gnus-data-number d) articles))))
6000 (gnus-summary-limit (nreverse articles)))
6001 (gnus-summary-position-point)))
6003 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6005 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6007 (defun gnus-summary-limit-to-unread (&optional all)
6008 "Limit the summary buffer to articles that are not marked as read.
6009 If ALL is non-nil, limit strictly to unread articles."
6012 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6013 (gnus-summary-limit-to-marks
6014 ;; Concat all the marks that say that an article is read and have
6016 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6017 gnus-killed-mark gnus-kill-file-mark
6018 gnus-low-score-mark gnus-expirable-mark
6019 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6020 gnus-duplicate-mark gnus-souped-mark)
6023 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6024 (make-obsolete 'gnus-summary-delete-marked-with
6025 'gnus-summary-limit-exlude-marks)
6027 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6028 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6029 If REVERSE, limit the summary buffer to articles that are marked
6030 with MARKS. MARKS can either be a string of marks or a list of marks.
6031 Returns how many articles were removed."
6032 (interactive "sMarks: ")
6033 (gnus-summary-limit-to-marks marks t))
6035 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6036 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6037 If REVERSE (the prefix), limit the summary buffer to articles that are
6038 not marked with MARKS. MARKS can either be a string of marks or a
6040 Returns how many articles were removed."
6041 (interactive "sMarks: \nP")
6043 (let ((data gnus-newsgroup-data)
6044 (marks (if (listp marks) marks
6045 (append marks nil))) ; Transform to list.
6048 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6049 (memq (gnus-data-mark (car data)) marks))
6050 (push (gnus-data-number (car data)) articles))
6051 (setq data (cdr data)))
6052 (gnus-summary-limit articles))
6053 (gnus-summary-position-point)))
6055 (defun gnus-summary-limit-to-score (&optional score)
6056 "Limit to articles with score at or above SCORE."
6058 (setq score (if score
6059 (prefix-numeric-value score)
6060 (or gnus-summary-default-score 0)))
6061 (let ((data gnus-newsgroup-data)
6064 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6066 (push (gnus-data-number (car data)) articles))
6067 (setq data (cdr data)))
6069 (gnus-summary-limit articles)
6070 (gnus-summary-position-point))))
6072 (defun gnus-summary-limit-include-thread (id)
6073 "Display all the hidden articles that in the current thread."
6074 (interactive (list (mail-header-id (gnus-summary-article-header))))
6075 (let ((articles (gnus-articles-in-thread
6076 (gnus-id-to-thread (gnus-root-id id)))))
6078 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6079 (gnus-summary-position-point))))
6081 (defun gnus-summary-limit-include-dormant ()
6082 "Display all the hidden articles that are marked as dormant.
6083 Note that this command only works on a subset of the articles currently
6084 fetched for this group."
6086 (unless gnus-newsgroup-dormant
6087 (error "There are no dormant articles in this group"))
6089 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6090 (gnus-summary-position-point)))
6092 (defun gnus-summary-limit-exclude-dormant ()
6093 "Hide all dormant articles."
6096 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6097 (gnus-summary-position-point)))
6099 (defun gnus-summary-limit-exclude-childless-dormant ()
6100 "Hide all dormant articles that have no children."
6102 (let ((data (gnus-data-list t))
6103 articles d children)
6104 ;; Find all articles that are either not dormant or have
6106 (while (setq d (pop data))
6107 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6109 (gnus-article-children (gnus-data-number d)))
6112 (when (memq (car children) articles)
6117 (push (gnus-data-number d) articles)))
6120 (gnus-summary-limit articles)
6121 (gnus-summary-position-point))))
6123 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6124 "Mark all unread excluded articles as read.
6125 If ALL, mark even excluded ticked and dormants as read."
6127 (let ((articles (gnus-sorted-complement
6129 (mapcar (lambda (h) (mail-header-number h))
6130 gnus-newsgroup-headers)
6132 (sort gnus-newsgroup-limit '<)))
6134 (setq gnus-newsgroup-unreads
6135 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6137 (setq gnus-newsgroup-dormant nil
6138 gnus-newsgroup-marked nil
6139 gnus-newsgroup-reads
6141 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6142 gnus-newsgroup-reads))
6143 (while (setq article (pop articles))
6144 (unless (or (memq article gnus-newsgroup-dormant)
6145 (memq article gnus-newsgroup-marked))
6146 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6148 (defun gnus-summary-limit (articles &optional pop)
6150 ;; We pop the previous limit off the stack and use that.
6151 (setq articles (car gnus-newsgroup-limits)
6152 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6153 ;; We use the new limit, so we push the old limit on the stack.
6154 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6156 (setq gnus-newsgroup-limit articles)
6157 (let ((total (length gnus-newsgroup-data))
6158 (data (gnus-data-find-list (gnus-summary-article-number)))
6159 (gnus-summary-mark-below nil) ; Inhibit this.
6161 ;; This will do all the work of generating the new summary buffer
6162 ;; according to the new limit.
6163 (gnus-summary-prepare)
6164 ;; Hide any threads, possibly.
6165 (and gnus-show-threads
6166 gnus-thread-hide-subtree
6167 (gnus-summary-hide-all-threads))
6168 ;; Try to return to the article you were at, or one in the
6171 ;; We try to find some article after the current one.
6173 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6176 (setq data (cdr data))))
6178 ;; If there is no data, that means that we were after the last
6179 ;; article. The same goes when we can't find any articles
6180 ;; after the current one.
6181 (goto-char (point-max))
6182 (gnus-summary-find-prev))
6183 (gnus-set-mode-line 'summary)
6184 ;; We return how many articles were removed from the summary
6185 ;; buffer as a result of the new limit.
6186 (- total (length gnus-newsgroup-data))))
6188 (defsubst gnus-invisible-cut-children (threads)
6191 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6196 (defsubst gnus-cut-thread (thread)
6197 "Go forwards in the thread until we find an article that we want to display."
6198 (when (or (eq gnus-fetch-old-headers 'some)
6199 (eq gnus-fetch-old-headers 'invisible)
6200 (eq gnus-build-sparse-threads 'some)
6201 (eq gnus-build-sparse-threads 'more))
6202 ;; Deal with old-fetched headers and sparse threads.
6206 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6207 (gnus-summary-article-ancient-p
6208 (mail-header-number (car thread))))
6209 (if (or (<= (length (cdr thread)) 1)
6210 (eq gnus-fetch-old-headers 'invisible))
6211 (setq gnus-newsgroup-limit
6212 (delq (mail-header-number (car thread))
6213 gnus-newsgroup-limit)
6214 thread (cadr thread))
6215 (when (gnus-invisible-cut-children (cdr thread))
6216 (let ((th (cdr thread)))
6218 (if (memq (mail-header-number (caar th))
6219 gnus-newsgroup-limit)
6220 (setq thread (car th)
6222 (setq th (cdr th))))))))))
6225 (defun gnus-cut-threads (threads)
6226 "Cut off all uninteresting articles from the beginning of threads."
6227 (when (or (eq gnus-fetch-old-headers 'some)
6228 (eq gnus-fetch-old-headers 'invisible)
6229 (eq gnus-build-sparse-threads 'some)
6230 (eq gnus-build-sparse-threads 'more))
6233 (setcar th (gnus-cut-thread (car th)))
6234 (setq th (cdr th)))))
6235 ;; Remove nixed out threads.
6238 (defun gnus-summary-initial-limit (&optional show-if-empty)
6239 "Figure out what the initial limit is supposed to be on group entry.
6240 This entails weeding out unwanted dormants, low-scored articles,
6241 fetch-old-headers verbiage, and so on."
6242 ;; Most groups have nothing to remove.
6243 (if (or gnus-inhibit-limiting
6244 (and (null gnus-newsgroup-dormant)
6245 (not (eq gnus-fetch-old-headers 'some))
6246 (not (eq gnus-fetch-old-headers 'invisible))
6247 (null gnus-summary-expunge-below)
6248 (not (eq gnus-build-sparse-threads 'some))
6249 (not (eq gnus-build-sparse-threads 'more))
6250 (null gnus-thread-expunge-below)
6251 (not gnus-use-nocem)))
6253 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6254 (setq gnus-newsgroup-limit nil)
6257 (unless (car (symbol-value node))
6258 ;; These threads have no parents -- they are roots.
6259 (let ((nodes (cdr (symbol-value node)))
6262 (if (and gnus-thread-expunge-below
6263 (< (gnus-thread-total-score (car nodes))
6264 gnus-thread-expunge-below))
6265 (gnus-expunge-thread (pop nodes))
6266 (setq thread (pop nodes))
6267 (gnus-summary-limit-children thread))))))
6268 gnus-newsgroup-dependencies)
6269 ;; If this limitation resulted in an empty group, we might
6270 ;; pop the previous limit and use it instead.
6271 (when (and (not gnus-newsgroup-limit)
6273 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6274 gnus-newsgroup-limit))
6276 (defun gnus-summary-limit-children (thread)
6277 "Return 1 if this subthread is visible and 0 if it is not."
6278 ;; First we get the number of visible children to this thread. This
6279 ;; is done by recursing down the thread using this function, so this
6280 ;; will really go down to a leaf article first, before slowly
6281 ;; working its way up towards the root.
6285 (apply '+ (mapcar 'gnus-summary-limit-children
6288 (number (mail-header-number (car thread)))
6291 (not (memq number gnus-newsgroup-marked))
6293 ;; If this article is dormant and has absolutely no visible
6294 ;; children, then this article isn't visible.
6295 (and (memq number gnus-newsgroup-dormant)
6297 ;; If this is "fetch-old-headered" and there is no
6298 ;; visible children, then we don't want this article.
6299 (and (eq gnus-fetch-old-headers 'some)
6300 (gnus-summary-article-ancient-p number)
6302 ;; If this is "fetch-old-headered" and `invisible', then
6303 ;; we don't want this article.
6304 (and (eq gnus-fetch-old-headers 'invisible)
6305 (gnus-summary-article-ancient-p number))
6306 ;; If this is a sparsely inserted article with no children,
6307 ;; we don't want it.
6308 (and (eq gnus-build-sparse-threads 'some)
6309 (gnus-summary-article-sparse-p number)
6311 ;; If we use expunging, and this article is really
6312 ;; low-scored, then we don't want this article.
6313 (when (and gnus-summary-expunge-below
6315 (or (cdr (assq number gnus-newsgroup-scored))
6316 gnus-summary-default-score))
6317 gnus-summary-expunge-below))
6318 ;; We increase the expunge-tally here, but that has
6319 ;; nothing to do with the limits, really.
6320 (incf gnus-newsgroup-expunged-tally)
6321 ;; We also mark as read here, if that's wanted.
6322 (when (and gnus-summary-mark-below
6323 (< score gnus-summary-mark-below))
6324 (setq gnus-newsgroup-unreads
6325 (delq number gnus-newsgroup-unreads))
6326 (if gnus-newsgroup-auto-expire
6327 (push number gnus-newsgroup-expirable)
6328 (push (cons number gnus-low-score-mark)
6329 gnus-newsgroup-reads)))
6331 ;; Check NoCeM things.
6332 (if (and gnus-use-nocem
6333 (gnus-nocem-unwanted-article-p
6334 (mail-header-id (car thread))))
6336 (setq gnus-newsgroup-unreads
6337 (delq number gnus-newsgroup-unreads))
6339 ;; Nope, invisible article.
6341 ;; Ok, this article is to be visible, so we add it to the limit
6343 (push number gnus-newsgroup-limit)
6346 (defun gnus-expunge-thread (thread)
6347 "Mark all articles in THREAD as read."
6348 (let* ((number (mail-header-number (car thread))))
6349 (incf gnus-newsgroup-expunged-tally)
6350 ;; We also mark as read here, if that's wanted.
6351 (setq gnus-newsgroup-unreads
6352 (delq number gnus-newsgroup-unreads))
6353 (if gnus-newsgroup-auto-expire
6354 (push number gnus-newsgroup-expirable)
6355 (push (cons number gnus-low-score-mark)
6356 gnus-newsgroup-reads)))
6357 ;; Go recursively through all subthreads.
6358 (mapcar 'gnus-expunge-thread (cdr thread)))
6360 ;; Summary article oriented commands
6362 (defun gnus-summary-refer-parent-article (n)
6363 "Refer parent article N times.
6364 If N is negative, go to ancestor -N instead.
6365 The difference between N and the number of articles fetched is returned."
6369 (when (not (natnump n))
6374 (setq header (gnus-summary-article-header))
6375 (if (and (eq (mail-header-number header)
6376 (cdr gnus-article-current))
6377 (equal gnus-newsgroup-name
6378 (car gnus-article-current)))
6379 ;; If we try to find the parent of the currently
6380 ;; displayed article, then we take a look at the actual
6381 ;; References header, since this is slightly more
6382 ;; reliable than the References field we got from the
6385 (set-buffer gnus-original-article-buffer)
6386 (nnheader-narrow-to-headers)
6387 (unless (setq ref (message-fetch-field "references"))
6388 (setq ref (message-fetch-field "in-reply-to")))
6391 ;; It's not the current article, so we take a bet on
6392 ;; the value we got from the server.
6393 (mail-header-references header)))
6395 (not (equal ref "")))
6396 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6397 (gnus-message 1 "Couldn't find parent"))
6398 (gnus-message 1 "No references in article %d"
6399 (gnus-summary-article-number))
6402 (gnus-summary-position-point)
6405 (defun gnus-summary-refer-references ()
6406 "Fetch all articles mentioned in the References header.
6407 Return the number of articles fetched."
6409 (let ((ref (mail-header-references (gnus-summary-article-header)))
6410 (current (gnus-summary-article-number))
6414 (error "No References in the current article")
6415 ;; For each Message-ID in the References header...
6416 (while (string-match "<[^>]*>" ref)
6418 ;; ... fetch that article.
6419 (gnus-summary-refer-article
6420 (prog1 (match-string 0 ref)
6421 (setq ref (substring ref (match-end 0))))))
6422 (gnus-summary-goto-subject current)
6423 (gnus-summary-position-point)
6426 (defun gnus-summary-refer-thread (&optional limit)
6427 "Fetch all articles in the current thread.
6428 If LIMIT (the numerical prefix), fetch that many old headers instead
6429 of what's specified by the `gnus-refer-thread-limit' variable."
6431 (let ((id (mail-header-id (gnus-summary-article-header)))
6432 (limit (if limit (prefix-numeric-value limit)
6433 gnus-refer-thread-limit)))
6434 ;; We want to fetch LIMIT *old* headers, but we also have to
6435 ;; re-fetch all the headers in the current buffer, because many of
6436 ;; them may be undisplayed. So we adjust LIMIT.
6437 (when (numberp limit)
6438 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6439 (unless (eq gnus-fetch-old-headers 'invisible)
6440 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6441 ;; Retrieve the headers and read them in.
6442 (if (eq (gnus-retrieve-headers
6443 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6445 (gnus-build-all-threads)
6446 (error "Can't fetch thread from backends that don't support NOV"))
6447 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6448 (gnus-summary-limit-include-thread id)))
6450 (defun gnus-summary-refer-article (message-id &optional arg)
6451 "Fetch an article specified by MESSAGE-ID.
6452 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6453 or `gnus-select-method', no matter what backend the article comes from."
6454 (interactive "sMessage-ID: \nP")
6455 (when (and (stringp message-id)
6456 (not (zerop (length message-id))))
6457 ;; Construct the correct Message-ID if necessary.
6458 ;; Suggested by tale@pawl.rpi.edu.
6459 (unless (string-match "^<" message-id)
6460 (setq message-id (concat "<" message-id)))
6461 (unless (string-match ">$" message-id)
6462 (setq message-id (concat message-id ">")))
6463 (let* ((header (gnus-id-to-header message-id))
6465 (gnus-summary-article-sparse-p
6466 (mail-header-number header))
6467 (memq (mail-header-number header)
6468 gnus-newsgroup-limit))))
6470 ;; If the article is present in the buffer we just go to it.
6472 (or (not (gnus-summary-article-sparse-p
6473 (mail-header-number header)))
6476 (gnus-summary-goto-article
6477 (mail-header-number header) nil t)
6479 (gnus-summary-update-article (mail-header-number header)))))
6481 ;; We fetch the article
6482 (let ((gnus-override-method
6483 (cond ((gnus-news-group-p gnus-newsgroup-name)
6484 gnus-refer-article-method)
6486 (or gnus-refer-article-method gnus-select-method))
6489 ;; Start the special refer-article method, if necessary.
6490 (when (and gnus-refer-article-method
6491 (gnus-news-group-p gnus-newsgroup-name))
6492 (gnus-check-server gnus-refer-article-method))
6493 ;; Fetch the header, and display the article.
6494 (if (setq number (gnus-summary-insert-subject message-id))
6495 (gnus-summary-select-article nil nil nil number)
6496 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6498 (defun gnus-summary-edit-parameters ()
6499 "Edit the group parameters of the current group."
6501 (gnus-group-edit-group gnus-newsgroup-name 'params))
6503 (defun gnus-summary-enter-digest-group (&optional force)
6504 "Enter an nndoc group based on the current article.
6505 If FORCE, force a digest interpretation. If not, try
6506 to guess what the document format is."
6508 (let ((conf gnus-current-window-configuration))
6510 (gnus-summary-select-article))
6511 (setq gnus-current-window-configuration conf)
6512 (let* ((name (format "%s-%d"
6513 (gnus-group-prefixed-name
6514 gnus-newsgroup-name (list 'nndoc ""))
6516 (set-buffer gnus-summary-buffer)
6517 gnus-current-article)))
6518 (ogroup gnus-newsgroup-name)
6519 (params (append (gnus-info-params (gnus-get-info ogroup))
6520 (list (cons 'to-group ogroup))
6521 (list (cons 'save-article-group ogroup))))
6522 (case-fold-search t)
6523 (buf (current-buffer))
6526 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6527 (insert-buffer-substring gnus-original-article-buffer)
6528 ;; Remove lines that may lead nndoc to misinterpret the
6531 (goto-char (point-min))
6532 (or (search-forward "\n\n" nil t) (point)))
6533 (goto-char (point-min))
6534 (delete-matching-lines "^\\(Path\\):\\|^From ")
6537 (if (gnus-group-read-ephemeral-group
6538 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6540 ,(if force 'digest 'guess))) t)
6541 ;; Make all postings to this group go to the parent group.
6542 (nconc (gnus-info-params (gnus-get-info name))
6544 ;; Couldn't select this doc group.
6545 (switch-to-buffer buf)
6546 (gnus-set-global-variables)
6547 (gnus-configure-windows 'summary)
6548 (gnus-message 3 "Article couldn't be entered?"))
6549 (kill-buffer dig)))))
6551 (defun gnus-summary-read-document (n)
6552 "Open a new group based on the current article(s).
6553 This will allow you to read digests and other similar
6554 documents as newsgroups.
6555 Obeys the standard process/prefix convention."
6557 (let* ((articles (gnus-summary-work-articles n))
6558 (ogroup gnus-newsgroup-name)
6559 (params (append (gnus-info-params (gnus-get-info ogroup))
6560 (list (cons 'to-group ogroup))))
6561 article group egroup groups vgroup)
6562 (while (setq article (pop articles))
6563 (setq group (format "%s-%d" gnus-newsgroup-name article))
6564 (gnus-summary-remove-process-mark article)
6565 (when (gnus-summary-display-article article)
6568 (insert-buffer-substring gnus-original-article-buffer)
6569 ;; Remove some headers that may lead nndoc to make
6571 (message-narrow-to-head)
6572 (goto-char (point-min))
6573 (delete-matching-lines "^\\(Path\\):\\|^From ")
6576 (gnus-group-read-ephemeral-group
6577 group `(nndoc ,group (nndoc-address ,(current-buffer))
6578 (nndoc-article-type guess))
6581 ;; Make all postings to this group go to the parent group.
6582 (nconc (gnus-info-params (gnus-get-info egroup))
6584 (push egroup groups))
6585 ;; Couldn't select this doc group.
6586 (gnus-error 3 "Article couldn't be entered"))))))
6587 ;; Now we have selected all the documents.
6590 (error "None of the articles could be interpreted as documents"))
6591 ((gnus-group-read-ephemeral-group
6592 (setq vgroup (format
6593 "nnvirtual:%s-%s" gnus-newsgroup-name
6594 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6595 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6597 (cons (current-buffer) 'summary)))
6599 (error "Couldn't select virtual nndoc group")))))
6601 (defun gnus-summary-isearch-article (&optional regexp-p)
6602 "Do incremental search forward on the current article.
6603 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6605 (gnus-summary-select-article)
6606 (gnus-configure-windows 'article)
6607 (gnus-eval-in-buffer-window gnus-article-buffer
6610 (isearch-forward regexp-p))))
6612 (defun gnus-summary-search-article-forward (regexp &optional backward)
6613 "Search for an article containing REGEXP forward.
6614 If BACKWARD, search backward instead."
6617 (format "Search article %s (regexp%s): "
6618 (if current-prefix-arg "backward" "forward")
6619 (if gnus-last-search-regexp
6620 (concat ", default " gnus-last-search-regexp)
6622 current-prefix-arg))
6623 (if (string-equal regexp "")
6624 (setq regexp (or gnus-last-search-regexp ""))
6625 (setq gnus-last-search-regexp regexp))
6626 (if (gnus-summary-search-article regexp backward)
6627 (gnus-summary-show-thread)
6628 (error "Search failed: \"%s\"" regexp)))
6630 (defun gnus-summary-search-article-backward (regexp)
6631 "Search for an article containing REGEXP backward."
6634 (format "Search article backward (regexp%s): "
6635 (if gnus-last-search-regexp
6636 (concat ", default " gnus-last-search-regexp)
6638 (gnus-summary-search-article-forward regexp 'backward))
6640 (defun gnus-summary-search-article (regexp &optional backward)
6641 "Search for an article containing REGEXP.
6642 Optional argument BACKWARD means do search for backward.
6643 `gnus-select-article-hook' is not called during the search."
6644 ;; We have to require this here to make sure that the following
6645 ;; dynamic binding isn't shadowed by autoloading.
6646 (require 'gnus-async)
6647 (let ((gnus-select-article-hook nil) ;Disable hook.
6648 (gnus-article-display-hook nil)
6649 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6650 (gnus-use-article-prefetch nil)
6651 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6652 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6653 (sum (current-buffer))
6655 point gnus-display-mime-function)
6656 (gnus-save-hidden-threads
6657 (gnus-summary-select-article)
6658 (set-buffer gnus-article-buffer)
6662 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6664 (re-search-backward regexp nil t)
6665 (re-search-forward regexp nil t))
6666 ;; We found the regexp.
6671 (get-buffer-window (current-buffer))
6675 (setq point (point)))
6676 ;; We didn't find it, so we go to the next article.
6679 (while (eq found 'not)
6680 (if (not (if backward (gnus-summary-find-prev)
6681 (gnus-summary-find-next)))
6682 ;; No more articles.
6684 ;; Select the next article and adjust point.
6685 (unless (gnus-summary-article-sparse-p
6686 (gnus-summary-article-number))
6688 (gnus-summary-select-article)
6689 (set-buffer gnus-article-buffer)
6691 (goto-char (if backward (point-max) (point-min))))))))
6692 (gnus-message 7 ""))
6693 ;; Return whether we found the regexp.
6694 (when (eq found 'found)
6696 (gnus-summary-show-thread)
6697 (gnus-summary-goto-subject gnus-current-article)
6698 (gnus-summary-position-point)
6701 (defun gnus-summary-find-matching (header regexp &optional backward unread
6703 "Return a list of all articles that match REGEXP on HEADER.
6704 The search stars on the current article and goes forwards unless
6705 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6706 If UNREAD is non-nil, only unread articles will
6707 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6708 in the comparisons."
6709 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6710 (gnus-data-find-list
6711 (gnus-summary-article-number) (gnus-data-list backward))))
6712 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6713 (case-fold-search (not not-case-fold))
6715 (unless (fboundp (intern (concat "mail-header-" header)))
6716 (error "%s is not a valid header" header))
6719 (and (or (not unread) ; We want all articles...
6720 (gnus-data-unread-p d)) ; Or just unreads.
6721 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6722 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6723 (push (gnus-data-number d) articles)) ; Success!
6724 (setq data (cdr data)))
6725 (nreverse articles)))
6727 (defun gnus-summary-execute-command (header regexp command &optional backward)
6728 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6729 If HEADER is an empty string (or nil), the match is done on the entire
6730 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6732 (list (let ((completion-ignore-case t))
6735 (mapcar (lambda (string) (list string))
6736 '("Number" "Subject" "From" "Lines" "Date"
6737 "Message-ID" "Xref" "References" "Body"))
6738 nil 'require-match))
6739 (read-string "Regexp: ")
6740 (read-key-sequence "Command: ")
6741 current-prefix-arg))
6742 (when (equal header "Body")
6744 ;; Hidden thread subtrees must be searched as well.
6745 (gnus-summary-show-all-threads)
6746 ;; We don't want to change current point nor window configuration.
6748 (save-window-excursion
6749 (gnus-message 6 "Executing %s..." (key-description command))
6750 ;; We'd like to execute COMMAND interactively so as to give arguments.
6751 (gnus-execute header regexp
6752 `(call-interactively ',(key-binding command))
6754 (gnus-message 6 "Executing %s...done" (key-description command)))))
6756 (defun gnus-summary-beginning-of-article ()
6757 "Scroll the article back to the beginning."
6759 (gnus-summary-select-article)
6760 (gnus-configure-windows 'article)
6761 (gnus-eval-in-buffer-window gnus-article-buffer
6763 (goto-char (point-min))
6764 (when gnus-page-broken
6765 (gnus-narrow-to-page))))
6767 (defun gnus-summary-end-of-article ()
6768 "Scroll to the end of the article."
6770 (gnus-summary-select-article)
6771 (gnus-configure-windows 'article)
6772 (gnus-eval-in-buffer-window gnus-article-buffer
6774 (goto-char (point-max))
6776 (when gnus-page-broken
6777 (gnus-narrow-to-page))))
6779 (defun gnus-summary-print-article (&optional filename n)
6780 "Generate and print a PostScript image of the N next (mail) articles.
6782 If N is negative, print the N previous articles. If N is nil and articles
6783 have been marked with the process mark, print these instead.
6785 If the optional second argument FILENAME is nil, send the image to the
6786 printer. If FILENAME is a string, save the PostScript image in a file with
6787 that name. If FILENAME is a number, prompt the user for the name of the file
6789 (interactive (list (ps-print-preprint current-prefix-arg)
6790 current-prefix-arg))
6791 (dolist (article (gnus-summary-work-articles n))
6792 (gnus-summary-select-article nil nil 'pseudo article)
6793 (gnus-eval-in-buffer-window gnus-article-buffer
6794 (let ((buffer (generate-new-buffer " *print*")))
6797 (copy-to-buffer buffer (point-min) (point-max))
6799 (gnus-article-delete-invisible-text)
6800 (let ((ps-left-header
6803 (mail-header-subject gnus-current-headers) ")")
6805 (mail-header-from gnus-current-headers) ")")))
6808 "/pagenumberstring load"
6810 (mail-header-date gnus-current-headers) ")"))))
6811 (gnus-run-hooks 'gnus-ps-print-hook)
6813 (ps-print-buffer-with-faces filename))))
6814 (kill-buffer buffer))))))
6816 (defun gnus-summary-show-article (&optional arg)
6817 "Force re-fetching of the current article.
6818 If ARG (the prefix) is non-nil, show the raw article without any
6819 article massaging functions being run."
6822 ;; Select the article the normal way.
6823 (gnus-summary-select-article nil 'force)
6824 ;; Bind the article treatment functions to nil.
6825 (let ((gnus-have-all-headers t)
6826 gnus-article-display-hook
6827 gnus-article-prepare-hook
6828 gnus-article-decode-hook
6829 gnus-display-mime-function
6832 (gnus-summary-select-article nil 'force)))
6833 (gnus-summary-goto-subject gnus-current-article)
6834 (gnus-summary-position-point))
6836 (defun gnus-summary-verbose-headers (&optional arg)
6837 "Toggle permanent full header display.
6838 If ARG is a positive number, turn header display on.
6839 If ARG is a negative number, turn header display off."
6841 (setq gnus-show-all-headers
6842 (cond ((or (not (numberp arg))
6844 (not gnus-show-all-headers))
6847 (gnus-summary-show-article))
6849 (defun gnus-summary-toggle-header (&optional arg)
6850 "Show the headers if they are hidden, or hide them if they are shown.
6851 If ARG is a positive number, show the entire header.
6852 If ARG is a negative number, hide the unwanted header lines."
6855 (set-buffer gnus-article-buffer)
6856 (let* ((buffer-read-only nil)
6857 (inhibit-point-motion-hooks t)
6858 (hidden (text-property-any
6859 (goto-char (point-min)) (search-forward "\n\n")
6862 (goto-char (point-min))
6863 (when (search-forward "\n\n" nil t)
6864 (delete-region (point-min) (1- (point))))
6865 (goto-char (point-min))
6867 (set-buffer gnus-original-article-buffer)
6868 (goto-char (point-min))
6869 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6870 (insert-buffer-substring gnus-original-article-buffer 1 e)
6871 (let ((article-inhibit-hiding t))
6872 (gnus-run-hooks 'gnus-article-display-hook))
6873 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6874 (gnus-article-hide-headers)))))
6876 (defun gnus-summary-show-all-headers ()
6877 "Make all header lines visible."
6879 (gnus-article-show-all-headers))
6881 (defun gnus-summary-caesar-message (&optional arg)
6882 "Caesar rotate the current article by 13.
6883 The numerical prefix specifies how many places to rotate each letter
6886 (gnus-summary-select-article)
6887 (let ((mail-header-separator ""))
6888 (gnus-eval-in-buffer-window gnus-article-buffer
6891 (let ((start (window-start))
6893 (message-caesar-buffer-body arg)
6894 (set-window-start (get-buffer-window (current-buffer)) start))))))
6896 (defun gnus-summary-stop-page-breaking ()
6897 "Stop page breaking in the current article."
6899 (gnus-summary-select-article)
6900 (gnus-eval-in-buffer-window gnus-article-buffer
6902 (when (gnus-visual-p 'page-marker)
6903 (let ((buffer-read-only nil))
6904 (gnus-remove-text-with-property 'gnus-prev)
6905 (gnus-remove-text-with-property 'gnus-next))
6906 (setq gnus-page-broken nil))))
6908 (defun gnus-summary-move-article (&optional n to-newsgroup
6909 select-method action)
6910 "Move the current article to a different newsgroup.
6911 If N is a positive number, move the N next articles.
6912 If N is a negative number, move the N previous articles.
6913 If N is nil and any articles have been marked with the process mark,
6914 move those articles instead.
6915 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6916 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6917 re-spool using this method.
6919 For this function to work, both the current newsgroup and the
6920 newsgroup that you want to move to have to support the `request-move'
6921 and `request-accept' functions."
6924 (setq action 'move))
6925 ;; Disable marking as read.
6926 (let (gnus-mark-article-hook)
6927 (save-window-excursion
6928 (gnus-summary-select-article)))
6929 ;; Check whether the source group supports the required functions.
6930 (cond ((and (eq action 'move)
6931 (not (gnus-check-backend-function
6932 'request-move-article gnus-newsgroup-name)))
6933 (error "The current group does not support article moving"))
6934 ((and (eq action 'crosspost)
6935 (not (gnus-check-backend-function
6936 'request-replace-article gnus-newsgroup-name)))
6937 (error "The current group does not support article editing")))
6938 (let ((articles (gnus-summary-work-articles n))
6939 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6940 (names '((move "Move" "Moving")
6941 (copy "Copy" "Copying")
6942 (crosspost "Crosspost" "Crossposting")))
6943 (copy-buf (save-excursion
6944 (nnheader-set-temp-buffer " *copy article*")))
6945 art-group to-method new-xref article to-groups)
6946 (unless (assq action names)
6947 (error "Unknown action %s" action))
6948 ;; Read the newsgroup name.
6949 (when (and (not to-newsgroup)
6950 (not select-method))
6952 (gnus-read-move-group-name
6953 (cadr (assq action names))
6954 (symbol-value (intern (format "gnus-current-%s-group" action)))
6956 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6957 (setq to-method (or select-method
6958 (gnus-group-name-to-method to-newsgroup)))
6959 ;; Check the method we are to move this article to...
6960 (unless (gnus-check-backend-function
6961 'request-accept-article (car to-method))
6962 (error "%s does not support article copying" (car to-method)))
6963 (unless (gnus-check-server to-method)
6964 (error "Can't open server %s" (car to-method)))
6965 (gnus-message 6 "%s to %s: %s..."
6966 (caddr (assq action names))
6967 (or (car select-method) to-newsgroup) articles)
6969 (setq article (pop articles))
6973 ;; Move the article.
6975 ;; Remove this article from future suppression.
6976 (gnus-dup-unsuppress-article article)
6977 (gnus-request-move-article
6978 article ; Article to move
6979 gnus-newsgroup-name ; From newsgroup
6980 (nth 1 (gnus-find-method-for-group
6981 gnus-newsgroup-name)) ; Server
6982 (list 'gnus-request-accept-article
6983 to-newsgroup (list 'quote select-method)
6984 (not articles)) ; Accept form
6985 (not articles))) ; Only save nov last time
6986 ;; Copy the article.
6989 (set-buffer copy-buf)
6990 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6991 (gnus-request-accept-article
6992 to-newsgroup select-method (not articles) t))))
6993 ;; Crosspost the article.
6994 ((eq action 'crosspost)
6995 (let ((xref (message-tokenize-header
6996 (mail-header-xref (gnus-summary-article-header article))
6998 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7001 (setq xref (list (system-name))))
7004 (mapconcat 'identity
7005 (delete "Xref:" (delete new-xref xref))
7009 (set-buffer copy-buf)
7010 ;; First put the article in the destination group.
7011 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7012 (when (consp (setq art-group
7013 (gnus-request-accept-article
7014 to-newsgroup select-method (not articles))))
7015 (setq new-xref (concat new-xref " " (car art-group)
7016 ":" (cdr art-group)))
7017 ;; Now we have the new Xrefs header, so we insert
7018 ;; it and replace the new article.
7019 (nnheader-replace-header "Xref" new-xref)
7020 (gnus-request-replace-article
7021 (cdr art-group) to-newsgroup (current-buffer))
7025 (gnus-message 1 "Couldn't %s article %s"
7026 (cadr (assq action names)) article))
7027 ((and (eq art-group 'junk)
7029 (gnus-summary-mark-article article gnus-canceled-mark)
7030 (gnus-message 4 "Deleted article %s" article))
7032 (let* ((pto-group (gnus-group-prefixed-name
7033 (car art-group) to-method))
7035 (gnus-gethash pto-group gnus-newsrc-hashtb))
7036 (info (nth 2 entry))
7037 (to-group (gnus-info-group info)))
7038 ;; Update the group that has been moved to.
7040 (memq action '(move copy)))
7041 (unless (member to-group to-groups)
7042 (push to-group to-groups))
7044 (unless (memq article gnus-newsgroup-unreads)
7046 info (gnus-add-to-range (gnus-info-read info)
7047 (list (cdr art-group)))))
7049 ;; Copy any marks over to the new group.
7050 (let ((marks gnus-article-mark-lists)
7051 (to-article (cdr art-group)))
7053 ;; See whether the article is to be put in the cache.
7054 (when gnus-use-cache
7055 (gnus-cache-possibly-enter-article
7057 (let ((header (copy-sequence
7058 (gnus-summary-article-header article))))
7059 (mail-header-set-number header to-article)
7061 (memq article gnus-newsgroup-marked)
7062 (memq article gnus-newsgroup-dormant)
7063 (memq article gnus-newsgroup-unreads)))
7065 (when (and (equal to-group gnus-newsgroup-name)
7066 (not (memq article gnus-newsgroup-unreads)))
7067 ;; Mark this article as read in this group.
7068 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7069 (setcdr (gnus-active to-group) to-article)
7070 (setcdr gnus-newsgroup-active to-article))
7073 (when (memq article (symbol-value
7074 (intern (format "gnus-newsgroup-%s"
7076 ;; If the other group is the same as this group,
7077 ;; then we have to add the mark to the list.
7078 (when (equal to-group gnus-newsgroup-name)
7079 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7082 (intern (format "gnus-newsgroup-%s"
7084 ;; Copy the marks to other group.
7085 (gnus-add-marked-articles
7086 to-group (cdar marks) (list to-article) info))
7087 (setq marks (cdr marks)))
7090 (concat "(gnus-group-set-info '"
7091 (gnus-prin1-to-string (gnus-get-info to-group))
7094 ;; Update the Xref header in this article to point to
7095 ;; the new crossposted article we have just created.
7096 (when (eq action 'crosspost)
7098 (set-buffer copy-buf)
7099 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7100 (nnheader-replace-header "Xref" new-xref)
7101 (gnus-request-replace-article
7102 article gnus-newsgroup-name (current-buffer)))))
7104 ;;;!!!Why is this necessary?
7105 (set-buffer gnus-summary-buffer)
7107 (gnus-summary-goto-subject article)
7108 (when (eq action 'move)
7109 (gnus-summary-mark-article article gnus-canceled-mark))))
7110 (gnus-summary-remove-process-mark article))
7111 ;; Re-activate all groups that have been moved to.
7114 (set-buffer gnus-group-buffer)
7115 (when (gnus-group-goto-group (car to-groups) t)
7116 (gnus-group-get-new-news-this-group 1 t))
7119 (gnus-kill-buffer copy-buf)
7120 (gnus-summary-position-point)
7121 (gnus-set-mode-line 'summary)))
7123 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7124 "Move the current article to a different newsgroup.
7125 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7126 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7127 re-spool using this method."
7129 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7131 (defun gnus-summary-crosspost-article (&optional n)
7132 "Crosspost the current article to some other group."
7134 (gnus-summary-move-article n nil nil 'crosspost))
7136 (defcustom gnus-summary-respool-default-method nil
7137 "Default method for respooling an article.
7138 If nil, use to the current newsgroup method."
7139 :type '(choice (gnus-select-method :value (nnml ""))
7141 :group 'gnus-summary-mail)
7143 (defun gnus-summary-respool-article (&optional n method)
7144 "Respool the current article.
7145 The article will be squeezed through the mail spooling process again,
7146 which means that it will be put in some mail newsgroup or other
7147 depending on `nnmail-split-methods'.
7148 If N is a positive number, respool the N next articles.
7149 If N is a negative number, respool the N previous articles.
7150 If N is nil and any articles have been marked with the process mark,
7151 respool those articles instead.
7153 Respooling can be done both from mail groups and \"real\" newsgroups.
7154 In the former case, the articles in question will be moved from the
7155 current group into whatever groups they are destined to. In the
7156 latter case, they will be copied into the relevant groups."
7158 (list current-prefix-arg
7159 (let* ((methods (gnus-methods-using 'respool))
7161 (symbol-name (or gnus-summary-respool-default-method
7162 (car (gnus-find-method-for-group
7163 gnus-newsgroup-name)))))
7165 (gnus-completing-read
7166 methname "What backend do you want to use when respooling?"
7167 methods nil t nil 'gnus-mail-method-history))
7170 ((zerop (length (setq ms (gnus-servers-using-backend
7172 (list (intern method) ""))
7176 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7177 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7180 (error "No method given for respooling"))
7181 (if (assoc (symbol-name
7182 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7183 (gnus-methods-using 'respool))
7184 (gnus-summary-move-article n nil method)
7185 (gnus-summary-copy-article n nil method)))
7187 (defun gnus-summary-import-article (file)
7188 "Import an arbitrary file into a mail newsgroup."
7189 (interactive "fImport file: ")
7190 (let ((group gnus-newsgroup-name)
7191 (now (current-time))
7193 (unless (gnus-check-backend-function 'request-accept-article group)
7194 (error "%s does not support article importing" group))
7195 (or (file-readable-p file)
7196 (not (file-regular-p file))
7197 (error "Can't read %s" file))
7199 (set-buffer (gnus-get-buffer-create " *import file*"))
7201 (insert-file-contents file)
7202 (goto-char (point-min))
7203 (unless (nnheader-article-p)
7204 ;; This doesn't look like an article, so we fudge some headers.
7205 (setq atts (file-attributes file)
7206 lines (count-lines (point-min) (point-max)))
7207 (insert "From: " (read-string "From: ") "\n"
7208 "Subject: " (read-string "Subject: ") "\n"
7209 "Date: " (message-make-date (nth 5 atts))
7211 "Message-ID: " (message-make-message-id) "\n"
7212 "Lines: " (int-to-string lines) "\n"
7213 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7214 (gnus-request-accept-article group nil t)
7215 (kill-buffer (current-buffer)))))
7217 (defun gnus-summary-article-posted-p ()
7218 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7219 This will be the case if the article has both been mailed and posted."
7221 (let ((id (mail-header-references (gnus-summary-article-header)))
7222 (gnus-override-method
7223 (or gnus-refer-article-method gnus-select-method)))
7224 (if (gnus-request-head id "")
7225 (gnus-message 2 "The current message was found on %s"
7226 gnus-override-method)
7227 (gnus-message 2 "The current message couldn't be found on %s"
7228 gnus-override-method)
7231 (defun gnus-summary-expire-articles (&optional now)
7232 "Expire all articles that are marked as expirable in the current group."
7234 (when (gnus-check-backend-function
7235 'request-expire-articles gnus-newsgroup-name)
7236 ;; This backend supports expiry.
7237 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7238 (expirable (if total
7240 ;; We need to update the info for
7241 ;; this group for `gnus-list-of-read-articles'
7242 ;; to give us the right answer.
7243 (gnus-run-hooks 'gnus-exit-group-hook)
7244 (gnus-summary-update-info)
7245 (gnus-list-of-read-articles gnus-newsgroup-name))
7246 (setq gnus-newsgroup-expirable
7247 (sort gnus-newsgroup-expirable '<))))
7248 (expiry-wait (if now 'immediate
7249 (gnus-group-find-parameter
7250 gnus-newsgroup-name 'expiry-wait)))
7253 ;; There are expirable articles in this group, so we run them
7254 ;; through the expiry process.
7255 (gnus-message 6 "Expiring articles...")
7256 ;; The list of articles that weren't expired is returned.
7259 (let ((nnmail-expiry-wait-function nil)
7260 (nnmail-expiry-wait expiry-wait))
7261 (setq es (gnus-request-expire-articles
7262 expirable gnus-newsgroup-name)))
7263 (setq es (gnus-request-expire-articles
7264 expirable gnus-newsgroup-name))))
7266 (setq gnus-newsgroup-expirable es))
7267 ;; We go through the old list of expirable, and mark all
7268 ;; really expired articles as nonexistent.
7269 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7270 (let ((gnus-use-cache nil))
7272 (unless (memq (car expirable) es)
7273 (when (gnus-data-find (car expirable))
7274 (gnus-summary-mark-article
7275 (car expirable) gnus-canceled-mark)))
7276 (setq expirable (cdr expirable)))))
7277 (gnus-message 6 "Expiring articles...done")))))
7279 (defun gnus-summary-expire-articles-now ()
7280 "Expunge all expirable articles in the current group.
7281 This means that *all* articles that are marked as expirable will be
7282 deleted forever, right now."
7284 (or gnus-expert-user
7286 "Are you really, really, really sure you want to delete all these messages? ")
7288 (gnus-summary-expire-articles t))
7290 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7291 (defun gnus-summary-delete-article (&optional n)
7292 "Delete the N next (mail) articles.
7293 This command actually deletes articles. This is not a marking
7294 command. The article will disappear forever from your life, never to
7296 If N is negative, delete backwards.
7297 If N is nil and articles have been marked with the process mark,
7298 delete these instead."
7300 (unless (gnus-check-backend-function 'request-expire-articles
7301 gnus-newsgroup-name)
7302 (error "The current newsgroup does not support article deletion"))
7303 ;; Compute the list of articles to delete.
7304 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7306 (if (and gnus-novice-user
7307 (not (gnus-yes-or-no-p
7308 (format "Do you really want to delete %s forever? "
7309 (if (> (length articles) 1)
7310 (format "these %s articles" (length articles))
7313 ;; Delete the articles.
7314 (setq not-deleted (gnus-request-expire-articles
7315 articles gnus-newsgroup-name 'force))
7317 (gnus-summary-remove-process-mark (car articles))
7318 ;; The backend might not have been able to delete the article
7320 (unless (memq (car articles) not-deleted)
7321 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7322 (setq articles (cdr articles)))
7324 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7325 (gnus-summary-position-point)
7326 (gnus-set-mode-line 'summary)
7329 (defun gnus-summary-edit-article (&optional force)
7330 "Edit the current article.
7331 This will have permanent effect only in mail groups.
7332 If FORCE is non-nil, allow editing of articles even in read-only
7336 (set-buffer gnus-summary-buffer)
7337 (gnus-set-global-variables)
7338 (when (and (not force)
7339 (gnus-group-read-only-p))
7340 (error "The current newsgroup does not support article editing"))
7341 ;; Select article if needed.
7342 (unless (eq (gnus-summary-article-number)
7343 gnus-current-article)
7344 (gnus-summary-select-article t))
7345 (gnus-article-date-original)
7346 (gnus-article-edit-article
7347 `(lambda (no-highlight)
7348 (gnus-summary-edit-article-done
7349 ,(or (mail-header-references gnus-current-headers) "")
7350 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7352 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7354 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7356 "Make edits to the current article permanent."
7358 ;; Replace the article.
7359 (let ((buf (current-buffer)))
7362 (if (and (not read-only)
7363 (not (gnus-request-replace-article
7364 (cdr gnus-article-current) (car gnus-article-current)
7366 (not gnus-article-decoded-p))))
7367 (error "Couldn't replace article")
7368 ;; Update the summary buffer.
7370 (equal (message-tokenize-header references " ")
7371 (message-tokenize-header
7372 (or (message-fetch-field "references") "") " ")))
7373 ;; We only have to update this line.
7376 (message-narrow-to-head)
7377 (let ((head (buffer-string))
7380 (insert (format "211 %d Article retrieved.\n"
7381 (cdr gnus-article-current)))
7384 (let ((nntp-server-buffer (current-buffer)))
7385 (setq header (car (gnus-get-newsgroup-headers
7387 (set-buffer gnus-summary-buffer)
7388 gnus-newsgroup-dependencies)
7391 (set-buffer gnus-summary-buffer)
7392 (gnus-data-set-header
7393 (gnus-data-find (cdr gnus-article-current))
7395 (gnus-summary-update-article-line
7396 (cdr gnus-article-current) header))))))
7398 (set-buffer (or buffer gnus-summary-buffer))
7399 (gnus-summary-update-article (cdr gnus-article-current)))
7400 ;; Prettify the article buffer again.
7401 (unless no-highlight
7403 (set-buffer gnus-article-buffer)
7404 (gnus-run-hooks 'gnus-article-display-hook)
7405 (set-buffer gnus-original-article-buffer)
7406 (gnus-request-article
7407 (cdr gnus-article-current)
7408 (car gnus-article-current) (current-buffer))))
7409 ;; Prettify the summary buffer line.
7410 (when (gnus-visual-p 'summary-highlight 'highlight)
7411 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7413 (defun gnus-summary-edit-wash (key)
7414 "Perform editing command KEY in the article buffer."
7418 (message "%s" (concat (this-command-keys) "- "))
7421 (gnus-summary-edit-article)
7422 (execute-kbd-macro (concat (this-command-keys) key))
7423 (gnus-article-edit-done))
7427 (defun gnus-summary-respool-query (&optional silent trace)
7428 "Query where the respool algorithm would put this article."
7430 (let (gnus-mark-article-hook)
7431 (gnus-summary-select-article)
7433 (set-buffer gnus-original-article-buffer)
7435 (message-narrow-to-head)
7436 (let ((groups (nnmail-article-group 'identity trace)))
7439 (message "This message would go to %s"
7440 (mapconcat 'car groups ", "))
7441 (message "This message would go to no groups"))
7444 (defun gnus-summary-respool-trace ()
7445 "Trace where the respool algorithm would put this article.
7446 Display a buffer showing all fancy splitting patterns which matched."
7448 (gnus-summary-respool-query nil t))
7450 ;; Summary marking commands.
7452 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7453 "Mark articles which has the same subject as read, and then select the next.
7454 If UNMARK is positive, remove any kind of mark.
7455 If UNMARK is negative, tick articles."
7458 (setq unmark (prefix-numeric-value unmark)))
7460 (gnus-summary-mark-same-subject
7461 (gnus-summary-article-subject) unmark)))
7462 ;; Select next unread article. If auto-select-same mode, should
7463 ;; select the first unread article.
7464 (gnus-summary-next-article t (and gnus-auto-select-same
7465 (gnus-summary-article-subject)))
7466 (gnus-message 7 "%d article%s marked as %s"
7467 count (if (= count 1) " is" "s are")
7468 (if unmark "unread" "read"))))
7470 (defun gnus-summary-kill-same-subject (&optional unmark)
7471 "Mark articles which has the same subject as read.
7472 If UNMARK is positive, remove any kind of mark.
7473 If UNMARK is negative, tick articles."
7476 (setq unmark (prefix-numeric-value unmark)))
7478 (gnus-summary-mark-same-subject
7479 (gnus-summary-article-subject) unmark)))
7480 ;; If marked as read, go to next unread subject.
7482 ;; Go to next unread subject.
7483 (gnus-summary-next-subject 1 t))
7484 (gnus-message 7 "%d articles are marked as %s"
7485 count (if unmark "unread" "read"))))
7487 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7488 "Mark articles with same SUBJECT as read, and return marked number.
7489 If optional argument UNMARK is positive, remove any kinds of marks.
7490 If optional argument UNMARK is negative, mark articles as unread instead."
7494 ((null unmark) ; Mark as read.
7497 (gnus-summary-mark-article-as-read gnus-killed-mark)
7498 (gnus-summary-show-thread) t)
7499 (gnus-summary-find-subject subject))
7500 (setq count (1+ count))))
7501 ((> unmark 0) ; Tick.
7504 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7505 (gnus-summary-show-thread) t)
7506 (gnus-summary-find-subject subject))
7507 (setq count (1+ count))))
7508 (t ; Mark as unread.
7511 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7512 (gnus-summary-show-thread) t)
7513 (gnus-summary-find-subject subject))
7514 (setq count (1+ count)))))
7515 (gnus-set-mode-line 'summary)
7516 ;; Return the number of marked articles.
7519 (defun gnus-summary-mark-as-processable (n &optional unmark)
7520 "Set the process mark on the next N articles.
7521 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7522 the process mark instead. The difference between N and the actual
7523 number of articles marked is returned."
7525 (let ((backward (< n 0))
7530 (gnus-summary-remove-process-mark
7531 (gnus-summary-article-number))
7532 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7533 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7536 (gnus-message 7 "No more articles"))
7537 (gnus-summary-recenter)
7538 (gnus-summary-position-point)
7541 (defun gnus-summary-unmark-as-processable (n)
7542 "Remove the process mark from the next N articles.
7543 If N is negative, unmark backward instead. The difference between N and
7544 the actual number of articles unmarked is returned."
7546 (gnus-summary-mark-as-processable n t))
7548 (defun gnus-summary-unmark-all-processable ()
7549 "Remove the process mark from all articles."
7552 (while gnus-newsgroup-processable
7553 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7554 (gnus-summary-position-point))
7556 (defun gnus-summary-mark-as-expirable (n)
7557 "Mark N articles forward as expirable.
7558 If N is negative, mark backward instead. The difference between N and
7559 the actual number of articles marked is returned."
7561 (gnus-summary-mark-forward n gnus-expirable-mark))
7563 (defun gnus-summary-mark-article-as-replied (article)
7564 "Mark ARTICLE replied and update the summary line."
7565 (push article gnus-newsgroup-replied)
7566 (let ((buffer-read-only nil))
7567 (when (gnus-summary-goto-subject article nil t)
7568 (gnus-summary-update-secondary-mark article))))
7570 (defun gnus-summary-set-bookmark (article)
7571 "Set a bookmark in current article."
7572 (interactive (list (gnus-summary-article-number)))
7573 (when (or (not (get-buffer gnus-article-buffer))
7574 (not gnus-current-article)
7575 (not gnus-article-current)
7576 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7577 (error "No current article selected"))
7578 ;; Remove old bookmark, if one exists.
7579 (let ((old (assq article gnus-newsgroup-bookmarks)))
7581 (setq gnus-newsgroup-bookmarks
7582 (delq old gnus-newsgroup-bookmarks))))
7583 ;; Set the new bookmark, which is on the form
7584 ;; (article-number . line-number-in-body).
7588 (set-buffer gnus-article-buffer)
7592 (goto-char (point-min))
7593 (search-forward "\n\n" nil t)
7596 gnus-newsgroup-bookmarks)
7597 (gnus-message 6 "A bookmark has been added to the current article."))
7599 (defun gnus-summary-remove-bookmark (article)
7600 "Remove the bookmark from the current article."
7601 (interactive (list (gnus-summary-article-number)))
7602 ;; Remove old bookmark, if one exists.
7603 (let ((old (assq article gnus-newsgroup-bookmarks)))
7606 (setq gnus-newsgroup-bookmarks
7607 (delq old gnus-newsgroup-bookmarks))
7608 (gnus-message 6 "Removed bookmark."))
7609 (gnus-message 6 "No bookmark in current article."))))
7611 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7612 (defun gnus-summary-mark-as-dormant (n)
7613 "Mark N articles forward as dormant.
7614 If N is negative, mark backward instead. The difference between N and
7615 the actual number of articles marked is returned."
7617 (gnus-summary-mark-forward n gnus-dormant-mark))
7619 (defun gnus-summary-set-process-mark (article)
7620 "Set the process mark on ARTICLE and update the summary line."
7621 (setq gnus-newsgroup-processable
7623 (delq article gnus-newsgroup-processable)))
7624 (when (gnus-summary-goto-subject article)
7625 (gnus-summary-show-thread)
7626 (gnus-summary-goto-subject article)
7627 (gnus-summary-update-secondary-mark article)))
7629 (defun gnus-summary-remove-process-mark (article)
7630 "Remove the process mark from ARTICLE and update the summary line."
7631 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7632 (when (gnus-summary-goto-subject article)
7633 (gnus-summary-show-thread)
7634 (gnus-summary-goto-subject article)
7635 (gnus-summary-update-secondary-mark article)))
7637 (defun gnus-summary-set-saved-mark (article)
7638 "Set the process mark on ARTICLE and update the summary line."
7639 (push article gnus-newsgroup-saved)
7640 (when (gnus-summary-goto-subject article)
7641 (gnus-summary-update-secondary-mark article)))
7643 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7644 "Mark N articles as read forwards.
7645 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7646 The difference between N and the actual number of articles marked is
7649 (let ((backward (< n 0))
7650 (gnus-summary-goto-unread
7651 (and gnus-summary-goto-unread
7652 (not (eq gnus-summary-goto-unread 'never))
7653 (not (memq mark (list gnus-unread-mark
7654 gnus-ticked-mark gnus-dormant-mark)))))
7656 (mark (or mark gnus-del-mark)))
7658 (gnus-summary-mark-article nil mark no-expire)
7659 (zerop (gnus-summary-next-subject
7661 (and gnus-summary-goto-unread
7662 (not (eq gnus-summary-goto-unread 'never)))
7666 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7667 (gnus-summary-recenter)
7668 (gnus-summary-position-point)
7669 (gnus-set-mode-line 'summary)
7672 (defun gnus-summary-mark-article-as-read (mark)
7673 "Mark the current article quickly as read with MARK."
7674 (let ((article (gnus-summary-article-number)))
7675 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7676 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7677 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7678 (push (cons article mark) gnus-newsgroup-reads)
7679 ;; Possibly remove from cache, if that is used.
7680 (when gnus-use-cache
7681 (gnus-cache-enter-remove-article article))
7682 ;; Allow the backend to change the mark.
7683 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7684 ;; Check for auto-expiry.
7685 (when (and gnus-newsgroup-auto-expire
7686 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7687 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7688 (= mark gnus-ancient-mark)
7689 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7690 (= mark gnus-duplicate-mark)))
7691 (setq mark gnus-expirable-mark)
7692 ;; Let the backend know about the mark change.
7693 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7694 (push article gnus-newsgroup-expirable))
7695 ;; Set the mark in the buffer.
7696 (gnus-summary-update-mark mark 'unread)
7699 (defun gnus-summary-mark-article-as-unread (mark)
7700 "Mark the current article quickly as unread with MARK."
7701 (let* ((article (gnus-summary-article-number))
7702 (old-mark (gnus-summary-article-mark article)))
7703 ;; Allow the backend to change the mark.
7704 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7705 (if (eq mark old-mark)
7709 (gnus-error 1 "Can't mark negative article numbers")
7711 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7712 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7713 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7714 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7715 (cond ((= mark gnus-ticked-mark)
7716 (push article gnus-newsgroup-marked))
7717 ((= mark gnus-dormant-mark)
7718 (push article gnus-newsgroup-dormant))
7720 (push article gnus-newsgroup-unreads)))
7721 (gnus-pull article gnus-newsgroup-reads)
7723 ;; See whether the article is to be put in the cache.
7725 (vectorp (gnus-summary-article-header article))
7727 (gnus-cache-possibly-enter-article
7728 gnus-newsgroup-name article
7729 (gnus-summary-article-header article)
7730 (= mark gnus-ticked-mark)
7731 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7734 (gnus-summary-update-mark mark 'unread)
7737 (defun gnus-summary-mark-article (&optional article mark no-expire)
7738 "Mark ARTICLE with MARK. MARK can be any character.
7739 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7740 `??' (dormant) and `?E' (expirable).
7741 If MARK is nil, then the default character `?D' is used.
7742 If ARTICLE is nil, then the article on the current line will be
7744 ;; The mark might be a string.
7745 (when (stringp mark)
7746 (setq mark (aref mark 0)))
7747 ;; If no mark is given, then we check auto-expiring.
7748 (and (not no-expire)
7749 gnus-newsgroup-auto-expire
7751 (and (gnus-characterp mark)
7752 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7753 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7754 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7755 (= mark gnus-duplicate-mark))))
7756 (setq mark gnus-expirable-mark))
7757 (let* ((mark (or mark gnus-del-mark))
7758 (article (or article (gnus-summary-article-number)))
7759 (old-mark (gnus-summary-article-mark article)))
7760 ;; Allow the backend to change the mark.
7761 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7762 (if (eq mark old-mark)
7765 (error "No article on current line"))
7766 (if (not (if (or (= mark gnus-unread-mark)
7767 (= mark gnus-ticked-mark)
7768 (= mark gnus-dormant-mark))
7769 (gnus-mark-article-as-unread article mark)
7770 (gnus-mark-article-as-read article mark)))
7772 ;; See whether the article is to be put in the cache.
7774 (not (= mark gnus-canceled-mark))
7775 (vectorp (gnus-summary-article-header article))
7777 (gnus-cache-possibly-enter-article
7778 gnus-newsgroup-name article
7779 (gnus-summary-article-header article)
7780 (= mark gnus-ticked-mark)
7781 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7783 (when (gnus-summary-goto-subject article nil t)
7784 (let ((buffer-read-only nil))
7785 (gnus-summary-show-thread)
7787 (gnus-summary-update-mark mark 'unread)
7790 (defun gnus-summary-update-secondary-mark (article)
7791 "Update the secondary (read, process, cache) mark."
7792 (gnus-summary-update-mark
7793 (cond ((memq article gnus-newsgroup-processable)
7795 ((memq article gnus-newsgroup-cached)
7797 ((memq article gnus-newsgroup-replied)
7799 ((memq article gnus-newsgroup-saved)
7801 (t gnus-unread-mark))
7803 (when (gnus-visual-p 'summary-highlight 'highlight)
7804 (gnus-run-hooks 'gnus-summary-update-hook))
7807 (defun gnus-summary-update-mark (mark type)
7808 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7809 (buffer-read-only nil))
7810 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7811 (when (looking-at "\r")
7814 (<= (+ forward (point)) (point-max)))
7815 ;; Go to the right position on the line.
7816 (goto-char (+ forward (point)))
7817 ;; Replace the old mark with the new mark.
7818 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
7819 ;; Optionally update the marks by some user rule.
7820 (when (eq type 'unread)
7822 (gnus-data-find (gnus-summary-article-number)) mark)
7823 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7825 (defun gnus-mark-article-as-read (article &optional mark)
7826 "Enter ARTICLE in the pertinent lists and remove it from others."
7827 ;; Make the article expirable.
7828 (let ((mark (or mark gnus-del-mark)))
7829 (if (= mark gnus-expirable-mark)
7830 (push article gnus-newsgroup-expirable)
7831 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7832 ;; Remove from unread and marked lists.
7833 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7834 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7835 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7836 (push (cons article mark) gnus-newsgroup-reads)
7837 ;; Possibly remove from cache, if that is used.
7838 (when gnus-use-cache
7839 (gnus-cache-enter-remove-article article))
7842 (defun gnus-mark-article-as-unread (article &optional mark)
7843 "Enter ARTICLE in the pertinent lists and remove it from others."
7844 (let ((mark (or mark gnus-ticked-mark)))
7847 (gnus-error 1 "Can't mark negative article numbers")
7849 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7850 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7851 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7852 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7854 ;; Unsuppress duplicates?
7855 (when gnus-suppress-duplicates
7856 (gnus-dup-unsuppress-article article))
7858 (cond ((= mark gnus-ticked-mark)
7859 (push article gnus-newsgroup-marked))
7860 ((= mark gnus-dormant-mark)
7861 (push article gnus-newsgroup-dormant))
7863 (push article gnus-newsgroup-unreads)))
7864 (gnus-pull article gnus-newsgroup-reads)
7867 (defalias 'gnus-summary-mark-as-unread-forward
7868 'gnus-summary-tick-article-forward)
7869 (make-obsolete 'gnus-summary-mark-as-unread-forward
7870 'gnus-summary-tick-article-forward)
7871 (defun gnus-summary-tick-article-forward (n)
7872 "Tick N articles forwards.
7873 If N is negative, tick backwards instead.
7874 The difference between N and the number of articles ticked is returned."
7876 (gnus-summary-mark-forward n gnus-ticked-mark))
7878 (defalias 'gnus-summary-mark-as-unread-backward
7879 'gnus-summary-tick-article-backward)
7880 (make-obsolete 'gnus-summary-mark-as-unread-backward
7881 'gnus-summary-tick-article-backward)
7882 (defun gnus-summary-tick-article-backward (n)
7883 "Tick N articles backwards.
7884 The difference between N and the number of articles ticked is returned."
7886 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7888 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7889 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7890 (defun gnus-summary-tick-article (&optional article clear-mark)
7891 "Mark current article as unread.
7892 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7893 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7895 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7898 (defun gnus-summary-mark-as-read-forward (n)
7899 "Mark N articles as read forwards.
7900 If N is negative, mark backwards instead.
7901 The difference between N and the actual number of articles marked is
7904 (gnus-summary-mark-forward n gnus-del-mark t))
7906 (defun gnus-summary-mark-as-read-backward (n)
7907 "Mark the N articles as read backwards.
7908 The difference between N and the actual number of articles marked is
7911 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7913 (defun gnus-summary-mark-as-read (&optional article mark)
7914 "Mark current article as read.
7915 ARTICLE specifies the article to be marked as read.
7916 MARK specifies a string to be inserted at the beginning of the line."
7917 (gnus-summary-mark-article article mark))
7919 (defun gnus-summary-clear-mark-forward (n)
7920 "Clear marks from N articles forward.
7921 If N is negative, clear backward instead.
7922 The difference between N and the number of marks cleared is returned."
7924 (gnus-summary-mark-forward n gnus-unread-mark))
7926 (defun gnus-summary-clear-mark-backward (n)
7927 "Clear marks from N articles backward.
7928 The difference between N and the number of marks cleared is returned."
7930 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7932 (defun gnus-summary-mark-unread-as-read ()
7933 "Intended to be used by `gnus-summary-mark-article-hook'."
7934 (when (memq gnus-current-article gnus-newsgroup-unreads)
7935 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7937 (defun gnus-summary-mark-read-and-unread-as-read ()
7938 "Intended to be used by `gnus-summary-mark-article-hook'."
7939 (let ((mark (gnus-summary-article-mark)))
7940 (when (or (gnus-unread-mark-p mark)
7941 (gnus-read-mark-p mark))
7942 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7944 (defun gnus-summary-mark-region-as-read (point mark all)
7945 "Mark all unread articles between point and mark as read.
7946 If given a prefix, mark all articles between point and mark as read,
7947 even ticked and dormant ones."
7948 (interactive "r\nP")
7957 (memq (setq article (gnus-summary-article-number))
7958 gnus-newsgroup-unreads))
7959 (gnus-summary-mark-article article gnus-del-mark))
7961 (gnus-summary-find-next))))))
7963 (defun gnus-summary-mark-below (score mark)
7964 "Mark articles with score less than SCORE with MARK."
7965 (interactive "P\ncMark: ")
7966 (setq score (if score
7967 (prefix-numeric-value score)
7968 (or gnus-summary-default-score 0)))
7970 (set-buffer gnus-summary-buffer)
7971 (goto-char (point-min))
7974 (and (< (gnus-summary-article-score) score)
7975 (gnus-summary-mark-article nil mark))
7976 (gnus-summary-find-next)))))
7978 (defun gnus-summary-kill-below (&optional score)
7979 "Mark articles with score below SCORE as read."
7981 (gnus-summary-mark-below score gnus-killed-mark))
7983 (defun gnus-summary-clear-above (&optional score)
7984 "Clear all marks from articles with score above SCORE."
7986 (gnus-summary-mark-above score gnus-unread-mark))
7988 (defun gnus-summary-tick-above (&optional score)
7989 "Tick all articles with score above SCORE."
7991 (gnus-summary-mark-above score gnus-ticked-mark))
7993 (defun gnus-summary-mark-above (score mark)
7994 "Mark articles with score over SCORE with MARK."
7995 (interactive "P\ncMark: ")
7996 (setq score (if score
7997 (prefix-numeric-value score)
7998 (or gnus-summary-default-score 0)))
8000 (set-buffer gnus-summary-buffer)
8001 (goto-char (point-min))
8003 (when (> (gnus-summary-article-score) score)
8004 (gnus-summary-mark-article nil mark))
8006 (gnus-summary-find-next)))))
8008 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8009 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8010 (defun gnus-summary-limit-include-expunged (&optional no-error)
8011 "Display all the hidden articles that were expunged for low scores."
8013 (let ((buffer-read-only nil))
8014 (let ((scored gnus-newsgroup-scored)
8017 (unless (gnus-summary-goto-subject (caar scored))
8018 (and (setq h (gnus-summary-article-header (caar scored)))
8019 (< (cdar scored) gnus-summary-expunge-below)
8021 (setq scored (cdr scored)))
8023 (when (not no-error)
8024 (error "No expunged articles hidden"))
8025 (goto-char (point-min))
8026 (gnus-summary-prepare-unthreaded (nreverse headers))
8027 (goto-char (point-min))
8028 (gnus-summary-position-point)
8031 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8032 "Mark all unread articles in this newsgroup as read.
8033 If prefix argument ALL is non-nil, ticked and dormant articles will
8034 also be marked as read.
8035 If QUIETLY is non-nil, no questions will be asked.
8036 If TO-HERE is non-nil, it should be a point in the buffer. All
8037 articles before this point will be marked as read.
8038 Note that this function will only catch up the unread article
8039 in the current summary buffer limitation.
8040 The number of articles marked as read is returned."
8045 (not gnus-interactive-catchup) ;Without confirmation?
8049 "Mark absolutely all articles as read? "
8050 "Mark all unread articles as read? ")))
8052 (not gnus-newsgroup-adaptive)
8053 (not gnus-newsgroup-auto-expire)
8054 (not gnus-suppress-duplicates)
8055 (or (not gnus-use-cache)
8056 (eq gnus-use-cache 'passive)))
8059 (setq gnus-newsgroup-marked nil
8060 gnus-newsgroup-dormant nil))
8061 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8062 ;; We actually mark all articles as canceled, which we
8063 ;; have to do when using auto-expiry or adaptive scoring.
8064 (gnus-summary-show-all-threads)
8065 (when (gnus-summary-first-subject (not all) t)
8067 (if to-here (< (point) to-here) t)
8068 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8069 (gnus-summary-find-next (not all) nil nil t))))
8070 (gnus-set-mode-line 'summary))
8072 (gnus-summary-position-point)))
8074 (defun gnus-summary-catchup-to-here (&optional all)
8075 "Mark all unticked articles before the current one as read.
8076 If ALL is non-nil, also mark ticked and dormant articles as read."
8079 (gnus-save-hidden-threads
8080 (let ((beg (point)))
8081 ;; We check that there are unread articles.
8082 (when (or all (gnus-summary-find-prev))
8083 (gnus-summary-catchup all t beg)))))
8084 (gnus-summary-position-point))
8086 (defun gnus-summary-catchup-all (&optional quietly)
8087 "Mark all articles in this newsgroup as read."
8089 (gnus-summary-catchup t quietly))
8091 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8092 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8093 If prefix argument ALL is non-nil, all articles are marked as read."
8095 (when (gnus-summary-catchup all quietly nil 'fast)
8096 ;; Select next newsgroup or exit.
8097 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8098 (eq gnus-auto-select-next 'quietly))
8099 (gnus-summary-next-group nil)
8100 (gnus-summary-exit))))
8102 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8103 "Mark all articles in this newsgroup as read, and then exit."
8105 (gnus-summary-catchup-and-exit t quietly))
8107 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8108 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8109 "Mark all articles in this group as read and select the next group.
8110 If given a prefix, mark all articles, unread as well as ticked, as
8114 (gnus-summary-catchup all))
8115 (gnus-summary-next-article t nil nil t))
8117 ;; Thread-based commands.
8119 (defun gnus-summary-articles-in-thread (&optional article)
8120 "Return a list of all articles in the current thread.
8121 If ARTICLE is non-nil, return all articles in the thread that starts
8123 (let* ((article (or article (gnus-summary-article-number)))
8124 (data (gnus-data-find-list article))
8125 (top-level (gnus-data-level (car data)))
8127 (cond ((null gnus-thread-operation-ignore-subject)
8128 (gnus-simplify-subject-re
8129 (mail-header-subject (gnus-data-header (car data)))))
8130 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8131 (gnus-simplify-subject-fuzzy
8132 (mail-header-subject (gnus-data-header (car data)))))
8134 (end-point (save-excursion
8135 (if (gnus-summary-go-to-next-thread)
8136 (point) (point-max))))
8139 (< (gnus-data-pos (car data)) end-point))
8140 (when (or (not top-subject)
8141 (string= top-subject
8142 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8143 (gnus-simplify-subject-fuzzy
8144 (mail-header-subject
8145 (gnus-data-header (car data))))
8146 (gnus-simplify-subject-re
8147 (mail-header-subject
8148 (gnus-data-header (car data)))))))
8149 (push (gnus-data-number (car data)) articles))
8150 (unless (and (setq data (cdr data))
8151 (> (gnus-data-level (car data)) top-level))
8153 ;; Return the list of articles.
8154 (nreverse articles)))
8156 (defun gnus-summary-rethread-current ()
8157 "Rethread the thread the current article is part of."
8159 (let* ((gnus-show-threads t)
8160 (article (gnus-summary-article-number))
8161 (id (mail-header-id (gnus-summary-article-header)))
8162 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8164 (error "No article on the current line"))
8165 (gnus-rebuild-thread id)
8166 (gnus-summary-goto-subject article)))
8168 (defun gnus-summary-reparent-thread ()
8169 "Make the current article child of the marked (or previous) article.
8171 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8172 is non-nil or the Subject: of both articles are the same."
8174 (unless (not (gnus-group-read-only-p))
8175 (error "The current newsgroup does not support article editing"))
8176 (unless (<= (length gnus-newsgroup-processable) 1)
8177 (error "No more than one article may be marked"))
8178 (save-window-excursion
8179 (let ((gnus-article-buffer " *reparent*")
8180 (current-article (gnus-summary-article-number))
8181 ;; First grab the marked article, otherwise one line up.
8182 (parent-article (if (not (null gnus-newsgroup-processable))
8183 (car gnus-newsgroup-processable)
8185 (if (eq (forward-line -1) 0)
8186 (gnus-summary-article-number)
8187 (error "Beginning of summary buffer"))))))
8188 (unless (not (eq current-article parent-article))
8189 (error "An article may not be self-referential"))
8190 (let ((message-id (mail-header-id
8191 (gnus-summary-article-header parent-article))))
8192 (unless (and message-id (not (equal message-id "")))
8193 (error "No message-id in desired parent"))
8194 ;; We don't want the article to be marked as read.
8195 (let (gnus-mark-article-hook)
8196 (gnus-summary-select-article t t nil current-article))
8197 (set-buffer gnus-original-article-buffer)
8198 (let ((buf (format "%s" (buffer-string))))
8201 (goto-char (point-min))
8202 (if (re-search-forward "^References: " nil t)
8204 (re-search-forward "^[^ \t]" nil t)
8207 (insert " " message-id))
8208 (insert "References: " message-id "\n"))
8209 (unless (gnus-request-replace-article
8210 current-article (car gnus-article-current)
8212 (error "Couldn't replace article"))))
8213 (set-buffer gnus-summary-buffer)
8214 (gnus-summary-unmark-all-processable)
8215 (gnus-summary-update-article current-article)
8216 (gnus-summary-rethread-current)
8217 (gnus-message 3 "Article %d is now the child of article %d"
8218 current-article parent-article)))))
8220 (defun gnus-summary-toggle-threads (&optional arg)
8221 "Toggle showing conversation threads.
8222 If ARG is positive number, turn showing conversation threads on."
8224 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8225 (setq gnus-show-threads
8226 (if (null arg) (not gnus-show-threads)
8227 (> (prefix-numeric-value arg) 0)))
8228 (gnus-summary-prepare)
8229 (gnus-summary-goto-subject current)
8230 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8231 (gnus-summary-position-point)))
8233 (defun gnus-summary-show-all-threads ()
8237 (let ((buffer-read-only nil))
8238 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8239 (gnus-summary-position-point))
8241 (defun gnus-summary-show-thread ()
8242 "Show thread subtrees.
8243 Returns nil if no thread was there to be shown."
8245 (let ((buffer-read-only nil)
8247 ;; first goto end then to beg, to have point at beg after let
8248 (end (progn (end-of-line) (point)))
8249 (beg (progn (beginning-of-line) (point))))
8251 ;; Any hidden lines here?
8252 (search-forward "\r" end t)
8253 (subst-char-in-region beg end ?\^M ?\n t)
8255 (gnus-summary-position-point))))
8257 (defun gnus-summary-hide-all-threads ()
8258 "Hide all thread subtrees."
8261 (goto-char (point-min))
8262 (gnus-summary-hide-thread)
8263 (while (zerop (gnus-summary-next-thread 1 t))
8264 (gnus-summary-hide-thread)))
8265 (gnus-summary-position-point))
8267 (defun gnus-summary-hide-thread ()
8268 "Hide thread subtrees.
8269 Returns nil if no threads were there to be hidden."
8271 (let ((buffer-read-only nil)
8273 (article (gnus-summary-article-number)))
8275 ;; Go forward until either the buffer ends or the subthread
8277 (when (and (not (eobp))
8278 (or (zerop (gnus-summary-next-thread 1 t))
8279 (goto-char (point-max))))
8281 (if (and (> (point) start)
8282 (search-backward "\n" start t))
8284 (subst-char-in-region start (point) ?\n ?\^M)
8285 (gnus-summary-goto-subject article))
8288 ;;(gnus-summary-position-point)
8291 (defun gnus-summary-go-to-next-thread (&optional previous)
8292 "Go to the same level (or less) next thread.
8293 If PREVIOUS is non-nil, go to previous thread instead.
8294 Return the article number moved to, or nil if moving was impossible."
8295 (let ((level (gnus-summary-thread-level))
8296 (way (if previous -1 1))
8299 (while (and (not (eobp))
8300 (< level (gnus-summary-thread-level)))
8308 (gnus-summary-article-number)
8311 (defun gnus-summary-next-thread (n &optional silent)
8312 "Go to the same level next N'th thread.
8313 If N is negative, search backward instead.
8314 Returns the difference between N and the number of skips actually
8317 If SILENT, don't output messages."
8319 (let ((backward (< n 0))
8322 (gnus-summary-go-to-next-thread backward))
8325 (gnus-summary-position-point))
8326 (when (and (not silent) (/= 0 n))
8327 (gnus-message 7 "No more threads"))
8330 (defun gnus-summary-prev-thread (n)
8331 "Go to the same level previous N'th thread.
8332 Returns the difference between N and the number of skips actually
8335 (gnus-summary-next-thread (- n)))
8337 (defun gnus-summary-go-down-thread ()
8338 "Go down one level in the current thread."
8339 (let ((children (gnus-summary-article-children)))
8341 (gnus-summary-goto-subject (car children)))))
8343 (defun gnus-summary-go-up-thread ()
8344 "Go up one level in the current thread."
8345 (let ((parent (gnus-summary-article-parent)))
8347 (gnus-summary-goto-subject parent))))
8349 (defun gnus-summary-down-thread (n)
8350 "Go down thread N steps.
8351 If N is negative, go up instead.
8352 Returns the difference between N and how many steps down that were
8358 (if up (gnus-summary-go-up-thread)
8359 (gnus-summary-go-down-thread)))
8361 (gnus-summary-position-point)
8363 (gnus-message 7 "Can't go further"))
8366 (defun gnus-summary-up-thread (n)
8367 "Go up thread N steps.
8368 If N is negative, go up instead.
8369 Returns the difference between N and how many steps down that were
8372 (gnus-summary-down-thread (- n)))
8374 (defun gnus-summary-top-thread ()
8375 "Go to the top of the thread."
8377 (while (gnus-summary-go-up-thread))
8378 (gnus-summary-article-number))
8380 (defun gnus-summary-kill-thread (&optional unmark)
8381 "Mark articles under current thread as read.
8382 If the prefix argument is positive, remove any kinds of marks.
8383 If the prefix argument is negative, tick articles instead."
8386 (setq unmark (prefix-numeric-value unmark)))
8387 (let ((articles (gnus-summary-articles-in-thread)))
8389 ;; Expand the thread.
8390 (gnus-summary-show-thread)
8391 ;; Mark all the articles.
8393 (gnus-summary-goto-subject (car articles))
8394 (cond ((null unmark)
8395 (gnus-summary-mark-article-as-read gnus-killed-mark))
8397 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8399 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8400 (setq articles (cdr articles))))
8401 ;; Hide killed subtrees.
8403 gnus-thread-hide-killed
8404 (gnus-summary-hide-thread))
8405 ;; If marked as read, go to next unread subject.
8407 ;; Go to next unread subject.
8408 (gnus-summary-next-subject 1 t)))
8409 (gnus-set-mode-line 'summary))
8411 ;; Summary sorting commands
8413 (defun gnus-summary-sort-by-number (&optional reverse)
8414 "Sort the summary buffer by article number.
8415 Argument REVERSE means reverse order."
8417 (gnus-summary-sort 'number reverse))
8419 (defun gnus-summary-sort-by-author (&optional reverse)
8420 "Sort the summary buffer by author name alphabetically.
8421 If case-fold-search is non-nil, case of letters is ignored.
8422 Argument REVERSE means reverse order."
8424 (gnus-summary-sort 'author reverse))
8426 (defun gnus-summary-sort-by-subject (&optional reverse)
8427 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8428 If case-fold-search is non-nil, case of letters is ignored.
8429 Argument REVERSE means reverse order."
8431 (gnus-summary-sort 'subject reverse))
8433 (defun gnus-summary-sort-by-date (&optional reverse)
8434 "Sort the summary buffer by date.
8435 Argument REVERSE means reverse order."
8437 (gnus-summary-sort 'date reverse))
8439 (defun gnus-summary-sort-by-score (&optional reverse)
8440 "Sort the summary buffer by score.
8441 Argument REVERSE means reverse order."
8443 (gnus-summary-sort 'score reverse))
8445 (defun gnus-summary-sort-by-lines (&optional reverse)
8446 "Sort the summary buffer by article length.
8447 Argument REVERSE means reverse order."
8449 (gnus-summary-sort 'lines reverse))
8451 (defun gnus-summary-sort (predicate reverse)
8452 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8453 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8454 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8455 (gnus-thread-sort-functions
8461 (gnus-article-sort-functions
8466 (,article t2 t1)))))
8468 (gnus-summary-prepare-hook nil))
8469 ;; We do the sorting by regenerating the threads.
8470 (gnus-summary-prepare)
8471 ;; Hide subthreads if needed.
8472 (when (and gnus-show-threads gnus-thread-hide-subtree)
8473 (gnus-summary-hide-all-threads))))
8475 ;; Summary saving commands.
8477 (defun gnus-summary-save-article (&optional n not-saved)
8478 "Save the current article using the default saver function.
8479 If N is a positive number, save the N next articles.
8480 If N is a negative number, save the N previous articles.
8481 If N is nil and any articles have been marked with the process mark,
8482 save those articles instead.
8483 The variable `gnus-default-article-saver' specifies the saver function."
8485 (let* ((articles (gnus-summary-work-articles n))
8486 (save-buffer (save-excursion
8487 (nnheader-set-temp-buffer " *Gnus Save*")))
8488 (num (length articles))
8489 header article file)
8491 (setq header (gnus-summary-article-header
8492 (setq article (pop articles))))
8493 (if (not (vectorp header))
8494 ;; This is a pseudo-article.
8495 (if (assq 'name header)
8496 (gnus-copy-file (cdr (assq 'name header)))
8497 (gnus-message 1 "Article %d is unsaveable" article))
8498 ;; This is a real article.
8499 (save-window-excursion
8500 (gnus-summary-select-article t nil nil article))
8502 (set-buffer save-buffer)
8504 (insert-buffer-substring gnus-original-article-buffer))
8505 (setq file (gnus-article-save save-buffer file num))
8506 (gnus-summary-remove-process-mark article)
8508 (gnus-summary-set-saved-mark article))))
8509 (gnus-kill-buffer save-buffer)
8510 (gnus-summary-position-point)
8511 (gnus-set-mode-line 'summary)
8514 (defun gnus-summary-pipe-output (&optional arg)
8515 "Pipe the current article to a subprocess.
8516 If N is a positive number, pipe the N next articles.
8517 If N is a negative number, pipe the N previous articles.
8518 If N is nil and any articles have been marked with the process mark,
8519 pipe those articles instead."
8521 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8522 (gnus-summary-save-article arg t))
8523 (gnus-configure-windows 'pipe))
8525 (defun gnus-summary-save-article-mail (&optional arg)
8526 "Append the current article to an mail file.
8527 If N is a positive number, save the N next articles.
8528 If N is a negative number, save the N previous articles.
8529 If N is nil and any articles have been marked with the process mark,
8530 save those articles instead."
8532 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8533 (gnus-summary-save-article arg)))
8535 (defun gnus-summary-save-article-rmail (&optional arg)
8536 "Append the current article to an rmail file.
8537 If N is a positive number, save the N next articles.
8538 If N is a negative number, save the N previous articles.
8539 If N is nil and any articles have been marked with the process mark,
8540 save those articles instead."
8542 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8543 (gnus-summary-save-article arg)))
8545 (defun gnus-summary-save-article-file (&optional arg)
8546 "Append the current article to a file.
8547 If N is a positive number, save the N next articles.
8548 If N is a negative number, save the N previous articles.
8549 If N is nil and any articles have been marked with the process mark,
8550 save those articles instead."
8552 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8553 (gnus-summary-save-article arg)))
8555 (defun gnus-summary-write-article-file (&optional arg)
8556 "Write the current article to a file, deleting the previous file.
8557 If N is a positive number, save the N next articles.
8558 If N is a negative number, save the N previous articles.
8559 If N is nil and any articles have been marked with the process mark,
8560 save those articles instead."
8562 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8563 (gnus-summary-save-article arg)))
8565 (defun gnus-summary-save-article-body-file (&optional arg)
8566 "Append the current article body to a file.
8567 If N is a positive number, save the N next articles.
8568 If N is a negative number, save the N previous articles.
8569 If N is nil and any articles have been marked with the process mark,
8570 save those articles instead."
8572 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8573 (gnus-summary-save-article arg)))
8575 (defun gnus-summary-pipe-message (program)
8576 "Pipe the current article through PROGRAM."
8577 (interactive "sProgram: ")
8578 (gnus-summary-select-article)
8579 (let ((mail-header-separator ""))
8580 (gnus-eval-in-buffer-window gnus-article-buffer
8583 (let ((start (window-start))
8585 (message-pipe-buffer-body program)
8586 (set-window-start (get-buffer-window (current-buffer)) start))))))
8588 (defun gnus-get-split-value (methods)
8589 "Return a value based on the split METHODS."
8590 (let (split-name method result match)
8593 (set-buffer gnus-original-article-buffer)
8595 (nnheader-narrow-to-headers)
8597 (goto-char (point-min))
8598 (setq method (pop methods))
8599 (setq match (car method))
8602 ;; Regular expression.
8604 (re-search-forward match nil t)))
8605 ((gnus-functionp match)
8609 (setq result (funcall match gnus-newsgroup-name))))
8614 (setq result (eval match)))))
8615 (setq split-name (append (cdr method) split-name))
8616 (cond ((stringp result)
8617 (push (expand-file-name
8618 result gnus-article-save-directory)
8621 (setq split-name (append result split-name)))))))))
8624 (defun gnus-valid-move-group-p (group)
8629 (car (gnus-find-method-for-group
8630 (symbol-name group))))
8631 gnus-valid-select-methods))))
8633 (defun gnus-read-move-group-name (prompt default articles prefix)
8634 "Read a group name."
8635 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8636 (minibuffer-confirm-incomplete nil) ; XEmacs
8640 (if (> (length articles) 1)
8641 (format "these %d articles" (length articles))
8646 (gnus-completing-read default prom
8648 'gnus-valid-move-group-p
8650 'gnus-group-history))
8651 ((= 1 (length split-name))
8652 (gnus-completing-read (car split-name) prom
8654 'gnus-valid-move-group-p
8656 'gnus-group-history))
8658 (gnus-completing-read nil prom
8659 (mapcar (lambda (el) (list el))
8660 (nreverse split-name))
8662 'gnus-group-history)))))
8664 (if (or (string= to-newsgroup "")
8665 (string= to-newsgroup prefix))
8666 (setq to-newsgroup default))
8667 (unless to-newsgroup
8668 (error "No group name entered"))
8669 (or (gnus-active to-newsgroup)
8670 (gnus-activate-group to-newsgroup)
8671 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8673 (or (and (gnus-request-create-group
8674 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8675 (gnus-activate-group to-newsgroup nil nil
8676 (gnus-group-name-to-method
8678 (error "Couldn't create group %s" to-newsgroup)))
8679 (error "No such group: %s" to-newsgroup)))
8682 ;; Summary extract commands
8684 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8685 (let ((buffer-read-only nil)
8686 (article (gnus-summary-article-number))
8688 (unless (gnus-summary-goto-subject article)
8689 (error "No such article: %d" article))
8690 (gnus-summary-position-point)
8691 ;; If all commands are to be bunched up on one line, we collect
8693 (unless gnus-view-pseudos-separately
8694 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8697 (setq action (cdr (assq 'action (car ps))))
8698 (setq files (list (cdr (assq 'name (car ps)))))
8699 (while (and ps (cdr ps)
8700 (string= (or action "1")
8701 (or (cdr (assq 'action (cadr ps))) "2")))
8702 (push (cdr (assq 'name (cadr ps))) files)
8703 (setcdr ps (cddr ps)))
8705 (when (not (string-match "%s" action))
8708 (when (assq 'execute (car ps))
8709 (setcdr (assq 'execute (car ps))
8710 (funcall (if (string-match "%s" action)
8719 (setq ps (cdr ps)))))
8720 (if (and gnus-view-pseudos (not not-view))
8722 (when (assq 'execute (car pslist))
8723 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8724 (eq gnus-view-pseudos 'not-confirm)))
8725 (setq pslist (cdr pslist)))
8728 (setq after-article (or (cdr (assq 'article (car pslist)))
8729 (gnus-summary-article-number)))
8730 (gnus-summary-goto-subject after-article)
8733 (insert " " (file-name-nondirectory
8734 (cdr (assq 'name (car pslist))))
8735 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8737 (forward-line -1) ; back to `b'
8738 (gnus-add-text-properties
8739 b (1- e) (list 'gnus-number gnus-reffed-article-number
8740 gnus-mouse-face-prop gnus-mouse-face))
8742 after-article gnus-reffed-article-number
8743 gnus-unread-mark b (car pslist) 0 (- e b))
8744 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8745 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8746 (setq pslist (cdr pslist)))))))
8748 (defun gnus-pseudos< (p1 p2)
8749 (let ((c1 (cdr (assq 'action p1)))
8750 (c2 (cdr (assq 'action p2))))
8751 (and c1 c2 (string< c1 c2))))
8753 (defun gnus-request-pseudo-article (props)
8754 (cond ((assq 'execute props)
8755 (gnus-execute-command (cdr (assq 'execute props)))))
8756 (let ((gnus-current-article (gnus-summary-article-number)))
8757 (gnus-run-hooks 'gnus-mark-article-hook)))
8759 (defun gnus-execute-command (command &optional automatic)
8761 (gnus-article-setup-buffer)
8762 (set-buffer gnus-article-buffer)
8763 (setq buffer-read-only nil)
8764 (let ((command (if automatic command
8765 (read-string "Command: " (cons command 0)))))
8767 (insert "$ " command "\n\n")
8768 (if gnus-view-pseudo-asynchronously
8769 (start-process "gnus-execute" (current-buffer) shell-file-name
8770 shell-command-switch command)
8771 (call-process shell-file-name nil t nil
8772 shell-command-switch command)))))
8774 ;; Summary kill commands.
8776 (defun gnus-summary-edit-global-kill (article)
8777 "Edit the \"global\" kill file."
8778 (interactive (list (gnus-summary-article-number)))
8779 (gnus-group-edit-global-kill article))
8781 (defun gnus-summary-edit-local-kill ()
8782 "Edit a local kill file applied to the current newsgroup."
8784 (setq gnus-current-headers (gnus-summary-article-header))
8785 (gnus-group-edit-local-kill
8786 (gnus-summary-article-number) gnus-newsgroup-name))
8790 (defun gnus-read-header (id &optional header)
8791 "Read the headers of article ID and enter them into the Gnus system."
8792 (let ((group gnus-newsgroup-name)
8793 (gnus-override-method
8794 (and (gnus-news-group-p gnus-newsgroup-name)
8795 gnus-refer-article-method))
8797 ;; First we check to see whether the header in question is already
8800 ;; This is a Message-ID.
8801 (setq header (or header (gnus-id-to-header id)))
8802 ;; This is an article number.
8803 (setq header (or header (gnus-summary-article-header id))))
8805 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8806 ;; We have found the header.
8808 ;; If this is a sparse article, we have to nix out its
8809 ;; previous entry in the thread hashtb.
8811 (gnus-summary-article-sparse-p (mail-header-number header)))
8812 (let* ((parent (gnus-parent-id (mail-header-references header)))
8813 (thread (and parent (gnus-id-to-thread parent))))
8815 (delq (assq header thread) thread))))
8816 ;; We have to really fetch the header to this article.
8818 (set-buffer nntp-server-buffer)
8819 (when (setq where (gnus-request-head id group))
8820 (nnheader-fold-continuation-lines)
8821 (goto-char (point-max))
8823 (goto-char (point-min))
8827 ((cdr where) (cdr where))
8828 (header (mail-header-number header))
8829 (t gnus-reffed-article-number))
8831 (insert " Article retrieved.\n"))
8833 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8834 () ; Malformed head.
8835 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8836 (when (and (stringp id)
8837 (not (string= (gnus-group-real-name group)
8839 ;; If we fetched by Message-ID and the article came
8840 ;; from a different group, we fudge some bogus article
8841 ;; numbers for this article.
8842 (mail-header-set-number header gnus-reffed-article-number))
8844 (set-buffer gnus-summary-buffer)
8845 (decf gnus-reffed-article-number)
8846 (gnus-remove-header (mail-header-number header))
8847 (push header gnus-newsgroup-headers)
8848 (setq gnus-current-headers header)
8849 (push (mail-header-number header) gnus-newsgroup-limit)))
8852 (defun gnus-remove-header (number)
8853 "Remove header NUMBER from `gnus-newsgroup-headers'."
8854 (if (and gnus-newsgroup-headers
8855 (= number (mail-header-number (car gnus-newsgroup-headers))))
8856 (pop gnus-newsgroup-headers)
8857 (let ((headers gnus-newsgroup-headers))
8858 (while (and (cdr headers)
8859 (not (= number (mail-header-number (cadr headers)))))
8862 (setcdr headers (cddr headers))))))
8865 ;;; summary highlights
8868 (defun gnus-highlight-selected-summary ()
8869 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8870 ;; Highlight selected article in summary buffer
8871 (when gnus-summary-selected-face
8873 (let* ((beg (progn (beginning-of-line) (point)))
8874 (end (progn (end-of-line) (point)))
8875 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8876 (from (if (get-text-property beg gnus-mouse-face-prop)
8878 (or (next-single-property-change
8879 beg gnus-mouse-face-prop nil end)
8884 (or (next-single-property-change
8885 from gnus-mouse-face-prop nil end)
8887 ;; If no mouse-face prop on line we will have to = from = end,
8888 ;; so we highlight the entire line instead.
8889 (when (= (+ to 2) from)
8892 (if gnus-newsgroup-selected-overlay
8893 ;; Move old overlay.
8895 gnus-newsgroup-selected-overlay from to (current-buffer))
8896 ;; Create new overlay.
8898 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8899 'face gnus-summary-selected-face))))))
8901 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8902 (defun gnus-summary-highlight-line ()
8903 "Highlight current line according to `gnus-summary-highlight'."
8904 (let* ((list gnus-summary-highlight)
8906 (end (progn (end-of-line) (point)))
8907 ;; now find out where the line starts and leave point there.
8908 (beg (progn (beginning-of-line) (point)))
8909 (article (gnus-summary-article-number))
8910 (score (or (cdr (assq (or article gnus-current-article)
8911 gnus-newsgroup-scored))
8912 gnus-summary-default-score 0))
8913 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8914 (inhibit-read-only t))
8915 ;; Eval the cars of the lists until we find a match.
8916 (let ((default gnus-summary-default-score))
8918 (not (eval (caar list))))
8919 (setq list (cdr list))))
8920 (let ((face (cdar list)))
8921 (unless (eq face (get-text-property beg 'face))
8922 (gnus-put-text-property-excluding-characters-with-faces
8924 (setq face (if (boundp face) (symbol-value face) face)))
8925 (when gnus-summary-highlight-line-function
8926 (funcall gnus-summary-highlight-line-function article face))))
8929 (defun gnus-update-read-articles (group unread &optional compute)
8930 "Update the list of read articles in GROUP."
8931 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8932 (entry (gnus-gethash group gnus-newsrc-hashtb))
8933 (info (nth 2 entry))
8935 (unread (sort (copy-sequence unread) '<))
8937 (if (or (not info) (not active))
8938 ;; There is no info on this group if it was, in fact,
8939 ;; killed. Gnus stores no information on killed groups, so
8940 ;; there's nothing to be done.
8941 ;; One could store the information somewhere temporarily,
8942 ;; perhaps... Hmmm...
8944 ;; Remove any negative articles numbers.
8945 (while (and unread (< (car unread) 0))
8946 (setq unread (cdr unread)))
8947 ;; Remove any expired article numbers
8948 (while (and unread (< (car unread) (car active)))
8949 (setq unread (cdr unread)))
8950 ;; Compute the ranges of read articles by looking at the list of
8953 (when (/= (car unread) prev)
8954 (push (if (= prev (1- (car unread))) prev
8955 (cons prev (1- (car unread))))
8957 (setq prev (1+ (car unread)))
8958 (setq unread (cdr unread)))
8959 (when (<= prev (cdr active))
8960 (push (cons prev (cdr active)) read))
8961 (setq read (if (> (length read) 1) (nreverse read) read))
8965 (set-buffer gnus-group-buffer)
8968 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8969 (gnus-info-set-read ',info ',(gnus-info-read info))
8970 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8971 (gnus-group-update-group ,group t))))
8972 ;; Enter this list into the group info.
8973 (gnus-info-set-read info read)
8974 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8975 (gnus-get-unread-articles-in-group info (gnus-active group))
8978 (defun gnus-offer-save-summaries ()
8979 "Offer to save all active summary buffers."
8981 (let ((buflist (buffer-list))
8983 ;; Go through all buffers and find all summaries.
8985 (and (setq bufname (buffer-name (car buflist)))
8986 (string-match "Summary" bufname)
8988 (set-buffer bufname)
8989 ;; We check that this is, indeed, a summary buffer.
8990 (and (eq major-mode 'gnus-summary-mode)
8991 ;; Also make sure this isn't bogus.
8992 gnus-newsgroup-prepared
8993 ;; Also make sure that this isn't a dead summary buffer.
8994 (not gnus-dead-summary-mode)))
8995 (push bufname buffers))
8996 (setq buflist (cdr buflist)))
8997 ;; Go through all these summary buffers and offer to save them.
9000 "Update summary buffer %s? "
9002 (switch-to-buffer buf)
9003 (gnus-summary-exit))
9010 (run-hooks 'gnus-sum-load-hook)
9012 ;;; gnus-sum.el ends here