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@ifi.uio.no>
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))
36 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
38 (defcustom gnus-kill-summary-on-exit t
39 "*If non-nil, kill the summary buffer when you exit from it.
40 If nil, the summary will become a \"*Dead Summary*\" buffer, and
41 it will be killed sometime later."
42 :group 'gnus-summary-exit
45 (defcustom gnus-fetch-old-headers nil
46 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
47 If an unread article in the group refers to an older, already read (or
48 just marked as read) article, the old article will not normally be
49 displayed in the Summary buffer. If this variable is non-nil, Gnus
50 will attempt to grab the headers to the old articles, and thereby
51 build complete threads. If it has the value `some', only enough
52 headers to connect otherwise loose threads will be displayed. This
53 variable can also be a number. In that case, no more than that number
54 of old headers will be fetched. If it has the value `invisible', all
55 old headers will be fetched, but none will be displayed.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-refer-thread-limit 200
65 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
66 If t, fetch all the available old headers."
69 (sexp :menu-tag "other" t)))
71 (defcustom gnus-summary-make-false-root 'adopt
72 "*nil means that Gnus won't gather loose threads.
73 If the root of a thread has expired or been read in a previous
74 session, the information necessary to build a complete thread has been
75 lost. Instead of having many small sub-threads from this original thread
76 scattered all over the summary buffer, Gnus can gather them.
78 If non-nil, Gnus will try to gather all loose sub-threads from an
79 original thread into one large thread.
81 If this variable is non-nil, it should be one of `none', `adopt',
84 If this variable is `none', Gnus will not make a false root, but just
85 present the sub-threads after another.
86 If this variable is `dummy', Gnus will create a dummy root that will
87 have all the sub-threads as children.
88 If this variable is `adopt', Gnus will make one of the \"children\"
89 the parent and mark all the step-children as such.
90 If this variable is `empty', the \"children\" are printed with empty
91 subject fields. (Or rather, they will be printed with a string
92 given by the `gnus-summary-same-subject' variable.)"
94 :type '(choice (const :tag "off" nil)
100 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
101 "*A regexp to match subjects to be excluded from loose thread gathering.
102 As loose thread gathering is done on subjects only, that means that
103 there can be many false gatherings performed. By rooting out certain
104 common subjects, gathering might become saner."
108 (defcustom gnus-summary-gather-subject-limit nil
109 "*Maximum length of subject comparisons when gathering loose threads.
110 Use nil to compare full subjects. Setting this variable to a low
111 number will help gather threads that have been corrupted by
112 newsreaders chopping off subject lines, but it might also mean that
113 unrelated articles that have subject that happen to begin with the
114 same few characters will be incorrectly gathered.
116 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
119 :type '(choice (const :tag "off" nil)
121 (sexp :menu-tag "on" t)))
123 (defcustom gnus-simplify-subject-functions nil
124 "List of functions taking a string argument that simplify subjects.
125 The functions are applied recursively."
127 :type '(repeat (list function)))
129 (defcustom gnus-simplify-ignored-prefixes nil
130 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
132 :type '(choice (const :tag "off" nil)
135 (defcustom gnus-build-sparse-threads nil
136 "*If non-nil, fill in the gaps in threads.
137 If `some', only fill in the gaps that are needed to tie loose threads
138 together. If `more', fill in all leaf nodes that Gnus can find. If
139 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
141 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "all" t)))
146 (defcustom gnus-summary-thread-gathering-function
147 'gnus-gather-threads-by-subject
148 "*Function used for gathering loose threads.
149 There are two pre-defined functions: `gnus-gather-threads-by-subject',
150 which only takes Subjects into consideration; and
151 `gnus-gather-threads-by-references', which compared the References
152 headers of the articles to find matches."
154 :type '(radio (function-item gnus-gather-threads-by-subject)
155 (function-item gnus-gather-threads-by-references)
156 (function :tag "other")))
158 (defcustom gnus-summary-same-subject ""
159 "*String indicating that the current article has the same subject as the previous.
160 This variable will only be used if the value of
161 `gnus-summary-make-false-root' is `empty'."
162 :group 'gnus-summary-format
165 (defcustom gnus-summary-goto-unread t
166 "*If t, marking commands will go to the next unread article.
167 If `never', commands that usually go to the next unread article, will
168 go to the next article, whether it is read or not.
169 If nil, only the marking commands will go to the next (un)read article."
170 :group 'gnus-summary-marks
171 :link '(custom-manual "(gnus)Setting Marks")
172 :type '(choice (const :tag "off" nil)
174 (sexp :menu-tag "on" t)))
176 (defcustom gnus-summary-default-score 0
177 "*Default article score level.
178 All scores generated by the score files will be added to this score.
179 If this variable is nil, scoring will be disabled."
180 :group 'gnus-score-default
181 :type '(choice (const :tag "disable")
184 (defcustom gnus-summary-zcore-fuzz 0
185 "*Fuzziness factor for the zcore in the summary buffer.
186 Articles with scores closer than this to `gnus-summary-default-score'
188 :group 'gnus-summary-format
191 (defcustom gnus-simplify-subject-fuzzy-regexp nil
192 "*Strings to be removed when doing fuzzy matches.
193 This can either be a regular expression or list of regular expressions
194 that will be removed from subject strings if fuzzy subject
195 simplification is selected."
197 :type '(repeat regexp))
199 (defcustom gnus-show-threads t
200 "*If non-nil, display threads in summary mode."
204 (defcustom gnus-thread-hide-subtree nil
205 "*If non-nil, hide all threads initially.
206 If threads are hidden, you have to run the command
207 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
208 to expose hidden threads."
212 (defcustom gnus-thread-hide-killed t
213 "*If non-nil, hide killed threads automatically."
217 (defcustom gnus-thread-ignore-subject nil
218 "*If non-nil, ignore subjects and do all threading based on the Reference header.
219 If nil, which is the default, articles that have different subjects
220 from their parents will start separate threads."
224 (defcustom gnus-thread-operation-ignore-subject t
225 "*If non-nil, subjects will be ignored when doing thread commands.
226 This affects commands like `gnus-summary-kill-thread' and
227 `gnus-summary-lower-thread'.
229 If this variable is nil, articles in the same thread with different
230 subjects will not be included in the operation in question. If this
231 variable is `fuzzy', only articles that have subjects that are fuzzily
232 equal will be included."
234 :type '(choice (const :tag "off" nil)
238 (defcustom gnus-thread-indent-level 4
239 "*Number that says how much each sub-thread should be indented."
243 (defcustom gnus-auto-extend-newsgroup t
244 "*If non-nil, extend newsgroup forward and backward when requested."
245 :group 'gnus-summary-choose
248 (defcustom gnus-auto-select-first t
249 "*If nil, don't select the first unread article when entering a group.
250 If this variable is `best', select the highest-scored unread article
251 in the group. If neither nil nor `best', select the first unread
254 If you want to prevent automatic selection of the first unread article
255 in some newsgroups, set the variable to nil in
256 `gnus-select-group-hook'."
257 :group 'gnus-group-select
258 :type '(choice (const :tag "none" nil)
260 (sexp :menu-tag "first" t)))
262 (defcustom gnus-auto-select-next t
263 "*If non-nil, offer to go to the next group from the end of the previous.
264 If the value is t and the next newsgroup is empty, Gnus will exit
265 summary mode and go back to group mode. If the value is neither nil
266 nor t, Gnus will select the following unread newsgroup. In
267 particular, if the value is the symbol `quietly', the next unread
268 newsgroup will be selected without any confirmation, and if it is
269 `almost-quietly', the next group will be selected without any
270 confirmation if you are located on the last article in the group.
271 Finally, if this variable is `slightly-quietly', the `Z n' command
272 will go to the next group without confirmation."
273 :group 'gnus-summary-maneuvering
274 :type '(choice (const :tag "off" nil)
276 (const almost-quietly)
277 (const slightly-quietly)
278 (sexp :menu-tag "on" t)))
280 (defcustom gnus-auto-select-same nil
281 "*If non-nil, select the next article with the same subject."
282 :group 'gnus-summary-maneuvering
285 (defcustom gnus-summary-check-current nil
286 "*If non-nil, consider the current article when moving.
287 The \"unread\" movement commands will stay on the same line if the
288 current article is unread."
289 :group 'gnus-summary-maneuvering
292 (defcustom gnus-auto-center-summary t
293 "*If non-nil, always center the current summary buffer.
294 In particular, if `vertical' do only vertical recentering. If non-nil
295 and non-`vertical', do both horizontal and vertical recentering."
296 :group 'gnus-summary-maneuvering
297 :type '(choice (const :tag "none" nil)
299 (sexp :menu-tag "both" t)))
301 (defcustom gnus-show-all-headers nil
302 "*If non-nil, don't hide any headers."
303 :group 'gnus-article-hiding
304 :group 'gnus-article-headers
307 (defcustom gnus-summary-ignore-duplicates nil
308 "*If non-nil, ignore articles with identical Message-ID headers."
312 (defcustom gnus-single-article-buffer t
313 "*If non-nil, display all articles in the same buffer.
314 If nil, each group will get its own article buffer."
315 :group 'gnus-article-various
318 (defcustom gnus-break-pages t
319 "*If non-nil, do page breaking on articles.
320 The page delimiter is specified by the `gnus-page-delimiter'
322 :group 'gnus-article-various
325 (defcustom gnus-show-mime nil
326 "*If non-nil, do mime processing of articles.
327 The articles will simply be fed to the function given by
328 `gnus-show-mime-method'."
329 :group 'gnus-article-mime
332 (defcustom gnus-move-split-methods nil
333 "*Variable used to suggest where articles are to be moved to.
334 It uses the same syntax as the `gnus-split-methods' variable."
335 :group 'gnus-summary-mail
336 :type '(repeat (choice (list :value (fun) function)
337 (cons :value ("" "") regexp (repeat string))
340 (defcustom gnus-unread-mark ?
341 "*Mark used for unread articles."
342 :group 'gnus-summary-marks
345 (defcustom gnus-ticked-mark ?!
346 "*Mark used for ticked articles."
347 :group 'gnus-summary-marks
350 (defcustom gnus-dormant-mark ??
351 "*Mark used for dormant articles."
352 :group 'gnus-summary-marks
355 (defcustom gnus-del-mark ?r
356 "*Mark used for del'd articles."
357 :group 'gnus-summary-marks
360 (defcustom gnus-read-mark ?R
361 "*Mark used for read articles."
362 :group 'gnus-summary-marks
365 (defcustom gnus-expirable-mark ?E
366 "*Mark used for expirable articles."
367 :group 'gnus-summary-marks
370 (defcustom gnus-killed-mark ?K
371 "*Mark used for killed articles."
372 :group 'gnus-summary-marks
375 (defcustom gnus-souped-mark ?F
376 "*Mark used for killed articles."
377 :group 'gnus-summary-marks
380 (defcustom gnus-kill-file-mark ?X
381 "*Mark used for articles killed by kill files."
382 :group 'gnus-summary-marks
385 (defcustom gnus-low-score-mark ?Y
386 "*Mark used for articles with a low score."
387 :group 'gnus-summary-marks
390 (defcustom gnus-catchup-mark ?C
391 "*Mark used for articles that are caught up."
392 :group 'gnus-summary-marks
395 (defcustom gnus-replied-mark ?A
396 "*Mark used for articles that have been replied to."
397 :group 'gnus-summary-marks
400 (defcustom gnus-cached-mark ?*
401 "*Mark used for articles that are in the cache."
402 :group 'gnus-summary-marks
405 (defcustom gnus-saved-mark ?S
406 "*Mark used for articles that have been saved to."
407 :group 'gnus-summary-marks
410 (defcustom gnus-ancient-mark ?O
411 "*Mark used for ancient articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-sparse-mark ?Q
416 "*Mark used for sparsely reffed articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-canceled-mark ?G
421 "*Mark used for canceled articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-duplicate-mark ?M
426 "*Mark used for duplicate articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-undownloaded-mark ?@
431 "*Mark used for articles that weren't downloaded."
432 :group 'gnus-summary-marks
435 (defcustom gnus-downloadable-mark ?%
436 "*Mark used for articles that are to be downloaded."
437 :group 'gnus-summary-marks
440 (defcustom gnus-unsendable-mark ?=
441 "*Mark used for articles that won't be sent."
442 :group 'gnus-summary-marks
445 (defcustom gnus-score-over-mark ?+
446 "*Score mark used for articles with high scores."
447 :group 'gnus-summary-marks
450 (defcustom gnus-score-below-mark ?-
451 "*Score mark used for articles with low scores."
452 :group 'gnus-summary-marks
455 (defcustom gnus-empty-thread-mark ?
456 "*There is no thread under the article."
457 :group 'gnus-summary-marks
460 (defcustom gnus-not-empty-thread-mark ?=
461 "*There is a thread under the article."
462 :group 'gnus-summary-marks
465 (defcustom gnus-view-pseudo-asynchronously nil
466 "*If non-nil, Gnus will view pseudo-articles asynchronously."
467 :group 'gnus-extract-view
470 (defcustom gnus-view-pseudos nil
471 "*If `automatic', pseudo-articles will be viewed automatically.
472 If `not-confirm', pseudos will be viewed automatically, and the user
473 will not be asked to confirm the command."
474 :group 'gnus-extract-view
475 :type '(choice (const :tag "off" nil)
477 (const not-confirm)))
479 (defcustom gnus-view-pseudos-separately t
480 "*If non-nil, one pseudo-article will be created for each file to be viewed.
481 If nil, all files that use the same viewing command will be given as a
482 list of parameters to that command."
483 :group 'gnus-extract-view
486 (defcustom gnus-insert-pseudo-articles t
487 "*If non-nil, insert pseudo-articles when decoding articles."
488 :group 'gnus-extract-view
491 (defcustom gnus-summary-dummy-line-format
493 "*The format specification for the dummy roots in the summary buffer.
494 It works along the same lines as a normal formatting string,
495 with some simple extensions.
498 :group 'gnus-threading
501 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
502 "*The format specification for the summary mode line.
503 It works along the same lines as a normal formatting string,
504 with some simple extensions:
507 %p Unprefixed group name
508 %A Current article number
510 %U Number of unread articles in the group
511 %e Number of unselected articles in the group
512 %Z A string with unread/unselected article counts
513 %g Shortish group name
514 %S Subject of the current article
516 %s Current score file name
517 %d Number of dormant articles
518 %r Number of articles that have been marked as read in this session
519 %E Number of articles expunged by the score files"
520 :group 'gnus-summary-format
523 (defcustom gnus-summary-mark-below 0
524 "*Mark all articles with a score below this variable as read.
525 This variable is local to each summary buffer and usually set by the
527 :group 'gnus-score-default
530 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
531 "*List of functions used for sorting articles in the summary buffer.
532 This variable is only used when not using a threaded display."
533 :group 'gnus-summary-sort
534 :type '(repeat (choice (function-item gnus-article-sort-by-number)
535 (function-item gnus-article-sort-by-author)
536 (function-item gnus-article-sort-by-subject)
537 (function-item gnus-article-sort-by-date)
538 (function-item gnus-article-sort-by-score)
539 (function :tag "other"))))
541 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
542 "*List of functions used for sorting threads in the summary buffer.
543 By default, threads are sorted by article number.
545 Each function takes two threads and return non-nil if the first thread
546 should be sorted before the other. If you use more than one function,
547 the primary sort function should be the last. You should probably
548 always include `gnus-thread-sort-by-number' in the list of sorting
549 functions -- preferably first.
551 Ready-made functions include `gnus-thread-sort-by-number',
552 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
553 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
554 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
555 :group 'gnus-summary-sort
556 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
557 (function-item gnus-thread-sort-by-author)
558 (function-item gnus-thread-sort-by-subject)
559 (function-item gnus-thread-sort-by-date)
560 (function-item gnus-thread-sort-by-score)
561 (function-item gnus-thread-sort-by-total-score)
562 (function :tag "other"))))
564 (defcustom gnus-thread-score-function '+
565 "*Function used for calculating the total score of a thread.
567 The function is called with the scores of the article and each
568 subthread and should then return the score of the thread.
570 Some functions you can use are `+', `max', or `min'."
571 :group 'gnus-summary-sort
574 (defcustom gnus-summary-expunge-below nil
575 "All articles that have a score less than this variable will be expunged.
576 This variable is local to the summary buffers."
577 :group 'gnus-score-default
578 :type '(choice (const :tag "off" nil)
581 (defcustom gnus-thread-expunge-below nil
582 "All threads that have a total score less than this variable will be expunged.
583 See `gnus-thread-score-function' for en explanation of what a
586 This variable is local to the summary buffers."
587 :group 'gnus-treading
588 :group 'gnus-score-default
589 :type '(choice (const :tag "off" nil)
592 (defcustom gnus-summary-mode-hook nil
593 "*A hook for Gnus summary mode.
594 This hook is run before any variables are set in the summary buffer."
595 :group 'gnus-summary-various
598 (defcustom gnus-summary-menu-hook nil
599 "*Hook run after the creation of the summary mode menu."
600 :group 'gnus-summary-visual
603 (defcustom gnus-summary-exit-hook nil
604 "*A hook called on exit from the summary buffer.
605 It will be called with point in the group buffer."
606 :group 'gnus-summary-exit
609 (defcustom gnus-summary-prepare-hook nil
610 "*A hook called after the summary buffer has been generated.
611 If you want to modify the summary buffer, you can use this hook."
612 :group 'gnus-summary-various
615 (defcustom gnus-summary-prepared-hook nil
616 "*A hook called as the last thing after the summary buffer has been generated."
617 :group 'gnus-summary-various
620 (defcustom gnus-summary-generate-hook nil
621 "*A hook run just before generating the summary buffer.
622 This hook is commonly used to customize threading variables and the
624 :group 'gnus-summary-various
627 (defcustom gnus-select-group-hook nil
628 "*A hook called when a newsgroup is selected.
630 If you'd like to simplify subjects like the
631 `gnus-summary-next-same-subject' command does, you can use the
634 (setq gnus-select-group-hook
637 (mapcar (lambda (header)
638 (mail-header-set-subject
640 (gnus-simplify-subject
641 (mail-header-subject header) 're-only)))
642 gnus-newsgroup-headers))))"
643 :group 'gnus-group-select
646 (defcustom gnus-select-article-hook nil
647 "*A hook called when an article is selected."
648 :group 'gnus-summary-choose
651 (defcustom gnus-visual-mark-article-hook
652 (list 'gnus-highlight-selected-summary)
653 "*Hook run after selecting an article in the summary buffer.
654 It is meant to be used for highlighting the article in some way. It
655 is not run if `gnus-visual' is nil."
656 :group 'gnus-summary-visual
659 (defcustom gnus-structured-field-decoder 'identity
660 "Function to decode non-ASCII characters in structured field for summary."
664 (defcustom gnus-unstructured-field-decoder 'identity
665 "Function to decode non-ASCII characters in unstructured field for summary."
669 (defcustom gnus-parse-headers-hook
670 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
671 "*A hook called before parsing the headers."
675 (defcustom gnus-exit-group-hook nil
676 "*A hook called when exiting (not quitting) summary mode."
680 (defcustom gnus-summary-update-hook
681 (list 'gnus-summary-highlight-line)
682 "*A hook called when a summary line is changed.
683 The hook will not be called if `gnus-visual' is nil.
685 The default function `gnus-summary-highlight-line' will
686 highlight the line according to the `gnus-summary-highlight'
688 :group 'gnus-summary-visual
691 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
692 "*A hook called when an article is selected for the first time.
693 The hook is intended to mark an article as read (or unread)
694 automatically when it is selected."
695 :group 'gnus-summary-choose
698 (defcustom gnus-group-no-more-groups-hook nil
699 "*A hook run when returning to group mode having no more (unread) groups."
700 :group 'gnus-group-select
703 (defcustom gnus-ps-print-hook nil
704 "*A hook run before ps-printing something from Gnus."
708 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
709 "Face used for highlighting the current article in the summary buffer."
710 :group 'gnus-summary-visual
713 (defcustom gnus-summary-highlight
714 '(((= mark gnus-canceled-mark)
715 . gnus-summary-cancelled-face)
716 ((and (> score default)
717 (or (= mark gnus-dormant-mark)
718 (= mark gnus-ticked-mark)))
719 . gnus-summary-high-ticked-face)
720 ((and (< score default)
721 (or (= mark gnus-dormant-mark)
722 (= mark gnus-ticked-mark)))
723 . gnus-summary-low-ticked-face)
724 ((or (= mark gnus-dormant-mark)
725 (= mark gnus-ticked-mark))
726 . gnus-summary-normal-ticked-face)
727 ((and (> score default) (= mark gnus-ancient-mark))
728 . gnus-summary-high-ancient-face)
729 ((and (< score default) (= mark gnus-ancient-mark))
730 . gnus-summary-low-ancient-face)
731 ((= mark gnus-ancient-mark)
732 . gnus-summary-normal-ancient-face)
733 ((and (> score default) (= mark gnus-unread-mark))
734 . gnus-summary-high-unread-face)
735 ((and (< score default) (= mark gnus-unread-mark))
736 . gnus-summary-low-unread-face)
737 ((= mark gnus-unread-mark)
738 . gnus-summary-normal-unread-face)
739 ((and (> score default) (memq mark (list gnus-downloadable-mark
740 gnus-undownloaded-mark)))
741 . gnus-summary-high-unread-face)
742 ((and (< score default) (memq mark (list gnus-downloadable-mark
743 gnus-undownloaded-mark)))
744 . gnus-summary-low-unread-face)
745 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
746 . gnus-summary-normal-unread-face)
748 . gnus-summary-high-read-face)
750 . gnus-summary-low-read-face)
752 . gnus-summary-normal-read-face))
753 "*Controls the highlighting of summary buffer lines.
755 A list of (FORM . FACE) pairs. When deciding how a a particular
756 summary line should be displayed, each form is evaluated. The content
757 of the face field after the first true form is used. You can change
758 how those summary lines are displayed, by editing the face field.
760 You can use the following variables in the FORM field.
762 score: The articles score
763 default: The default article score.
764 below: The score below which articles are automatically marked as read.
765 mark: The articles mark."
766 :group 'gnus-summary-visual
767 :type '(repeat (cons (sexp :tag "Form" nil)
770 (defcustom gnus-alter-header-function nil
771 "Function called to allow alteration of article header structures.
772 The function is called with one parameter, the article header vector,
773 which it may alter in any way.")
775 ;;; Internal variables
777 (defvar gnus-scores-exclude-files nil)
778 (defvar gnus-page-broken nil)
780 (defvar gnus-original-article nil)
781 (defvar gnus-article-internal-prepare-hook nil)
782 (defvar gnus-newsgroup-process-stack nil)
784 (defvar gnus-thread-indent-array nil)
785 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
787 ;; Avoid highlighting in kill files.
788 (defvar gnus-summary-inhibit-highlight nil)
789 (defvar gnus-newsgroup-selected-overlay nil)
790 (defvar gnus-inhibit-limiting nil)
791 (defvar gnus-newsgroup-adaptive-score-file nil)
792 (defvar gnus-current-score-file nil)
793 (defvar gnus-current-move-group nil)
794 (defvar gnus-current-copy-group nil)
795 (defvar gnus-current-crosspost-group nil)
797 (defvar gnus-newsgroup-dependencies nil)
798 (defvar gnus-newsgroup-adaptive nil)
799 (defvar gnus-summary-display-article-function nil)
800 (defvar gnus-summary-highlight-line-function nil
801 "Function called after highlighting a summary line.")
803 (defvar gnus-summary-line-format-alist
804 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
805 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
806 (?s gnus-tmp-subject-or-nil ?s)
807 (?n gnus-tmp-name ?s)
808 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
810 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
812 (?F gnus-tmp-from ?s)
813 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
814 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
815 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
816 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
817 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
818 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
819 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
820 (?L gnus-tmp-lines ?d)
821 (?I gnus-tmp-indentation ?s)
822 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
823 (?R gnus-tmp-replied ?c)
824 (?\[ gnus-tmp-opening-bracket ?c)
825 (?\] gnus-tmp-closing-bracket ?c)
826 (?\> (make-string gnus-tmp-level ? ) ?s)
827 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
828 (?i gnus-tmp-score ?d)
829 (?z gnus-tmp-score-char ?c)
830 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
831 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
832 (?U gnus-tmp-unread ?c)
833 (?t (gnus-summary-number-of-articles-in-thread
834 (and (boundp 'thread) (car thread)) gnus-tmp-level)
836 (?e (gnus-summary-number-of-articles-in-thread
837 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
839 (?u gnus-tmp-user-defined ?s)
840 (?P (gnus-pick-line-number) ?d))
841 "An alist of format specifications that can appear in summary lines,
842 and what variables they correspond with, along with the type of the
843 variable (string, integer, character, etc).")
845 (defvar gnus-summary-dummy-line-format-alist
846 `((?S gnus-tmp-subject ?s)
847 (?N gnus-tmp-number ?d)
848 (?u gnus-tmp-user-defined ?s)))
850 (defvar gnus-summary-mode-line-format-alist
851 `((?G gnus-tmp-group-name ?s)
852 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
853 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
854 (?A gnus-tmp-article-number ?d)
855 (?Z gnus-tmp-unread-and-unselected ?s)
857 (?U gnus-tmp-unread-and-unticked ?d)
858 (?S gnus-tmp-subject ?s)
859 (?e gnus-tmp-unselected ?d)
860 (?u gnus-tmp-user-defined ?s)
861 (?d (length gnus-newsgroup-dormant) ?d)
862 (?t (length gnus-newsgroup-marked) ?d)
863 (?r (length gnus-newsgroup-reads) ?d)
864 (?E gnus-newsgroup-expunged-tally ?d)
865 (?s (gnus-current-score-file-nondirectory) ?s)))
867 (defvar gnus-last-search-regexp nil
868 "Default regexp for article search command.")
870 (defvar gnus-last-shell-command nil
871 "Default shell command on article.")
873 (defvar gnus-newsgroup-begin nil)
874 (defvar gnus-newsgroup-end nil)
875 (defvar gnus-newsgroup-last-rmail nil)
876 (defvar gnus-newsgroup-last-mail nil)
877 (defvar gnus-newsgroup-last-folder nil)
878 (defvar gnus-newsgroup-last-file nil)
879 (defvar gnus-newsgroup-auto-expire nil)
880 (defvar gnus-newsgroup-active nil)
882 (defvar gnus-newsgroup-data nil)
883 (defvar gnus-newsgroup-data-reverse nil)
884 (defvar gnus-newsgroup-limit nil)
885 (defvar gnus-newsgroup-limits nil)
887 (defvar gnus-newsgroup-unreads nil
888 "List of unread articles in the current newsgroup.")
890 (defvar gnus-newsgroup-unselected nil
891 "List of unselected unread articles in the current newsgroup.")
893 (defvar gnus-newsgroup-reads nil
894 "Alist of read articles and article marks in the current newsgroup.")
896 (defvar gnus-newsgroup-expunged-tally nil)
898 (defvar gnus-newsgroup-marked nil
899 "List of ticked articles in the current newsgroup (a subset of unread art).")
901 (defvar gnus-newsgroup-killed nil
902 "List of ranges of articles that have been through the scoring process.")
904 (defvar gnus-newsgroup-cached nil
905 "List of articles that come from the article cache.")
907 (defvar gnus-newsgroup-saved nil
908 "List of articles that have been saved.")
910 (defvar gnus-newsgroup-kill-headers nil)
912 (defvar gnus-newsgroup-replied nil
913 "List of articles that have been replied to in the current newsgroup.")
915 (defvar gnus-newsgroup-expirable nil
916 "List of articles in the current newsgroup that can be expired.")
918 (defvar gnus-newsgroup-processable nil
919 "List of articles in the current newsgroup that can be processed.")
921 (defvar gnus-newsgroup-downloadable nil
922 "List of articles in the current newsgroup that can be processed.")
924 (defvar gnus-newsgroup-undownloaded nil
925 "List of articles in the current newsgroup that haven't been downloaded..")
927 (defvar gnus-newsgroup-unsendable nil
928 "List of articles in the current newsgroup that won't be sent.")
930 (defvar gnus-newsgroup-bookmarks nil
931 "List of articles in the current newsgroup that have bookmarks.")
933 (defvar gnus-newsgroup-dormant nil
934 "List of dormant articles in the current newsgroup.")
936 (defvar gnus-newsgroup-scored nil
937 "List of scored articles in the current newsgroup.")
939 (defvar gnus-newsgroup-headers nil
940 "List of article headers in the current newsgroup.")
942 (defvar gnus-newsgroup-threads nil)
944 (defvar gnus-newsgroup-prepared nil
945 "Whether the current group has been prepared properly.")
947 (defvar gnus-newsgroup-ancient nil
948 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
950 (defvar gnus-newsgroup-sparse nil)
952 (defvar gnus-current-article nil)
953 (defvar gnus-article-current nil)
954 (defvar gnus-current-headers nil)
955 (defvar gnus-have-all-headers nil)
956 (defvar gnus-last-article nil)
957 (defvar gnus-newsgroup-history nil)
959 (defconst gnus-summary-local-variables
960 '(gnus-newsgroup-name
961 gnus-newsgroup-begin gnus-newsgroup-end
962 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
963 gnus-newsgroup-last-folder gnus-newsgroup-last-file
964 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
965 gnus-newsgroup-unselected gnus-newsgroup-marked
966 gnus-newsgroup-reads gnus-newsgroup-saved
967 gnus-newsgroup-replied gnus-newsgroup-expirable
968 gnus-newsgroup-processable gnus-newsgroup-killed
969 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
970 gnus-newsgroup-unsendable
971 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
972 gnus-newsgroup-headers gnus-newsgroup-threads
973 gnus-newsgroup-prepared gnus-summary-highlight-line-function
974 gnus-current-article gnus-current-headers gnus-have-all-headers
975 gnus-last-article gnus-article-internal-prepare-hook
976 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
977 gnus-newsgroup-scored gnus-newsgroup-kill-headers
978 gnus-thread-expunge-below
979 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
980 (gnus-summary-mark-below . global)
981 gnus-newsgroup-active gnus-scores-exclude-files
982 gnus-newsgroup-history gnus-newsgroup-ancient
983 gnus-newsgroup-sparse gnus-newsgroup-process-stack
984 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
985 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
986 (gnus-newsgroup-expunged-tally . 0)
987 gnus-cache-removable-articles gnus-newsgroup-cached
988 gnus-newsgroup-data gnus-newsgroup-data-reverse
989 gnus-newsgroup-limit gnus-newsgroup-limits)
990 "Variables that are buffer-local to the summary buffers.")
992 ;; Byte-compiler warning.
993 (defvar gnus-article-mode-map)
995 ;; Subject simplification.
997 (defun gnus-simplify-whitespace (str)
998 "Remove excessive whitespace."
1001 (while (string-match "[ \t][ \t]+" mystr)
1002 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1004 (substring mystr (match-end 0)))))
1006 (when (string-match "^[ \t]+" mystr)
1007 (setq mystr (substring mystr (match-end 0))))
1009 (when (string-match "[ \t]+$" mystr)
1010 (setq mystr (substring mystr 0 (match-beginning 0))))
1013 (defsubst gnus-simplify-subject-re (subject)
1014 "Remove \"Re:\" from subject lines."
1015 (if (string-match "^[Rr][Ee]: *" subject)
1016 (substring subject (match-end 0))
1019 (defun gnus-simplify-subject (subject &optional re-only)
1020 "Remove `Re:' and words in parentheses.
1021 If RE-ONLY is non-nil, strip leading `Re:'s only."
1022 (let ((case-fold-search t)) ;Ignore case.
1023 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1024 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1025 (setq subject (substring subject (match-end 0))))
1026 ;; Remove uninteresting prefixes.
1027 (when (and (not re-only)
1028 gnus-simplify-ignored-prefixes
1029 (string-match gnus-simplify-ignored-prefixes subject))
1030 (setq subject (substring subject (match-end 0))))
1031 ;; Remove words in parentheses from end.
1033 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1034 (setq subject (substring subject 0 (match-beginning 0)))))
1035 ;; Return subject string.
1038 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1040 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1041 (goto-char (point-min))
1042 (while (re-search-forward regexp nil t)
1043 (replace-match (or newtext ""))))
1045 (defun gnus-simplify-buffer-fuzzy ()
1046 "Simplify string in the buffer fuzzily.
1047 The string in the accessible portion of the current buffer is simplified.
1048 It is assumed to be a single-line subject.
1049 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1050 matter is removed. Additional things can be deleted by setting
1051 gnus-simplify-subject-fuzzy-regexp."
1052 (let ((case-fold-search t)
1054 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1056 (while (not (eq modified-tick (buffer-modified-tick)))
1057 (setq modified-tick (buffer-modified-tick))
1059 ((listp gnus-simplify-subject-fuzzy-regexp)
1060 (mapcar 'gnus-simplify-buffer-fuzzy-step
1061 gnus-simplify-subject-fuzzy-regexp))
1062 (gnus-simplify-subject-fuzzy-regexp
1063 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1064 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1065 (gnus-simplify-buffer-fuzzy-step
1066 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1067 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1069 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1070 (gnus-simplify-buffer-fuzzy-step " +" " ")
1071 (gnus-simplify-buffer-fuzzy-step " $")
1072 (gnus-simplify-buffer-fuzzy-step "^ +")))
1074 (defun gnus-simplify-subject-fuzzy (subject)
1075 "Simplify a subject string fuzzily.
1076 See `gnus-simplify-buffer-fuzzy' for details."
1078 (gnus-set-work-buffer)
1079 (let ((case-fold-search t))
1080 ;; Remove uninteresting prefixes.
1081 (when (and gnus-simplify-ignored-prefixes
1082 (string-match gnus-simplify-ignored-prefixes subject))
1083 (setq subject (substring subject (match-end 0))))
1085 (inline (gnus-simplify-buffer-fuzzy))
1088 (defsubst gnus-simplify-subject-fully (subject)
1089 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1091 (gnus-simplify-subject-functions
1092 (gnus-map-function gnus-simplify-subject-functions subject))
1093 ((null gnus-summary-gather-subject-limit)
1094 (gnus-simplify-subject-re subject))
1095 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1096 (gnus-simplify-subject-fuzzy subject))
1097 ((numberp gnus-summary-gather-subject-limit)
1098 (gnus-limit-string (gnus-simplify-subject-re subject)
1099 gnus-summary-gather-subject-limit))
1103 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1104 "Check whether two subjects are equal.
1105 If optional argument simple-first is t, first argument is already
1108 ((null simple-first)
1109 (equal (gnus-simplify-subject-fully s1)
1110 (gnus-simplify-subject-fully s2)))
1113 (gnus-simplify-subject-fully s2)))))
1115 (defun gnus-summary-bubble-group ()
1116 "Increase the score of the current group.
1117 This is a handy function to add to `gnus-summary-exit-hook' to
1118 increase the score of each group you read."
1119 (gnus-group-add-score gnus-newsgroup-name))
1123 ;;; Gnus summary mode
1126 (put 'gnus-summary-mode 'mode-class 'special)
1129 ;; Non-orthogonal keys
1131 (gnus-define-keys gnus-summary-mode-map
1132 " " gnus-summary-next-page
1133 "\177" gnus-summary-prev-page
1134 [delete] gnus-summary-prev-page
1135 [backspace] gnus-summary-prev-page
1136 "\r" gnus-summary-scroll-up
1137 "n" gnus-summary-next-unread-article
1138 "p" gnus-summary-prev-unread-article
1139 "N" gnus-summary-next-article
1140 "P" gnus-summary-prev-article
1141 "\M-\C-n" gnus-summary-next-same-subject
1142 "\M-\C-p" gnus-summary-prev-same-subject
1143 "\M-n" gnus-summary-next-unread-subject
1144 "\M-p" gnus-summary-prev-unread-subject
1145 "." gnus-summary-first-unread-article
1146 "," gnus-summary-best-unread-article
1147 "\M-s" gnus-summary-search-article-forward
1148 "\M-r" gnus-summary-search-article-backward
1149 "<" gnus-summary-beginning-of-article
1150 ">" gnus-summary-end-of-article
1151 "j" gnus-summary-goto-article
1152 "^" gnus-summary-refer-parent-article
1153 "\M-^" gnus-summary-refer-article
1154 "u" gnus-summary-tick-article-forward
1155 "!" gnus-summary-tick-article-forward
1156 "U" gnus-summary-tick-article-backward
1157 "d" gnus-summary-mark-as-read-forward
1158 "D" gnus-summary-mark-as-read-backward
1159 "E" gnus-summary-mark-as-expirable
1160 "\M-u" gnus-summary-clear-mark-forward
1161 "\M-U" gnus-summary-clear-mark-backward
1162 "k" gnus-summary-kill-same-subject-and-select
1163 "\C-k" gnus-summary-kill-same-subject
1164 "\M-\C-k" gnus-summary-kill-thread
1165 "\M-\C-l" gnus-summary-lower-thread
1166 "e" gnus-summary-edit-article
1167 "#" gnus-summary-mark-as-processable
1168 "\M-#" gnus-summary-unmark-as-processable
1169 "\M-\C-t" gnus-summary-toggle-threads
1170 "\M-\C-s" gnus-summary-show-thread
1171 "\M-\C-h" gnus-summary-hide-thread
1172 "\M-\C-f" gnus-summary-next-thread
1173 "\M-\C-b" gnus-summary-prev-thread
1174 "\M-\C-u" gnus-summary-up-thread
1175 "\M-\C-d" gnus-summary-down-thread
1176 "&" gnus-summary-execute-command
1177 "c" gnus-summary-catchup-and-exit
1178 "\C-w" gnus-summary-mark-region-as-read
1179 "\C-t" gnus-summary-toggle-truncation
1180 "?" gnus-summary-mark-as-dormant
1181 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1182 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1183 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1184 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1185 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1186 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1187 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1188 "=" gnus-summary-expand-window
1189 "\C-x\C-s" gnus-summary-reselect-current-group
1190 "\M-g" gnus-summary-rescan-group
1191 "w" gnus-summary-stop-page-breaking
1192 "\C-c\C-r" gnus-summary-caesar-message
1193 "\M-t" gnus-summary-toggle-mime
1194 "f" gnus-summary-followup
1195 "F" gnus-summary-followup-with-original
1196 "C" gnus-summary-cancel-article
1197 "r" gnus-summary-reply
1198 "R" gnus-summary-reply-with-original
1199 "\C-c\C-f" gnus-summary-mail-forward
1200 "o" gnus-summary-save-article
1201 "\C-o" gnus-summary-save-article-mail
1202 "|" gnus-summary-pipe-output
1203 "\M-k" gnus-summary-edit-local-kill
1204 "\M-K" gnus-summary-edit-global-kill
1206 "\C-c\C-d" gnus-summary-describe-group
1207 "q" gnus-summary-exit
1208 "Q" gnus-summary-exit-no-update
1209 "\C-c\C-i" gnus-info-find-node
1210 gnus-mouse-2 gnus-mouse-pick-article
1211 "m" gnus-summary-mail-other-window
1212 "a" gnus-summary-post-news
1213 "x" gnus-summary-limit-to-unread
1214 "s" gnus-summary-isearch-article
1215 "t" gnus-article-hide-headers
1216 "g" gnus-summary-show-article
1217 "l" gnus-summary-goto-last-article
1218 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1219 "\C-d" gnus-summary-enter-digest-group
1220 "\M-\C-d" gnus-summary-read-document
1221 "\M-\C-e" gnus-summary-edit-parameters
1223 "*" gnus-cache-enter-article
1224 "\M-*" gnus-cache-remove-article
1225 "\M-&" gnus-summary-universal-argument
1226 "\C-l" gnus-recenter
1227 "I" gnus-summary-increase-score
1228 "L" gnus-summary-lower-score
1229 "\M-i" gnus-symbolic-argument
1230 "h" gnus-summary-select-article-buffer
1232 "V" gnus-summary-score-map
1233 "X" gnus-uu-extract-map
1234 "S" gnus-summary-send-map)
1236 ;; Sort of orthogonal keymap
1237 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1238 "t" gnus-summary-tick-article-forward
1239 "!" gnus-summary-tick-article-forward
1240 "d" gnus-summary-mark-as-read-forward
1241 "r" gnus-summary-mark-as-read-forward
1242 "c" gnus-summary-clear-mark-forward
1243 " " gnus-summary-clear-mark-forward
1244 "e" gnus-summary-mark-as-expirable
1245 "x" gnus-summary-mark-as-expirable
1246 "?" gnus-summary-mark-as-dormant
1247 "b" gnus-summary-set-bookmark
1248 "B" gnus-summary-remove-bookmark
1249 "#" gnus-summary-mark-as-processable
1250 "\M-#" gnus-summary-unmark-as-processable
1251 "S" gnus-summary-limit-include-expunged
1252 "C" gnus-summary-catchup
1253 "H" gnus-summary-catchup-to-here
1254 "\C-c" gnus-summary-catchup-all
1255 "k" gnus-summary-kill-same-subject-and-select
1256 "K" gnus-summary-kill-same-subject
1257 "P" gnus-uu-mark-map)
1259 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1260 "c" gnus-summary-clear-above
1261 "u" gnus-summary-tick-above
1262 "m" gnus-summary-mark-above
1263 "k" gnus-summary-kill-below)
1265 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1266 "/" gnus-summary-limit-to-subject
1267 "n" gnus-summary-limit-to-articles
1268 "w" gnus-summary-pop-limit
1269 "s" gnus-summary-limit-to-subject
1270 "a" gnus-summary-limit-to-author
1271 "u" gnus-summary-limit-to-unread
1272 "m" gnus-summary-limit-to-marks
1273 "v" gnus-summary-limit-to-score
1274 "*" gnus-summary-limit-include-cached
1275 "D" gnus-summary-limit-include-dormant
1276 "T" gnus-summary-limit-include-thread
1277 "d" gnus-summary-limit-exclude-dormant
1278 "t" gnus-summary-limit-to-age
1279 "E" gnus-summary-limit-include-expunged
1280 "c" gnus-summary-limit-exclude-childless-dormant
1281 "C" gnus-summary-limit-mark-excluded-as-read)
1283 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1284 "n" gnus-summary-next-unread-article
1285 "p" gnus-summary-prev-unread-article
1286 "N" gnus-summary-next-article
1287 "P" gnus-summary-prev-article
1288 "\C-n" gnus-summary-next-same-subject
1289 "\C-p" gnus-summary-prev-same-subject
1290 "\M-n" gnus-summary-next-unread-subject
1291 "\M-p" gnus-summary-prev-unread-subject
1292 "f" gnus-summary-first-unread-article
1293 "b" gnus-summary-best-unread-article
1294 "j" gnus-summary-goto-article
1295 "g" gnus-summary-goto-subject
1296 "l" gnus-summary-goto-last-article
1297 "o" gnus-summary-pop-article)
1299 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1300 "k" gnus-summary-kill-thread
1301 "l" gnus-summary-lower-thread
1302 "i" gnus-summary-raise-thread
1303 "T" gnus-summary-toggle-threads
1304 "t" gnus-summary-rethread-current
1305 "^" gnus-summary-reparent-thread
1306 "s" gnus-summary-show-thread
1307 "S" gnus-summary-show-all-threads
1308 "h" gnus-summary-hide-thread
1309 "H" gnus-summary-hide-all-threads
1310 "n" gnus-summary-next-thread
1311 "p" gnus-summary-prev-thread
1312 "u" gnus-summary-up-thread
1313 "o" gnus-summary-top-thread
1314 "d" gnus-summary-down-thread
1315 "#" gnus-uu-mark-thread
1316 "\M-#" gnus-uu-unmark-thread)
1318 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1319 "g" gnus-summary-prepare
1320 "c" gnus-summary-insert-cached-articles)
1322 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1323 "c" gnus-summary-catchup-and-exit
1324 "C" gnus-summary-catchup-all-and-exit
1325 "E" gnus-summary-exit-no-update
1326 "Q" gnus-summary-exit
1327 "Z" gnus-summary-exit
1328 "n" gnus-summary-catchup-and-goto-next-group
1329 "R" gnus-summary-reselect-current-group
1330 "G" gnus-summary-rescan-group
1331 "N" gnus-summary-next-group
1332 "s" gnus-summary-save-newsrc
1333 "P" gnus-summary-prev-group)
1335 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1336 " " gnus-summary-next-page
1337 "n" gnus-summary-next-page
1338 "\177" gnus-summary-prev-page
1339 [delete] gnus-summary-prev-page
1340 "p" gnus-summary-prev-page
1341 "\r" gnus-summary-scroll-up
1342 "<" gnus-summary-beginning-of-article
1343 ">" gnus-summary-end-of-article
1344 "b" gnus-summary-beginning-of-article
1345 "e" gnus-summary-end-of-article
1346 "^" gnus-summary-refer-parent-article
1347 "r" gnus-summary-refer-parent-article
1348 "R" gnus-summary-refer-references
1349 "T" gnus-summary-refer-thread
1350 "g" gnus-summary-show-article
1351 "s" gnus-summary-isearch-article
1352 "P" gnus-summary-print-article)
1354 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1355 "b" gnus-article-add-buttons
1356 "B" gnus-article-add-buttons-to-head
1357 "o" gnus-article-treat-overstrike
1358 "e" gnus-article-emphasize
1359 "w" gnus-article-fill-cited-article
1360 "c" gnus-article-remove-cr
1361 "q" gnus-article-de-quoted-unreadable
1362 "f" gnus-article-display-x-face
1363 "l" gnus-summary-stop-page-breaking
1364 "r" gnus-summary-caesar-message
1365 "t" gnus-article-hide-headers
1366 "v" gnus-summary-verbose-headers
1367 "m" gnus-summary-toggle-mime
1368 "h" gnus-article-treat-html
1369 "d" gnus-article-treat-dumbquotes)
1371 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1372 "a" gnus-article-hide
1373 "h" gnus-article-hide-headers
1374 "b" gnus-article-hide-boring-headers
1375 "s" gnus-article-hide-signature
1376 "c" gnus-article-hide-citation
1377 "p" gnus-article-hide-pgp
1378 "P" gnus-article-hide-pem
1379 "\C-c" gnus-article-hide-citation-maybe)
1381 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1382 "a" gnus-article-highlight
1383 "h" gnus-article-highlight-headers
1384 "c" gnus-article-highlight-citation
1385 "s" gnus-article-highlight-signature)
1387 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1388 "z" gnus-article-date-ut
1389 "u" gnus-article-date-ut
1390 "l" gnus-article-date-local
1391 "e" gnus-article-date-lapsed
1392 "o" gnus-article-date-original
1393 "i" gnus-article-date-iso8601
1394 "s" gnus-article-date-user)
1396 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1397 "t" gnus-article-remove-trailing-blank-lines
1398 "l" gnus-article-strip-leading-blank-lines
1399 "m" gnus-article-strip-multiple-blank-lines
1400 "a" gnus-article-strip-blank-lines
1401 "A" gnus-article-strip-all-blank-lines
1402 "s" gnus-article-strip-leading-space)
1404 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1406 "f" gnus-summary-fetch-faq
1407 "d" gnus-summary-describe-group
1408 "h" gnus-summary-describe-briefly
1409 "i" gnus-info-find-node)
1411 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1412 "e" gnus-summary-expire-articles
1413 "\M-\C-e" gnus-summary-expire-articles-now
1414 "\177" gnus-summary-delete-article
1415 [delete] gnus-summary-delete-article
1416 "m" gnus-summary-move-article
1417 "r" gnus-summary-respool-article
1418 "w" gnus-summary-edit-article
1419 "c" gnus-summary-copy-article
1420 "B" gnus-summary-crosspost-article
1421 "q" gnus-summary-respool-query
1422 "i" gnus-summary-import-article
1423 "p" gnus-summary-article-posted-p)
1425 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1426 "o" gnus-summary-save-article
1427 "m" gnus-summary-save-article-mail
1428 "F" gnus-summary-write-article-file
1429 "r" gnus-summary-save-article-rmail
1430 "f" gnus-summary-save-article-file
1431 "b" gnus-summary-save-article-body-file
1432 "h" gnus-summary-save-article-folder
1433 "v" gnus-summary-save-article-vm
1434 "p" gnus-summary-pipe-output
1435 "s" gnus-soup-add-article))
1437 (defun gnus-summary-make-menu-bar ()
1438 (gnus-turn-off-edit-menu 'summary)
1440 (unless (boundp 'gnus-summary-misc-menu)
1443 gnus-summary-kill-menu gnus-summary-mode-map ""
1448 ["Enter score..." gnus-summary-score-entry t]
1449 ["Customize" gnus-score-customize t])
1450 (gnus-make-score-map 'increase)
1451 (gnus-make-score-map 'lower)
1453 ["Kill below" gnus-summary-kill-below t]
1454 ["Mark above" gnus-summary-mark-above t]
1455 ["Tick above" gnus-summary-tick-above t]
1456 ["Clear above" gnus-summary-clear-above t])
1457 ["Current score" gnus-summary-current-score t]
1458 ["Set score" gnus-summary-set-score t]
1459 ["Switch current score file..." gnus-score-change-score-file t]
1460 ["Set mark below..." gnus-score-set-mark-below t]
1461 ["Set expunge below..." gnus-score-set-expunge-below t]
1462 ["Edit current score file" gnus-score-edit-current-scores t]
1463 ["Edit score file" gnus-score-edit-file t]
1464 ["Trace score" gnus-score-find-trace t]
1465 ["Find words" gnus-score-find-favourite-words t]
1466 ["Rescore buffer" gnus-summary-rescore t]
1467 ["Increase score..." gnus-summary-increase-score t]
1468 ["Lower score..." gnus-summary-lower-score t]))))
1471 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1473 :selected (null gnus-score-default-header)]
1474 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1476 :selected (eq gnus-score-default-header 'a)]
1477 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1479 :selected (eq gnus-score-default-header 's)]
1481 (gnus-score-set-default 'gnus-score-default-header 'b)
1483 :selected (eq gnus-score-default-header 'b )]
1485 (gnus-score-set-default 'gnus-score-default-header 'h)
1487 :selected (eq gnus-score-default-header 'h )]
1488 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1490 :selected (eq gnus-score-default-header 'i )]
1491 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1493 :selected (eq gnus-score-default-header 't )]
1495 (gnus-score-set-default 'gnus-score-default-header 'x)
1497 :selected (eq gnus-score-default-header 'x )]
1498 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1500 :selected (eq gnus-score-default-header 'l )]
1501 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1503 :selected (eq gnus-score-default-header 'd )]
1504 ["Followups to author"
1505 (gnus-score-set-default 'gnus-score-default-header 'f)
1507 :selected (eq gnus-score-default-header 'f )])
1509 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1511 :selected (null gnus-score-default-type)]
1512 ;; The `:active' key is commented out in the following,
1513 ;; because the GNU Emacs hack to support radio buttons use
1514 ;; active to indicate which button is selected.
1515 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1517 ;; :active (not (memq gnus-score-default-header '(l d)))
1518 :selected (eq gnus-score-default-type 's)]
1519 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1521 ;; :active (not (memq gnus-score-default-header '(l d)))
1522 :selected (eq gnus-score-default-type 'r)]
1523 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1525 ;; :active (not (memq gnus-score-default-header '(l d)))
1526 :selected (eq gnus-score-default-type 'e)]
1527 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1529 ;; :active (not (memq gnus-score-default-header '(l d)))
1530 :selected (eq gnus-score-default-type 'f)]
1531 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1533 ;; :active (eq (gnus-score-default-header 'd))
1534 :selected (eq gnus-score-default-type 'b)]
1535 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1537 ;; :active (eq (gnus-score-default-header 'd))
1538 :selected (eq gnus-score-default-type 'n)]
1539 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1541 ;; :active (eq (gnus-score-default-header 'd))
1542 :selected (eq gnus-score-default-type 'a)]
1544 (gnus-score-set-default 'gnus-score-default-type '<)
1546 ;; :active (eq (gnus-score-default-header 'l))
1547 :selected (eq gnus-score-default-type '<)]
1549 (gnus-score-set-default 'gnus-score-default-type '=)
1551 ;; :active (eq (gnus-score-default-header 'l))
1552 :selected (eq gnus-score-default-type '=)]
1553 ["Greater than number"
1554 (gnus-score-set-default 'gnus-score-default-type '>)
1556 ;; :active (eq (gnus-score-default-header 'l))
1557 :selected (eq gnus-score-default-type '>)])
1558 ["Default fold" gnus-score-default-fold-toggle
1560 :selected gnus-score-default-fold]
1562 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1564 :selected (null gnus-score-default-duration)]
1566 (gnus-score-set-default 'gnus-score-default-duration 'p)
1568 :selected (eq gnus-score-default-duration 'p)]
1570 (gnus-score-set-default 'gnus-score-default-duration 't)
1572 :selected (eq gnus-score-default-duration 't)]
1574 (gnus-score-set-default 'gnus-score-default-duration 'i)
1576 :selected (eq gnus-score-default-duration 'i)]))
1579 gnus-summary-article-menu gnus-summary-mode-map ""
1582 ["All" gnus-article-hide t]
1583 ["Headers" gnus-article-hide-headers t]
1584 ["Signature" gnus-article-hide-signature t]
1585 ["Citation" gnus-article-hide-citation t]
1586 ["PGP" gnus-article-hide-pgp t]
1587 ["Boring headers" gnus-article-hide-boring-headers t])
1589 ["All" gnus-article-highlight t]
1590 ["Headers" gnus-article-highlight-headers t]
1591 ["Signature" gnus-article-highlight-signature t]
1592 ["Citation" gnus-article-highlight-citation t])
1594 ["Local" gnus-article-date-local t]
1595 ["ISO8601" gnus-article-date-iso8601 t]
1596 ["UT" gnus-article-date-ut t]
1597 ["Original" gnus-article-date-original t]
1598 ["Lapsed" gnus-article-date-lapsed t]
1599 ["User-defined" gnus-article-date-user t])
1602 ["Leading" gnus-article-strip-leading-blank-lines t]
1603 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1604 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1605 ["All of the above" gnus-article-strip-blank-lines t]
1606 ["All" gnus-article-strip-all-blank-lines t]
1607 ["Leading space" gnus-article-strip-leading-space t])
1608 ["Overstrike" gnus-article-treat-overstrike t]
1609 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1610 ["Emphasis" gnus-article-emphasize t]
1611 ["Word wrap" gnus-article-fill-cited-article t]
1612 ["CR" gnus-article-remove-cr t]
1613 ["Show X-Face" gnus-article-display-x-face t]
1614 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1615 ["UnHTMLize" gnus-article-treat-html t]
1616 ["Rot 13" gnus-summary-caesar-message t]
1617 ["Unix pipe" gnus-summary-pipe-message t]
1618 ["Add buttons" gnus-article-add-buttons t]
1619 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1620 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1621 ["Toggle MIME" gnus-summary-toggle-mime t]
1622 ["Verbose header" gnus-summary-verbose-headers t]
1623 ["Toggle header" gnus-summary-toggle-header t])
1625 ["Save in default format" gnus-summary-save-article t]
1626 ["Save in file" gnus-summary-save-article-file t]
1627 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1628 ["Save in MH folder" gnus-summary-save-article-folder t]
1629 ["Save in VM folder" gnus-summary-save-article-vm t]
1630 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1631 ["Save body in file" gnus-summary-save-article-body-file t]
1632 ["Pipe through a filter" gnus-summary-pipe-output t]
1633 ["Add to SOUP packet" gnus-soup-add-article t]
1634 ["Print" gnus-summary-print-article t])
1636 ["Respool article..." gnus-summary-respool-article t]
1637 ["Move article..." gnus-summary-move-article
1638 (gnus-check-backend-function
1639 'request-move-article gnus-newsgroup-name)]
1640 ["Copy article..." gnus-summary-copy-article t]
1641 ["Crosspost article..." gnus-summary-crosspost-article
1642 (gnus-check-backend-function
1643 'request-replace-article gnus-newsgroup-name)]
1644 ["Import file..." gnus-summary-import-article t]
1645 ["Check if posted" gnus-summary-article-posted-p t]
1646 ["Edit article" gnus-summary-edit-article
1647 (not (gnus-group-read-only-p))]
1648 ["Delete article" gnus-summary-delete-article
1649 (gnus-check-backend-function
1650 'request-expire-articles gnus-newsgroup-name)]
1651 ["Query respool" gnus-summary-respool-query t]
1652 ["Delete expirable articles" gnus-summary-expire-articles-now
1653 (gnus-check-backend-function
1654 'request-expire-articles gnus-newsgroup-name)])
1656 ["Uudecode" gnus-uu-decode-uu t]
1657 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1658 ["Unshar" gnus-uu-decode-unshar t]
1659 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1660 ["Save" gnus-uu-decode-save t]
1661 ["Binhex" gnus-uu-decode-binhex t]
1662 ["Postscript" gnus-uu-decode-postscript t])
1664 ["Enter article" gnus-cache-enter-article t]
1665 ["Remove article" gnus-cache-remove-article t])
1666 ["Select article buffer" gnus-summary-select-article-buffer t]
1667 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1668 ["Isearch article..." gnus-summary-isearch-article t]
1669 ["Beginning of the article" gnus-summary-beginning-of-article t]
1670 ["End of the article" gnus-summary-end-of-article t]
1671 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1672 ["Fetch referenced articles" gnus-summary-refer-references t]
1673 ["Fetch current thread" gnus-summary-refer-thread t]
1674 ["Fetch article with id..." gnus-summary-refer-article t]
1675 ["Redisplay" gnus-summary-show-article t]))
1678 gnus-summary-thread-menu gnus-summary-mode-map ""
1680 ["Toggle threading" gnus-summary-toggle-threads t]
1681 ["Hide threads" gnus-summary-hide-all-threads t]
1682 ["Show threads" gnus-summary-show-all-threads t]
1683 ["Hide thread" gnus-summary-hide-thread t]
1684 ["Show thread" gnus-summary-show-thread t]
1685 ["Go to next thread" gnus-summary-next-thread t]
1686 ["Go to previous thread" gnus-summary-prev-thread t]
1687 ["Go down thread" gnus-summary-down-thread t]
1688 ["Go up thread" gnus-summary-up-thread t]
1689 ["Top of thread" gnus-summary-top-thread t]
1690 ["Mark thread as read" gnus-summary-kill-thread t]
1691 ["Lower thread score" gnus-summary-lower-thread t]
1692 ["Raise thread score" gnus-summary-raise-thread t]
1693 ["Rethread current" gnus-summary-rethread-current t]
1697 gnus-summary-post-menu gnus-summary-mode-map ""
1699 ["Post an article" gnus-summary-post-news t]
1700 ["Followup" gnus-summary-followup t]
1701 ["Followup and yank" gnus-summary-followup-with-original t]
1702 ["Supersede article" gnus-summary-supersede-article t]
1703 ["Cancel article" gnus-summary-cancel-article t]
1704 ["Reply" gnus-summary-reply t]
1705 ["Reply and yank" gnus-summary-reply-with-original t]
1706 ["Wide reply" gnus-summary-wide-reply t]
1707 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1708 ["Mail forward" gnus-summary-mail-forward t]
1709 ["Post forward" gnus-summary-post-forward t]
1710 ["Digest and mail" gnus-uu-digest-mail-forward t]
1711 ["Digest and post" gnus-uu-digest-post-forward t]
1712 ["Resend message" gnus-summary-resend-message t]
1713 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1714 ["Send a mail" gnus-summary-mail-other-window t]
1715 ["Uuencode and post" gnus-uu-post-news t]
1716 ["Followup via news" gnus-summary-followup-to-mail t]
1717 ["Followup via news and yank"
1718 gnus-summary-followup-to-mail-with-original t]
1720 ;;["Send" gnus-summary-send-draft t]
1721 ;;["Send bounced" gnus-resend-bounced-mail t])
1725 gnus-summary-misc-menu gnus-summary-mode-map ""
1728 ["Mark as read" gnus-summary-mark-as-read-forward t]
1729 ["Mark same subject and select"
1730 gnus-summary-kill-same-subject-and-select t]
1731 ["Mark same subject" gnus-summary-kill-same-subject t]
1732 ["Catchup" gnus-summary-catchup t]
1733 ["Catchup all" gnus-summary-catchup-all t]
1734 ["Catchup to here" gnus-summary-catchup-to-here t]
1735 ["Catchup region" gnus-summary-mark-region-as-read t]
1736 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1738 ["Tick" gnus-summary-tick-article-forward t]
1739 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1740 ["Remove marks" gnus-summary-clear-mark-forward t]
1741 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1742 ["Set bookmark" gnus-summary-set-bookmark t]
1743 ["Remove bookmark" gnus-summary-remove-bookmark t])
1745 ["Marks..." gnus-summary-limit-to-marks t]
1746 ["Subject..." gnus-summary-limit-to-subject t]
1747 ["Author..." gnus-summary-limit-to-author t]
1748 ["Age..." gnus-summary-limit-to-age t]
1749 ["Score" gnus-summary-limit-to-score t]
1750 ["Unread" gnus-summary-limit-to-unread t]
1751 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1752 ["Articles" gnus-summary-limit-to-articles t]
1753 ["Pop limit" gnus-summary-pop-limit t]
1754 ["Show dormant" gnus-summary-limit-include-dormant t]
1755 ["Hide childless dormant"
1756 gnus-summary-limit-exclude-childless-dormant t]
1757 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1758 ["Show expunged" gnus-summary-show-all-expunged t])
1760 ["Set mark" gnus-summary-mark-as-processable t]
1761 ["Remove mark" gnus-summary-unmark-as-processable t]
1762 ["Remove all marks" gnus-summary-unmark-all-processable t]
1763 ["Mark above" gnus-uu-mark-over t]
1764 ["Mark series" gnus-uu-mark-series t]
1765 ["Mark region" gnus-uu-mark-region t]
1766 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1767 ["Mark all" gnus-uu-mark-all t]
1768 ["Mark buffer" gnus-uu-mark-buffer t]
1769 ["Mark sparse" gnus-uu-mark-sparse t]
1770 ["Mark thread" gnus-uu-mark-thread t]
1771 ["Unmark thread" gnus-uu-unmark-thread t]
1772 ("Process Mark Sets"
1773 ["Kill" gnus-summary-kill-process-mark t]
1774 ["Yank" gnus-summary-yank-process-mark
1775 gnus-newsgroup-process-stack]
1776 ["Save" gnus-summary-save-process-mark t]))
1778 ["Page forward" gnus-summary-next-page t]
1779 ["Page backward" gnus-summary-prev-page t]
1780 ["Line forward" gnus-summary-scroll-up t])
1782 ["Next unread article" gnus-summary-next-unread-article t]
1783 ["Previous unread article" gnus-summary-prev-unread-article t]
1784 ["Next article" gnus-summary-next-article t]
1785 ["Previous article" gnus-summary-prev-article t]
1786 ["Next unread subject" gnus-summary-next-unread-subject t]
1787 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1788 ["Next article same subject" gnus-summary-next-same-subject t]
1789 ["Previous article same subject" gnus-summary-prev-same-subject t]
1790 ["First unread article" gnus-summary-first-unread-article t]
1791 ["Best unread article" gnus-summary-best-unread-article t]
1792 ["Go to subject number..." gnus-summary-goto-subject t]
1793 ["Go to article number..." gnus-summary-goto-article t]
1794 ["Go to the last article" gnus-summary-goto-last-article t]
1795 ["Pop article off history" gnus-summary-pop-article t])
1797 ["Sort by number" gnus-summary-sort-by-number t]
1798 ["Sort by author" gnus-summary-sort-by-author t]
1799 ["Sort by subject" gnus-summary-sort-by-subject t]
1800 ["Sort by date" gnus-summary-sort-by-date t]
1801 ["Sort by score" gnus-summary-sort-by-score t]
1802 ["Sort by lines" gnus-summary-sort-by-lines t])
1804 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1805 ["Describe group" gnus-summary-describe-group t]
1806 ["Read manual" gnus-info-find-node t])
1808 ["Pick and read" gnus-pick-mode t]
1809 ["Binary" gnus-binary-mode t])
1811 ["Regenerate" gnus-summary-prepare t]
1812 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1813 ["Toggle threading" gnus-summary-toggle-threads t])
1814 ["Filter articles..." gnus-summary-execute-command t]
1815 ["Run command on subjects..." gnus-summary-universal-argument t]
1816 ["Search articles forward..." gnus-summary-search-article-forward t]
1817 ["Search articles backward..." gnus-summary-search-article-backward t]
1818 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1819 ["Expand window" gnus-summary-expand-window t]
1820 ["Expire expirable articles" gnus-summary-expire-articles
1821 (gnus-check-backend-function
1822 'request-expire-articles gnus-newsgroup-name)]
1823 ["Edit local kill file" gnus-summary-edit-local-kill t]
1824 ["Edit main kill file" gnus-summary-edit-global-kill t]
1825 ["Edit group parameters" gnus-summary-edit-parameters t]
1827 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1828 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1829 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1830 ["Exit group" gnus-summary-exit t]
1831 ["Exit group without updating" gnus-summary-exit-no-update t]
1832 ["Exit and goto next group" gnus-summary-next-group t]
1833 ["Exit and goto prev group" gnus-summary-prev-group t]
1834 ["Reselect group" gnus-summary-reselect-current-group t]
1835 ["Rescan group" gnus-summary-rescan-group t]
1836 ["Update dribble" gnus-summary-save-newsrc t])))
1838 (gnus-run-hooks 'gnus-summary-menu-hook)))
1840 (defun gnus-score-set-default (var value)
1841 "A version of set that updates the GNU Emacs menu-bar."
1843 ;; It is the message that forces the active status to be updated.
1846 (defun gnus-make-score-map (type)
1847 "Make a summary score map of type TYPE."
1850 (let ((headers '(("author" "from" string)
1851 ("subject" "subject" string)
1852 ("article body" "body" string)
1853 ("article head" "head" string)
1854 ("xref" "xref" string)
1855 ("lines" "lines" number)
1856 ("followups to author" "followup" string)))
1857 (types '((number ("less than" <)
1860 (string ("substring" s)
1864 (perms '(("temporary" (current-time-string))
1872 (if (eq type 'lower)
1877 (setq header (car headers))
1883 (let ((ts (cdr (assoc (nth 2 header) types)))
1899 'gnus-summary-score-entry
1901 (if (or (string= (nth 1 header)
1903 (string= (nth 1 header)
1906 (list 'gnus-summary-header
1908 (list 'quote (nth 1 (car ts)))
1909 (list 'gnus-score-default nil)
1915 (list (nreverse outp))))
1918 (list (nreverse outt))))
1920 (setq headers (cdr headers)))
1921 (list (nreverse outh))))))))
1925 (defun gnus-summary-mode (&optional group)
1926 "Major mode for reading articles.
1928 All normal editing commands are switched off.
1929 \\<gnus-summary-mode-map>
1930 Each line in this buffer represents one article. To read an
1931 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1932 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1935 You can also post articles and send mail from this buffer. To
1936 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1937 of an article, type `\\[gnus-summary-reply]'.
1939 There are approx. one gazillion commands you can execute in this
1940 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1942 The following commands are available:
1944 \\{gnus-summary-mode-map}"
1946 (when (gnus-visual-p 'summary-menu 'menu)
1947 (gnus-summary-make-menu-bar))
1948 (kill-all-local-variables)
1949 (gnus-summary-make-local-variables)
1950 (gnus-make-thread-indent-array)
1951 (gnus-simplify-mode-line)
1952 (setq major-mode 'gnus-summary-mode)
1953 (setq mode-name "Summary")
1954 (make-local-variable 'minor-mode-alist)
1955 (use-local-map gnus-summary-mode-map)
1956 (buffer-disable-undo (current-buffer))
1957 (setq buffer-read-only t) ;Disable modification
1958 (setq truncate-lines t)
1959 (setq selective-display t)
1960 (setq selective-display-ellipses t) ;Display `...'
1961 (gnus-summary-set-display-table)
1962 (gnus-set-default-directory)
1963 (setq gnus-newsgroup-name group)
1964 (make-local-variable 'gnus-summary-line-format)
1965 (make-local-variable 'gnus-summary-line-format-spec)
1966 (make-local-variable 'gnus-summary-dummy-line-format)
1967 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1968 (make-local-variable 'gnus-summary-mark-positions)
1969 (make-local-hook 'post-command-hook)
1970 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1971 (make-local-hook 'pre-command-hook)
1972 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1973 (gnus-run-hooks 'gnus-summary-mode-hook)
1974 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1975 (gnus-update-summary-mark-positions))
1977 (defun gnus-summary-make-local-variables ()
1978 "Make all the local summary buffer variables."
1979 (let ((locals gnus-summary-local-variables)
1981 (while (setq local (pop locals))
1984 (if (eq (cdr local) 'global)
1985 ;; Copy the global value of the variable.
1986 (setq global (symbol-value (car local)))
1987 ;; Use the value from the list.
1988 (setq global (eval (cdr local))))
1989 (make-local-variable (car local))
1990 (set (car local) global))
1991 ;; Simple nil-valued local variable.
1992 (make-local-variable local)
1995 (defun gnus-summary-clear-local-variables ()
1996 (let ((locals gnus-summary-local-variables))
1998 (if (consp (car locals))
1999 (and (vectorp (caar locals))
2000 (set (caar locals) nil))
2001 (and (vectorp (car locals))
2002 (set (car locals) nil)))
2003 (setq locals (cdr locals)))))
2005 ;; Summary data functions.
2007 (defmacro gnus-data-number (data)
2010 (defmacro gnus-data-set-number (data number)
2011 `(setcar ,data ,number))
2013 (defmacro gnus-data-mark (data)
2016 (defmacro gnus-data-set-mark (data mark)
2017 `(setcar (nthcdr 1 ,data) ,mark))
2019 (defmacro gnus-data-pos (data)
2022 (defmacro gnus-data-set-pos (data pos)
2023 `(setcar (nthcdr 2 ,data) ,pos))
2025 (defmacro gnus-data-header (data)
2028 (defmacro gnus-data-set-header (data header)
2029 `(setf (nth 3 ,data) ,header))
2031 (defmacro gnus-data-level (data)
2034 (defmacro gnus-data-unread-p (data)
2035 `(= (nth 1 ,data) gnus-unread-mark))
2037 (defmacro gnus-data-read-p (data)
2038 `(/= (nth 1 ,data) gnus-unread-mark))
2040 (defmacro gnus-data-pseudo-p (data)
2041 `(consp (nth 3 ,data)))
2043 (defmacro gnus-data-find (number)
2044 `(assq ,number gnus-newsgroup-data))
2046 (defmacro gnus-data-find-list (number &optional data)
2047 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2048 (memq (assq ,number bdata)
2051 (defmacro gnus-data-make (number mark pos header level)
2052 `(list ,number ,mark ,pos ,header ,level))
2054 (defun gnus-data-enter (after-article number mark pos header level offset)
2055 (let ((data (gnus-data-find-list after-article)))
2057 (error "No such article: %d" after-article))
2058 (setcdr data (cons (gnus-data-make number mark pos header level)
2060 (setq gnus-newsgroup-data-reverse nil)
2061 (gnus-data-update-list (cddr data) offset)))
2063 (defun gnus-data-enter-list (after-article list &optional offset)
2065 (let ((data (and after-article (gnus-data-find-list after-article)))
2067 (or data (not after-article) (error "No such article: %d" after-article))
2068 ;; Find the last element in the list to be spliced into the main
2071 (setq list (cdr list)))
2074 (setcdr list gnus-newsgroup-data)
2075 (setq gnus-newsgroup-data ilist)
2077 (gnus-data-update-list (cdr list) offset)))
2078 (setcdr list (cdr data))
2081 (gnus-data-update-list (cdr list) offset)))
2082 (setq gnus-newsgroup-data-reverse nil))))
2084 (defun gnus-data-remove (article &optional offset)
2085 (let ((data gnus-newsgroup-data))
2086 (if (= (gnus-data-number (car data)) article)
2088 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2089 gnus-newsgroup-data-reverse nil)
2091 (gnus-data-update-list gnus-newsgroup-data offset)))
2093 (when (= (gnus-data-number (cadr data)) article)
2094 (setcdr data (cddr data))
2096 (gnus-data-update-list (cdr data) offset))
2098 gnus-newsgroup-data-reverse nil))
2099 (setq data (cdr data))))))
2101 (defmacro gnus-data-list (backward)
2103 (or gnus-newsgroup-data-reverse
2104 (setq gnus-newsgroup-data-reverse
2105 (reverse gnus-newsgroup-data)))
2106 gnus-newsgroup-data))
2108 (defun gnus-data-update-list (data offset)
2109 "Add OFFSET to the POS of all data entries in DATA."
2111 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2112 (setq data (cdr data))))
2114 (defun gnus-data-compute-positions ()
2115 "Compute the positions of all articles."
2116 (let ((data gnus-newsgroup-data)
2119 (when (setq pos (text-property-any
2120 (point-min) (point-max)
2121 'gnus-number (gnus-data-number (car data))))
2122 (gnus-data-set-pos (car data) (+ pos 3)))
2123 (setq data (cdr data)))))
2125 (defun gnus-summary-article-pseudo-p (article)
2126 "Say whether this article is a pseudo article or not."
2127 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2129 (defmacro gnus-summary-article-sparse-p (article)
2130 "Say whether this article is a sparse article or not."
2131 `(memq ,article gnus-newsgroup-sparse))
2133 (defmacro gnus-summary-article-ancient-p (article)
2134 "Say whether this article is a sparse article or not."
2135 `(memq ,article gnus-newsgroup-ancient))
2137 (defun gnus-article-parent-p (number)
2138 "Say whether this article is a parent or not."
2139 (let ((data (gnus-data-find-list number)))
2140 (and (cdr data) ; There has to be an article after...
2141 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2142 (gnus-data-level (nth 1 data))))))
2144 (defun gnus-article-children (number)
2145 "Return a list of all children to NUMBER."
2146 (let* ((data (gnus-data-find-list number))
2147 (level (gnus-data-level (car data)))
2149 (setq data (cdr data))
2151 (= (gnus-data-level (car data)) (1+ level)))
2152 (push (gnus-data-number (car data)) children)
2153 (setq data (cdr data)))
2156 (defmacro gnus-summary-skip-intangible ()
2157 "If the current article is intangible, then jump to a different article."
2158 '(let ((to (get-text-property (point) 'gnus-intangible)))
2159 (and to (gnus-summary-goto-subject to))))
2161 (defmacro gnus-summary-article-intangible-p ()
2162 "Say whether this article is intangible or not."
2163 '(get-text-property (point) 'gnus-intangible))
2165 (defun gnus-article-read-p (article)
2166 "Say whether ARTICLE is read or not."
2167 (not (or (memq article gnus-newsgroup-marked)
2168 (memq article gnus-newsgroup-unreads)
2169 (memq article gnus-newsgroup-unselected)
2170 (memq article gnus-newsgroup-dormant))))
2172 ;; Some summary mode macros.
2174 (defmacro gnus-summary-article-number ()
2175 "The article number of the article on the current line.
2176 If there isn's an article number here, then we return the current
2179 (gnus-summary-skip-intangible)
2180 (or (get-text-property (point) 'gnus-number)
2181 (gnus-summary-last-subject))))
2183 (defmacro gnus-summary-article-header (&optional number)
2184 "Return the header of article NUMBER."
2185 `(gnus-data-header (gnus-data-find
2186 ,(or number '(gnus-summary-article-number)))))
2188 (defmacro gnus-summary-thread-level (&optional number)
2189 "Return the level of thread that starts with article NUMBER."
2190 `(if (and (eq gnus-summary-make-false-root 'dummy)
2191 (get-text-property (point) 'gnus-intangible))
2193 (gnus-data-level (gnus-data-find
2194 ,(or number '(gnus-summary-article-number))))))
2196 (defmacro gnus-summary-article-mark (&optional number)
2197 "Return the mark of article NUMBER."
2198 `(gnus-data-mark (gnus-data-find
2199 ,(or number '(gnus-summary-article-number)))))
2201 (defmacro gnus-summary-article-pos (&optional number)
2202 "Return the position of the line of article NUMBER."
2203 `(gnus-data-pos (gnus-data-find
2204 ,(or number '(gnus-summary-article-number)))))
2206 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2207 (defmacro gnus-summary-article-subject (&optional number)
2208 "Return current subject string or nil if nothing."
2211 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2212 '(gnus-data-header (assq (gnus-summary-article-number)
2213 gnus-newsgroup-data)))))
2216 (mail-header-subject headers))))
2218 (defmacro gnus-summary-article-score (&optional number)
2219 "Return current article score."
2220 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2221 gnus-newsgroup-scored))
2222 gnus-summary-default-score 0))
2224 (defun gnus-summary-article-children (&optional number)
2225 "Return a list of article numbers that are children of article NUMBER."
2226 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2227 (level (gnus-data-level (car data)))
2229 (while (and (setq data (cdr data))
2230 (> (setq l (gnus-data-level (car data))) level))
2231 (and (= (1+ level) l)
2232 (push (gnus-data-number (car data))
2234 (nreverse children)))
2236 (defun gnus-summary-article-parent (&optional number)
2237 "Return the article number of the parent of article NUMBER."
2238 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2239 (gnus-data-list t)))
2240 (level (gnus-data-level (car data))))
2242 () ; This is a root.
2243 ;; We search until we find an article with a level less than
2244 ;; this one. That function has to be the parent.
2245 (while (and (setq data (cdr data))
2246 (not (< (gnus-data-level (car data)) level))))
2247 (and data (gnus-data-number (car data))))))
2249 (defun gnus-unread-mark-p (mark)
2250 "Say whether MARK is the unread mark."
2251 (= mark gnus-unread-mark))
2253 (defun gnus-read-mark-p (mark)
2254 "Say whether MARK is one of the marks that mark as read.
2255 This is all marks except unread, ticked, dormant, and expirable."
2256 (not (or (= mark gnus-unread-mark)
2257 (= mark gnus-ticked-mark)
2258 (= mark gnus-dormant-mark)
2259 (= mark gnus-expirable-mark))))
2261 (defmacro gnus-article-mark (number)
2262 "Return the MARK of article NUMBER.
2263 This macro should only be used when computing the mark the \"first\"
2264 time; i.e., when generating the summary lines. After that,
2265 `gnus-summary-article-mark' should be used to examine the
2268 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2269 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2270 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2271 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2272 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2273 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2274 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2275 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2276 gnus-ancient-mark))))
2278 ;; Saving hidden threads.
2280 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2281 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2283 (defmacro gnus-save-hidden-threads (&rest forms)
2284 "Save hidden threads, eval FORMS, and restore the hidden threads."
2285 (let ((config (make-symbol "config")))
2286 `(let ((,config (gnus-hidden-threads-configuration)))
2290 (gnus-restore-hidden-threads-configuration ,config)))))
2292 (defun gnus-hidden-threads-configuration ()
2293 "Return the current hidden threads configuration."
2296 (goto-char (point-min))
2297 (while (search-forward "\r" nil t)
2298 (push (1- (point)) config))
2301 (defun gnus-restore-hidden-threads-configuration (config)
2302 "Restore hidden threads configuration from CONFIG."
2303 (let (point buffer-read-only)
2304 (while (setq point (pop config))
2305 (when (and (< point (point-max))
2307 (= (following-char) ?\n))
2308 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2310 ;; Various summary mode internalish functions.
2312 (defun gnus-mouse-pick-article (e)
2315 (gnus-summary-next-page nil t))
2317 (defun gnus-summary-set-display-table ()
2318 ;; Change the display table. Odd characters have a tendency to mess
2319 ;; up nicely formatted displays - we make all possible glyphs
2320 ;; display only a single character.
2322 ;; We start from the standard display table, if any.
2323 (let ((table (or (copy-sequence standard-display-table)
2324 (make-display-table)))
2326 ;; Nix out all the control chars...
2327 (while (>= (setq i (1- i)) 0)
2328 (aset table i [??]))
2329 ;; ... but not newline and cr, of course. (cr is necessary for the
2330 ;; selective display).
2331 (aset table ?\n nil)
2332 (aset table ?\r nil)
2333 ;; We keep TAB as well.
2334 (aset table ?\t nil)
2335 ;; We nix out any glyphs over 126 that are not set already.
2337 (while (>= (setq i (1- i)) 127)
2338 ;; Only modify if the entry is nil.
2339 (unless (aref table i)
2340 (aset table i [??]))))
2341 (setq buffer-display-table table)))
2343 (defun gnus-summary-setup-buffer (group)
2344 "Initialize summary buffer."
2345 (let ((buffer (concat "*Summary " group "*")))
2346 (if (get-buffer buffer)
2349 (setq gnus-summary-buffer (current-buffer))
2350 (not gnus-newsgroup-prepared))
2351 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2352 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2353 (gnus-add-current-to-buffer-list)
2354 (gnus-summary-mode group)
2356 (gnus-carpal-setup-buffer 'summary))
2357 (unless gnus-single-article-buffer
2358 (make-local-variable 'gnus-article-buffer)
2359 (make-local-variable 'gnus-article-current)
2360 (make-local-variable 'gnus-original-article-buffer))
2361 (setq gnus-newsgroup-name group)
2364 (defun gnus-set-global-variables ()
2365 ;; Set the global equivalents of the summary buffer-local variables
2366 ;; to the latest values they had. These reflect the summary buffer
2367 ;; that was in action when the last article was fetched.
2368 (when (eq major-mode 'gnus-summary-mode)
2369 (setq gnus-summary-buffer (current-buffer))
2370 (let ((name gnus-newsgroup-name)
2371 (marked gnus-newsgroup-marked)
2372 (unread gnus-newsgroup-unreads)
2373 (headers gnus-current-headers)
2374 (data gnus-newsgroup-data)
2375 (summary gnus-summary-buffer)
2376 (article-buffer gnus-article-buffer)
2377 (original gnus-original-article-buffer)
2378 (gac gnus-article-current)
2379 (reffed gnus-reffed-article-number)
2380 (score-file gnus-current-score-file))
2382 (set-buffer gnus-group-buffer)
2383 (setq gnus-newsgroup-name name
2384 gnus-newsgroup-marked marked
2385 gnus-newsgroup-unreads unread
2386 gnus-current-headers headers
2387 gnus-newsgroup-data data
2388 gnus-article-current gac
2389 gnus-summary-buffer summary
2390 gnus-article-buffer article-buffer
2391 gnus-original-article-buffer original
2392 gnus-reffed-article-number reffed
2393 gnus-current-score-file score-file)
2394 ;; The article buffer also has local variables.
2395 (when (gnus-buffer-live-p gnus-article-buffer)
2396 (set-buffer gnus-article-buffer)
2397 (setq gnus-summary-buffer summary))))))
2399 (defun gnus-summary-article-unread-p (article)
2400 "Say whether ARTICLE is unread or not."
2401 (memq article gnus-newsgroup-unreads))
2403 (defun gnus-summary-first-article-p (&optional article)
2404 "Return whether ARTICLE is the first article in the buffer."
2405 (if (not (setq article (or article (gnus-summary-article-number))))
2407 (eq article (caar gnus-newsgroup-data))))
2409 (defun gnus-summary-last-article-p (&optional article)
2410 "Return whether ARTICLE is the last article in the buffer."
2411 (if (not (setq article (or article (gnus-summary-article-number))))
2412 t ; All non-existent numbers are the last article. :-)
2413 (not (cdr (gnus-data-find-list article)))))
2415 (defun gnus-make-thread-indent-array ()
2417 (unless (and gnus-thread-indent-array
2418 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2419 (setq gnus-thread-indent-array (make-vector 201 "")
2420 gnus-thread-indent-array-level gnus-thread-indent-level)
2422 (aset gnus-thread-indent-array n
2423 (make-string (* n gnus-thread-indent-level) ? ))
2426 (defun gnus-update-summary-mark-positions ()
2427 "Compute where the summary marks are to go."
2429 (when (and gnus-summary-buffer
2430 (get-buffer gnus-summary-buffer)
2431 (buffer-name (get-buffer gnus-summary-buffer)))
2432 (set-buffer gnus-summary-buffer))
2433 (let ((gnus-replied-mark 129)
2434 (gnus-score-below-mark 130)
2435 (gnus-score-over-mark 130)
2436 (gnus-download-mark 131)
2437 (spec gnus-summary-line-format-spec)
2438 thread gnus-visual pos)
2440 (gnus-set-work-buffer)
2441 (let ((gnus-summary-line-format-spec spec)
2442 (gnus-newsgroup-downloadable '((0 . t))))
2443 (gnus-summary-insert-line
2444 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2445 (goto-char (point-min))
2446 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2448 (goto-char (point-min))
2449 (push (cons 'replied (and (search-forward "\201" nil t)
2452 (goto-char (point-min))
2453 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2455 (goto-char (point-min))
2456 (push (cons 'download
2457 (and (search-forward "\203" nil t) (- (point) 2)))
2459 (setq gnus-summary-mark-positions pos))))
2461 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2462 "Insert a dummy root in the summary buffer."
2464 (gnus-add-text-properties
2465 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2466 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2468 (defun gnus-summary-insert-line (gnus-tmp-header
2469 gnus-tmp-level gnus-tmp-current
2470 gnus-tmp-unread gnus-tmp-replied
2471 gnus-tmp-expirable gnus-tmp-subject-or-nil
2472 &optional gnus-tmp-dummy gnus-tmp-score
2474 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2475 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2476 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2477 (gnus-tmp-score-char
2478 (if (or (null gnus-summary-default-score)
2479 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2480 gnus-summary-zcore-fuzz))
2482 (if (< gnus-tmp-score gnus-summary-default-score)
2483 gnus-score-below-mark gnus-score-over-mark)))
2485 (cond (gnus-tmp-process gnus-process-mark)
2486 ((memq gnus-tmp-current gnus-newsgroup-cached)
2488 (gnus-tmp-replied gnus-replied-mark)
2489 ((memq gnus-tmp-current gnus-newsgroup-saved)
2491 (t gnus-unread-mark)))
2492 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2495 ((string-match "<[^>]+> *$" gnus-tmp-from)
2496 (let ((beg (match-beginning 0)))
2497 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2498 (substring gnus-tmp-from (1+ (match-beginning 0))
2499 (1- (match-end 0))))
2500 (substring gnus-tmp-from 0 beg))))
2501 ((string-match "(.+)" gnus-tmp-from)
2502 (substring gnus-tmp-from
2503 (1+ (match-beginning 0)) (1- (match-end 0))))
2505 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2506 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2507 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2508 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2509 (buffer-read-only nil))
2510 (when (string= gnus-tmp-name "")
2511 (setq gnus-tmp-name gnus-tmp-from))
2512 (unless (numberp gnus-tmp-lines)
2513 (setq gnus-tmp-lines 0))
2514 (gnus-put-text-property
2516 (progn (eval gnus-summary-line-format-spec) (point))
2517 'gnus-number gnus-tmp-number)
2518 (when (gnus-visual-p 'summary-highlight 'highlight)
2520 (gnus-run-hooks 'gnus-summary-update-hook)
2523 (defun gnus-summary-update-line (&optional dont-update)
2524 ;; Update summary line after change.
2525 (when (and gnus-summary-default-score
2526 (not gnus-summary-inhibit-highlight))
2527 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2528 (article (gnus-summary-article-number))
2529 (score (gnus-summary-article-score article)))
2531 (if (and gnus-summary-mark-below
2532 (< (gnus-summary-article-score)
2533 gnus-summary-mark-below))
2534 ;; This article has a low score, so we mark it as read.
2535 (when (memq article gnus-newsgroup-unreads)
2536 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2537 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2538 ;; This article was previously marked as read on account
2539 ;; of a low score, but now it has risen, so we mark it as
2541 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2542 (gnus-summary-update-mark
2543 (if (or (null gnus-summary-default-score)
2544 (<= (abs (- score gnus-summary-default-score))
2545 gnus-summary-zcore-fuzz))
2547 (if (< score gnus-summary-default-score)
2548 gnus-score-below-mark gnus-score-over-mark))
2550 ;; Do visual highlighting.
2551 (when (gnus-visual-p 'summary-highlight 'highlight)
2552 (gnus-run-hooks 'gnus-summary-update-hook)))))
2554 (defvar gnus-tmp-new-adopts nil)
2556 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2557 "Return the number of articles in THREAD.
2558 This may be 0 in some cases -- if none of the articles in
2559 the thread are to be displayed."
2561 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2563 ((not (listp thread))
2565 ((and (consp thread) (cdr thread))
2568 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2571 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2574 (when (and level (zerop level) gnus-tmp-new-adopts)
2577 'gnus-summary-number-of-articles-in-thread
2578 gnus-tmp-new-adopts))))
2580 (if (> number 1) gnus-not-empty-thread-mark
2581 gnus-empty-thread-mark)
2584 (defun gnus-summary-set-local-parameters (group)
2585 "Go through the local params of GROUP and set all variable specs in that list."
2586 (let ((params (gnus-group-find-parameter group))
2589 (setq elem (car params)
2590 params (cdr params))
2591 (and (consp elem) ; Has to be a cons.
2592 (consp (cdr elem)) ; The cdr has to be a list.
2593 (symbolp (car elem)) ; Has to be a symbol in there.
2594 (not (memq (car elem)
2595 '(quit-config to-address to-list to-group)))
2596 (ignore-errors ; So we set it.
2597 (make-local-variable (car elem))
2598 (set (car elem) (eval (nth 1 elem))))))))
2600 (defun gnus-summary-read-group (group &optional show-all no-article
2601 kill-buffer no-display)
2602 "Start reading news in newsgroup GROUP.
2603 If SHOW-ALL is non-nil, already read articles are also listed.
2604 If NO-ARTICLE is non-nil, no article is selected initially.
2605 If NO-DISPLAY, don't generate a summary buffer."
2609 (let ((gnus-auto-select-next nil))
2610 (or (gnus-summary-read-group-1
2611 group show-all no-article
2612 kill-buffer no-display)
2613 (setq show-all nil)))))
2614 (eq gnus-auto-select-next 'quietly))
2615 (set-buffer gnus-group-buffer)
2616 (if (not (equal group (gnus-group-group-name)))
2617 (setq group (gnus-group-group-name))
2621 (defun gnus-summary-read-group-1 (group show-all no-article
2622 kill-buffer no-display)
2623 ;; Killed foreign groups can't be entered.
2624 (when (and (not (gnus-group-native-p group))
2625 (not (gnus-gethash group gnus-newsrc-hashtb)))
2626 (error "Dead non-native groups can't be entered"))
2627 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2628 (let* ((new-group (gnus-summary-setup-buffer group))
2629 (quit-config (gnus-group-quit-config group))
2630 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2632 ;; This summary buffer exists already, so we just select it.
2634 (gnus-set-global-variables)
2636 (gnus-kill-or-deaden-summary kill-buffer))
2637 (gnus-configure-windows 'summary 'force)
2638 (gnus-set-mode-line 'summary)
2639 (gnus-summary-position-point)
2642 ;; We couldn't select this group.
2644 (when (and (eq major-mode 'gnus-summary-mode)
2645 (not (equal (current-buffer) kill-buffer)))
2646 (kill-buffer (current-buffer))
2647 (if (not quit-config)
2649 ;; Update the info -- marks might need to be removed,
2651 (gnus-summary-update-info)
2652 (set-buffer gnus-group-buffer)
2653 (gnus-group-jump-to-group group)
2654 (gnus-group-next-unread-group 1))
2655 (gnus-handle-ephemeral-exit quit-config)))
2656 (gnus-message 3 "Can't select group")
2658 ;; The user did a `C-g' while prompting for number of articles,
2659 ;; so we exit this group.
2660 ((eq did-select 'quit)
2661 (and (eq major-mode 'gnus-summary-mode)
2662 (not (equal (current-buffer) kill-buffer))
2663 (kill-buffer (current-buffer)))
2665 (gnus-kill-or-deaden-summary kill-buffer))
2666 (if (not quit-config)
2668 (set-buffer gnus-group-buffer)
2669 (gnus-group-jump-to-group group)
2670 (gnus-group-next-unread-group 1)
2671 (gnus-configure-windows 'group 'force))
2672 (gnus-handle-ephemeral-exit quit-config))
2673 ;; Finally signal the quit.
2675 ;; The group was successfully selected.
2677 (gnus-set-global-variables)
2678 ;; Save the active value in effect when the group was entered.
2679 (setq gnus-newsgroup-active
2681 (gnus-active gnus-newsgroup-name)))
2682 ;; You can change the summary buffer in some way with this hook.
2683 (gnus-run-hooks 'gnus-select-group-hook)
2684 ;; Set any local variables in the group parameters.
2685 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2686 (gnus-update-format-specifications
2687 nil 'summary 'summary-mode 'summary-dummy)
2688 ;; Do score processing.
2689 (when gnus-use-scoring
2690 (gnus-possibly-score-headers))
2691 ;; Check whether to fill in the gaps in the threads.
2692 (when gnus-build-sparse-threads
2693 (gnus-build-sparse-threads))
2694 ;; Find the initial limit.
2695 (if gnus-show-threads
2697 (let ((gnus-newsgroup-dormant nil))
2698 (gnus-summary-initial-limit show-all))
2699 (gnus-summary-initial-limit show-all))
2700 (setq gnus-newsgroup-limit
2702 (lambda (header) (mail-header-number header))
2703 gnus-newsgroup-headers)))
2704 ;; Generate the summary buffer.
2706 (gnus-summary-prepare))
2707 (when gnus-use-trees
2708 (gnus-tree-open group)
2709 (setq gnus-summary-highlight-line-function
2710 'gnus-tree-highlight-article))
2711 ;; If the summary buffer is empty, but there are some low-scored
2712 ;; articles or some excluded dormants, we include these in the
2714 (when (and (zerop (buffer-size))
2716 (cond (gnus-newsgroup-dormant
2717 (gnus-summary-limit-include-dormant))
2718 ((and gnus-newsgroup-scored show-all)
2719 (gnus-summary-limit-include-expunged t))))
2720 ;; Function `gnus-apply-kill-file' must be called in this hook.
2721 (gnus-run-hooks 'gnus-apply-kill-hook)
2722 (if (and (zerop (buffer-size))
2725 ;; This newsgroup is empty.
2726 (gnus-summary-catchup-and-exit nil t)
2727 (gnus-message 6 "No unread news")
2729 (gnus-kill-or-deaden-summary kill-buffer))
2730 ;; Return nil from this function.
2732 ;; Hide conversation thread subtrees. We cannot do this in
2733 ;; gnus-summary-prepare-hook since kill processing may not
2734 ;; work with hidden articles.
2735 (and gnus-show-threads
2736 gnus-thread-hide-subtree
2737 (gnus-summary-hide-all-threads))
2739 (gnus-kill-or-deaden-summary kill-buffer))
2740 ;; Show first unread article if requested.
2741 (if (and (not no-article)
2743 gnus-newsgroup-unreads
2744 gnus-auto-select-first)
2745 (unless (if (eq gnus-auto-select-first 'best)
2746 (gnus-summary-best-unread-article)
2747 (gnus-summary-first-unread-article))
2748 (gnus-configure-windows 'summary))
2749 ;; Don't select any articles, just move point to the first
2750 ;; article in the group.
2751 (goto-char (point-min))
2752 (gnus-summary-position-point)
2753 (gnus-configure-windows 'summary 'force)
2754 (gnus-set-mode-line 'summary))
2755 (when (get-buffer-window gnus-group-buffer t)
2756 ;; Gotta use windows, because recenter does weird stuff if
2757 ;; the current buffer ain't the displayed window.
2758 (let ((owin (selected-window)))
2759 (select-window (get-buffer-window gnus-group-buffer t))
2760 (when (gnus-group-goto-group group)
2762 (select-window owin)))
2763 ;; Mark this buffer as "prepared".
2764 (setq gnus-newsgroup-prepared t)
2765 (gnus-run-hooks 'gnus-summary-prepared-hook)
2768 (defun gnus-summary-prepare ()
2769 "Generate the summary buffer."
2771 (let ((buffer-read-only nil))
2773 (setq gnus-newsgroup-data nil
2774 gnus-newsgroup-data-reverse nil)
2775 (gnus-run-hooks 'gnus-summary-generate-hook)
2776 ;; Generate the buffer, either with threads or without.
2777 (when gnus-newsgroup-headers
2778 (gnus-summary-prepare-threads
2779 (if gnus-show-threads
2780 (gnus-sort-gathered-threads
2781 (funcall gnus-summary-thread-gathering-function
2783 (gnus-cut-threads (gnus-make-threads)))))
2784 ;; Unthreaded display.
2785 (gnus-sort-articles gnus-newsgroup-headers))))
2786 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2787 ;; Call hooks for modifying summary buffer.
2788 (goto-char (point-min))
2789 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2791 (defsubst gnus-general-simplify-subject (subject)
2792 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2795 ;; Truncate the subject.
2796 (gnus-simplify-subject-functions
2797 (gnus-map-function gnus-simplify-subject-functions subject))
2798 ((numberp gnus-summary-gather-subject-limit)
2799 (setq subject (gnus-simplify-subject-re subject))
2800 (if (> (length subject) gnus-summary-gather-subject-limit)
2801 (substring subject 0 gnus-summary-gather-subject-limit)
2803 ;; Fuzzily simplify it.
2804 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2805 (gnus-simplify-subject-fuzzy subject))
2806 ;; Just remove the leading "Re:".
2808 (gnus-simplify-subject-re subject))))
2810 (if (and gnus-summary-gather-exclude-subject
2811 (string-match gnus-summary-gather-exclude-subject subject))
2812 nil ; This article shouldn't be gathered
2815 (defun gnus-summary-simplify-subject-query ()
2816 "Query where the respool algorithm would put this article."
2818 (gnus-summary-select-article)
2819 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2821 (defun gnus-gather-threads-by-subject (threads)
2822 "Gather threads by looking at Subject headers."
2823 (if (not gnus-summary-make-false-root)
2825 (let ((hashtb (gnus-make-hashtable 1024))
2828 subject hthread whole-subject)
2830 (setq subject (gnus-general-simplify-subject
2831 (setq whole-subject (mail-header-subject
2834 (if (setq hthread (gnus-gethash subject hashtb))
2836 ;; We enter a dummy root into the thread, if we
2837 ;; haven't done that already.
2838 (unless (stringp (caar hthread))
2839 (setcar hthread (list whole-subject (car hthread))))
2840 ;; We add this new gathered thread to this gathered
2842 (setcdr (car hthread)
2843 (nconc (cdar hthread) (list (car threads))))
2844 ;; Remove it from the list of threads.
2845 (setcdr prev (cdr threads))
2846 (setq threads prev))
2847 ;; Enter this thread into the hash table.
2848 (gnus-sethash subject threads hashtb)))
2850 (setq threads (cdr threads)))
2853 (defun gnus-gather-threads-by-references (threads)
2854 "Gather threads by looking at References headers."
2855 (let ((idhashtb (gnus-make-hashtable 1024))
2856 (thhashtb (gnus-make-hashtable 1024))
2859 ids references id gthread gid entered ref)
2861 (when (setq references (mail-header-references (caar threads)))
2862 (setq id (mail-header-id (caar threads))
2863 ids (gnus-split-references references)
2865 (while (setq ref (pop ids))
2866 (setq ids (delete ref ids))
2867 (if (not (setq gid (gnus-gethash ref idhashtb)))
2869 (gnus-sethash ref id idhashtb)
2870 (gnus-sethash id threads thhashtb))
2871 (setq gthread (gnus-gethash gid thhashtb))
2873 ;; We enter a dummy root into the thread, if we
2874 ;; haven't done that already.
2875 (unless (stringp (caar gthread))
2876 (setcar gthread (list (mail-header-subject (caar gthread))
2878 ;; We add this new gathered thread to this gathered
2880 (setcdr (car gthread)
2881 (nconc (cdar gthread) (list (car threads)))))
2882 ;; Add it into the thread hash table.
2883 (gnus-sethash id gthread thhashtb)
2885 ;; Remove it from the list of threads.
2886 (setcdr prev (cdr threads))
2887 (setq threads prev))))
2889 (setq threads (cdr threads)))
2892 (defun gnus-sort-gathered-threads (threads)
2893 "Sort subtreads inside each gathered thread by article number."
2894 (let ((result threads))
2896 (when (stringp (caar threads))
2897 (setcdr (car threads)
2898 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2899 (setq threads (cdr threads)))
2902 (defun gnus-thread-loop-p (root thread)
2903 "Say whether ROOT is in THREAD."
2904 (let ((stack (list thread))
2907 (while (setq thread (pop stack))
2908 (setq th (cdr thread))
2910 (not (eq (caar th) root)))
2913 ;; We have found a loop.
2915 (setcdr thread (delq (car th) (cdr thread)))
2916 (if (boundp (setq ref-dep (intern "none"
2917 gnus-newsgroup-dependencies)))
2918 (setcdr (symbol-value ref-dep)
2919 (nconc (cdr (symbol-value ref-dep))
2921 (set ref-dep (list nil (car th))))
2924 ;; Push all the subthreads onto the stack.
2925 (push (cdr thread) stack)))
2928 (defun gnus-make-threads ()
2929 "Go through the dependency hashtb and find the roots. Return all threads."
2931 (while (catch 'infloop
2934 ;; Deal with self-referencing References loops.
2935 (when (and (car (symbol-value refs))
2942 (car (symbol-value refs)) thread))
2943 (cdr (symbol-value refs)))))))
2946 (unless (car (symbol-value refs))
2947 ;; These threads do not refer back to any other articles,
2948 ;; so they're roots.
2949 (setq threads (append (cdr (symbol-value refs)) threads))))
2950 gnus-newsgroup-dependencies)))
2953 (defun gnus-build-sparse-threads ()
2954 (let ((headers gnus-newsgroup-headers)
2955 (deps gnus-newsgroup-dependencies)
2956 header references generation relations
2957 cthread subject child end pthread relation new-child)
2958 ;; First we create an alist of generations/relations, where
2959 ;; generations is how much we trust the relation, and the relation
2961 (gnus-message 7 "Making sparse threads...")
2963 (nnheader-set-temp-buffer " *gnus sparse threads*")
2964 (while (setq header (pop headers))
2965 (when (and (setq references (mail-header-references header))
2966 (not (string= references "")))
2968 (setq child (mail-header-id header)
2969 subject (mail-header-subject header))
2971 (while (search-backward ">" nil t)
2972 (setq end (1+ (point)))
2973 (when (search-backward "<" nil t)
2974 (unless (string= (setq new-child (buffer-substring (point) end))
2976 (push (list (incf generation)
2977 child (setq child new-child)
2980 (push (list (1+ generation) child nil subject) relations)
2982 (kill-buffer (current-buffer)))
2983 ;; Sort over trustworthiness.
2984 (setq relations (sort relations 'car-less-than-car))
2985 (while (setq relation (pop relations))
2986 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2987 (unless (car (symbol-value cthread))
2988 ;; Make this article the parent of these threads.
2989 (setcar (symbol-value cthread)
2990 (vector gnus-reffed-article-number
2994 (or (caddr relation) "") 0 0 "")))
2995 (set cthread (list (vector gnus-reffed-article-number
2997 "" "" (cadr relation)
2998 (or (caddr relation) "") 0 0 ""))))
2999 (push gnus-reffed-article-number gnus-newsgroup-limit)
3000 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3001 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3002 gnus-newsgroup-reads)
3003 (decf gnus-reffed-article-number)
3004 ;; Make this new thread the child of its parent.
3005 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
3006 (setcdr (symbol-value pthread)
3007 (nconc (cdr (symbol-value pthread))
3008 (list (symbol-value cthread))))
3009 (set pthread (list nil (symbol-value cthread))))))
3010 (gnus-message 7 "Making sparse threads...done")))
3012 (defun gnus-build-old-threads ()
3013 ;; Look at all the articles that refer back to old articles, and
3014 ;; fetch the headers for the articles that aren't there. This will
3015 ;; build complete threads - if the roots haven't been expired by the
3020 (when (not (car (symbol-value refs)))
3021 (setq heads (cdr (symbol-value refs)))
3023 (if (memq (mail-header-number (caar heads))
3024 gnus-newsgroup-dormant)
3025 (setq heads (cdr heads))
3026 (setq id (symbol-name refs))
3027 (while (and (setq id (gnus-build-get-header id))
3028 (not (car (gnus-gethash
3029 id gnus-newsgroup-dependencies)))))
3030 (setq heads nil)))))
3031 gnus-newsgroup-dependencies)))
3033 (defun gnus-build-get-header (id)
3034 ;; Look through the buffer of NOV lines and find the header to
3035 ;; ID. Enter this line into the dependencies hash table, and return
3036 ;; the id of the parent article (if any).
3037 (let ((deps gnus-newsgroup-dependencies)
3041 (set-buffer nntp-server-buffer)
3042 (let ((case-fold-search nil))
3043 (goto-char (point-min))
3044 (while (and (not found)
3045 (search-forward id nil t))
3047 (setq found (looking-at
3048 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3049 (regexp-quote id))))
3050 (or found (beginning-of-line 2)))
3054 (setq header (gnus-nov-parse-line
3055 (read (current-buffer)) deps))
3056 (gnus-parent-id (mail-header-references header))))))
3058 (let ((number (mail-header-number header)))
3059 (push number gnus-newsgroup-limit)
3060 (push header gnus-newsgroup-headers)
3061 (if (memq number gnus-newsgroup-unselected)
3063 (push number gnus-newsgroup-unreads)
3064 (setq gnus-newsgroup-unselected
3065 (delq number gnus-newsgroup-unselected)))
3066 (push number gnus-newsgroup-ancient)))))))
3068 (defun gnus-build-all-threads ()
3069 "Read all the headers."
3070 (let ((deps gnus-newsgroup-dependencies)
3071 (gnus-summary-ignore-duplicates t)
3072 found header article)
3074 (set-buffer nntp-server-buffer)
3075 (let ((case-fold-search nil))
3076 (goto-char (point-min))
3079 (setq article (read (current-buffer)))
3080 (setq header (gnus-nov-parse-line article deps)))
3082 (push header gnus-newsgroup-headers)
3083 (if (memq (setq article (mail-header-number header))
3084 gnus-newsgroup-unselected)
3086 (push article gnus-newsgroup-unreads)
3087 (setq gnus-newsgroup-unselected
3088 (delq article gnus-newsgroup-unselected)))
3089 (push article gnus-newsgroup-ancient))
3090 (forward-line 1)))))))
3092 (defun gnus-summary-update-article-line (article header)
3093 "Update the line for ARTICLE using HEADERS."
3094 (let* ((id (mail-header-id header))
3095 (thread (gnus-id-to-thread id)))
3097 (error "Article in no thread"))
3098 ;; Update the thread.
3099 (setcar thread header)
3100 (gnus-summary-goto-subject article)
3101 (let* ((datal (gnus-data-find-list article))
3103 (length (when (cdr datal)
3104 (- (gnus-data-pos data)
3105 (gnus-data-pos (cadr datal)))))
3106 (buffer-read-only nil)
3107 (level (gnus-summary-thread-level)))
3109 (gnus-summary-insert-line
3110 header level nil (gnus-article-mark article)
3111 (memq article gnus-newsgroup-replied)
3112 (memq article gnus-newsgroup-expirable)
3113 ;; Only insert the Subject string when it's different
3114 ;; from the previous Subject string.
3115 (if (gnus-subject-equal
3117 (mail-header-subject
3120 (gnus-data-find-list
3122 (gnus-data-list t)))))
3123 ;; Error on the side of excessive subjects.
3125 (mail-header-subject header))
3127 (mail-header-subject header))
3128 nil (cdr (assq article gnus-newsgroup-scored))
3129 (memq article gnus-newsgroup-processable))
3131 (gnus-data-update-list
3132 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3134 (defun gnus-summary-update-article (article &optional iheader)
3135 "Update ARTICLE in the summary buffer."
3136 (set-buffer gnus-summary-buffer)
3137 (let* ((header (or iheader (gnus-summary-article-header article)))
3138 (id (mail-header-id header))
3139 (data (gnus-data-find article))
3140 (thread (gnus-id-to-thread id))
3141 (references (mail-header-references header))
3145 (when (and references
3146 (not (equal "" references)))
3149 (buffer-read-only nil)
3151 (number (mail-header-number header))
3154 ;; !!! Should this be in or not?
3156 (setcar thread nil))
3158 (delq thread parent))
3159 (if (gnus-summary-insert-subject id header iheader)
3160 ;; Set the (possibly) new article number in the data structure.
3161 (gnus-data-set-number data (gnus-id-to-article id))
3165 (defun gnus-rebuild-thread (id)
3166 "Rebuild the thread containing ID."
3167 (let ((buffer-read-only nil)
3168 old-pos current thread data)
3169 (if (not gnus-show-threads)
3170 (setq thread (list (car (gnus-id-to-thread id))))
3171 ;; Get the thread this article is part of.
3172 (setq thread (gnus-remove-thread id)))
3173 (setq old-pos (gnus-point-at-bol))
3174 (setq current (save-excursion
3175 (and (zerop (forward-line -1))
3176 (gnus-summary-article-number))))
3177 ;; If this is a gathered thread, we have to go some re-gathering.
3178 (when (stringp (car thread))
3179 (let ((subject (car thread))
3181 (setq thread (cdr thread))
3183 (unless (memq (setq thr (gnus-id-to-thread
3185 (mail-header-id (caar thread)))))
3188 (setq thread (cdr thread)))
3189 ;; We now have all (unique) roots.
3190 (if (= (length roots) 1)
3191 ;; All the loose roots are now one solid root.
3192 (setq thread (car roots))
3193 (setq thread (cons subject (gnus-sort-threads roots))))))
3195 ;; We then insert this thread into the summary buffer.
3196 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3197 (if gnus-show-threads
3198 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3199 (gnus-summary-prepare-unthreaded thread))
3200 (setq data (nreverse gnus-newsgroup-data))
3201 (setq threads gnus-newsgroup-threads))
3202 ;; We splice the new data into the data structure.
3203 (gnus-data-enter-list current data (- (point) old-pos))
3204 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3206 (defun gnus-number-to-header (number)
3207 "Return the header for article NUMBER."
3208 (let ((headers gnus-newsgroup-headers))
3210 (not (= number (mail-header-number (car headers)))))
3215 (defun gnus-parent-headers (headers &optional generation)
3216 "Return the headers of the GENERATIONeth parent of HEADERS."
3218 (setq generation 1))
3221 (while (and parent headers (not (zerop generation)))
3222 (setq references (mail-header-references headers))
3223 (when (and references
3224 (setq parent (gnus-parent-id references))
3225 (setq headers (car (gnus-id-to-thread parent))))
3229 (defun gnus-id-to-thread (id)
3230 "Return the (sub-)thread where ID appears."
3231 (gnus-gethash id gnus-newsgroup-dependencies))
3233 (defun gnus-id-to-article (id)
3234 "Return the article number of ID."
3235 (let ((thread (gnus-id-to-thread id)))
3238 (mail-header-number (car thread)))))
3240 (defun gnus-id-to-header (id)
3241 "Return the article headers of ID."
3242 (car (gnus-id-to-thread id)))
3244 (defun gnus-article-displayed-root-p (article)
3245 "Say whether ARTICLE is a root(ish) article."
3246 (let ((level (gnus-summary-thread-level article))
3247 (refs (mail-header-references (gnus-summary-article-header article)))
3253 ((null (gnus-parent-id refs)) t)
3255 (null (setq particle (gnus-id-to-article
3256 (gnus-parent-id refs))))
3257 (null (gnus-summary-thread-level particle)))))))
3259 (defun gnus-root-id (id)
3260 "Return the id of the root of the thread where ID appears."
3262 (while (and id (setq prev (car (gnus-gethash
3263 id gnus-newsgroup-dependencies))))
3265 id (gnus-parent-id (mail-header-references prev))))
3268 (defun gnus-articles-in-thread (thread)
3269 "Return the list of articles in THREAD."
3270 (cons (mail-header-number (car thread))
3271 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3273 (defun gnus-remove-thread (id &optional dont-remove)
3274 "Remove the thread that has ID in it."
3275 (let ((dep gnus-newsgroup-dependencies)
3276 headers thread last-id)
3277 ;; First go up in this thread until we find the root.
3278 (setq last-id (gnus-root-id id))
3279 (setq headers (list (car (gnus-id-to-thread last-id))
3280 (caadr (gnus-id-to-thread last-id))))
3281 ;; We have now found the real root of this thread. It might have
3282 ;; been gathered into some loose thread, so we have to search
3283 ;; through the threads to find the thread we wanted.
3284 (let ((threads gnus-newsgroup-threads)
3287 (setq sub (car threads))
3288 (if (stringp (car sub))
3289 ;; This is a gathered thread, so we look at the roots
3290 ;; below it to find whether this article is in this
3293 (setq sub (cdr sub))
3295 (when (member (caar sub) headers)
3296 (setq thread (car threads)
3299 (setq sub (cdr sub))))
3300 ;; It's an ordinary thread, so we check it.
3301 (when (eq (car sub) (car headers))
3304 (setq threads (cdr threads)))
3305 ;; If this article is in no thread, then it's a root.
3308 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3309 (setq thread (gnus-gethash last-id dep)))
3312 thread ; We return this thread.
3314 (if (stringp (car thread))
3316 ;; If we use dummy roots, then we have to remove the
3317 ;; dummy root as well.
3318 (when (eq gnus-summary-make-false-root 'dummy)
3320 (gnus-data-compute-positions))
3321 (setq thread (cdr thread))
3323 (gnus-remove-thread-1 (car thread))
3324 (setq thread (cdr thread))))
3325 (gnus-remove-thread-1 thread))))))))
3327 (defun gnus-remove-thread-1 (thread)
3328 "Remove the thread THREAD recursively."
3329 (let ((number (mail-header-number (pop thread)))
3331 (setq thread (reverse thread))
3333 (gnus-remove-thread-1 (pop thread)))
3334 (when (setq d (gnus-data-find number))
3335 (goto-char (gnus-data-pos d))
3338 (- (gnus-point-at-bol)
3340 (1+ (gnus-point-at-eol))
3341 (gnus-delete-line)))))))
3343 (defun gnus-sort-threads (threads)
3345 (if (not gnus-thread-sort-functions)
3347 (gnus-message 7 "Sorting threads...")
3349 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3350 (gnus-message 7 "Sorting threads...done"))))
3352 (defun gnus-sort-articles (articles)
3354 (when gnus-article-sort-functions
3355 (gnus-message 7 "Sorting articles...")
3357 (setq gnus-newsgroup-headers
3358 (sort articles (gnus-make-sort-function
3359 gnus-article-sort-functions)))
3360 (gnus-message 7 "Sorting articles...done"))))
3362 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3363 (defmacro gnus-thread-header (thread)
3364 ;; Return header of first article in THREAD.
3365 ;; Note that THREAD must never, ever be anything else than a variable -
3366 ;; using some other form will lead to serious barfage.
3367 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3368 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3369 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3372 (defsubst gnus-article-sort-by-number (h1 h2)
3373 "Sort articles by article number."
3374 (< (mail-header-number h1)
3375 (mail-header-number h2)))
3377 (defun gnus-thread-sort-by-number (h1 h2)
3378 "Sort threads by root article number."
3379 (gnus-article-sort-by-number
3380 (gnus-thread-header h1) (gnus-thread-header h2)))
3382 (defsubst gnus-article-sort-by-lines (h1 h2)
3383 "Sort articles by article Lines header."
3384 (< (mail-header-lines h1)
3385 (mail-header-lines h2)))
3387 (defun gnus-thread-sort-by-lines (h1 h2)
3388 "Sort threads by root article Lines header."
3389 (gnus-article-sort-by-lines
3390 (gnus-thread-header h1) (gnus-thread-header h2)))
3392 (defsubst gnus-article-sort-by-author (h1 h2)
3393 "Sort articles by root author."
3395 (let ((extract (funcall
3396 gnus-extract-address-components
3397 (mail-header-from h1))))
3398 (or (car extract) (cadr extract) ""))
3399 (let ((extract (funcall
3400 gnus-extract-address-components
3401 (mail-header-from h2))))
3402 (or (car extract) (cadr extract) ""))))
3404 (defun gnus-thread-sort-by-author (h1 h2)
3405 "Sort threads by root author."
3406 (gnus-article-sort-by-author
3407 (gnus-thread-header h1) (gnus-thread-header h2)))
3409 (defsubst gnus-article-sort-by-subject (h1 h2)
3410 "Sort articles by root subject."
3412 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3413 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3415 (defun gnus-thread-sort-by-subject (h1 h2)
3416 "Sort threads by root subject."
3417 (gnus-article-sort-by-subject
3418 (gnus-thread-header h1) (gnus-thread-header h2)))
3420 (defsubst gnus-article-sort-by-date (h1 h2)
3421 "Sort articles by root article date."
3423 (gnus-date-get-time (mail-header-date h1))
3424 (gnus-date-get-time (mail-header-date h2))))
3426 (defun gnus-thread-sort-by-date (h1 h2)
3427 "Sort threads by root article date."
3428 (gnus-article-sort-by-date
3429 (gnus-thread-header h1) (gnus-thread-header h2)))
3431 (defsubst gnus-article-sort-by-score (h1 h2)
3432 "Sort articles by root article score.
3433 Unscored articles will be counted as having a score of zero."
3434 (> (or (cdr (assq (mail-header-number h1)
3435 gnus-newsgroup-scored))
3436 gnus-summary-default-score 0)
3437 (or (cdr (assq (mail-header-number h2)
3438 gnus-newsgroup-scored))
3439 gnus-summary-default-score 0)))
3441 (defun gnus-thread-sort-by-score (h1 h2)
3442 "Sort threads by root article score."
3443 (gnus-article-sort-by-score
3444 (gnus-thread-header h1) (gnus-thread-header h2)))
3446 (defun gnus-thread-sort-by-total-score (h1 h2)
3447 "Sort threads by the sum of all scores in the thread.
3448 Unscored articles will be counted as having a score of zero."
3449 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3451 (defun gnus-thread-total-score (thread)
3452 ;; This function find the total score of THREAD.
3453 (cond ((null thread)
3456 (if (stringp (car thread))
3457 (apply gnus-thread-score-function 0
3458 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3459 (gnus-thread-total-score-1 thread)))
3461 (gnus-thread-total-score-1 (list thread)))))
3463 (defun gnus-thread-total-score-1 (root)
3464 ;; This function find the total score of the thread below ROOT.
3465 (setq root (car root))
3466 (apply gnus-thread-score-function
3468 (mapcar 'gnus-thread-total-score
3469 (cdr (gnus-gethash (mail-header-id root)
3470 gnus-newsgroup-dependencies)))
3471 (when (> (mail-header-number root) 0)
3472 (list (or (cdr (assq (mail-header-number root)
3473 gnus-newsgroup-scored))
3474 gnus-summary-default-score 0))))
3475 (list gnus-summary-default-score)
3478 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3479 (defvar gnus-tmp-prev-subject nil)
3480 (defvar gnus-tmp-false-parent nil)
3481 (defvar gnus-tmp-root-expunged nil)
3482 (defvar gnus-tmp-dummy-line nil)
3484 (defun gnus-summary-prepare-threads (threads)
3485 "Prepare summary buffer from THREADS and indentation LEVEL.
3486 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3487 or a straight list of headers."
3488 (gnus-message 7 "Generating summary...")
3490 (setq gnus-newsgroup-threads threads)
3493 (let ((gnus-tmp-level 0)
3494 (default-score (or gnus-summary-default-score 0))
3495 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3496 thread number subject stack state gnus-tmp-gathered beg-match
3497 new-roots gnus-tmp-new-adopts thread-end
3498 gnus-tmp-header gnus-tmp-unread
3499 gnus-tmp-replied gnus-tmp-subject-or-nil
3500 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3501 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3502 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3504 (setq gnus-tmp-prev-subject nil)
3506 (if (vectorp (car threads))
3507 ;; If this is a straight (sic) list of headers, then a
3508 ;; threaded summary display isn't required, so we just create
3509 ;; an unthreaded one.
3510 (gnus-summary-prepare-unthreaded threads)
3512 ;; Do the threaded display.
3514 (while (or threads stack gnus-tmp-new-adopts new-roots)
3516 (if (and (= gnus-tmp-level 0)
3517 (not (setq gnus-tmp-dummy-line nil))
3520 (not gnus-tmp-false-parent)
3521 (or gnus-tmp-new-adopts new-roots))
3522 (if gnus-tmp-new-adopts
3523 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3524 thread (list (car gnus-tmp-new-adopts))
3525 gnus-tmp-header (caar thread)
3526 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3528 (setq thread (list (car new-roots))
3529 gnus-tmp-header (caar thread)
3530 new-roots (cdr new-roots))))
3533 ;; If there are some threads, we do them before the
3534 ;; threads on the stack.
3535 (setq thread threads
3536 gnus-tmp-header (caar thread))
3537 ;; There were no current threads, so we pop something off
3539 (setq state (car stack)
3540 gnus-tmp-level (car state)
3543 gnus-tmp-header (caar thread))))
3545 (setq gnus-tmp-false-parent nil)
3546 (setq gnus-tmp-root-expunged nil)
3547 (setq thread-end nil)
3549 (if (stringp gnus-tmp-header)
3550 ;; The header is a dummy root.
3552 ((eq gnus-summary-make-false-root 'adopt)
3553 ;; We let the first article adopt the rest.
3554 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3556 (setq gnus-tmp-gathered
3558 (lambda (h) (mail-header-number (car h)))
3561 (setq thread (cons (list (caar thread)
3564 (setq gnus-tmp-level -1
3565 gnus-tmp-false-parent t))
3566 ((eq gnus-summary-make-false-root 'empty)
3567 ;; We print adopted articles with empty subject fields.
3568 (setq gnus-tmp-gathered
3570 (lambda (h) (mail-header-number (car h)))
3573 (setq gnus-tmp-level -1))
3574 ((eq gnus-summary-make-false-root 'dummy)
3575 ;; We remember that we probably want to output a dummy
3577 (setq gnus-tmp-dummy-line gnus-tmp-header)
3578 (setq gnus-tmp-prev-subject gnus-tmp-header))
3580 ;; We do not make a root for the gathered
3581 ;; sub-threads at all.
3582 (setq gnus-tmp-level -1)))
3584 (setq number (mail-header-number gnus-tmp-header)
3585 subject (mail-header-subject gnus-tmp-header))
3588 ;; If the thread has changed subject, we might want to make
3589 ;; this subthread into a root.
3590 ((and (null gnus-thread-ignore-subject)
3591 (not (zerop gnus-tmp-level))
3592 gnus-tmp-prev-subject
3594 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3595 (setq new-roots (nconc new-roots (list (car thread)))
3597 gnus-tmp-header nil))
3598 ;; If the article lies outside the current limit,
3599 ;; then we do not display it.
3600 ((not (memq number gnus-newsgroup-limit))
3601 (setq gnus-tmp-gathered
3603 (lambda (h) (mail-header-number (car h)))
3606 (setq gnus-tmp-new-adopts (if (cdar thread)
3607 (append gnus-tmp-new-adopts
3609 gnus-tmp-new-adopts)
3611 gnus-tmp-header nil)
3612 (when (zerop gnus-tmp-level)
3613 (setq gnus-tmp-root-expunged t)))
3614 ;; Perhaps this article is to be marked as read?
3615 ((and gnus-summary-mark-below
3616 (< (or (cdr (assq number gnus-newsgroup-scored))
3618 gnus-summary-mark-below)
3619 ;; Don't touch sparse articles.
3620 (not (gnus-summary-article-sparse-p number))
3621 (not (gnus-summary-article-ancient-p number)))
3622 (setq gnus-newsgroup-unreads
3623 (delq number gnus-newsgroup-unreads))
3624 (if gnus-newsgroup-auto-expire
3625 (push number gnus-newsgroup-expirable)
3626 (push (cons number gnus-low-score-mark)
3627 gnus-newsgroup-reads))))
3629 (when gnus-tmp-header
3630 ;; We may have an old dummy line to output before this
3632 (when gnus-tmp-dummy-line
3633 (gnus-summary-insert-dummy-line
3634 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3635 (setq gnus-tmp-dummy-line nil))
3637 ;; Compute the mark.
3638 (setq gnus-tmp-unread (gnus-article-mark number))
3640 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3641 gnus-tmp-header gnus-tmp-level)
3642 gnus-newsgroup-data)
3644 ;; Actually insert the line.
3646 gnus-tmp-subject-or-nil
3648 ((and gnus-thread-ignore-subject
3649 gnus-tmp-prev-subject
3650 (not (inline (gnus-subject-equal
3651 gnus-tmp-prev-subject subject))))
3653 ((zerop gnus-tmp-level)
3654 (if (and (eq gnus-summary-make-false-root 'empty)
3655 (memq number gnus-tmp-gathered)
3656 gnus-tmp-prev-subject
3657 (inline (gnus-subject-equal
3658 gnus-tmp-prev-subject subject)))
3659 gnus-summary-same-subject
3661 (t gnus-summary-same-subject)))
3662 (if (and (eq gnus-summary-make-false-root 'adopt)
3663 (= gnus-tmp-level 1)
3664 (memq number gnus-tmp-gathered))
3665 (setq gnus-tmp-opening-bracket ?\<
3666 gnus-tmp-closing-bracket ?\>)
3667 (setq gnus-tmp-opening-bracket ?\[
3668 gnus-tmp-closing-bracket ?\]))
3670 gnus-tmp-indentation
3671 (aref gnus-thread-indent-array gnus-tmp-level)
3672 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3673 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3674 gnus-summary-default-score 0)
3676 (if (or (null gnus-summary-default-score)
3677 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3678 gnus-summary-zcore-fuzz))
3680 (if (< gnus-tmp-score gnus-summary-default-score)
3681 gnus-score-below-mark gnus-score-over-mark))
3683 (cond ((memq number gnus-newsgroup-processable)
3685 ((memq number gnus-newsgroup-cached)
3687 ((memq number gnus-newsgroup-replied)
3689 ((memq number gnus-newsgroup-saved)
3691 (t gnus-unread-mark))
3692 gnus-tmp-from (mail-header-from gnus-tmp-header)
3695 ((string-match "<[^>]+> *$" gnus-tmp-from)
3696 (setq beg-match (match-beginning 0))
3697 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3698 (substring gnus-tmp-from (1+ (match-beginning 0))
3699 (1- (match-end 0))))
3700 (substring gnus-tmp-from 0 beg-match)))
3701 ((string-match "(.+)" gnus-tmp-from)
3702 (substring gnus-tmp-from
3703 (1+ (match-beginning 0)) (1- (match-end 0))))
3705 (when (string= gnus-tmp-name "")
3706 (setq gnus-tmp-name gnus-tmp-from))
3707 (unless (numberp gnus-tmp-lines)
3708 (setq gnus-tmp-lines 0))
3709 (gnus-put-text-property
3711 (progn (eval gnus-summary-line-format-spec) (point))
3712 'gnus-number number)
3715 (gnus-run-hooks 'gnus-summary-update-hook)
3718 (setq gnus-tmp-prev-subject subject)))
3720 (when (nth 1 thread)
3721 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3722 (incf gnus-tmp-level)
3723 (setq threads (if thread-end nil (cdar thread)))
3725 (setq gnus-tmp-level 0)))))
3726 (gnus-message 7 "Generating summary...done"))
3728 (defun gnus-summary-prepare-unthreaded (headers)
3729 "Generate an unthreaded summary buffer based on HEADERS."
3730 (let (header number mark)
3735 ;; We may have to root out some bad articles...
3736 (when (memq (setq number (mail-header-number
3737 (setq header (pop headers))))
3738 gnus-newsgroup-limit)
3739 ;; Mark article as read when it has a low score.
3740 (when (and gnus-summary-mark-below
3741 (< (or (cdr (assq number gnus-newsgroup-scored))
3742 gnus-summary-default-score 0)
3743 gnus-summary-mark-below)
3744 (not (gnus-summary-article-ancient-p number)))
3745 (setq gnus-newsgroup-unreads
3746 (delq number gnus-newsgroup-unreads))
3747 (if gnus-newsgroup-auto-expire
3748 (push number gnus-newsgroup-expirable)
3749 (push (cons number gnus-low-score-mark)
3750 gnus-newsgroup-reads)))
3752 (setq mark (gnus-article-mark number))
3753 (push (gnus-data-make number mark (1+ (point)) header 0)
3754 gnus-newsgroup-data)
3755 (gnus-summary-insert-line
3757 mark (memq number gnus-newsgroup-replied)
3758 (memq number gnus-newsgroup-expirable)
3759 (mail-header-subject header) nil
3760 (cdr (assq number gnus-newsgroup-scored))
3761 (memq number gnus-newsgroup-processable))))))
3763 (defun gnus-select-newsgroup (group &optional read-all)
3764 "Select newsgroup GROUP.
3765 If READ-ALL is non-nil, all articles in the group are selected."
3766 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3767 ;;!!! Dirty hack; should be removed.
3768 (gnus-summary-ignore-duplicates
3769 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3771 gnus-summary-ignore-duplicates))
3772 (info (nth 2 entry))
3773 articles fetched-articles cached)
3775 (unless (gnus-check-server
3776 (setq gnus-current-select-method
3777 (gnus-find-method-for-group group)))
3778 (error "Couldn't open server"))
3780 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3781 (gnus-activate-group group) ; Or we can activate it...
3782 (progn ; Or we bug out.
3783 (when (equal major-mode 'gnus-summary-mode)
3784 (kill-buffer (current-buffer)))
3785 (error "Couldn't request group %s: %s"
3786 group (gnus-status-message group))))
3788 (unless (gnus-request-group group t)
3789 (when (equal major-mode 'gnus-summary-mode)
3790 (kill-buffer (current-buffer)))
3791 (error "Couldn't request group %s: %s"
3792 group (gnus-status-message group)))
3794 (setq gnus-newsgroup-name group)
3795 (setq gnus-newsgroup-unselected nil)
3796 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3798 ;; Adjust and set lists of article marks.
3800 (gnus-adjust-marked-articles info))
3802 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3803 (when (gnus-virtual-group-p group)
3804 (setq cached gnus-newsgroup-cached))
3806 (setq gnus-newsgroup-unreads
3807 (gnus-set-difference
3808 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3809 gnus-newsgroup-dormant))
3811 (setq gnus-newsgroup-processable nil)
3813 (gnus-update-read-articles group gnus-newsgroup-unreads)
3814 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3815 (gnus-group-update-group group))
3817 (setq articles (gnus-articles-to-read group read-all))
3821 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3823 ((eq articles 0) nil)
3825 ;; Init the dependencies hash table.
3826 (setq gnus-newsgroup-dependencies
3827 (gnus-make-hashtable (length articles)))
3828 ;; Retrieve the headers and read them in.
3829 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3830 (setq gnus-newsgroup-headers
3832 (setq gnus-headers-retrieved-by
3833 (gnus-retrieve-headers
3834 articles gnus-newsgroup-name
3835 ;; We might want to fetch old headers, but
3836 ;; not if there is only 1 article.
3837 (and gnus-fetch-old-headers
3839 (not (eq gnus-fetch-old-headers 'some))
3840 (not (numberp gnus-fetch-old-headers)))
3841 (> (length articles) 1))))))
3842 (gnus-get-newsgroup-headers-xover
3843 articles nil nil gnus-newsgroup-name t)
3844 (gnus-get-newsgroup-headers)))
3845 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3847 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3849 (setq gnus-newsgroup-cached cached))
3851 ;; Suppress duplicates?
3852 (when gnus-suppress-duplicates
3853 (gnus-dup-suppress-articles))
3855 ;; Set the initial limit.
3856 (setq gnus-newsgroup-limit (copy-sequence articles))
3857 ;; Remove canceled articles from the list of unread articles.
3858 (setq gnus-newsgroup-unreads
3859 (gnus-set-sorted-intersection
3860 gnus-newsgroup-unreads
3861 (setq fetched-articles
3862 (mapcar (lambda (headers) (mail-header-number headers))
3863 gnus-newsgroup-headers))))
3864 ;; Removed marked articles that do not exist.
3865 (gnus-update-missing-marks
3866 (gnus-sorted-complement fetched-articles articles))
3867 ;; Let the Gnus agent mark articles as read.
3869 (gnus-agent-get-undownloaded-list))
3870 ;; We might want to build some more threads first.
3871 (when (and gnus-fetch-old-headers
3872 (eq gnus-headers-retrieved-by 'nov))
3873 (if (eq gnus-fetch-old-headers 'invisible)
3874 (gnus-build-all-threads)
3875 (gnus-build-old-threads)))
3876 ;; Check whether auto-expire is to be done in this group.
3877 (setq gnus-newsgroup-auto-expire
3878 (gnus-group-auto-expirable-p group))
3879 ;; Set up the article buffer now, if necessary.
3880 (unless gnus-single-article-buffer
3881 (gnus-article-setup-buffer))
3882 ;; First and last article in this newsgroup.
3883 (when gnus-newsgroup-headers
3884 (setq gnus-newsgroup-begin
3885 (mail-header-number (car gnus-newsgroup-headers))
3888 (gnus-last-element gnus-newsgroup-headers))))
3889 ;; GROUP is successfully selected.
3890 (or gnus-newsgroup-headers t)))))
3892 (defun gnus-articles-to-read (group &optional read-all)
3893 ;; Find out what articles the user wants to read.
3895 ;; Select all articles if `read-all' is non-nil, or if there
3896 ;; are no unread articles.
3898 (and (zerop (length gnus-newsgroup-marked))
3899 (zerop (length gnus-newsgroup-unreads)))
3900 (eq (gnus-group-find-parameter group 'display)
3902 (gnus-uncompress-range (gnus-active group))
3903 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3904 (copy-sequence gnus-newsgroup-unreads))
3906 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3907 (scored (length scored-list))
3908 (number (length articles))
3909 (marked (+ (length gnus-newsgroup-marked)
3910 (length gnus-newsgroup-dormant)))
3918 ((and (or (<= scored marked) (= scored number))
3919 (numberp gnus-large-newsgroup)
3920 (> number gnus-large-newsgroup))
3924 "How many articles from %s (default %d): "
3925 (gnus-limit-string gnus-newsgroup-name 35)
3927 (if (string-match "^[ \t]*$" input) number input)))
3928 ((and (> scored marked) (< scored number)
3929 (> (- scored number) 20))
3932 (format "%s %s (%d scored, %d total): "
3933 "How many articles from"
3934 group scored number))))
3935 (if (string-match "^[ \t]*$" input)
3939 (setq select (if (stringp select) (string-to-number select) select))
3940 (if (or (null select) (zerop select))
3942 (if (and (not (zerop scored)) (<= (abs select) scored))
3944 (setq articles (sort scored-list '<))
3945 (setq number (length articles)))
3946 (setq articles (copy-sequence articles)))
3948 (when (< (abs select) number)
3950 ;; Select the N oldest articles.
3951 (setcdr (nthcdr (1- (abs select)) articles) nil)
3952 ;; Select the N most recent articles.
3953 (setq articles (nthcdr (- number select) articles))))
3954 (setq gnus-newsgroup-unselected
3955 (gnus-sorted-intersection
3956 gnus-newsgroup-unreads
3957 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3960 (defun gnus-killed-articles (killed articles)
3963 (when (inline (gnus-member-of-range (car articles) killed))
3964 (push (car articles) out))
3965 (setq articles (cdr articles)))
3968 (defun gnus-uncompress-marks (marks)
3969 "Uncompress the mark ranges in MARKS."
3970 (let ((uncompressed '(score bookmark))
3973 (if (memq (caar marks) uncompressed)
3974 (push (car marks) out)
3975 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3976 (setq marks (cdr marks)))
3979 (defun gnus-adjust-marked-articles (info)
3980 "Set all article lists and remove all marks that are no longer legal."
3981 (let* ((marked-lists (gnus-info-marks info))
3982 (active (gnus-active (gnus-info-group info)))
3985 (types gnus-article-mark-lists)
3986 (uncompressed '(score bookmark killed))
3987 marks var articles article mark)
3990 (setq marks (pop marked-lists))
3991 (set (setq var (intern (format "gnus-newsgroup-%s"
3992 (car (rassq (setq mark (car marks))
3994 (if (memq (car marks) uncompressed) (cdr marks)
3995 (gnus-uncompress-range (cdr marks))))
3997 (setq articles (symbol-value var))
3999 ;; All articles have to be subsets of the active articles.
4001 ;; Adjust "simple" lists.
4002 ((memq mark '(tick dormant expire reply save))
4004 (when (or (< (setq article (pop articles)) min) (> article max))
4005 (set var (delq article (symbol-value var))))))
4007 ((memq mark uncompressed)
4008 (when (not (listp (cdr (symbol-value var))))
4009 (set var (list (symbol-value var))))
4010 (when (not (listp (cdr articles)))
4011 (setq articles (list articles)))
4013 (when (or (not (consp (setq article (pop articles))))
4014 (< (car article) min)
4015 (> (car article) max))
4016 (set var (delq article (symbol-value var))))))))))
4018 (defun gnus-update-missing-marks (missing)
4019 "Go through the list of MISSING articles and remove them from the mark lists."
4021 (let ((types gnus-article-mark-lists)
4023 ;; Go through all types.
4025 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4026 (when (symbol-value var)
4027 ;; This list has articles. So we delete all missing articles
4031 (set var (delq (pop m) (symbol-value var)))))))))
4033 (defun gnus-update-marks ()
4034 "Enter the various lists of marked articles into the newsgroup info list."
4035 (let ((types gnus-article-mark-lists)
4036 (info (gnus-get-info gnus-newsgroup-name))
4037 (uncompressed '(score bookmark killed))
4038 type list newmarked symbol)
4040 ;; Add all marks lists that are non-nil to the list of marks lists.
4041 (while (setq type (pop types))
4042 (when (setq list (symbol-value
4044 (intern (format "gnus-newsgroup-%s"
4047 ;; Get rid of the entries of the articles that have the
4049 (when (and (eq (cdr type) 'score)
4053 (prev (cons nil list))
4056 (if (or (not (consp (car arts)))
4057 (= (cdar arts) gnus-summary-default-score))
4058 (setcdr prev (cdr arts))
4060 (setq arts (cdr arts)))
4061 (setq list (cdr all))))
4063 (push (cons (cdr type)
4064 (if (memq (cdr type) uncompressed) list
4065 (gnus-compress-sequence
4066 (set symbol (sort list '<)) t)))
4069 ;; Enter these new marks into the info of the group.
4071 (setcar (nthcdr 3 info) newmarked)
4072 ;; Add the marks lists to the end of the info.
4074 (setcdr (nthcdr 2 info) (list newmarked))))
4076 ;; Cut off the end of the info if there's nothing else there.
4080 (when (nthcdr (decf i) info)
4081 (setcdr (nthcdr i info) nil)))))))
4083 (defun gnus-set-mode-line (where)
4084 "This function sets the mode line of the article or summary buffers.
4085 If WHERE is `summary', the summary mode line format will be used."
4086 ;; Is this mode line one we keep updated?
4087 (when (memq where gnus-updated-mode-lines)
4090 ;; We evaluate this in the summary buffer since these
4091 ;; variables are buffer-local to that buffer.
4092 (set-buffer gnus-summary-buffer)
4093 ;; We bind all these variables that are used in the `eval' form
4095 (let* ((mformat (symbol-value
4097 (format "gnus-%s-mode-line-format-spec" where))))
4098 (gnus-tmp-group-name gnus-newsgroup-name)
4099 (gnus-tmp-article-number (or gnus-current-article 0))
4100 (gnus-tmp-unread gnus-newsgroup-unreads)
4101 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4102 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4103 (gnus-tmp-unread-and-unselected
4104 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4105 (zerop gnus-tmp-unselected))
4107 ((zerop gnus-tmp-unselected)
4108 (format "{%d more}" gnus-tmp-unread-and-unticked))
4109 (t (format "{%d(+%d) more}"
4110 gnus-tmp-unread-and-unticked
4111 gnus-tmp-unselected))))
4113 (if (and gnus-current-headers
4114 (vectorp gnus-current-headers))
4115 (gnus-mode-string-quote
4116 (mail-header-subject gnus-current-headers))
4118 bufname-length max-len
4119 gnus-tmp-header);; passed as argument to any user-format-funcs
4120 (setq mode-string (eval mformat))
4121 (setq bufname-length (if (string-match "%b" mode-string)
4124 (if (eq where 'summary)
4126 (get-buffer gnus-article-buffer))))
4129 (setq max-len (max 4 (if gnus-mode-non-string-length
4131 gnus-mode-non-string-length
4133 (length mode-string))))
4134 ;; We might have to chop a bit of the string off...
4135 (when (> (length mode-string) max-len)
4137 (concat (gnus-truncate-string mode-string (- max-len 3))
4139 ;; Pad the mode string a bit.
4140 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4141 ;; Update the mode line.
4142 (setq mode-line-buffer-identification
4143 (gnus-mode-line-buffer-identification (list mode-string)))
4144 (set-buffer-modified-p t))))
4146 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4147 "Go through the HEADERS list and add all Xrefs to a hash table.
4148 The resulting hash table is returned, or nil if no Xrefs were found."
4149 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4150 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4151 (xref-hashtb (gnus-make-hashtable))
4152 start group entry number xrefs header)
4154 (setq header (pop headers))
4155 (when (and (setq xrefs (mail-header-xref header))
4156 (not (memq (setq number (mail-header-number header))
4159 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4160 (setq start (match-end 0))
4161 (setq group (if prefix
4162 (concat prefix (substring xrefs (match-beginning 1)
4164 (substring xrefs (match-beginning 1) (match-end 1))))
4166 (string-to-int (substring xrefs (match-beginning 2)
4168 (if (setq entry (gnus-gethash group xref-hashtb))
4169 (setcdr entry (cons number (cdr entry)))
4170 (gnus-sethash group (cons number nil) xref-hashtb)))))
4171 (and start xref-hashtb)))
4173 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4174 "Look through all the headers and mark the Xrefs as read."
4175 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4176 name entry info xref-hashtb idlist method nth4)
4178 (set-buffer gnus-group-buffer)
4179 (when (setq xref-hashtb
4180 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4183 (unless (string= from-newsgroup (setq name (symbol-name group)))
4184 (setq idlist (symbol-value group))
4185 ;; Dead groups are not updated.
4187 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4189 (when (stringp (setq nth4 (gnus-info-method info)))
4190 (setq nth4 (gnus-server-to-method nth4))))
4191 ;; Only do the xrefs if the group has the same
4192 ;; select method as the group we have just read.
4193 (or (gnus-methods-equal-p
4194 nth4 (gnus-find-method-for-group from-newsgroup))
4196 (equal nth4 (setq method (gnus-find-method-for-group
4198 (and (equal (car nth4) (car method))
4199 (equal (nth 1 nth4) (nth 1 method))))
4200 gnus-use-cross-reference
4201 (or (not (eq gnus-use-cross-reference t))
4203 ;; Only do cross-references on subscribed
4204 ;; groups, if that is what is wanted.
4205 (<= (gnus-info-level info) gnus-level-subscribed))
4206 (gnus-group-make-articles-read name idlist))))
4209 (defun gnus-compute-read-articles (group articles)
4210 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4211 (info (nth 2 entry))
4212 (active (gnus-active group))
4215 ;; First peel off all illegal article numbers.
4217 (let ((ids articles)
4219 (while (setq id (pop ids))
4220 (when (and first (> id (cdr active)))
4221 ;; We'll end up in this situation in one particular
4222 ;; obscure situation. If you re-scan a group and get
4223 ;; a new article that is cross-posted to a different
4224 ;; group that has not been re-scanned, you might get
4225 ;; crossposted article that has a higher number than
4226 ;; Gnus believes possible. So we re-activate this
4227 ;; group as well. This might mean doing the
4228 ;; crossposting thingy will *increase* the number
4229 ;; of articles in some groups. Tsk, tsk.
4230 (setq active (or (gnus-activate-group group) active)))
4231 (when (or (> id (cdr active))
4232 (< id (car active)))
4233 (setq articles (delq id articles))))))
4234 ;; If the read list is nil, we init it.
4236 (null (gnus-info-read info))
4238 (setq ninfo (cons 1 (1- (car active))))
4239 (setq ninfo (gnus-info-read info)))
4240 ;; Then we add the read articles to the range.
4242 ninfo (setq articles (sort articles '<))))))
4244 (defun gnus-group-make-articles-read (group articles)
4245 "Update the info of GROUP to say that ARTICLES are read."
4247 (entry (gnus-gethash group gnus-newsrc-hashtb))
4248 (info (nth 2 entry))
4249 (active (gnus-active group))
4252 (setq range (gnus-compute-read-articles group articles))
4254 (set-buffer gnus-group-buffer)
4257 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4258 (gnus-info-set-read ',info ',(gnus-info-read info))
4259 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4260 (gnus-group-update-group ,group t))))
4261 ;; Add the read articles to the range.
4262 (gnus-info-set-read info range)
4263 ;; Then we have to re-compute how many unread
4264 ;; articles there are in this group.
4268 (setq num (- (1+ (cdr active)) (car active))))
4269 ((not (listp (cdr range)))
4270 (setq num (- (cdr active) (- (1+ (cdr range))
4274 (if (numberp (car range))
4276 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4277 (setq range (cdr range)))
4278 (setq num (- (cdr active) num))))
4279 ;; Update the number of unread articles.
4281 ;; Update the group buffer.
4282 (gnus-group-update-group group t)))))
4284 (defun gnus-methods-equal-p (m1 m2)
4285 (let ((m1 (or m1 gnus-select-method))
4286 (m2 (or m2 gnus-select-method)))
4288 (and (eq (car m1) (car m2))
4289 (or (not (memq 'address (assoc (symbol-name (car m1))
4290 gnus-valid-select-methods)))
4291 (equal (nth 1 m1) (nth 1 m2)))))))
4293 (defvar gnus-newsgroup-none-id 0)
4295 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4296 (let ((cur nntp-server-buffer)
4299 (save-excursion (set-buffer gnus-summary-buffer)
4300 gnus-newsgroup-dependencies)))
4301 headers id id-dep ref-dep end ref)
4303 (set-buffer nntp-server-buffer)
4304 ;; Translate all TAB characters into SPACE characters.
4305 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4306 (gnus-run-hooks 'gnus-parse-headers-hook)
4307 (let ((case-fold-search t)
4308 in-reply-to header p lines)
4309 (goto-char (point-min))
4310 ;; Search to the beginning of the next header. Error messages
4311 ;; do not begin with 2 or 3.
4312 (while (re-search-forward "^[23][0-9]+ " nil t)
4315 ;; This implementation of this function, with nine
4316 ;; search-forwards instead of the one re-search-forward and
4317 ;; a case (which basically was the old function) is actually
4318 ;; about twice as fast, even though it looks messier. You
4319 ;; can't have everything, I guess. Speed and elegance
4320 ;; doesn't always go hand in hand.
4329 (narrow-to-region (point)
4330 (or (and (search-forward "\n.\n" nil t)
4336 (if (search-forward "\nsubject: " nil t)
4338 gnus-unstructured-field-decoder (nnheader-header-value))
4343 (if (search-forward "\nfrom: " nil t)
4345 gnus-structured-field-decoder (nnheader-header-value))
4350 (if (search-forward "\ndate: " nil t)
4351 (nnheader-header-value) ""))
4355 (setq id (if (re-search-forward
4356 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4357 ;; We do it this way to make sure the Message-ID
4358 ;; is (somewhat) syntactically valid.
4359 (buffer-substring (match-beginning 1)
4361 ;; If there was no message-id, we just fake one
4362 ;; to make subsequent routines simpler.
4363 (nnheader-generate-fake-message-id))))
4367 (if (search-forward "\nreferences: " nil t)
4371 (nnheader-header-value)
4376 (search-backward ">" end t)
4379 (search-backward "<" end t)
4381 ;; Get the references from the in-reply-to header if there
4382 ;; were no references and the in-reply-to header looks
4384 (if (and (search-forward "\nin-reply-to: " nil t)
4385 (setq in-reply-to (nnheader-header-value))
4386 (string-match "<[^>]+>" in-reply-to))
4388 (setq ref (substring in-reply-to (match-beginning 0)
4390 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4391 (setq ref2 (substring in-reply-to (match-beginning 0)
4393 (when (> (length ref2) (length ref))
4401 (if (search-forward "\nlines: " nil t)
4402 (if (numberp (setq lines (ignore-errors (read cur))))
4408 (and (search-forward "\nxref: " nil t)
4409 (nnheader-header-value)))))
4410 (when (equal id ref)
4413 (when gnus-alter-header-function
4414 (funcall gnus-alter-header-function header)
4415 (setq id (mail-header-id header)
4416 ref (gnus-parent-id (mail-header-references header))))
4418 ;; We do the threading while we read the headers. The
4419 ;; message-id and the last reference are both entered into
4420 ;; the same hash table. Some tippy-toeing around has to be
4421 ;; done in case an article has arrived before the article
4422 ;; which it refers to.
4423 (if (boundp (setq id-dep (intern id dependencies)))
4424 (if (and (car (symbol-value id-dep))
4426 ;; An article with this Message-ID has already been seen.
4427 (if gnus-summary-ignore-duplicates
4428 ;; We ignore this one, except we add
4429 ;; any additional Xrefs (in case the two articles
4430 ;; came from different servers).
4432 (mail-header-set-xref
4433 (car (symbol-value id-dep))
4434 (concat (or (mail-header-xref
4435 (car (symbol-value id-dep)))
4437 (or (mail-header-xref header) "")))
4439 ;; We rename the Message-ID.
4441 (setq id-dep (intern (setq id (nnmail-message-id))
4444 (mail-header-set-id header id))
4445 (setcar (symbol-value id-dep) header))
4446 (set id-dep (list header)))
4448 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4449 (setcdr (symbol-value ref-dep)
4450 (nconc (cdr (symbol-value ref-dep))
4451 (list (symbol-value id-dep))))
4452 (set ref-dep (list nil (symbol-value id-dep))))
4453 (push header headers))
4454 (goto-char (point-max))
4456 (nreverse headers)))))
4458 ;; The following macros and functions were written by Felix Lee
4459 ;; <flee@cse.psu.edu>.
4461 (defmacro gnus-nov-read-integer ()
4463 (if (= (following-char) ?\t)
4465 (let ((num (ignore-errors (read buffer))))
4466 (if (numberp num) num 0)))
4468 (search-forward "\t" eol 'move))))
4470 (defmacro gnus-nov-skip-field ()
4471 '(search-forward "\t" eol 'move))
4473 (defmacro gnus-nov-field ()
4474 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4476 ;; (defvar gnus-nov-none-counter 0)
4478 ;; This function has to be called with point after the article number
4479 ;; on the beginning of the line.
4480 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4481 (let ((eol (gnus-point-at-eol))
4482 (buffer (current-buffer))
4483 header ref id id-dep ref-dep)
4485 ;; overview: [num subject from date id refs chars lines misc]
4488 (narrow-to-region (point) eol)
4496 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4498 gnus-structured-field-decoder (gnus-nov-field)) ; from
4499 (gnus-nov-field) ; date
4500 (setq id (or (gnus-nov-field)
4501 (nnheader-generate-fake-message-id))) ; id
4503 (let ((beg (point)))
4504 (search-forward "\t" eol)
4505 (if (search-backward ">" beg t)
4509 (or (search-backward "<" beg t) beg)))
4512 (gnus-nov-field)) ; refs
4513 (gnus-nov-read-integer) ; chars
4514 (gnus-nov-read-integer) ; lines
4515 (if (= (following-char) ?\n)
4517 (gnus-nov-field))))) ; misc
4521 (when gnus-alter-header-function
4522 (funcall gnus-alter-header-function header)
4523 (setq id (mail-header-id header)
4524 ref (gnus-parent-id (mail-header-references header))))
4526 ;; We build the thread tree.
4527 (when (equal id ref)
4528 ;; This article refers back to itself. Naughty, naughty.
4530 (if (boundp (setq id-dep (intern id dependencies)))
4531 (if (and (car (symbol-value id-dep))
4533 ;; An article with this Message-ID has already been seen.
4534 (if gnus-summary-ignore-duplicates
4535 ;; We ignore this one, except we add any additional
4536 ;; Xrefs (in case the two articles came from different
4539 (mail-header-set-xref
4540 (car (symbol-value id-dep))
4541 (concat (or (mail-header-xref
4542 (car (symbol-value id-dep)))
4544 (or (mail-header-xref header) "")))
4546 ;; We rename the Message-ID.
4548 (setq id-dep (intern (setq id (nnmail-message-id))
4551 (mail-header-set-id header id))
4552 (setcar (symbol-value id-dep) header))
4553 (set id-dep (list header)))
4555 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4556 (setcdr (symbol-value ref-dep)
4557 (nconc (cdr (symbol-value ref-dep))
4558 (list (symbol-value id-dep))))
4559 (set ref-dep (list nil (symbol-value id-dep)))))
4562 ;; Goes through the xover lines and returns a list of vectors
4563 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4564 force-new dependencies
4565 group also-fetch-heads)
4566 "Parse the news overview data in the server buffer, and return a
4567 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4568 ;; Get the Xref when the users reads the articles since most/some
4569 ;; NNTP servers do not include Xrefs when using XOVER.
4570 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4571 (let ((cur nntp-server-buffer)
4572 (dependencies (or dependencies gnus-newsgroup-dependencies))
4573 number headers header)
4575 (set-buffer nntp-server-buffer)
4576 ;; Allow the user to mangle the headers before parsing them.
4577 (gnus-run-hooks 'gnus-parse-headers-hook)
4578 (goto-char (point-min))
4581 (while (and sequence (not (eobp)))
4582 (setq number (read cur))
4583 (while (and sequence
4584 (< (car sequence) number))
4585 (setq sequence (cdr sequence)))
4587 (eq number (car sequence))
4589 (setq sequence (cdr sequence))
4590 (setq header (inline
4591 (gnus-nov-parse-line
4592 number dependencies force-new))))
4593 (push header headers))
4596 (gnus-error 4 "Strange nov line (%d)"
4597 (count-lines (point-min) (point)))))
4599 ;; A common bug in inn is that if you have posted an article and
4600 ;; then retrieves the active file, it will answer correctly --
4601 ;; the new article is included. However, a NOV entry for the
4602 ;; article may not have been generated yet, so this may fail.
4603 ;; We work around this problem by retrieving the last few
4604 ;; headers using HEAD.
4605 (if (or (not also-fetch-heads)
4607 ;; We (probably) got all the headers.
4609 (let ((gnus-nov-is-evil t))
4612 (when (gnus-retrieve-headers sequence group)
4613 (gnus-get-newsgroup-headers))))))))
4615 (defun gnus-article-get-xrefs ()
4616 "Fill in the Xref value in `gnus-current-headers', if necessary.
4617 This is meant to be called in `gnus-article-internal-prepare-hook'."
4618 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4619 gnus-current-headers)))
4620 (or (not gnus-use-cross-reference)
4622 (and (mail-header-xref headers)
4623 (not (string= (mail-header-xref headers) "")))
4624 (let ((case-fold-search t)
4627 (nnheader-narrow-to-headers)
4628 (goto-char (point-min))
4629 (when (or (and (eq (downcase (following-char)) ?x)
4630 (looking-at "Xref:"))
4631 (search-forward "\nXref:" nil t))
4632 (goto-char (1+ (match-end 0)))
4633 (setq xref (buffer-substring (point)
4634 (progn (end-of-line) (point))))
4635 (mail-header-set-xref headers xref)))))))
4637 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4638 "Find article ID and insert the summary line for that article."
4639 (let ((header (cond ((and old-header use-old-header)
4642 (gnus-number-to-header id))
4643 (gnus-number-to-header id))
4645 (gnus-read-header id))))
4646 (number (and (numberp id) id))
4649 ;; Rebuild the thread that this article is part of and go to the
4650 ;; article we have fetched.
4651 (when (and (not gnus-show-threads)
4653 (when (setq d (gnus-data-find (mail-header-number old-header)))
4654 (goto-char (gnus-data-pos d))
4657 (- (gnus-point-at-bol)
4659 (1+ (gnus-point-at-eol))
4660 (gnus-delete-line))))))
4662 (mail-header-set-number header (mail-header-number old-header)))
4663 (setq gnus-newsgroup-sparse
4664 (delq (setq number (mail-header-number header))
4665 gnus-newsgroup-sparse))
4666 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4667 (push number gnus-newsgroup-limit)
4668 (gnus-rebuild-thread (mail-header-id header))
4669 (gnus-summary-goto-subject number nil t))
4670 (when (and (numberp number)
4672 ;; We have to update the boundaries even if we can't fetch the
4673 ;; article if ID is a number -- so that the next `P' or `N'
4674 ;; command will fetch the previous (or next) article even
4675 ;; if the one we tried to fetch this time has been canceled.
4676 (when (> number gnus-newsgroup-end)
4677 (setq gnus-newsgroup-end number))
4678 (when (< number gnus-newsgroup-begin)
4679 (setq gnus-newsgroup-begin number))
4680 (setq gnus-newsgroup-unselected
4681 (delq number gnus-newsgroup-unselected)))
4682 ;; Report back a success?
4683 (and header (mail-header-number header))))
4685 ;;; Process/prefix in the summary buffer
4687 (defun gnus-summary-work-articles (n)
4688 "Return a list of articles to be worked upon. The prefix argument,
4689 the list of process marked articles, and the current article will be
4690 taken into consideration."
4692 (set-buffer gnus-summary-buffer)
4695 ;; A numerical prefix has been given.
4696 (setq n (prefix-numeric-value n))
4697 (let ((backward (< n 0))
4698 (n (abs (prefix-numeric-value n)))
4703 (push (setq article (gnus-summary-article-number))
4706 (gnus-summary-find-prev nil article)
4707 (gnus-summary-find-next nil article)))
4709 (nreverse articles)))
4710 ((and (gnus-region-active-p) (mark))
4711 (message "region active")
4712 ;; Work on the region between point and mark.
4713 (let ((max (max (point) (mark)))
4716 (goto-char (min (min (point) (mark))))
4719 (push (setq article (gnus-summary-article-number)) articles)
4720 (gnus-summary-find-next nil article)
4722 (nreverse articles))))
4723 (gnus-newsgroup-processable
4724 ;; There are process-marked articles present.
4725 ;; Save current state.
4726 (gnus-summary-save-process-mark)
4728 (reverse gnus-newsgroup-processable))
4730 ;; Just return the current article.
4731 (list (gnus-summary-article-number))))))
4733 (defun gnus-summary-save-process-mark ()
4734 "Push the current set of process marked articles on the stack."
4736 (push (copy-sequence gnus-newsgroup-processable)
4737 gnus-newsgroup-process-stack))
4739 (defun gnus-summary-kill-process-mark ()
4740 "Push the current set of process marked articles on the stack and unmark."
4742 (gnus-summary-save-process-mark)
4743 (gnus-summary-unmark-all-processable))
4745 (defun gnus-summary-yank-process-mark ()
4746 "Pop the last process mark state off the stack and restore it."
4748 (unless gnus-newsgroup-process-stack
4749 (error "Empty mark stack"))
4750 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4752 (defun gnus-summary-process-mark-set (set)
4753 "Make SET into the current process marked articles."
4754 (gnus-summary-unmark-all-processable)
4756 (gnus-summary-set-process-mark (pop set))))
4758 ;;; Searching and stuff
4760 (defun gnus-summary-search-group (&optional backward use-level)
4761 "Search for next unread newsgroup.
4762 If optional argument BACKWARD is non-nil, search backward instead."
4764 (set-buffer gnus-group-buffer)
4765 (when (gnus-group-search-forward
4766 backward nil (if use-level (gnus-group-group-level) nil))
4767 (gnus-group-group-name))))
4769 (defun gnus-summary-best-group (&optional exclude-group)
4770 "Find the name of the best unread group.
4771 If EXCLUDE-GROUP, do not go to this group."
4773 (set-buffer gnus-group-buffer)
4775 (gnus-group-best-unread-group exclude-group))))
4777 (defun gnus-summary-find-next (&optional unread article backward)
4778 (if backward (gnus-summary-find-prev)
4779 (let* ((dummy (gnus-summary-article-intangible-p))
4780 (article (or article (gnus-summary-article-number)))
4781 (arts (gnus-data-find-list article))
4783 (when (and (not dummy)
4784 (or (not gnus-summary-check-current)
4786 (not (gnus-data-unread-p (car arts)))))
4787 (setq arts (cdr arts)))
4792 (when (gnus-data-unread-p (car arts))
4793 (setq result (car arts)
4795 (setq arts (cdr arts)))
4798 (goto-char (gnus-data-pos result))
4799 (gnus-data-number result)))))
4801 (defun gnus-summary-find-prev (&optional unread article)
4802 (let* ((eobp (eobp))
4803 (article (or article (gnus-summary-article-number)))
4804 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4806 (when (and (not eobp)
4807 (or (not gnus-summary-check-current)
4809 (not (gnus-data-unread-p (car arts)))))
4810 (setq arts (cdr arts)))
4815 (when (gnus-data-unread-p (car arts))
4816 (setq result (car arts)
4818 (setq arts (cdr arts)))
4821 (goto-char (gnus-data-pos result))
4822 (gnus-data-number result))))
4824 (defun gnus-summary-find-subject (subject &optional unread backward article)
4825 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4826 (article (or article (gnus-summary-article-number)))
4827 (articles (gnus-data-list backward))
4828 (arts (gnus-data-find-list article articles))
4830 (when (or (not gnus-summary-check-current)
4832 (not (gnus-data-unread-p (car arts))))
4833 (setq arts (cdr arts)))
4835 (and (or (not unread)
4836 (gnus-data-unread-p (car arts)))
4837 (vectorp (gnus-data-header (car arts)))
4839 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4840 (setq result (car arts)
4842 (setq arts (cdr arts)))
4844 (goto-char (gnus-data-pos result))
4845 (gnus-data-number result))))
4847 (defun gnus-summary-search-forward (&optional unread subject backward)
4848 "Search forward for an article.
4849 If UNREAD, look for unread articles. If SUBJECT, look for
4850 articles with that subject. If BACKWARD, search backward instead."
4851 (cond (subject (gnus-summary-find-subject subject unread backward))
4852 (backward (gnus-summary-find-prev unread))
4853 (t (gnus-summary-find-next unread))))
4855 (defun gnus-recenter (&optional n)
4856 "Center point in window and redisplay frame.
4857 Also do horizontal recentering."
4859 (when (and gnus-auto-center-summary
4860 (not (eq gnus-auto-center-summary 'vertical)))
4861 (gnus-horizontal-recenter))
4864 (defun gnus-summary-recenter ()
4865 "Center point in the summary window.
4866 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4867 displayed, no centering will be performed."
4868 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4869 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4870 (let* ((top (cond ((< (window-height) 4) 0)
4871 ((< (window-height) 7) 1)
4873 (height (1- (window-height)))
4874 (bottom (save-excursion (goto-char (point-max))
4875 (forward-line (- height))
4877 (window (get-buffer-window (current-buffer))))
4878 ;; The user has to want it.
4879 (when gnus-auto-center-summary
4880 (when (get-buffer-window gnus-article-buffer)
4881 ;; Only do recentering when the article buffer is displayed,
4882 ;; Set the window start to either `bottom', which is the biggest
4883 ;; possible valid number, or the second line from the top,
4884 ;; whichever is the least.
4886 window (min bottom (save-excursion
4887 (forward-line (- top)) (point)))))
4888 ;; Do horizontal recentering while we're at it.
4889 (when (and (get-buffer-window (current-buffer) t)
4890 (not (eq gnus-auto-center-summary 'vertical)))
4891 (let ((selected (selected-window)))
4892 (select-window (get-buffer-window (current-buffer) t))
4893 (gnus-summary-position-point)
4894 (gnus-horizontal-recenter)
4895 (select-window selected))))))
4897 (defun gnus-summary-jump-to-group (newsgroup)
4898 "Move point to NEWSGROUP in group mode buffer."
4899 ;; Keep update point of group mode buffer if visible.
4900 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4901 (save-window-excursion
4902 ;; Take care of tree window mode.
4903 (when (get-buffer-window gnus-group-buffer)
4904 (pop-to-buffer gnus-group-buffer))
4905 (gnus-group-jump-to-group newsgroup))
4907 ;; Take care of tree window mode.
4908 (if (get-buffer-window gnus-group-buffer)
4909 (pop-to-buffer gnus-group-buffer)
4910 (set-buffer gnus-group-buffer))
4911 (gnus-group-jump-to-group newsgroup))))
4913 ;; This function returns a list of article numbers based on the
4914 ;; difference between the ranges of read articles in this group and
4915 ;; the range of active articles.
4916 (defun gnus-list-of-unread-articles (group)
4917 (let* ((read (gnus-info-read (gnus-get-info group)))
4918 (active (or (gnus-active group) (gnus-activate-group group)))
4921 ;; If none are read, then all are unread.
4923 (setq first (car active))
4924 ;; If the range of read articles is a single range, then the
4925 ;; first unread article is the article after the last read
4926 ;; article. Sounds logical, doesn't it?
4927 (if (not (listp (cdr read)))
4928 (setq first (1+ (cdr read)))
4929 ;; `read' is a list of ranges.
4930 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4936 (while (< first nlast)
4938 (setq first (1+ first))))
4939 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4940 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4941 (setq read (cdr read)))))
4942 ;; And add the last unread articles.
4943 (while (<= first last)
4945 (setq first (1+ first)))
4946 ;; Return the list of unread articles.
4947 (delq 0 (nreverse unread))))
4949 (defun gnus-list-of-read-articles (group)
4950 "Return a list of unread, unticked and non-dormant articles."
4951 (let* ((info (gnus-get-info group))
4952 (marked (gnus-info-marks info))
4953 (active (gnus-active group)))
4955 (gnus-set-difference
4956 (gnus-sorted-complement
4957 (gnus-uncompress-range active)
4958 (gnus-list-of-unread-articles group))
4960 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4961 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4963 ;; Various summary commands
4965 (defun gnus-summary-select-article-buffer ()
4966 "Reconfigure windows to show article buffer."
4968 (if (not (gnus-buffer-live-p gnus-article-buffer))
4969 (error "There is no article buffer for this summary buffer")
4970 (gnus-configure-windows 'article)
4971 (select-window (get-buffer-window gnus-article-buffer))))
4973 (defun gnus-summary-universal-argument (arg)
4974 "Perform any operation on all articles that are process/prefixed."
4976 (let ((articles (gnus-summary-work-articles arg))
4983 (substitute-command-keys
4984 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4987 (gnus-error 1 "Undefined key")
4990 (gnus-summary-goto-subject (setq article (pop articles)))
4991 (let (gnus-newsgroup-processable)
4992 (command-execute func))
4993 (gnus-summary-remove-process-mark article)))))
4994 (gnus-summary-position-point))
4996 (defun gnus-summary-toggle-truncation (&optional arg)
4997 "Toggle truncation of summary lines.
4998 With arg, turn line truncation on iff arg is positive."
5000 (setq truncate-lines
5001 (if (null arg) (not truncate-lines)
5002 (> (prefix-numeric-value arg) 0)))
5005 (defun gnus-summary-reselect-current-group (&optional all rescan)
5006 "Exit and then reselect the current newsgroup.
5007 The prefix argument ALL means to select all articles."
5009 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5010 (error "Ephemeral groups can't be reselected"))
5011 (let ((current-subject (gnus-summary-article-number))
5012 (group gnus-newsgroup-name))
5013 (setq gnus-newsgroup-begin nil)
5015 ;; We have to adjust the point of group mode buffer because
5016 ;; point was moved to the next unread newsgroup by exiting.
5017 (gnus-summary-jump-to-group group)
5020 (gnus-group-get-new-news-this-group 1)))
5021 (gnus-group-read-group all t)
5022 (gnus-summary-goto-subject current-subject nil t)))
5024 (defun gnus-summary-rescan-group (&optional all)
5025 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5027 (gnus-summary-reselect-current-group all t))
5029 (defun gnus-summary-update-info (&optional non-destructive)
5031 (let ((group gnus-newsgroup-name))
5033 (when gnus-newsgroup-kill-headers
5034 (setq gnus-newsgroup-killed
5035 (gnus-compress-sequence
5037 (gnus-set-sorted-intersection
5038 (gnus-uncompress-range gnus-newsgroup-killed)
5039 (setq gnus-newsgroup-unselected
5040 (sort gnus-newsgroup-unselected '<)))
5041 (setq gnus-newsgroup-unreads
5042 (sort gnus-newsgroup-unreads '<)))
5044 (unless (listp (cdr gnus-newsgroup-killed))
5045 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5046 (let ((headers gnus-newsgroup-headers))
5047 (when (and (not gnus-save-score)
5048 (not non-destructive))
5049 (setq gnus-newsgroup-scored nil))
5050 ;; Set the new ranges of read articles.
5052 (set-buffer gnus-group-buffer)
5053 (gnus-undo-force-boundary))
5054 (gnus-update-read-articles
5055 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5056 ;; Set the current article marks.
5058 ;; Do the cross-ref thing.
5059 (when gnus-use-cross-reference
5060 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5061 ;; Do not switch windows but change the buffer to work.
5062 (set-buffer gnus-group-buffer)
5063 (unless (gnus-ephemeral-group-p group)
5064 (gnus-group-update-group group)))))))
5066 (defun gnus-summary-save-newsrc (&optional force)
5067 "Save the current number of read/marked articles in the dribble buffer.
5068 The dribble buffer will then be saved.
5069 If FORCE (the prefix), also save the .newsrc file(s)."
5071 (gnus-summary-update-info t)
5073 (gnus-save-newsrc-file)
5074 (gnus-dribble-save)))
5076 (defun gnus-summary-exit (&optional temporary)
5077 "Exit reading current newsgroup, and then return to group selection mode.
5078 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5080 (gnus-set-global-variables)
5081 (gnus-kill-save-kill-buffer)
5082 (gnus-async-halt-prefetch)
5083 (let* ((group gnus-newsgroup-name)
5084 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5087 (buf (current-buffer)))
5088 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5089 ;; If we have several article buffers, we kill them at exit.
5090 (unless gnus-single-article-buffer
5091 (gnus-kill-buffer gnus-original-article-buffer)
5092 (setq gnus-article-current nil))
5093 (when gnus-use-cache
5094 (gnus-cache-possibly-remove-articles)
5095 (gnus-cache-save-buffers))
5096 (gnus-async-prefetch-remove-group group)
5097 (when gnus-suppress-duplicates
5098 (gnus-dup-enter-articles))
5099 (when gnus-use-trees
5100 (gnus-tree-close group))
5101 ;; Remove entries for this group.
5102 (nnmail-purge-split-history (gnus-group-real-name group))
5103 ;; Make all changes in this group permanent.
5105 (gnus-run-hooks 'gnus-exit-group-hook)
5106 (gnus-summary-update-info)
5107 ;; Do adaptive scoring, and possibly save score files.
5108 (when gnus-newsgroup-adaptive
5109 (gnus-score-adaptive))
5110 (when gnus-use-scoring
5112 (gnus-close-group group)
5113 ;; Make sure where we were, and go to next newsgroup.
5114 (set-buffer gnus-group-buffer)
5116 (gnus-group-jump-to-group group))
5117 (gnus-run-hooks 'gnus-summary-exit-hook)
5118 (unless (or quit-config
5119 ;; If this group has disappeared from the summary
5120 ;; buffer, don't skip forwards.
5121 (not (string= group (gnus-group-group-name))))
5122 (gnus-group-next-unread-group 1))
5123 (setq group-point (point))
5126 ;; If we have several article buffers, we kill them at exit.
5127 (unless gnus-single-article-buffer
5128 (gnus-kill-buffer gnus-article-buffer)
5129 (gnus-kill-buffer gnus-original-article-buffer)
5130 (setq gnus-article-current nil))
5132 (if (not gnus-kill-summary-on-exit)
5133 (gnus-deaden-summary)
5134 ;; We set all buffer-local variables to nil. It is unclear why
5135 ;; this is needed, but if we don't, buffer-local variables are
5136 ;; not garbage-collected, it seems. This would the lead to en
5137 ;; ever-growing Emacs.
5138 (gnus-summary-clear-local-variables)
5139 (when (get-buffer gnus-article-buffer)
5140 (bury-buffer gnus-article-buffer))
5141 ;; We clear the global counterparts of the buffer-local
5142 ;; variables as well, just to be on the safe side.
5143 (set-buffer gnus-group-buffer)
5144 (gnus-summary-clear-local-variables)
5145 ;; Return to group mode buffer.
5146 (when (eq mode 'gnus-summary-mode)
5147 (gnus-kill-buffer buf)))
5148 (setq gnus-current-select-method gnus-select-method)
5149 (pop-to-buffer gnus-group-buffer)
5150 ;; Clear the current group name.
5151 (if (not quit-config)
5153 (goto-char group-point)
5154 (gnus-configure-windows 'group 'force))
5155 (gnus-handle-ephemeral-exit quit-config))
5157 (setq gnus-newsgroup-name nil)))))
5159 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5160 (defun gnus-summary-exit-no-update (&optional no-questions)
5161 "Quit reading current newsgroup without updating read article info."
5163 (let* ((group gnus-newsgroup-name)
5164 (quit-config (gnus-group-quit-config group)))
5165 (when (or no-questions
5167 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5168 (gnus-async-halt-prefetch)
5169 ;; If we have several article buffers, we kill them at exit.
5170 (unless gnus-single-article-buffer
5171 (gnus-kill-buffer gnus-article-buffer)
5172 (gnus-kill-buffer gnus-original-article-buffer)
5173 (setq gnus-article-current nil))
5174 (if (not gnus-kill-summary-on-exit)
5175 (gnus-deaden-summary)
5176 (gnus-close-group group)
5177 (gnus-summary-clear-local-variables)
5178 (set-buffer gnus-group-buffer)
5179 (gnus-summary-clear-local-variables)
5180 (when (get-buffer gnus-summary-buffer)
5181 (kill-buffer gnus-summary-buffer)))
5182 (unless gnus-single-article-buffer
5183 (setq gnus-article-current nil))
5184 (when gnus-use-trees
5185 (gnus-tree-close group))
5186 (gnus-async-prefetch-remove-group group)
5187 (when (get-buffer gnus-article-buffer)
5188 (bury-buffer gnus-article-buffer))
5189 ;; Return to the group buffer.
5190 (gnus-configure-windows 'group 'force)
5191 ;; Clear the current group name.
5192 (setq gnus-newsgroup-name nil)
5193 (when (equal (gnus-group-group-name) group)
5194 (gnus-group-next-unread-group 1))
5196 (gnus-handle-ephemeral-exit quit-config)))))
5198 (defun gnus-handle-ephemeral-exit (quit-config)
5199 "Handle movement when leaving an ephemeral group. The state
5200 which existed when entering the ephemeral is reset."
5201 (if (not (buffer-name (car quit-config)))
5202 (gnus-configure-windows 'group 'force)
5203 (set-buffer (car quit-config))
5204 (cond ((eq major-mode 'gnus-summary-mode)
5205 (gnus-set-global-variables))
5206 ((eq major-mode 'gnus-article-mode)
5208 ;; The `gnus-summary-buffer' variable may point
5209 ;; to the old summary buffer when using a single
5211 (unless (gnus-buffer-live-p gnus-summary-buffer)
5212 (set-buffer gnus-group-buffer))
5213 (set-buffer gnus-summary-buffer)
5214 (gnus-set-global-variables))))
5215 (if (or (eq (cdr quit-config) 'article)
5216 (eq (cdr quit-config) 'pick))
5218 ;; The current article may be from the ephemeral group
5219 ;; thus it is best that we reload this article
5220 (gnus-summary-show-article)
5221 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5222 (gnus-configure-windows 'pick 'force)
5223 (gnus-configure-windows (cdr quit-config) 'force)))
5224 (gnus-configure-windows (cdr quit-config) 'force))
5225 (when (eq major-mode 'gnus-summary-mode)
5226 (gnus-summary-next-subject 1 nil t)
5227 (gnus-summary-recenter)
5228 (gnus-summary-position-point))))
5232 (defvar gnus-dead-summary-mode-map nil)
5234 (unless gnus-dead-summary-mode-map
5235 (setq gnus-dead-summary-mode-map (make-keymap))
5236 (suppress-keymap gnus-dead-summary-mode-map)
5237 (substitute-key-definition
5238 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5239 (let ((keys '("\C-d" "\r" "\177" [delete])))
5241 (define-key gnus-dead-summary-mode-map
5242 (pop keys) 'gnus-summary-wake-up-the-dead))))
5244 (defvar gnus-dead-summary-mode nil
5245 "Minor mode for Gnus summary buffers.")
5247 (defun gnus-dead-summary-mode (&optional arg)
5248 "Minor mode for Gnus summary buffers."
5250 (when (eq major-mode 'gnus-summary-mode)
5251 (make-local-variable 'gnus-dead-summary-mode)
5252 (setq gnus-dead-summary-mode
5253 (if (null arg) (not gnus-dead-summary-mode)
5254 (> (prefix-numeric-value arg) 0)))
5255 (when gnus-dead-summary-mode
5256 (gnus-add-minor-mode
5257 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5259 (defun gnus-deaden-summary ()
5260 "Make the current summary buffer into a dead summary buffer."
5261 ;; Kill any previous dead summary buffer.
5262 (when (and gnus-dead-summary
5263 (buffer-name gnus-dead-summary))
5265 (set-buffer gnus-dead-summary)
5266 (when gnus-dead-summary-mode
5267 (kill-buffer (current-buffer)))))
5268 ;; Make this the current dead summary.
5269 (setq gnus-dead-summary (current-buffer))
5270 (gnus-dead-summary-mode 1)
5271 (let ((name (buffer-name)))
5272 (when (string-match "Summary" name)
5274 (concat (substring name 0 (match-beginning 0)) "Dead "
5275 (substring name (match-beginning 0)))
5278 (defun gnus-kill-or-deaden-summary (buffer)
5279 "Kill or deaden the summary BUFFER."
5281 (when (and (buffer-name buffer)
5282 (not gnus-single-article-buffer))
5285 (gnus-kill-buffer gnus-article-buffer)
5286 (gnus-kill-buffer gnus-original-article-buffer)))
5287 (cond (gnus-kill-summary-on-exit
5288 (when (and gnus-use-trees
5289 (and (get-buffer buffer)
5290 (buffer-name (get-buffer buffer))))
5292 (set-buffer (get-buffer buffer))
5293 (gnus-tree-close gnus-newsgroup-name)))
5294 (gnus-kill-buffer buffer))
5295 ((and (get-buffer buffer)
5296 (buffer-name (get-buffer buffer)))
5299 (gnus-deaden-summary))))))
5301 (defun gnus-summary-wake-up-the-dead (&rest args)
5302 "Wake up the dead summary buffer."
5304 (gnus-dead-summary-mode -1)
5305 (let ((name (buffer-name)))
5306 (when (string-match "Dead " name)
5308 (concat (substring name 0 (match-beginning 0))
5309 (substring name (match-end 0)))
5311 (gnus-message 3 "This dead summary is now alive again"))
5313 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5314 (defun gnus-summary-fetch-faq (&optional faq-dir)
5315 "Fetch the FAQ for the current group.
5316 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5320 (when current-prefix-arg
5322 "Faq dir: " (and (listp gnus-group-faq-directory)
5323 (mapcar (lambda (file) (list file))
5324 gnus-group-faq-directory))))))
5325 (let (gnus-faq-buffer)
5326 (when (setq gnus-faq-buffer
5327 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5328 (gnus-configure-windows 'summary-faq))))
5330 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5331 (defun gnus-summary-describe-group (&optional force)
5332 "Describe the current newsgroup."
5334 (gnus-group-describe-group force gnus-newsgroup-name))
5336 (defun gnus-summary-describe-briefly ()
5337 "Describe summary mode commands briefly."
5340 (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")))
5342 ;; Walking around group mode buffer from summary mode.
5344 (defun gnus-summary-next-group (&optional no-article target-group backward)
5345 "Exit current newsgroup and then select next unread newsgroup.
5346 If prefix argument NO-ARTICLE is non-nil, no article is selected
5347 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5348 previous group instead."
5350 ;; Stop pre-fetching.
5351 (gnus-async-halt-prefetch)
5352 (let ((current-group gnus-newsgroup-name)
5353 (current-buffer (current-buffer))
5355 ;; First we semi-exit this group to update Xrefs and all variables.
5356 ;; We can't do a real exit, because the window conf must remain
5357 ;; the same in case the user is prompted for info, and we don't
5358 ;; want the window conf to change before that...
5359 (gnus-summary-exit t)
5360 (while (not entered)
5361 ;; Then we find what group we are supposed to enter.
5362 (set-buffer gnus-group-buffer)
5363 (gnus-group-jump-to-group current-group)
5366 (if (eq gnus-keep-same-level 'best)
5367 (gnus-summary-best-group gnus-newsgroup-name)
5368 (gnus-summary-search-group backward gnus-keep-same-level))))
5369 (if (not target-group)
5370 ;; There are no further groups, so we return to the group
5373 (gnus-message 5 "Returning to the group buffer")
5375 (when (gnus-buffer-live-p current-buffer)
5376 (set-buffer current-buffer)
5377 (gnus-summary-exit))
5378 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5379 ;; We try to enter the target group.
5380 (gnus-group-jump-to-group target-group)
5381 (let ((unreads (gnus-group-group-unread)))
5382 (if (and (or (eq t unreads)
5383 (and unreads (not (zerop unreads))))
5384 (gnus-summary-read-group
5385 target-group nil no-article
5386 (and (buffer-name current-buffer) current-buffer)))
5388 (setq current-group target-group
5389 target-group nil)))))))
5391 (defun gnus-summary-prev-group (&optional no-article)
5392 "Exit current newsgroup and then select previous unread newsgroup.
5393 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5395 (gnus-summary-next-group no-article nil t))
5397 ;; Walking around summary lines.
5399 (defun gnus-summary-first-subject (&optional unread)
5400 "Go to the first unread subject.
5401 If UNREAD is non-nil, go to the first unread article.
5402 Returns the article selected or nil if there are no unread articles."
5407 ((null gnus-newsgroup-data)
5408 (gnus-message 3 "No articles in the group")
5410 ;; Pick the first article.
5412 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5413 (gnus-data-number (car gnus-newsgroup-data)))
5414 ;; No unread articles.
5415 ((null gnus-newsgroup-unreads)
5416 (gnus-message 3 "No more unread articles")
5418 ;; Find the first unread article.
5420 (let ((data gnus-newsgroup-data))
5422 (not (gnus-data-unread-p (car data))))
5423 (setq data (cdr data)))
5425 (goto-char (gnus-data-pos (car data)))
5426 (gnus-data-number (car data))))))
5427 (gnus-summary-position-point)))
5429 (defun gnus-summary-next-subject (n &optional unread dont-display)
5430 "Go to next N'th summary line.
5431 If N is negative, go to the previous N'th subject line.
5432 If UNREAD is non-nil, only unread articles are selected.
5433 The difference between N and the actual number of steps taken is
5436 (let ((backward (< n 0))
5440 (gnus-summary-find-prev unread)
5441 (gnus-summary-find-next unread)))
5444 (gnus-message 7 "No more%s articles"
5445 (if unread " unread" "")))
5446 (unless dont-display
5447 (gnus-summary-recenter)
5448 (gnus-summary-position-point))
5451 (defun gnus-summary-next-unread-subject (n)
5452 "Go to next N'th unread summary line."
5454 (gnus-summary-next-subject n t))
5456 (defun gnus-summary-prev-subject (n &optional unread)
5457 "Go to previous N'th summary line.
5458 If optional argument UNREAD is non-nil, only unread article is selected."
5460 (gnus-summary-next-subject (- n) unread))
5462 (defun gnus-summary-prev-unread-subject (n)
5463 "Go to previous N'th unread summary line."
5465 (gnus-summary-next-subject (- n) t))
5467 (defun gnus-summary-goto-subject (article &optional force silent)
5468 "Go the subject line of ARTICLE.
5469 If FORCE, also allow jumping to articles not currently shown."
5470 (interactive "nArticle number: ")
5472 (data (gnus-data-find article)))
5473 ;; We read in the article if we have to.
5476 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5477 (setq data (gnus-data-find article)))
5482 (gnus-message 3 "Can't find article %d" article))
5484 (goto-char (gnus-data-pos data))
5487 ;; Walking around summary lines with displaying articles.
5489 (defun gnus-summary-expand-window (&optional arg)
5490 "Make the summary buffer take up the entire Emacs frame.
5491 Given a prefix, will force an `article' buffer configuration."
5494 (gnus-configure-windows 'article 'force)
5495 (gnus-configure-windows 'summary 'force)))
5497 (defun gnus-summary-display-article (article &optional all-header)
5498 "Display ARTICLE in article buffer."
5499 (gnus-set-global-variables)
5503 (if gnus-summary-display-article-function
5504 (funcall gnus-summary-display-article-function article all-header)
5505 (gnus-article-prepare article all-header))
5506 (gnus-run-hooks 'gnus-select-article-hook)
5507 (when (and gnus-current-article
5508 (not (zerop gnus-current-article)))
5509 (gnus-summary-goto-subject gnus-current-article))
5510 (gnus-summary-recenter)
5511 (when (and gnus-use-trees gnus-show-threads)
5512 (gnus-possibly-generate-tree article)
5513 (gnus-highlight-selected-tree article))
5514 ;; Successfully display article.
5515 (gnus-article-set-window-start
5516 (cdr (assq article gnus-newsgroup-bookmarks))))))
5518 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5519 "Select the current article.
5520 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5521 non-nil, the article will be re-fetched even if it already present in
5522 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5524 ;; Make sure we are in the summary buffer to work around bbdb bug.
5525 (unless (eq major-mode 'gnus-summary-mode)
5526 (set-buffer gnus-summary-buffer))
5527 (let ((article (or article (gnus-summary-article-number)))
5528 (all-headers (not (not all-headers))) ;Must be T or NIL.
5529 gnus-summary-display-article-function
5532 (gnus-summary-article-pseudo-p article)
5533 (error "This is a pseudo-article"))
5536 (set-buffer gnus-summary-buffer)
5537 (if (or (and gnus-single-article-buffer
5538 (or (null gnus-current-article)
5539 (null gnus-article-current)
5540 (null (get-buffer gnus-article-buffer))
5541 (not (eq article (cdr gnus-article-current)))
5542 (not (equal (car gnus-article-current)
5543 gnus-newsgroup-name))))
5544 (and (not gnus-single-article-buffer)
5545 (or (null gnus-current-article)
5546 (not (eq gnus-current-article article))))
5548 ;; The requested article is different from the current article.
5550 (gnus-summary-display-article article all-headers)
5552 (when (or all-headers gnus-show-all-headers)
5553 (gnus-article-show-all-headers))
5556 (gnus-article-set-window-start
5557 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5559 (defun gnus-summary-set-current-mark (&optional current-mark)
5560 "Obsolete function."
5563 (defun gnus-summary-next-article (&optional unread subject backward push)
5564 "Select the next article.
5565 If UNREAD, only unread articles are selected.
5566 If SUBJECT, only articles with SUBJECT are selected.
5567 If BACKWARD, the previous article is selected instead of the next."
5570 ;; Is there such an article?
5571 ((and (gnus-summary-search-forward unread subject backward)
5572 (or (gnus-summary-display-article (gnus-summary-article-number))
5573 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5574 (gnus-summary-position-point))
5575 ;; If not, we try the first unread, if that is wanted.
5577 gnus-auto-select-same
5578 (gnus-summary-first-unread-article))
5579 (gnus-summary-position-point)
5580 (gnus-message 6 "Wrapped"))
5581 ;; Try to get next/previous article not displayed in this group.
5582 ((and gnus-auto-extend-newsgroup
5583 (not unread) (not subject))
5584 (gnus-summary-goto-article
5585 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5587 ;; Go to next/previous group.
5589 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5590 (gnus-summary-jump-to-group gnus-newsgroup-name))
5591 (let ((cmd last-command-char)
5594 (set-buffer gnus-group-buffer)
5597 (if (eq gnus-keep-same-level 'best)
5598 (gnus-summary-best-group gnus-newsgroup-name)
5599 (gnus-summary-search-group backward gnus-keep-same-level))))
5600 ;; For some reason, the group window gets selected. We change
5602 (select-window (get-buffer-window (current-buffer)))
5603 ;; Select next unread newsgroup automagically.
5605 ((or (not gnus-auto-select-next)
5607 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5608 ((or (eq gnus-auto-select-next 'quietly)
5609 (and (eq gnus-auto-select-next 'slightly-quietly)
5611 (and (eq gnus-auto-select-next 'almost-quietly)
5612 (gnus-summary-last-article-p)))
5614 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5616 (gnus-message 7 "No more%s articles (%s)..."
5617 (if unread " unread" "")
5618 (if group (concat "selecting " group)
5620 (gnus-summary-next-group nil group backward)))
5622 (when (gnus-key-press-event-p last-input-event)
5623 (gnus-summary-walk-group-buffer
5624 gnus-newsgroup-name cmd unread backward point))))))))
5626 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5627 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5628 (?\C-p (gnus-group-prev-unread-group 1))))
5629 (cursor-in-echo-area t)
5630 keve key group ended)
5632 (set-buffer gnus-group-buffer)
5635 (if (eq gnus-keep-same-level 'best)
5636 (gnus-summary-best-group gnus-newsgroup-name)
5637 (gnus-summary-search-group backward gnus-keep-same-level))))
5640 5 "No more%s articles%s" (if unread " unread" "")
5642 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5643 (format " (Type %s for %s [%s])"
5644 (single-key-description cmd) group
5645 (car (gnus-gethash group gnus-newsrc-hashtb)))
5646 (format " (Type %s to exit %s)"
5647 (single-key-description cmd)
5648 gnus-newsgroup-name)))
5649 ;; Confirm auto selection.
5650 (setq key (car (setq keve (gnus-read-event-char))))
5653 ((assq key keystrokes)
5654 (let ((obuf (current-buffer)))
5655 (switch-to-buffer gnus-group-buffer)
5657 (gnus-group-jump-to-group group))
5658 (eval (cadr (assq key keystrokes)))
5659 (setq group (gnus-group-group-name))
5660 (switch-to-buffer obuf))
5664 (gnus-ephemeral-group-p gnus-newsgroup-name))
5666 (gnus-summary-next-group nil group backward)))
5668 (push (cdr keve) unread-command-events))))))
5670 (defun gnus-summary-next-unread-article ()
5671 "Select unread article after current one."
5673 (gnus-summary-next-article
5674 (or (not (eq gnus-summary-goto-unread 'never))
5675 (gnus-summary-last-article-p (gnus-summary-article-number)))
5676 (and gnus-auto-select-same
5677 (gnus-summary-article-subject))))
5679 (defun gnus-summary-prev-article (&optional unread subject)
5680 "Select the article after the current one.
5681 If UNREAD is non-nil, only unread articles are selected."
5683 (gnus-summary-next-article unread subject t))
5685 (defun gnus-summary-prev-unread-article ()
5686 "Select unread article before current one."
5688 (gnus-summary-prev-article
5689 (or (not (eq gnus-summary-goto-unread 'never))
5690 (gnus-summary-first-article-p (gnus-summary-article-number)))
5691 (and gnus-auto-select-same
5692 (gnus-summary-article-subject))))
5694 (defun gnus-summary-next-page (&optional lines circular)
5695 "Show next page of the selected article.
5696 If at the end of the current article, select the next article.
5697 LINES says how many lines should be scrolled up.
5699 If CIRCULAR is non-nil, go to the start of the article instead of
5700 selecting the next article when reaching the end of the current
5703 (setq gnus-summary-buffer (current-buffer))
5704 (gnus-set-global-variables)
5705 (let ((article (gnus-summary-article-number))
5706 (article-window (get-buffer-window gnus-article-buffer t))
5708 (gnus-configure-windows 'article)
5709 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5710 (if (and (eq gnus-summary-goto-unread 'never)
5711 (not (gnus-summary-last-article-p article)))
5712 (gnus-summary-next-article)
5713 (gnus-summary-next-unread-article))
5714 (if (or (null gnus-current-article)
5715 (null gnus-article-current)
5716 (/= article (cdr gnus-article-current))
5717 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5718 ;; Selected subject is different from current article's.
5719 (gnus-summary-display-article article)
5720 (when article-window
5721 (gnus-eval-in-buffer-window gnus-article-buffer
5722 (setq endp (gnus-article-next-page lines)))
5725 (gnus-summary-beginning-of-article))
5727 (gnus-message 3 "End of message"))
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 (gnus-summary-recenter)
5734 (gnus-summary-position-point)))
5736 (defun gnus-summary-prev-page (&optional lines move)
5737 "Show previous page of selected article.
5738 Argument LINES specifies lines to be scrolled down.
5739 If MOVE, move to the previous unread article if point is at
5740 the beginning of the buffer."
5742 (let ((article (gnus-summary-article-number))
5743 (article-window (get-buffer-window gnus-article-buffer t))
5745 (gnus-configure-windows 'article)
5746 (if (or (null gnus-current-article)
5747 (null gnus-article-current)
5748 (/= article (cdr gnus-article-current))
5749 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5750 ;; Selected subject is different from current article's.
5751 (gnus-summary-display-article article)
5752 (gnus-summary-recenter)
5753 (when article-window
5754 (gnus-eval-in-buffer-window gnus-article-buffer
5755 (setq endp (gnus-article-prev-page lines)))
5756 (when (and move endp)
5758 (gnus-message 3 "Beginning of message"))
5760 (if (and (eq gnus-summary-goto-unread 'never)
5761 (not (gnus-summary-first-article-p article)))
5762 (gnus-summary-prev-article)
5763 (gnus-summary-prev-unread-article))))))))
5764 (gnus-summary-position-point))
5766 (defun gnus-summary-prev-page-or-article (&optional lines)
5767 "Show previous page of selected article.
5768 Argument LINES specifies lines to be scrolled down.
5769 If at the beginning of the article, go to the next article."
5771 (gnus-summary-prev-page lines t))
5773 (defun gnus-summary-scroll-up (lines)
5774 "Scroll up (or down) one line current article.
5775 Argument LINES specifies lines to be scrolled up (or down if negative)."
5777 (gnus-configure-windows 'article)
5778 (gnus-summary-show-thread)
5779 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5780 (gnus-eval-in-buffer-window gnus-article-buffer
5782 (when (gnus-article-next-page lines)
5783 (gnus-message 3 "End of message")))
5785 (gnus-article-prev-page (- lines))))))
5786 (gnus-summary-recenter)
5787 (gnus-summary-position-point))
5789 (defun gnus-summary-next-same-subject ()
5790 "Select next article which has the same subject as current one."
5792 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5794 (defun gnus-summary-prev-same-subject ()
5795 "Select previous article which has the same subject as current one."
5797 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5799 (defun gnus-summary-next-unread-same-subject ()
5800 "Select next unread article which has the same subject as current one."
5802 (gnus-summary-next-article t (gnus-summary-article-subject)))
5804 (defun gnus-summary-prev-unread-same-subject ()
5805 "Select previous unread article which has the same subject as current one."
5807 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5809 (defun gnus-summary-first-unread-article ()
5810 "Select the first unread article.
5811 Return nil if there are no unread articles."
5814 (when (gnus-summary-first-subject t)
5815 (gnus-summary-show-thread)
5816 (gnus-summary-first-subject t)
5817 (gnus-summary-display-article (gnus-summary-article-number)))
5818 (gnus-summary-position-point)))
5820 (defun gnus-summary-first-article ()
5821 "Select the first article.
5822 Return nil if there are no articles."
5825 (when (gnus-summary-first-subject)
5826 (gnus-summary-show-thread)
5827 (gnus-summary-first-subject)
5828 (gnus-summary-display-article (gnus-summary-article-number)))
5829 (gnus-summary-position-point)))
5831 (defun gnus-summary-best-unread-article ()
5832 "Select the unread article with the highest score."
5834 (let ((best -1000000)
5835 (data gnus-newsgroup-data)
5838 (and (gnus-data-unread-p (car data))
5840 (gnus-summary-article-score (gnus-data-number (car data))))
5843 article (gnus-data-number (car data))))
5844 (setq data (cdr data)))
5847 (gnus-summary-goto-article article)
5848 (error "No unread articles"))
5849 (gnus-summary-position-point))))
5851 (defun gnus-summary-last-subject ()
5852 "Go to the last displayed subject line in the group."
5853 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5855 (gnus-summary-goto-subject article))))
5857 (defun gnus-summary-goto-article (article &optional all-headers force)
5858 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5859 If ALL-HEADERS is non-nil, no header lines are hidden."
5863 "Article number or Message-ID: "
5864 (mapcar (lambda (number) (list (int-to-string number)))
5865 gnus-newsgroup-limit))
5869 (if (and (stringp article)
5870 (string-match "@" article))
5871 (gnus-summary-refer-article article)
5872 (when (stringp article)
5873 (setq article (string-to-number article)))
5874 (if (gnus-summary-goto-subject article force)
5875 (gnus-summary-display-article article all-headers)
5876 (gnus-message 4 "Couldn't go to article %s" article) nil))
5877 (gnus-summary-position-point)))
5879 (defun gnus-summary-goto-last-article ()
5880 "Go to the previously read article."
5883 (when gnus-last-article
5884 (gnus-summary-goto-article gnus-last-article nil t))
5885 (gnus-summary-position-point)))
5887 (defun gnus-summary-pop-article (number)
5888 "Pop one article off the history and go to the previous.
5889 NUMBER articles will be popped off."
5892 (setq gnus-newsgroup-history
5893 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5895 (gnus-summary-goto-article (car to) nil t)
5896 (error "Article history empty")))
5897 (gnus-summary-position-point))
5899 ;; Summary commands and functions for limiting the summary buffer.
5901 (defun gnus-summary-limit-to-articles (n)
5902 "Limit the summary buffer to the next N articles.
5903 If not given a prefix, use the process marked articles instead."
5906 (let ((articles (gnus-summary-work-articles n)))
5907 (setq gnus-newsgroup-processable nil)
5908 (gnus-summary-limit articles))
5909 (gnus-summary-position-point)))
5911 (defun gnus-summary-pop-limit (&optional total)
5912 "Restore the previous limit.
5913 If given a prefix, remove all limits."
5916 (setq gnus-newsgroup-limits
5917 (list (mapcar (lambda (h) (mail-header-number h))
5918 gnus-newsgroup-headers))))
5919 (unless gnus-newsgroup-limits
5920 (error "No limit to pop"))
5922 (gnus-summary-limit nil 'pop)
5923 (gnus-summary-position-point)))
5925 (defun gnus-summary-limit-to-subject (subject &optional header)
5926 "Limit the summary buffer to articles that have subjects that match a regexp."
5927 (interactive "sLimit to subject (regexp): ")
5929 (setq header "subject"))
5930 (when (not (equal "" subject))
5932 (let ((articles (gnus-summary-find-matching
5933 (or header "subject") subject 'all)))
5935 (error "Found no matches for \"%s\"" subject))
5936 (gnus-summary-limit articles))
5937 (gnus-summary-position-point))))
5939 (defun gnus-summary-limit-to-author (from)
5940 "Limit the summary buffer to articles that have authors that match a regexp."
5941 (interactive "sLimit to author (regexp): ")
5942 (gnus-summary-limit-to-subject from "from"))
5944 (defun gnus-summary-limit-to-age (age &optional younger-p)
5945 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5946 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5947 articles that are younger than AGE days."
5948 (interactive "nTime in days: \nP")
5950 (let ((data gnus-newsgroup-data)
5951 (cutoff (nnmail-days-to-time age))
5952 articles d date is-younger)
5953 (while (setq d (pop data))
5954 (when (and (vectorp (gnus-data-header d))
5955 (setq date (mail-header-date (gnus-data-header d))))
5956 (setq is-younger (nnmail-time-less
5957 (nnmail-time-since (nnmail-date-to-time date))
5959 (when (if younger-p is-younger (not is-younger))
5960 (push (gnus-data-number d) articles))))
5961 (gnus-summary-limit (nreverse articles)))
5962 (gnus-summary-position-point)))
5964 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5966 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5968 (defun gnus-summary-limit-to-unread (&optional all)
5969 "Limit the summary buffer to articles that are not marked as read.
5970 If ALL is non-nil, limit strictly to unread articles."
5973 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5974 (gnus-summary-limit-to-marks
5975 ;; Concat all the marks that say that an article is read and have
5977 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5978 gnus-killed-mark gnus-kill-file-mark
5979 gnus-low-score-mark gnus-expirable-mark
5980 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5981 gnus-duplicate-mark gnus-souped-mark)
5984 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5985 (make-obsolete 'gnus-summary-delete-marked-with
5986 'gnus-summary-limit-exlude-marks)
5988 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5989 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5990 If REVERSE, limit the summary buffer to articles that are marked
5991 with MARKS. MARKS can either be a string of marks or a list of marks.
5992 Returns how many articles were removed."
5993 (interactive "sMarks: ")
5994 (gnus-summary-limit-to-marks marks t))
5996 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5997 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5998 If REVERSE (the prefix), limit the summary buffer to articles that are
5999 not marked with MARKS. MARKS can either be a string of marks or a
6001 Returns how many articles were removed."
6002 (interactive "sMarks: \nP")
6004 (let ((data gnus-newsgroup-data)
6005 (marks (if (listp marks) marks
6006 (append marks nil))) ; Transform to list.
6009 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6010 (memq (gnus-data-mark (car data)) marks))
6011 (push (gnus-data-number (car data)) articles))
6012 (setq data (cdr data)))
6013 (gnus-summary-limit articles))
6014 (gnus-summary-position-point)))
6016 (defun gnus-summary-limit-to-score (&optional score)
6017 "Limit to articles with score at or above SCORE."
6019 (setq score (if score
6020 (prefix-numeric-value score)
6021 (or gnus-summary-default-score 0)))
6022 (let ((data gnus-newsgroup-data)
6025 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6027 (push (gnus-data-number (car data)) articles))
6028 (setq data (cdr data)))
6030 (gnus-summary-limit articles)
6031 (gnus-summary-position-point))))
6033 (defun gnus-summary-limit-include-thread (id)
6034 "Display all the hidden articles that in the current thread."
6035 (interactive (list (mail-header-id (gnus-summary-article-header))))
6036 (let ((articles (gnus-articles-in-thread
6037 (gnus-id-to-thread (gnus-root-id id)))))
6039 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6040 (gnus-summary-position-point))))
6042 (defun gnus-summary-limit-include-dormant ()
6043 "Display all the hidden articles that are marked as dormant.
6044 Note that this command only works on a subset of the articles currently
6045 fetched for this group."
6047 (unless gnus-newsgroup-dormant
6048 (error "There are no dormant articles in this group"))
6050 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6051 (gnus-summary-position-point)))
6053 (defun gnus-summary-limit-exclude-dormant ()
6054 "Hide all dormant articles."
6057 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6058 (gnus-summary-position-point)))
6060 (defun gnus-summary-limit-exclude-childless-dormant ()
6061 "Hide all dormant articles that have no children."
6063 (let ((data (gnus-data-list t))
6064 articles d children)
6065 ;; Find all articles that are either not dormant or have
6067 (while (setq d (pop data))
6068 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6070 (gnus-article-children (gnus-data-number d)))
6073 (when (memq (car children) articles)
6078 (push (gnus-data-number d) articles)))
6081 (gnus-summary-limit articles)
6082 (gnus-summary-position-point))))
6084 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6085 "Mark all unread excluded articles as read.
6086 If ALL, mark even excluded ticked and dormants as read."
6088 (let ((articles (gnus-sorted-complement
6090 (mapcar (lambda (h) (mail-header-number h))
6091 gnus-newsgroup-headers)
6093 (sort gnus-newsgroup-limit '<)))
6095 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6097 (setq gnus-newsgroup-dormant nil
6098 gnus-newsgroup-marked nil
6099 gnus-newsgroup-reads
6101 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6102 gnus-newsgroup-reads))
6103 (while (setq article (pop articles))
6104 (unless (or (memq article gnus-newsgroup-dormant)
6105 (memq article gnus-newsgroup-marked))
6106 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6108 (defun gnus-summary-limit (articles &optional pop)
6110 ;; We pop the previous limit off the stack and use that.
6111 (setq articles (car gnus-newsgroup-limits)
6112 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6113 ;; We use the new limit, so we push the old limit on the stack.
6114 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6116 (setq gnus-newsgroup-limit articles)
6117 (let ((total (length gnus-newsgroup-data))
6118 (data (gnus-data-find-list (gnus-summary-article-number)))
6119 (gnus-summary-mark-below nil) ; Inhibit this.
6121 ;; This will do all the work of generating the new summary buffer
6122 ;; according to the new limit.
6123 (gnus-summary-prepare)
6124 ;; Hide any threads, possibly.
6125 (and gnus-show-threads
6126 gnus-thread-hide-subtree
6127 (gnus-summary-hide-all-threads))
6128 ;; Try to return to the article you were at, or one in the
6131 ;; We try to find some article after the current one.
6133 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6136 (setq data (cdr data))))
6138 ;; If there is no data, that means that we were after the last
6139 ;; article. The same goes when we can't find any articles
6140 ;; after the current one.
6141 (goto-char (point-max))
6142 (gnus-summary-find-prev))
6143 ;; We return how many articles were removed from the summary
6144 ;; buffer as a result of the new limit.
6145 (- total (length gnus-newsgroup-data))))
6147 (defsubst gnus-invisible-cut-children (threads)
6150 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6155 (defsubst gnus-cut-thread (thread)
6156 "Go forwards in the thread until we find an article that we want to display."
6157 (when (or (eq gnus-fetch-old-headers 'some)
6158 (eq gnus-fetch-old-headers 'invisible)
6159 (eq gnus-build-sparse-threads 'some)
6160 (eq gnus-build-sparse-threads 'more))
6161 ;; Deal with old-fetched headers and sparse threads.
6165 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6166 (gnus-summary-article-ancient-p
6167 (mail-header-number (car thread))))
6168 (if (or (<= (length (cdr thread)) 1)
6169 (eq gnus-fetch-old-headers 'invisible))
6170 (setq gnus-newsgroup-limit
6171 (delq (mail-header-number (car thread))
6172 gnus-newsgroup-limit)
6173 thread (cadr thread))
6174 (when (gnus-invisible-cut-children (cdr thread))
6175 (let ((th (cdr thread)))
6177 (if (memq (mail-header-number (caar th))
6178 gnus-newsgroup-limit)
6179 (setq thread (car th)
6181 (setq th (cdr th))))))))))
6184 (defun gnus-cut-threads (threads)
6185 "Cut off all uninteresting articles from the beginning of threads."
6186 (when (or (eq gnus-fetch-old-headers 'some)
6187 (eq gnus-fetch-old-headers 'invisible)
6188 (eq gnus-build-sparse-threads 'some)
6189 (eq gnus-build-sparse-threads 'more))
6192 (setcar th (gnus-cut-thread (car th)))
6193 (setq th (cdr th)))))
6194 ;; Remove nixed out threads.
6197 (defun gnus-summary-initial-limit (&optional show-if-empty)
6198 "Figure out what the initial limit is supposed to be on group entry.
6199 This entails weeding out unwanted dormants, low-scored articles,
6200 fetch-old-headers verbiage, and so on."
6201 ;; Most groups have nothing to remove.
6202 (if (or gnus-inhibit-limiting
6203 (and (null gnus-newsgroup-dormant)
6204 (not (eq gnus-fetch-old-headers 'some))
6205 (not (eq gnus-fetch-old-headers 'invisible))
6206 (null gnus-summary-expunge-below)
6207 (not (eq gnus-build-sparse-threads 'some))
6208 (not (eq gnus-build-sparse-threads 'more))
6209 (null gnus-thread-expunge-below)
6210 (not gnus-use-nocem)))
6212 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6213 (setq gnus-newsgroup-limit nil)
6216 (unless (car (symbol-value node))
6217 ;; These threads have no parents -- they are roots.
6218 (let ((nodes (cdr (symbol-value node)))
6221 (if (and gnus-thread-expunge-below
6222 (< (gnus-thread-total-score (car nodes))
6223 gnus-thread-expunge-below))
6224 (gnus-expunge-thread (pop nodes))
6225 (setq thread (pop nodes))
6226 (gnus-summary-limit-children thread))))))
6227 gnus-newsgroup-dependencies)
6228 ;; If this limitation resulted in an empty group, we might
6229 ;; pop the previous limit and use it instead.
6230 (when (and (not gnus-newsgroup-limit)
6232 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6233 gnus-newsgroup-limit))
6235 (defun gnus-summary-limit-children (thread)
6236 "Return 1 if this subthread is visible and 0 if it is not."
6237 ;; First we get the number of visible children to this thread. This
6238 ;; is done by recursing down the thread using this function, so this
6239 ;; will really go down to a leaf article first, before slowly
6240 ;; working its way up towards the root.
6244 (apply '+ (mapcar 'gnus-summary-limit-children
6247 (number (mail-header-number (car thread)))
6250 (not (memq number gnus-newsgroup-marked))
6252 ;; If this article is dormant and has absolutely no visible
6253 ;; children, then this article isn't visible.
6254 (and (memq number gnus-newsgroup-dormant)
6256 ;; If this is "fetch-old-headered" and there is no
6257 ;; visible children, then we don't want this article.
6258 (and (eq gnus-fetch-old-headers 'some)
6259 (gnus-summary-article-ancient-p number)
6261 ;; If this is "fetch-old-headered" and `invisible', then
6262 ;; we don't want this article.
6263 (and (eq gnus-fetch-old-headers 'invisible)
6264 (gnus-summary-article-ancient-p number))
6265 ;; If this is a sparsely inserted article with no children,
6266 ;; we don't want it.
6267 (and (eq gnus-build-sparse-threads 'some)
6268 (gnus-summary-article-sparse-p number)
6270 ;; If we use expunging, and this article is really
6271 ;; low-scored, then we don't want this article.
6272 (when (and gnus-summary-expunge-below
6274 (or (cdr (assq number gnus-newsgroup-scored))
6275 gnus-summary-default-score))
6276 gnus-summary-expunge-below))
6277 ;; We increase the expunge-tally here, but that has
6278 ;; nothing to do with the limits, really.
6279 (incf gnus-newsgroup-expunged-tally)
6280 ;; We also mark as read here, if that's wanted.
6281 (when (and gnus-summary-mark-below
6282 (< score gnus-summary-mark-below))
6283 (setq gnus-newsgroup-unreads
6284 (delq number gnus-newsgroup-unreads))
6285 (if gnus-newsgroup-auto-expire
6286 (push number gnus-newsgroup-expirable)
6287 (push (cons number gnus-low-score-mark)
6288 gnus-newsgroup-reads)))
6290 ;; Check NoCeM things.
6291 (if (and gnus-use-nocem
6292 (gnus-nocem-unwanted-article-p
6293 (mail-header-id (car thread))))
6295 (setq gnus-newsgroup-unreads
6296 (delq number gnus-newsgroup-unreads))
6298 ;; Nope, invisible article.
6300 ;; Ok, this article is to be visible, so we add it to the limit
6302 (push number gnus-newsgroup-limit)
6305 (defun gnus-expunge-thread (thread)
6306 "Mark all articles in THREAD as read."
6307 (let* ((number (mail-header-number (car thread))))
6308 (incf gnus-newsgroup-expunged-tally)
6309 ;; We also mark as read here, if that's wanted.
6310 (setq gnus-newsgroup-unreads
6311 (delq number gnus-newsgroup-unreads))
6312 (if gnus-newsgroup-auto-expire
6313 (push number gnus-newsgroup-expirable)
6314 (push (cons number gnus-low-score-mark)
6315 gnus-newsgroup-reads)))
6316 ;; Go recursively through all subthreads.
6317 (mapcar 'gnus-expunge-thread (cdr thread)))
6319 ;; Summary article oriented commands
6321 (defun gnus-summary-refer-parent-article (n)
6322 "Refer parent article N times.
6323 If N is negative, go to ancestor -N instead.
6324 The difference between N and the number of articles fetched is returned."
6328 (when (not (natnump n))
6333 (setq header (gnus-summary-article-header))
6334 (if (and (eq (mail-header-number header)
6335 (cdr gnus-article-current))
6336 (equal gnus-newsgroup-name
6337 (car gnus-article-current)))
6338 ;; If we try to find the parent of the currently
6339 ;; displayed article, then we take a look at the actual
6340 ;; References header, since this is slightly more
6341 ;; reliable than the References field we got from the
6344 (set-buffer gnus-original-article-buffer)
6345 (nnheader-narrow-to-headers)
6346 (unless (setq ref (message-fetch-field "references"))
6347 (setq ref (message-fetch-field "in-reply-to")))
6350 ;; It's not the current article, so we take a bet on
6351 ;; the value we got from the server.
6352 (mail-header-references header)))
6354 (not (equal ref "")))
6355 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6356 (gnus-message 1 "Couldn't find parent"))
6357 (gnus-message 1 "No references in article %d"
6358 (gnus-summary-article-number))
6361 (gnus-summary-position-point)
6364 (defun gnus-summary-refer-references ()
6365 "Fetch all articles mentioned in the References header.
6366 Return the number of articles fetched."
6368 (let ((ref (mail-header-references (gnus-summary-article-header)))
6369 (current (gnus-summary-article-number))
6373 (error "No References in the current article")
6374 ;; For each Message-ID in the References header...
6375 (while (string-match "<[^>]*>" ref)
6377 ;; ... fetch that article.
6378 (gnus-summary-refer-article
6379 (prog1 (match-string 0 ref)
6380 (setq ref (substring ref (match-end 0))))))
6381 (gnus-summary-goto-subject current)
6382 (gnus-summary-position-point)
6385 (defun gnus-summary-refer-thread (&optional limit)
6386 "Fetch all articles in the current thread.
6387 If LIMIT (the numerical prefix), fetch that many old headers instead
6388 of what's specified by the `gnus-refer-thread-limit' variable."
6390 (let ((id (mail-header-id (gnus-summary-article-header)))
6391 (limit (if limit (prefix-numeric-value limit)
6392 gnus-refer-thread-limit))
6394 ;; We want to fetch LIMIT *old* headers, but we also have to
6395 ;; re-fetch all the headers in the current buffer, because many of
6396 ;; them may be undisplayed. So we adjust LIMIT.
6397 (when (numberp limit)
6398 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6399 (unless (eq gnus-fetch-old-headers 'invisible)
6400 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6401 ;; Retrieve the headers and read them in.
6402 (if (eq (gnus-retrieve-headers
6403 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6405 (gnus-build-all-threads)
6406 (error "Can't fetch thread from backends that don't support NOV"))
6407 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6408 (gnus-summary-limit-include-thread id)))
6410 (defun gnus-summary-refer-article (message-id &optional arg)
6411 "Fetch an article specified by MESSAGE-ID.
6412 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6413 or `gnus-select-method', no matter what backend the article comes from."
6414 (interactive "sMessage-ID: \nP")
6415 (when (and (stringp message-id)
6416 (not (zerop (length message-id))))
6417 ;; Construct the correct Message-ID if necessary.
6418 ;; Suggested by tale@pawl.rpi.edu.
6419 (unless (string-match "^<" message-id)
6420 (setq message-id (concat "<" message-id)))
6421 (unless (string-match ">$" message-id)
6422 (setq message-id (concat message-id ">")))
6423 (let* ((header (gnus-id-to-header message-id))
6425 (gnus-summary-article-sparse-p
6426 (mail-header-number header))
6427 (memq (mail-header-number header)
6428 gnus-newsgroup-limit)))
6431 ;; If the article is present in the buffer we just go to it.
6433 (or (not (gnus-summary-article-sparse-p
6434 (mail-header-number header)))
6437 (gnus-summary-goto-article
6438 (mail-header-number header) nil t)
6440 (gnus-summary-update-article (mail-header-number header)))))
6442 ;; We fetch the article
6443 (let ((gnus-override-method
6444 (cond ((gnus-news-group-p gnus-newsgroup-name)
6445 gnus-refer-article-method)
6447 (or gnus-refer-article-method gnus-select-method))
6450 ;; Start the special refer-article method, if necessary.
6451 (when (and gnus-refer-article-method
6452 (gnus-news-group-p gnus-newsgroup-name))
6453 (gnus-check-server gnus-refer-article-method))
6454 ;; Fetch the header, and display the article.
6455 (if (setq number (gnus-summary-insert-subject message-id))
6456 (gnus-summary-select-article nil nil nil number)
6457 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6459 (defun gnus-summary-edit-parameters ()
6460 "Edit the group parameters of the current group."
6461 (gnus-group-edit-group gnus-newsgroup-name 'params))
6463 (defun gnus-summary-enter-digest-group (&optional force)
6464 "Enter an nndoc group based on the current article.
6465 If FORCE, force a digest interpretation. If not, try
6466 to guess what the document format is."
6468 (let ((conf gnus-current-window-configuration))
6470 (gnus-summary-select-article))
6471 (setq gnus-current-window-configuration conf)
6472 (let* ((name (format "%s-%d"
6473 (gnus-group-prefixed-name
6474 gnus-newsgroup-name (list 'nndoc ""))
6476 (set-buffer gnus-summary-buffer)
6477 gnus-current-article)))
6478 (ogroup gnus-newsgroup-name)
6479 (params (append (gnus-info-params (gnus-get-info ogroup))
6480 (list (cons 'to-group ogroup))
6481 (list (cons 'save-article-group ogroup))))
6482 (case-fold-search t)
6483 (buf (current-buffer))
6486 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6487 (insert-buffer-substring gnus-original-article-buffer)
6488 ;; Remove lines that may lead nndoc to misinterpret the
6491 (goto-char (point-min))
6492 (or (search-forward "\n\n" nil t) (point)))
6493 (goto-char (point-min))
6494 (delete-matching-lines "^\\(Path\\):\\|^From ")
6497 (if (gnus-group-read-ephemeral-group
6498 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6500 ,(if force 'digest 'guess))) t)
6501 ;; Make all postings to this group go to the parent group.
6502 (nconc (gnus-info-params (gnus-get-info name))
6504 ;; Couldn't select this doc group.
6505 (switch-to-buffer buf)
6506 (gnus-set-global-variables)
6507 (gnus-configure-windows 'summary)
6508 (gnus-message 3 "Article couldn't be entered?"))
6509 (kill-buffer dig)))))
6511 (defun gnus-summary-read-document (n)
6512 "Open a new group based on the current article(s).
6513 This will allow you to read digests and other similar
6514 documents as newsgroups.
6515 Obeys the standard process/prefix convention."
6517 (let* ((articles (gnus-summary-work-articles n))
6518 (ogroup gnus-newsgroup-name)
6519 (params (append (gnus-info-params (gnus-get-info ogroup))
6520 (list (cons 'to-group ogroup))))
6521 article group egroup groups vgroup)
6522 (while (setq article (pop articles))
6523 (setq group (format "%s-%d" gnus-newsgroup-name article))
6524 (gnus-summary-remove-process-mark article)
6525 (when (gnus-summary-display-article article)
6527 (nnheader-temp-write nil
6528 (insert-buffer-substring gnus-original-article-buffer)
6529 ;; Remove some headers that may lead nndoc to make
6531 (message-narrow-to-head)
6532 (goto-char (point-min))
6533 (delete-matching-lines "^\\(Path\\):\\|^From ")
6536 (gnus-group-read-ephemeral-group
6537 group `(nndoc ,group (nndoc-address ,(current-buffer))
6538 (nndoc-article-type guess))
6541 ;; Make all postings to this group go to the parent group.
6542 (nconc (gnus-info-params (gnus-get-info egroup))
6544 (push egroup groups))
6545 ;; Couldn't select this doc group.
6546 (gnus-error 3 "Article couldn't be entered"))))))
6547 ;; Now we have selected all the documents.
6550 (error "None of the articles could be interpreted as documents"))
6551 ((gnus-group-read-ephemeral-group
6552 (setq vgroup (format
6553 "nnvirtual:%s-%s" gnus-newsgroup-name
6554 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6555 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6557 (cons (current-buffer) 'summary)))
6559 (error "Couldn't select virtual nndoc group")))))
6561 (defun gnus-summary-isearch-article (&optional regexp-p)
6562 "Do incremental search forward on the current article.
6563 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6565 (gnus-summary-select-article)
6566 (gnus-configure-windows 'article)
6567 (gnus-eval-in-buffer-window gnus-article-buffer
6570 (isearch-forward regexp-p))))
6572 (defun gnus-summary-search-article-forward (regexp &optional backward)
6573 "Search for an article containing REGEXP forward.
6574 If BACKWARD, search backward instead."
6577 (format "Search article %s (regexp%s): "
6578 (if current-prefix-arg "backward" "forward")
6579 (if gnus-last-search-regexp
6580 (concat ", default " gnus-last-search-regexp)
6582 current-prefix-arg))
6583 (if (string-equal regexp "")
6584 (setq regexp (or gnus-last-search-regexp ""))
6585 (setq gnus-last-search-regexp regexp))
6586 (if (gnus-summary-search-article regexp backward)
6587 (gnus-summary-show-thread)
6588 (error "Search failed: \"%s\"" regexp)))
6590 (defun gnus-summary-search-article-backward (regexp)
6591 "Search for an article containing REGEXP backward."
6594 (format "Search article backward (regexp%s): "
6595 (if gnus-last-search-regexp
6596 (concat ", default " gnus-last-search-regexp)
6598 (gnus-summary-search-article-forward regexp 'backward))
6600 (defun gnus-summary-search-article (regexp &optional backward)
6601 "Search for an article containing REGEXP.
6602 Optional argument BACKWARD means do search for backward.
6603 `gnus-select-article-hook' is not called during the search."
6604 ;; We have to require this here to make sure that the following
6605 ;; dynamic binding isn't shadowed by autoloading.
6606 (require 'gnus-async)
6607 (let ((gnus-select-article-hook nil) ;Disable hook.
6608 (gnus-article-display-hook nil)
6609 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6610 (gnus-use-article-prefetch nil)
6611 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6612 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6613 (sum (current-buffer))
6616 (gnus-save-hidden-threads
6617 (gnus-summary-select-article)
6618 (set-buffer gnus-article-buffer)
6622 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6624 (re-search-backward regexp nil t)
6625 (re-search-forward regexp nil t))
6626 ;; We found the regexp.
6631 (get-buffer-window (current-buffer))
6635 (setq point (point)))
6636 ;; We didn't find it, so we go to the next article.
6639 (while (eq found 'not)
6640 (if (not (if backward (gnus-summary-find-prev)
6641 (gnus-summary-find-next)))
6642 ;; No more articles.
6644 ;; Select the next article and adjust point.
6645 (unless (gnus-summary-article-sparse-p
6646 (gnus-summary-article-number))
6648 (gnus-summary-select-article)
6649 (set-buffer gnus-article-buffer)
6651 (goto-char (if backward (point-max) (point-min))))))))
6652 (gnus-message 7 ""))
6653 ;; Return whether we found the regexp.
6654 (when (eq found 'found)
6656 (gnus-summary-show-thread)
6657 (gnus-summary-goto-subject gnus-current-article)
6658 (gnus-summary-position-point)
6661 (defun gnus-summary-find-matching (header regexp &optional backward unread
6663 "Return a list of all articles that match REGEXP on HEADER.
6664 The search stars on the current article and goes forwards unless
6665 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6666 If UNREAD is non-nil, only unread articles will
6667 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6668 in the comparisons."
6669 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6670 (gnus-data-find-list
6671 (gnus-summary-article-number) (gnus-data-list backward))))
6672 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6673 (case-fold-search (not not-case-fold))
6675 (unless (fboundp (intern (concat "mail-header-" header)))
6676 (error "%s is not a valid header" header))
6679 (and (or (not unread) ; We want all articles...
6680 (gnus-data-unread-p d)) ; Or just unreads.
6681 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6682 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6683 (push (gnus-data-number d) articles)) ; Success!
6684 (setq data (cdr data)))
6685 (nreverse articles)))
6687 (defun gnus-summary-execute-command (header regexp command &optional backward)
6688 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6689 If HEADER is an empty string (or nil), the match is done on the entire
6690 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6692 (list (let ((completion-ignore-case t))
6695 (mapcar (lambda (string) (list string))
6696 '("Number" "Subject" "From" "Lines" "Date"
6697 "Message-ID" "Xref" "References" "Body"))
6698 nil 'require-match))
6699 (read-string "Regexp: ")
6700 (read-key-sequence "Command: ")
6701 current-prefix-arg))
6702 (when (equal header "Body")
6704 ;; Hidden thread subtrees must be searched as well.
6705 (gnus-summary-show-all-threads)
6706 ;; We don't want to change current point nor window configuration.
6708 (save-window-excursion
6709 (gnus-message 6 "Executing %s..." (key-description command))
6710 ;; We'd like to execute COMMAND interactively so as to give arguments.
6711 (gnus-execute header regexp
6712 `(call-interactively ',(key-binding command))
6714 (gnus-message 6 "Executing %s...done" (key-description command)))))
6716 (defun gnus-summary-beginning-of-article ()
6717 "Scroll the article back to the beginning."
6719 (gnus-summary-select-article)
6720 (gnus-configure-windows 'article)
6721 (gnus-eval-in-buffer-window gnus-article-buffer
6723 (goto-char (point-min))
6724 (when gnus-page-broken
6725 (gnus-narrow-to-page))))
6727 (defun gnus-summary-end-of-article ()
6728 "Scroll to the end of the article."
6730 (gnus-summary-select-article)
6731 (gnus-configure-windows 'article)
6732 (gnus-eval-in-buffer-window gnus-article-buffer
6734 (goto-char (point-max))
6736 (when gnus-page-broken
6737 (gnus-narrow-to-page))))
6739 (defun gnus-summary-print-article (&optional filename n)
6740 "Generate and print a PostScript image of the N next (mail) articles.
6742 If N is negative, print the N previous articles. If N is nil and articles
6743 have been marked with the process mark, print these instead.
6745 If the optional second argument FILENAME is nil, send the image to the
6746 printer. If FILENAME is a string, save the PostScript image in a file with
6747 that name. If FILENAME is a number, prompt the user for the name of the file
6749 (interactive (list (ps-print-preprint current-prefix-arg)
6750 current-prefix-arg))
6751 (dolist (article (gnus-summary-work-articles n))
6752 (gnus-summary-select-article nil nil 'pseudo article)
6753 (gnus-eval-in-buffer-window gnus-article-buffer
6754 (let ((buffer (generate-new-buffer " *print*")))
6757 (copy-to-buffer buffer (point-min) (point-max))
6759 (gnus-article-delete-invisible-text)
6760 (let ((ps-left-header
6763 (mail-header-subject gnus-current-headers) ")")
6765 (mail-header-from gnus-current-headers) ")")))
6768 "/pagenumberstring load"
6770 (mail-header-date gnus-current-headers) ")"))))
6771 (gnus-run-hooks 'gnus-ps-print-hook)
6772 (ps-print-buffer-with-faces filename)))
6773 (kill-buffer buffer))))))
6775 (defun gnus-summary-show-article (&optional arg)
6776 "Force re-fetching of the current article.
6777 If ARG (the prefix) is non-nil, show the raw article without any
6778 article massaging functions being run."
6781 ;; Select the article the normal way.
6782 (gnus-summary-select-article nil 'force)
6783 ;; Bind the article treatment functions to nil.
6784 (let ((gnus-have-all-headers t)
6785 gnus-article-display-hook
6786 gnus-article-prepare-hook
6790 (gnus-summary-select-article nil 'force)))
6791 (gnus-summary-goto-subject gnus-current-article)
6792 (gnus-summary-position-point))
6794 (defun gnus-summary-verbose-headers (&optional arg)
6795 "Toggle permanent full header display.
6796 If ARG is a positive number, turn header display on.
6797 If ARG is a negative number, turn header display off."
6799 (setq gnus-show-all-headers
6800 (cond ((or (not (numberp arg))
6802 (not gnus-show-all-headers))
6805 (gnus-summary-show-article))
6807 (defun gnus-summary-toggle-header (&optional arg)
6808 "Show the headers if they are hidden, or hide them if they are shown.
6809 If ARG is a positive number, show the entire header.
6810 If ARG is a negative number, hide the unwanted header lines."
6813 (set-buffer gnus-article-buffer)
6814 (let* ((buffer-read-only nil)
6815 (inhibit-point-motion-hooks t)
6816 (hidden (text-property-any
6817 (goto-char (point-min)) (search-forward "\n\n")
6820 (goto-char (point-min))
6821 (when (search-forward "\n\n" nil t)
6822 (delete-region (point-min) (1- (point))))
6823 (goto-char (point-min))
6825 (set-buffer gnus-original-article-buffer)
6826 (goto-char (point-min))
6827 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6828 (insert-buffer-substring gnus-original-article-buffer 1 e)
6829 (let ((article-inhibit-hiding t))
6830 (gnus-run-hooks 'gnus-article-display-hook))
6831 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6832 (gnus-article-hide-headers)))))
6834 (defun gnus-summary-show-all-headers ()
6835 "Make all header lines visible."
6837 (gnus-article-show-all-headers))
6839 (defun gnus-summary-toggle-mime (&optional arg)
6840 "Toggle MIME processing.
6841 If ARG is a positive number, turn MIME processing on."
6843 (setq gnus-show-mime
6844 (if (null arg) (not gnus-show-mime)
6845 (> (prefix-numeric-value arg) 0)))
6846 (gnus-summary-select-article t 'force))
6848 (defun gnus-summary-caesar-message (&optional arg)
6849 "Caesar rotate the current article by 13.
6850 The numerical prefix specifies how many places to rotate each letter
6853 (gnus-summary-select-article)
6854 (let ((mail-header-separator ""))
6855 (gnus-eval-in-buffer-window gnus-article-buffer
6858 (let ((start (window-start))
6860 (message-caesar-buffer-body arg)
6861 (set-window-start (get-buffer-window (current-buffer)) start))))))
6863 (defun gnus-summary-stop-page-breaking ()
6864 "Stop page breaking in the current article."
6866 (gnus-summary-select-article)
6867 (gnus-eval-in-buffer-window gnus-article-buffer
6869 (when (gnus-visual-p 'page-marker)
6870 (let ((buffer-read-only nil))
6871 (gnus-remove-text-with-property 'gnus-prev)
6872 (gnus-remove-text-with-property 'gnus-next))
6873 (setq gnus-page-broken nil))))
6875 (defun gnus-summary-move-article (&optional n to-newsgroup
6876 select-method action)
6877 "Move the current article to a different newsgroup.
6878 If N is a positive number, move the N next articles.
6879 If N is a negative number, move the N previous articles.
6880 If N is nil and any articles have been marked with the process mark,
6881 move those articles instead.
6882 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6883 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6884 re-spool using this method.
6886 For this function to work, both the current newsgroup and the
6887 newsgroup that you want to move to have to support the `request-move'
6888 and `request-accept' functions."
6891 (setq action 'move))
6892 ;; Disable marking as read.
6893 (let (gnus-mark-article-hook)
6894 (save-window-excursion
6895 (gnus-summary-select-article)))
6896 ;; Check whether the source group supports the required functions.
6897 (cond ((and (eq action 'move)
6898 (not (gnus-check-backend-function
6899 'request-move-article gnus-newsgroup-name)))
6900 (error "The current group does not support article moving"))
6901 ((and (eq action 'crosspost)
6902 (not (gnus-check-backend-function
6903 'request-replace-article gnus-newsgroup-name)))
6904 (error "The current group does not support article editing")))
6905 (let ((articles (gnus-summary-work-articles n))
6906 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6907 (names '((move "Move" "Moving")
6908 (copy "Copy" "Copying")
6909 (crosspost "Crosspost" "Crossposting")))
6910 (copy-buf (save-excursion
6911 (nnheader-set-temp-buffer " *copy article*")))
6912 art-group to-method new-xref article to-groups)
6913 (unless (assq action names)
6914 (error "Unknown action %s" action))
6915 ;; Read the newsgroup name.
6916 (when (and (not to-newsgroup)
6917 (not select-method))
6919 (gnus-read-move-group-name
6920 (cadr (assq action names))
6921 (symbol-value (intern (format "gnus-current-%s-group" action)))
6923 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6924 (setq to-method (or select-method
6925 (gnus-group-name-to-method to-newsgroup)))
6926 ;; Check the method we are to move this article to...
6927 (unless (gnus-check-backend-function
6928 'request-accept-article (car to-method))
6929 (error "%s does not support article copying" (car to-method)))
6930 (unless (gnus-check-server to-method)
6931 (error "Can't open server %s" (car to-method)))
6932 (gnus-message 6 "%s to %s: %s..."
6933 (caddr (assq action names))
6934 (or (car select-method) to-newsgroup) articles)
6936 (setq article (pop articles))
6940 ;; Move the article.
6942 ;; Remove this article from future suppression.
6943 (gnus-dup-unsuppress-article article)
6944 (gnus-request-move-article
6945 article ; Article to move
6946 gnus-newsgroup-name ; From newsgroup
6947 (nth 1 (gnus-find-method-for-group
6948 gnus-newsgroup-name)) ; Server
6949 (list 'gnus-request-accept-article
6950 to-newsgroup (list 'quote select-method)
6951 (not articles)) ; Accept form
6952 (not articles))) ; Only save nov last time
6953 ;; Copy the article.
6956 (set-buffer copy-buf)
6957 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6958 (gnus-request-accept-article
6959 to-newsgroup select-method (not articles)))))
6960 ;; Crosspost the article.
6961 ((eq action 'crosspost)
6962 (let ((xref (message-tokenize-header
6963 (mail-header-xref (gnus-summary-article-header article))
6965 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6968 (setq xref (list (system-name))))
6971 (mapconcat 'identity
6972 (delete "Xref:" (delete new-xref xref))
6976 (set-buffer copy-buf)
6977 ;; First put the article in the destination group.
6978 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6979 (when (consp (setq art-group
6980 (gnus-request-accept-article
6981 to-newsgroup select-method (not articles))))
6982 (setq new-xref (concat new-xref " " (car art-group)
6983 ":" (cdr art-group)))
6984 ;; Now we have the new Xrefs header, so we insert
6985 ;; it and replace the new article.
6986 (nnheader-replace-header "Xref" new-xref)
6987 (gnus-request-replace-article
6988 (cdr art-group) to-newsgroup (current-buffer))
6992 (gnus-message 1 "Couldn't %s article %s"
6993 (cadr (assq action names)) article))
6994 ((and (eq art-group 'junk)
6996 (gnus-summary-mark-article article gnus-canceled-mark)
6997 (gnus-message 4 "Deleted article %s" article))
7001 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7003 (gnus-group-prefixed-name
7006 (gnus-find-method-for-group to-newsgroup)))
7007 gnus-newsrc-hashtb)))
7008 (info (nth 2 entry))
7009 (to-group (gnus-info-group info)))
7010 ;; Update the group that has been moved to.
7012 (memq action '(move copy)))
7013 (unless (member to-group to-groups)
7014 (push to-group to-groups))
7016 (unless (memq article gnus-newsgroup-unreads)
7018 info (gnus-add-to-range (gnus-info-read info)
7019 (list (cdr art-group)))))
7021 ;; Copy any marks over to the new group.
7022 (let ((marks gnus-article-mark-lists)
7023 (to-article (cdr art-group)))
7025 ;; See whether the article is to be put in the cache.
7026 (when gnus-use-cache
7027 (gnus-cache-possibly-enter-article
7029 (let ((header (copy-sequence
7030 (gnus-summary-article-header article))))
7031 (mail-header-set-number header to-article)
7033 (memq article gnus-newsgroup-marked)
7034 (memq article gnus-newsgroup-dormant)
7035 (memq article gnus-newsgroup-unreads)))
7037 (when (and (equal to-group gnus-newsgroup-name)
7038 (not (memq article gnus-newsgroup-unreads)))
7039 ;; Mark this article as read in this group.
7040 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7041 (setcdr (gnus-active to-group) to-article)
7042 (setcdr gnus-newsgroup-active to-article))
7045 (when (memq article (symbol-value
7046 (intern (format "gnus-newsgroup-%s"
7048 ;; If the other group is the same as this group,
7049 ;; then we have to add the mark to the list.
7050 (when (equal to-group gnus-newsgroup-name)
7051 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7054 (intern (format "gnus-newsgroup-%s"
7056 ;; Copy the marks to other group.
7057 (gnus-add-marked-articles
7058 to-group (cdar marks) (list to-article) info))
7059 (setq marks (cdr marks)))
7062 (concat "(gnus-group-set-info '"
7063 (gnus-prin1-to-string (gnus-get-info to-group))
7066 ;; Update the Xref header in this article to point to
7067 ;; the new crossposted article we have just created.
7068 (when (eq action 'crosspost)
7070 (set-buffer copy-buf)
7071 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7072 (nnheader-replace-header "Xref" new-xref)
7073 (gnus-request-replace-article
7074 article gnus-newsgroup-name (current-buffer)))))
7076 ;;;!!!Why is this necessary?
7077 (set-buffer gnus-summary-buffer)
7079 (gnus-summary-goto-subject article)
7080 (when (eq action 'move)
7081 (gnus-summary-mark-article article gnus-canceled-mark))))
7082 (gnus-summary-remove-process-mark article))
7083 ;; Re-activate all groups that have been moved to.
7086 (set-buffer gnus-group-buffer)
7087 (when (gnus-group-goto-group (car to-groups) t)
7088 (gnus-group-get-new-news-this-group 1 t))
7091 (gnus-kill-buffer copy-buf)
7092 (gnus-summary-position-point)
7093 (gnus-set-mode-line 'summary)))
7095 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7096 "Move the current article to a different newsgroup.
7097 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7098 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7099 re-spool using this method."
7101 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7103 (defun gnus-summary-crosspost-article (&optional n)
7104 "Crosspost the current article to some other group."
7106 (gnus-summary-move-article n nil nil 'crosspost))
7108 (defcustom gnus-summary-respool-default-method nil
7109 "Default method for respooling an article.
7110 If nil, use to the current newsgroup method."
7111 :type `(choice (gnus-select-method :value (nnml ""))
7113 :group 'gnus-summary-mail)
7115 (defun gnus-summary-respool-article (&optional n method)
7116 "Respool the current article.
7117 The article will be squeezed through the mail spooling process again,
7118 which means that it will be put in some mail newsgroup or other
7119 depending on `nnmail-split-methods'.
7120 If N is a positive number, respool the N next articles.
7121 If N is a negative number, respool the N previous articles.
7122 If N is nil and any articles have been marked with the process mark,
7123 respool those articles instead.
7125 Respooling can be done both from mail groups and \"real\" newsgroups.
7126 In the former case, the articles in question will be moved from the
7127 current group into whatever groups they are destined to. In the
7128 latter case, they will be copied into the relevant groups."
7130 (list current-prefix-arg
7131 (let* ((methods (gnus-methods-using 'respool))
7133 (symbol-name (or gnus-summary-respool-default-method
7134 (car (gnus-find-method-for-group
7135 gnus-newsgroup-name)))))
7137 (gnus-completing-read
7138 methname "What backend do you want to use when respooling?"
7139 methods nil t nil 'gnus-mail-method-history))
7142 ((zerop (length (setq ms (gnus-servers-using-backend
7144 (list (intern method) ""))
7148 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7149 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7152 (error "No method given for respooling"))
7153 (if (assoc (symbol-name
7154 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7155 (gnus-methods-using 'respool))
7156 (gnus-summary-move-article n nil method)
7157 (gnus-summary-copy-article n nil method)))
7159 (defun gnus-summary-import-article (file)
7160 "Import a random file into a mail newsgroup."
7161 (interactive "fImport file: ")
7162 (let ((group gnus-newsgroup-name)
7163 (now (current-time))
7165 (unless (gnus-check-backend-function 'request-accept-article group)
7166 (error "%s does not support article importing" group))
7167 (or (file-readable-p file)
7168 (not (file-regular-p file))
7169 (error "Can't read %s" file))
7171 (set-buffer (get-buffer-create " *import file*"))
7172 (buffer-disable-undo (current-buffer))
7174 (insert-file-contents file)
7175 (goto-char (point-min))
7176 (unless (nnheader-article-p)
7177 ;; This doesn't look like an article, so we fudge some headers.
7178 (setq atts (file-attributes file)
7179 lines (count-lines (point-min) (point-max)))
7180 (insert "From: " (read-string "From: ") "\n"
7181 "Subject: " (read-string "Subject: ") "\n"
7182 "Date: " (timezone-make-date-arpa-standard
7183 (current-time-string (nth 5 atts))
7184 (current-time-zone now)
7185 (current-time-zone now))
7187 "Message-ID: " (message-make-message-id) "\n"
7188 "Lines: " (int-to-string lines) "\n"
7189 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7190 (gnus-request-accept-article group nil t)
7191 (kill-buffer (current-buffer)))))
7193 (defun gnus-summary-article-posted-p ()
7194 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7195 This will be the case if the article has both been mailed and posted."
7197 (let ((id (mail-header-references (gnus-summary-article-header)))
7198 (gnus-override-method
7199 (or gnus-refer-article-method gnus-select-method)))
7200 (if (gnus-request-head id "")
7201 (gnus-message 2 "The current message was found on %s"
7202 gnus-override-method)
7203 (gnus-message 2 "The current message couldn't be found on %s"
7204 gnus-override-method)
7207 (defun gnus-summary-expire-articles (&optional now)
7208 "Expire all articles that are marked as expirable in the current group."
7210 (when (gnus-check-backend-function
7211 'request-expire-articles gnus-newsgroup-name)
7212 ;; This backend supports expiry.
7213 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7214 (expirable (if total
7216 ;; We need to update the info for
7217 ;; this group for `gnus-list-of-read-articles'
7218 ;; to give us the right answer.
7219 (gnus-run-hooks 'gnus-exit-group-hook)
7220 (gnus-summary-update-info)
7221 (gnus-list-of-read-articles gnus-newsgroup-name))
7222 (setq gnus-newsgroup-expirable
7223 (sort gnus-newsgroup-expirable '<))))
7224 (expiry-wait (if now 'immediate
7225 (gnus-group-find-parameter
7226 gnus-newsgroup-name 'expiry-wait)))
7229 ;; There are expirable articles in this group, so we run them
7230 ;; through the expiry process.
7231 (gnus-message 6 "Expiring articles...")
7232 ;; The list of articles that weren't expired is returned.
7235 (let ((nnmail-expiry-wait-function nil)
7236 (nnmail-expiry-wait expiry-wait))
7237 (setq es (gnus-request-expire-articles
7238 expirable gnus-newsgroup-name)))
7239 (setq es (gnus-request-expire-articles
7240 expirable gnus-newsgroup-name))))
7242 (setq gnus-newsgroup-expirable es))
7243 ;; We go through the old list of expirable, and mark all
7244 ;; really expired articles as nonexistent.
7245 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7246 (let ((gnus-use-cache nil))
7248 (unless (memq (car expirable) es)
7249 (when (gnus-data-find (car expirable))
7250 (gnus-summary-mark-article
7251 (car expirable) gnus-canceled-mark)))
7252 (setq expirable (cdr expirable)))))
7253 (gnus-message 6 "Expiring articles...done")))))
7255 (defun gnus-summary-expire-articles-now ()
7256 "Expunge all expirable articles in the current group.
7257 This means that *all* articles that are marked as expirable will be
7258 deleted forever, right now."
7260 (unless gnus-expert-user
7262 "Are you really, really, really sure you want to delete all these messages? ")
7264 (gnus-summary-expire-articles t))
7266 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7267 (defun gnus-summary-delete-article (&optional n)
7268 "Delete the N next (mail) articles.
7269 This command actually deletes articles. This is not a marking
7270 command. The article will disappear forever from your life, never to
7272 If N is negative, delete backwards.
7273 If N is nil and articles have been marked with the process mark,
7274 delete these instead."
7276 (unless (gnus-check-backend-function 'request-expire-articles
7277 gnus-newsgroup-name)
7278 (error "The current newsgroup does not support article deletion"))
7279 ;; Compute the list of articles to delete.
7280 (let ((articles (gnus-summary-work-articles n))
7282 (if (and gnus-novice-user
7283 (not (gnus-yes-or-no-p
7284 (format "Do you really want to delete %s forever? "
7285 (if (> (length articles) 1)
7286 (format "these %s articles" (length articles))
7289 ;; Delete the articles.
7290 (setq not-deleted (gnus-request-expire-articles
7291 articles gnus-newsgroup-name 'force))
7293 (gnus-summary-remove-process-mark (car articles))
7294 ;; The backend might not have been able to delete the article
7296 (unless (memq (car articles) not-deleted)
7297 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7298 (setq articles (cdr articles)))
7300 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7301 (gnus-summary-position-point)
7302 (gnus-set-mode-line 'summary)
7305 (defun gnus-summary-edit-article (&optional force)
7306 "Edit the current article.
7307 This will have permanent effect only in mail groups.
7308 If FORCE is non-nil, allow editing of articles even in read-only
7312 (set-buffer gnus-summary-buffer)
7313 (gnus-set-global-variables)
7314 (when (and (not force)
7315 (gnus-group-read-only-p))
7316 (error "The current newsgroup does not support article editing"))
7317 ;; Select article if needed.
7318 (unless (eq (gnus-summary-article-number)
7319 gnus-current-article)
7320 (gnus-summary-select-article t))
7321 (gnus-article-date-original)
7322 (gnus-article-edit-article
7323 `(lambda (no-highlight)
7324 (gnus-summary-edit-article-done
7325 ,(or (mail-header-references gnus-current-headers) "")
7326 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7328 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7330 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7332 "Make edits to the current article permanent."
7334 ;; Replace the article.
7335 (if (and (not read-only)
7336 (not (gnus-request-replace-article
7337 (cdr gnus-article-current) (car gnus-article-current)
7339 (error "Couldn't replace article")
7340 ;; Update the summary buffer.
7342 (equal (message-tokenize-header references " ")
7343 (message-tokenize-header
7344 (or (message-fetch-field "references") "") " ")))
7345 ;; We only have to update this line.
7348 (message-narrow-to-head)
7349 (let ((head (buffer-string))
7351 (nnheader-temp-write nil
7352 (insert (format "211 %d Article retrieved.\n"
7353 (cdr gnus-article-current)))
7356 (let ((nntp-server-buffer (current-buffer)))
7357 (setq header (car (gnus-get-newsgroup-headers
7359 (set-buffer gnus-summary-buffer)
7360 gnus-newsgroup-dependencies)
7363 (set-buffer gnus-summary-buffer)
7364 (gnus-data-set-header
7365 (gnus-data-find (cdr gnus-article-current))
7367 (gnus-summary-update-article-line
7368 (cdr gnus-article-current) header))))))
7370 (set-buffer (or buffer gnus-summary-buffer))
7371 (gnus-summary-update-article (cdr gnus-article-current)))
7372 ;; Prettify the article buffer again.
7373 (unless no-highlight
7375 (set-buffer gnus-article-buffer)
7376 (gnus-run-hooks 'gnus-article-display-hook)
7377 (set-buffer gnus-original-article-buffer)
7378 (gnus-request-article
7379 (cdr gnus-article-current)
7380 (car gnus-article-current) (current-buffer))))
7381 ;; Prettify the summary buffer line.
7382 (when (gnus-visual-p 'summary-highlight 'highlight)
7383 (gnus-run-hooks 'gnus-visual-mark-article-hook))))
7385 (defun gnus-summary-edit-wash (key)
7386 "Perform editing command in the article buffer."
7390 (message "%s" (concat (this-command-keys) "- "))
7393 (gnus-summary-edit-article)
7394 (execute-kbd-macro (concat (this-command-keys) key))
7395 (gnus-article-edit-done))
7399 (defun gnus-summary-respool-query (&optional silent)
7400 "Query where the respool algorithm would put this article."
7402 (let (gnus-mark-article-hook)
7403 (gnus-summary-select-article)
7405 (set-buffer gnus-original-article-buffer)
7407 (message-narrow-to-head)
7408 (let ((groups (nnmail-article-group 'identity)))
7411 (message "This message would go to %s"
7412 (mapconcat 'car groups ", "))
7413 (message "This message would go to no groups"))
7416 ;; Summary marking commands.
7418 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7419 "Mark articles which has the same subject as read, and then select the next.
7420 If UNMARK is positive, remove any kind of mark.
7421 If UNMARK is negative, tick articles."
7424 (setq unmark (prefix-numeric-value unmark)))
7426 (gnus-summary-mark-same-subject
7427 (gnus-summary-article-subject) unmark)))
7428 ;; Select next unread article. If auto-select-same mode, should
7429 ;; select the first unread article.
7430 (gnus-summary-next-article t (and gnus-auto-select-same
7431 (gnus-summary-article-subject)))
7432 (gnus-message 7 "%d article%s marked as %s"
7433 count (if (= count 1) " is" "s are")
7434 (if unmark "unread" "read"))))
7436 (defun gnus-summary-kill-same-subject (&optional unmark)
7437 "Mark articles which has the same subject as read.
7438 If UNMARK is positive, remove any kind of mark.
7439 If UNMARK is negative, tick articles."
7442 (setq unmark (prefix-numeric-value unmark)))
7444 (gnus-summary-mark-same-subject
7445 (gnus-summary-article-subject) unmark)))
7446 ;; If marked as read, go to next unread subject.
7448 ;; Go to next unread subject.
7449 (gnus-summary-next-subject 1 t))
7450 (gnus-message 7 "%d articles are marked as %s"
7451 count (if unmark "unread" "read"))))
7453 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7454 "Mark articles with same SUBJECT as read, and return marked number.
7455 If optional argument UNMARK is positive, remove any kinds of marks.
7456 If optional argument UNMARK is negative, mark articles as unread instead."
7460 ((null unmark) ; Mark as read.
7463 (gnus-summary-mark-article-as-read gnus-killed-mark)
7464 (gnus-summary-show-thread) t)
7465 (gnus-summary-find-subject subject))
7466 (setq count (1+ count))))
7467 ((> unmark 0) ; Tick.
7470 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7471 (gnus-summary-show-thread) t)
7472 (gnus-summary-find-subject subject))
7473 (setq count (1+ count))))
7474 (t ; Mark as unread.
7477 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7478 (gnus-summary-show-thread) t)
7479 (gnus-summary-find-subject subject))
7480 (setq count (1+ count)))))
7481 (gnus-set-mode-line 'summary)
7482 ;; Return the number of marked articles.
7485 (defun gnus-summary-mark-as-processable (n &optional unmark)
7486 "Set the process mark on the next N articles.
7487 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7488 the process mark instead. The difference between N and the actual
7489 number of articles marked is returned."
7491 (let ((backward (< n 0))
7496 (gnus-summary-remove-process-mark
7497 (gnus-summary-article-number))
7498 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7499 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7502 (gnus-message 7 "No more articles"))
7503 (gnus-summary-recenter)
7504 (gnus-summary-position-point)
7507 (defun gnus-summary-unmark-as-processable (n)
7508 "Remove the process mark from the next N articles.
7509 If N is negative, unmark backward instead. The difference between N and
7510 the actual number of articles unmarked is returned."
7512 (gnus-summary-mark-as-processable n t))
7514 (defun gnus-summary-unmark-all-processable ()
7515 "Remove the process mark from all articles."
7518 (while gnus-newsgroup-processable
7519 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7520 (gnus-summary-position-point))
7522 (defun gnus-summary-mark-as-expirable (n)
7523 "Mark N articles forward as expirable.
7524 If N is negative, mark backward instead. The difference between N and
7525 the actual number of articles marked is returned."
7527 (gnus-summary-mark-forward n gnus-expirable-mark))
7529 (defun gnus-summary-mark-article-as-replied (article)
7530 "Mark ARTICLE replied and update the summary line."
7531 (push article gnus-newsgroup-replied)
7532 (let ((buffer-read-only nil))
7533 (when (gnus-summary-goto-subject article)
7534 (gnus-summary-update-secondary-mark article))))
7536 (defun gnus-summary-set-bookmark (article)
7537 "Set a bookmark in current article."
7538 (interactive (list (gnus-summary-article-number)))
7539 (when (or (not (get-buffer gnus-article-buffer))
7540 (not gnus-current-article)
7541 (not gnus-article-current)
7542 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7543 (error "No current article selected"))
7544 ;; Remove old bookmark, if one exists.
7545 (let ((old (assq article gnus-newsgroup-bookmarks)))
7547 (setq gnus-newsgroup-bookmarks
7548 (delq old gnus-newsgroup-bookmarks))))
7549 ;; Set the new bookmark, which is on the form
7550 ;; (article-number . line-number-in-body).
7554 (set-buffer gnus-article-buffer)
7558 (goto-char (point-min))
7559 (search-forward "\n\n" nil t)
7562 gnus-newsgroup-bookmarks)
7563 (gnus-message 6 "A bookmark has been added to the current article."))
7565 (defun gnus-summary-remove-bookmark (article)
7566 "Remove the bookmark from the current article."
7567 (interactive (list (gnus-summary-article-number)))
7568 ;; Remove old bookmark, if one exists.
7569 (let ((old (assq article gnus-newsgroup-bookmarks)))
7572 (setq gnus-newsgroup-bookmarks
7573 (delq old gnus-newsgroup-bookmarks))
7574 (gnus-message 6 "Removed bookmark."))
7575 (gnus-message 6 "No bookmark in current article."))))
7577 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7578 (defun gnus-summary-mark-as-dormant (n)
7579 "Mark N articles forward as dormant.
7580 If N is negative, mark backward instead. The difference between N and
7581 the actual number of articles marked is returned."
7583 (gnus-summary-mark-forward n gnus-dormant-mark))
7585 (defun gnus-summary-set-process-mark (article)
7586 "Set the process mark on ARTICLE and update the summary line."
7587 (setq gnus-newsgroup-processable
7589 (delq article gnus-newsgroup-processable)))
7590 (when (gnus-summary-goto-subject article)
7591 (gnus-summary-show-thread)
7592 (gnus-summary-update-secondary-mark article)))
7594 (defun gnus-summary-remove-process-mark (article)
7595 "Remove the process mark from ARTICLE and update the summary line."
7596 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7597 (when (gnus-summary-goto-subject article)
7598 (gnus-summary-show-thread)
7599 (gnus-summary-update-secondary-mark article)))
7601 (defun gnus-summary-set-saved-mark (article)
7602 "Set the process mark on ARTICLE and update the summary line."
7603 (push article gnus-newsgroup-saved)
7604 (when (gnus-summary-goto-subject article)
7605 (gnus-summary-update-secondary-mark article)))
7607 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7608 "Mark N articles as read forwards.
7609 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7610 The difference between N and the actual number of articles marked is
7613 (let ((backward (< n 0))
7614 (gnus-summary-goto-unread
7615 (and gnus-summary-goto-unread
7616 (not (eq gnus-summary-goto-unread 'never))
7617 (not (memq mark (list gnus-unread-mark
7618 gnus-ticked-mark gnus-dormant-mark)))))
7620 (mark (or mark gnus-del-mark)))
7622 (gnus-summary-mark-article nil mark no-expire)
7623 (zerop (gnus-summary-next-subject
7625 (and gnus-summary-goto-unread
7626 (not (eq gnus-summary-goto-unread 'never)))
7630 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7631 (gnus-summary-recenter)
7632 (gnus-summary-position-point)
7633 (gnus-set-mode-line 'summary)
7636 (defun gnus-summary-mark-article-as-read (mark)
7637 "Mark the current article quickly as read with MARK."
7638 (let ((article (gnus-summary-article-number)))
7639 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7640 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7641 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7642 (push (cons article mark) gnus-newsgroup-reads)
7643 ;; Possibly remove from cache, if that is used.
7644 (when gnus-use-cache
7645 (gnus-cache-enter-remove-article article))
7646 ;; Allow the backend to change the mark.
7647 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7648 ;; Check for auto-expiry.
7649 (when (and gnus-newsgroup-auto-expire
7650 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7651 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7652 (= mark gnus-ancient-mark)
7653 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7654 (= mark gnus-duplicate-mark)))
7655 (setq mark gnus-expirable-mark)
7656 (push article gnus-newsgroup-expirable))
7657 ;; Set the mark in the buffer.
7658 (gnus-summary-update-mark mark 'unread)
7661 (defun gnus-summary-mark-article-as-unread (mark)
7662 "Mark the current article quickly as unread with MARK."
7663 (let* ((article (gnus-summary-article-number))
7664 (old-mark (gnus-summary-article-mark article)))
7665 (if (eq mark old-mark)
7669 (gnus-error 1 "Can't mark negative article numbers")
7671 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7672 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7673 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7674 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7675 (cond ((= mark gnus-ticked-mark)
7676 (push article gnus-newsgroup-marked))
7677 ((= mark gnus-dormant-mark)
7678 (push article gnus-newsgroup-dormant))
7680 (push article gnus-newsgroup-unreads)))
7681 (setq gnus-newsgroup-reads
7682 (delq (assq article gnus-newsgroup-reads)
7683 gnus-newsgroup-reads))
7685 ;; See whether the article is to be put in the cache.
7687 (vectorp (gnus-summary-article-header article))
7689 (gnus-cache-possibly-enter-article
7690 gnus-newsgroup-name article
7691 (gnus-summary-article-header article)
7692 (= mark gnus-ticked-mark)
7693 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7696 (gnus-summary-update-mark mark 'unread)
7699 (defun gnus-summary-mark-article (&optional article mark no-expire)
7700 "Mark ARTICLE with MARK. MARK can be any character.
7701 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7702 `??' (dormant) and `?E' (expirable).
7703 If MARK is nil, then the default character `?D' is used.
7704 If ARTICLE is nil, then the article on the current line will be
7706 ;; The mark might be a string.
7707 (when (stringp mark)
7708 (setq mark (aref mark 0)))
7709 ;; If no mark is given, then we check auto-expiring.
7710 (and (not no-expire)
7711 gnus-newsgroup-auto-expire
7713 (and (gnus-characterp mark)
7714 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7715 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7716 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7717 (= mark gnus-duplicate-mark))))
7718 (setq mark gnus-expirable-mark))
7719 (let* ((mark (or mark gnus-del-mark))
7720 (article (or article (gnus-summary-article-number)))
7721 (old-mark (gnus-summary-article-mark article)))
7722 (if (eq mark old-mark)
7725 (error "No article on current line"))
7726 (if (not (if (or (= mark gnus-unread-mark)
7727 (= mark gnus-ticked-mark)
7728 (= mark gnus-dormant-mark))
7729 (gnus-mark-article-as-unread article mark)
7730 (gnus-mark-article-as-read article mark)))
7732 ;; See whether the article is to be put in the cache.
7734 (not (= mark gnus-canceled-mark))
7735 (vectorp (gnus-summary-article-header article))
7737 (gnus-cache-possibly-enter-article
7738 gnus-newsgroup-name article
7739 (gnus-summary-article-header article)
7740 (= mark gnus-ticked-mark)
7741 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7743 (when (gnus-summary-goto-subject article nil t)
7744 (let ((buffer-read-only nil))
7745 (gnus-summary-show-thread)
7747 (gnus-summary-update-mark mark 'unread)
7750 (defun gnus-summary-update-secondary-mark (article)
7751 "Update the secondary (read, process, cache) mark."
7752 (gnus-summary-update-mark
7753 (cond ((memq article gnus-newsgroup-processable)
7755 ((memq article gnus-newsgroup-cached)
7757 ((memq article gnus-newsgroup-replied)
7759 ((memq article gnus-newsgroup-saved)
7761 (t gnus-unread-mark))
7763 (when (gnus-visual-p 'summary-highlight 'highlight)
7764 (gnus-run-hooks 'gnus-summary-update-hook))
7767 (defun gnus-summary-update-mark (mark type)
7768 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7769 (buffer-read-only nil))
7770 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7771 (when (looking-at "\r")
7774 (<= (+ forward (point)) (point-max)))
7775 ;; Go to the right position on the line.
7776 (goto-char (+ forward (point)))
7777 ;; Replace the old mark with the new mark.
7778 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7779 ;; Optionally update the marks by some user rule.
7780 (when (eq type 'unread)
7782 (gnus-data-find (gnus-summary-article-number)) mark)
7783 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7785 (defun gnus-mark-article-as-read (article &optional mark)
7786 "Enter ARTICLE in the pertinent lists and remove it from others."
7787 ;; Make the article expirable.
7788 (let ((mark (or mark gnus-del-mark)))
7789 (if (= mark gnus-expirable-mark)
7790 (push article gnus-newsgroup-expirable)
7791 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7792 ;; Remove from unread and marked lists.
7793 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7794 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7795 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7796 (push (cons article mark) gnus-newsgroup-reads)
7797 ;; Possibly remove from cache, if that is used.
7798 (when gnus-use-cache
7799 (gnus-cache-enter-remove-article article))
7802 (defun gnus-mark-article-as-unread (article &optional mark)
7803 "Enter ARTICLE in the pertinent lists and remove it from others."
7804 (let ((mark (or mark gnus-ticked-mark)))
7807 (gnus-error 1 "Can't mark negative article numbers")
7809 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7810 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7811 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7812 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7814 ;; Unsuppress duplicates?
7815 (when gnus-suppress-duplicates
7816 (gnus-dup-unsuppress-article article))
7818 (cond ((= mark gnus-ticked-mark)
7819 (push article gnus-newsgroup-marked))
7820 ((= mark gnus-dormant-mark)
7821 (push article gnus-newsgroup-dormant))
7823 (push article gnus-newsgroup-unreads)))
7824 (setq gnus-newsgroup-reads
7825 (delq (assq article gnus-newsgroup-reads)
7826 gnus-newsgroup-reads))
7829 (defalias 'gnus-summary-mark-as-unread-forward
7830 'gnus-summary-tick-article-forward)
7831 (make-obsolete 'gnus-summary-mark-as-unread-forward
7832 'gnus-summary-tick-article-forward)
7833 (defun gnus-summary-tick-article-forward (n)
7834 "Tick N articles forwards.
7835 If N is negative, tick backwards instead.
7836 The difference between N and the number of articles ticked is returned."
7838 (gnus-summary-mark-forward n gnus-ticked-mark))
7840 (defalias 'gnus-summary-mark-as-unread-backward
7841 'gnus-summary-tick-article-backward)
7842 (make-obsolete 'gnus-summary-mark-as-unread-backward
7843 'gnus-summary-tick-article-backward)
7844 (defun gnus-summary-tick-article-backward (n)
7845 "Tick N articles backwards.
7846 The difference between N and the number of articles ticked is returned."
7848 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7850 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7851 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7852 (defun gnus-summary-tick-article (&optional article clear-mark)
7853 "Mark current article as unread.
7854 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7855 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7857 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7860 (defun gnus-summary-mark-as-read-forward (n)
7861 "Mark N articles as read forwards.
7862 If N is negative, mark backwards instead.
7863 The difference between N and the actual number of articles marked is
7866 (gnus-summary-mark-forward n gnus-del-mark t))
7868 (defun gnus-summary-mark-as-read-backward (n)
7869 "Mark the N articles as read backwards.
7870 The difference between N and the actual number of articles marked is
7873 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7875 (defun gnus-summary-mark-as-read (&optional article mark)
7876 "Mark current article as read.
7877 ARTICLE specifies the article to be marked as read.
7878 MARK specifies a string to be inserted at the beginning of the line."
7879 (gnus-summary-mark-article article mark))
7881 (defun gnus-summary-clear-mark-forward (n)
7882 "Clear marks from N articles forward.
7883 If N is negative, clear backward instead.
7884 The difference between N and the number of marks cleared is returned."
7886 (gnus-summary-mark-forward n gnus-unread-mark))
7888 (defun gnus-summary-clear-mark-backward (n)
7889 "Clear marks from N articles backward.
7890 The difference between N and the number of marks cleared is returned."
7892 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7894 (defun gnus-summary-mark-unread-as-read ()
7895 "Intended to be used by `gnus-summary-mark-article-hook'."
7896 (when (memq gnus-current-article gnus-newsgroup-unreads)
7897 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7899 (defun gnus-summary-mark-read-and-unread-as-read ()
7900 "Intended to be used by `gnus-summary-mark-article-hook'."
7901 (let ((mark (gnus-summary-article-mark)))
7902 (when (or (gnus-unread-mark-p mark)
7903 (gnus-read-mark-p mark))
7904 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7906 (defun gnus-summary-mark-region-as-read (point mark all)
7907 "Mark all unread articles between point and mark as read.
7908 If given a prefix, mark all articles between point and mark as read,
7909 even ticked and dormant ones."
7910 (interactive "r\nP")
7919 (memq (setq article (gnus-summary-article-number))
7920 gnus-newsgroup-unreads))
7921 (gnus-summary-mark-article article gnus-del-mark))
7923 (gnus-summary-find-next))))))
7925 (defun gnus-summary-mark-below (score mark)
7926 "Mark articles with score less than SCORE with MARK."
7927 (interactive "P\ncMark: ")
7928 (setq score (if score
7929 (prefix-numeric-value score)
7930 (or gnus-summary-default-score 0)))
7932 (set-buffer gnus-summary-buffer)
7933 (goto-char (point-min))
7936 (and (< (gnus-summary-article-score) score)
7937 (gnus-summary-mark-article nil mark))
7938 (gnus-summary-find-next)))))
7940 (defun gnus-summary-kill-below (&optional score)
7941 "Mark articles with score below SCORE as read."
7943 (gnus-summary-mark-below score gnus-killed-mark))
7945 (defun gnus-summary-clear-above (&optional score)
7946 "Clear all marks from articles with score above SCORE."
7948 (gnus-summary-mark-above score gnus-unread-mark))
7950 (defun gnus-summary-tick-above (&optional score)
7951 "Tick all articles with score above SCORE."
7953 (gnus-summary-mark-above score gnus-ticked-mark))
7955 (defun gnus-summary-mark-above (score mark)
7956 "Mark articles with score over SCORE with MARK."
7957 (interactive "P\ncMark: ")
7958 (setq score (if score
7959 (prefix-numeric-value score)
7960 (or gnus-summary-default-score 0)))
7962 (set-buffer gnus-summary-buffer)
7963 (goto-char (point-min))
7965 (when (> (gnus-summary-article-score) score)
7966 (gnus-summary-mark-article nil mark))
7968 (gnus-summary-find-next)))))
7970 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7971 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7972 (defun gnus-summary-limit-include-expunged (&optional no-error)
7973 "Display all the hidden articles that were expunged for low scores."
7975 (let ((buffer-read-only nil))
7976 (let ((scored gnus-newsgroup-scored)
7979 (unless (gnus-summary-goto-subject (caar scored))
7980 (and (setq h (gnus-summary-article-header (caar scored)))
7981 (< (cdar scored) gnus-summary-expunge-below)
7983 (setq scored (cdr scored)))
7985 (when (not no-error)
7986 (error "No expunged articles hidden"))
7987 (goto-char (point-min))
7988 (gnus-summary-prepare-unthreaded (nreverse headers))
7989 (goto-char (point-min))
7990 (gnus-summary-position-point)
7993 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7994 "Mark all unread articles in this newsgroup as read.
7995 If prefix argument ALL is non-nil, ticked and dormant articles will
7996 also be marked as read.
7997 If QUIETLY is non-nil, no questions will be asked.
7998 If TO-HERE is non-nil, it should be a point in the buffer. All
7999 articles before this point will be marked as read.
8000 Note that this function will only catch up the unread article
8001 in the current summary buffer limitation.
8002 The number of articles marked as read is returned."
8007 (not gnus-interactive-catchup) ;Without confirmation?
8011 "Mark absolutely all articles as read? "
8012 "Mark all unread articles as read? ")))
8014 (not gnus-newsgroup-adaptive)
8015 (not gnus-newsgroup-auto-expire)
8016 (not gnus-suppress-duplicates)
8017 (or (not gnus-use-cache)
8018 (eq gnus-use-cache 'passive)))
8021 (setq gnus-newsgroup-marked nil
8022 gnus-newsgroup-dormant nil))
8023 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8024 ;; We actually mark all articles as canceled, which we
8025 ;; have to do when using auto-expiry or adaptive scoring.
8026 (gnus-summary-show-all-threads)
8027 (when (gnus-summary-first-subject (not all))
8029 (if to-here (< (point) to-here) t)
8030 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8031 (gnus-summary-find-next (not all)))))
8032 (gnus-set-mode-line 'summary))
8034 (gnus-summary-position-point)))
8036 (defun gnus-summary-catchup-to-here (&optional all)
8037 "Mark all unticked articles before the current one as read.
8038 If ALL is non-nil, also mark ticked and dormant articles as read."
8041 (gnus-save-hidden-threads
8042 (let ((beg (point)))
8043 ;; We check that there are unread articles.
8044 (when (or all (gnus-summary-find-prev))
8045 (gnus-summary-catchup all t beg)))))
8046 (gnus-summary-position-point))
8048 (defun gnus-summary-catchup-all (&optional quietly)
8049 "Mark all articles in this newsgroup as read."
8051 (gnus-summary-catchup t quietly))
8053 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8054 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8055 If prefix argument ALL is non-nil, all articles are marked as read."
8057 (when (gnus-summary-catchup all quietly nil 'fast)
8058 ;; Select next newsgroup or exit.
8059 (if (eq gnus-auto-select-next 'quietly)
8060 (gnus-summary-next-group nil)
8061 (gnus-summary-exit))))
8063 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8064 "Mark all articles in this newsgroup as read, and then exit."
8066 (gnus-summary-catchup-and-exit t quietly))
8068 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8069 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8070 "Mark all articles in this group as read and select the next group.
8071 If given a prefix, mark all articles, unread as well as ticked, as
8075 (gnus-summary-catchup all))
8076 (gnus-summary-next-article t nil nil t))
8078 ;; Thread-based commands.
8080 (defun gnus-summary-articles-in-thread (&optional article)
8081 "Return a list of all articles in the current thread.
8082 If ARTICLE is non-nil, return all articles in the thread that starts
8084 (let* ((article (or article (gnus-summary-article-number)))
8085 (data (gnus-data-find-list article))
8086 (top-level (gnus-data-level (car data)))
8088 (cond ((null gnus-thread-operation-ignore-subject)
8089 (gnus-simplify-subject-re
8090 (mail-header-subject (gnus-data-header (car data)))))
8091 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8092 (gnus-simplify-subject-fuzzy
8093 (mail-header-subject (gnus-data-header (car data)))))
8095 (end-point (save-excursion
8096 (if (gnus-summary-go-to-next-thread)
8097 (point) (point-max))))
8100 (< (gnus-data-pos (car data)) end-point))
8101 (when (or (not top-subject)
8102 (string= top-subject
8103 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8104 (gnus-simplify-subject-fuzzy
8105 (mail-header-subject
8106 (gnus-data-header (car data))))
8107 (gnus-simplify-subject-re
8108 (mail-header-subject
8109 (gnus-data-header (car data)))))))
8110 (push (gnus-data-number (car data)) articles))
8111 (unless (and (setq data (cdr data))
8112 (> (gnus-data-level (car data)) top-level))
8114 ;; Return the list of articles.
8115 (nreverse articles)))
8117 (defun gnus-summary-rethread-current ()
8118 "Rethread the thread the current article is part of."
8120 (let* ((gnus-show-threads t)
8121 (article (gnus-summary-article-number))
8122 (id (mail-header-id (gnus-summary-article-header)))
8123 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8125 (error "No article on the current line"))
8126 (gnus-rebuild-thread id)
8127 (gnus-summary-goto-subject article)))
8129 (defun gnus-summary-reparent-thread ()
8130 "Make the current article child of the marked (or previous) article.
8132 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8133 is non-nil or the Subject: of both articles are the same."
8135 (unless (not (gnus-group-read-only-p))
8136 (error "The current newsgroup does not support article editing"))
8137 (unless (<= (length gnus-newsgroup-processable) 1)
8138 (error "No more than one article may be marked"))
8139 (save-window-excursion
8140 (let ((gnus-article-buffer " *reparent*")
8141 (current-article (gnus-summary-article-number))
8142 ;; First grab the marked article, otherwise one line up.
8143 (parent-article (if (not (null gnus-newsgroup-processable))
8144 (car gnus-newsgroup-processable)
8146 (if (eq (forward-line -1) 0)
8147 (gnus-summary-article-number)
8148 (error "Beginning of summary buffer"))))))
8149 (unless (not (eq current-article parent-article))
8150 (error "An article may not be self-referential"))
8151 (let ((message-id (mail-header-id
8152 (gnus-summary-article-header parent-article))))
8153 (unless (and message-id (not (equal message-id "")))
8154 (error "No message-id in desired parent"))
8155 ;; We don't want the article to be marked as read.
8156 (let (gnus-mark-article-hook)
8157 (gnus-summary-select-article t t nil current-article))
8158 (set-buffer gnus-original-article-buffer)
8159 (let ((buf (format "%s" (buffer-string))))
8160 (nnheader-temp-write nil
8162 (goto-char (point-min))
8163 (if (re-search-forward "^References: " nil t)
8165 (re-search-forward "^[^ \t]" nil t)
8168 (insert " " message-id))
8169 (insert "References: " message-id "\n"))
8170 (unless (gnus-request-replace-article
8171 current-article (car gnus-article-current)
8173 (error "Couldn't replace article"))))
8174 (set-buffer gnus-summary-buffer)
8175 (gnus-summary-unmark-all-processable)
8176 (gnus-summary-update-article current-article)
8177 (gnus-summary-rethread-current)
8178 (gnus-message 3 "Article %d is now the child of article %d"
8179 current-article parent-article)))))
8181 (defun gnus-summary-toggle-threads (&optional arg)
8182 "Toggle showing conversation threads.
8183 If ARG is positive number, turn showing conversation threads on."
8185 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8186 (setq gnus-show-threads
8187 (if (null arg) (not gnus-show-threads)
8188 (> (prefix-numeric-value arg) 0)))
8189 (gnus-summary-prepare)
8190 (gnus-summary-goto-subject current)
8191 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8192 (gnus-summary-position-point)))
8194 (defun gnus-summary-show-all-threads ()
8198 (let ((buffer-read-only nil))
8199 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8200 (gnus-summary-position-point))
8202 (defun gnus-summary-show-thread ()
8203 "Show thread subtrees.
8204 Returns nil if no thread was there to be shown."
8206 (let ((buffer-read-only nil)
8208 ;; first goto end then to beg, to have point at beg after let
8209 (end (progn (end-of-line) (point)))
8210 (beg (progn (beginning-of-line) (point))))
8212 ;; Any hidden lines here?
8213 (search-forward "\r" end t)
8214 (subst-char-in-region beg end ?\^M ?\n t)
8216 (gnus-summary-position-point))))
8218 (defun gnus-summary-hide-all-threads ()
8219 "Hide all thread subtrees."
8222 (goto-char (point-min))
8223 (gnus-summary-hide-thread)
8224 (while (zerop (gnus-summary-next-thread 1 t))
8225 (gnus-summary-hide-thread)))
8226 (gnus-summary-position-point))
8228 (defun gnus-summary-hide-thread ()
8229 "Hide thread subtrees.
8230 Returns nil if no threads were there to be hidden."
8232 (let ((buffer-read-only nil)
8234 (article (gnus-summary-article-number)))
8236 ;; Go forward until either the buffer ends or the subthread
8238 (when (and (not (eobp))
8239 (or (zerop (gnus-summary-next-thread 1 t))
8240 (goto-char (point-max))))
8242 (if (and (> (point) start)
8243 (search-backward "\n" start t))
8245 (subst-char-in-region start (point) ?\n ?\^M)
8246 (gnus-summary-goto-subject article))
8249 ;;(gnus-summary-position-point)
8252 (defun gnus-summary-go-to-next-thread (&optional previous)
8253 "Go to the same level (or less) next thread.
8254 If PREVIOUS is non-nil, go to previous thread instead.
8255 Return the article number moved to, or nil if moving was impossible."
8256 (let ((level (gnus-summary-thread-level))
8257 (way (if previous -1 1))
8260 (while (and (not (eobp))
8261 (< level (gnus-summary-thread-level)))
8269 (gnus-summary-article-number)
8272 (defun gnus-summary-next-thread (n &optional silent)
8273 "Go to the same level next N'th thread.
8274 If N is negative, search backward instead.
8275 Returns the difference between N and the number of skips actually
8278 If SILENT, don't output messages."
8280 (let ((backward (< n 0))
8283 (gnus-summary-go-to-next-thread backward))
8286 (gnus-summary-position-point))
8287 (when (and (not silent) (/= 0 n))
8288 (gnus-message 7 "No more threads"))
8291 (defun gnus-summary-prev-thread (n)
8292 "Go to the same level previous N'th thread.
8293 Returns the difference between N and the number of skips actually
8296 (gnus-summary-next-thread (- n)))
8298 (defun gnus-summary-go-down-thread ()
8299 "Go down one level in the current thread."
8300 (let ((children (gnus-summary-article-children)))
8302 (gnus-summary-goto-subject (car children)))))
8304 (defun gnus-summary-go-up-thread ()
8305 "Go up one level in the current thread."
8306 (let ((parent (gnus-summary-article-parent)))
8308 (gnus-summary-goto-subject parent))))
8310 (defun gnus-summary-down-thread (n)
8311 "Go down thread N steps.
8312 If N is negative, go up instead.
8313 Returns the difference between N and how many steps down that were
8319 (if up (gnus-summary-go-up-thread)
8320 (gnus-summary-go-down-thread)))
8322 (gnus-summary-position-point)
8324 (gnus-message 7 "Can't go further"))
8327 (defun gnus-summary-up-thread (n)
8328 "Go up thread N steps.
8329 If N is negative, go up instead.
8330 Returns the difference between N and how many steps down that were
8333 (gnus-summary-down-thread (- n)))
8335 (defun gnus-summary-top-thread ()
8336 "Go to the top of the thread."
8338 (while (gnus-summary-go-up-thread))
8339 (gnus-summary-article-number))
8341 (defun gnus-summary-kill-thread (&optional unmark)
8342 "Mark articles under current thread as read.
8343 If the prefix argument is positive, remove any kinds of marks.
8344 If the prefix argument is negative, tick articles instead."
8347 (setq unmark (prefix-numeric-value unmark)))
8348 (let ((articles (gnus-summary-articles-in-thread)))
8350 ;; Expand the thread.
8351 (gnus-summary-show-thread)
8352 ;; Mark all the articles.
8354 (gnus-summary-goto-subject (car articles))
8355 (cond ((null unmark)
8356 (gnus-summary-mark-article-as-read gnus-killed-mark))
8358 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8360 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8361 (setq articles (cdr articles))))
8362 ;; Hide killed subtrees.
8364 gnus-thread-hide-killed
8365 (gnus-summary-hide-thread))
8366 ;; If marked as read, go to next unread subject.
8368 ;; Go to next unread subject.
8369 (gnus-summary-next-subject 1 t)))
8370 (gnus-set-mode-line 'summary))
8372 ;; Summary sorting commands
8374 (defun gnus-summary-sort-by-number (&optional reverse)
8375 "Sort the summary buffer by article number.
8376 Argument REVERSE means reverse order."
8378 (gnus-summary-sort 'number reverse))
8380 (defun gnus-summary-sort-by-author (&optional reverse)
8381 "Sort the summary buffer by author name alphabetically.
8382 If case-fold-search is non-nil, case of letters is ignored.
8383 Argument REVERSE means reverse order."
8385 (gnus-summary-sort 'author reverse))
8387 (defun gnus-summary-sort-by-subject (&optional reverse)
8388 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8389 If case-fold-search is non-nil, case of letters is ignored.
8390 Argument REVERSE means reverse order."
8392 (gnus-summary-sort 'subject reverse))
8394 (defun gnus-summary-sort-by-date (&optional reverse)
8395 "Sort the summary buffer by date.
8396 Argument REVERSE means reverse order."
8398 (gnus-summary-sort 'date reverse))
8400 (defun gnus-summary-sort-by-score (&optional reverse)
8401 "Sort the summary buffer by score.
8402 Argument REVERSE means reverse order."
8404 (gnus-summary-sort 'score reverse))
8406 (defun gnus-summary-sort-by-lines (&optional reverse)
8407 "Sort the summary buffer by article length.
8408 Argument REVERSE means reverse order."
8410 (gnus-summary-sort 'lines reverse))
8412 (defun gnus-summary-sort (predicate reverse)
8413 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8414 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8415 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8416 (gnus-thread-sort-functions
8422 (gnus-article-sort-functions
8427 (,article t2 t1)))))
8429 (gnus-summary-prepare-hook nil))
8430 ;; We do the sorting by regenerating the threads.
8431 (gnus-summary-prepare)
8432 ;; Hide subthreads if needed.
8433 (when (and gnus-show-threads gnus-thread-hide-subtree)
8434 (gnus-summary-hide-all-threads))))
8436 ;; Summary saving commands.
8438 (defun gnus-summary-save-article (&optional n not-saved)
8439 "Save the current article using the default saver function.
8440 If N is a positive number, save the N next articles.
8441 If N is a negative number, save the N previous articles.
8442 If N is nil and any articles have been marked with the process mark,
8443 save those articles instead.
8444 The variable `gnus-default-article-saver' specifies the saver function."
8446 (let* ((articles (gnus-summary-work-articles n))
8447 (save-buffer (save-excursion
8448 (nnheader-set-temp-buffer " *Gnus Save*")))
8449 (num (length articles))
8450 header article file)
8452 (setq header (gnus-summary-article-header
8453 (setq article (pop articles))))
8454 (if (not (vectorp header))
8455 ;; This is a pseudo-article.
8456 (if (assq 'name header)
8457 (gnus-copy-file (cdr (assq 'name header)))
8458 (gnus-message 1 "Article %d is unsaveable" article))
8459 ;; This is a real article.
8460 (save-window-excursion
8461 (gnus-summary-select-article t nil nil article))
8463 (set-buffer save-buffer)
8465 (insert-buffer-substring gnus-original-article-buffer))
8466 (setq file (gnus-article-save save-buffer file num))
8467 (gnus-summary-remove-process-mark article)
8469 (gnus-summary-set-saved-mark article))))
8470 (gnus-kill-buffer save-buffer)
8471 (gnus-summary-position-point)
8472 (gnus-set-mode-line 'summary)
8475 (defun gnus-summary-pipe-output (&optional arg)
8476 "Pipe the current article to a subprocess.
8477 If N is a positive number, pipe the N next articles.
8478 If N is a negative number, pipe the N previous articles.
8479 If N is nil and any articles have been marked with the process mark,
8480 pipe those articles instead."
8482 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8483 (gnus-summary-save-article arg t))
8484 (gnus-configure-windows 'pipe))
8486 (defun gnus-summary-save-article-mail (&optional arg)
8487 "Append the current article to an mail file.
8488 If N is a positive number, save the N next articles.
8489 If N is a negative number, save the N previous articles.
8490 If N is nil and any articles have been marked with the process mark,
8491 save those articles instead."
8493 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8494 (gnus-summary-save-article arg)))
8496 (defun gnus-summary-save-article-rmail (&optional arg)
8497 "Append the current article to an rmail file.
8498 If N is a positive number, save the N next articles.
8499 If N is a negative number, save the N previous articles.
8500 If N is nil and any articles have been marked with the process mark,
8501 save those articles instead."
8503 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8504 (gnus-summary-save-article arg)))
8506 (defun gnus-summary-save-article-file (&optional arg)
8507 "Append the current article to a file.
8508 If N is a positive number, save the N next articles.
8509 If N is a negative number, save the N previous articles.
8510 If N is nil and any articles have been marked with the process mark,
8511 save those articles instead."
8513 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8514 (gnus-summary-save-article arg)))
8516 (defun gnus-summary-write-article-file (&optional arg)
8517 "Write the current article to a file, deleting the previous file.
8518 If N is a positive number, save the N next articles.
8519 If N is a negative number, save the N previous articles.
8520 If N is nil and any articles have been marked with the process mark,
8521 save those articles instead."
8523 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8524 (gnus-summary-save-article arg)))
8526 (defun gnus-summary-save-article-body-file (&optional arg)
8527 "Append the current article body to a file.
8528 If N is a positive number, save the N next articles.
8529 If N is a negative number, save the N previous articles.
8530 If N is nil and any articles have been marked with the process mark,
8531 save those articles instead."
8533 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8534 (gnus-summary-save-article arg)))
8536 (defun gnus-summary-pipe-message (program)
8537 "Pipe the current article through PROGRAM."
8538 (interactive "sProgram: ")
8539 (gnus-summary-select-article)
8540 (let ((mail-header-separator "")
8541 (art-buf (get-buffer gnus-article-buffer)))
8542 (gnus-eval-in-buffer-window gnus-article-buffer
8545 (let ((start (window-start))
8547 (message-pipe-buffer-body program)
8548 (set-window-start (get-buffer-window (current-buffer)) start))))))
8550 (defun gnus-get-split-value (methods)
8551 "Return a value based on the split METHODS."
8552 (let (split-name method result match)
8555 (set-buffer gnus-original-article-buffer)
8557 (nnheader-narrow-to-headers)
8559 (goto-char (point-min))
8560 (setq method (pop methods))
8561 (setq match (car method))
8564 ;; Regular expression.
8566 (re-search-forward match nil t)))
8567 ((gnus-functionp match)
8571 (setq result (funcall match gnus-newsgroup-name))))
8576 (setq result (eval match)))))
8577 (setq split-name (append (cdr method) split-name))
8578 (cond ((stringp result)
8579 (push (expand-file-name
8580 result gnus-article-save-directory)
8583 (setq split-name (append result split-name)))))))))
8586 (defun gnus-valid-move-group-p (group)
8591 (car (gnus-find-method-for-group
8592 (symbol-name group))))
8593 gnus-valid-select-methods))))
8595 (defun gnus-read-move-group-name (prompt default articles prefix)
8596 "Read a group name."
8597 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8598 (minibuffer-confirm-incomplete nil) ; XEmacs
8602 (if (> (length articles) 1)
8603 (format "these %d articles" (length articles))
8608 (gnus-completing-read default prom
8610 'gnus-valid-move-group-p
8612 'gnus-group-history))
8613 ((= 1 (length split-name))
8614 (gnus-completing-read (car split-name) prom
8616 'gnus-valid-move-group-p
8618 'gnus-group-history))
8620 (gnus-completing-read nil prom
8621 (mapcar (lambda (el) (list el))
8622 (nreverse split-name))
8624 'gnus-group-history)))))
8626 (if (or (string= to-newsgroup "")
8627 (string= to-newsgroup prefix))
8628 (setq to-newsgroup default))
8629 (unless to-newsgroup
8630 (error "No group name entered"))
8631 (or (gnus-active to-newsgroup)
8632 (gnus-activate-group to-newsgroup)
8633 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8635 (or (and (gnus-request-create-group
8636 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8637 (gnus-activate-group to-newsgroup nil nil
8638 (gnus-group-name-to-method
8640 (error "Couldn't create group %s" to-newsgroup)))
8641 (error "No such group: %s" to-newsgroup)))
8644 ;; Summary extract commands
8646 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8647 (let ((buffer-read-only nil)
8648 (article (gnus-summary-article-number))
8650 (unless (gnus-summary-goto-subject article)
8651 (error "No such article: %d" article))
8652 (gnus-summary-position-point)
8653 ;; If all commands are to be bunched up on one line, we collect
8655 (unless gnus-view-pseudos-separately
8656 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8659 (setq action (cdr (assq 'action (car ps))))
8660 (setq files (list (cdr (assq 'name (car ps)))))
8661 (while (and ps (cdr ps)
8662 (string= (or action "1")
8663 (or (cdr (assq 'action (cadr ps))) "2")))
8664 (push (cdr (assq 'name (cadr ps))) files)
8665 (setcdr ps (cddr ps)))
8667 (when (not (string-match "%s" action))
8670 (when (assq 'execute (car ps))
8671 (setcdr (assq 'execute (car ps))
8672 (funcall (if (string-match "%s" action)
8679 (gnus-quote-arg-for-sh-or-csh f)))
8681 (setq ps (cdr ps)))))
8682 (if (and gnus-view-pseudos (not not-view))
8684 (when (assq 'execute (car pslist))
8685 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8686 (eq gnus-view-pseudos 'not-confirm)))
8687 (setq pslist (cdr pslist)))
8690 (setq after-article (or (cdr (assq 'article (car pslist)))
8691 (gnus-summary-article-number)))
8692 (gnus-summary-goto-subject after-article)
8695 (insert " " (file-name-nondirectory
8696 (cdr (assq 'name (car pslist))))
8697 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8699 (forward-line -1) ; back to `b'
8700 (gnus-add-text-properties
8701 b (1- e) (list 'gnus-number gnus-reffed-article-number
8702 gnus-mouse-face-prop gnus-mouse-face))
8704 after-article gnus-reffed-article-number
8705 gnus-unread-mark b (car pslist) 0 (- e b))
8706 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8707 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8708 (setq pslist (cdr pslist)))))))
8710 (defun gnus-pseudos< (p1 p2)
8711 (let ((c1 (cdr (assq 'action p1)))
8712 (c2 (cdr (assq 'action p2))))
8713 (and c1 c2 (string< c1 c2))))
8715 (defun gnus-request-pseudo-article (props)
8716 (cond ((assq 'execute props)
8717 (gnus-execute-command (cdr (assq 'execute props)))))
8718 (let ((gnus-current-article (gnus-summary-article-number)))
8719 (gnus-run-hooks 'gnus-mark-article-hook)))
8721 (defun gnus-execute-command (command &optional automatic)
8723 (gnus-article-setup-buffer)
8724 (set-buffer gnus-article-buffer)
8725 (setq buffer-read-only nil)
8726 (let ((command (if automatic command
8727 (read-string "Command: " (cons command 0)))))
8729 (insert "$ " command "\n\n")
8730 (if gnus-view-pseudo-asynchronously
8731 (start-process "gnus-execute" (current-buffer) shell-file-name
8732 shell-command-switch command)
8733 (call-process shell-file-name nil t nil
8734 shell-command-switch command)))))
8736 ;; Summary kill commands.
8738 (defun gnus-summary-edit-global-kill (article)
8739 "Edit the \"global\" kill file."
8740 (interactive (list (gnus-summary-article-number)))
8741 (gnus-group-edit-global-kill article))
8743 (defun gnus-summary-edit-local-kill ()
8744 "Edit a local kill file applied to the current newsgroup."
8746 (setq gnus-current-headers (gnus-summary-article-header))
8747 (gnus-group-edit-local-kill
8748 (gnus-summary-article-number) gnus-newsgroup-name))
8752 (defun gnus-read-header (id &optional header)
8753 "Read the headers of article ID and enter them into the Gnus system."
8754 (let ((group gnus-newsgroup-name)
8755 (gnus-override-method
8756 (and (gnus-news-group-p gnus-newsgroup-name)
8757 gnus-refer-article-method))
8759 ;; First we check to see whether the header in question is already
8762 ;; This is a Message-ID.
8763 (setq header (or header (gnus-id-to-header id)))
8764 ;; This is an article number.
8765 (setq header (or header (gnus-summary-article-header id))))
8767 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8768 ;; We have found the header.
8770 ;; If this is a sparse article, we have to nix out its
8771 ;; previous entry in the thread hashtb.
8773 (gnus-summary-article-sparse-p (mail-header-number header)))
8774 (let* ((parent (gnus-parent-id (mail-header-references header)))
8777 (gnus-gethash parent gnus-newsgroup-dependencies))))
8779 (delq (assq header thread) thread))))
8780 ;; We have to really fetch the header to this article.
8782 (set-buffer nntp-server-buffer)
8783 (when (setq where (gnus-request-head id group))
8784 (nnheader-fold-continuation-lines)
8785 (goto-char (point-max))
8787 (goto-char (point-min))
8791 ((cdr where) (cdr where))
8792 (header (mail-header-number header))
8793 (t gnus-reffed-article-number))
8795 (insert " Article retrieved.\n"))
8797 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8798 () ; Malformed head.
8799 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8800 (when (and (stringp id)
8801 (not (string= (gnus-group-real-name group)
8803 ;; If we fetched by Message-ID and the article came
8804 ;; from a different group, we fudge some bogus article
8805 ;; numbers for this article.
8806 (mail-header-set-number header gnus-reffed-article-number))
8808 (set-buffer gnus-summary-buffer)
8809 (decf gnus-reffed-article-number)
8810 (gnus-remove-header (mail-header-number header))
8811 (push header gnus-newsgroup-headers)
8812 (setq gnus-current-headers header)
8813 (push (mail-header-number header) gnus-newsgroup-limit)))
8816 (defun gnus-remove-header (number)
8817 "Remove header NUMBER from `gnus-newsgroup-headers'."
8818 (if (and gnus-newsgroup-headers
8819 (= number (mail-header-number (car gnus-newsgroup-headers))))
8820 (pop gnus-newsgroup-headers)
8821 (let ((headers gnus-newsgroup-headers))
8822 (while (and (cdr headers)
8823 (not (= number (mail-header-number (cadr headers)))))
8826 (setcdr headers (cddr headers))))))
8829 ;;; summary highlights
8832 (defun gnus-highlight-selected-summary ()
8833 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8834 ;; Highlight selected article in summary buffer
8835 (when gnus-summary-selected-face
8837 (let* ((beg (progn (beginning-of-line) (point)))
8838 (end (progn (end-of-line) (point)))
8839 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8840 (from (if (get-text-property beg gnus-mouse-face-prop)
8842 (or (next-single-property-change
8843 beg gnus-mouse-face-prop nil end)
8848 (or (next-single-property-change
8849 from gnus-mouse-face-prop nil end)
8851 ;; If no mouse-face prop on line we will have to = from = end,
8852 ;; so we highlight the entire line instead.
8853 (when (= (+ to 2) from)
8856 (if gnus-newsgroup-selected-overlay
8857 ;; Move old overlay.
8859 gnus-newsgroup-selected-overlay from to (current-buffer))
8860 ;; Create new overlay.
8862 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8863 'face gnus-summary-selected-face))))))
8865 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8866 (defun gnus-summary-highlight-line ()
8867 "Highlight current line according to `gnus-summary-highlight'."
8868 (let* ((list gnus-summary-highlight)
8870 (end (progn (end-of-line) (point)))
8871 ;; now find out where the line starts and leave point there.
8872 (beg (progn (beginning-of-line) (point)))
8873 (article (gnus-summary-article-number))
8874 (score (or (cdr (assq (or article gnus-current-article)
8875 gnus-newsgroup-scored))
8876 gnus-summary-default-score 0))
8877 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8878 (inhibit-read-only t))
8879 ;; Eval the cars of the lists until we find a match.
8880 (let ((default gnus-summary-default-score))
8882 (not (eval (caar list))))
8883 (setq list (cdr list))))
8884 (let ((face (cdar list)))
8885 (unless (eq face (get-text-property beg 'face))
8886 (gnus-put-text-property
8888 (setq face (if (boundp face) (symbol-value face) face)))
8889 (when gnus-summary-highlight-line-function
8890 (funcall gnus-summary-highlight-line-function article face))))
8893 (defun gnus-update-read-articles (group unread &optional compute)
8894 "Update the list of read articles in GROUP."
8895 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8896 (entry (gnus-gethash group gnus-newsrc-hashtb))
8897 (info (nth 2 entry))
8899 (unread (sort (copy-sequence unread) '<))
8901 (if (or (not info) (not active))
8902 ;; There is no info on this group if it was, in fact,
8903 ;; killed. Gnus stores no information on killed groups, so
8904 ;; there's nothing to be done.
8905 ;; One could store the information somewhere temporarily,
8906 ;; perhaps... Hmmm...
8908 ;; Remove any negative articles numbers.
8909 (while (and unread (< (car unread) 0))
8910 (setq unread (cdr unread)))
8911 ;; Remove any expired article numbers
8912 (while (and unread (< (car unread) (car active)))
8913 (setq unread (cdr unread)))
8914 ;; Compute the ranges of read articles by looking at the list of
8917 (when (/= (car unread) prev)
8918 (push (if (= prev (1- (car unread))) prev
8919 (cons prev (1- (car unread))))
8921 (setq prev (1+ (car unread)))
8922 (setq unread (cdr unread)))
8923 (when (<= prev (cdr active))
8924 (push (cons prev (cdr active)) read))
8926 (if (> (length read) 1) (nreverse read) read)
8928 (set-buffer gnus-group-buffer)
8931 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8932 (gnus-info-set-read ',info ',(gnus-info-read info))
8933 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8934 (gnus-group-update-group ,group t))))
8935 ;; Enter this list into the group info.
8937 info (if (> (length read) 1) (nreverse read) read))
8938 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8939 (gnus-get-unread-articles-in-group info (gnus-active group))
8942 (defun gnus-offer-save-summaries ()
8943 "Offer to save all active summary buffers."
8945 (let ((buflist (buffer-list))
8947 ;; Go through all buffers and find all summaries.
8949 (and (setq bufname (buffer-name (car buflist)))
8950 (string-match "Summary" bufname)
8952 (set-buffer bufname)
8953 ;; We check that this is, indeed, a summary buffer.
8954 (and (eq major-mode 'gnus-summary-mode)
8955 ;; Also make sure this isn't bogus.
8956 gnus-newsgroup-prepared
8957 ;; Also make sure that this isn't a dead summary buffer.
8958 (not gnus-dead-summary-mode)))
8959 (push bufname buffers))
8960 (setq buflist (cdr buflist)))
8961 ;; Go through all these summary buffers and offer to save them.
8964 "Update summary buffer %s? "
8966 (switch-to-buffer buf)
8967 (gnus-summary-exit))
8974 (run-hooks 'gnus-sum-load-hook)
8976 ;;; gnus-sum.el ends here