1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
41 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
43 (defcustom gnus-kill-summary-on-exit t
44 "*If non-nil, kill the summary buffer when you exit from it.
45 If nil, the summary will become a \"*Dead Summary*\" buffer, and
46 it will be killed sometime later."
47 :group 'gnus-summary-exit
50 (defcustom gnus-fetch-old-headers nil
51 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
52 If an unread article in the group refers to an older, already read (or
53 just marked as read) article, the old article will not normally be
54 displayed in the Summary buffer. If this variable is non-nil, Gnus
55 will attempt to grab the headers to the old articles, and thereby
56 build complete threads. If it has the value `some', only enough
57 headers to connect otherwise loose threads will be displayed. This
58 variable can also be a number. In that case, no more than that number
59 of old headers will be fetched. If it has the value `invisible', all
60 old headers will be fetched, but none will be displayed.
62 The server has to support NOV for any of this to work."
64 :type '(choice (const :tag "off" nil)
67 (sexp :menu-tag "other" t)))
69 (defcustom gnus-refer-thread-limit 200
70 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
71 If t, fetch all the available old headers."
74 (sexp :menu-tag "other" t)))
76 (defcustom gnus-summary-make-false-root 'adopt
77 "*nil means that Gnus won't gather loose threads.
78 If the root of a thread has expired or been read in a previous
79 session, the information necessary to build a complete thread has been
80 lost. Instead of having many small sub-threads from this original thread
81 scattered all over the summary buffer, Gnus can gather them.
83 If non-nil, Gnus will try to gather all loose sub-threads from an
84 original thread into one large thread.
86 If this variable is non-nil, it should be one of `none', `adopt',
89 If this variable is `none', Gnus will not make a false root, but just
90 present the sub-threads after another.
91 If this variable is `dummy', Gnus will create a dummy root that will
92 have all the sub-threads as children.
93 If this variable is `adopt', Gnus will make one of the \"children\"
94 the parent and mark all the step-children as such.
95 If this variable is `empty', the \"children\" are printed with empty
96 subject fields. (Or rather, they will be printed with a string
97 given by the `gnus-summary-same-subject' variable.)"
99 :type '(choice (const :tag "off" nil)
105 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
106 "*A regexp to match subjects to be excluded from loose thread gathering.
107 As loose thread gathering is done on subjects only, that means that
108 there can be many false gatherings performed. By rooting out certain
109 common subjects, gathering might become saner."
113 (defcustom gnus-summary-gather-subject-limit nil
114 "*Maximum length of subject comparisons when gathering loose threads.
115 Use nil to compare full subjects. Setting this variable to a low
116 number will help gather threads that have been corrupted by
117 newsreaders chopping off subject lines, but it might also mean that
118 unrelated articles that have subject that happen to begin with the
119 same few characters will be incorrectly gathered.
121 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
124 :type '(choice (const :tag "off" nil)
126 (sexp :menu-tag "on" t)))
128 (defcustom gnus-simplify-subject-functions nil
129 "List of functions taking a string argument that simplify subjects.
130 The functions are applied recursively.
132 Useful functions to put in this list include: `gnus-simplify-subject-re',
133 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
135 :type '(repeat function))
137 (defcustom gnus-simplify-ignored-prefixes nil
138 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
140 :type '(choice (const :tag "off" nil)
143 (defcustom gnus-build-sparse-threads nil
144 "*If non-nil, fill in the gaps in threads.
145 If `some', only fill in the gaps that are needed to tie loose threads
146 together. If `more', fill in all leaf nodes that Gnus can find. If
147 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
149 :type '(choice (const :tag "off" nil)
152 (sexp :menu-tag "all" t)))
154 (defcustom gnus-summary-thread-gathering-function
155 'gnus-gather-threads-by-subject
156 "*Function used for gathering loose threads.
157 There are two pre-defined functions: `gnus-gather-threads-by-subject',
158 which only takes Subjects into consideration; and
159 `gnus-gather-threads-by-references', which compared the References
160 headers of the articles to find matches."
162 :type '(radio (function-item gnus-gather-threads-by-subject)
163 (function-item gnus-gather-threads-by-references)
164 (function :tag "other")))
166 (defcustom gnus-summary-same-subject ""
167 "*String indicating that the current article has the same subject as the previous.
168 This variable will only be used if the value of
169 `gnus-summary-make-false-root' is `empty'."
170 :group 'gnus-summary-format
173 (defcustom gnus-summary-goto-unread t
174 "*If t, marking commands will go to the next unread article.
175 If `never', commands that usually go to the next unread article, will
176 go to the next article, whether it is read or not.
177 If nil, only the marking commands will go to the next (un)read article."
178 :group 'gnus-summary-marks
179 :link '(custom-manual "(gnus)Setting Marks")
180 :type '(choice (const :tag "off" nil)
182 (sexp :menu-tag "on" t)))
184 (defcustom gnus-summary-default-score 0
185 "*Default article score level.
186 All scores generated by the score files will be added to this score.
187 If this variable is nil, scoring will be disabled."
188 :group 'gnus-score-default
189 :type '(choice (const :tag "disable")
192 (defcustom gnus-summary-zcore-fuzz 0
193 "*Fuzziness factor for the zcore in the summary buffer.
194 Articles with scores closer than this to `gnus-summary-default-score'
196 :group 'gnus-summary-format
199 (defcustom gnus-simplify-subject-fuzzy-regexp nil
200 "*Strings to be removed when doing fuzzy matches.
201 This can either be a regular expression or list of regular expressions
202 that will be removed from subject strings if fuzzy subject
203 simplification is selected."
205 :type '(repeat regexp))
207 (defcustom gnus-show-threads t
208 "*If non-nil, display threads in summary mode."
212 (defcustom gnus-thread-hide-subtree nil
213 "*If non-nil, hide all threads initially.
214 If threads are hidden, you have to run the command
215 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
216 to expose hidden threads."
220 (defcustom gnus-thread-hide-killed t
221 "*If non-nil, hide killed threads automatically."
225 (defcustom gnus-thread-ignore-subject t
226 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
227 If nil, articles that have different subjects from their parents will
228 start separate threads."
232 (defcustom gnus-thread-operation-ignore-subject t
233 "*If non-nil, subjects will be ignored when doing thread commands.
234 This affects commands like `gnus-summary-kill-thread' and
235 `gnus-summary-lower-thread'.
237 If this variable is nil, articles in the same thread with different
238 subjects will not be included in the operation in question. If this
239 variable is `fuzzy', only articles that have subjects that are fuzzily
240 equal will be included."
242 :type '(choice (const :tag "off" nil)
246 (defcustom gnus-thread-indent-level 4
247 "*Number that says how much each sub-thread should be indented."
251 (defcustom gnus-auto-extend-newsgroup t
252 "*If non-nil, extend newsgroup forward and backward when requested."
253 :group 'gnus-summary-choose
256 (defcustom gnus-auto-select-first t
257 "*If nil, don't select the first unread article when entering a group.
258 If this variable is `best', select the highest-scored unread article
259 in the group. If neither nil nor `best', select the first unread
262 If you want to prevent automatic selection of the first unread article
263 in some newsgroups, set the variable to nil in
264 `gnus-select-group-hook'."
265 :group 'gnus-group-select
266 :type '(choice (const :tag "none" nil)
268 (sexp :menu-tag "first" t)))
270 (defcustom gnus-auto-select-next t
271 "*If non-nil, offer to go to the next group from the end of the previous.
272 If the value is t and the next newsgroup is empty, Gnus will exit
273 summary mode and go back to group mode. If the value is neither nil
274 nor t, Gnus will select the following unread newsgroup. In
275 particular, if the value is the symbol `quietly', the next unread
276 newsgroup will be selected without any confirmation, and if it is
277 `almost-quietly', the next group will be selected without any
278 confirmation if you are located on the last article in the group.
279 Finally, if this variable is `slightly-quietly', the `Z n' command
280 will go to the next group without confirmation."
281 :group 'gnus-summary-maneuvering
282 :type '(choice (const :tag "off" nil)
284 (const almost-quietly)
285 (const slightly-quietly)
286 (sexp :menu-tag "on" t)))
288 (defcustom gnus-auto-select-same nil
289 "*If non-nil, select the next article with the same subject.
290 If there are no more articles with the same subject, go to
291 the first unread article."
292 :group 'gnus-summary-maneuvering
295 (defcustom gnus-summary-check-current nil
296 "*If non-nil, consider the current article when moving.
297 The \"unread\" movement commands will stay on the same line if the
298 current article is unread."
299 :group 'gnus-summary-maneuvering
302 (defcustom gnus-auto-center-summary t
303 "*If non-nil, always center the current summary buffer.
304 In particular, if `vertical' do only vertical recentering. If non-nil
305 and non-`vertical', do both horizontal and vertical recentering."
306 :group 'gnus-summary-maneuvering
307 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "both" t)))
311 (defcustom gnus-show-all-headers nil
312 "*If non-nil, don't hide any headers."
313 :group 'gnus-article-hiding
314 :group 'gnus-article-headers
317 (defcustom gnus-summary-ignore-duplicates nil
318 "*If non-nil, ignore articles with identical Message-ID headers."
322 (defcustom gnus-single-article-buffer t
323 "*If non-nil, display all articles in the same buffer.
324 If nil, each group will get its own article buffer."
325 :group 'gnus-article-various
328 (defcustom gnus-break-pages t
329 "*If non-nil, do page breaking on articles.
330 The page delimiter is specified by the `gnus-page-delimiter'
332 :group 'gnus-article-various
335 (defcustom gnus-show-mime t
336 "*If non-nil, do mime processing of articles.
337 The articles will simply be fed to the function given by
338 `gnus-article-display-method-for-mime'."
339 :group 'gnus-article-mime
342 (defcustom gnus-move-split-methods nil
343 "*Variable used to suggest where articles are to be moved to.
344 It uses the same syntax as the `gnus-split-methods' variable."
345 :group 'gnus-summary-mail
346 :type '(repeat (choice (list :value (fun) function)
347 (cons :value ("" "") regexp (repeat string))
350 (defcustom gnus-unread-mark ?
351 "*Mark used for unread articles."
352 :group 'gnus-summary-marks
355 (defcustom gnus-ticked-mark ?!
356 "*Mark used for ticked articles."
357 :group 'gnus-summary-marks
360 (defcustom gnus-dormant-mark ??
361 "*Mark used for dormant articles."
362 :group 'gnus-summary-marks
365 (defcustom gnus-del-mark ?r
366 "*Mark used for del'd articles."
367 :group 'gnus-summary-marks
370 (defcustom gnus-read-mark ?R
371 "*Mark used for read articles."
372 :group 'gnus-summary-marks
375 (defcustom gnus-expirable-mark ?E
376 "*Mark used for expirable articles."
377 :group 'gnus-summary-marks
380 (defcustom gnus-killed-mark ?K
381 "*Mark used for killed articles."
382 :group 'gnus-summary-marks
385 (defcustom gnus-souped-mark ?F
386 "*Mark used for killed articles."
387 :group 'gnus-summary-marks
390 (defcustom gnus-kill-file-mark ?X
391 "*Mark used for articles killed by kill files."
392 :group 'gnus-summary-marks
395 (defcustom gnus-low-score-mark ?Y
396 "*Mark used for articles with a low score."
397 :group 'gnus-summary-marks
400 (defcustom gnus-catchup-mark ?C
401 "*Mark used for articles that are caught up."
402 :group 'gnus-summary-marks
405 (defcustom gnus-replied-mark ?A
406 "*Mark used for articles that have been replied to."
407 :group 'gnus-summary-marks
410 (defcustom gnus-cached-mark ?*
411 "*Mark used for articles that are in the cache."
412 :group 'gnus-summary-marks
415 (defcustom gnus-saved-mark ?S
416 "*Mark used for articles that have been saved to."
417 :group 'gnus-summary-marks
420 (defcustom gnus-ancient-mark ?O
421 "*Mark used for ancient articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-sparse-mark ?Q
426 "*Mark used for sparsely reffed articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-canceled-mark ?G
431 "*Mark used for canceled articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-duplicate-mark ?M
436 "*Mark used for duplicate articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-undownloaded-mark ?@
441 "*Mark used for articles that weren't downloaded."
442 :group 'gnus-summary-marks
445 (defcustom gnus-downloadable-mark ?%
446 "*Mark used for articles that are to be downloaded."
447 :group 'gnus-summary-marks
450 (defcustom gnus-unsendable-mark ?=
451 "*Mark used for articles that won't be sent."
452 :group 'gnus-summary-marks
455 (defcustom gnus-score-over-mark ?+
456 "*Score mark used for articles with high scores."
457 :group 'gnus-summary-marks
460 (defcustom gnus-score-below-mark ?-
461 "*Score mark used for articles with low scores."
462 :group 'gnus-summary-marks
465 (defcustom gnus-empty-thread-mark ?
466 "*There is no thread under the article."
467 :group 'gnus-summary-marks
470 (defcustom gnus-not-empty-thread-mark ?=
471 "*There is a thread under the article."
472 :group 'gnus-summary-marks
475 (defcustom gnus-view-pseudo-asynchronously nil
476 "*If non-nil, Gnus will view pseudo-articles asynchronously."
477 :group 'gnus-extract-view
480 (defcustom gnus-view-pseudos nil
481 "*If `automatic', pseudo-articles will be viewed automatically.
482 If `not-confirm', pseudos will be viewed automatically, and the user
483 will not be asked to confirm the command."
484 :group 'gnus-extract-view
485 :type '(choice (const :tag "off" nil)
487 (const not-confirm)))
489 (defcustom gnus-view-pseudos-separately t
490 "*If non-nil, one pseudo-article will be created for each file to be viewed.
491 If nil, all files that use the same viewing command will be given as a
492 list of parameters to that command."
493 :group 'gnus-extract-view
496 (defcustom gnus-insert-pseudo-articles t
497 "*If non-nil, insert pseudo-articles when decoding articles."
498 :group 'gnus-extract-view
501 (defcustom gnus-summary-dummy-line-format
503 "*The format specification for the dummy roots in the summary buffer.
504 It works along the same lines as a normal formatting string,
505 with some simple extensions.
508 :group 'gnus-threading
511 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
512 "*The format specification for the summary mode line.
513 It works along the same lines as a normal formatting string,
514 with some simple extensions:
517 %p Unprefixed group name
518 %A Current article number
519 %z Current article score
521 %U Number of unread articles in the group
522 %e Number of unselected articles in the group
523 %Z A string with unread/unselected article counts
524 %g Shortish group name
525 %S Subject of the current article
527 %s Current score file name
528 %d Number of dormant articles
529 %r Number of articles that have been marked as read in this session
530 %E Number of articles expunged by the score files"
531 :group 'gnus-summary-format
534 (defcustom gnus-summary-mark-below 0
535 "*Mark all articles with a score below this variable as read.
536 This variable is local to each summary buffer and usually set by the
538 :group 'gnus-score-default
541 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
542 "*List of functions used for sorting articles in the summary buffer.
543 This variable is only used when not using a threaded display."
544 :group 'gnus-summary-sort
545 :type '(repeat (choice (function-item gnus-article-sort-by-number)
546 (function-item gnus-article-sort-by-author)
547 (function-item gnus-article-sort-by-subject)
548 (function-item gnus-article-sort-by-date)
549 (function-item gnus-article-sort-by-score)
550 (function :tag "other"))))
552 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
553 "*List of functions used for sorting threads in the summary buffer.
554 By default, threads are sorted by article number.
556 Each function takes two threads and return non-nil if the first thread
557 should be sorted before the other. If you use more than one function,
558 the primary sort function should be the last. You should probably
559 always include `gnus-thread-sort-by-number' in the list of sorting
560 functions -- preferably first.
562 Ready-made functions include `gnus-thread-sort-by-number',
563 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
564 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
565 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
566 :group 'gnus-summary-sort
567 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
568 (function-item gnus-thread-sort-by-author)
569 (function-item gnus-thread-sort-by-subject)
570 (function-item gnus-thread-sort-by-date)
571 (function-item gnus-thread-sort-by-score)
572 (function-item gnus-thread-sort-by-total-score)
573 (function :tag "other"))))
575 (defcustom gnus-thread-score-function '+
576 "*Function used for calculating the total score of a thread.
578 The function is called with the scores of the article and each
579 subthread and should then return the score of the thread.
581 Some functions you can use are `+', `max', or `min'."
582 :group 'gnus-summary-sort
585 (defcustom gnus-summary-expunge-below nil
586 "All articles that have a score less than this variable will be expunged.
587 This variable is local to the summary buffers."
588 :group 'gnus-score-default
589 :type '(choice (const :tag "off" nil)
592 (defcustom gnus-thread-expunge-below nil
593 "All threads that have a total score less than this variable will be expunged.
594 See `gnus-thread-score-function' for en explanation of what a
597 This variable is local to the summary buffers."
598 :group 'gnus-treading
599 :group 'gnus-score-default
600 :type '(choice (const :tag "off" nil)
603 (defcustom gnus-summary-mode-hook nil
604 "*A hook for Gnus summary mode.
605 This hook is run before any variables are set in the summary buffer."
606 :group 'gnus-summary-various
609 (defcustom gnus-summary-menu-hook nil
610 "*Hook run after the creation of the summary mode menu."
611 :group 'gnus-summary-visual
614 (defcustom gnus-summary-exit-hook nil
615 "*A hook called on exit from the summary buffer.
616 It will be called with point in the group buffer."
617 :group 'gnus-summary-exit
620 (defcustom gnus-summary-prepare-hook nil
621 "*A hook called after the summary buffer has been generated.
622 If you want to modify the summary buffer, you can use this hook."
623 :group 'gnus-summary-various
626 (defcustom gnus-summary-prepared-hook nil
627 "*A hook called as the last thing after the summary buffer has been generated."
628 :group 'gnus-summary-various
631 (defcustom gnus-summary-generate-hook nil
632 "*A hook run just before generating the summary buffer.
633 This hook is commonly used to customize threading variables and the
635 :group 'gnus-summary-various
638 (defcustom gnus-select-group-hook nil
639 "*A hook called when a newsgroup is selected.
641 If you'd like to simplify subjects like the
642 `gnus-summary-next-same-subject' command does, you can use the
645 (setq gnus-select-group-hook
648 (mapcar (lambda (header)
649 (mail-header-set-subject
651 (gnus-simplify-subject
652 (mail-header-subject header) 're-only)))
653 gnus-newsgroup-headers))))"
654 :group 'gnus-group-select
657 (defcustom gnus-select-article-hook nil
658 "*A hook called when an article is selected."
659 :group 'gnus-summary-choose
662 (defcustom gnus-visual-mark-article-hook
663 (list 'gnus-highlight-selected-summary)
664 "*Hook run after selecting an article in the summary buffer.
665 It is meant to be used for highlighting the article in some way. It
666 is not run if `gnus-visual' is nil."
667 :group 'gnus-summary-visual
670 (defcustom gnus-structured-field-decoder
671 #'eword-decode-and-unfold-structured-field
672 "Function to decode non-ASCII characters in structured field for summary."
676 (defcustom gnus-unstructured-field-decoder
679 (eword-decode-unstructured-field-body
680 (std11-unfold-string string) 'must-unfold)
682 "Function to decode non-ASCII characters in unstructured field for summary."
686 (defcustom gnus-parse-headers-hook
687 '(gnus-set-summary-default-charset)
688 "*A hook called before parsing the headers."
692 (defcustom gnus-exit-group-hook nil
693 "*A hook called when exiting (not quitting) summary mode."
697 (defcustom gnus-summary-update-hook
698 (list 'gnus-summary-highlight-line)
699 "*A hook called when a summary line is changed.
700 The hook will not be called if `gnus-visual' is nil.
702 The default function `gnus-summary-highlight-line' will
703 highlight the line according to the `gnus-summary-highlight'
705 :group 'gnus-summary-visual
708 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
709 "*A hook called when an article is selected for the first time.
710 The hook is intended to mark an article as read (or unread)
711 automatically when it is selected."
712 :group 'gnus-summary-choose
715 (defcustom gnus-group-no-more-groups-hook nil
716 "*A hook run when returning to group mode having no more (unread) groups."
717 :group 'gnus-group-select
720 (defcustom gnus-ps-print-hook nil
721 "*A hook run before ps-printing something from Gnus."
725 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
726 "Face used for highlighting the current article in the summary buffer."
727 :group 'gnus-summary-visual
730 (defcustom gnus-summary-highlight
731 '(((= mark gnus-canceled-mark)
732 . gnus-summary-cancelled-face)
733 ((and (> score default)
734 (or (= mark gnus-dormant-mark)
735 (= mark gnus-ticked-mark)))
736 . gnus-summary-high-ticked-face)
737 ((and (< score default)
738 (or (= mark gnus-dormant-mark)
739 (= mark gnus-ticked-mark)))
740 . gnus-summary-low-ticked-face)
741 ((or (= mark gnus-dormant-mark)
742 (= mark gnus-ticked-mark))
743 . gnus-summary-normal-ticked-face)
744 ((and (> score default) (= mark gnus-ancient-mark))
745 . gnus-summary-high-ancient-face)
746 ((and (< score default) (= mark gnus-ancient-mark))
747 . gnus-summary-low-ancient-face)
748 ((= mark gnus-ancient-mark)
749 . gnus-summary-normal-ancient-face)
750 ((and (> score default) (= mark gnus-unread-mark))
751 . gnus-summary-high-unread-face)
752 ((and (< score default) (= mark gnus-unread-mark))
753 . gnus-summary-low-unread-face)
754 ((= mark gnus-unread-mark)
755 . gnus-summary-normal-unread-face)
756 ((and (> score default) (memq mark (list gnus-downloadable-mark
757 gnus-undownloaded-mark)))
758 . gnus-summary-high-unread-face)
759 ((and (< score default) (memq mark (list gnus-downloadable-mark
760 gnus-undownloaded-mark)))
761 . gnus-summary-low-unread-face)
762 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
763 . gnus-summary-normal-unread-face)
765 . gnus-summary-high-read-face)
767 . gnus-summary-low-read-face)
769 . gnus-summary-normal-read-face))
770 "*Controls the highlighting of summary buffer lines.
772 A list of (FORM . FACE) pairs. When deciding how a a particular
773 summary line should be displayed, each form is evaluated. The content
774 of the face field after the first true form is used. You can change
775 how those summary lines are displayed, by editing the face field.
777 You can use the following variables in the FORM field.
779 score: The articles score
780 default: The default article score.
781 below: The score below which articles are automatically marked as read.
782 mark: The articles mark."
783 :group 'gnus-summary-visual
784 :type '(repeat (cons (sexp :tag "Form" nil)
787 (defcustom gnus-alter-header-function nil
788 "Function called to allow alteration of article header structures.
789 The function is called with one parameter, the article header vector,
790 which it may alter in any way.")
792 ;;; Internal variables
794 (defvar gnus-scores-exclude-files nil)
795 (defvar gnus-page-broken nil)
797 (defvar gnus-original-article nil)
798 (defvar gnus-article-internal-prepare-hook nil)
799 (defvar gnus-newsgroup-process-stack nil)
801 (defvar gnus-thread-indent-array nil)
802 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
804 ;; Avoid highlighting in kill files.
805 (defvar gnus-summary-inhibit-highlight nil)
806 (defvar gnus-newsgroup-selected-overlay nil)
807 (defvar gnus-inhibit-limiting nil)
808 (defvar gnus-newsgroup-adaptive-score-file nil)
809 (defvar gnus-current-score-file nil)
810 (defvar gnus-current-move-group nil)
811 (defvar gnus-current-copy-group nil)
812 (defvar gnus-current-crosspost-group nil)
814 (defvar gnus-newsgroup-dependencies nil)
815 (defvar gnus-newsgroup-adaptive nil)
816 (defvar gnus-summary-display-article-function nil)
817 (defvar gnus-summary-highlight-line-function nil
818 "Function called after highlighting a summary line.")
820 (defvar gnus-summary-line-format-alist
821 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
822 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
823 (?s gnus-tmp-subject-or-nil ?s)
824 (?n gnus-tmp-name ?s)
825 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
827 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
829 (?F gnus-tmp-from ?s)
830 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
831 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
832 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
833 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
834 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
835 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
836 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
837 (?L gnus-tmp-lines ?d)
838 (?I gnus-tmp-indentation ?s)
839 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
840 (?R gnus-tmp-replied ?c)
841 (?\[ gnus-tmp-opening-bracket ?c)
842 (?\] gnus-tmp-closing-bracket ?c)
843 (?\> (make-string gnus-tmp-level ? ) ?s)
844 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
845 (?i gnus-tmp-score ?d)
846 (?z gnus-tmp-score-char ?c)
847 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
848 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
849 (?U gnus-tmp-unread ?c)
850 (?t (gnus-summary-number-of-articles-in-thread
851 (and (boundp 'thread) (car thread)) gnus-tmp-level)
853 (?e (gnus-summary-number-of-articles-in-thread
854 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
856 (?u gnus-tmp-user-defined ?s)
857 (?P (gnus-pick-line-number) ?d))
858 "An alist of format specifications that can appear in summary lines,
859 and what variables they correspond with, along with the type of the
860 variable (string, integer, character, etc).")
862 (defvar gnus-summary-dummy-line-format-alist
863 `((?S gnus-tmp-subject ?s)
864 (?N gnus-tmp-number ?d)
865 (?u gnus-tmp-user-defined ?s)))
867 (defvar gnus-summary-mode-line-format-alist
868 `((?G gnus-tmp-group-name ?s)
869 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
870 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
871 (?A gnus-tmp-article-number ?d)
872 (?Z gnus-tmp-unread-and-unselected ?s)
874 (?U gnus-tmp-unread-and-unticked ?d)
875 (?S gnus-tmp-subject ?s)
876 (?e gnus-tmp-unselected ?d)
877 (?u gnus-tmp-user-defined ?s)
878 (?d (length gnus-newsgroup-dormant) ?d)
879 (?t (length gnus-newsgroup-marked) ?d)
880 (?r (length gnus-newsgroup-reads) ?d)
881 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
882 (?E gnus-newsgroup-expunged-tally ?d)
883 (?s (gnus-current-score-file-nondirectory) ?s)))
885 (defvar gnus-last-search-regexp nil
886 "Default regexp for article search command.")
888 (defvar gnus-last-shell-command nil
889 "Default shell command on article.")
891 (defvar gnus-newsgroup-begin nil)
892 (defvar gnus-newsgroup-end nil)
893 (defvar gnus-newsgroup-last-rmail nil)
894 (defvar gnus-newsgroup-last-mail nil)
895 (defvar gnus-newsgroup-last-folder nil)
896 (defvar gnus-newsgroup-last-file nil)
897 (defvar gnus-newsgroup-auto-expire nil)
898 (defvar gnus-newsgroup-active nil)
900 (defvar gnus-newsgroup-data nil)
901 (defvar gnus-newsgroup-data-reverse nil)
902 (defvar gnus-newsgroup-limit nil)
903 (defvar gnus-newsgroup-limits nil)
905 (defvar gnus-newsgroup-unreads nil
906 "List of unread articles in the current newsgroup.")
908 (defvar gnus-newsgroup-unselected nil
909 "List of unselected unread articles in the current newsgroup.")
911 (defvar gnus-newsgroup-reads nil
912 "Alist of read articles and article marks in the current newsgroup.")
914 (defvar gnus-newsgroup-expunged-tally nil)
916 (defvar gnus-newsgroup-marked nil
917 "List of ticked articles in the current newsgroup (a subset of unread art).")
919 (defvar gnus-newsgroup-killed nil
920 "List of ranges of articles that have been through the scoring process.")
922 (defvar gnus-newsgroup-cached nil
923 "List of articles that come from the article cache.")
925 (defvar gnus-newsgroup-saved nil
926 "List of articles that have been saved.")
928 (defvar gnus-newsgroup-kill-headers nil)
930 (defvar gnus-newsgroup-replied nil
931 "List of articles that have been replied to in the current newsgroup.")
933 (defvar gnus-newsgroup-expirable nil
934 "List of articles in the current newsgroup that can be expired.")
936 (defvar gnus-newsgroup-processable nil
937 "List of articles in the current newsgroup that can be processed.")
939 (defvar gnus-newsgroup-downloadable nil
940 "List of articles in the current newsgroup that can be processed.")
942 (defvar gnus-newsgroup-undownloaded nil
943 "List of articles in the current newsgroup that haven't been downloaded..")
945 (defvar gnus-newsgroup-unsendable nil
946 "List of articles in the current newsgroup that won't be sent.")
948 (defvar gnus-newsgroup-bookmarks nil
949 "List of articles in the current newsgroup that have bookmarks.")
951 (defvar gnus-newsgroup-dormant nil
952 "List of dormant articles in the current newsgroup.")
954 (defvar gnus-newsgroup-scored nil
955 "List of scored articles in the current newsgroup.")
957 (defvar gnus-newsgroup-headers nil
958 "List of article headers in the current newsgroup.")
960 (defvar gnus-newsgroup-threads nil)
962 (defvar gnus-newsgroup-prepared nil
963 "Whether the current group has been prepared properly.")
965 (defvar gnus-newsgroup-ancient nil
966 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
968 (defvar gnus-newsgroup-sparse nil)
970 (defvar gnus-current-article nil)
971 (defvar gnus-article-current nil)
972 (defvar gnus-current-headers nil)
973 (defvar gnus-have-all-headers nil)
974 (defvar gnus-last-article nil)
975 (defvar gnus-newsgroup-history nil)
977 (defconst gnus-summary-local-variables
978 '(gnus-newsgroup-name
979 gnus-newsgroup-begin gnus-newsgroup-end
980 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
981 gnus-newsgroup-last-folder gnus-newsgroup-last-file
982 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
983 gnus-newsgroup-unselected gnus-newsgroup-marked
984 gnus-newsgroup-reads gnus-newsgroup-saved
985 gnus-newsgroup-replied gnus-newsgroup-expirable
986 gnus-newsgroup-processable gnus-newsgroup-killed
987 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
988 gnus-newsgroup-unsendable
989 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
990 gnus-newsgroup-headers gnus-newsgroup-threads
991 gnus-newsgroup-prepared gnus-summary-highlight-line-function
992 gnus-current-article gnus-current-headers gnus-have-all-headers
993 gnus-last-article gnus-article-internal-prepare-hook
994 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
995 gnus-newsgroup-scored gnus-newsgroup-kill-headers
996 gnus-thread-expunge-below
997 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
998 (gnus-summary-mark-below . global)
999 gnus-newsgroup-active gnus-scores-exclude-files
1000 gnus-newsgroup-history gnus-newsgroup-ancient
1001 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1002 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1003 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1004 (gnus-newsgroup-expunged-tally . 0)
1005 gnus-cache-removable-articles gnus-newsgroup-cached
1006 gnus-newsgroup-data gnus-newsgroup-data-reverse
1007 gnus-newsgroup-limit gnus-newsgroup-limits)
1008 "Variables that are buffer-local to the summary buffers.")
1010 ;; Byte-compiler warning.
1011 (defvar gnus-article-mode-map)
1015 (defvar gnus-encoded-word-method-alist
1016 '(("chinese" mail-decode-encoded-word-string rfc1843-decode-string)
1017 (".*" mail-decode-encoded-word-string))
1018 "Alist of regexps (to match group names) and lists of functions to be applied.")
1020 (defun gnus-multi-decode-encoded-word-string (string)
1021 "Apply the functions from `gnus-encoded-word-method-alist' that match."
1022 (let ((alist gnus-encoded-word-method-alist)
1024 (while (setq elem (pop alist))
1025 (when (string-match (car elem) gnus-newsgroup-name)
1028 (setq string (funcall (pop elem) string)))
1032 ;; Subject simplification.
1034 (defun gnus-simplify-whitespace (str)
1035 "Remove excessive whitespace."
1038 (while (string-match "[ \t][ \t]+" mystr)
1039 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1041 (substring mystr (match-end 0)))))
1043 (when (string-match "^[ \t]+" mystr)
1044 (setq mystr (substring mystr (match-end 0))))
1046 (when (string-match "[ \t]+$" mystr)
1047 (setq mystr (substring mystr 0 (match-beginning 0))))
1050 (defsubst gnus-simplify-subject-re (subject)
1051 "Remove \"Re:\" from subject lines."
1052 (if (string-match "^[Rr][Ee]: *" subject)
1053 (substring subject (match-end 0))
1056 (defun gnus-simplify-subject (subject &optional re-only)
1057 "Remove `Re:' and words in parentheses.
1058 If RE-ONLY is non-nil, strip leading `Re:'s only."
1059 (let ((case-fold-search t)) ;Ignore case.
1060 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1061 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1062 (setq subject (substring subject (match-end 0))))
1063 ;; Remove uninteresting prefixes.
1064 (when (and (not re-only)
1065 gnus-simplify-ignored-prefixes
1066 (string-match gnus-simplify-ignored-prefixes subject))
1067 (setq subject (substring subject (match-end 0))))
1068 ;; Remove words in parentheses from end.
1070 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1071 (setq subject (substring subject 0 (match-beginning 0)))))
1072 ;; Return subject string.
1075 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1077 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1078 (goto-char (point-min))
1079 (while (re-search-forward regexp nil t)
1080 (replace-match (or newtext ""))))
1082 (defun gnus-simplify-buffer-fuzzy ()
1083 "Simplify string in the buffer fuzzily.
1084 The string in the accessible portion of the current buffer is simplified.
1085 It is assumed to be a single-line subject.
1086 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1087 matter is removed. Additional things can be deleted by setting
1088 gnus-simplify-subject-fuzzy-regexp."
1089 (let ((case-fold-search t)
1091 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1093 (while (not (eq modified-tick (buffer-modified-tick)))
1094 (setq modified-tick (buffer-modified-tick))
1096 ((listp gnus-simplify-subject-fuzzy-regexp)
1097 (mapcar 'gnus-simplify-buffer-fuzzy-step
1098 gnus-simplify-subject-fuzzy-regexp))
1099 (gnus-simplify-subject-fuzzy-regexp
1100 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1101 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1102 (gnus-simplify-buffer-fuzzy-step
1103 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1104 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1106 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1107 (gnus-simplify-buffer-fuzzy-step " +" " ")
1108 (gnus-simplify-buffer-fuzzy-step " $")
1109 (gnus-simplify-buffer-fuzzy-step "^ +")))
1111 (defun gnus-simplify-subject-fuzzy (subject)
1112 "Simplify a subject string fuzzily.
1113 See `gnus-simplify-buffer-fuzzy' for details."
1115 (gnus-set-work-buffer)
1116 (let ((case-fold-search t))
1117 ;; Remove uninteresting prefixes.
1118 (when (and gnus-simplify-ignored-prefixes
1119 (string-match gnus-simplify-ignored-prefixes subject))
1120 (setq subject (substring subject (match-end 0))))
1122 (inline (gnus-simplify-buffer-fuzzy))
1125 (defsubst gnus-simplify-subject-fully (subject)
1126 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1128 (gnus-simplify-subject-functions
1129 (gnus-map-function gnus-simplify-subject-functions subject))
1130 ((null gnus-summary-gather-subject-limit)
1131 (gnus-simplify-subject-re subject))
1132 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1133 (gnus-simplify-subject-fuzzy subject))
1134 ((numberp gnus-summary-gather-subject-limit)
1135 (gnus-limit-string (gnus-simplify-subject-re subject)
1136 gnus-summary-gather-subject-limit))
1140 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1141 "Check whether two subjects are equal.
1142 If optional argument simple-first is t, first argument is already
1145 ((null simple-first)
1146 (equal (gnus-simplify-subject-fully s1)
1147 (gnus-simplify-subject-fully s2)))
1150 (gnus-simplify-subject-fully s2)))))
1152 (defun gnus-summary-bubble-group ()
1153 "Increase the score of the current group.
1154 This is a handy function to add to `gnus-summary-exit-hook' to
1155 increase the score of each group you read."
1156 (gnus-group-add-score gnus-newsgroup-name))
1160 ;;; Gnus summary mode
1163 (put 'gnus-summary-mode 'mode-class 'special)
1166 ;; Non-orthogonal keys
1168 (gnus-define-keys gnus-summary-mode-map
1169 " " gnus-summary-next-page
1170 "\177" gnus-summary-prev-page
1171 [delete] gnus-summary-prev-page
1172 [backspace] gnus-summary-prev-page
1173 "\r" gnus-summary-scroll-up
1174 "\M-\r" gnus-summary-scroll-down
1175 "n" gnus-summary-next-unread-article
1176 "p" gnus-summary-prev-unread-article
1177 "N" gnus-summary-next-article
1178 "P" gnus-summary-prev-article
1179 "\M-\C-n" gnus-summary-next-same-subject
1180 "\M-\C-p" gnus-summary-prev-same-subject
1181 "\M-n" gnus-summary-next-unread-subject
1182 "\M-p" gnus-summary-prev-unread-subject
1183 "." gnus-summary-first-unread-article
1184 "," gnus-summary-best-unread-article
1185 "\M-s" gnus-summary-search-article-forward
1186 "\M-r" gnus-summary-search-article-backward
1187 "<" gnus-summary-beginning-of-article
1188 ">" gnus-summary-end-of-article
1189 "j" gnus-summary-goto-article
1190 "^" gnus-summary-refer-parent-article
1191 "\M-^" gnus-summary-refer-article
1192 "u" gnus-summary-tick-article-forward
1193 "!" gnus-summary-tick-article-forward
1194 "U" gnus-summary-tick-article-backward
1195 "d" gnus-summary-mark-as-read-forward
1196 "D" gnus-summary-mark-as-read-backward
1197 "E" gnus-summary-mark-as-expirable
1198 "\M-u" gnus-summary-clear-mark-forward
1199 "\M-U" gnus-summary-clear-mark-backward
1200 "k" gnus-summary-kill-same-subject-and-select
1201 "\C-k" gnus-summary-kill-same-subject
1202 "\M-\C-k" gnus-summary-kill-thread
1203 "\M-\C-l" gnus-summary-lower-thread
1204 "e" gnus-summary-edit-article
1205 "#" gnus-summary-mark-as-processable
1206 "\M-#" gnus-summary-unmark-as-processable
1207 "\M-\C-t" gnus-summary-toggle-threads
1208 "\M-\C-s" gnus-summary-show-thread
1209 "\M-\C-h" gnus-summary-hide-thread
1210 "\M-\C-f" gnus-summary-next-thread
1211 "\M-\C-b" gnus-summary-prev-thread
1212 "\M-\C-u" gnus-summary-up-thread
1213 "\M-\C-d" gnus-summary-down-thread
1214 "&" gnus-summary-execute-command
1215 "c" gnus-summary-catchup-and-exit
1216 "\C-w" gnus-summary-mark-region-as-read
1217 "\C-t" gnus-summary-toggle-truncation
1218 "?" gnus-summary-mark-as-dormant
1219 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1220 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1221 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1222 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1223 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1224 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1225 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1226 "=" gnus-summary-expand-window
1227 "\C-x\C-s" gnus-summary-reselect-current-group
1228 "\M-g" gnus-summary-rescan-group
1229 "w" gnus-summary-stop-page-breaking
1230 "\C-c\C-r" gnus-summary-caesar-message
1231 "\M-t" gnus-summary-toggle-mime
1232 "f" gnus-summary-followup
1233 "F" gnus-summary-followup-with-original
1234 "C" gnus-summary-cancel-article
1235 "r" gnus-summary-reply
1236 "R" gnus-summary-reply-with-original
1237 "\C-c\C-f" gnus-summary-mail-forward
1238 "o" gnus-summary-save-article
1239 "\C-o" gnus-summary-save-article-mail
1240 "|" gnus-summary-pipe-output
1241 "\M-k" gnus-summary-edit-local-kill
1242 "\M-K" gnus-summary-edit-global-kill
1244 "\C-c\C-d" gnus-summary-describe-group
1245 "q" gnus-summary-exit
1246 "Q" gnus-summary-exit-no-update
1247 "\C-c\C-i" gnus-info-find-node
1248 gnus-mouse-2 gnus-mouse-pick-article
1249 "m" gnus-summary-mail-other-window
1250 "a" gnus-summary-post-news
1251 "x" gnus-summary-limit-to-unread
1252 "s" gnus-summary-isearch-article
1253 "t" gnus-article-hide-headers
1254 "g" gnus-summary-show-article
1255 "l" gnus-summary-goto-last-article
1256 "v" gnus-summary-preview-mime-message
1257 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1258 "\C-d" gnus-summary-enter-digest-group
1259 "\M-\C-d" gnus-summary-read-document
1260 "\M-\C-e" gnus-summary-edit-parameters
1262 "*" gnus-cache-enter-article
1263 "\M-*" gnus-cache-remove-article
1264 "\M-&" gnus-summary-universal-argument
1265 "\C-l" gnus-recenter
1266 "I" gnus-summary-increase-score
1267 "L" gnus-summary-lower-score
1268 "\M-i" gnus-symbolic-argument
1269 "h" gnus-summary-select-article-buffer
1271 "V" gnus-summary-score-map
1272 "X" gnus-uu-extract-map
1273 "S" gnus-summary-send-map)
1275 ;; Sort of orthogonal keymap
1276 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1277 "t" gnus-summary-tick-article-forward
1278 "!" gnus-summary-tick-article-forward
1279 "d" gnus-summary-mark-as-read-forward
1280 "r" gnus-summary-mark-as-read-forward
1281 "c" gnus-summary-clear-mark-forward
1282 " " gnus-summary-clear-mark-forward
1283 "e" gnus-summary-mark-as-expirable
1284 "x" gnus-summary-mark-as-expirable
1285 "?" gnus-summary-mark-as-dormant
1286 "b" gnus-summary-set-bookmark
1287 "B" gnus-summary-remove-bookmark
1288 "#" gnus-summary-mark-as-processable
1289 "\M-#" gnus-summary-unmark-as-processable
1290 "S" gnus-summary-limit-include-expunged
1291 "C" gnus-summary-catchup
1292 "H" gnus-summary-catchup-to-here
1293 "\C-c" gnus-summary-catchup-all
1294 "k" gnus-summary-kill-same-subject-and-select
1295 "K" gnus-summary-kill-same-subject
1296 "P" gnus-uu-mark-map)
1298 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1299 "c" gnus-summary-clear-above
1300 "u" gnus-summary-tick-above
1301 "m" gnus-summary-mark-above
1302 "k" gnus-summary-kill-below)
1304 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1305 "/" gnus-summary-limit-to-subject
1306 "n" gnus-summary-limit-to-articles
1307 "w" gnus-summary-pop-limit
1308 "s" gnus-summary-limit-to-subject
1309 "a" gnus-summary-limit-to-author
1310 "u" gnus-summary-limit-to-unread
1311 "m" gnus-summary-limit-to-marks
1312 "v" gnus-summary-limit-to-score
1313 "*" gnus-summary-limit-include-cached
1314 "D" gnus-summary-limit-include-dormant
1315 "T" gnus-summary-limit-include-thread
1316 "d" gnus-summary-limit-exclude-dormant
1317 "t" gnus-summary-limit-to-age
1318 "E" gnus-summary-limit-include-expunged
1319 "c" gnus-summary-limit-exclude-childless-dormant
1320 "C" gnus-summary-limit-mark-excluded-as-read)
1322 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1323 "n" gnus-summary-next-unread-article
1324 "p" gnus-summary-prev-unread-article
1325 "N" gnus-summary-next-article
1326 "P" gnus-summary-prev-article
1327 "\C-n" gnus-summary-next-same-subject
1328 "\C-p" gnus-summary-prev-same-subject
1329 "\M-n" gnus-summary-next-unread-subject
1330 "\M-p" gnus-summary-prev-unread-subject
1331 "f" gnus-summary-first-unread-article
1332 "b" gnus-summary-best-unread-article
1333 "j" gnus-summary-goto-article
1334 "g" gnus-summary-goto-subject
1335 "l" gnus-summary-goto-last-article
1336 "o" gnus-summary-pop-article)
1338 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1339 "k" gnus-summary-kill-thread
1340 "l" gnus-summary-lower-thread
1341 "i" gnus-summary-raise-thread
1342 "T" gnus-summary-toggle-threads
1343 "t" gnus-summary-rethread-current
1344 "^" gnus-summary-reparent-thread
1345 "s" gnus-summary-show-thread
1346 "S" gnus-summary-show-all-threads
1347 "h" gnus-summary-hide-thread
1348 "H" gnus-summary-hide-all-threads
1349 "n" gnus-summary-next-thread
1350 "p" gnus-summary-prev-thread
1351 "u" gnus-summary-up-thread
1352 "o" gnus-summary-top-thread
1353 "d" gnus-summary-down-thread
1354 "#" gnus-uu-mark-thread
1355 "\M-#" gnus-uu-unmark-thread)
1357 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1358 "g" gnus-summary-prepare
1359 "c" gnus-summary-insert-cached-articles)
1361 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1362 "c" gnus-summary-catchup-and-exit
1363 "C" gnus-summary-catchup-all-and-exit
1364 "E" gnus-summary-exit-no-update
1365 "Q" gnus-summary-exit
1366 "Z" gnus-summary-exit
1367 "n" gnus-summary-catchup-and-goto-next-group
1368 "R" gnus-summary-reselect-current-group
1369 "G" gnus-summary-rescan-group
1370 "N" gnus-summary-next-group
1371 "s" gnus-summary-save-newsrc
1372 "P" gnus-summary-prev-group)
1374 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1375 " " gnus-summary-next-page
1376 "n" gnus-summary-next-page
1377 "\177" gnus-summary-prev-page
1378 [delete] gnus-summary-prev-page
1379 "p" gnus-summary-prev-page
1380 "\r" gnus-summary-scroll-up
1381 "\M-\r" gnus-summary-scroll-down
1382 "<" gnus-summary-beginning-of-article
1383 ">" gnus-summary-end-of-article
1384 "b" gnus-summary-beginning-of-article
1385 "e" gnus-summary-end-of-article
1386 "^" gnus-summary-refer-parent-article
1387 "r" gnus-summary-refer-parent-article
1388 "R" gnus-summary-refer-references
1389 "T" gnus-summary-refer-thread
1390 "g" gnus-summary-show-article
1391 "s" gnus-summary-isearch-article
1392 "P" gnus-summary-print-article)
1394 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1395 "b" gnus-article-add-buttons
1396 "B" gnus-article-add-buttons-to-head
1397 "o" gnus-article-treat-overstrike
1398 "e" gnus-article-emphasize
1399 "w" gnus-article-fill-cited-article
1400 "c" gnus-article-remove-cr
1401 "f" gnus-article-display-x-face
1402 "l" gnus-summary-stop-page-breaking
1403 "r" gnus-summary-caesar-message
1404 "t" gnus-article-hide-headers
1405 "v" gnus-summary-verbose-headers
1406 "m" gnus-summary-toggle-mime
1407 "h" gnus-article-treat-html
1408 "d" gnus-article-treat-dumbquotes)
1410 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1411 "a" gnus-article-hide
1412 "h" gnus-article-hide-headers
1413 "b" gnus-article-hide-boring-headers
1414 "s" gnus-article-hide-signature
1415 "c" gnus-article-hide-citation
1416 "C" gnus-article-hide-citation-in-followups
1417 "p" gnus-article-hide-pgp
1418 "P" gnus-article-hide-pem
1419 "\C-c" gnus-article-hide-citation-maybe)
1421 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1422 "a" gnus-article-highlight
1423 "h" gnus-article-highlight-headers
1424 "c" gnus-article-highlight-citation
1425 "s" gnus-article-highlight-signature)
1427 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1428 "z" gnus-article-date-ut
1429 "u" gnus-article-date-ut
1430 "l" gnus-article-date-local
1431 "e" gnus-article-date-lapsed
1432 "o" gnus-article-date-original
1433 "i" gnus-article-date-iso8601
1434 "s" gnus-article-date-user)
1436 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1437 "t" gnus-article-remove-trailing-blank-lines
1438 "l" gnus-article-strip-leading-blank-lines
1439 "m" gnus-article-strip-multiple-blank-lines
1440 "a" gnus-article-strip-blank-lines
1441 "A" gnus-article-strip-all-blank-lines
1442 "s" gnus-article-strip-leading-space)
1444 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1446 "f" gnus-summary-fetch-faq
1447 "d" gnus-summary-describe-group
1448 "h" gnus-summary-describe-briefly
1449 "i" gnus-info-find-node)
1451 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1452 "e" gnus-summary-expire-articles
1453 "\M-\C-e" gnus-summary-expire-articles-now
1454 "\177" gnus-summary-delete-article
1455 [delete] gnus-summary-delete-article
1456 "m" gnus-summary-move-article
1457 "r" gnus-summary-respool-article
1458 "w" gnus-summary-edit-article
1459 "c" gnus-summary-copy-article
1460 "B" gnus-summary-crosspost-article
1461 "q" gnus-summary-respool-query
1462 "t" gnus-summary-respool-trace
1463 "i" gnus-summary-import-article
1464 "p" gnus-summary-article-posted-p)
1466 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1467 "o" gnus-summary-save-article
1468 "m" gnus-summary-save-article-mail
1469 "F" gnus-summary-write-article-file
1470 "r" gnus-summary-save-article-rmail
1471 "f" gnus-summary-save-article-file
1472 "b" gnus-summary-save-article-body-file
1473 "h" gnus-summary-save-article-folder
1474 "v" gnus-summary-save-article-vm
1475 "p" gnus-summary-pipe-output
1476 "s" gnus-soup-add-article))
1478 (defun gnus-summary-make-menu-bar ()
1479 (gnus-turn-off-edit-menu 'summary)
1481 (unless (boundp 'gnus-summary-misc-menu)
1484 gnus-summary-kill-menu gnus-summary-mode-map ""
1489 ["Enter score..." gnus-summary-score-entry t]
1490 ["Customize" gnus-score-customize t])
1491 (gnus-make-score-map 'increase)
1492 (gnus-make-score-map 'lower)
1494 ["Kill below" gnus-summary-kill-below t]
1495 ["Mark above" gnus-summary-mark-above t]
1496 ["Tick above" gnus-summary-tick-above t]
1497 ["Clear above" gnus-summary-clear-above t])
1498 ["Current score" gnus-summary-current-score t]
1499 ["Set score" gnus-summary-set-score t]
1500 ["Switch current score file..." gnus-score-change-score-file t]
1501 ["Set mark below..." gnus-score-set-mark-below t]
1502 ["Set expunge below..." gnus-score-set-expunge-below t]
1503 ["Edit current score file" gnus-score-edit-current-scores t]
1504 ["Edit score file" gnus-score-edit-file t]
1505 ["Trace score" gnus-score-find-trace t]
1506 ["Find words" gnus-score-find-favourite-words t]
1507 ["Rescore buffer" gnus-summary-rescore t]
1508 ["Increase score..." gnus-summary-increase-score t]
1509 ["Lower score..." gnus-summary-lower-score t]))))
1511 ;; Define both the Article menu in the summary buffer and the equivalent
1512 ;; Commands menu in the article buffer here for consistency.
1515 ["All" gnus-article-hide t]
1516 ["Headers" gnus-article-hide-headers t]
1517 ["Signature" gnus-article-hide-signature t]
1518 ["Citation" gnus-article-hide-citation t]
1519 ["PGP" gnus-article-hide-pgp t]
1520 ["Boring headers" gnus-article-hide-boring-headers t])
1522 ["All" gnus-article-highlight t]
1523 ["Headers" gnus-article-highlight-headers t]
1524 ["Signature" gnus-article-highlight-signature t]
1525 ["Citation" gnus-article-highlight-citation t])
1527 ["Local" gnus-article-date-local t]
1528 ["ISO8601" gnus-article-date-iso8601 t]
1529 ["UT" gnus-article-date-ut t]
1530 ["Original" gnus-article-date-original t]
1531 ["Lapsed" gnus-article-date-lapsed t]
1532 ["User-defined" gnus-article-date-user t])
1535 ["Leading" gnus-article-strip-leading-blank-lines t]
1536 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1537 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1538 ["All of the above" gnus-article-strip-blank-lines t]
1539 ["All" gnus-article-strip-all-blank-lines t]
1540 ["Leading space" gnus-article-strip-leading-space t])
1541 ["Overstrike" gnus-article-treat-overstrike t]
1542 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1543 ["Emphasis" gnus-article-emphasize t]
1544 ["Word wrap" gnus-article-fill-cited-article t]
1545 ["CR" gnus-article-remove-cr t]
1546 ["Show X-Face" gnus-article-display-x-face t]
1547 ["UnHTMLize" gnus-article-treat-html t]
1548 ["Rot 13" gnus-summary-caesar-message t]
1549 ["Unix pipe" gnus-summary-pipe-message t]
1550 ["Add buttons" gnus-article-add-buttons t]
1551 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1552 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1553 ["Toggle MIME" gnus-summary-toggle-mime t]
1554 ["Verbose header" gnus-summary-verbose-headers t]
1555 ["Toggle header" gnus-summary-toggle-header t])
1557 ["Save in default format" gnus-summary-save-article t]
1558 ["Save in file" gnus-summary-save-article-file t]
1559 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1560 ["Save in MH folder" gnus-summary-save-article-folder t]
1561 ["Save in VM folder" gnus-summary-save-article-vm t]
1562 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1563 ["Save body in file" gnus-summary-save-article-body-file t]
1564 ["Pipe through a filter" gnus-summary-pipe-output t]
1565 ["Add to SOUP packet" gnus-soup-add-article t]
1566 ["Print" gnus-summary-print-article t])
1568 ["Respool article..." gnus-summary-respool-article t]
1569 ["Move article..." gnus-summary-move-article
1570 (gnus-check-backend-function
1571 'request-move-article gnus-newsgroup-name)]
1572 ["Copy article..." gnus-summary-copy-article t]
1573 ["Crosspost article..." gnus-summary-crosspost-article
1574 (gnus-check-backend-function
1575 'request-replace-article gnus-newsgroup-name)]
1576 ["Import file..." gnus-summary-import-article t]
1577 ["Check if posted" gnus-summary-article-posted-p t]
1578 ["Edit article" gnus-summary-edit-article
1579 (not (gnus-group-read-only-p))]
1580 ["Delete article" gnus-summary-delete-article
1581 (gnus-check-backend-function
1582 'request-expire-articles gnus-newsgroup-name)]
1583 ["Query respool" gnus-summary-respool-query t]
1584 ["Trace respool" gnus-summary-respool-trace t]
1585 ["Delete expirable articles" gnus-summary-expire-articles-now
1586 (gnus-check-backend-function
1587 'request-expire-articles gnus-newsgroup-name)])
1589 ["Uudecode" gnus-uu-decode-uu t]
1590 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1591 ["Unshar" gnus-uu-decode-unshar t]
1592 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1593 ["Save" gnus-uu-decode-save t]
1594 ["Binhex" gnus-uu-decode-binhex t]
1595 ["Postscript" gnus-uu-decode-postscript t])
1597 ["Enter article" gnus-cache-enter-article t]
1598 ["Remove article" gnus-cache-remove-article t])
1599 ["Select article buffer" gnus-summary-select-article-buffer t]
1600 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1601 ["Isearch article..." gnus-summary-isearch-article t]
1602 ["Beginning of the article" gnus-summary-beginning-of-article t]
1603 ["End of the article" gnus-summary-end-of-article t]
1604 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1605 ["Fetch referenced articles" gnus-summary-refer-references t]
1606 ["Fetch current thread" gnus-summary-refer-thread t]
1607 ["Fetch article with id..." gnus-summary-refer-article t]
1608 ["Redisplay" gnus-summary-show-article t])))
1610 gnus-summary-article-menu gnus-summary-mode-map ""
1611 (cons "Article" innards))
1614 gnus-article-commands-menu gnus-article-mode-map ""
1615 (cons "Commands" innards)))
1618 gnus-summary-thread-menu gnus-summary-mode-map ""
1620 ["Toggle threading" gnus-summary-toggle-threads t]
1621 ["Hide threads" gnus-summary-hide-all-threads t]
1622 ["Show threads" gnus-summary-show-all-threads t]
1623 ["Hide thread" gnus-summary-hide-thread t]
1624 ["Show thread" gnus-summary-show-thread t]
1625 ["Go to next thread" gnus-summary-next-thread t]
1626 ["Go to previous thread" gnus-summary-prev-thread t]
1627 ["Go down thread" gnus-summary-down-thread t]
1628 ["Go up thread" gnus-summary-up-thread t]
1629 ["Top of thread" gnus-summary-top-thread t]
1630 ["Mark thread as read" gnus-summary-kill-thread t]
1631 ["Lower thread score" gnus-summary-lower-thread t]
1632 ["Raise thread score" gnus-summary-raise-thread t]
1633 ["Rethread current" gnus-summary-rethread-current t]
1637 gnus-summary-post-menu gnus-summary-mode-map ""
1639 ["Post an article" gnus-summary-post-news t]
1640 ["Followup" gnus-summary-followup t]
1641 ["Followup and yank" gnus-summary-followup-with-original t]
1642 ["Supersede article" gnus-summary-supersede-article t]
1643 ["Cancel article" gnus-summary-cancel-article t]
1644 ["Reply" gnus-summary-reply t]
1645 ["Reply and yank" gnus-summary-reply-with-original t]
1646 ["Wide reply" gnus-summary-wide-reply t]
1647 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1648 ["Mail forward" gnus-summary-mail-forward t]
1649 ["Post forward" gnus-summary-post-forward t]
1650 ["Digest and mail" gnus-summary-mail-digest t]
1651 ["Digest and post" gnus-summary-post-digest t]
1652 ["Resend message" gnus-summary-resend-message t]
1653 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1654 ["Send a mail" gnus-summary-mail-other-window t]
1655 ["Uuencode and post" gnus-uu-post-news t]
1656 ["Followup via news" gnus-summary-followup-to-mail t]
1657 ["Followup via news and yank"
1658 gnus-summary-followup-to-mail-with-original t]
1660 ;;["Send" gnus-summary-send-draft t]
1661 ;;["Send bounced" gnus-resend-bounced-mail t])
1665 gnus-summary-misc-menu gnus-summary-mode-map ""
1668 ["Mark as read" gnus-summary-mark-as-read-forward t]
1669 ["Mark same subject and select"
1670 gnus-summary-kill-same-subject-and-select t]
1671 ["Mark same subject" gnus-summary-kill-same-subject t]
1672 ["Catchup" gnus-summary-catchup t]
1673 ["Catchup all" gnus-summary-catchup-all t]
1674 ["Catchup to here" gnus-summary-catchup-to-here t]
1675 ["Catchup region" gnus-summary-mark-region-as-read t]
1676 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1678 ["Tick" gnus-summary-tick-article-forward t]
1679 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1680 ["Remove marks" gnus-summary-clear-mark-forward t]
1681 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1682 ["Set bookmark" gnus-summary-set-bookmark t]
1683 ["Remove bookmark" gnus-summary-remove-bookmark t])
1685 ["Marks..." gnus-summary-limit-to-marks t]
1686 ["Subject..." gnus-summary-limit-to-subject t]
1687 ["Author..." gnus-summary-limit-to-author t]
1688 ["Age..." gnus-summary-limit-to-age t]
1689 ["Score" gnus-summary-limit-to-score t]
1690 ["Unread" gnus-summary-limit-to-unread t]
1691 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1692 ["Articles" gnus-summary-limit-to-articles t]
1693 ["Pop limit" gnus-summary-pop-limit t]
1694 ["Show dormant" gnus-summary-limit-include-dormant t]
1695 ["Hide childless dormant"
1696 gnus-summary-limit-exclude-childless-dormant t]
1697 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1698 ["Show expunged" gnus-summary-show-all-expunged t])
1700 ["Set mark" gnus-summary-mark-as-processable t]
1701 ["Remove mark" gnus-summary-unmark-as-processable t]
1702 ["Remove all marks" gnus-summary-unmark-all-processable t]
1703 ["Mark above" gnus-uu-mark-over t]
1704 ["Mark series" gnus-uu-mark-series t]
1705 ["Mark region" gnus-uu-mark-region t]
1706 ["Unmark region" gnus-uu-unmark-region t]
1707 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1708 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1709 ["Mark all" gnus-uu-mark-all t]
1710 ["Mark buffer" gnus-uu-mark-buffer t]
1711 ["Mark sparse" gnus-uu-mark-sparse t]
1712 ["Mark thread" gnus-uu-mark-thread t]
1713 ["Unmark thread" gnus-uu-unmark-thread t]
1714 ("Process Mark Sets"
1715 ["Kill" gnus-summary-kill-process-mark t]
1716 ["Yank" gnus-summary-yank-process-mark
1717 gnus-newsgroup-process-stack]
1718 ["Save" gnus-summary-save-process-mark t]))
1720 ["Page forward" gnus-summary-next-page t]
1721 ["Page backward" gnus-summary-prev-page t]
1722 ["Line forward" gnus-summary-scroll-up t])
1724 ["Next unread article" gnus-summary-next-unread-article t]
1725 ["Previous unread article" gnus-summary-prev-unread-article t]
1726 ["Next article" gnus-summary-next-article t]
1727 ["Previous article" gnus-summary-prev-article t]
1728 ["Next unread subject" gnus-summary-next-unread-subject t]
1729 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1730 ["Next article same subject" gnus-summary-next-same-subject t]
1731 ["Previous article same subject" gnus-summary-prev-same-subject t]
1732 ["First unread article" gnus-summary-first-unread-article t]
1733 ["Best unread article" gnus-summary-best-unread-article t]
1734 ["Go to subject number..." gnus-summary-goto-subject t]
1735 ["Go to article number..." gnus-summary-goto-article t]
1736 ["Go to the last article" gnus-summary-goto-last-article t]
1737 ["Pop article off history" gnus-summary-pop-article t])
1739 ["Sort by number" gnus-summary-sort-by-number t]
1740 ["Sort by author" gnus-summary-sort-by-author t]
1741 ["Sort by subject" gnus-summary-sort-by-subject t]
1742 ["Sort by date" gnus-summary-sort-by-date t]
1743 ["Sort by score" gnus-summary-sort-by-score t]
1744 ["Sort by lines" gnus-summary-sort-by-lines t])
1746 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1747 ["Describe group" gnus-summary-describe-group t]
1748 ["Read manual" gnus-info-find-node t])
1750 ["Pick and read" gnus-pick-mode t]
1751 ["Binary" gnus-binary-mode t])
1753 ["Regenerate" gnus-summary-prepare t]
1754 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1755 ["Toggle threading" gnus-summary-toggle-threads t])
1756 ["Filter articles..." gnus-summary-execute-command t]
1757 ["Run command on subjects..." gnus-summary-universal-argument t]
1758 ["Search articles forward..." gnus-summary-search-article-forward t]
1759 ["Search articles backward..." gnus-summary-search-article-backward t]
1760 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1761 ["Expand window" gnus-summary-expand-window t]
1762 ["Expire expirable articles" gnus-summary-expire-articles
1763 (gnus-check-backend-function
1764 'request-expire-articles gnus-newsgroup-name)]
1765 ["Edit local kill file" gnus-summary-edit-local-kill t]
1766 ["Edit main kill file" gnus-summary-edit-global-kill t]
1767 ["Edit group parameters" gnus-summary-edit-parameters t]
1768 ["Send a bug report" gnus-bug t]
1770 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1771 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1772 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1773 ["Exit group" gnus-summary-exit t]
1774 ["Exit group without updating" gnus-summary-exit-no-update t]
1775 ["Exit and goto next group" gnus-summary-next-group t]
1776 ["Exit and goto prev group" gnus-summary-prev-group t]
1777 ["Reselect group" gnus-summary-reselect-current-group t]
1778 ["Rescan group" gnus-summary-rescan-group t]
1779 ["Update dribble" gnus-summary-save-newsrc t])))
1781 (gnus-run-hooks 'gnus-summary-menu-hook)))
1783 (defun gnus-score-set-default (var value)
1784 "A version of set that updates the GNU Emacs menu-bar."
1786 ;; It is the message that forces the active status to be updated.
1789 (defun gnus-make-score-map (type)
1790 "Make a summary score map of type TYPE."
1793 (let ((headers '(("author" "from" string)
1794 ("subject" "subject" string)
1795 ("article body" "body" string)
1796 ("article head" "head" string)
1797 ("xref" "xref" string)
1798 ("lines" "lines" number)
1799 ("followups to author" "followup" string)))
1800 (types '((number ("less than" <)
1803 (string ("substring" s)
1807 (perms '(("temporary" (current-time-string))
1815 (if (eq type 'lower)
1820 (setq header (car headers))
1826 (let ((ts (cdr (assoc (nth 2 header) types)))
1842 'gnus-summary-score-entry
1844 (if (or (string= (nth 1 header)
1846 (string= (nth 1 header)
1849 (list 'gnus-summary-header
1851 (list 'quote (nth 1 (car ts)))
1852 (list 'gnus-score-default nil)
1858 (list (nreverse outp))))
1861 (list (nreverse outt))))
1863 (setq headers (cdr headers)))
1864 (list (nreverse outh))))))))
1868 (defun gnus-summary-mode (&optional group)
1869 "Major mode for reading articles.
1871 All normal editing commands are switched off.
1872 \\<gnus-summary-mode-map>
1873 Each line in this buffer represents one article. To read an
1874 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1875 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1878 You can also post articles and send mail from this buffer. To
1879 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1880 of an article, type `\\[gnus-summary-reply]'.
1882 There are approx. one gazillion commands you can execute in this
1883 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1885 The following commands are available:
1887 \\{gnus-summary-mode-map}"
1889 (when (gnus-visual-p 'summary-menu 'menu)
1890 (gnus-summary-make-menu-bar))
1891 (kill-all-local-variables)
1892 (gnus-summary-make-local-variables)
1893 (gnus-make-thread-indent-array)
1894 (gnus-simplify-mode-line)
1895 (setq major-mode 'gnus-summary-mode)
1896 (setq mode-name "Summary")
1897 (make-local-variable 'minor-mode-alist)
1898 (use-local-map gnus-summary-mode-map)
1899 (buffer-disable-undo)
1900 (setq buffer-read-only t) ;Disable modification
1901 (setq truncate-lines t)
1902 (setq selective-display t)
1903 (setq selective-display-ellipses t) ;Display `...'
1904 (gnus-summary-set-display-table)
1905 (gnus-set-default-directory)
1906 (setq gnus-newsgroup-name group)
1907 (make-local-variable 'gnus-summary-line-format)
1908 (make-local-variable 'gnus-summary-line-format-spec)
1909 (make-local-variable 'gnus-summary-dummy-line-format)
1910 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1911 (make-local-variable 'gnus-summary-mark-positions)
1912 (make-local-hook 'post-command-hook)
1913 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1914 (make-local-hook 'pre-command-hook)
1915 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1916 (gnus-run-hooks 'gnus-summary-mode-hook)
1917 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1918 (gnus-update-summary-mark-positions))
1920 (defun gnus-summary-make-local-variables ()
1921 "Make all the local summary buffer variables."
1922 (let ((locals gnus-summary-local-variables)
1924 (while (setq local (pop locals))
1927 (if (eq (cdr local) 'global)
1928 ;; Copy the global value of the variable.
1929 (setq global (symbol-value (car local)))
1930 ;; Use the value from the list.
1931 (setq global (eval (cdr local))))
1932 (make-local-variable (car local))
1933 (set (car local) global))
1934 ;; Simple nil-valued local variable.
1935 (make-local-variable local)
1938 (defun gnus-summary-clear-local-variables ()
1939 (let ((locals gnus-summary-local-variables))
1941 (if (consp (car locals))
1942 (and (vectorp (caar locals))
1943 (set (caar locals) nil))
1944 (and (vectorp (car locals))
1945 (set (car locals) nil)))
1946 (setq locals (cdr locals)))))
1948 ;; Summary data functions.
1950 (defmacro gnus-data-number (data)
1953 (defmacro gnus-data-set-number (data number)
1954 `(setcar ,data ,number))
1956 (defmacro gnus-data-mark (data)
1959 (defmacro gnus-data-set-mark (data mark)
1960 `(setcar (nthcdr 1 ,data) ,mark))
1962 (defmacro gnus-data-pos (data)
1965 (defmacro gnus-data-set-pos (data pos)
1966 `(setcar (nthcdr 2 ,data) ,pos))
1968 (defmacro gnus-data-header (data)
1971 (defmacro gnus-data-set-header (data header)
1972 `(setf (nth 3 ,data) ,header))
1974 (defmacro gnus-data-level (data)
1977 (defmacro gnus-data-unread-p (data)
1978 `(= (nth 1 ,data) gnus-unread-mark))
1980 (defmacro gnus-data-read-p (data)
1981 `(/= (nth 1 ,data) gnus-unread-mark))
1983 (defmacro gnus-data-pseudo-p (data)
1984 `(consp (nth 3 ,data)))
1986 (defmacro gnus-data-find (number)
1987 `(assq ,number gnus-newsgroup-data))
1989 (defmacro gnus-data-find-list (number &optional data)
1990 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1991 (memq (assq ,number bdata)
1994 (defmacro gnus-data-make (number mark pos header level)
1995 `(list ,number ,mark ,pos ,header ,level))
1997 (defun gnus-data-enter (after-article number mark pos header level offset)
1998 (let ((data (gnus-data-find-list after-article)))
2000 (error "No such article: %d" after-article))
2001 (setcdr data (cons (gnus-data-make number mark pos header level)
2003 (setq gnus-newsgroup-data-reverse nil)
2004 (gnus-data-update-list (cddr data) offset)))
2006 (defun gnus-data-enter-list (after-article list &optional offset)
2008 (let ((data (and after-article (gnus-data-find-list after-article)))
2012 (let ((odata gnus-newsgroup-data))
2013 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2015 (gnus-data-update-list odata offset)))
2016 ;; Find the last element in the list to be spliced into the main
2019 (setq list (cdr list)))
2022 (setcdr list gnus-newsgroup-data)
2023 (setq gnus-newsgroup-data ilist)
2025 (gnus-data-update-list (cdr list) offset)))
2026 (setcdr list (cdr data))
2029 (gnus-data-update-list (cdr list) offset))))
2030 (setq gnus-newsgroup-data-reverse nil))))
2032 (defun gnus-data-remove (article &optional offset)
2033 (let ((data gnus-newsgroup-data))
2034 (if (= (gnus-data-number (car data)) article)
2036 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2037 gnus-newsgroup-data-reverse nil)
2039 (gnus-data-update-list gnus-newsgroup-data offset)))
2041 (when (= (gnus-data-number (cadr data)) article)
2042 (setcdr data (cddr data))
2044 (gnus-data-update-list (cdr data) offset))
2046 gnus-newsgroup-data-reverse nil))
2047 (setq data (cdr data))))))
2049 (defmacro gnus-data-list (backward)
2051 (or gnus-newsgroup-data-reverse
2052 (setq gnus-newsgroup-data-reverse
2053 (reverse gnus-newsgroup-data)))
2054 gnus-newsgroup-data))
2056 (defun gnus-data-update-list (data offset)
2057 "Add OFFSET to the POS of all data entries in DATA."
2058 (setq gnus-newsgroup-data-reverse nil)
2060 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2061 (setq data (cdr data))))
2063 (defun gnus-summary-article-pseudo-p (article)
2064 "Say whether this article is a pseudo article or not."
2065 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2067 (defmacro gnus-summary-article-sparse-p (article)
2068 "Say whether this article is a sparse article or not."
2069 `(memq ,article gnus-newsgroup-sparse))
2071 (defmacro gnus-summary-article-ancient-p (article)
2072 "Say whether this article is a sparse article or not."
2073 `(memq ,article gnus-newsgroup-ancient))
2075 (defun gnus-article-parent-p (number)
2076 "Say whether this article is a parent or not."
2077 (let ((data (gnus-data-find-list number)))
2078 (and (cdr data) ; There has to be an article after...
2079 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2080 (gnus-data-level (nth 1 data))))))
2082 (defun gnus-article-children (number)
2083 "Return a list of all children to NUMBER."
2084 (let* ((data (gnus-data-find-list number))
2085 (level (gnus-data-level (car data)))
2087 (setq data (cdr data))
2089 (= (gnus-data-level (car data)) (1+ level)))
2090 (push (gnus-data-number (car data)) children)
2091 (setq data (cdr data)))
2094 (defmacro gnus-summary-skip-intangible ()
2095 "If the current article is intangible, then jump to a different article."
2096 '(let ((to (get-text-property (point) 'gnus-intangible)))
2097 (and to (gnus-summary-goto-subject to))))
2099 (defmacro gnus-summary-article-intangible-p ()
2100 "Say whether this article is intangible or not."
2101 '(get-text-property (point) 'gnus-intangible))
2103 (defun gnus-article-read-p (article)
2104 "Say whether ARTICLE is read or not."
2105 (not (or (memq article gnus-newsgroup-marked)
2106 (memq article gnus-newsgroup-unreads)
2107 (memq article gnus-newsgroup-unselected)
2108 (memq article gnus-newsgroup-dormant))))
2110 ;; Some summary mode macros.
2112 (defmacro gnus-summary-article-number ()
2113 "The article number of the article on the current line.
2114 If there isn's an article number here, then we return the current
2117 (gnus-summary-skip-intangible)
2118 (or (get-text-property (point) 'gnus-number)
2119 (gnus-summary-last-subject))))
2121 (defmacro gnus-summary-article-header (&optional number)
2122 "Return the header of article NUMBER."
2123 `(gnus-data-header (gnus-data-find
2124 ,(or number '(gnus-summary-article-number)))))
2126 (defmacro gnus-summary-thread-level (&optional number)
2127 "Return the level of thread that starts with article NUMBER."
2128 `(if (and (eq gnus-summary-make-false-root 'dummy)
2129 (get-text-property (point) 'gnus-intangible))
2131 (gnus-data-level (gnus-data-find
2132 ,(or number '(gnus-summary-article-number))))))
2134 (defmacro gnus-summary-article-mark (&optional number)
2135 "Return the mark of article NUMBER."
2136 `(gnus-data-mark (gnus-data-find
2137 ,(or number '(gnus-summary-article-number)))))
2139 (defmacro gnus-summary-article-pos (&optional number)
2140 "Return the position of the line of article NUMBER."
2141 `(gnus-data-pos (gnus-data-find
2142 ,(or number '(gnus-summary-article-number)))))
2144 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2145 (defmacro gnus-summary-article-subject (&optional number)
2146 "Return current subject string or nil if nothing."
2149 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2150 '(gnus-data-header (assq (gnus-summary-article-number)
2151 gnus-newsgroup-data)))))
2154 (mail-header-subject headers))))
2156 (defmacro gnus-summary-article-score (&optional number)
2157 "Return current article score."
2158 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2159 gnus-newsgroup-scored))
2160 gnus-summary-default-score 0))
2162 (defun gnus-summary-article-children (&optional number)
2163 "Return a list of article numbers that are children of article NUMBER."
2164 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2165 (level (gnus-data-level (car data)))
2167 (while (and (setq data (cdr data))
2168 (> (setq l (gnus-data-level (car data))) level))
2169 (and (= (1+ level) l)
2170 (push (gnus-data-number (car data))
2172 (nreverse children)))
2174 (defun gnus-summary-article-parent (&optional number)
2175 "Return the article number of the parent of article NUMBER."
2176 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2177 (gnus-data-list t)))
2178 (level (gnus-data-level (car data))))
2180 () ; This is a root.
2181 ;; We search until we find an article with a level less than
2182 ;; this one. That function has to be the parent.
2183 (while (and (setq data (cdr data))
2184 (not (< (gnus-data-level (car data)) level))))
2185 (and data (gnus-data-number (car data))))))
2187 (defun gnus-unread-mark-p (mark)
2188 "Say whether MARK is the unread mark."
2189 (= mark gnus-unread-mark))
2191 (defun gnus-read-mark-p (mark)
2192 "Say whether MARK is one of the marks that mark as read.
2193 This is all marks except unread, ticked, dormant, and expirable."
2194 (not (or (= mark gnus-unread-mark)
2195 (= mark gnus-ticked-mark)
2196 (= mark gnus-dormant-mark)
2197 (= mark gnus-expirable-mark))))
2199 (defmacro gnus-article-mark (number)
2200 "Return the MARK of article NUMBER.
2201 This macro should only be used when computing the mark the \"first\"
2202 time; i.e., when generating the summary lines. After that,
2203 `gnus-summary-article-mark' should be used to examine the
2206 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2207 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2208 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2209 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2210 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2211 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2212 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2213 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2214 gnus-ancient-mark))))
2216 ;; Saving hidden threads.
2218 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2219 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2221 (defmacro gnus-save-hidden-threads (&rest forms)
2222 "Save hidden threads, eval FORMS, and restore the hidden threads."
2223 (let ((config (make-symbol "config")))
2224 `(let ((,config (gnus-hidden-threads-configuration)))
2228 (gnus-restore-hidden-threads-configuration ,config)))))
2230 (defun gnus-data-compute-positions ()
2231 "Compute the positions of all articles."
2232 (setq gnus-newsgroup-data-reverse nil)
2233 (let ((data gnus-newsgroup-data))
2235 (gnus-save-hidden-threads
2236 (gnus-summary-show-all-threads)
2237 (goto-char (point-min))
2239 (while (get-text-property (point) 'gnus-intangible)
2241 (gnus-data-set-pos (car data) (+ (point) 3))
2242 (setq data (cdr data))
2243 (forward-line 1))))))
2245 (defun gnus-hidden-threads-configuration ()
2246 "Return the current hidden threads configuration."
2249 (goto-char (point-min))
2250 (while (search-forward "\r" nil t)
2251 (push (1- (point)) config))
2254 (defun gnus-restore-hidden-threads-configuration (config)
2255 "Restore hidden threads configuration from CONFIG."
2256 (let (point buffer-read-only)
2257 (while (setq point (pop config))
2258 (when (and (< point (point-max))
2260 (= (following-char) ?\n))
2261 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2263 ;; Various summary mode internalish functions.
2265 (defun gnus-mouse-pick-article (e)
2268 (gnus-summary-next-page nil t))
2270 (defun gnus-summary-set-display-table ()
2271 ;; Change the display table. Odd characters have a tendency to mess
2272 ;; up nicely formatted displays - we make all possible glyphs
2273 ;; display only a single character.
2275 ;; We start from the standard display table, if any.
2276 (let ((table (or (copy-sequence standard-display-table)
2277 (make-display-table)))
2279 ;; Nix out all the control chars...
2280 (while (>= (setq i (1- i)) 0)
2281 (aset table i [??]))
2282 ;; ... but not newline and cr, of course. (cr is necessary for the
2283 ;; selective display).
2284 (aset table ?\n nil)
2285 (aset table ?\r nil)
2286 ;; We keep TAB as well.
2287 (aset table ?\t nil)
2288 ;; We nix out any glyphs over 126 that are not set already.
2290 (while (>= (setq i (1- i)) 127)
2291 ;; Only modify if the entry is nil.
2292 (unless (aref table i)
2293 (aset table i [??]))))
2294 (setq buffer-display-table table)))
2296 (defun gnus-summary-setup-buffer (group)
2297 "Initialize summary buffer."
2298 (let ((buffer (concat "*Summary " group "*")))
2299 (if (get-buffer buffer)
2302 (setq gnus-summary-buffer (current-buffer))
2303 (not gnus-newsgroup-prepared))
2304 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2305 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2306 (gnus-summary-mode group)
2308 (gnus-carpal-setup-buffer 'summary))
2309 (unless gnus-single-article-buffer
2310 (make-local-variable 'gnus-article-buffer)
2311 (make-local-variable 'gnus-article-current)
2312 (make-local-variable 'gnus-original-article-buffer))
2313 (setq gnus-newsgroup-name group)
2316 (defun gnus-set-global-variables ()
2317 ;; Set the global equivalents of the summary buffer-local variables
2318 ;; to the latest values they had. These reflect the summary buffer
2319 ;; that was in action when the last article was fetched.
2320 (when (eq major-mode 'gnus-summary-mode)
2321 (setq gnus-summary-buffer (current-buffer))
2322 (let ((name gnus-newsgroup-name)
2323 (marked gnus-newsgroup-marked)
2324 (unread gnus-newsgroup-unreads)
2325 (headers gnus-current-headers)
2326 (data gnus-newsgroup-data)
2327 (summary gnus-summary-buffer)
2328 (article-buffer gnus-article-buffer)
2329 (original gnus-original-article-buffer)
2330 (gac gnus-article-current)
2331 (reffed gnus-reffed-article-number)
2332 (score-file gnus-current-score-file))
2334 (set-buffer gnus-group-buffer)
2335 (setq gnus-newsgroup-name name
2336 gnus-newsgroup-marked marked
2337 gnus-newsgroup-unreads unread
2338 gnus-current-headers headers
2339 gnus-newsgroup-data data
2340 gnus-article-current gac
2341 gnus-summary-buffer summary
2342 gnus-article-buffer article-buffer
2343 gnus-original-article-buffer original
2344 gnus-reffed-article-number reffed
2345 gnus-current-score-file score-file)
2346 ;; The article buffer also has local variables.
2347 (when (gnus-buffer-live-p gnus-article-buffer)
2348 (set-buffer gnus-article-buffer)
2349 (setq gnus-summary-buffer summary))))))
2351 (defun gnus-summary-article-unread-p (article)
2352 "Say whether ARTICLE is unread or not."
2353 (memq article gnus-newsgroup-unreads))
2355 (defun gnus-summary-first-article-p (&optional article)
2356 "Return whether ARTICLE is the first article in the buffer."
2357 (if (not (setq article (or article (gnus-summary-article-number))))
2359 (eq article (caar gnus-newsgroup-data))))
2361 (defun gnus-summary-last-article-p (&optional article)
2362 "Return whether ARTICLE is the last article in the buffer."
2363 (if (not (setq article (or article (gnus-summary-article-number))))
2364 t ; All non-existent numbers are the last article. :-)
2365 (not (cdr (gnus-data-find-list article)))))
2367 (defun gnus-make-thread-indent-array ()
2369 (unless (and gnus-thread-indent-array
2370 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2371 (setq gnus-thread-indent-array (make-vector 201 "")
2372 gnus-thread-indent-array-level gnus-thread-indent-level)
2374 (aset gnus-thread-indent-array n
2375 (make-string (* n gnus-thread-indent-level) ? ))
2378 (defun gnus-update-summary-mark-positions ()
2379 "Compute where the summary marks are to go."
2381 (when (gnus-buffer-exists-p gnus-summary-buffer)
2382 (set-buffer gnus-summary-buffer))
2383 (let ((gnus-replied-mark 129)
2384 (gnus-score-below-mark 130)
2385 (gnus-score-over-mark 130)
2386 (gnus-download-mark 131)
2387 (spec gnus-summary-line-format-spec)
2390 (gnus-set-work-buffer)
2391 (let ((gnus-summary-line-format-spec spec)
2392 (gnus-newsgroup-downloadable '((0 . t))))
2393 (gnus-summary-insert-line
2394 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2395 (goto-char (point-min))
2396 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2398 (goto-char (point-min))
2399 (push (cons 'replied (and (search-forward "\201" nil t)
2402 (goto-char (point-min))
2403 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2405 (goto-char (point-min))
2406 (push (cons 'download
2407 (and (search-forward "\203" nil t) (- (point) 2)))
2409 (setq gnus-summary-mark-positions pos))))
2411 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2412 "Insert a dummy root in the summary buffer."
2414 (gnus-add-text-properties
2415 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2416 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2418 (defun gnus-summary-insert-line (gnus-tmp-header
2419 gnus-tmp-level gnus-tmp-current
2420 gnus-tmp-unread gnus-tmp-replied
2421 gnus-tmp-expirable gnus-tmp-subject-or-nil
2422 &optional gnus-tmp-dummy gnus-tmp-score
2424 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2425 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2426 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2427 (gnus-tmp-score-char
2428 (if (or (null gnus-summary-default-score)
2429 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2430 gnus-summary-zcore-fuzz))
2432 (if (< gnus-tmp-score gnus-summary-default-score)
2433 gnus-score-below-mark gnus-score-over-mark)))
2435 (cond (gnus-tmp-process gnus-process-mark)
2436 ((memq gnus-tmp-current gnus-newsgroup-cached)
2438 (gnus-tmp-replied gnus-replied-mark)
2439 ((memq gnus-tmp-current gnus-newsgroup-saved)
2441 (t gnus-unread-mark)))
2442 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2445 ((string-match "<[^>]+> *$" gnus-tmp-from)
2446 (let ((beg (match-beginning 0)))
2447 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2448 (substring gnus-tmp-from (1+ (match-beginning 0))
2449 (1- (match-end 0))))
2450 (substring gnus-tmp-from 0 beg))))
2451 ((string-match "(.+)" gnus-tmp-from)
2452 (substring gnus-tmp-from
2453 (1+ (match-beginning 0)) (1- (match-end 0))))
2455 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2456 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2457 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2458 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2459 (buffer-read-only nil))
2460 (when (string= gnus-tmp-name "")
2461 (setq gnus-tmp-name gnus-tmp-from))
2462 (unless (numberp gnus-tmp-lines)
2463 (setq gnus-tmp-lines 0))
2464 (gnus-put-text-property
2466 (progn (eval gnus-summary-line-format-spec) (point))
2467 'gnus-number gnus-tmp-number)
2468 (when (gnus-visual-p 'summary-highlight 'highlight)
2470 (gnus-run-hooks 'gnus-summary-update-hook)
2473 (defun gnus-summary-update-line (&optional dont-update)
2474 ;; Update summary line after change.
2475 (when (and gnus-summary-default-score
2476 (not gnus-summary-inhibit-highlight))
2477 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2478 (article (gnus-summary-article-number))
2479 (score (gnus-summary-article-score article)))
2481 (if (and gnus-summary-mark-below
2482 (< (gnus-summary-article-score)
2483 gnus-summary-mark-below))
2484 ;; This article has a low score, so we mark it as read.
2485 (when (memq article gnus-newsgroup-unreads)
2486 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2487 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2488 ;; This article was previously marked as read on account
2489 ;; of a low score, but now it has risen, so we mark it as
2491 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2492 (gnus-summary-update-mark
2493 (if (or (null gnus-summary-default-score)
2494 (<= (abs (- score gnus-summary-default-score))
2495 gnus-summary-zcore-fuzz))
2497 (if (< score gnus-summary-default-score)
2498 gnus-score-below-mark gnus-score-over-mark))
2500 ;; Do visual highlighting.
2501 (when (gnus-visual-p 'summary-highlight 'highlight)
2502 (gnus-run-hooks 'gnus-summary-update-hook)))))
2504 (defvar gnus-tmp-new-adopts nil)
2506 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2507 "Return the number of articles in THREAD.
2508 This may be 0 in some cases -- if none of the articles in
2509 the thread are to be displayed."
2511 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2513 ((not (listp thread))
2515 ((and (consp thread) (cdr thread))
2518 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2521 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2524 (when (and level (zerop level) gnus-tmp-new-adopts)
2527 'gnus-summary-number-of-articles-in-thread
2528 gnus-tmp-new-adopts))))
2530 (if (> number 1) gnus-not-empty-thread-mark
2531 gnus-empty-thread-mark)
2534 (defun gnus-summary-set-local-parameters (group)
2535 "Go through the local params of GROUP and set all variable specs in that list."
2536 (let ((params (gnus-group-find-parameter group))
2539 (setq elem (car params)
2540 params (cdr params))
2541 (and (consp elem) ; Has to be a cons.
2542 (consp (cdr elem)) ; The cdr has to be a list.
2543 (symbolp (car elem)) ; Has to be a symbol in there.
2544 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2545 (ignore-errors ; So we set it.
2546 (make-local-variable (car elem))
2547 (set (car elem) (eval (nth 1 elem))))))))
2549 (defun gnus-summary-read-group (group &optional show-all no-article
2550 kill-buffer no-display backward
2552 "Start reading news in newsgroup GROUP.
2553 If SHOW-ALL is non-nil, already read articles are also listed.
2554 If NO-ARTICLE is non-nil, no article is selected initially.
2555 If NO-DISPLAY, don't generate a summary buffer."
2559 (let ((gnus-auto-select-next nil))
2560 (or (gnus-summary-read-group-1
2561 group show-all no-article
2562 kill-buffer no-display
2565 select-articles nil)))))
2566 (eq gnus-auto-select-next 'quietly))
2567 (set-buffer gnus-group-buffer)
2568 ;; The entry function called above goes to the next
2569 ;; group automatically, so we go two groups back
2570 ;; if we are searching for the previous group.
2572 (gnus-group-prev-unread-group 2))
2573 (if (not (equal group (gnus-group-group-name)))
2574 (setq group (gnus-group-group-name))
2578 (defun gnus-summary-read-group-1 (group show-all no-article
2579 kill-buffer no-display
2580 &optional select-articles)
2581 ;; Killed foreign groups can't be entered.
2582 (when (and (not (gnus-group-native-p group))
2583 (not (gnus-gethash group gnus-newsrc-hashtb)))
2584 (error "Dead non-native groups can't be entered"))
2585 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2586 (let* ((new-group (gnus-summary-setup-buffer group))
2587 (quit-config (gnus-group-quit-config group))
2588 (did-select (and new-group (gnus-select-newsgroup
2589 group show-all select-articles))))
2591 ;; This summary buffer exists already, so we just select it.
2593 (gnus-set-global-variables)
2595 (gnus-kill-or-deaden-summary kill-buffer))
2596 (gnus-configure-windows 'summary 'force)
2597 (gnus-set-mode-line 'summary)
2598 (gnus-summary-position-point)
2601 ;; We couldn't select this group.
2603 (when (and (eq major-mode 'gnus-summary-mode)
2604 (not (equal (current-buffer) kill-buffer)))
2605 (kill-buffer (current-buffer))
2606 (if (not quit-config)
2608 ;; Update the info -- marks might need to be removed,
2610 (gnus-summary-update-info)
2611 (set-buffer gnus-group-buffer)
2612 (gnus-group-jump-to-group group)
2613 (gnus-group-next-unread-group 1))
2614 (gnus-handle-ephemeral-exit quit-config)))
2615 (gnus-message 3 "Can't select group")
2617 ;; The user did a `C-g' while prompting for number of articles,
2618 ;; so we exit this group.
2619 ((eq did-select 'quit)
2620 (and (eq major-mode 'gnus-summary-mode)
2621 (not (equal (current-buffer) kill-buffer))
2622 (kill-buffer (current-buffer)))
2624 (gnus-kill-or-deaden-summary kill-buffer))
2625 (if (not quit-config)
2627 (set-buffer gnus-group-buffer)
2628 (gnus-group-jump-to-group group)
2629 (gnus-group-next-unread-group 1)
2630 (gnus-configure-windows 'group 'force))
2631 (gnus-handle-ephemeral-exit quit-config))
2632 ;; Finally signal the quit.
2634 ;; The group was successfully selected.
2636 (gnus-set-global-variables)
2637 ;; Save the active value in effect when the group was entered.
2638 (setq gnus-newsgroup-active
2640 (gnus-active gnus-newsgroup-name)))
2641 ;; You can change the summary buffer in some way with this hook.
2642 (gnus-run-hooks 'gnus-select-group-hook)
2643 ;; Set any local variables in the group parameters.
2644 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2645 (gnus-update-format-specifications
2646 nil 'summary 'summary-mode 'summary-dummy)
2647 ;; Do score processing.
2648 (when gnus-use-scoring
2649 (gnus-possibly-score-headers))
2650 ;; Check whether to fill in the gaps in the threads.
2651 (when gnus-build-sparse-threads
2652 (gnus-build-sparse-threads))
2653 ;; Find the initial limit.
2654 (if gnus-show-threads
2656 (let ((gnus-newsgroup-dormant nil))
2657 (gnus-summary-initial-limit show-all))
2658 (gnus-summary-initial-limit show-all))
2659 (setq gnus-newsgroup-limit
2661 (lambda (header) (mail-header-number header))
2662 gnus-newsgroup-headers)))
2663 ;; Generate the summary buffer.
2665 (gnus-summary-prepare))
2666 (when gnus-use-trees
2667 (gnus-tree-open group)
2668 (setq gnus-summary-highlight-line-function
2669 'gnus-tree-highlight-article))
2670 ;; If the summary buffer is empty, but there are some low-scored
2671 ;; articles or some excluded dormants, we include these in the
2673 (when (and (zerop (buffer-size))
2675 (cond (gnus-newsgroup-dormant
2676 (gnus-summary-limit-include-dormant))
2677 ((and gnus-newsgroup-scored show-all)
2678 (gnus-summary-limit-include-expunged t))))
2679 ;; Function `gnus-apply-kill-file' must be called in this hook.
2680 (gnus-run-hooks 'gnus-apply-kill-hook)
2681 (if (and (zerop (buffer-size))
2684 ;; This newsgroup is empty.
2685 (gnus-summary-catchup-and-exit nil t)
2686 (gnus-message 6 "No unread news")
2688 (gnus-kill-or-deaden-summary kill-buffer))
2689 ;; Return nil from this function.
2691 ;; Hide conversation thread subtrees. We cannot do this in
2692 ;; gnus-summary-prepare-hook since kill processing may not
2693 ;; work with hidden articles.
2694 (and gnus-show-threads
2695 gnus-thread-hide-subtree
2696 (gnus-summary-hide-all-threads))
2698 (gnus-kill-or-deaden-summary kill-buffer))
2699 ;; Show first unread article if requested.
2700 (if (and (not no-article)
2702 gnus-newsgroup-unreads
2703 gnus-auto-select-first)
2704 (unless (if (eq gnus-auto-select-first 'best)
2705 (gnus-summary-best-unread-article)
2706 (gnus-summary-first-unread-article))
2707 (gnus-configure-windows 'summary))
2708 ;; Don't select any articles, just move point to the first
2709 ;; article in the group.
2710 (goto-char (point-min))
2711 (gnus-summary-position-point)
2712 (gnus-configure-windows 'summary 'force)
2713 (gnus-set-mode-line 'summary))
2714 (when (get-buffer-window gnus-group-buffer t)
2715 ;; Gotta use windows, because recenter does weird stuff if
2716 ;; the current buffer ain't the displayed window.
2717 (let ((owin (selected-window)))
2718 (select-window (get-buffer-window gnus-group-buffer t))
2719 (when (gnus-group-goto-group group)
2721 (select-window owin)))
2722 ;; Mark this buffer as "prepared".
2723 (setq gnus-newsgroup-prepared t)
2724 (gnus-run-hooks 'gnus-summary-prepared-hook)
2727 (defun gnus-summary-prepare ()
2728 "Generate the summary buffer."
2730 (let ((buffer-read-only nil))
2732 (setq gnus-newsgroup-data nil
2733 gnus-newsgroup-data-reverse nil)
2734 (gnus-run-hooks 'gnus-summary-generate-hook)
2735 ;; Generate the buffer, either with threads or without.
2736 (when gnus-newsgroup-headers
2737 (gnus-summary-prepare-threads
2738 (if gnus-show-threads
2739 (gnus-sort-gathered-threads
2740 (funcall gnus-summary-thread-gathering-function
2742 (gnus-cut-threads (gnus-make-threads)))))
2743 ;; Unthreaded display.
2744 (gnus-sort-articles gnus-newsgroup-headers))))
2745 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2746 ;; Call hooks for modifying summary buffer.
2747 (goto-char (point-min))
2748 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2750 (defsubst gnus-general-simplify-subject (subject)
2751 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2754 ;; Truncate the subject.
2755 (gnus-simplify-subject-functions
2756 (gnus-map-function gnus-simplify-subject-functions subject))
2757 ((numberp gnus-summary-gather-subject-limit)
2758 (setq subject (gnus-simplify-subject-re subject))
2759 (if (> (length subject) gnus-summary-gather-subject-limit)
2760 (substring subject 0 gnus-summary-gather-subject-limit)
2762 ;; Fuzzily simplify it.
2763 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2764 (gnus-simplify-subject-fuzzy subject))
2765 ;; Just remove the leading "Re:".
2767 (gnus-simplify-subject-re subject))))
2769 (if (and gnus-summary-gather-exclude-subject
2770 (string-match gnus-summary-gather-exclude-subject subject))
2771 nil ; This article shouldn't be gathered
2774 (defun gnus-summary-simplify-subject-query ()
2775 "Query where the respool algorithm would put this article."
2777 (gnus-summary-select-article)
2778 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2780 (defun gnus-gather-threads-by-subject (threads)
2781 "Gather threads by looking at Subject headers."
2782 (if (not gnus-summary-make-false-root)
2784 (let ((hashtb (gnus-make-hashtable 1024))
2787 subject hthread whole-subject)
2789 (setq subject (gnus-general-simplify-subject
2790 (setq whole-subject (mail-header-subject
2793 (if (setq hthread (gnus-gethash subject hashtb))
2795 ;; We enter a dummy root into the thread, if we
2796 ;; haven't done that already.
2797 (unless (stringp (caar hthread))
2798 (setcar hthread (list whole-subject (car hthread))))
2799 ;; We add this new gathered thread to this gathered
2801 (setcdr (car hthread)
2802 (nconc (cdar hthread) (list (car threads))))
2803 ;; Remove it from the list of threads.
2804 (setcdr prev (cdr threads))
2805 (setq threads prev))
2806 ;; Enter this thread into the hash table.
2807 (gnus-sethash subject threads hashtb)))
2809 (setq threads (cdr threads)))
2812 (defun gnus-gather-threads-by-references (threads)
2813 "Gather threads by looking at References headers."
2814 (let ((idhashtb (gnus-make-hashtable 1024))
2815 (thhashtb (gnus-make-hashtable 1024))
2818 ids references id gthread gid entered ref)
2820 (when (setq references (mail-header-references (caar threads)))
2821 (setq id (mail-header-id (caar threads))
2822 ids (gnus-split-references references)
2824 (while (setq ref (pop ids))
2825 (setq ids (delete ref ids))
2826 (if (not (setq gid (gnus-gethash ref idhashtb)))
2828 (gnus-sethash ref id idhashtb)
2829 (gnus-sethash id threads thhashtb))
2830 (setq gthread (gnus-gethash gid thhashtb))
2832 ;; We enter a dummy root into the thread, if we
2833 ;; haven't done that already.
2834 (unless (stringp (caar gthread))
2835 (setcar gthread (list (mail-header-subject (caar gthread))
2837 ;; We add this new gathered thread to this gathered
2839 (setcdr (car gthread)
2840 (nconc (cdar gthread) (list (car threads)))))
2841 ;; Add it into the thread hash table.
2842 (gnus-sethash id gthread thhashtb)
2844 ;; Remove it from the list of threads.
2845 (setcdr prev (cdr threads))
2846 (setq threads prev))))
2848 (setq threads (cdr threads)))
2851 (defun gnus-sort-gathered-threads (threads)
2852 "Sort subtreads inside each gathered thread by article number."
2853 (let ((result threads))
2855 (when (stringp (caar threads))
2856 (setcdr (car threads)
2857 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2858 (setq threads (cdr threads)))
2861 (defun gnus-thread-loop-p (root thread)
2862 "Say whether ROOT is in THREAD."
2863 (let ((stack (list thread))
2866 (while (setq thread (pop stack))
2867 (setq th (cdr thread))
2869 (not (eq (caar th) root)))
2872 ;; We have found a loop.
2874 (setcdr thread (delq (car th) (cdr thread)))
2875 (if (boundp (setq ref-dep (intern "none"
2876 gnus-newsgroup-dependencies)))
2877 (setcdr (symbol-value ref-dep)
2878 (nconc (cdr (symbol-value ref-dep))
2880 (set ref-dep (list nil (car th))))
2883 ;; Push all the subthreads onto the stack.
2884 (push (cdr thread) stack)))
2887 (defun gnus-make-threads ()
2888 "Go through the dependency hashtb and find the roots. Return all threads."
2890 (while (catch 'infloop
2893 ;; Deal with self-referencing References loops.
2894 (when (and (car (symbol-value refs))
2901 (car (symbol-value refs)) thread))
2902 (cdr (symbol-value refs)))))))
2905 (unless (car (symbol-value refs))
2906 ;; These threads do not refer back to any other articles,
2907 ;; so they're roots.
2908 (setq threads (append (cdr (symbol-value refs)) threads))))
2909 gnus-newsgroup-dependencies)))
2912 ;; Build the thread tree.
2913 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2914 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2916 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2917 if it was already present.
2919 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2920 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2921 Message-IDs will be renamed be renamed to a unique Message-ID before
2924 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2925 (let* ((id (mail-header-id header))
2926 (id-dep (and id (intern id dependencies)))
2927 ref ref-dep ref-header)
2928 ;; Enter this `header' in the `dependencies' table.
2932 ;; The first two cases do the normal part: enter a new `header'
2933 ;; in the `dependencies' table.
2934 ((not (boundp id-dep))
2935 (set id-dep (list header)))
2936 ((null (car (symbol-value id-dep)))
2937 (setcar (symbol-value id-dep) header))
2939 ;; From here the `header' was already present in the
2940 ;; `dependencies' table.
2942 ;; Overrides an existing entry;
2943 ;; just set the header part of the entry.
2944 (setcar (symbol-value id-dep) header))
2946 ;; Renames the existing `header' to a unique Message-ID.
2947 ((not gnus-summary-ignore-duplicates)
2948 ;; An article with this Message-ID has already been seen.
2949 ;; We rename the Message-ID.
2950 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2952 (mail-header-set-id header id))
2954 ;; The last case ignores an existing entry, except it adds any
2955 ;; additional Xrefs (in case the two articles came from different
2957 ;; Also sets `header' to `nil' meaning that the `dependencies'
2958 ;; table was *not* modified.
2960 (mail-header-set-xref
2961 (car (symbol-value id-dep))
2962 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2964 (or (mail-header-xref header) "")))
2968 ;; First check if that we are not creating a References loop.
2969 (setq ref (gnus-parent-id (mail-header-references header)))
2971 (setq ref-dep (intern-soft ref dependencies))
2973 (setq ref-header (car (symbol-value ref-dep))))
2974 (if (string= id ref)
2975 ;; Yuk! This is a reference loop. Make the article be a
2978 (mail-header-set-references (car (symbol-value id-dep)) "none")
2980 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2981 (setq ref (gnus-parent-id (mail-header-references header)))
2982 (setq ref-dep (intern (or ref "none") dependencies))
2983 (if (boundp ref-dep)
2984 (setcdr (symbol-value ref-dep)
2985 (nconc (cdr (symbol-value ref-dep))
2986 (list (symbol-value id-dep))))
2987 (set ref-dep (list nil (symbol-value id-dep)))))
2990 (defun gnus-build-sparse-threads ()
2991 (let ((headers gnus-newsgroup-headers)
2992 (gnus-summary-ignore-duplicates t)
2993 header references generation relations
2994 subject child end new-child date)
2995 ;; First we create an alist of generations/relations, where
2996 ;; generations is how much we trust the relation, and the relation
2998 (gnus-message 7 "Making sparse threads...")
3000 (nnheader-set-temp-buffer " *gnus sparse threads*")
3001 (while (setq header (pop headers))
3002 (when (and (setq references (mail-header-references header))
3003 (not (string= references "")))
3005 (setq child (mail-header-id header)
3006 subject (mail-header-subject header)
3007 date (mail-header-date header)
3009 (while (search-backward ">" nil t)
3010 (setq end (1+ (point)))
3011 (when (search-backward "<" nil t)
3012 (setq new-child (buffer-substring (point) end))
3013 (push (list (incf generation)
3014 child (setq child new-child)
3018 (push (list (1+ generation) child nil subject) relations))
3020 (kill-buffer (current-buffer)))
3021 ;; Sort over trustworthiness.
3024 (when (gnus-dependencies-add-header
3025 (make-full-mail-header
3026 gnus-reffed-article-number
3027 (nth 3 relation) "" (or (nth 4 relation) "")
3029 (or (nth 2 relation) "") 0 0 "")
3030 gnus-newsgroup-dependencies nil)
3031 (push gnus-reffed-article-number gnus-newsgroup-limit)
3032 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3033 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3034 gnus-newsgroup-reads)
3035 (decf gnus-reffed-article-number)))
3036 (sort relations 'car-less-than-car))
3037 (gnus-message 7 "Making sparse threads...done")))
3039 (defun gnus-build-old-threads ()
3040 ;; Look at all the articles that refer back to old articles, and
3041 ;; fetch the headers for the articles that aren't there. This will
3042 ;; build complete threads - if the roots haven't been expired by the
3047 (when (not (car (symbol-value refs)))
3048 (setq heads (cdr (symbol-value refs)))
3050 (if (memq (mail-header-number (caar heads))
3051 gnus-newsgroup-dormant)
3052 (setq heads (cdr heads))
3053 (setq id (symbol-name refs))
3054 (while (and (setq id (gnus-build-get-header id))
3055 (not (car (gnus-id-to-thread id)))))
3056 (setq heads nil)))))
3057 gnus-newsgroup-dependencies)))
3059 ;; The following macros and functions were written by Felix Lee
3060 ;; <flee@cse.psu.edu>.
3062 (defmacro gnus-nov-read-integer ()
3064 (if (= (following-char) ?\t)
3066 (let ((num (ignore-errors (read buffer))))
3067 (if (numberp num) num 0)))
3069 (search-forward "\t" eol 'move))))
3071 (defmacro gnus-nov-skip-field ()
3072 '(search-forward "\t" eol 'move))
3074 (defmacro gnus-nov-field ()
3075 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3077 ;; This function has to be called with point after the article number
3078 ;; on the beginning of the line.
3079 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3080 (let ((eol (gnus-point-at-eol))
3081 (buffer (current-buffer))
3082 header rawtext decoded)
3084 ;; overview: [num subject from date id refs chars lines misc]
3087 (narrow-to-region (point) eol)
3092 (make-full-mail-header
3095 (setq rawtext (gnus-nov-field) ; subject
3097 gnus-unstructured-field-decoder rawtext))
3098 (if (string= rawtext decoded)
3100 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
3103 (setq rawtext (gnus-nov-field) ; from
3105 gnus-structured-field-decoder rawtext))
3106 (if (string= rawtext decoded)
3108 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
3110 (gnus-nov-field) ; date
3111 (or (gnus-nov-field)
3112 (nnheader-generate-fake-message-id)) ; id
3113 (gnus-nov-field) ; refs
3114 (gnus-nov-read-integer) ; chars
3115 (gnus-nov-read-integer) ; lines
3116 (unless (= (following-char) ?\n)
3117 (gnus-nov-field))))) ; misc
3121 (when gnus-alter-header-function
3122 (funcall gnus-alter-header-function header))
3123 (gnus-dependencies-add-header header dependencies force-new)))
3125 (defun gnus-build-get-header (id)
3126 ;; Look through the buffer of NOV lines and find the header to
3127 ;; ID. Enter this line into the dependencies hash table, and return
3128 ;; the id of the parent article (if any).
3129 (let ((deps gnus-newsgroup-dependencies)
3133 (set-buffer nntp-server-buffer)
3134 (let ((case-fold-search nil))
3135 (goto-char (point-min))
3136 (while (and (not found)
3137 (search-forward id nil t))
3139 (setq found (looking-at
3140 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3141 (regexp-quote id))))
3142 (or found (beginning-of-line 2)))
3146 (setq header (gnus-nov-parse-line
3147 (read (current-buffer)) deps))
3148 (gnus-parent-id (mail-header-references header))))))
3150 (let ((number (mail-header-number header)))
3151 (push number gnus-newsgroup-limit)
3152 (push header gnus-newsgroup-headers)
3153 (if (memq number gnus-newsgroup-unselected)
3155 (push number gnus-newsgroup-unreads)
3156 (setq gnus-newsgroup-unselected
3157 (delq number gnus-newsgroup-unselected)))
3158 (push number gnus-newsgroup-ancient)))))))
3160 (defun gnus-build-all-threads ()
3161 "Read all the headers."
3162 (let ((gnus-summary-ignore-duplicates t)
3163 (dependencies gnus-newsgroup-dependencies)
3166 (set-buffer nntp-server-buffer)
3167 (let ((case-fold-search nil))
3168 (goto-char (point-min))
3171 (setq article (read (current-buffer))
3172 header (gnus-nov-parse-line
3173 article dependencies)))
3176 (set-buffer gnus-summary-buffer)
3177 (push header gnus-newsgroup-headers)
3178 (if (memq (setq article (mail-header-number header))
3179 gnus-newsgroup-unselected)
3181 (push article gnus-newsgroup-unreads)
3182 (setq gnus-newsgroup-unselected
3183 (delq article gnus-newsgroup-unselected)))
3184 (push article gnus-newsgroup-ancient)))
3185 (forward-line 1)))))))
3187 (defun gnus-summary-update-article-line (article header)
3188 "Update the line for ARTICLE using HEADERS."
3189 (let* ((id (mail-header-id header))
3190 (thread (gnus-id-to-thread id)))
3192 (error "Article in no thread"))
3193 ;; Update the thread.
3194 (setcar thread header)
3195 (gnus-summary-goto-subject article)
3196 (let* ((datal (gnus-data-find-list article))
3198 (length (when (cdr datal)
3199 (- (gnus-data-pos data)
3200 (gnus-data-pos (cadr datal)))))
3201 (buffer-read-only nil)
3202 (level (gnus-summary-thread-level)))
3204 (gnus-summary-insert-line
3205 header level nil (gnus-article-mark article)
3206 (memq article gnus-newsgroup-replied)
3207 (memq article gnus-newsgroup-expirable)
3208 ;; Only insert the Subject string when it's different
3209 ;; from the previous Subject string.
3210 (if (gnus-subject-equal
3212 (mail-header-subject
3215 (gnus-data-find-list
3217 (gnus-data-list t)))))
3218 ;; Error on the side of excessive subjects.
3220 (mail-header-subject header))
3222 (mail-header-subject header))
3223 nil (cdr (assq article gnus-newsgroup-scored))
3224 (memq article gnus-newsgroup-processable))
3226 (gnus-data-update-list
3227 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3229 (defun gnus-summary-update-article (article &optional iheader)
3230 "Update ARTICLE in the summary buffer."
3231 (set-buffer gnus-summary-buffer)
3232 (let* ((header (gnus-summary-article-header article))
3233 (id (mail-header-id header))
3234 (data (gnus-data-find article))
3235 (thread (gnus-id-to-thread id))
3236 (references (mail-header-references header))
3240 (when (and references
3241 (not (equal "" references)))
3244 (buffer-read-only nil)
3250 (delq thread parent)))
3251 (if (gnus-summary-insert-subject id header)
3252 ;; Set the (possibly) new article number in the data structure.
3253 (gnus-data-set-number data (gnus-id-to-article id))
3257 (defun gnus-rebuild-thread (id &optional line)
3258 "Rebuild the thread containing ID.
3259 If LINE, insert the rebuilt thread starting on line LINE."
3260 (let ((buffer-read-only nil)
3261 old-pos current thread data)
3262 (if (not gnus-show-threads)
3263 (setq thread (list (car (gnus-id-to-thread id))))
3264 ;; Get the thread this article is part of.
3265 (setq thread (gnus-remove-thread id)))
3266 (setq old-pos (gnus-point-at-bol))
3267 (setq current (save-excursion
3268 (and (zerop (forward-line -1))
3269 (gnus-summary-article-number))))
3270 ;; If this is a gathered thread, we have to go some re-gathering.
3271 (when (stringp (car thread))
3272 (let ((subject (car thread))
3274 (setq thread (cdr thread))
3276 (unless (memq (setq thr (gnus-id-to-thread
3278 (mail-header-id (caar thread)))))
3281 (setq thread (cdr thread)))
3282 ;; We now have all (unique) roots.
3283 (if (= (length roots) 1)
3284 ;; All the loose roots are now one solid root.
3285 (setq thread (car roots))
3286 (setq thread (cons subject (gnus-sort-threads roots))))))
3288 ;; We then insert this thread into the summary buffer.
3290 (goto-char (point-min))
3291 (forward-line (1- line)))
3292 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3293 (if gnus-show-threads
3294 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3295 (gnus-summary-prepare-unthreaded thread))
3296 (setq data (nreverse gnus-newsgroup-data))
3297 (setq threads gnus-newsgroup-threads))
3298 ;; We splice the new data into the data structure.
3299 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3300 ;;!!! then we want to insert at the beginning of the buffer.
3301 ;;!!! That happens to be true with Gnus now, but that may
3302 ;;!!! change in the future. Perhaps.
3303 (gnus-data-enter-list
3304 (if line nil current) data (- (point) old-pos))
3305 (setq gnus-newsgroup-threads
3306 (nconc threads gnus-newsgroup-threads))
3307 (gnus-data-compute-positions))))
3309 (defun gnus-number-to-header (number)
3310 "Return the header for article NUMBER."
3311 (let ((headers gnus-newsgroup-headers))
3313 (not (= number (mail-header-number (car headers)))))
3318 (defun gnus-parent-headers (in-headers &optional generation)
3319 "Return the headers of the GENERATIONeth parent of HEADERS."
3321 (setq generation 1))
3323 (headers in-headers)
3326 (not (zerop generation))
3327 (setq references (mail-header-references headers)))
3328 (setq headers (if (and references
3329 (setq parent (gnus-parent-id references)))
3330 (car (gnus-id-to-thread parent))
3333 (and (not (eq headers in-headers))
3336 (defun gnus-id-to-thread (id)
3337 "Return the (sub-)thread where ID appears."
3338 (gnus-gethash id gnus-newsgroup-dependencies))
3340 (defun gnus-id-to-article (id)
3341 "Return the article number of ID."
3342 (let ((thread (gnus-id-to-thread id)))
3345 (mail-header-number (car thread)))))
3347 (defun gnus-id-to-header (id)
3348 "Return the article headers of ID."
3349 (car (gnus-id-to-thread id)))
3351 (defun gnus-article-displayed-root-p (article)
3352 "Say whether ARTICLE is a root(ish) article."
3353 (let ((level (gnus-summary-thread-level article))
3354 (refs (mail-header-references (gnus-summary-article-header article)))
3360 ((null (gnus-parent-id refs)) t)
3362 (null (setq particle (gnus-id-to-article
3363 (gnus-parent-id refs))))
3364 (null (gnus-summary-thread-level particle)))))))
3366 (defun gnus-root-id (id)
3367 "Return the id of the root of the thread where ID appears."
3369 (while (and id (setq prev (car (gnus-id-to-thread id))))
3371 id (gnus-parent-id (mail-header-references prev))))
3374 (defun gnus-articles-in-thread (thread)
3375 "Return the list of articles in THREAD."
3376 (cons (mail-header-number (car thread))
3377 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3379 (defun gnus-remove-thread (id &optional dont-remove)
3380 "Remove the thread that has ID in it."
3381 (let (headers thread last-id)
3382 ;; First go up in this thread until we find the root.
3383 (setq last-id (gnus-root-id id)
3384 headers (message-flatten-list (gnus-id-to-thread last-id)))
3385 ;; We have now found the real root of this thread. It might have
3386 ;; been gathered into some loose thread, so we have to search
3387 ;; through the threads to find the thread we wanted.
3388 (let ((threads gnus-newsgroup-threads)
3391 (setq sub (car threads))
3392 (if (stringp (car sub))
3393 ;; This is a gathered thread, so we look at the roots
3394 ;; below it to find whether this article is in this
3397 (setq sub (cdr sub))
3399 (when (member (caar sub) headers)
3400 (setq thread (car threads)
3403 (setq sub (cdr sub))))
3404 ;; It's an ordinary thread, so we check it.
3405 (when (eq (car sub) (car headers))
3408 (setq threads (cdr threads)))
3409 ;; If this article is in no thread, then it's a root.
3412 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3413 (setq thread (gnus-id-to-thread last-id)))
3416 thread ; We return this thread.
3418 (if (stringp (car thread))
3420 ;; If we use dummy roots, then we have to remove the
3421 ;; dummy root as well.
3422 (when (eq gnus-summary-make-false-root 'dummy)
3423 ;; We go to the dummy root by going to
3424 ;; the first sub-"thread", and then one line up.
3425 (gnus-summary-goto-article
3426 (mail-header-number (caadr thread)))
3429 (gnus-data-compute-positions))
3430 (setq thread (cdr thread))
3432 (gnus-remove-thread-1 (car thread))
3433 (setq thread (cdr thread))))
3434 (gnus-summary-show-all-threads)
3435 (gnus-remove-thread-1 thread))))))))
3437 (defun gnus-remove-thread-1 (thread)
3438 "Remove the thread THREAD recursively."
3439 (let ((number (mail-header-number (pop thread)))
3441 (setq thread (reverse thread))
3443 (gnus-remove-thread-1 (pop thread)))
3444 (when (setq d (gnus-data-find number))
3445 (goto-char (gnus-data-pos d))
3448 (- (gnus-point-at-bol)
3450 (1+ (gnus-point-at-eol))
3451 (gnus-delete-line)))))))
3453 (defun gnus-sort-threads (threads)
3455 (if (not gnus-thread-sort-functions)
3457 (gnus-message 8 "Sorting threads...")
3459 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3460 (gnus-message 8 "Sorting threads...done"))))
3462 (defun gnus-sort-articles (articles)
3464 (when gnus-article-sort-functions
3465 (gnus-message 7 "Sorting articles...")
3467 (setq gnus-newsgroup-headers
3468 (sort articles (gnus-make-sort-function
3469 gnus-article-sort-functions)))
3470 (gnus-message 7 "Sorting articles...done"))))
3472 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3473 (defmacro gnus-thread-header (thread)
3474 ;; Return header of first article in THREAD.
3475 ;; Note that THREAD must never, ever be anything else than a variable -
3476 ;; using some other form will lead to serious barfage.
3477 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3478 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3479 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3482 (defsubst gnus-article-sort-by-number (h1 h2)
3483 "Sort articles by article number."
3484 (< (mail-header-number h1)
3485 (mail-header-number h2)))
3487 (defun gnus-thread-sort-by-number (h1 h2)
3488 "Sort threads by root article number."
3489 (gnus-article-sort-by-number
3490 (gnus-thread-header h1) (gnus-thread-header h2)))
3492 (defsubst gnus-article-sort-by-lines (h1 h2)
3493 "Sort articles by article Lines header."
3494 (< (mail-header-lines h1)
3495 (mail-header-lines h2)))
3497 (defun gnus-thread-sort-by-lines (h1 h2)
3498 "Sort threads by root article Lines header."
3499 (gnus-article-sort-by-lines
3500 (gnus-thread-header h1) (gnus-thread-header h2)))
3502 (defsubst gnus-article-sort-by-author (h1 h2)
3503 "Sort articles by root author."
3505 (let ((extract (funcall
3506 gnus-extract-address-components
3507 (mail-header-from h1))))
3508 (or (car extract) (cadr extract) ""))
3509 (let ((extract (funcall
3510 gnus-extract-address-components
3511 (mail-header-from h2))))
3512 (or (car extract) (cadr extract) ""))))
3514 (defun gnus-thread-sort-by-author (h1 h2)
3515 "Sort threads by root author."
3516 (gnus-article-sort-by-author
3517 (gnus-thread-header h1) (gnus-thread-header h2)))
3519 (defsubst gnus-article-sort-by-subject (h1 h2)
3520 "Sort articles by root subject."
3522 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3523 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3525 (defun gnus-thread-sort-by-subject (h1 h2)
3526 "Sort threads by root subject."
3527 (gnus-article-sort-by-subject
3528 (gnus-thread-header h1) (gnus-thread-header h2)))
3530 (defsubst gnus-article-sort-by-date (h1 h2)
3531 "Sort articles by root article date."
3533 (gnus-date-get-time (mail-header-date h1))
3534 (gnus-date-get-time (mail-header-date h2))))
3536 (defun gnus-thread-sort-by-date (h1 h2)
3537 "Sort threads by root article date."
3538 (gnus-article-sort-by-date
3539 (gnus-thread-header h1) (gnus-thread-header h2)))
3541 (defsubst gnus-article-sort-by-score (h1 h2)
3542 "Sort articles by root article score.
3543 Unscored articles will be counted as having a score of zero."
3544 (> (or (cdr (assq (mail-header-number h1)
3545 gnus-newsgroup-scored))
3546 gnus-summary-default-score 0)
3547 (or (cdr (assq (mail-header-number h2)
3548 gnus-newsgroup-scored))
3549 gnus-summary-default-score 0)))
3551 (defun gnus-thread-sort-by-score (h1 h2)
3552 "Sort threads by root article score."
3553 (gnus-article-sort-by-score
3554 (gnus-thread-header h1) (gnus-thread-header h2)))
3556 (defun gnus-thread-sort-by-total-score (h1 h2)
3557 "Sort threads by the sum of all scores in the thread.
3558 Unscored articles will be counted as having a score of zero."
3559 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3561 (defun gnus-thread-total-score (thread)
3562 ;; This function find the total score of THREAD.
3563 (cond ((null thread)
3566 (if (stringp (car thread))
3567 (apply gnus-thread-score-function 0
3568 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3569 (gnus-thread-total-score-1 thread)))
3571 (gnus-thread-total-score-1 (list thread)))))
3573 (defun gnus-thread-total-score-1 (root)
3574 ;; This function find the total score of the thread below ROOT.
3575 (setq root (car root))
3576 (apply gnus-thread-score-function
3578 (mapcar 'gnus-thread-total-score
3579 (cdr (gnus-id-to-thread (mail-header-id root))))
3580 (when (> (mail-header-number root) 0)
3581 (list (or (cdr (assq (mail-header-number root)
3582 gnus-newsgroup-scored))
3583 gnus-summary-default-score 0))))
3584 (list gnus-summary-default-score)
3587 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3588 (defvar gnus-tmp-prev-subject nil)
3589 (defvar gnus-tmp-false-parent nil)
3590 (defvar gnus-tmp-root-expunged nil)
3591 (defvar gnus-tmp-dummy-line nil)
3593 (defun gnus-summary-prepare-threads (threads)
3594 "Prepare summary buffer from THREADS and indentation LEVEL.
3595 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3596 or a straight list of headers."
3597 (gnus-message 7 "Generating summary...")
3599 (setq gnus-newsgroup-threads threads)
3602 (let ((gnus-tmp-level 0)
3603 (default-score (or gnus-summary-default-score 0))
3604 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3605 thread number subject stack state gnus-tmp-gathered beg-match
3606 new-roots gnus-tmp-new-adopts thread-end
3607 gnus-tmp-header gnus-tmp-unread
3608 gnus-tmp-replied gnus-tmp-subject-or-nil
3609 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3610 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3611 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3613 (setq gnus-tmp-prev-subject nil)
3615 (if (vectorp (car threads))
3616 ;; If this is a straight (sic) list of headers, then a
3617 ;; threaded summary display isn't required, so we just create
3618 ;; an unthreaded one.
3619 (gnus-summary-prepare-unthreaded threads)
3621 ;; Do the threaded display.
3623 (while (or threads stack gnus-tmp-new-adopts new-roots)
3625 (if (and (= gnus-tmp-level 0)
3628 (not gnus-tmp-false-parent)
3629 (or gnus-tmp-new-adopts new-roots))
3630 (if gnus-tmp-new-adopts
3631 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3632 thread (list (car gnus-tmp-new-adopts))
3633 gnus-tmp-header (caar thread)
3634 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3636 (setq thread (list (car new-roots))
3637 gnus-tmp-header (caar thread)
3638 new-roots (cdr new-roots))))
3641 ;; If there are some threads, we do them before the
3642 ;; threads on the stack.
3643 (setq thread threads
3644 gnus-tmp-header (caar thread))
3645 ;; There were no current threads, so we pop something off
3647 (setq state (car stack)
3648 gnus-tmp-level (car state)
3651 gnus-tmp-header (caar thread))))
3653 (setq gnus-tmp-false-parent nil)
3654 (setq gnus-tmp-root-expunged nil)
3655 (setq thread-end nil)
3657 (if (stringp gnus-tmp-header)
3658 ;; The header is a dummy root.
3660 ((eq gnus-summary-make-false-root 'adopt)
3661 ;; We let the first article adopt the rest.
3662 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3664 (setq gnus-tmp-gathered
3666 (lambda (h) (mail-header-number (car h)))
3669 (setq thread (cons (list (caar thread)
3672 (setq gnus-tmp-level -1
3673 gnus-tmp-false-parent t))
3674 ((eq gnus-summary-make-false-root 'empty)
3675 ;; We print adopted articles with empty subject fields.
3676 (setq gnus-tmp-gathered
3678 (lambda (h) (mail-header-number (car h)))
3681 (setq gnus-tmp-level -1))
3682 ((eq gnus-summary-make-false-root 'dummy)
3683 ;; We remember that we probably want to output a dummy
3685 (setq gnus-tmp-dummy-line gnus-tmp-header)
3686 (setq gnus-tmp-prev-subject gnus-tmp-header))
3688 ;; We do not make a root for the gathered
3689 ;; sub-threads at all.
3690 (setq gnus-tmp-level -1)))
3692 (setq number (mail-header-number gnus-tmp-header)
3693 subject (mail-header-subject gnus-tmp-header))
3696 ;; If the thread has changed subject, we might want to make
3697 ;; this subthread into a root.
3698 ((and (null gnus-thread-ignore-subject)
3699 (not (zerop gnus-tmp-level))
3700 gnus-tmp-prev-subject
3702 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3703 (setq new-roots (nconc new-roots (list (car thread)))
3705 gnus-tmp-header nil))
3706 ;; If the article lies outside the current limit,
3707 ;; then we do not display it.
3708 ((not (memq number gnus-newsgroup-limit))
3709 (setq gnus-tmp-gathered
3711 (lambda (h) (mail-header-number (car h)))
3714 (setq gnus-tmp-new-adopts (if (cdar thread)
3715 (append gnus-tmp-new-adopts
3717 gnus-tmp-new-adopts)
3719 gnus-tmp-header nil)
3720 (when (zerop gnus-tmp-level)
3721 (setq gnus-tmp-root-expunged t)))
3722 ;; Perhaps this article is to be marked as read?
3723 ((and gnus-summary-mark-below
3724 (< (or (cdr (assq number gnus-newsgroup-scored))
3726 gnus-summary-mark-below)
3727 ;; Don't touch sparse articles.
3728 (not (gnus-summary-article-sparse-p number))
3729 (not (gnus-summary-article-ancient-p number)))
3730 (setq gnus-newsgroup-unreads
3731 (delq number gnus-newsgroup-unreads))
3732 (if gnus-newsgroup-auto-expire
3733 (push number gnus-newsgroup-expirable)
3734 (push (cons number gnus-low-score-mark)
3735 gnus-newsgroup-reads))))
3737 (when gnus-tmp-header
3738 ;; We may have an old dummy line to output before this
3740 (when (and gnus-tmp-dummy-line
3743 (mail-header-subject gnus-tmp-header)))
3744 (gnus-summary-insert-dummy-line
3745 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3746 (setq gnus-tmp-dummy-line nil))
3748 ;; Compute the mark.
3749 (setq gnus-tmp-unread (gnus-article-mark number))
3751 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3752 gnus-tmp-header gnus-tmp-level)
3753 gnus-newsgroup-data)
3755 ;; Actually insert the line.
3757 gnus-tmp-subject-or-nil
3759 ((and gnus-thread-ignore-subject
3760 gnus-tmp-prev-subject
3761 (not (inline (gnus-subject-equal
3762 gnus-tmp-prev-subject subject))))
3764 ((zerop gnus-tmp-level)
3765 (if (and (eq gnus-summary-make-false-root 'empty)
3766 (memq number gnus-tmp-gathered)
3767 gnus-tmp-prev-subject
3768 (inline (gnus-subject-equal
3769 gnus-tmp-prev-subject subject)))
3770 gnus-summary-same-subject
3772 (t gnus-summary-same-subject)))
3773 (if (and (eq gnus-summary-make-false-root 'adopt)
3774 (= gnus-tmp-level 1)
3775 (memq number gnus-tmp-gathered))
3776 (setq gnus-tmp-opening-bracket ?\<
3777 gnus-tmp-closing-bracket ?\>)
3778 (setq gnus-tmp-opening-bracket ?\[
3779 gnus-tmp-closing-bracket ?\]))
3781 gnus-tmp-indentation
3782 (aref gnus-thread-indent-array gnus-tmp-level)
3783 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3784 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3785 gnus-summary-default-score 0)
3787 (if (or (null gnus-summary-default-score)
3788 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3789 gnus-summary-zcore-fuzz))
3791 (if (< gnus-tmp-score gnus-summary-default-score)
3792 gnus-score-below-mark gnus-score-over-mark))
3794 (cond ((memq number gnus-newsgroup-processable)
3796 ((memq number gnus-newsgroup-cached)
3798 ((memq number gnus-newsgroup-replied)
3800 ((memq number gnus-newsgroup-saved)
3802 (t gnus-unread-mark))
3803 gnus-tmp-from (mail-header-from gnus-tmp-header)
3806 ((string-match "<[^>]+> *$" gnus-tmp-from)
3807 (setq beg-match (match-beginning 0))
3808 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3809 (substring gnus-tmp-from (1+ (match-beginning 0))
3810 (1- (match-end 0))))
3811 (substring gnus-tmp-from 0 beg-match)))
3812 ((string-match "(.+)" gnus-tmp-from)
3813 (substring gnus-tmp-from
3814 (1+ (match-beginning 0)) (1- (match-end 0))))
3816 (when (string= gnus-tmp-name "")
3817 (setq gnus-tmp-name gnus-tmp-from))
3818 (unless (numberp gnus-tmp-lines)
3819 (setq gnus-tmp-lines 0))
3820 (gnus-put-text-property
3822 (progn (eval gnus-summary-line-format-spec) (point))
3823 'gnus-number number)
3826 (gnus-run-hooks 'gnus-summary-update-hook)
3829 (setq gnus-tmp-prev-subject subject)))
3831 (when (nth 1 thread)
3832 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3833 (incf gnus-tmp-level)
3834 (setq threads (if thread-end nil (cdar thread)))
3836 (setq gnus-tmp-level 0)))))
3837 (gnus-message 7 "Generating summary...done"))
3839 (defun gnus-summary-prepare-unthreaded (headers)
3840 "Generate an unthreaded summary buffer based on HEADERS."
3841 (let (header number mark)
3846 ;; We may have to root out some bad articles...
3847 (when (memq (setq number (mail-header-number
3848 (setq header (pop headers))))
3849 gnus-newsgroup-limit)
3850 ;; Mark article as read when it has a low score.
3851 (when (and gnus-summary-mark-below
3852 (< (or (cdr (assq number gnus-newsgroup-scored))
3853 gnus-summary-default-score 0)
3854 gnus-summary-mark-below)
3855 (not (gnus-summary-article-ancient-p number)))
3856 (setq gnus-newsgroup-unreads
3857 (delq number gnus-newsgroup-unreads))
3858 (if gnus-newsgroup-auto-expire
3859 (push number gnus-newsgroup-expirable)
3860 (push (cons number gnus-low-score-mark)
3861 gnus-newsgroup-reads)))
3863 (setq mark (gnus-article-mark number))
3864 (push (gnus-data-make number mark (1+ (point)) header 0)
3865 gnus-newsgroup-data)
3866 (gnus-summary-insert-line
3868 mark (memq number gnus-newsgroup-replied)
3869 (memq number gnus-newsgroup-expirable)
3870 (mail-header-subject header) nil
3871 (cdr (assq number gnus-newsgroup-scored))
3872 (memq number gnus-newsgroup-processable))))))
3874 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3875 "Select newsgroup GROUP.
3876 If READ-ALL is non-nil, all articles in the group are selected.
3877 If SELECT-ARTICLES, only select those articles from GROUP."
3878 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3879 ;;!!! Dirty hack; should be removed.
3880 (gnus-summary-ignore-duplicates
3881 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3883 gnus-summary-ignore-duplicates))
3884 (info (nth 2 entry))
3885 articles fetched-articles cached)
3887 (unless (gnus-check-server
3888 (setq gnus-current-select-method
3889 (gnus-find-method-for-group group)))
3890 (error "Couldn't open server"))
3892 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3893 (gnus-activate-group group) ; Or we can activate it...
3894 (progn ; Or we bug out.
3895 (when (equal major-mode 'gnus-summary-mode)
3896 (kill-buffer (current-buffer)))
3897 (error "Couldn't request group %s: %s"
3898 group (gnus-status-message group))))
3900 (unless (gnus-request-group group t)
3901 (when (equal major-mode 'gnus-summary-mode)
3902 (kill-buffer (current-buffer)))
3903 (error "Couldn't request group %s: %s"
3904 group (gnus-status-message group)))
3906 (setq gnus-newsgroup-name group)
3907 (setq gnus-newsgroup-unselected nil)
3908 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3910 ;; Adjust and set lists of article marks.
3912 (gnus-adjust-marked-articles info))
3914 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3915 (when (gnus-virtual-group-p group)
3916 (setq cached gnus-newsgroup-cached))
3918 (setq gnus-newsgroup-unreads
3919 (gnus-set-difference
3920 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3921 gnus-newsgroup-dormant))
3923 (setq gnus-newsgroup-processable nil)
3925 (gnus-update-read-articles group gnus-newsgroup-unreads)
3927 (if (setq articles select-articles)
3928 (setq gnus-newsgroup-unselected
3929 (gnus-sorted-intersection
3930 gnus-newsgroup-unreads
3931 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3932 (setq articles (gnus-articles-to-read group read-all)))
3936 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3938 ((eq articles 0) nil)
3940 ;; Init the dependencies hash table.
3941 (setq gnus-newsgroup-dependencies
3942 (gnus-make-hashtable (length articles)))
3943 (gnus-set-global-variables)
3944 ;; Retrieve the headers and read them in.
3945 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3946 (setq gnus-newsgroup-headers
3948 (setq gnus-headers-retrieved-by
3949 (gnus-retrieve-headers
3950 articles gnus-newsgroup-name
3951 ;; We might want to fetch old headers, but
3952 ;; not if there is only 1 article.
3954 (not (eq gnus-fetch-old-headers 'some))
3955 (not (numberp gnus-fetch-old-headers)))
3956 (> (length articles) 1))
3957 gnus-fetch-old-headers))))
3958 (gnus-get-newsgroup-headers-xover
3959 articles nil nil gnus-newsgroup-name t)
3960 (gnus-get-newsgroup-headers)))
3961 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3963 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3965 (setq gnus-newsgroup-cached cached))
3967 ;; Suppress duplicates?
3968 (when gnus-suppress-duplicates
3969 (gnus-dup-suppress-articles))
3971 ;; Set the initial limit.
3972 (setq gnus-newsgroup-limit (copy-sequence articles))
3973 ;; Remove canceled articles from the list of unread articles.
3974 (setq gnus-newsgroup-unreads
3975 (gnus-set-sorted-intersection
3976 gnus-newsgroup-unreads
3977 (setq fetched-articles
3978 (mapcar (lambda (headers) (mail-header-number headers))
3979 gnus-newsgroup-headers))))
3980 ;; Removed marked articles that do not exist.
3981 (gnus-update-missing-marks
3982 (gnus-sorted-complement fetched-articles articles))
3983 ;; We might want to build some more threads first.
3984 (when (and gnus-fetch-old-headers
3985 (eq gnus-headers-retrieved-by 'nov))
3986 (if (eq gnus-fetch-old-headers 'invisible)
3987 (gnus-build-all-threads)
3988 (gnus-build-old-threads)))
3989 ;; Let the Gnus agent mark articles as read.
3991 (gnus-agent-get-undownloaded-list))
3992 ;; Check whether auto-expire is to be done in this group.
3993 (setq gnus-newsgroup-auto-expire
3994 (gnus-group-auto-expirable-p group))
3995 ;; Set up the article buffer now, if necessary.
3996 (unless gnus-single-article-buffer
3997 (gnus-article-setup-buffer))
3998 ;; First and last article in this newsgroup.
3999 (when gnus-newsgroup-headers
4000 (setq gnus-newsgroup-begin
4001 (mail-header-number (car gnus-newsgroup-headers))
4004 (gnus-last-element gnus-newsgroup-headers))))
4005 ;; GROUP is successfully selected.
4006 (or gnus-newsgroup-headers t)))))
4008 (defun gnus-articles-to-read (group &optional read-all)
4009 ;; Find out what articles the user wants to read.
4011 ;; Select all articles if `read-all' is non-nil, or if there
4012 ;; are no unread articles.
4014 (and (zerop (length gnus-newsgroup-marked))
4015 (zerop (length gnus-newsgroup-unreads)))
4016 (eq (gnus-group-find-parameter group 'display)
4018 (gnus-uncompress-range (gnus-active group))
4019 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4020 (copy-sequence gnus-newsgroup-unreads))
4022 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4023 (scored (length scored-list))
4024 (number (length articles))
4025 (marked (+ (length gnus-newsgroup-marked)
4026 (length gnus-newsgroup-dormant)))
4034 ((and (or (<= scored marked) (= scored number))
4035 (numberp gnus-large-newsgroup)
4036 (> number gnus-large-newsgroup))
4040 "How many articles from %s (default %d): "
4041 (gnus-limit-string gnus-newsgroup-name 35)
4043 (if (string-match "^[ \t]*$" input) number input)))
4044 ((and (> scored marked) (< scored number)
4045 (> (- scored number) 20))
4048 (format "%s %s (%d scored, %d total): "
4049 "How many articles from"
4050 group scored number))))
4051 (if (string-match "^[ \t]*$" input)
4055 (setq select (if (stringp select) (string-to-number select) select))
4056 (if (or (null select) (zerop select))
4058 (if (and (not (zerop scored)) (<= (abs select) scored))
4060 (setq articles (sort scored-list '<))
4061 (setq number (length articles)))
4062 (setq articles (copy-sequence articles)))
4064 (when (< (abs select) number)
4066 ;; Select the N oldest articles.
4067 (setcdr (nthcdr (1- (abs select)) articles) nil)
4068 ;; Select the N most recent articles.
4069 (setq articles (nthcdr (- number select) articles))))
4070 (setq gnus-newsgroup-unselected
4071 (gnus-sorted-intersection
4072 gnus-newsgroup-unreads
4073 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4076 (defun gnus-killed-articles (killed articles)
4079 (when (inline (gnus-member-of-range (car articles) killed))
4080 (push (car articles) out))
4081 (setq articles (cdr articles)))
4084 (defun gnus-uncompress-marks (marks)
4085 "Uncompress the mark ranges in MARKS."
4086 (let ((uncompressed '(score bookmark))
4089 (if (memq (caar marks) uncompressed)
4090 (push (car marks) out)
4091 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4092 (setq marks (cdr marks)))
4095 (defun gnus-adjust-marked-articles (info)
4096 "Set all article lists and remove all marks that are no longer legal."
4097 (let* ((marked-lists (gnus-info-marks info))
4098 (active (gnus-active (gnus-info-group info)))
4101 (types gnus-article-mark-lists)
4102 (uncompressed '(score bookmark killed))
4103 marks var articles article mark)
4106 (setq marks (pop marked-lists))
4107 (set (setq var (intern (format "gnus-newsgroup-%s"
4108 (car (rassq (setq mark (car marks))
4110 (if (memq (car marks) uncompressed) (cdr marks)
4111 (gnus-uncompress-range (cdr marks))))
4113 (setq articles (symbol-value var))
4115 ;; All articles have to be subsets of the active articles.
4117 ;; Adjust "simple" lists.
4118 ((memq mark '(tick dormant expire reply save))
4120 (when (or (< (setq article (pop articles)) min) (> article max))
4121 (set var (delq article (symbol-value var))))))
4123 ((memq mark uncompressed)
4124 (when (not (listp (cdr (symbol-value var))))
4125 (set var (list (symbol-value var))))
4126 (when (not (listp (cdr articles)))
4127 (setq articles (list articles)))
4129 (when (or (not (consp (setq article (pop articles))))
4130 (< (car article) min)
4131 (> (car article) max))
4132 (set var (delq article (symbol-value var))))))))))
4134 (defun gnus-update-missing-marks (missing)
4135 "Go through the list of MISSING articles and remove them from the mark lists."
4137 (let ((types gnus-article-mark-lists)
4139 ;; Go through all types.
4141 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4142 (when (symbol-value var)
4143 ;; This list has articles. So we delete all missing articles
4147 (set var (delq (pop m) (symbol-value var)))))))))
4149 (defun gnus-update-marks ()
4150 "Enter the various lists of marked articles into the newsgroup info list."
4151 (let ((types gnus-article-mark-lists)
4152 (info (gnus-get-info gnus-newsgroup-name))
4153 (uncompressed '(score bookmark killed))
4154 type list newmarked symbol)
4156 ;; Add all marks lists that are non-nil to the list of marks lists.
4157 (while (setq type (pop types))
4158 (when (setq list (symbol-value
4160 (intern (format "gnus-newsgroup-%s"
4163 ;; Get rid of the entries of the articles that have the
4165 (when (and (eq (cdr type) 'score)
4169 (prev (cons nil list))
4172 (if (or (not (consp (car arts)))
4173 (= (cdar arts) gnus-summary-default-score))
4174 (setcdr prev (cdr arts))
4176 (setq arts (cdr arts)))
4177 (setq list (cdr all))))
4179 (push (cons (cdr type)
4180 (if (memq (cdr type) uncompressed) list
4181 (gnus-compress-sequence
4182 (set symbol (sort list '<)) t)))
4185 ;; Enter these new marks into the info of the group.
4187 (setcar (nthcdr 3 info) newmarked)
4188 ;; Add the marks lists to the end of the info.
4190 (setcdr (nthcdr 2 info) (list newmarked))))
4192 ;; Cut off the end of the info if there's nothing else there.
4196 (when (nthcdr (decf i) info)
4197 (setcdr (nthcdr i info) nil)))))))
4199 (defun gnus-set-mode-line (where)
4200 "This function sets the mode line of the article or summary buffers.
4201 If WHERE is `summary', the summary mode line format will be used."
4202 ;; Is this mode line one we keep updated?
4203 (when (memq where gnus-updated-mode-lines)
4206 ;; We evaluate this in the summary buffer since these
4207 ;; variables are buffer-local to that buffer.
4208 (set-buffer gnus-summary-buffer)
4209 ;; We bind all these variables that are used in the `eval' form
4211 (let* ((mformat (symbol-value
4213 (format "gnus-%s-mode-line-format-spec" where))))
4214 (gnus-tmp-group-name gnus-newsgroup-name)
4215 (gnus-tmp-article-number (or gnus-current-article 0))
4216 (gnus-tmp-unread gnus-newsgroup-unreads)
4217 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4218 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4219 (gnus-tmp-unread-and-unselected
4220 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4221 (zerop gnus-tmp-unselected))
4223 ((zerop gnus-tmp-unselected)
4224 (format "{%d more}" gnus-tmp-unread-and-unticked))
4225 (t (format "{%d(+%d) more}"
4226 gnus-tmp-unread-and-unticked
4227 gnus-tmp-unselected))))
4229 (if (and gnus-current-headers
4230 (vectorp gnus-current-headers))
4231 (gnus-mode-string-quote
4232 (mail-header-subject gnus-current-headers))
4234 bufname-length max-len
4235 gnus-tmp-header);; passed as argument to any user-format-funcs
4236 (setq mode-string (eval mformat))
4237 (setq bufname-length (if (string-match "%b" mode-string)
4240 (if (eq where 'summary)
4242 (get-buffer gnus-article-buffer))))
4245 (setq max-len (max 4 (if gnus-mode-non-string-length
4247 gnus-mode-non-string-length
4249 (length mode-string))))
4250 ;; We might have to chop a bit of the string off...
4251 (when (> (length mode-string) max-len)
4253 (concat (gnus-truncate-string mode-string (- max-len 3))
4255 ;; Pad the mode string a bit.
4256 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4257 ;; Update the mode line.
4258 (setq mode-line-buffer-identification
4259 (gnus-mode-line-buffer-identification (list mode-string)))
4260 (set-buffer-modified-p t))))
4262 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4263 "Go through the HEADERS list and add all Xrefs to a hash table.
4264 The resulting hash table is returned, or nil if no Xrefs were found."
4265 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4266 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4267 (xref-hashtb (gnus-make-hashtable))
4268 start group entry number xrefs header)
4270 (setq header (pop headers))
4271 (when (and (setq xrefs (mail-header-xref header))
4272 (not (memq (setq number (mail-header-number header))
4275 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4276 (setq start (match-end 0))
4277 (setq group (if prefix
4278 (concat prefix (substring xrefs (match-beginning 1)
4280 (substring xrefs (match-beginning 1) (match-end 1))))
4282 (string-to-int (substring xrefs (match-beginning 2)
4284 (if (setq entry (gnus-gethash group xref-hashtb))
4285 (setcdr entry (cons number (cdr entry)))
4286 (gnus-sethash group (cons number nil) xref-hashtb)))))
4287 (and start xref-hashtb)))
4289 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4290 "Look through all the headers and mark the Xrefs as read."
4291 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4292 name entry info xref-hashtb idlist method nth4)
4294 (set-buffer gnus-group-buffer)
4295 (when (setq xref-hashtb
4296 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4299 (unless (string= from-newsgroup (setq name (symbol-name group)))
4300 (setq idlist (symbol-value group))
4301 ;; Dead groups are not updated.
4303 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4305 (when (stringp (setq nth4 (gnus-info-method info)))
4306 (setq nth4 (gnus-server-to-method nth4))))
4307 ;; Only do the xrefs if the group has the same
4308 ;; select method as the group we have just read.
4309 (or (gnus-methods-equal-p
4310 nth4 (gnus-find-method-for-group from-newsgroup))
4312 (equal nth4 (setq method (gnus-find-method-for-group
4314 (and (equal (car nth4) (car method))
4315 (equal (nth 1 nth4) (nth 1 method))))
4316 gnus-use-cross-reference
4317 (or (not (eq gnus-use-cross-reference t))
4319 ;; Only do cross-references on subscribed
4320 ;; groups, if that is what is wanted.
4321 (<= (gnus-info-level info) gnus-level-subscribed))
4322 (gnus-group-make-articles-read name idlist))))
4325 (defun gnus-compute-read-articles (group articles)
4326 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4327 (info (nth 2 entry))
4328 (active (gnus-active group))
4331 ;; First peel off all illegal article numbers.
4333 (let ((ids articles)
4335 (while (setq id (pop ids))
4336 (when (and first (> id (cdr active)))
4337 ;; We'll end up in this situation in one particular
4338 ;; obscure situation. If you re-scan a group and get
4339 ;; a new article that is cross-posted to a different
4340 ;; group that has not been re-scanned, you might get
4341 ;; crossposted article that has a higher number than
4342 ;; Gnus believes possible. So we re-activate this
4343 ;; group as well. This might mean doing the
4344 ;; crossposting thingy will *increase* the number
4345 ;; of articles in some groups. Tsk, tsk.
4346 (setq active (or (gnus-activate-group group) active)))
4347 (when (or (> id (cdr active))
4348 (< id (car active)))
4349 (setq articles (delq id articles))))))
4350 ;; If the read list is nil, we init it.
4352 (null (gnus-info-read info))
4354 (setq ninfo (cons 1 (1- (car active))))
4355 (setq ninfo (gnus-info-read info)))
4356 ;; Then we add the read articles to the range.
4358 ninfo (setq articles (sort articles '<))))))
4360 (defun gnus-group-make-articles-read (group articles)
4361 "Update the info of GROUP to say that ARTICLES are read."
4363 (entry (gnus-gethash group gnus-newsrc-hashtb))
4364 (info (nth 2 entry))
4365 (active (gnus-active group))
4368 (setq range (gnus-compute-read-articles group articles))
4370 (set-buffer gnus-group-buffer)
4373 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4374 (gnus-info-set-read ',info ',(gnus-info-read info))
4375 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4376 (gnus-group-update-group ,group t))))
4377 ;; Add the read articles to the range.
4378 (gnus-info-set-read info range)
4379 ;; Then we have to re-compute how many unread
4380 ;; articles there are in this group.
4384 (setq num (- (1+ (cdr active)) (car active))))
4385 ((not (listp (cdr range)))
4386 (setq num (- (cdr active) (- (1+ (cdr range))
4390 (if (numberp (car range))
4392 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4393 (setq range (cdr range)))
4394 (setq num (- (cdr active) num))))
4395 ;; Update the number of unread articles.
4397 ;; Update the group buffer.
4398 (gnus-group-update-group group t)))))
4400 (defun gnus-methods-equal-p (m1 m2)
4401 (let ((m1 (or m1 gnus-select-method))
4402 (m2 (or m2 gnus-select-method)))
4404 (and (eq (car m1) (car m2))
4405 (or (not (memq 'address (assoc (symbol-name (car m1))
4406 gnus-valid-select-methods)))
4407 (equal (nth 1 m1) (nth 1 m2)))))))
4409 (defvar gnus-newsgroup-none-id 0)
4411 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4412 (let ((cur nntp-server-buffer)
4415 (save-excursion (set-buffer gnus-summary-buffer)
4416 gnus-newsgroup-dependencies)))
4419 (set-buffer nntp-server-buffer)
4420 ;; Translate all TAB characters into SPACE characters.
4421 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4422 (gnus-run-hooks 'gnus-parse-headers-hook)
4423 (let ((case-fold-search t)
4425 in-reply-to header p lines chars)
4426 (goto-char (point-min))
4427 ;; Search to the beginning of the next header. Error messages
4428 ;; do not begin with 2 or 3.
4429 (while (re-search-forward "^[23][0-9]+ " nil t)
4432 ;; This implementation of this function, with nine
4433 ;; search-forwards instead of the one re-search-forward and
4434 ;; a case (which basically was the old function) is actually
4435 ;; about twice as fast, even though it looks messier. You
4436 ;; can't have everything, I guess. Speed and elegance
4437 ;; doesn't always go hand in hand.
4446 (narrow-to-region (point)
4447 (or (and (search-forward "\n.\n" nil t)
4453 (if (search-forward "\nsubject: " nil t)
4455 (setq rawtext (nnheader-header-value)
4457 gnus-unstructured-field-decoder rawtext))
4458 (if (string-equal rawtext decoded)
4460 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
4466 (if (search-forward "\nfrom: " nil t)
4468 (setq rawtext (nnheader-header-value)
4470 gnus-structured-field-decoder rawtext))
4471 (if (string-equal rawtext decoded)
4473 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
4479 (if (search-forward "\ndate: " nil t)
4480 (nnheader-header-value) ""))
4484 (setq id (if (re-search-forward
4485 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4486 ;; We do it this way to make sure the Message-ID
4487 ;; is (somewhat) syntactically valid.
4488 (buffer-substring (match-beginning 1)
4490 ;; If there was no message-id, we just fake one
4491 ;; to make subsequent routines simpler.
4492 (nnheader-generate-fake-message-id))))
4496 (if (search-forward "\nreferences: " nil t)
4500 (nnheader-header-value)
4505 (search-backward ">" end t)
4508 (search-backward "<" end t)
4510 ;; Get the references from the in-reply-to header if there
4511 ;; were no references and the in-reply-to header looks
4513 (if (and (search-forward "\nin-reply-to: " nil t)
4514 (setq in-reply-to (nnheader-header-value))
4515 (string-match "<[^>]+>" in-reply-to))
4517 (setq ref (substring in-reply-to (match-beginning 0)
4519 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4520 (setq ref2 (substring in-reply-to (match-beginning 0)
4522 (when (> (length ref2) (length ref))
4529 (if (search-forward "\nchars: " nil t)
4530 (if (numberp (setq chars (ignore-errors (read cur))))
4536 (if (search-forward "\nlines: " nil t)
4537 (if (numberp (setq lines (ignore-errors (read cur))))
4543 (and (search-forward "\nxref: " nil t)
4544 (nnheader-header-value)))))
4545 (when (equal id ref)
4548 (when gnus-alter-header-function
4549 (funcall gnus-alter-header-function header)
4550 (setq id (mail-header-id header)
4551 ref (gnus-parent-id (mail-header-references header))))
4554 (gnus-dependencies-add-header
4555 header dependencies force-new))
4556 (push header headers))
4557 (goto-char (point-max))
4559 (nreverse headers)))))
4561 ;; Goes through the xover lines and returns a list of vectors
4562 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4563 force-new dependencies
4564 group also-fetch-heads)
4565 "Parse the news overview data in the server buffer, and return a
4566 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4567 ;; Get the Xref when the users reads the articles since most/some
4568 ;; NNTP servers do not include Xrefs when using XOVER.
4569 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4570 (let ((cur nntp-server-buffer)
4571 (dependencies (or dependencies gnus-newsgroup-dependencies))
4572 number headers header)
4574 (set-buffer nntp-server-buffer)
4575 ;; Allow the user to mangle the headers before parsing them.
4576 (gnus-run-hooks 'gnus-parse-headers-hook)
4577 (goto-char (point-min))
4580 (while (and sequence (not (eobp)))
4581 (setq number (read cur))
4582 (while (and sequence
4583 (< (car sequence) number))
4584 (setq sequence (cdr sequence)))
4586 (eq number (car sequence))
4588 (setq sequence (cdr sequence))
4589 (setq header (inline
4590 (gnus-nov-parse-line
4591 number dependencies force-new))))
4592 (push header headers))
4595 (gnus-error 4 "Strange nov line (%d)"
4596 (count-lines (point-min) (point)))))
4598 ;; A common bug in inn is that if you have posted an article and
4599 ;; then retrieves the active file, it will answer correctly --
4600 ;; the new article is included. However, a NOV entry for the
4601 ;; article may not have been generated yet, so this may fail.
4602 ;; We work around this problem by retrieving the last few
4603 ;; headers using HEAD.
4604 (if (or (not also-fetch-heads)
4606 ;; We (probably) got all the headers.
4608 (let ((gnus-nov-is-evil t))
4611 (when (gnus-retrieve-headers sequence group)
4612 (gnus-get-newsgroup-headers))))))))
4614 (defun gnus-article-get-xrefs ()
4615 "Fill in the Xref value in `gnus-current-headers', if necessary.
4616 This is meant to be called in `gnus-article-internal-prepare-hook'."
4617 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4618 gnus-current-headers)))
4619 (or (not gnus-use-cross-reference)
4621 (and (mail-header-xref headers)
4622 (not (string= (mail-header-xref headers) "")))
4623 (let ((case-fold-search t)
4626 (nnheader-narrow-to-headers)
4627 (goto-char (point-min))
4628 (when (or (and (eq (downcase (following-char)) ?x)
4629 (looking-at "Xref:"))
4630 (search-forward "\nXref:" nil t))
4631 (goto-char (1+ (match-end 0)))
4632 (setq xref (buffer-substring (point)
4633 (progn (end-of-line) (point))))
4634 (mail-header-set-xref headers xref)))))))
4636 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4637 "Find article ID and insert the summary line for that article.
4638 OLD-HEADER can either be a header or a line number to insert
4639 the subject line on."
4640 (let* ((line (and (numberp old-header) old-header))
4641 (old-header (and (vectorp old-header) old-header))
4642 (header (cond ((and old-header use-old-header)
4645 (gnus-number-to-header id))
4646 (gnus-number-to-header id))
4648 (gnus-read-header id))))
4649 (number (and (numberp id) id))
4652 ;; Rebuild the thread that this article is part of and go to the
4653 ;; article we have fetched.
4654 (when (and (not gnus-show-threads)
4657 (setq d (gnus-data-find (mail-header-number old-header))))
4658 (goto-char (gnus-data-pos d))
4661 (- (gnus-point-at-bol)
4663 (1+ (gnus-point-at-eol))
4664 (gnus-delete-line))))))
4666 (mail-header-set-number header (mail-header-number old-header)))
4667 (setq gnus-newsgroup-sparse
4668 (delq (setq number (mail-header-number header))
4669 gnus-newsgroup-sparse))
4670 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4671 (push number gnus-newsgroup-limit)
4672 (gnus-rebuild-thread (mail-header-id header) line)
4673 (gnus-summary-goto-subject number nil t))
4674 (when (and (numberp number)
4676 ;; We have to update the boundaries even if we can't fetch the
4677 ;; article if ID is a number -- so that the next `P' or `N'
4678 ;; command will fetch the previous (or next) article even
4679 ;; if the one we tried to fetch this time has been canceled.
4680 (when (> number gnus-newsgroup-end)
4681 (setq gnus-newsgroup-end number))
4682 (when (< number gnus-newsgroup-begin)
4683 (setq gnus-newsgroup-begin number))
4684 (setq gnus-newsgroup-unselected
4685 (delq number gnus-newsgroup-unselected)))
4686 ;; Report back a success?
4687 (and header (mail-header-number header))))
4689 ;;; Process/prefix in the summary buffer
4691 (defun gnus-summary-work-articles (n)
4692 "Return a list of articles to be worked upon.
4693 The prefix argument, the list of process marked articles, and the
4694 current article will be taken into consideration."
4696 (set-buffer gnus-summary-buffer)
4699 ;; A numerical prefix has been given.
4700 (setq n (prefix-numeric-value n))
4701 (let ((backward (< n 0))
4702 (n (abs (prefix-numeric-value n)))
4707 (push (setq article (gnus-summary-article-number))
4710 (gnus-summary-find-prev nil article)
4711 (gnus-summary-find-next nil article)))
4713 (nreverse articles)))
4714 ((and (gnus-region-active-p) (mark))
4715 (message "region active")
4716 ;; Work on the region between point and mark.
4717 (let ((max (max (point) (mark)))
4720 (goto-char (min (point) (mark)))
4723 (push (setq article (gnus-summary-article-number)) articles)
4724 (gnus-summary-find-next nil article)
4726 (nreverse articles))))
4727 (gnus-newsgroup-processable
4728 ;; There are process-marked articles present.
4729 ;; Save current state.
4730 (gnus-summary-save-process-mark)
4732 (reverse gnus-newsgroup-processable))
4734 ;; Just return the current article.
4735 (list (gnus-summary-article-number))))))
4737 (defmacro gnus-summary-iterate (arg &rest forms)
4738 "Iterate over the process/prefixed articles and do FORMS.
4739 ARG is the interactive prefix given to the command. FORMS will be
4740 executed with point over the summary line of the articles."
4741 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4742 `(let ((,articles (gnus-summary-work-articles ,arg)))
4744 (gnus-summary-goto-subject (car ,articles))
4747 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4748 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4750 (defun gnus-summary-save-process-mark ()
4751 "Push the current set of process marked articles on the stack."
4753 (push (copy-sequence gnus-newsgroup-processable)
4754 gnus-newsgroup-process-stack))
4756 (defun gnus-summary-kill-process-mark ()
4757 "Push the current set of process marked articles on the stack and unmark."
4759 (gnus-summary-save-process-mark)
4760 (gnus-summary-unmark-all-processable))
4762 (defun gnus-summary-yank-process-mark ()
4763 "Pop the last process mark state off the stack and restore it."
4765 (unless gnus-newsgroup-process-stack
4766 (error "Empty mark stack"))
4767 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4769 (defun gnus-summary-process-mark-set (set)
4770 "Make SET into the current process marked articles."
4771 (gnus-summary-unmark-all-processable)
4773 (gnus-summary-set-process-mark (pop set))))
4775 ;;; Searching and stuff
4777 (defun gnus-summary-search-group (&optional backward use-level)
4778 "Search for next unread newsgroup.
4779 If optional argument BACKWARD is non-nil, search backward instead."
4781 (set-buffer gnus-group-buffer)
4782 (when (gnus-group-search-forward
4783 backward nil (if use-level (gnus-group-group-level) nil))
4784 (gnus-group-group-name))))
4786 (defun gnus-summary-best-group (&optional exclude-group)
4787 "Find the name of the best unread group.
4788 If EXCLUDE-GROUP, do not go to this group."
4790 (set-buffer gnus-group-buffer)
4792 (gnus-group-best-unread-group exclude-group))))
4794 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4795 (if backward (gnus-summary-find-prev)
4796 (let* ((dummy (gnus-summary-article-intangible-p))
4797 (article (or article (gnus-summary-article-number)))
4798 (arts (gnus-data-find-list article))
4800 (when (and (not dummy)
4801 (or (not gnus-summary-check-current)
4803 (not (gnus-data-unread-p (car arts)))))
4804 (setq arts (cdr arts)))
4809 (when (or (and undownloaded
4810 (eq gnus-undownloaded-mark
4811 (gnus-data-mark (car arts))))
4812 (gnus-data-unread-p (car arts)))
4813 (setq result (car arts)
4815 (setq arts (cdr arts)))
4818 (goto-char (gnus-data-pos result))
4819 (gnus-data-number result)))))
4821 (defun gnus-summary-find-prev (&optional unread article)
4822 (let* ((eobp (eobp))
4823 (article (or article (gnus-summary-article-number)))
4824 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4826 (when (and (not eobp)
4827 (or (not gnus-summary-check-current)
4829 (not (gnus-data-unread-p (car arts)))))
4830 (setq arts (cdr arts)))
4835 (when (gnus-data-unread-p (car arts))
4836 (setq result (car arts)
4838 (setq arts (cdr arts)))
4841 (goto-char (gnus-data-pos result))
4842 (gnus-data-number result))))
4844 (defun gnus-summary-find-subject (subject &optional unread backward article)
4845 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4846 (article (or article (gnus-summary-article-number)))
4847 (articles (gnus-data-list backward))
4848 (arts (gnus-data-find-list article articles))
4850 (when (or (not gnus-summary-check-current)
4852 (not (gnus-data-unread-p (car arts))))
4853 (setq arts (cdr arts)))
4855 (and (or (not unread)
4856 (gnus-data-unread-p (car arts)))
4857 (vectorp (gnus-data-header (car arts)))
4859 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4860 (setq result (car arts)
4862 (setq arts (cdr arts)))
4864 (goto-char (gnus-data-pos result))
4865 (gnus-data-number result))))
4867 (defun gnus-summary-search-forward (&optional unread subject backward)
4868 "Search forward for an article.
4869 If UNREAD, look for unread articles. If SUBJECT, look for
4870 articles with that subject. If BACKWARD, search backward instead."
4871 (cond (subject (gnus-summary-find-subject subject unread backward))
4872 (backward (gnus-summary-find-prev unread))
4873 (t (gnus-summary-find-next unread))))
4875 (defun gnus-recenter (&optional n)
4876 "Center point in window and redisplay frame.
4877 Also do horizontal recentering."
4879 (when (and gnus-auto-center-summary
4880 (not (eq gnus-auto-center-summary 'vertical)))
4881 (gnus-horizontal-recenter))
4884 (defun gnus-summary-recenter ()
4885 "Center point in the summary window.
4886 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4887 displayed, no centering will be performed."
4888 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4889 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4890 (let* ((top (cond ((< (window-height) 4) 0)
4891 ((< (window-height) 7) 1)
4893 (height (1- (window-height)))
4894 (bottom (save-excursion (goto-char (point-max))
4895 (forward-line (- height))
4897 (window (get-buffer-window (current-buffer))))
4898 ;; The user has to want it.
4899 (when gnus-auto-center-summary
4900 (when (get-buffer-window gnus-article-buffer)
4901 ;; Only do recentering when the article buffer is displayed,
4902 ;; Set the window start to either `bottom', which is the biggest
4903 ;; possible valid number, or the second line from the top,
4904 ;; whichever is the least.
4906 window (min bottom (save-excursion
4907 (forward-line (- top)) (point)))))
4908 ;; Do horizontal recentering while we're at it.
4909 (when (and (get-buffer-window (current-buffer) t)
4910 (not (eq gnus-auto-center-summary 'vertical)))
4911 (let ((selected (selected-window)))
4912 (select-window (get-buffer-window (current-buffer) t))
4913 (gnus-summary-position-point)
4914 (gnus-horizontal-recenter)
4915 (select-window selected))))))
4917 (defun gnus-summary-jump-to-group (newsgroup)
4918 "Move point to NEWSGROUP in group mode buffer."
4919 ;; Keep update point of group mode buffer if visible.
4920 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4921 (save-window-excursion
4922 ;; Take care of tree window mode.
4923 (when (get-buffer-window gnus-group-buffer)
4924 (pop-to-buffer gnus-group-buffer))
4925 (gnus-group-jump-to-group newsgroup))
4927 ;; Take care of tree window mode.
4928 (if (get-buffer-window gnus-group-buffer)
4929 (pop-to-buffer gnus-group-buffer)
4930 (set-buffer gnus-group-buffer))
4931 (gnus-group-jump-to-group newsgroup))))
4933 ;; This function returns a list of article numbers based on the
4934 ;; difference between the ranges of read articles in this group and
4935 ;; the range of active articles.
4936 (defun gnus-list-of-unread-articles (group)
4937 (let* ((read (gnus-info-read (gnus-get-info group)))
4938 (active (or (gnus-active group) (gnus-activate-group group)))
4941 ;; If none are read, then all are unread.
4943 (setq first (car active))
4944 ;; If the range of read articles is a single range, then the
4945 ;; first unread article is the article after the last read
4946 ;; article. Sounds logical, doesn't it?
4947 (if (not (listp (cdr read)))
4948 (setq first (max (car active) (1+ (cdr read))))
4949 ;; `read' is a list of ranges.
4950 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4953 (setq first (car active)))
4956 (while (< first nlast)
4958 (setq first (1+ first))))
4959 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4960 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4961 (setq read (cdr read)))))
4962 ;; And add the last unread articles.
4963 (while (<= first last)
4965 (setq first (1+ first)))
4966 ;; Return the list of unread articles.
4967 (delq 0 (nreverse unread))))
4969 (defun gnus-list-of-read-articles (group)
4970 "Return a list of unread, unticked and non-dormant articles."
4971 (let* ((info (gnus-get-info group))
4972 (marked (gnus-info-marks info))
4973 (active (gnus-active group)))
4975 (gnus-set-difference
4976 (gnus-sorted-complement
4977 (gnus-uncompress-range active)
4978 (gnus-list-of-unread-articles group))
4980 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4981 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4983 ;; Various summary commands
4985 (defun gnus-summary-select-article-buffer ()
4986 "Reconfigure windows to show article buffer."
4988 (if (not (gnus-buffer-live-p gnus-article-buffer))
4989 (error "There is no article buffer for this summary buffer")
4990 (gnus-configure-windows 'article)
4991 (select-window (get-buffer-window gnus-article-buffer))))
4993 (defun gnus-summary-universal-argument (arg)
4994 "Perform any operation on all articles that are process/prefixed."
4996 (let ((articles (gnus-summary-work-articles arg))
5003 (substitute-command-keys
5004 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5007 (gnus-error 1 "Undefined key")
5010 (gnus-summary-goto-subject (setq article (pop articles)))
5011 (let (gnus-newsgroup-processable)
5012 (command-execute func))
5013 (gnus-summary-remove-process-mark article)))))
5014 (gnus-summary-position-point))
5016 (defun gnus-summary-toggle-truncation (&optional arg)
5017 "Toggle truncation of summary lines.
5018 With arg, turn line truncation on iff arg is positive."
5020 (setq truncate-lines
5021 (if (null arg) (not truncate-lines)
5022 (> (prefix-numeric-value arg) 0)))
5025 (defun gnus-summary-reselect-current-group (&optional all rescan)
5026 "Exit and then reselect the current newsgroup.
5027 The prefix argument ALL means to select all articles."
5029 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5030 (error "Ephemeral groups can't be reselected"))
5031 (let ((current-subject (gnus-summary-article-number))
5032 (group gnus-newsgroup-name))
5033 (setq gnus-newsgroup-begin nil)
5035 ;; We have to adjust the point of group mode buffer because
5036 ;; point was moved to the next unread newsgroup by exiting.
5037 (gnus-summary-jump-to-group group)
5040 (gnus-group-get-new-news-this-group 1)))
5041 (gnus-group-read-group all t)
5042 (gnus-summary-goto-subject current-subject nil t)))
5044 (defun gnus-summary-rescan-group (&optional all)
5045 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5047 (gnus-summary-reselect-current-group all t))
5049 (defun gnus-summary-update-info (&optional non-destructive)
5051 (let ((group gnus-newsgroup-name))
5053 (when gnus-newsgroup-kill-headers
5054 (setq gnus-newsgroup-killed
5055 (gnus-compress-sequence
5057 (gnus-set-sorted-intersection
5058 (gnus-uncompress-range gnus-newsgroup-killed)
5059 (setq gnus-newsgroup-unselected
5060 (sort gnus-newsgroup-unselected '<)))
5061 (setq gnus-newsgroup-unreads
5062 (sort gnus-newsgroup-unreads '<)))
5064 (unless (listp (cdr gnus-newsgroup-killed))
5065 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5066 (let ((headers gnus-newsgroup-headers))
5067 ;; Set the new ranges of read articles.
5069 (set-buffer gnus-group-buffer)
5070 (gnus-undo-force-boundary))
5071 (gnus-update-read-articles
5072 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5073 ;; Set the current article marks.
5074 (let ((gnus-newsgroup-scored
5075 (if (and (not gnus-save-score)
5076 (not non-destructive))
5078 gnus-newsgroup-scored)))
5080 (gnus-update-marks)))
5081 ;; Do the cross-ref thing.
5082 (when gnus-use-cross-reference
5083 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5084 ;; Do not switch windows but change the buffer to work.
5085 (set-buffer gnus-group-buffer)
5086 (unless (gnus-ephemeral-group-p group)
5087 (gnus-group-update-group group)))))))
5089 (defun gnus-summary-save-newsrc (&optional force)
5090 "Save the current number of read/marked articles in the dribble buffer.
5091 The dribble buffer will then be saved.
5092 If FORCE (the prefix), also save the .newsrc file(s)."
5094 (gnus-summary-update-info t)
5096 (gnus-save-newsrc-file)
5097 (gnus-dribble-save)))
5099 (defun gnus-summary-exit (&optional temporary)
5100 "Exit reading current newsgroup, and then return to group selection mode.
5101 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5103 (gnus-set-global-variables)
5104 (gnus-kill-save-kill-buffer)
5105 (gnus-async-halt-prefetch)
5106 (let* ((group gnus-newsgroup-name)
5107 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5110 (buf (current-buffer)))
5111 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5112 ;; If we have several article buffers, we kill them at exit.
5113 (unless gnus-single-article-buffer
5114 (gnus-kill-buffer gnus-original-article-buffer)
5115 (setq gnus-article-current nil))
5116 (when gnus-use-cache
5117 (gnus-cache-possibly-remove-articles)
5118 (gnus-cache-save-buffers))
5119 (gnus-async-prefetch-remove-group group)
5120 (when gnus-suppress-duplicates
5121 (gnus-dup-enter-articles))
5122 (when gnus-use-trees
5123 (gnus-tree-close group))
5124 ;; Remove entries for this group.
5125 (nnmail-purge-split-history (gnus-group-real-name group))
5126 ;; Make all changes in this group permanent.
5128 (gnus-run-hooks 'gnus-exit-group-hook)
5129 (gnus-summary-update-info)
5130 ;; Do adaptive scoring, and possibly save score files.
5131 (when gnus-newsgroup-adaptive
5132 (gnus-score-adaptive))
5133 (when gnus-use-scoring
5135 (gnus-close-group group)
5136 ;; Make sure where we were, and go to next newsgroup.
5137 (set-buffer gnus-group-buffer)
5139 (gnus-group-jump-to-group group))
5140 (gnus-run-hooks 'gnus-summary-exit-hook)
5141 (unless (or quit-config
5142 ;; If this group has disappeared from the summary
5143 ;; buffer, don't skip forwards.
5144 (not (string= group (gnus-group-group-name))))
5145 (gnus-group-next-unread-group 1))
5146 (setq group-point (point))
5149 ;; If we have several article buffers, we kill them at exit.
5150 (unless gnus-single-article-buffer
5151 (gnus-kill-buffer gnus-article-buffer)
5152 (gnus-kill-buffer gnus-original-article-buffer)
5153 (setq gnus-article-current nil))
5155 (if (not gnus-kill-summary-on-exit)
5156 (gnus-deaden-summary)
5157 ;; We set all buffer-local variables to nil. It is unclear why
5158 ;; this is needed, but if we don't, buffer-local variables are
5159 ;; not garbage-collected, it seems. This would the lead to en
5160 ;; ever-growing Emacs.
5161 (gnus-summary-clear-local-variables)
5162 (when (get-buffer gnus-article-buffer)
5163 (bury-buffer gnus-article-buffer))
5164 ;; We clear the global counterparts of the buffer-local
5165 ;; variables as well, just to be on the safe side.
5166 (set-buffer gnus-group-buffer)
5167 (gnus-summary-clear-local-variables)
5168 ;; Return to group mode buffer.
5169 (when (eq mode 'gnus-summary-mode)
5170 (gnus-kill-buffer buf)))
5171 (setq gnus-current-select-method gnus-select-method)
5172 (pop-to-buffer gnus-group-buffer)
5173 (if (not quit-config)
5175 (goto-char group-point)
5176 (gnus-configure-windows 'group 'force))
5177 (gnus-handle-ephemeral-exit quit-config))
5178 ;; Clear the current group name.
5180 (setq gnus-newsgroup-name nil)))))
5182 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5183 (defun gnus-summary-exit-no-update (&optional no-questions)
5184 "Quit reading current newsgroup without updating read article info."
5186 (let* ((group gnus-newsgroup-name)
5187 (quit-config (gnus-group-quit-config group)))
5188 (when (or no-questions
5190 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5191 (gnus-async-halt-prefetch)
5192 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5193 ;; If we have several article buffers, we kill them at exit.
5194 (unless gnus-single-article-buffer
5195 (gnus-kill-buffer gnus-article-buffer)
5196 (gnus-kill-buffer gnus-original-article-buffer)
5197 (setq gnus-article-current nil))
5198 (if (not gnus-kill-summary-on-exit)
5199 (gnus-deaden-summary)
5200 (gnus-close-group group)
5201 (gnus-summary-clear-local-variables)
5202 (set-buffer gnus-group-buffer)
5203 (gnus-summary-clear-local-variables)
5204 (when (get-buffer gnus-summary-buffer)
5205 (kill-buffer gnus-summary-buffer)))
5206 (unless gnus-single-article-buffer
5207 (setq gnus-article-current nil))
5208 (when gnus-use-trees
5209 (gnus-tree-close group))
5210 (gnus-async-prefetch-remove-group group)
5211 (when (get-buffer gnus-article-buffer)
5212 (bury-buffer gnus-article-buffer))
5213 ;; Return to the group buffer.
5214 (gnus-configure-windows 'group 'force)
5215 ;; Clear the current group name.
5216 (setq gnus-newsgroup-name nil)
5217 (when (equal (gnus-group-group-name) group)
5218 (gnus-group-next-unread-group 1))
5220 (gnus-handle-ephemeral-exit quit-config)))))
5222 (defun gnus-handle-ephemeral-exit (quit-config)
5223 "Handle movement when leaving an ephemeral group.
5224 The state which existed when entering the ephemeral is reset."
5225 (if (not (buffer-name (car quit-config)))
5226 (gnus-configure-windows 'group 'force)
5227 (set-buffer (car quit-config))
5228 (cond ((eq major-mode 'gnus-summary-mode)
5229 (gnus-set-global-variables))
5230 ((eq major-mode 'gnus-article-mode)
5232 ;; The `gnus-summary-buffer' variable may point
5233 ;; to the old summary buffer when using a single
5235 (unless (gnus-buffer-live-p gnus-summary-buffer)
5236 (set-buffer gnus-group-buffer))
5237 (set-buffer gnus-summary-buffer)
5238 (gnus-set-global-variables))))
5239 (if (or (eq (cdr quit-config) 'article)
5240 (eq (cdr quit-config) 'pick))
5242 ;; The current article may be from the ephemeral group
5243 ;; thus it is best that we reload this article
5244 (gnus-summary-show-article)
5245 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5246 (gnus-configure-windows 'pick 'force)
5247 (gnus-configure-windows (cdr quit-config) 'force)))
5248 (gnus-configure-windows (cdr quit-config) 'force))
5249 (when (eq major-mode 'gnus-summary-mode)
5250 (gnus-summary-next-subject 1 nil t)
5251 (gnus-summary-recenter)
5252 (gnus-summary-position-point))))
5254 (defun gnus-summary-preview-mime-message (arg)
5255 "MIME decode and play this message."
5258 (let ((gnus-break-pages nil)
5260 (gnus-summary-select-article t t)
5262 (select-window (get-buffer-window gnus-article-buffer))
5267 (defvar gnus-dead-summary-mode-map nil)
5269 (unless gnus-dead-summary-mode-map
5270 (setq gnus-dead-summary-mode-map (make-keymap))
5271 (suppress-keymap gnus-dead-summary-mode-map)
5272 (substitute-key-definition
5273 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5274 (let ((keys '("\C-d" "\r" "\177" [delete])))
5276 (define-key gnus-dead-summary-mode-map
5277 (pop keys) 'gnus-summary-wake-up-the-dead))))
5279 (defvar gnus-dead-summary-mode nil
5280 "Minor mode for Gnus summary buffers.")
5282 (defun gnus-dead-summary-mode (&optional arg)
5283 "Minor mode for Gnus summary buffers."
5285 (when (eq major-mode 'gnus-summary-mode)
5286 (make-local-variable 'gnus-dead-summary-mode)
5287 (setq gnus-dead-summary-mode
5288 (if (null arg) (not gnus-dead-summary-mode)
5289 (> (prefix-numeric-value arg) 0)))
5290 (when gnus-dead-summary-mode
5291 (gnus-add-minor-mode
5292 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5294 (defun gnus-deaden-summary ()
5295 "Make the current summary buffer into a dead summary buffer."
5296 ;; Kill any previous dead summary buffer.
5297 (when (and gnus-dead-summary
5298 (buffer-name gnus-dead-summary))
5300 (set-buffer gnus-dead-summary)
5301 (when gnus-dead-summary-mode
5302 (kill-buffer (current-buffer)))))
5303 ;; Make this the current dead summary.
5304 (setq gnus-dead-summary (current-buffer))
5305 (gnus-dead-summary-mode 1)
5306 (let ((name (buffer-name)))
5307 (when (string-match "Summary" name)
5309 (concat (substring name 0 (match-beginning 0)) "Dead "
5310 (substring name (match-beginning 0)))
5313 (defun gnus-kill-or-deaden-summary (buffer)
5314 "Kill or deaden the summary BUFFER."
5316 (when (and (buffer-name buffer)
5317 (not gnus-single-article-buffer))
5320 (gnus-kill-buffer gnus-article-buffer)
5321 (gnus-kill-buffer gnus-original-article-buffer)))
5322 (cond (gnus-kill-summary-on-exit
5323 (when (and gnus-use-trees
5324 (gnus-buffer-exists-p buffer))
5327 (gnus-tree-close gnus-newsgroup-name)))
5328 (gnus-kill-buffer buffer))
5329 ((gnus-buffer-exists-p buffer)
5332 (gnus-deaden-summary))))))
5334 (defun gnus-summary-wake-up-the-dead (&rest args)
5335 "Wake up the dead summary buffer."
5337 (gnus-dead-summary-mode -1)
5338 (let ((name (buffer-name)))
5339 (when (string-match "Dead " name)
5341 (concat (substring name 0 (match-beginning 0))
5342 (substring name (match-end 0)))
5344 (gnus-message 3 "This dead summary is now alive again"))
5346 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5347 (defun gnus-summary-fetch-faq (&optional faq-dir)
5348 "Fetch the FAQ for the current group.
5349 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5353 (when current-prefix-arg
5355 "Faq dir: " (and (listp gnus-group-faq-directory)
5356 (mapcar (lambda (file) (list file))
5357 gnus-group-faq-directory))))))
5358 (let (gnus-faq-buffer)
5359 (when (setq gnus-faq-buffer
5360 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5361 (gnus-configure-windows 'summary-faq))))
5363 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5364 (defun gnus-summary-describe-group (&optional force)
5365 "Describe the current newsgroup."
5367 (gnus-group-describe-group force gnus-newsgroup-name))
5369 (defun gnus-summary-describe-briefly ()
5370 "Describe summary mode commands briefly."
5373 (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")))
5375 ;; Walking around group mode buffer from summary mode.
5377 (defun gnus-summary-next-group (&optional no-article target-group backward)
5378 "Exit current newsgroup and then select next unread newsgroup.
5379 If prefix argument NO-ARTICLE is non-nil, no article is selected
5380 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5381 previous group instead."
5383 ;; Stop pre-fetching.
5384 (gnus-async-halt-prefetch)
5385 (let ((current-group gnus-newsgroup-name)
5386 (current-buffer (current-buffer))
5388 ;; First we semi-exit this group to update Xrefs and all variables.
5389 ;; We can't do a real exit, because the window conf must remain
5390 ;; the same in case the user is prompted for info, and we don't
5391 ;; want the window conf to change before that...
5392 (gnus-summary-exit t)
5393 (while (not entered)
5394 ;; Then we find what group we are supposed to enter.
5395 (set-buffer gnus-group-buffer)
5396 (gnus-group-jump-to-group current-group)
5399 (if (eq gnus-keep-same-level 'best)
5400 (gnus-summary-best-group gnus-newsgroup-name)
5401 (gnus-summary-search-group backward gnus-keep-same-level))))
5402 (if (not target-group)
5403 ;; There are no further groups, so we return to the group
5406 (gnus-message 5 "Returning to the group buffer")
5408 (when (gnus-buffer-live-p current-buffer)
5409 (set-buffer current-buffer)
5410 (gnus-summary-exit))
5411 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5412 ;; We try to enter the target group.
5413 (gnus-group-jump-to-group target-group)
5414 (let ((unreads (gnus-group-group-unread)))
5415 (if (and (or (eq t unreads)
5416 (and unreads (not (zerop unreads))))
5417 (gnus-summary-read-group
5418 target-group nil no-article
5419 (and (buffer-name current-buffer) current-buffer)
5422 (setq current-group target-group
5423 target-group nil)))))))
5425 (defun gnus-summary-prev-group (&optional no-article)
5426 "Exit current newsgroup and then select previous unread newsgroup.
5427 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5429 (gnus-summary-next-group no-article nil t))
5431 ;; Walking around summary lines.
5433 (defun gnus-summary-first-subject (&optional unread undownloaded)
5434 "Go to the first unread subject.
5435 If UNREAD is non-nil, go to the first unread article.
5436 Returns the article selected or nil if there are no unread articles."
5441 ((null gnus-newsgroup-data)
5442 (gnus-message 3 "No articles in the group")
5444 ;; Pick the first article.
5446 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5447 (gnus-data-number (car gnus-newsgroup-data)))
5448 ;; No unread articles.
5449 ((null gnus-newsgroup-unreads)
5450 (gnus-message 3 "No more unread articles")
5452 ;; Find the first unread article.
5454 (let ((data gnus-newsgroup-data))
5456 (and (not (and undownloaded
5457 (eq gnus-undownloaded-mark
5458 (gnus-data-mark (car data)))))
5459 (not (gnus-data-unread-p (car data)))))
5460 (setq data (cdr data)))
5462 (goto-char (gnus-data-pos (car data)))
5463 (gnus-data-number (car data))))))
5464 (gnus-summary-position-point)))
5466 (defun gnus-summary-next-subject (n &optional unread dont-display)
5467 "Go to next N'th summary line.
5468 If N is negative, go to the previous N'th subject line.
5469 If UNREAD is non-nil, only unread articles are selected.
5470 The difference between N and the actual number of steps taken is
5473 (let ((backward (< n 0))
5477 (gnus-summary-find-prev unread)
5478 (gnus-summary-find-next unread)))
5479 (gnus-summary-show-thread)
5482 (gnus-message 7 "No more%s articles"
5483 (if unread " unread" "")))
5484 (unless dont-display
5485 (gnus-summary-recenter)
5486 (gnus-summary-position-point))
5489 (defun gnus-summary-next-unread-subject (n)
5490 "Go to next N'th unread summary line."
5492 (gnus-summary-next-subject n t))
5494 (defun gnus-summary-prev-subject (n &optional unread)
5495 "Go to previous N'th summary line.
5496 If optional argument UNREAD is non-nil, only unread article is selected."
5498 (gnus-summary-next-subject (- n) unread))
5500 (defun gnus-summary-prev-unread-subject (n)
5501 "Go to previous N'th unread summary line."
5503 (gnus-summary-next-subject (- n) t))
5505 (defun gnus-summary-goto-subject (article &optional force silent)
5506 "Go the subject line of ARTICLE.
5507 If FORCE, also allow jumping to articles not currently shown."
5508 (interactive "nArticle number: ")
5510 (data (gnus-data-find article)))
5511 ;; We read in the article if we have to.
5514 (gnus-summary-insert-subject
5516 (if (or (numberp force) (vectorp force)) force)
5518 (setq data (gnus-data-find article)))
5523 (gnus-message 3 "Can't find article %d" article))
5525 (goto-char (gnus-data-pos data))
5526 (gnus-summary-position-point)
5529 ;; Walking around summary lines with displaying articles.
5531 (defun gnus-summary-expand-window (&optional arg)
5532 "Make the summary buffer take up the entire Emacs frame.
5533 Given a prefix, will force an `article' buffer configuration."
5536 (gnus-configure-windows 'article 'force)
5537 (gnus-configure-windows 'summary 'force)))
5539 (defun gnus-summary-display-article (article &optional all-header)
5540 "Display ARTICLE in article buffer."
5541 (gnus-set-global-variables)
5545 (if gnus-summary-display-article-function
5546 (funcall gnus-summary-display-article-function article all-header)
5547 (gnus-article-prepare article all-header))
5548 (gnus-run-hooks 'gnus-select-article-hook)
5549 (when (and gnus-current-article
5550 (not (zerop gnus-current-article)))
5551 (gnus-summary-goto-subject gnus-current-article))
5552 (gnus-summary-recenter)
5553 (when (and gnus-use-trees gnus-show-threads)
5554 (gnus-possibly-generate-tree article)
5555 (gnus-highlight-selected-tree article))
5556 ;; Successfully display article.
5557 (gnus-article-set-window-start
5558 (cdr (assq article gnus-newsgroup-bookmarks))))))
5560 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5561 "Select the current article.
5562 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5563 non-nil, the article will be re-fetched even if it already present in
5564 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5566 ;; Make sure we are in the summary buffer to work around bbdb bug.
5567 (unless (eq major-mode 'gnus-summary-mode)
5568 (set-buffer gnus-summary-buffer))
5569 (let ((article (or article (gnus-summary-article-number)))
5570 (all-headers (not (not all-headers))) ;Must be T or NIL.
5571 gnus-summary-display-article-function
5574 (gnus-summary-article-pseudo-p article)
5575 (error "This is a pseudo-article"))
5578 (set-buffer gnus-summary-buffer)
5579 (if (or (and gnus-single-article-buffer
5580 (or (null gnus-current-article)
5581 (null gnus-article-current)
5582 (null (get-buffer gnus-article-buffer))
5583 (not (eq article (cdr gnus-article-current)))
5584 (not (equal (car gnus-article-current)
5585 gnus-newsgroup-name))))
5586 (and (not gnus-single-article-buffer)
5587 (or (null gnus-current-article)
5588 (not (eq gnus-current-article article))))
5590 ;; The requested article is different from the current article.
5592 (gnus-summary-display-article article all-headers)
5594 (when (or all-headers gnus-show-all-headers)
5595 (gnus-article-show-all-headers))
5598 (gnus-article-set-window-start
5599 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5601 (defun gnus-summary-set-current-mark (&optional current-mark)
5602 "Obsolete function."
5605 (defun gnus-summary-next-article (&optional unread subject backward push)
5606 "Select the next article.
5607 If UNREAD, only unread articles are selected.
5608 If SUBJECT, only articles with SUBJECT are selected.
5609 If BACKWARD, the previous article is selected instead of the next."
5612 ;; Is there such an article?
5613 ((and (gnus-summary-search-forward unread subject backward)
5614 (or (gnus-summary-display-article (gnus-summary-article-number))
5615 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5616 (gnus-summary-position-point))
5617 ;; If not, we try the first unread, if that is wanted.
5619 gnus-auto-select-same
5620 (gnus-summary-first-unread-article))
5621 (gnus-summary-position-point)
5622 (gnus-message 6 "Wrapped"))
5623 ;; Try to get next/previous article not displayed in this group.
5624 ((and gnus-auto-extend-newsgroup
5625 (not unread) (not subject))
5626 (gnus-summary-goto-article
5627 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5628 nil (count-lines (point-min) (point))))
5629 ;; Go to next/previous group.
5631 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5632 (gnus-summary-jump-to-group gnus-newsgroup-name))
5633 (let ((cmd last-command-char)
5636 (set-buffer gnus-group-buffer)
5639 (if (eq gnus-keep-same-level 'best)
5640 (gnus-summary-best-group gnus-newsgroup-name)
5641 (gnus-summary-search-group backward gnus-keep-same-level))))
5642 ;; For some reason, the group window gets selected. We change
5644 (select-window (get-buffer-window (current-buffer)))
5645 ;; Select next unread newsgroup automagically.
5647 ((or (not gnus-auto-select-next)
5649 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5650 ((or (eq gnus-auto-select-next 'quietly)
5651 (and (eq gnus-auto-select-next 'slightly-quietly)
5653 (and (eq gnus-auto-select-next 'almost-quietly)
5654 (gnus-summary-last-article-p)))
5656 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5658 (gnus-message 7 "No more%s articles (%s)..."
5659 (if unread " unread" "")
5660 (if group (concat "selecting " group)
5662 (gnus-summary-next-group nil group backward)))
5664 (when (gnus-key-press-event-p last-input-event)
5665 (gnus-summary-walk-group-buffer
5666 gnus-newsgroup-name cmd unread backward point))))))))
5668 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5669 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5670 (?\C-p (gnus-group-prev-unread-group 1))))
5671 (cursor-in-echo-area t)
5672 keve key group ended)
5674 (set-buffer gnus-group-buffer)
5677 (if (eq gnus-keep-same-level 'best)
5678 (gnus-summary-best-group gnus-newsgroup-name)
5679 (gnus-summary-search-group backward gnus-keep-same-level))))
5682 5 "No more%s articles%s" (if unread " unread" "")
5684 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5685 (format " (Type %s for %s [%s])"
5686 (single-key-description cmd) group
5687 (car (gnus-gethash group gnus-newsrc-hashtb)))
5688 (format " (Type %s to exit %s)"
5689 (single-key-description cmd)
5690 gnus-newsgroup-name)))
5691 ;; Confirm auto selection.
5692 (setq key (car (setq keve (gnus-read-event-char))))
5695 ((assq key keystrokes)
5696 (let ((obuf (current-buffer)))
5697 (switch-to-buffer gnus-group-buffer)
5699 (gnus-group-jump-to-group group))
5700 (eval (cadr (assq key keystrokes)))
5701 (setq group (gnus-group-group-name))
5702 (switch-to-buffer obuf))
5706 (gnus-ephemeral-group-p gnus-newsgroup-name))
5708 (gnus-summary-next-group nil group backward)))
5710 (push (cdr keve) unread-command-events))))))
5712 (defun gnus-summary-next-unread-article ()
5713 "Select unread article after current one."
5715 (gnus-summary-next-article
5716 (or (not (eq gnus-summary-goto-unread 'never))
5717 (gnus-summary-last-article-p (gnus-summary-article-number)))
5718 (and gnus-auto-select-same
5719 (gnus-summary-article-subject))))
5721 (defun gnus-summary-prev-article (&optional unread subject)
5722 "Select the article after the current one.
5723 If UNREAD is non-nil, only unread articles are selected."
5725 (gnus-summary-next-article unread subject t))
5727 (defun gnus-summary-prev-unread-article ()
5728 "Select unread article before current one."
5730 (gnus-summary-prev-article
5731 (or (not (eq gnus-summary-goto-unread 'never))
5732 (gnus-summary-first-article-p (gnus-summary-article-number)))
5733 (and gnus-auto-select-same
5734 (gnus-summary-article-subject))))
5736 (defun gnus-summary-next-page (&optional lines circular)
5737 "Show next page of the selected article.
5738 If at the end of the current article, select the next article.
5739 LINES says how many lines should be scrolled up.
5741 If CIRCULAR is non-nil, go to the start of the article instead of
5742 selecting the next article when reaching the end of the current
5745 (setq gnus-summary-buffer (current-buffer))
5746 (gnus-set-global-variables)
5747 (let ((article (gnus-summary-article-number))
5748 (article-window (get-buffer-window gnus-article-buffer t))
5750 ;; If the buffer is empty, we have no article.
5752 (error "No article to select"))
5753 (gnus-configure-windows 'article)
5754 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5755 (if (and (eq gnus-summary-goto-unread 'never)
5756 (not (gnus-summary-last-article-p article)))
5757 (gnus-summary-next-article)
5758 (gnus-summary-next-unread-article))
5759 (if (or (null gnus-current-article)
5760 (null gnus-article-current)
5761 (/= article (cdr gnus-article-current))
5762 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5763 ;; Selected subject is different from current article's.
5764 (gnus-summary-display-article article)
5765 (when article-window
5766 (gnus-eval-in-buffer-window gnus-article-buffer
5767 (setq endp (gnus-article-next-page lines)))
5770 (gnus-summary-beginning-of-article))
5772 (gnus-message 3 "End of message"))
5774 (if (and (eq gnus-summary-goto-unread 'never)
5775 (not (gnus-summary-last-article-p article)))
5776 (gnus-summary-next-article)
5777 (gnus-summary-next-unread-article))))))))
5778 (gnus-summary-recenter)
5779 (gnus-summary-position-point)))
5781 (defun gnus-summary-prev-page (&optional lines move)
5782 "Show previous page of selected article.
5783 Argument LINES specifies lines to be scrolled down.
5784 If MOVE, move to the previous unread article if point is at
5785 the beginning of the buffer."
5787 (let ((article (gnus-summary-article-number))
5788 (article-window (get-buffer-window gnus-article-buffer t))
5790 (gnus-configure-windows 'article)
5791 (if (or (null gnus-current-article)
5792 (null gnus-article-current)
5793 (/= article (cdr gnus-article-current))
5794 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5795 ;; Selected subject is different from current article's.
5796 (gnus-summary-display-article article)
5797 (gnus-summary-recenter)
5798 (when article-window
5799 (gnus-eval-in-buffer-window gnus-article-buffer
5800 (setq endp (gnus-article-prev-page lines)))
5801 (when (and move endp)
5803 (gnus-message 3 "Beginning of message"))
5805 (if (and (eq gnus-summary-goto-unread 'never)
5806 (not (gnus-summary-first-article-p article)))
5807 (gnus-summary-prev-article)
5808 (gnus-summary-prev-unread-article))))))))
5809 (gnus-summary-position-point))
5811 (defun gnus-summary-prev-page-or-article (&optional lines)
5812 "Show previous page of selected article.
5813 Argument LINES specifies lines to be scrolled down.
5814 If at the beginning of the article, go to the next article."
5816 (gnus-summary-prev-page lines t))
5818 (defun gnus-summary-scroll-up (lines)
5819 "Scroll up (or down) one line current article.
5820 Argument LINES specifies lines to be scrolled up (or down if negative)."
5822 (gnus-configure-windows 'article)
5823 (gnus-summary-show-thread)
5824 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5825 (gnus-eval-in-buffer-window gnus-article-buffer
5827 (when (gnus-article-next-page lines)
5828 (gnus-message 3 "End of message")))
5830 (gnus-article-prev-page (- lines))))))
5831 (gnus-summary-recenter)
5832 (gnus-summary-position-point))
5834 (defun gnus-summary-scroll-down (lines)
5835 "Scroll down (or up) one line current article.
5836 Argument LINES specifies lines to be scrolled down (or up if negative)."
5838 (gnus-summary-scroll-up (- lines)))
5840 (defun gnus-summary-next-same-subject ()
5841 "Select next article which has the same subject as current one."
5843 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5845 (defun gnus-summary-prev-same-subject ()
5846 "Select previous article which has the same subject as current one."
5848 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5850 (defun gnus-summary-next-unread-same-subject ()
5851 "Select next unread article which has the same subject as current one."
5853 (gnus-summary-next-article t (gnus-summary-article-subject)))
5855 (defun gnus-summary-prev-unread-same-subject ()
5856 "Select previous unread article which has the same subject as current one."
5858 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5860 (defun gnus-summary-first-unread-article ()
5861 "Select the first unread article.
5862 Return nil if there are no unread articles."
5865 (when (gnus-summary-first-subject t)
5866 (gnus-summary-show-thread)
5867 (gnus-summary-first-subject t)
5868 (gnus-summary-display-article (gnus-summary-article-number)))
5869 (gnus-summary-position-point)))
5871 (defun gnus-summary-first-article ()
5872 "Select the first article.
5873 Return nil if there are no articles."
5876 (when (gnus-summary-first-subject)
5877 (gnus-summary-show-thread)
5878 (gnus-summary-first-subject)
5879 (gnus-summary-display-article (gnus-summary-article-number)))
5880 (gnus-summary-position-point)))
5882 (defun gnus-summary-best-unread-article ()
5883 "Select the unread article with the highest score."
5885 (let ((best -1000000)
5886 (data gnus-newsgroup-data)
5889 (and (gnus-data-unread-p (car data))
5891 (gnus-summary-article-score (gnus-data-number (car data))))
5894 article (gnus-data-number (car data))))
5895 (setq data (cdr data)))
5898 (gnus-summary-goto-article article)
5899 (error "No unread articles"))
5900 (gnus-summary-position-point))))
5902 (defun gnus-summary-last-subject ()
5903 "Go to the last displayed subject line in the group."
5904 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5906 (gnus-summary-goto-subject article))))
5908 (defun gnus-summary-goto-article (article &optional all-headers force)
5909 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5910 If ALL-HEADERS is non-nil, no header lines are hidden.
5911 If FORCE, go to the article even if it isn't displayed. If FORCE
5912 is a number, it is the line the article is to be displayed on."
5916 "Article number or Message-ID: "
5917 (mapcar (lambda (number) (list (int-to-string number)))
5918 gnus-newsgroup-limit))
5922 (if (and (stringp article)
5923 (string-match "@" article))
5924 (gnus-summary-refer-article article)
5925 (when (stringp article)
5926 (setq article (string-to-number article)))
5927 (if (gnus-summary-goto-subject article force)
5928 (gnus-summary-display-article article all-headers)
5929 (gnus-message 4 "Couldn't go to article %s" article) nil))
5930 (gnus-summary-position-point)))
5932 (defun gnus-summary-goto-last-article ()
5933 "Go to the previously read article."
5936 (when gnus-last-article
5937 (gnus-summary-goto-article gnus-last-article nil t))
5938 (gnus-summary-position-point)))
5940 (defun gnus-summary-pop-article (number)
5941 "Pop one article off the history and go to the previous.
5942 NUMBER articles will be popped off."
5945 (setq gnus-newsgroup-history
5946 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5948 (gnus-summary-goto-article (car to) nil t)
5949 (error "Article history empty")))
5950 (gnus-summary-position-point))
5952 ;; Summary commands and functions for limiting the summary buffer.
5954 (defun gnus-summary-limit-to-articles (n)
5955 "Limit the summary buffer to the next N articles.
5956 If not given a prefix, use the process marked articles instead."
5959 (let ((articles (gnus-summary-work-articles n)))
5960 (setq gnus-newsgroup-processable nil)
5961 (gnus-summary-limit articles))
5962 (gnus-summary-position-point)))
5964 (defun gnus-summary-pop-limit (&optional total)
5965 "Restore the previous limit.
5966 If given a prefix, remove all limits."
5969 (setq gnus-newsgroup-limits
5970 (list (mapcar (lambda (h) (mail-header-number h))
5971 gnus-newsgroup-headers))))
5972 (unless gnus-newsgroup-limits
5973 (error "No limit to pop"))
5975 (gnus-summary-limit nil 'pop)
5976 (gnus-summary-position-point)))
5978 (defun gnus-summary-limit-to-subject (subject &optional header)
5979 "Limit the summary buffer to articles that have subjects that match a regexp."
5980 (interactive "sLimit to subject (regexp): ")
5982 (setq header "subject"))
5983 (when (not (equal "" subject))
5985 (let ((articles (gnus-summary-find-matching
5986 (or header "subject") subject 'all)))
5988 (error "Found no matches for \"%s\"" subject))
5989 (gnus-summary-limit articles))
5990 (gnus-summary-position-point))))
5992 (defun gnus-summary-limit-to-author (from)
5993 "Limit the summary buffer to articles that have authors that match a regexp."
5994 (interactive "sLimit to author (regexp): ")
5995 (gnus-summary-limit-to-subject from "from"))
5997 (defun gnus-summary-limit-to-age (age &optional younger-p)
5998 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5999 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6000 articles that are younger than AGE days."
6001 (interactive "nTime in days: \nP")
6003 (let ((data gnus-newsgroup-data)
6004 (cutoff (days-to-time age))
6005 articles d date is-younger)
6006 (while (setq d (pop data))
6007 (when (and (vectorp (gnus-data-header d))
6008 (setq date (mail-header-date (gnus-data-header d))))
6009 (setq is-younger (time-less-p
6010 (time-since (date-to-time date))
6015 (push (gnus-data-number d) articles))))
6016 (gnus-summary-limit (nreverse articles)))
6017 (gnus-summary-position-point)))
6019 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6021 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6023 (defun gnus-summary-limit-to-unread (&optional all)
6024 "Limit the summary buffer to articles that are not marked as read.
6025 If ALL is non-nil, limit strictly to unread articles."
6028 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6029 (gnus-summary-limit-to-marks
6030 ;; Concat all the marks that say that an article is read and have
6032 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6033 gnus-killed-mark gnus-kill-file-mark
6034 gnus-low-score-mark gnus-expirable-mark
6035 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6036 gnus-duplicate-mark gnus-souped-mark)
6039 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6040 (make-obsolete 'gnus-summary-delete-marked-with
6041 'gnus-summary-limit-exlude-marks)
6043 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6044 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6045 If REVERSE, limit the summary buffer to articles that are marked
6046 with MARKS. MARKS can either be a string of marks or a list of marks.
6047 Returns how many articles were removed."
6048 (interactive "sMarks: ")
6049 (gnus-summary-limit-to-marks marks t))
6051 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6052 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6053 If REVERSE (the prefix), limit the summary buffer to articles that are
6054 not marked with MARKS. MARKS can either be a string of marks or a
6056 Returns how many articles were removed."
6057 (interactive "sMarks: \nP")
6059 (let ((data gnus-newsgroup-data)
6060 (marks (if (listp marks) marks
6061 (append marks nil))) ; Transform to list.
6064 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6065 (memq (gnus-data-mark (car data)) marks))
6066 (push (gnus-data-number (car data)) articles))
6067 (setq data (cdr data)))
6068 (gnus-summary-limit articles))
6069 (gnus-summary-position-point)))
6071 (defun gnus-summary-limit-to-score (&optional score)
6072 "Limit to articles with score at or above SCORE."
6074 (setq score (if score
6075 (prefix-numeric-value score)
6076 (or gnus-summary-default-score 0)))
6077 (let ((data gnus-newsgroup-data)
6080 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6082 (push (gnus-data-number (car data)) articles))
6083 (setq data (cdr data)))
6085 (gnus-summary-limit articles)
6086 (gnus-summary-position-point))))
6088 (defun gnus-summary-limit-include-thread (id)
6089 "Display all the hidden articles that in the current thread."
6090 (interactive (list (mail-header-id (gnus-summary-article-header))))
6091 (let ((articles (gnus-articles-in-thread
6092 (gnus-id-to-thread (gnus-root-id id)))))
6094 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6095 (gnus-summary-position-point))))
6097 (defun gnus-summary-limit-include-dormant ()
6098 "Display all the hidden articles that are marked as dormant.
6099 Note that this command only works on a subset of the articles currently
6100 fetched for this group."
6102 (unless gnus-newsgroup-dormant
6103 (error "There are no dormant articles in this group"))
6105 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6106 (gnus-summary-position-point)))
6108 (defun gnus-summary-limit-exclude-dormant ()
6109 "Hide all dormant articles."
6112 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6113 (gnus-summary-position-point)))
6115 (defun gnus-summary-limit-exclude-childless-dormant ()
6116 "Hide all dormant articles that have no children."
6118 (let ((data (gnus-data-list t))
6119 articles d children)
6120 ;; Find all articles that are either not dormant or have
6122 (while (setq d (pop data))
6123 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6125 (gnus-article-children (gnus-data-number d)))
6128 (when (memq (car children) articles)
6133 (push (gnus-data-number d) articles)))
6136 (gnus-summary-limit articles)
6137 (gnus-summary-position-point))))
6139 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6140 "Mark all unread excluded articles as read.
6141 If ALL, mark even excluded ticked and dormants as read."
6143 (let ((articles (gnus-sorted-complement
6145 (mapcar (lambda (h) (mail-header-number h))
6146 gnus-newsgroup-headers)
6148 (sort gnus-newsgroup-limit '<)))
6150 (setq gnus-newsgroup-unreads
6151 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6153 (setq gnus-newsgroup-dormant nil
6154 gnus-newsgroup-marked nil
6155 gnus-newsgroup-reads
6157 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6158 gnus-newsgroup-reads))
6159 (while (setq article (pop articles))
6160 (unless (or (memq article gnus-newsgroup-dormant)
6161 (memq article gnus-newsgroup-marked))
6162 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6164 (defun gnus-summary-limit (articles &optional pop)
6166 ;; We pop the previous limit off the stack and use that.
6167 (setq articles (car gnus-newsgroup-limits)
6168 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6169 ;; We use the new limit, so we push the old limit on the stack.
6170 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6172 (setq gnus-newsgroup-limit articles)
6173 (let ((total (length gnus-newsgroup-data))
6174 (data (gnus-data-find-list (gnus-summary-article-number)))
6175 (gnus-summary-mark-below nil) ; Inhibit this.
6177 ;; This will do all the work of generating the new summary buffer
6178 ;; according to the new limit.
6179 (gnus-summary-prepare)
6180 ;; Hide any threads, possibly.
6181 (and gnus-show-threads
6182 gnus-thread-hide-subtree
6183 (gnus-summary-hide-all-threads))
6184 ;; Try to return to the article you were at, or one in the
6187 ;; We try to find some article after the current one.
6189 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6192 (setq data (cdr data))))
6194 ;; If there is no data, that means that we were after the last
6195 ;; article. The same goes when we can't find any articles
6196 ;; after the current one.
6197 (goto-char (point-max))
6198 (gnus-summary-find-prev))
6199 (gnus-set-mode-line 'summary)
6200 ;; We return how many articles were removed from the summary
6201 ;; buffer as a result of the new limit.
6202 (- total (length gnus-newsgroup-data))))
6204 (defsubst gnus-invisible-cut-children (threads)
6207 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6212 (defsubst gnus-cut-thread (thread)
6213 "Go forwards in the thread until we find an article that we want to display."
6214 (when (or (eq gnus-fetch-old-headers 'some)
6215 (eq gnus-fetch-old-headers 'invisible)
6216 (eq gnus-build-sparse-threads 'some)
6217 (eq gnus-build-sparse-threads 'more))
6218 ;; Deal with old-fetched headers and sparse threads.
6222 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6223 (gnus-summary-article-ancient-p
6224 (mail-header-number (car thread))))
6225 (if (or (<= (length (cdr thread)) 1)
6226 (eq gnus-fetch-old-headers 'invisible))
6227 (setq gnus-newsgroup-limit
6228 (delq (mail-header-number (car thread))
6229 gnus-newsgroup-limit)
6230 thread (cadr thread))
6231 (when (gnus-invisible-cut-children (cdr thread))
6232 (let ((th (cdr thread)))
6234 (if (memq (mail-header-number (caar th))
6235 gnus-newsgroup-limit)
6236 (setq thread (car th)
6238 (setq th (cdr th))))))))))
6241 (defun gnus-cut-threads (threads)
6242 "Cut off all uninteresting articles from the beginning of threads."
6243 (when (or (eq gnus-fetch-old-headers 'some)
6244 (eq gnus-fetch-old-headers 'invisible)
6245 (eq gnus-build-sparse-threads 'some)
6246 (eq gnus-build-sparse-threads 'more))
6249 (setcar th (gnus-cut-thread (car th)))
6250 (setq th (cdr th)))))
6251 ;; Remove nixed out threads.
6254 (defun gnus-summary-initial-limit (&optional show-if-empty)
6255 "Figure out what the initial limit is supposed to be on group entry.
6256 This entails weeding out unwanted dormants, low-scored articles,
6257 fetch-old-headers verbiage, and so on."
6258 ;; Most groups have nothing to remove.
6259 (if (or gnus-inhibit-limiting
6260 (and (null gnus-newsgroup-dormant)
6261 (not (eq gnus-fetch-old-headers 'some))
6262 (not (eq gnus-fetch-old-headers 'invisible))
6263 (null gnus-summary-expunge-below)
6264 (not (eq gnus-build-sparse-threads 'some))
6265 (not (eq gnus-build-sparse-threads 'more))
6266 (null gnus-thread-expunge-below)
6267 (not gnus-use-nocem)))
6269 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6270 (setq gnus-newsgroup-limit nil)
6273 (unless (car (symbol-value node))
6274 ;; These threads have no parents -- they are roots.
6275 (let ((nodes (cdr (symbol-value node)))
6278 (if (and gnus-thread-expunge-below
6279 (< (gnus-thread-total-score (car nodes))
6280 gnus-thread-expunge-below))
6281 (gnus-expunge-thread (pop nodes))
6282 (setq thread (pop nodes))
6283 (gnus-summary-limit-children thread))))))
6284 gnus-newsgroup-dependencies)
6285 ;; If this limitation resulted in an empty group, we might
6286 ;; pop the previous limit and use it instead.
6287 (when (and (not gnus-newsgroup-limit)
6289 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6290 gnus-newsgroup-limit))
6292 (defun gnus-summary-limit-children (thread)
6293 "Return 1 if this subthread is visible and 0 if it is not."
6294 ;; First we get the number of visible children to this thread. This
6295 ;; is done by recursing down the thread using this function, so this
6296 ;; will really go down to a leaf article first, before slowly
6297 ;; working its way up towards the root.
6301 (apply '+ (mapcar 'gnus-summary-limit-children
6304 (number (mail-header-number (car thread)))
6307 (not (memq number gnus-newsgroup-marked))
6309 ;; If this article is dormant and has absolutely no visible
6310 ;; children, then this article isn't visible.
6311 (and (memq number gnus-newsgroup-dormant)
6313 ;; If this is "fetch-old-headered" and there is no
6314 ;; visible children, then we don't want this article.
6315 (and (eq gnus-fetch-old-headers 'some)
6316 (gnus-summary-article-ancient-p number)
6318 ;; If this is "fetch-old-headered" and `invisible', then
6319 ;; we don't want this article.
6320 (and (eq gnus-fetch-old-headers 'invisible)
6321 (gnus-summary-article-ancient-p number))
6322 ;; If this is a sparsely inserted article with no children,
6323 ;; we don't want it.
6324 (and (eq gnus-build-sparse-threads 'some)
6325 (gnus-summary-article-sparse-p number)
6327 ;; If we use expunging, and this article is really
6328 ;; low-scored, then we don't want this article.
6329 (when (and gnus-summary-expunge-below
6331 (or (cdr (assq number gnus-newsgroup-scored))
6332 gnus-summary-default-score))
6333 gnus-summary-expunge-below))
6334 ;; We increase the expunge-tally here, but that has
6335 ;; nothing to do with the limits, really.
6336 (incf gnus-newsgroup-expunged-tally)
6337 ;; We also mark as read here, if that's wanted.
6338 (when (and gnus-summary-mark-below
6339 (< score gnus-summary-mark-below))
6340 (setq gnus-newsgroup-unreads
6341 (delq number gnus-newsgroup-unreads))
6342 (if gnus-newsgroup-auto-expire
6343 (push number gnus-newsgroup-expirable)
6344 (push (cons number gnus-low-score-mark)
6345 gnus-newsgroup-reads)))
6347 ;; Check NoCeM things.
6348 (if (and gnus-use-nocem
6349 (gnus-nocem-unwanted-article-p
6350 (mail-header-id (car thread))))
6352 (setq gnus-newsgroup-unreads
6353 (delq number gnus-newsgroup-unreads))
6355 ;; Nope, invisible article.
6357 ;; Ok, this article is to be visible, so we add it to the limit
6359 (push number gnus-newsgroup-limit)
6362 (defun gnus-expunge-thread (thread)
6363 "Mark all articles in THREAD as read."
6364 (let* ((number (mail-header-number (car thread))))
6365 (incf gnus-newsgroup-expunged-tally)
6366 ;; We also mark as read here, if that's wanted.
6367 (setq gnus-newsgroup-unreads
6368 (delq number gnus-newsgroup-unreads))
6369 (if gnus-newsgroup-auto-expire
6370 (push number gnus-newsgroup-expirable)
6371 (push (cons number gnus-low-score-mark)
6372 gnus-newsgroup-reads)))
6373 ;; Go recursively through all subthreads.
6374 (mapcar 'gnus-expunge-thread (cdr thread)))
6376 ;; Summary article oriented commands
6378 (defun gnus-summary-refer-parent-article (n)
6379 "Refer parent article N times.
6380 If N is negative, go to ancestor -N instead.
6381 The difference between N and the number of articles fetched is returned."
6385 (when (not (natnump n))
6390 (setq header (gnus-summary-article-header))
6391 (if (and (eq (mail-header-number header)
6392 (cdr gnus-article-current))
6393 (equal gnus-newsgroup-name
6394 (car gnus-article-current)))
6395 ;; If we try to find the parent of the currently
6396 ;; displayed article, then we take a look at the actual
6397 ;; References header, since this is slightly more
6398 ;; reliable than the References field we got from the
6401 (set-buffer gnus-original-article-buffer)
6402 (nnheader-narrow-to-headers)
6403 (unless (setq ref (message-fetch-field "references"))
6404 (setq ref (message-fetch-field "in-reply-to")))
6407 ;; It's not the current article, so we take a bet on
6408 ;; the value we got from the server.
6409 (mail-header-references header)))
6411 (not (equal ref "")))
6412 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6413 (gnus-message 1 "Couldn't find parent"))
6414 (gnus-message 1 "No references in article %d"
6415 (gnus-summary-article-number))
6418 (gnus-summary-position-point)
6421 (defun gnus-summary-refer-references ()
6422 "Fetch all articles mentioned in the References header.
6423 Return the number of articles fetched."
6425 (let ((ref (mail-header-references (gnus-summary-article-header)))
6426 (current (gnus-summary-article-number))
6430 (error "No References in the current article")
6431 ;; For each Message-ID in the References header...
6432 (while (string-match "<[^>]*>" ref)
6434 ;; ... fetch that article.
6435 (gnus-summary-refer-article
6436 (prog1 (match-string 0 ref)
6437 (setq ref (substring ref (match-end 0))))))
6438 (gnus-summary-goto-subject current)
6439 (gnus-summary-position-point)
6442 (defun gnus-summary-refer-thread (&optional limit)
6443 "Fetch all articles in the current thread.
6444 If LIMIT (the numerical prefix), fetch that many old headers instead
6445 of what's specified by the `gnus-refer-thread-limit' variable."
6447 (let ((id (mail-header-id (gnus-summary-article-header)))
6448 (limit (if limit (prefix-numeric-value limit)
6449 gnus-refer-thread-limit)))
6450 ;; We want to fetch LIMIT *old* headers, but we also have to
6451 ;; re-fetch all the headers in the current buffer, because many of
6452 ;; them may be undisplayed. So we adjust LIMIT.
6453 (when (numberp limit)
6454 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6455 (unless (eq gnus-fetch-old-headers 'invisible)
6456 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6457 ;; Retrieve the headers and read them in.
6458 (if (eq (gnus-retrieve-headers
6459 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6461 (gnus-build-all-threads)
6462 (error "Can't fetch thread from backends that don't support NOV"))
6463 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6464 (gnus-summary-limit-include-thread id)))
6466 (defun gnus-summary-refer-article (message-id &optional arg)
6467 "Fetch an article specified by MESSAGE-ID.
6468 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6469 or `gnus-select-method', no matter what backend the article comes from."
6470 (interactive "sMessage-ID: \nP")
6471 (when (and (stringp message-id)
6472 (not (zerop (length message-id))))
6473 ;; Construct the correct Message-ID if necessary.
6474 ;; Suggested by tale@pawl.rpi.edu.
6475 (unless (string-match "^<" message-id)
6476 (setq message-id (concat "<" message-id)))
6477 (unless (string-match ">$" message-id)
6478 (setq message-id (concat message-id ">")))
6479 (let* ((header (gnus-id-to-header message-id))
6481 (gnus-summary-article-sparse-p
6482 (mail-header-number header))
6483 (memq (mail-header-number header)
6484 gnus-newsgroup-limit))))
6486 ;; If the article is present in the buffer we just go to it.
6488 (or (not (gnus-summary-article-sparse-p
6489 (mail-header-number header)))
6492 (gnus-summary-goto-article
6493 (mail-header-number header) nil t)
6495 (gnus-summary-update-article (mail-header-number header)))))
6497 ;; We fetch the article
6498 (let ((gnus-override-method
6499 (cond ((gnus-news-group-p gnus-newsgroup-name)
6500 gnus-refer-article-method)
6502 (or gnus-refer-article-method gnus-select-method))
6505 ;; Start the special refer-article method, if necessary.
6506 (when (and gnus-refer-article-method
6507 (gnus-news-group-p gnus-newsgroup-name))
6508 (gnus-check-server gnus-refer-article-method))
6509 ;; Fetch the header, and display the article.
6510 (if (setq number (gnus-summary-insert-subject message-id))
6511 (gnus-summary-select-article nil nil nil number)
6512 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6514 (defun gnus-summary-edit-parameters ()
6515 "Edit the group parameters of the current group."
6517 (gnus-group-edit-group gnus-newsgroup-name 'params))
6519 (defun gnus-summary-enter-digest-group (&optional force)
6520 "Enter an nndoc group based on the current article.
6521 If FORCE, force a digest interpretation. If not, try
6522 to guess what the document format is."
6524 (let ((conf gnus-current-window-configuration))
6526 (gnus-summary-select-article))
6527 (setq gnus-current-window-configuration conf)
6528 (let* ((name (format "%s-%d"
6529 (gnus-group-prefixed-name
6530 gnus-newsgroup-name (list 'nndoc ""))
6532 (set-buffer gnus-summary-buffer)
6533 gnus-current-article)))
6534 (ogroup gnus-newsgroup-name)
6535 (params (append (gnus-info-params (gnus-get-info ogroup))
6536 (list (cons 'to-group ogroup))
6537 (list (cons 'save-article-group ogroup))))
6538 (case-fold-search t)
6539 (buf (current-buffer))
6542 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6543 (insert-buffer-substring gnus-original-article-buffer)
6544 ;; Remove lines that may lead nndoc to misinterpret the
6547 (goto-char (point-min))
6548 (or (search-forward "\n\n" nil t) (point)))
6549 (goto-char (point-min))
6550 (delete-matching-lines "^\\(Path\\):\\|^From ")
6553 (if (gnus-group-read-ephemeral-group
6554 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6556 ,(if force 'digest 'guess))) t)
6557 ;; Make all postings to this group go to the parent group.
6558 (nconc (gnus-info-params (gnus-get-info name))
6560 ;; Couldn't select this doc group.
6561 (switch-to-buffer buf)
6562 (gnus-set-global-variables)
6563 (gnus-configure-windows 'summary)
6564 (gnus-message 3 "Article couldn't be entered?"))
6565 (kill-buffer dig)))))
6567 (defun gnus-summary-read-document (n)
6568 "Open a new group based on the current article(s).
6569 This will allow you to read digests and other similar
6570 documents as newsgroups.
6571 Obeys the standard process/prefix convention."
6573 (let* ((articles (gnus-summary-work-articles n))
6574 (ogroup gnus-newsgroup-name)
6575 (params (append (gnus-info-params (gnus-get-info ogroup))
6576 (list (cons 'to-group ogroup))))
6577 article group egroup groups vgroup)
6578 (while (setq article (pop articles))
6579 (setq group (format "%s-%d" gnus-newsgroup-name article))
6580 (gnus-summary-remove-process-mark article)
6581 (when (gnus-summary-display-article article)
6584 (insert-buffer-substring gnus-original-article-buffer)
6585 ;; Remove some headers that may lead nndoc to make
6587 (message-narrow-to-head)
6588 (goto-char (point-min))
6589 (delete-matching-lines "^\\(Path\\):\\|^From ")
6592 (gnus-group-read-ephemeral-group
6593 group `(nndoc ,group (nndoc-address ,(current-buffer))
6594 (nndoc-article-type guess))
6597 ;; Make all postings to this group go to the parent group.
6598 (nconc (gnus-info-params (gnus-get-info egroup))
6600 (push egroup groups))
6601 ;; Couldn't select this doc group.
6602 (gnus-error 3 "Article couldn't be entered"))))))
6603 ;; Now we have selected all the documents.
6606 (error "None of the articles could be interpreted as documents"))
6607 ((gnus-group-read-ephemeral-group
6608 (setq vgroup (format
6609 "nnvirtual:%s-%s" gnus-newsgroup-name
6610 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6611 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6613 (cons (current-buffer) 'summary)))
6615 (error "Couldn't select virtual nndoc group")))))
6617 (defun gnus-summary-isearch-article (&optional regexp-p)
6618 "Do incremental search forward on the current article.
6619 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6621 (gnus-summary-select-article)
6622 (gnus-configure-windows 'article)
6623 (gnus-eval-in-buffer-window gnus-article-buffer
6626 (isearch-forward regexp-p))))
6628 (defun gnus-summary-search-article-forward (regexp &optional backward)
6629 "Search for an article containing REGEXP forward.
6630 If BACKWARD, search backward instead."
6633 (format "Search article %s (regexp%s): "
6634 (if current-prefix-arg "backward" "forward")
6635 (if gnus-last-search-regexp
6636 (concat ", default " gnus-last-search-regexp)
6638 current-prefix-arg))
6639 (if (string-equal regexp "")
6640 (setq regexp (or gnus-last-search-regexp ""))
6641 (setq gnus-last-search-regexp regexp))
6642 (if (gnus-summary-search-article regexp backward)
6643 (gnus-summary-show-thread)
6644 (error "Search failed: \"%s\"" regexp)))
6646 (defun gnus-summary-search-article-backward (regexp)
6647 "Search for an article containing REGEXP backward."
6650 (format "Search article backward (regexp%s): "
6651 (if gnus-last-search-regexp
6652 (concat ", default " gnus-last-search-regexp)
6654 (gnus-summary-search-article-forward regexp 'backward))
6656 (defun gnus-summary-search-article (regexp &optional backward)
6657 "Search for an article containing REGEXP.
6658 Optional argument BACKWARD means do search for backward.
6659 `gnus-select-article-hook' is not called during the search."
6660 ;; We have to require this here to make sure that the following
6661 ;; dynamic binding isn't shadowed by autoloading.
6662 (require 'gnus-async)
6663 (let ((gnus-select-article-hook nil) ;Disable hook.
6664 (gnus-article-display-hook nil)
6665 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6666 (gnus-use-article-prefetch nil)
6667 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6668 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6669 (sum (current-buffer))
6672 (gnus-save-hidden-threads
6673 (gnus-summary-select-article)
6674 (set-buffer gnus-article-buffer)
6678 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6680 (re-search-backward regexp nil t)
6681 (re-search-forward regexp nil t))
6682 ;; We found the regexp.
6687 (get-buffer-window (current-buffer))
6691 (setq point (point)))
6692 ;; We didn't find it, so we go to the next article.
6695 (while (eq found 'not)
6696 (if (not (if backward (gnus-summary-find-prev)
6697 (gnus-summary-find-next)))
6698 ;; No more articles.
6700 ;; Select the next article and adjust point.
6701 (unless (gnus-summary-article-sparse-p
6702 (gnus-summary-article-number))
6704 (gnus-summary-select-article)
6705 (set-buffer gnus-article-buffer)
6707 (goto-char (if backward (point-max) (point-min))))))))
6708 (gnus-message 7 ""))
6709 ;; Return whether we found the regexp.
6710 (when (eq found 'found)
6712 (gnus-summary-show-thread)
6713 (gnus-summary-goto-subject gnus-current-article)
6714 (gnus-summary-position-point)
6717 (defun gnus-summary-find-matching (header regexp &optional backward unread
6719 "Return a list of all articles that match REGEXP on HEADER.
6720 The search stars on the current article and goes forwards unless
6721 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6722 If UNREAD is non-nil, only unread articles will
6723 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6724 in the comparisons."
6725 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6726 (gnus-data-find-list
6727 (gnus-summary-article-number) (gnus-data-list backward))))
6728 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6729 (case-fold-search (not not-case-fold))
6731 (unless (fboundp (intern (concat "mail-header-" header)))
6732 (error "%s is not a valid header" header))
6735 (and (or (not unread) ; We want all articles...
6736 (gnus-data-unread-p d)) ; Or just unreads.
6737 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6738 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6739 (push (gnus-data-number d) articles)) ; Success!
6740 (setq data (cdr data)))
6741 (nreverse articles)))
6743 (defun gnus-summary-execute-command (header regexp command &optional backward)
6744 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6745 If HEADER is an empty string (or nil), the match is done on the entire
6746 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6748 (list (let ((completion-ignore-case t))
6751 (mapcar (lambda (string) (list string))
6752 '("Number" "Subject" "From" "Lines" "Date"
6753 "Message-ID" "Xref" "References" "Body"))
6754 nil 'require-match))
6755 (read-string "Regexp: ")
6756 (read-key-sequence "Command: ")
6757 current-prefix-arg))
6758 (when (equal header "Body")
6760 ;; Hidden thread subtrees must be searched as well.
6761 (gnus-summary-show-all-threads)
6762 ;; We don't want to change current point nor window configuration.
6764 (save-window-excursion
6765 (gnus-message 6 "Executing %s..." (key-description command))
6766 ;; We'd like to execute COMMAND interactively so as to give arguments.
6767 (gnus-execute header regexp
6768 `(call-interactively ',(key-binding command))
6770 (gnus-message 6 "Executing %s...done" (key-description command)))))
6772 (defun gnus-summary-beginning-of-article ()
6773 "Scroll the article back to the beginning."
6775 (gnus-summary-select-article)
6776 (gnus-configure-windows 'article)
6777 (gnus-eval-in-buffer-window gnus-article-buffer
6779 (goto-char (point-min))
6780 (when gnus-page-broken
6781 (gnus-narrow-to-page))))
6783 (defun gnus-summary-end-of-article ()
6784 "Scroll to the end of the article."
6786 (gnus-summary-select-article)
6787 (gnus-configure-windows 'article)
6788 (gnus-eval-in-buffer-window gnus-article-buffer
6790 (goto-char (point-max))
6792 (when gnus-page-broken
6793 (gnus-narrow-to-page))))
6795 (defun gnus-summary-print-article (&optional filename n)
6796 "Generate and print a PostScript image of the N next (mail) articles.
6798 If N is negative, print the N previous articles. If N is nil and articles
6799 have been marked with the process mark, print these instead.
6801 If the optional second argument FILENAME is nil, send the image to the
6802 printer. If FILENAME is a string, save the PostScript image in a file with
6803 that name. If FILENAME is a number, prompt the user for the name of the file
6805 (interactive (list (ps-print-preprint current-prefix-arg)
6806 current-prefix-arg))
6807 (dolist (article (gnus-summary-work-articles n))
6808 (gnus-summary-select-article nil nil 'pseudo article)
6809 (gnus-eval-in-buffer-window gnus-article-buffer
6810 (let ((buffer (generate-new-buffer " *print*")))
6813 (copy-to-buffer buffer (point-min) (point-max))
6815 (gnus-article-delete-invisible-text)
6816 (let ((ps-left-header
6819 (mail-header-subject gnus-current-headers) ")")
6821 (mail-header-from gnus-current-headers) ")")))
6824 "/pagenumberstring load"
6826 (mail-header-date gnus-current-headers) ")"))))
6827 (gnus-run-hooks 'gnus-ps-print-hook)
6829 (ps-print-buffer-with-faces filename))))
6830 (kill-buffer buffer))))))
6832 (defun gnus-summary-show-article (&optional arg)
6833 "Force re-fetching of the current article.
6834 If ARG (the prefix) is non-nil, show the raw article without any
6835 article massaging functions being run."
6838 ;; Select the article the normal way.
6839 (gnus-summary-select-article nil 'force)
6840 ;; Bind the article treatment functions to nil.
6841 (let ((gnus-have-all-headers t)
6842 gnus-article-display-hook
6843 gnus-article-prepare-hook
6844 gnus-article-decode-hook
6848 (gnus-summary-select-article nil 'force)))
6849 (gnus-summary-goto-subject gnus-current-article)
6850 (gnus-summary-position-point))
6852 (defun gnus-summary-verbose-headers (&optional arg)
6853 "Toggle permanent full header display.
6854 If ARG is a positive number, turn header display on.
6855 If ARG is a negative number, turn header display off."
6857 (setq gnus-show-all-headers
6858 (cond ((or (not (numberp arg))
6860 (not gnus-show-all-headers))
6863 (gnus-summary-show-article))
6865 (defun gnus-summary-toggle-header (&optional arg)
6866 "Show the headers if they are hidden, or hide them if they are shown.
6867 If ARG is a positive number, show the entire header.
6868 If ARG is a negative number, hide the unwanted header lines."
6871 (set-buffer gnus-article-buffer)
6872 (let* ((buffer-read-only nil)
6873 (inhibit-point-motion-hooks t)
6874 (hidden (text-property-any
6875 (goto-char (point-min)) (search-forward "\n\n")
6878 (goto-char (point-min))
6879 (when (search-forward "\n\n" nil t)
6880 (delete-region (point-min) (1- (point))))
6881 (goto-char (point-min))
6883 (set-buffer gnus-original-article-buffer)
6884 (goto-char (point-min))
6885 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6886 (insert-buffer-substring gnus-original-article-buffer 1 e)
6887 (let ((article-inhibit-hiding t))
6888 (gnus-run-hooks 'gnus-article-display-hook))
6889 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6890 (gnus-article-hide-headers)))))
6892 (defun gnus-summary-show-all-headers ()
6893 "Make all header lines visible."
6895 (gnus-article-show-all-headers))
6897 (defun gnus-summary-toggle-mime (&optional arg)
6898 "Toggle MIME processing.
6899 If ARG is a positive number, turn MIME processing on."
6901 (setq gnus-show-mime
6902 (if (null arg) (not gnus-show-mime)
6903 (> (prefix-numeric-value arg) 0)))
6904 (gnus-summary-select-article t 'force))
6906 (defun gnus-summary-caesar-message (&optional arg)
6907 "Caesar rotate the current article by 13.
6908 The numerical prefix specifies how many places to rotate each letter
6911 (gnus-summary-select-article)
6912 (let ((mail-header-separator ""))
6913 (gnus-eval-in-buffer-window gnus-article-buffer
6916 (let ((start (window-start))
6918 (message-caesar-buffer-body arg)
6919 (set-window-start (get-buffer-window (current-buffer)) start))))))
6921 (defun gnus-summary-stop-page-breaking ()
6922 "Stop page breaking in the current article."
6924 (gnus-summary-select-article)
6925 (gnus-eval-in-buffer-window gnus-article-buffer
6927 (when (gnus-visual-p 'page-marker)
6928 (let ((buffer-read-only nil))
6929 (gnus-remove-text-with-property 'gnus-prev)
6930 (gnus-remove-text-with-property 'gnus-next))
6931 (setq gnus-page-broken nil))))
6933 (defun gnus-summary-move-article (&optional n to-newsgroup
6934 select-method action)
6935 "Move the current article to a different newsgroup.
6936 If N is a positive number, move the N next articles.
6937 If N is a negative number, move the N previous articles.
6938 If N is nil and any articles have been marked with the process mark,
6939 move those articles instead.
6940 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6941 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6942 re-spool using this method.
6944 For this function to work, both the current newsgroup and the
6945 newsgroup that you want to move to have to support the `request-move'
6946 and `request-accept' functions."
6949 (setq action 'move))
6950 ;; Disable marking as read.
6951 (let (gnus-mark-article-hook)
6952 (save-window-excursion
6953 (gnus-summary-select-article)))
6954 ;; Check whether the source group supports the required functions.
6955 (cond ((and (eq action 'move)
6956 (not (gnus-check-backend-function
6957 'request-move-article gnus-newsgroup-name)))
6958 (error "The current group does not support article moving"))
6959 ((and (eq action 'crosspost)
6960 (not (gnus-check-backend-function
6961 'request-replace-article gnus-newsgroup-name)))
6962 (error "The current group does not support article editing")))
6963 (let ((articles (gnus-summary-work-articles n))
6964 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6965 (names '((move "Move" "Moving")
6966 (copy "Copy" "Copying")
6967 (crosspost "Crosspost" "Crossposting")))
6968 (copy-buf (save-excursion
6969 (nnheader-set-temp-buffer " *copy article*")))
6970 art-group to-method new-xref article to-groups)
6971 (unless (assq action names)
6972 (error "Unknown action %s" action))
6973 ;; Read the newsgroup name.
6974 (when (and (not to-newsgroup)
6975 (not select-method))
6977 (gnus-read-move-group-name
6978 (cadr (assq action names))
6979 (symbol-value (intern (format "gnus-current-%s-group" action)))
6981 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6982 (setq to-method (or select-method
6983 (gnus-group-name-to-method to-newsgroup)))
6984 ;; Check the method we are to move this article to...
6985 (unless (gnus-check-backend-function
6986 'request-accept-article (car to-method))
6987 (error "%s does not support article copying" (car to-method)))
6988 (unless (gnus-check-server to-method)
6989 (error "Can't open server %s" (car to-method)))
6990 (gnus-message 6 "%s to %s: %s..."
6991 (caddr (assq action names))
6992 (or (car select-method) to-newsgroup) articles)
6994 (setq article (pop articles))
6998 ;; Move the article.
7000 ;; Remove this article from future suppression.
7001 (gnus-dup-unsuppress-article article)
7002 (gnus-request-move-article
7003 article ; Article to move
7004 gnus-newsgroup-name ; From newsgroup
7005 (nth 1 (gnus-find-method-for-group
7006 gnus-newsgroup-name)) ; Server
7007 (list 'gnus-request-accept-article
7008 to-newsgroup (list 'quote select-method)
7009 (not articles)) ; Accept form
7010 (not articles))) ; Only save nov last time
7011 ;; Copy the article.
7014 (set-buffer copy-buf)
7015 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7016 (gnus-request-accept-article
7017 to-newsgroup select-method (not articles) t))))
7018 ;; Crosspost the article.
7019 ((eq action 'crosspost)
7020 (let ((xref (message-tokenize-header
7021 (mail-header-xref (gnus-summary-article-header article))
7023 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7026 (setq xref (list (system-name))))
7029 (mapconcat 'identity
7030 (delete "Xref:" (delete new-xref xref))
7034 (set-buffer copy-buf)
7035 ;; First put the article in the destination group.
7036 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7037 (when (consp (setq art-group
7038 (gnus-request-accept-article
7039 to-newsgroup select-method (not articles))))
7040 (setq new-xref (concat new-xref " " (car art-group)
7041 ":" (cdr art-group)))
7042 ;; Now we have the new Xrefs header, so we insert
7043 ;; it and replace the new article.
7044 (nnheader-replace-header "Xref" new-xref)
7045 (gnus-request-replace-article
7046 (cdr art-group) to-newsgroup (current-buffer))
7050 (gnus-message 1 "Couldn't %s article %s"
7051 (cadr (assq action names)) article))
7052 ((and (eq art-group 'junk)
7054 (gnus-summary-mark-article article gnus-canceled-mark)
7055 (gnus-message 4 "Deleted article %s" article))
7057 (let* ((pto-group (gnus-group-prefixed-name
7058 (car art-group) to-method))
7060 (gnus-gethash pto-group gnus-newsrc-hashtb))
7061 (info (nth 2 entry))
7062 (to-group (gnus-info-group info)))
7063 ;; Update the group that has been moved to.
7065 (memq action '(move copy)))
7066 (unless (member to-group to-groups)
7067 (push to-group to-groups))
7069 (unless (memq article gnus-newsgroup-unreads)
7071 info (gnus-add-to-range (gnus-info-read info)
7072 (list (cdr art-group)))))
7074 ;; Copy any marks over to the new group.
7075 (let ((marks gnus-article-mark-lists)
7076 (to-article (cdr art-group)))
7078 ;; See whether the article is to be put in the cache.
7079 (when gnus-use-cache
7080 (gnus-cache-possibly-enter-article
7082 (let ((header (copy-sequence
7083 (gnus-summary-article-header article))))
7084 (mail-header-set-number header to-article)
7086 (memq article gnus-newsgroup-marked)
7087 (memq article gnus-newsgroup-dormant)
7088 (memq article gnus-newsgroup-unreads)))
7090 (when (and (equal to-group gnus-newsgroup-name)
7091 (not (memq article gnus-newsgroup-unreads)))
7092 ;; Mark this article as read in this group.
7093 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7094 (setcdr (gnus-active to-group) to-article)
7095 (setcdr gnus-newsgroup-active to-article))
7098 (when (memq article (symbol-value
7099 (intern (format "gnus-newsgroup-%s"
7101 ;; If the other group is the same as this group,
7102 ;; then we have to add the mark to the list.
7103 (when (equal to-group gnus-newsgroup-name)
7104 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7107 (intern (format "gnus-newsgroup-%s"
7109 ;; Copy the marks to other group.
7110 (gnus-add-marked-articles
7111 to-group (cdar marks) (list to-article) info))
7112 (setq marks (cdr marks)))
7115 (concat "(gnus-group-set-info '"
7116 (gnus-prin1-to-string (gnus-get-info to-group))
7119 ;; Update the Xref header in this article to point to
7120 ;; the new crossposted article we have just created.
7121 (when (eq action 'crosspost)
7123 (set-buffer copy-buf)
7124 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7125 (nnheader-replace-header "Xref" new-xref)
7126 (gnus-request-replace-article
7127 article gnus-newsgroup-name (current-buffer)))))
7129 ;;;!!!Why is this necessary?
7130 (set-buffer gnus-summary-buffer)
7132 (gnus-summary-goto-subject article)
7133 (when (eq action 'move)
7134 (gnus-summary-mark-article article gnus-canceled-mark))))
7135 (gnus-summary-remove-process-mark article))
7136 ;; Re-activate all groups that have been moved to.
7139 (set-buffer gnus-group-buffer)
7140 (when (gnus-group-goto-group (car to-groups) t)
7141 (gnus-group-get-new-news-this-group 1 t))
7144 (gnus-kill-buffer copy-buf)
7145 (gnus-summary-position-point)
7146 (gnus-set-mode-line 'summary)))
7148 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7149 "Move the current article to a different newsgroup.
7150 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7151 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7152 re-spool using this method."
7154 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7156 (defun gnus-summary-crosspost-article (&optional n)
7157 "Crosspost the current article to some other group."
7159 (gnus-summary-move-article n nil nil 'crosspost))
7161 (defcustom gnus-summary-respool-default-method nil
7162 "Default method for respooling an article.
7163 If nil, use to the current newsgroup method."
7164 :type '(choice (gnus-select-method :value (nnml ""))
7166 :group 'gnus-summary-mail)
7168 (defun gnus-summary-respool-article (&optional n method)
7169 "Respool the current article.
7170 The article will be squeezed through the mail spooling process again,
7171 which means that it will be put in some mail newsgroup or other
7172 depending on `nnmail-split-methods'.
7173 If N is a positive number, respool the N next articles.
7174 If N is a negative number, respool the N previous articles.
7175 If N is nil and any articles have been marked with the process mark,
7176 respool those articles instead.
7178 Respooling can be done both from mail groups and \"real\" newsgroups.
7179 In the former case, the articles in question will be moved from the
7180 current group into whatever groups they are destined to. In the
7181 latter case, they will be copied into the relevant groups."
7183 (list current-prefix-arg
7184 (let* ((methods (gnus-methods-using 'respool))
7186 (symbol-name (or gnus-summary-respool-default-method
7187 (car (gnus-find-method-for-group
7188 gnus-newsgroup-name)))))
7190 (gnus-completing-read
7191 methname "What backend do you want to use when respooling?"
7192 methods nil t nil 'gnus-mail-method-history))
7195 ((zerop (length (setq ms (gnus-servers-using-backend
7197 (list (intern method) ""))
7201 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7202 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7205 (error "No method given for respooling"))
7206 (if (assoc (symbol-name
7207 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7208 (gnus-methods-using 'respool))
7209 (gnus-summary-move-article n nil method)
7210 (gnus-summary-copy-article n nil method)))
7212 (defun gnus-summary-import-article (file)
7213 "Import an arbitrary file into a mail newsgroup."
7214 (interactive "fImport file: ")
7215 (let ((group gnus-newsgroup-name)
7216 (now (current-time))
7218 (unless (gnus-check-backend-function 'request-accept-article group)
7219 (error "%s does not support article importing" group))
7220 (or (file-readable-p file)
7221 (not (file-regular-p file))
7222 (error "Can't read %s" file))
7224 (set-buffer (gnus-get-buffer-create " *import file*"))
7226 (nnheader-insert-file-contents file)
7227 (goto-char (point-min))
7228 (unless (nnheader-article-p)
7229 ;; This doesn't look like an article, so we fudge some headers.
7230 (setq atts (file-attributes file)
7231 lines (count-lines (point-min) (point-max)))
7232 (insert "From: " (read-string "From: ") "\n"
7233 "Subject: " (read-string "Subject: ") "\n"
7234 "Date: " (message-make-date (nth 5 atts))
7236 "Message-ID: " (message-make-message-id) "\n"
7237 "Lines: " (int-to-string lines) "\n"
7238 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7239 (gnus-request-accept-article group nil t)
7240 (kill-buffer (current-buffer)))))
7242 (defun gnus-summary-article-posted-p ()
7243 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7244 This will be the case if the article has both been mailed and posted."
7246 (let ((id (mail-header-references (gnus-summary-article-header)))
7247 (gnus-override-method
7248 (or gnus-refer-article-method gnus-select-method)))
7249 (if (gnus-request-head id "")
7250 (gnus-message 2 "The current message was found on %s"
7251 gnus-override-method)
7252 (gnus-message 2 "The current message couldn't be found on %s"
7253 gnus-override-method)
7256 (defun gnus-summary-expire-articles (&optional now)
7257 "Expire all articles that are marked as expirable in the current group."
7259 (when (gnus-check-backend-function
7260 'request-expire-articles gnus-newsgroup-name)
7261 ;; This backend supports expiry.
7262 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7263 (expirable (if total
7265 ;; We need to update the info for
7266 ;; this group for `gnus-list-of-read-articles'
7267 ;; to give us the right answer.
7268 (gnus-run-hooks 'gnus-exit-group-hook)
7269 (gnus-summary-update-info)
7270 (gnus-list-of-read-articles gnus-newsgroup-name))
7271 (setq gnus-newsgroup-expirable
7272 (sort gnus-newsgroup-expirable '<))))
7273 (expiry-wait (if now 'immediate
7274 (gnus-group-find-parameter
7275 gnus-newsgroup-name 'expiry-wait)))
7278 ;; There are expirable articles in this group, so we run them
7279 ;; through the expiry process.
7280 (gnus-message 6 "Expiring articles...")
7281 ;; The list of articles that weren't expired is returned.
7284 (let ((nnmail-expiry-wait-function nil)
7285 (nnmail-expiry-wait expiry-wait))
7286 (setq es (gnus-request-expire-articles
7287 expirable gnus-newsgroup-name)))
7288 (setq es (gnus-request-expire-articles
7289 expirable gnus-newsgroup-name))))
7291 (setq gnus-newsgroup-expirable es))
7292 ;; We go through the old list of expirable, and mark all
7293 ;; really expired articles as nonexistent.
7294 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7295 (let ((gnus-use-cache nil))
7297 (unless (memq (car expirable) es)
7298 (when (gnus-data-find (car expirable))
7299 (gnus-summary-mark-article
7300 (car expirable) gnus-canceled-mark)))
7301 (setq expirable (cdr expirable)))))
7302 (gnus-message 6 "Expiring articles...done")))))
7304 (defun gnus-summary-expire-articles-now ()
7305 "Expunge all expirable articles in the current group.
7306 This means that *all* articles that are marked as expirable will be
7307 deleted forever, right now."
7309 (or gnus-expert-user
7311 "Are you really, really, really sure you want to delete all these messages? ")
7313 (gnus-summary-expire-articles t))
7315 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7316 (defun gnus-summary-delete-article (&optional n)
7317 "Delete the N next (mail) articles.
7318 This command actually deletes articles. This is not a marking
7319 command. The article will disappear forever from your life, never to
7321 If N is negative, delete backwards.
7322 If N is nil and articles have been marked with the process mark,
7323 delete these instead."
7325 (unless (gnus-check-backend-function 'request-expire-articles
7326 gnus-newsgroup-name)
7327 (error "The current newsgroup does not support article deletion"))
7328 ;; Compute the list of articles to delete.
7329 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7331 (if (and gnus-novice-user
7332 (not (gnus-yes-or-no-p
7333 (format "Do you really want to delete %s forever? "
7334 (if (> (length articles) 1)
7335 (format "these %s articles" (length articles))
7338 ;; Delete the articles.
7339 (setq not-deleted (gnus-request-expire-articles
7340 articles gnus-newsgroup-name 'force))
7342 (gnus-summary-remove-process-mark (car articles))
7343 ;; The backend might not have been able to delete the article
7345 (unless (memq (car articles) not-deleted)
7346 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7347 (setq articles (cdr articles)))
7349 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7350 (gnus-summary-position-point)
7351 (gnus-set-mode-line 'summary)
7354 (defun gnus-summary-edit-article (&optional force)
7355 "Edit the current article.
7356 This will have permanent effect only in mail groups.
7357 If FORCE is non-nil, allow editing of articles even in read-only
7361 (set-buffer gnus-summary-buffer)
7362 (gnus-set-global-variables)
7363 (when (and (not force)
7364 (gnus-group-read-only-p))
7365 (error "The current newsgroup does not support article editing"))
7366 ;; Select article if needed.
7367 (unless (eq (gnus-summary-article-number)
7368 gnus-current-article)
7369 (gnus-summary-select-article t))
7370 (gnus-article-date-original)
7371 (gnus-article-edit-article
7372 `(lambda (no-highlight)
7373 (gnus-summary-edit-article-done
7374 ,(or (mail-header-references gnus-current-headers) "")
7375 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7377 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7379 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7381 "Make edits to the current article permanent."
7383 ;; Replace the article.
7384 (let ((buf (current-buffer)))
7387 (if (and (not read-only)
7388 (not (gnus-request-replace-article
7389 (cdr gnus-article-current) (car gnus-article-current)
7391 (not gnus-article-decoded-p))))
7392 (error "Couldn't replace article")
7393 ;; Update the summary buffer.
7395 (equal (message-tokenize-header references " ")
7396 (message-tokenize-header
7397 (or (message-fetch-field "references") "") " ")))
7398 ;; We only have to update this line.
7401 (message-narrow-to-head)
7402 (let ((head (buffer-string))
7405 (insert (format "211 %d Article retrieved.\n"
7406 (cdr gnus-article-current)))
7409 (let ((nntp-server-buffer (current-buffer)))
7410 (setq header (car (gnus-get-newsgroup-headers
7412 (set-buffer gnus-summary-buffer)
7413 gnus-newsgroup-dependencies)
7416 (set-buffer gnus-summary-buffer)
7417 (gnus-data-set-header
7418 (gnus-data-find (cdr gnus-article-current))
7420 (gnus-summary-update-article-line
7421 (cdr gnus-article-current) header))))))
7423 (set-buffer (or buffer gnus-summary-buffer))
7424 (gnus-summary-update-article (cdr gnus-article-current)))
7425 ;; Prettify the article buffer again.
7426 (unless no-highlight
7428 (set-buffer gnus-article-buffer)
7429 (gnus-run-hooks 'gnus-article-display-hook)
7430 (set-buffer gnus-original-article-buffer)
7431 (gnus-request-article
7432 (cdr gnus-article-current)
7433 (car gnus-article-current) (current-buffer))))
7434 ;; Prettify the summary buffer line.
7435 (when (gnus-visual-p 'summary-highlight 'highlight)
7436 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7438 (defun gnus-summary-edit-wash (key)
7439 "Perform editing command KEY in the article buffer."
7443 (message "%s" (concat (this-command-keys) "- "))
7446 (gnus-summary-edit-article)
7447 (execute-kbd-macro (concat (this-command-keys) key))
7448 (gnus-article-edit-done))
7452 (defun gnus-summary-respool-query (&optional silent trace)
7453 "Query where the respool algorithm would put this article."
7455 (let (gnus-mark-article-hook)
7456 (gnus-summary-select-article)
7458 (set-buffer gnus-original-article-buffer)
7460 (message-narrow-to-head)
7461 (let ((groups (nnmail-article-group 'identity trace)))
7464 (message "This message would go to %s"
7465 (mapconcat 'car groups ", "))
7466 (message "This message would go to no groups"))
7469 (defun gnus-summary-respool-trace ()
7470 "Trace where the respool algorithm would put this article.
7471 Display a buffer showing all fancy splitting patterns which matched."
7473 (gnus-summary-respool-query nil t))
7475 ;; Summary marking commands.
7477 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7478 "Mark articles which has the same subject as read, and then select the next.
7479 If UNMARK is positive, remove any kind of mark.
7480 If UNMARK is negative, tick articles."
7483 (setq unmark (prefix-numeric-value unmark)))
7485 (gnus-summary-mark-same-subject
7486 (gnus-summary-article-subject) unmark)))
7487 ;; Select next unread article. If auto-select-same mode, should
7488 ;; select the first unread article.
7489 (gnus-summary-next-article t (and gnus-auto-select-same
7490 (gnus-summary-article-subject)))
7491 (gnus-message 7 "%d article%s marked as %s"
7492 count (if (= count 1) " is" "s are")
7493 (if unmark "unread" "read"))))
7495 (defun gnus-summary-kill-same-subject (&optional unmark)
7496 "Mark articles which has the same subject as read.
7497 If UNMARK is positive, remove any kind of mark.
7498 If UNMARK is negative, tick articles."
7501 (setq unmark (prefix-numeric-value unmark)))
7503 (gnus-summary-mark-same-subject
7504 (gnus-summary-article-subject) unmark)))
7505 ;; If marked as read, go to next unread subject.
7507 ;; Go to next unread subject.
7508 (gnus-summary-next-subject 1 t))
7509 (gnus-message 7 "%d articles are marked as %s"
7510 count (if unmark "unread" "read"))))
7512 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7513 "Mark articles with same SUBJECT as read, and return marked number.
7514 If optional argument UNMARK is positive, remove any kinds of marks.
7515 If optional argument UNMARK is negative, mark articles as unread instead."
7519 ((null unmark) ; Mark as read.
7522 (gnus-summary-mark-article-as-read gnus-killed-mark)
7523 (gnus-summary-show-thread) t)
7524 (gnus-summary-find-subject subject))
7525 (setq count (1+ count))))
7526 ((> unmark 0) ; Tick.
7529 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7530 (gnus-summary-show-thread) t)
7531 (gnus-summary-find-subject subject))
7532 (setq count (1+ count))))
7533 (t ; Mark as unread.
7536 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7537 (gnus-summary-show-thread) t)
7538 (gnus-summary-find-subject subject))
7539 (setq count (1+ count)))))
7540 (gnus-set-mode-line 'summary)
7541 ;; Return the number of marked articles.
7544 (defun gnus-summary-mark-as-processable (n &optional unmark)
7545 "Set the process mark on the next N articles.
7546 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7547 the process mark instead. The difference between N and the actual
7548 number of articles marked is returned."
7550 (let ((backward (< n 0))
7555 (gnus-summary-remove-process-mark
7556 (gnus-summary-article-number))
7557 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7558 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7561 (gnus-message 7 "No more articles"))
7562 (gnus-summary-recenter)
7563 (gnus-summary-position-point)
7566 (defun gnus-summary-unmark-as-processable (n)
7567 "Remove the process mark from the next N articles.
7568 If N is negative, unmark backward instead. The difference between N and
7569 the actual number of articles unmarked is returned."
7571 (gnus-summary-mark-as-processable n t))
7573 (defun gnus-summary-unmark-all-processable ()
7574 "Remove the process mark from all articles."
7577 (while gnus-newsgroup-processable
7578 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7579 (gnus-summary-position-point))
7581 (defun gnus-summary-mark-as-expirable (n)
7582 "Mark N articles forward as expirable.
7583 If N is negative, mark backward instead. The difference between N and
7584 the actual number of articles marked is returned."
7586 (gnus-summary-mark-forward n gnus-expirable-mark))
7588 (defun gnus-summary-mark-article-as-replied (article)
7589 "Mark ARTICLE replied and update the summary line."
7590 (push article gnus-newsgroup-replied)
7591 (let ((buffer-read-only nil))
7592 (when (gnus-summary-goto-subject article nil t)
7593 (gnus-summary-update-secondary-mark article))))
7595 (defun gnus-summary-set-bookmark (article)
7596 "Set a bookmark in current article."
7597 (interactive (list (gnus-summary-article-number)))
7598 (when (or (not (get-buffer gnus-article-buffer))
7599 (not gnus-current-article)
7600 (not gnus-article-current)
7601 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7602 (error "No current article selected"))
7603 ;; Remove old bookmark, if one exists.
7604 (let ((old (assq article gnus-newsgroup-bookmarks)))
7606 (setq gnus-newsgroup-bookmarks
7607 (delq old gnus-newsgroup-bookmarks))))
7608 ;; Set the new bookmark, which is on the form
7609 ;; (article-number . line-number-in-body).
7613 (set-buffer gnus-article-buffer)
7617 (goto-char (point-min))
7618 (search-forward "\n\n" nil t)
7621 gnus-newsgroup-bookmarks)
7622 (gnus-message 6 "A bookmark has been added to the current article."))
7624 (defun gnus-summary-remove-bookmark (article)
7625 "Remove the bookmark from the current article."
7626 (interactive (list (gnus-summary-article-number)))
7627 ;; Remove old bookmark, if one exists.
7628 (let ((old (assq article gnus-newsgroup-bookmarks)))
7631 (setq gnus-newsgroup-bookmarks
7632 (delq old gnus-newsgroup-bookmarks))
7633 (gnus-message 6 "Removed bookmark."))
7634 (gnus-message 6 "No bookmark in current article."))))
7636 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7637 (defun gnus-summary-mark-as-dormant (n)
7638 "Mark N articles forward as dormant.
7639 If N is negative, mark backward instead. The difference between N and
7640 the actual number of articles marked is returned."
7642 (gnus-summary-mark-forward n gnus-dormant-mark))
7644 (defun gnus-summary-set-process-mark (article)
7645 "Set the process mark on ARTICLE and update the summary line."
7646 (setq gnus-newsgroup-processable
7648 (delq article gnus-newsgroup-processable)))
7649 (when (gnus-summary-goto-subject article)
7650 (gnus-summary-show-thread)
7651 (gnus-summary-goto-subject article)
7652 (gnus-summary-update-secondary-mark article)))
7654 (defun gnus-summary-remove-process-mark (article)
7655 "Remove the process mark from ARTICLE and update the summary line."
7656 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7657 (when (gnus-summary-goto-subject article)
7658 (gnus-summary-show-thread)
7659 (gnus-summary-goto-subject article)
7660 (gnus-summary-update-secondary-mark article)))
7662 (defun gnus-summary-set-saved-mark (article)
7663 "Set the process mark on ARTICLE and update the summary line."
7664 (push article gnus-newsgroup-saved)
7665 (when (gnus-summary-goto-subject article)
7666 (gnus-summary-update-secondary-mark article)))
7668 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7669 "Mark N articles as read forwards.
7670 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7671 The difference between N and the actual number of articles marked is
7674 (let ((backward (< n 0))
7675 (gnus-summary-goto-unread
7676 (and gnus-summary-goto-unread
7677 (not (eq gnus-summary-goto-unread 'never))
7678 (not (memq mark (list gnus-unread-mark
7679 gnus-ticked-mark gnus-dormant-mark)))))
7681 (mark (or mark gnus-del-mark)))
7683 (gnus-summary-mark-article nil mark no-expire)
7684 (zerop (gnus-summary-next-subject
7686 (and gnus-summary-goto-unread
7687 (not (eq gnus-summary-goto-unread 'never)))
7691 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7692 (gnus-summary-recenter)
7693 (gnus-summary-position-point)
7694 (gnus-set-mode-line 'summary)
7697 (defun gnus-summary-mark-article-as-read (mark)
7698 "Mark the current article quickly as read with MARK."
7699 (let ((article (gnus-summary-article-number)))
7700 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7701 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7702 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7703 (push (cons article mark) gnus-newsgroup-reads)
7704 ;; Possibly remove from cache, if that is used.
7705 (when gnus-use-cache
7706 (gnus-cache-enter-remove-article article))
7707 ;; Allow the backend to change the mark.
7708 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7709 ;; Check for auto-expiry.
7710 (when (and gnus-newsgroup-auto-expire
7711 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7712 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7713 (= mark gnus-ancient-mark)
7714 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7715 (= mark gnus-duplicate-mark)))
7716 (setq mark gnus-expirable-mark)
7717 ;; Let the backend know about the mark change.
7718 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7719 (push article gnus-newsgroup-expirable))
7720 ;; Set the mark in the buffer.
7721 (gnus-summary-update-mark mark 'unread)
7724 (defun gnus-summary-mark-article-as-unread (mark)
7725 "Mark the current article quickly as unread with MARK."
7726 (let* ((article (gnus-summary-article-number))
7727 (old-mark (gnus-summary-article-mark article)))
7728 ;; Allow the backend to change the mark.
7729 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7730 (if (eq mark old-mark)
7734 (gnus-error 1 "Can't mark negative article numbers")
7736 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7737 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7738 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7739 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7740 (cond ((= mark gnus-ticked-mark)
7741 (push article gnus-newsgroup-marked))
7742 ((= mark gnus-dormant-mark)
7743 (push article gnus-newsgroup-dormant))
7745 (push article gnus-newsgroup-unreads)))
7746 (gnus-pull article gnus-newsgroup-reads)
7748 ;; See whether the article is to be put in the cache.
7750 (vectorp (gnus-summary-article-header article))
7752 (gnus-cache-possibly-enter-article
7753 gnus-newsgroup-name article
7754 (gnus-summary-article-header article)
7755 (= mark gnus-ticked-mark)
7756 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7759 (gnus-summary-update-mark mark 'unread)
7762 (defun gnus-summary-mark-article (&optional article mark no-expire)
7763 "Mark ARTICLE with MARK. MARK can be any character.
7764 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7765 `??' (dormant) and `?E' (expirable).
7766 If MARK is nil, then the default character `?D' is used.
7767 If ARTICLE is nil, then the article on the current line will be
7769 ;; The mark might be a string.
7770 (when (stringp mark)
7771 (setq mark (aref mark 0)))
7772 ;; If no mark is given, then we check auto-expiring.
7773 (and (not no-expire)
7774 gnus-newsgroup-auto-expire
7776 (and (gnus-characterp mark)
7777 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7778 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7779 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7780 (= mark gnus-duplicate-mark))))
7781 (setq mark gnus-expirable-mark))
7782 (let* ((mark (or mark gnus-del-mark))
7783 (article (or article (gnus-summary-article-number)))
7784 (old-mark (gnus-summary-article-mark article)))
7785 ;; Allow the backend to change the mark.
7786 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7787 (if (eq mark old-mark)
7790 (error "No article on current line"))
7791 (if (not (if (or (= mark gnus-unread-mark)
7792 (= mark gnus-ticked-mark)
7793 (= mark gnus-dormant-mark))
7794 (gnus-mark-article-as-unread article mark)
7795 (gnus-mark-article-as-read article mark)))
7797 ;; See whether the article is to be put in the cache.
7799 (not (= mark gnus-canceled-mark))
7800 (vectorp (gnus-summary-article-header article))
7802 (gnus-cache-possibly-enter-article
7803 gnus-newsgroup-name article
7804 (gnus-summary-article-header article)
7805 (= mark gnus-ticked-mark)
7806 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7808 (when (gnus-summary-goto-subject article nil t)
7809 (let ((buffer-read-only nil))
7810 (gnus-summary-show-thread)
7812 (gnus-summary-update-mark mark 'unread)
7815 (defun gnus-summary-update-secondary-mark (article)
7816 "Update the secondary (read, process, cache) mark."
7817 (gnus-summary-update-mark
7818 (cond ((memq article gnus-newsgroup-processable)
7820 ((memq article gnus-newsgroup-cached)
7822 ((memq article gnus-newsgroup-replied)
7824 ((memq article gnus-newsgroup-saved)
7826 (t gnus-unread-mark))
7828 (when (gnus-visual-p 'summary-highlight 'highlight)
7829 (gnus-run-hooks 'gnus-summary-update-hook))
7832 (defun gnus-summary-update-mark (mark type)
7833 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7834 (buffer-read-only nil))
7835 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7836 (when (looking-at "\r")
7839 (<= (+ forward (point)) (point-max)))
7840 ;; Go to the right position on the line.
7841 (goto-char (+ forward (point)))
7842 ;; Replace the old mark with the new mark.
7843 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7844 ;; Optionally update the marks by some user rule.
7845 (when (eq type 'unread)
7847 (gnus-data-find (gnus-summary-article-number)) mark)
7848 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7850 (defun gnus-mark-article-as-read (article &optional mark)
7851 "Enter ARTICLE in the pertinent lists and remove it from others."
7852 ;; Make the article expirable.
7853 (let ((mark (or mark gnus-del-mark)))
7854 (if (= mark gnus-expirable-mark)
7855 (push article gnus-newsgroup-expirable)
7856 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7857 ;; Remove from unread and marked lists.
7858 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7859 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7860 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7861 (push (cons article mark) gnus-newsgroup-reads)
7862 ;; Possibly remove from cache, if that is used.
7863 (when gnus-use-cache
7864 (gnus-cache-enter-remove-article article))
7867 (defun gnus-mark-article-as-unread (article &optional mark)
7868 "Enter ARTICLE in the pertinent lists and remove it from others."
7869 (let ((mark (or mark gnus-ticked-mark)))
7872 (gnus-error 1 "Can't mark negative article numbers")
7874 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7875 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7876 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7877 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7879 ;; Unsuppress duplicates?
7880 (when gnus-suppress-duplicates
7881 (gnus-dup-unsuppress-article article))
7883 (cond ((= mark gnus-ticked-mark)
7884 (push article gnus-newsgroup-marked))
7885 ((= mark gnus-dormant-mark)
7886 (push article gnus-newsgroup-dormant))
7888 (push article gnus-newsgroup-unreads)))
7889 (gnus-pull article gnus-newsgroup-reads)
7892 (defalias 'gnus-summary-mark-as-unread-forward
7893 'gnus-summary-tick-article-forward)
7894 (make-obsolete 'gnus-summary-mark-as-unread-forward
7895 'gnus-summary-tick-article-forward)
7896 (defun gnus-summary-tick-article-forward (n)
7897 "Tick N articles forwards.
7898 If N is negative, tick backwards instead.
7899 The difference between N and the number of articles ticked is returned."
7901 (gnus-summary-mark-forward n gnus-ticked-mark))
7903 (defalias 'gnus-summary-mark-as-unread-backward
7904 'gnus-summary-tick-article-backward)
7905 (make-obsolete 'gnus-summary-mark-as-unread-backward
7906 'gnus-summary-tick-article-backward)
7907 (defun gnus-summary-tick-article-backward (n)
7908 "Tick N articles backwards.
7909 The difference between N and the number of articles ticked is returned."
7911 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7913 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7914 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7915 (defun gnus-summary-tick-article (&optional article clear-mark)
7916 "Mark current article as unread.
7917 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7918 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7920 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7923 (defun gnus-summary-mark-as-read-forward (n)
7924 "Mark N articles as read forwards.
7925 If N is negative, mark backwards instead.
7926 The difference between N and the actual number of articles marked is
7929 (gnus-summary-mark-forward n gnus-del-mark t))
7931 (defun gnus-summary-mark-as-read-backward (n)
7932 "Mark the N articles as read backwards.
7933 The difference between N and the actual number of articles marked is
7936 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7938 (defun gnus-summary-mark-as-read (&optional article mark)
7939 "Mark current article as read.
7940 ARTICLE specifies the article to be marked as read.
7941 MARK specifies a string to be inserted at the beginning of the line."
7942 (gnus-summary-mark-article article mark))
7944 (defun gnus-summary-clear-mark-forward (n)
7945 "Clear marks from N articles forward.
7946 If N is negative, clear backward instead.
7947 The difference between N and the number of marks cleared is returned."
7949 (gnus-summary-mark-forward n gnus-unread-mark))
7951 (defun gnus-summary-clear-mark-backward (n)
7952 "Clear marks from N articles backward.
7953 The difference between N and the number of marks cleared is returned."
7955 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7957 (defun gnus-summary-mark-unread-as-read ()
7958 "Intended to be used by `gnus-summary-mark-article-hook'."
7959 (when (memq gnus-current-article gnus-newsgroup-unreads)
7960 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7962 (defun gnus-summary-mark-read-and-unread-as-read ()
7963 "Intended to be used by `gnus-summary-mark-article-hook'."
7964 (let ((mark (gnus-summary-article-mark)))
7965 (when (or (gnus-unread-mark-p mark)
7966 (gnus-read-mark-p mark))
7967 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7969 (defun gnus-summary-mark-region-as-read (point mark all)
7970 "Mark all unread articles between point and mark as read.
7971 If given a prefix, mark all articles between point and mark as read,
7972 even ticked and dormant ones."
7973 (interactive "r\nP")
7982 (memq (setq article (gnus-summary-article-number))
7983 gnus-newsgroup-unreads))
7984 (gnus-summary-mark-article article gnus-del-mark))
7986 (gnus-summary-find-next))))))
7988 (defun gnus-summary-mark-below (score mark)
7989 "Mark articles with score less than SCORE with MARK."
7990 (interactive "P\ncMark: ")
7991 (setq score (if score
7992 (prefix-numeric-value score)
7993 (or gnus-summary-default-score 0)))
7995 (set-buffer gnus-summary-buffer)
7996 (goto-char (point-min))
7999 (and (< (gnus-summary-article-score) score)
8000 (gnus-summary-mark-article nil mark))
8001 (gnus-summary-find-next)))))
8003 (defun gnus-summary-kill-below (&optional score)
8004 "Mark articles with score below SCORE as read."
8006 (gnus-summary-mark-below score gnus-killed-mark))
8008 (defun gnus-summary-clear-above (&optional score)
8009 "Clear all marks from articles with score above SCORE."
8011 (gnus-summary-mark-above score gnus-unread-mark))
8013 (defun gnus-summary-tick-above (&optional score)
8014 "Tick all articles with score above SCORE."
8016 (gnus-summary-mark-above score gnus-ticked-mark))
8018 (defun gnus-summary-mark-above (score mark)
8019 "Mark articles with score over SCORE with MARK."
8020 (interactive "P\ncMark: ")
8021 (setq score (if score
8022 (prefix-numeric-value score)
8023 (or gnus-summary-default-score 0)))
8025 (set-buffer gnus-summary-buffer)
8026 (goto-char (point-min))
8028 (when (> (gnus-summary-article-score) score)
8029 (gnus-summary-mark-article nil mark))
8031 (gnus-summary-find-next)))))
8033 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8034 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8035 (defun gnus-summary-limit-include-expunged (&optional no-error)
8036 "Display all the hidden articles that were expunged for low scores."
8038 (let ((buffer-read-only nil))
8039 (let ((scored gnus-newsgroup-scored)
8042 (unless (gnus-summary-goto-subject (caar scored))
8043 (and (setq h (gnus-summary-article-header (caar scored)))
8044 (< (cdar scored) gnus-summary-expunge-below)
8046 (setq scored (cdr scored)))
8048 (when (not no-error)
8049 (error "No expunged articles hidden"))
8050 (goto-char (point-min))
8051 (gnus-summary-prepare-unthreaded (nreverse headers))
8052 (goto-char (point-min))
8053 (gnus-summary-position-point)
8056 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8057 "Mark all unread articles in this newsgroup as read.
8058 If prefix argument ALL is non-nil, ticked and dormant articles will
8059 also be marked as read.
8060 If QUIETLY is non-nil, no questions will be asked.
8061 If TO-HERE is non-nil, it should be a point in the buffer. All
8062 articles before this point will be marked as read.
8063 Note that this function will only catch up the unread article
8064 in the current summary buffer limitation.
8065 The number of articles marked as read is returned."
8070 (not gnus-interactive-catchup) ;Without confirmation?
8074 "Mark absolutely all articles as read? "
8075 "Mark all unread articles as read? ")))
8077 (not gnus-newsgroup-adaptive)
8078 (not gnus-newsgroup-auto-expire)
8079 (not gnus-suppress-duplicates)
8080 (or (not gnus-use-cache)
8081 (eq gnus-use-cache 'passive)))
8084 (setq gnus-newsgroup-marked nil
8085 gnus-newsgroup-dormant nil))
8086 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8087 ;; We actually mark all articles as canceled, which we
8088 ;; have to do when using auto-expiry or adaptive scoring.
8089 (gnus-summary-show-all-threads)
8090 (when (gnus-summary-first-subject (not all) t)
8092 (if to-here (< (point) to-here) t)
8093 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8094 (gnus-summary-find-next (not all) nil nil t))))
8095 (gnus-set-mode-line 'summary))
8097 (gnus-summary-position-point)))
8099 (defun gnus-summary-catchup-to-here (&optional all)
8100 "Mark all unticked articles before the current one as read.
8101 If ALL is non-nil, also mark ticked and dormant articles as read."
8104 (gnus-save-hidden-threads
8105 (let ((beg (point)))
8106 ;; We check that there are unread articles.
8107 (when (or all (gnus-summary-find-prev))
8108 (gnus-summary-catchup all t beg)))))
8109 (gnus-summary-position-point))
8111 (defun gnus-summary-catchup-all (&optional quietly)
8112 "Mark all articles in this newsgroup as read."
8114 (gnus-summary-catchup t quietly))
8116 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8117 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8118 If prefix argument ALL is non-nil, all articles are marked as read."
8120 (when (gnus-summary-catchup all quietly nil 'fast)
8121 ;; Select next newsgroup or exit.
8122 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8123 (eq gnus-auto-select-next 'quietly))
8124 (gnus-summary-next-group nil)
8125 (gnus-summary-exit))))
8127 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8128 "Mark all articles in this newsgroup as read, and then exit."
8130 (gnus-summary-catchup-and-exit t quietly))
8132 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8133 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8134 "Mark all articles in this group as read and select the next group.
8135 If given a prefix, mark all articles, unread as well as ticked, as
8139 (gnus-summary-catchup all))
8140 (gnus-summary-next-article t nil nil t))
8142 ;; Thread-based commands.
8144 (defun gnus-summary-articles-in-thread (&optional article)
8145 "Return a list of all articles in the current thread.
8146 If ARTICLE is non-nil, return all articles in the thread that starts
8148 (let* ((article (or article (gnus-summary-article-number)))
8149 (data (gnus-data-find-list article))
8150 (top-level (gnus-data-level (car data)))
8152 (cond ((null gnus-thread-operation-ignore-subject)
8153 (gnus-simplify-subject-re
8154 (mail-header-subject (gnus-data-header (car data)))))
8155 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8156 (gnus-simplify-subject-fuzzy
8157 (mail-header-subject (gnus-data-header (car data)))))
8159 (end-point (save-excursion
8160 (if (gnus-summary-go-to-next-thread)
8161 (point) (point-max))))
8164 (< (gnus-data-pos (car data)) end-point))
8165 (when (or (not top-subject)
8166 (string= top-subject
8167 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8168 (gnus-simplify-subject-fuzzy
8169 (mail-header-subject
8170 (gnus-data-header (car data))))
8171 (gnus-simplify-subject-re
8172 (mail-header-subject
8173 (gnus-data-header (car data)))))))
8174 (push (gnus-data-number (car data)) articles))
8175 (unless (and (setq data (cdr data))
8176 (> (gnus-data-level (car data)) top-level))
8178 ;; Return the list of articles.
8179 (nreverse articles)))
8181 (defun gnus-summary-rethread-current ()
8182 "Rethread the thread the current article is part of."
8184 (let* ((gnus-show-threads t)
8185 (article (gnus-summary-article-number))
8186 (id (mail-header-id (gnus-summary-article-header)))
8187 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8189 (error "No article on the current line"))
8190 (gnus-rebuild-thread id)
8191 (gnus-summary-goto-subject article)))
8193 (defun gnus-summary-reparent-thread ()
8194 "Make the current article child of the marked (or previous) article.
8196 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8197 is non-nil or the Subject: of both articles are the same."
8199 (unless (not (gnus-group-read-only-p))
8200 (error "The current newsgroup does not support article editing"))
8201 (unless (<= (length gnus-newsgroup-processable) 1)
8202 (error "No more than one article may be marked"))
8203 (save-window-excursion
8204 (let ((gnus-article-buffer " *reparent*")
8205 (current-article (gnus-summary-article-number))
8206 ;; First grab the marked article, otherwise one line up.
8207 (parent-article (if (not (null gnus-newsgroup-processable))
8208 (car gnus-newsgroup-processable)
8210 (if (eq (forward-line -1) 0)
8211 (gnus-summary-article-number)
8212 (error "Beginning of summary buffer"))))))
8213 (unless (not (eq current-article parent-article))
8214 (error "An article may not be self-referential"))
8215 (let ((message-id (mail-header-id
8216 (gnus-summary-article-header parent-article))))
8217 (unless (and message-id (not (equal message-id "")))
8218 (error "No message-id in desired parent"))
8219 ;; We don't want the article to be marked as read.
8220 (let (gnus-mark-article-hook)
8221 (gnus-summary-select-article t t nil current-article))
8222 (set-buffer gnus-original-article-buffer)
8223 (let ((buf (format "%s" (buffer-string))))
8226 (goto-char (point-min))
8227 (if (re-search-forward "^References: " nil t)
8229 (re-search-forward "^[^ \t]" nil t)
8232 (insert " " message-id))
8233 (insert "References: " message-id "\n"))
8234 (unless (gnus-request-replace-article
8235 current-article (car gnus-article-current)
8237 (error "Couldn't replace article"))))
8238 (set-buffer gnus-summary-buffer)
8239 (gnus-summary-unmark-all-processable)
8240 (gnus-summary-update-article current-article)
8241 (gnus-summary-rethread-current)
8242 (gnus-message 3 "Article %d is now the child of article %d"
8243 current-article parent-article)))))
8245 (defun gnus-summary-toggle-threads (&optional arg)
8246 "Toggle showing conversation threads.
8247 If ARG is positive number, turn showing conversation threads on."
8249 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8250 (setq gnus-show-threads
8251 (if (null arg) (not gnus-show-threads)
8252 (> (prefix-numeric-value arg) 0)))
8253 (gnus-summary-prepare)
8254 (gnus-summary-goto-subject current)
8255 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8256 (gnus-summary-position-point)))
8258 (defun gnus-summary-show-all-threads ()
8262 (let ((buffer-read-only nil))
8263 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8264 (gnus-summary-position-point))
8266 (defun gnus-summary-show-thread ()
8267 "Show thread subtrees.
8268 Returns nil if no thread was there to be shown."
8270 (let ((buffer-read-only nil)
8272 ;; first goto end then to beg, to have point at beg after let
8273 (end (progn (end-of-line) (point)))
8274 (beg (progn (beginning-of-line) (point))))
8276 ;; Any hidden lines here?
8277 (search-forward "\r" end t)
8278 (subst-char-in-region beg end ?\^M ?\n t)
8280 (gnus-summary-position-point))))
8282 (defun gnus-summary-hide-all-threads ()
8283 "Hide all thread subtrees."
8286 (goto-char (point-min))
8287 (gnus-summary-hide-thread)
8288 (while (zerop (gnus-summary-next-thread 1 t))
8289 (gnus-summary-hide-thread)))
8290 (gnus-summary-position-point))
8292 (defun gnus-summary-hide-thread ()
8293 "Hide thread subtrees.
8294 Returns nil if no threads were there to be hidden."
8296 (let ((buffer-read-only nil)
8298 (article (gnus-summary-article-number)))
8300 ;; Go forward until either the buffer ends or the subthread
8302 (when (and (not (eobp))
8303 (or (zerop (gnus-summary-next-thread 1 t))
8304 (goto-char (point-max))))
8306 (if (and (> (point) start)
8307 (search-backward "\n" start t))
8309 (subst-char-in-region start (point) ?\n ?\^M)
8310 (gnus-summary-goto-subject article))
8313 ;;(gnus-summary-position-point)
8316 (defun gnus-summary-go-to-next-thread (&optional previous)
8317 "Go to the same level (or less) next thread.
8318 If PREVIOUS is non-nil, go to previous thread instead.
8319 Return the article number moved to, or nil if moving was impossible."
8320 (let ((level (gnus-summary-thread-level))
8321 (way (if previous -1 1))
8324 (while (and (not (eobp))
8325 (< level (gnus-summary-thread-level)))
8333 (gnus-summary-article-number)
8336 (defun gnus-summary-next-thread (n &optional silent)
8337 "Go to the same level next N'th thread.
8338 If N is negative, search backward instead.
8339 Returns the difference between N and the number of skips actually
8342 If SILENT, don't output messages."
8344 (let ((backward (< n 0))
8347 (gnus-summary-go-to-next-thread backward))
8350 (gnus-summary-position-point))
8351 (when (and (not silent) (/= 0 n))
8352 (gnus-message 7 "No more threads"))
8355 (defun gnus-summary-prev-thread (n)
8356 "Go to the same level previous N'th thread.
8357 Returns the difference between N and the number of skips actually
8360 (gnus-summary-next-thread (- n)))
8362 (defun gnus-summary-go-down-thread ()
8363 "Go down one level in the current thread."
8364 (let ((children (gnus-summary-article-children)))
8366 (gnus-summary-goto-subject (car children)))))
8368 (defun gnus-summary-go-up-thread ()
8369 "Go up one level in the current thread."
8370 (let ((parent (gnus-summary-article-parent)))
8372 (gnus-summary-goto-subject parent))))
8374 (defun gnus-summary-down-thread (n)
8375 "Go down thread N steps.
8376 If N is negative, go up instead.
8377 Returns the difference between N and how many steps down that were
8383 (if up (gnus-summary-go-up-thread)
8384 (gnus-summary-go-down-thread)))
8386 (gnus-summary-position-point)
8388 (gnus-message 7 "Can't go further"))
8391 (defun gnus-summary-up-thread (n)
8392 "Go up thread N steps.
8393 If N is negative, go up instead.
8394 Returns the difference between N and how many steps down that were
8397 (gnus-summary-down-thread (- n)))
8399 (defun gnus-summary-top-thread ()
8400 "Go to the top of the thread."
8402 (while (gnus-summary-go-up-thread))
8403 (gnus-summary-article-number))
8405 (defun gnus-summary-kill-thread (&optional unmark)
8406 "Mark articles under current thread as read.
8407 If the prefix argument is positive, remove any kinds of marks.
8408 If the prefix argument is negative, tick articles instead."
8411 (setq unmark (prefix-numeric-value unmark)))
8412 (let ((articles (gnus-summary-articles-in-thread)))
8414 ;; Expand the thread.
8415 (gnus-summary-show-thread)
8416 ;; Mark all the articles.
8418 (gnus-summary-goto-subject (car articles))
8419 (cond ((null unmark)
8420 (gnus-summary-mark-article-as-read gnus-killed-mark))
8422 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8424 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8425 (setq articles (cdr articles))))
8426 ;; Hide killed subtrees.
8428 gnus-thread-hide-killed
8429 (gnus-summary-hide-thread))
8430 ;; If marked as read, go to next unread subject.
8432 ;; Go to next unread subject.
8433 (gnus-summary-next-subject 1 t)))
8434 (gnus-set-mode-line 'summary))
8436 ;; Summary sorting commands
8438 (defun gnus-summary-sort-by-number (&optional reverse)
8439 "Sort the summary buffer by article number.
8440 Argument REVERSE means reverse order."
8442 (gnus-summary-sort 'number reverse))
8444 (defun gnus-summary-sort-by-author (&optional reverse)
8445 "Sort the summary buffer by author name alphabetically.
8446 If case-fold-search is non-nil, case of letters is ignored.
8447 Argument REVERSE means reverse order."
8449 (gnus-summary-sort 'author reverse))
8451 (defun gnus-summary-sort-by-subject (&optional reverse)
8452 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8453 If case-fold-search is non-nil, case of letters is ignored.
8454 Argument REVERSE means reverse order."
8456 (gnus-summary-sort 'subject reverse))
8458 (defun gnus-summary-sort-by-date (&optional reverse)
8459 "Sort the summary buffer by date.
8460 Argument REVERSE means reverse order."
8462 (gnus-summary-sort 'date reverse))
8464 (defun gnus-summary-sort-by-score (&optional reverse)
8465 "Sort the summary buffer by score.
8466 Argument REVERSE means reverse order."
8468 (gnus-summary-sort 'score reverse))
8470 (defun gnus-summary-sort-by-lines (&optional reverse)
8471 "Sort the summary buffer by article length.
8472 Argument REVERSE means reverse order."
8474 (gnus-summary-sort 'lines reverse))
8476 (defun gnus-summary-sort (predicate reverse)
8477 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8478 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8479 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8480 (gnus-thread-sort-functions
8486 (gnus-article-sort-functions
8491 (,article t2 t1)))))
8493 (gnus-summary-prepare-hook nil))
8494 ;; We do the sorting by regenerating the threads.
8495 (gnus-summary-prepare)
8496 ;; Hide subthreads if needed.
8497 (when (and gnus-show-threads gnus-thread-hide-subtree)
8498 (gnus-summary-hide-all-threads))))
8500 ;; Summary saving commands.
8502 (defun gnus-summary-save-article (&optional n not-saved)
8503 "Save the current article using the default saver function.
8504 If N is a positive number, save the N next articles.
8505 If N is a negative number, save the N previous articles.
8506 If N is nil and any articles have been marked with the process mark,
8507 save those articles instead.
8508 The variable `gnus-default-article-saver' specifies the saver function."
8510 (let* ((articles (gnus-summary-work-articles n))
8511 (save-buffer (save-excursion
8512 (nnheader-set-temp-buffer " *Gnus Save*")))
8513 (num (length articles))
8514 header article file)
8516 (setq header (gnus-summary-article-header
8517 (setq article (pop articles))))
8518 (if (not (vectorp header))
8519 ;; This is a pseudo-article.
8520 (if (assq 'name header)
8521 (gnus-copy-file (cdr (assq 'name header)))
8522 (gnus-message 1 "Article %d is unsaveable" article))
8523 ;; This is a real article.
8524 (save-window-excursion
8525 (gnus-summary-select-article t nil nil article))
8527 (set-buffer save-buffer)
8529 (insert-buffer-substring gnus-original-article-buffer))
8530 (setq file (gnus-article-save save-buffer file num))
8531 (gnus-summary-remove-process-mark article)
8533 (gnus-summary-set-saved-mark article))))
8534 (gnus-kill-buffer save-buffer)
8535 (gnus-summary-position-point)
8536 (gnus-set-mode-line 'summary)
8539 (defun gnus-summary-pipe-output (&optional arg)
8540 "Pipe the current article to a subprocess.
8541 If N is a positive number, pipe the N next articles.
8542 If N is a negative number, pipe the N previous articles.
8543 If N is nil and any articles have been marked with the process mark,
8544 pipe those articles instead."
8546 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8547 (gnus-summary-save-article arg t))
8548 (gnus-configure-windows 'pipe))
8550 (defun gnus-summary-save-article-mail (&optional arg)
8551 "Append the current article to an mail file.
8552 If N is a positive number, save the N next articles.
8553 If N is a negative number, save the N previous articles.
8554 If N is nil and any articles have been marked with the process mark,
8555 save those articles instead."
8557 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8558 (gnus-summary-save-article arg)))
8560 (defun gnus-summary-save-article-rmail (&optional arg)
8561 "Append the current article to an rmail file.
8562 If N is a positive number, save the N next articles.
8563 If N is a negative number, save the N previous articles.
8564 If N is nil and any articles have been marked with the process mark,
8565 save those articles instead."
8567 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8568 (gnus-summary-save-article arg)))
8570 (defun gnus-summary-save-article-file (&optional arg)
8571 "Append the current article to a file.
8572 If N is a positive number, save the N next articles.
8573 If N is a negative number, save the N previous articles.
8574 If N is nil and any articles have been marked with the process mark,
8575 save those articles instead."
8577 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8578 (gnus-summary-save-article arg)))
8580 (defun gnus-summary-write-article-file (&optional arg)
8581 "Write the current article to a file, deleting the previous file.
8582 If N is a positive number, save the N next articles.
8583 If N is a negative number, save the N previous articles.
8584 If N is nil and any articles have been marked with the process mark,
8585 save those articles instead."
8587 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8588 (gnus-summary-save-article arg)))
8590 (defun gnus-summary-save-article-body-file (&optional arg)
8591 "Append the current article body to a file.
8592 If N is a positive number, save the N next articles.
8593 If N is a negative number, save the N previous articles.
8594 If N is nil and any articles have been marked with the process mark,
8595 save those articles instead."
8597 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8598 (gnus-summary-save-article arg)))
8600 (defun gnus-summary-pipe-message (program)
8601 "Pipe the current article through PROGRAM."
8602 (interactive "sProgram: ")
8603 (gnus-summary-select-article)
8604 (let ((mail-header-separator ""))
8605 (gnus-eval-in-buffer-window gnus-article-buffer
8608 (let ((start (window-start))
8610 (message-pipe-buffer-body program)
8611 (set-window-start (get-buffer-window (current-buffer)) start))))))
8613 (defun gnus-get-split-value (methods)
8614 "Return a value based on the split METHODS."
8615 (let (split-name method result match)
8618 (set-buffer gnus-original-article-buffer)
8620 (nnheader-narrow-to-headers)
8622 (goto-char (point-min))
8623 (setq method (pop methods))
8624 (setq match (car method))
8627 ;; Regular expression.
8629 (re-search-forward match nil t)))
8630 ((gnus-functionp match)
8634 (setq result (funcall match gnus-newsgroup-name))))
8639 (setq result (eval match)))))
8640 (setq split-name (append (cdr method) split-name))
8641 (cond ((stringp result)
8642 (push (expand-file-name
8643 result gnus-article-save-directory)
8646 (setq split-name (append result split-name)))))))))
8649 (defun gnus-valid-move-group-p (group)
8654 (car (gnus-find-method-for-group
8655 (symbol-name group))))
8656 gnus-valid-select-methods))))
8658 (defun gnus-read-move-group-name (prompt default articles prefix)
8659 "Read a group name."
8660 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8661 (minibuffer-confirm-incomplete nil) ; XEmacs
8665 (if (> (length articles) 1)
8666 (format "these %d articles" (length articles))
8671 (gnus-completing-read default prom
8673 'gnus-valid-move-group-p
8675 'gnus-group-history))
8676 ((= 1 (length split-name))
8677 (gnus-completing-read (car split-name) prom
8679 'gnus-valid-move-group-p
8681 'gnus-group-history))
8683 (gnus-completing-read nil prom
8684 (mapcar (lambda (el) (list el))
8685 (nreverse split-name))
8687 'gnus-group-history)))))
8689 (if (or (string= to-newsgroup "")
8690 (string= to-newsgroup prefix))
8691 (setq to-newsgroup default))
8692 (unless to-newsgroup
8693 (error "No group name entered"))
8694 (or (gnus-active to-newsgroup)
8695 (gnus-activate-group to-newsgroup)
8696 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8698 (or (and (gnus-request-create-group
8699 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8700 (gnus-activate-group to-newsgroup nil nil
8701 (gnus-group-name-to-method
8703 (error "Couldn't create group %s" to-newsgroup)))
8704 (error "No such group: %s" to-newsgroup)))
8707 ;; Summary extract commands
8709 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8710 (let ((buffer-read-only nil)
8711 (article (gnus-summary-article-number))
8713 (unless (gnus-summary-goto-subject article)
8714 (error "No such article: %d" article))
8715 (gnus-summary-position-point)
8716 ;; If all commands are to be bunched up on one line, we collect
8718 (unless gnus-view-pseudos-separately
8719 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8722 (setq action (cdr (assq 'action (car ps))))
8723 (setq files (list (cdr (assq 'name (car ps)))))
8724 (while (and ps (cdr ps)
8725 (string= (or action "1")
8726 (or (cdr (assq 'action (cadr ps))) "2")))
8727 (push (cdr (assq 'name (cadr ps))) files)
8728 (setcdr ps (cddr ps)))
8730 (when (not (string-match "%s" action))
8733 (when (assq 'execute (car ps))
8734 (setcdr (assq 'execute (car ps))
8735 (funcall (if (string-match "%s" action)
8742 (gnus-quote-arg-for-sh-or-csh f)))
8744 (setq ps (cdr ps)))))
8745 (if (and gnus-view-pseudos (not not-view))
8747 (when (assq 'execute (car pslist))
8748 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8749 (eq gnus-view-pseudos 'not-confirm)))
8750 (setq pslist (cdr pslist)))
8753 (setq after-article (or (cdr (assq 'article (car pslist)))
8754 (gnus-summary-article-number)))
8755 (gnus-summary-goto-subject after-article)
8758 (insert " " (file-name-nondirectory
8759 (cdr (assq 'name (car pslist))))
8760 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8762 (forward-line -1) ; back to `b'
8763 (gnus-add-text-properties
8764 b (1- e) (list 'gnus-number gnus-reffed-article-number
8765 gnus-mouse-face-prop gnus-mouse-face))
8767 after-article gnus-reffed-article-number
8768 gnus-unread-mark b (car pslist) 0 (- e b))
8769 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8770 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8771 (setq pslist (cdr pslist)))))))
8773 (defun gnus-pseudos< (p1 p2)
8774 (let ((c1 (cdr (assq 'action p1)))
8775 (c2 (cdr (assq 'action p2))))
8776 (and c1 c2 (string< c1 c2))))
8778 (defun gnus-request-pseudo-article (props)
8779 (cond ((assq 'execute props)
8780 (gnus-execute-command (cdr (assq 'execute props)))))
8781 (let ((gnus-current-article (gnus-summary-article-number)))
8782 (gnus-run-hooks 'gnus-mark-article-hook)))
8784 (defun gnus-execute-command (command &optional automatic)
8786 (gnus-article-setup-buffer)
8787 (set-buffer gnus-article-buffer)
8788 (setq buffer-read-only nil)
8789 (let ((command (if automatic command
8790 (read-string "Command: " (cons command 0)))))
8792 (insert "$ " command "\n\n")
8793 (if gnus-view-pseudo-asynchronously
8794 (start-process "gnus-execute" (current-buffer) shell-file-name
8795 shell-command-switch command)
8796 (call-process shell-file-name nil t nil
8797 shell-command-switch command)))))
8799 ;; Summary kill commands.
8801 (defun gnus-summary-edit-global-kill (article)
8802 "Edit the \"global\" kill file."
8803 (interactive (list (gnus-summary-article-number)))
8804 (gnus-group-edit-global-kill article))
8806 (defun gnus-summary-edit-local-kill ()
8807 "Edit a local kill file applied to the current newsgroup."
8809 (setq gnus-current-headers (gnus-summary-article-header))
8810 (gnus-group-edit-local-kill
8811 (gnus-summary-article-number) gnus-newsgroup-name))
8815 (defun gnus-read-header (id &optional header)
8816 "Read the headers of article ID and enter them into the Gnus system."
8817 (let ((group gnus-newsgroup-name)
8818 (gnus-override-method
8819 (and (gnus-news-group-p gnus-newsgroup-name)
8820 gnus-refer-article-method))
8822 ;; First we check to see whether the header in question is already
8825 ;; This is a Message-ID.
8826 (setq header (or header (gnus-id-to-header id)))
8827 ;; This is an article number.
8828 (setq header (or header (gnus-summary-article-header id))))
8830 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8831 ;; We have found the header.
8833 ;; If this is a sparse article, we have to nix out its
8834 ;; previous entry in the thread hashtb.
8836 (gnus-summary-article-sparse-p (mail-header-number header)))
8837 (let* ((parent (gnus-parent-id (mail-header-references header)))
8838 (thread (and parent (gnus-id-to-thread parent))))
8840 (delq (assq header thread) thread))))
8841 ;; We have to really fetch the header to this article.
8843 (set-buffer nntp-server-buffer)
8844 (when (setq where (gnus-request-head id group))
8845 (nnheader-fold-continuation-lines)
8846 (goto-char (point-max))
8848 (goto-char (point-min))
8852 ((cdr where) (cdr where))
8853 (header (mail-header-number header))
8854 (t gnus-reffed-article-number))
8856 (insert " Article retrieved.\n"))
8858 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8859 () ; Malformed head.
8860 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8861 (when (and (stringp id)
8862 (not (string= (gnus-group-real-name group)
8864 ;; If we fetched by Message-ID and the article came
8865 ;; from a different group, we fudge some bogus article
8866 ;; numbers for this article.
8867 (mail-header-set-number header gnus-reffed-article-number))
8869 (set-buffer gnus-summary-buffer)
8870 (decf gnus-reffed-article-number)
8871 (gnus-remove-header (mail-header-number header))
8872 (push header gnus-newsgroup-headers)
8873 (setq gnus-current-headers header)
8874 (push (mail-header-number header) gnus-newsgroup-limit)))
8877 (defun gnus-remove-header (number)
8878 "Remove header NUMBER from `gnus-newsgroup-headers'."
8879 (if (and gnus-newsgroup-headers
8880 (= number (mail-header-number (car gnus-newsgroup-headers))))
8881 (pop gnus-newsgroup-headers)
8882 (let ((headers gnus-newsgroup-headers))
8883 (while (and (cdr headers)
8884 (not (= number (mail-header-number (cadr headers)))))
8887 (setcdr headers (cddr headers))))))
8890 ;;; summary highlights
8893 (defun gnus-highlight-selected-summary ()
8894 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8895 ;; Highlight selected article in summary buffer
8896 (when gnus-summary-selected-face
8898 (let* ((beg (progn (beginning-of-line) (point)))
8899 (end (progn (end-of-line) (point)))
8900 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8901 (from (if (get-text-property beg gnus-mouse-face-prop)
8903 (or (next-single-property-change
8904 beg gnus-mouse-face-prop nil end)
8909 (or (next-single-property-change
8910 from gnus-mouse-face-prop nil end)
8912 ;; If no mouse-face prop on line we will have to = from = end,
8913 ;; so we highlight the entire line instead.
8914 (when (= (+ to 2) from)
8917 (if gnus-newsgroup-selected-overlay
8918 ;; Move old overlay.
8920 gnus-newsgroup-selected-overlay from to (current-buffer))
8921 ;; Create new overlay.
8923 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8924 'face gnus-summary-selected-face))))))
8926 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8927 (defun gnus-summary-highlight-line ()
8928 "Highlight current line according to `gnus-summary-highlight'."
8929 (let* ((list gnus-summary-highlight)
8931 (end (progn (end-of-line) (point)))
8932 ;; now find out where the line starts and leave point there.
8933 (beg (progn (beginning-of-line) (point)))
8934 (article (gnus-summary-article-number))
8935 (score (or (cdr (assq (or article gnus-current-article)
8936 gnus-newsgroup-scored))
8937 gnus-summary-default-score 0))
8938 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8939 (inhibit-read-only t))
8940 ;; Eval the cars of the lists until we find a match.
8941 (let ((default gnus-summary-default-score))
8943 (not (eval (caar list))))
8944 (setq list (cdr list))))
8945 (let ((face (cdar list)))
8946 (unless (eq face (get-text-property beg 'face))
8947 (gnus-put-text-property-excluding-characters-with-faces
8949 (setq face (if (boundp face) (symbol-value face) face)))
8950 (when gnus-summary-highlight-line-function
8951 (funcall gnus-summary-highlight-line-function article face))))
8954 (defun gnus-update-read-articles (group unread &optional compute)
8955 "Update the list of read articles in GROUP."
8956 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8957 (entry (gnus-gethash group gnus-newsrc-hashtb))
8958 (info (nth 2 entry))
8960 (unread (sort (copy-sequence unread) '<))
8962 (if (or (not info) (not active))
8963 ;; There is no info on this group if it was, in fact,
8964 ;; killed. Gnus stores no information on killed groups, so
8965 ;; there's nothing to be done.
8966 ;; One could store the information somewhere temporarily,
8967 ;; perhaps... Hmmm...
8969 ;; Remove any negative articles numbers.
8970 (while (and unread (< (car unread) 0))
8971 (setq unread (cdr unread)))
8972 ;; Remove any expired article numbers
8973 (while (and unread (< (car unread) (car active)))
8974 (setq unread (cdr unread)))
8975 ;; Compute the ranges of read articles by looking at the list of
8978 (when (/= (car unread) prev)
8979 (push (if (= prev (1- (car unread))) prev
8980 (cons prev (1- (car unread))))
8982 (setq prev (1+ (car unread)))
8983 (setq unread (cdr unread)))
8984 (when (<= prev (cdr active))
8985 (push (cons prev (cdr active)) read))
8987 (if (> (length read) 1) (nreverse read) read)
8989 (set-buffer gnus-group-buffer)
8992 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8993 (gnus-info-set-read ',info ',(gnus-info-read info))
8994 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8995 (gnus-group-update-group ,group t))))
8996 ;; Enter this list into the group info.
8998 info (if (> (length read) 1) (nreverse read) read))
8999 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9000 (gnus-get-unread-articles-in-group info (gnus-active group))
9003 (defun gnus-offer-save-summaries ()
9004 "Offer to save all active summary buffers."
9006 (let ((buflist (buffer-list))
9008 ;; Go through all buffers and find all summaries.
9010 (and (setq bufname (buffer-name (car buflist)))
9011 (string-match "Summary" bufname)
9013 (set-buffer bufname)
9014 ;; We check that this is, indeed, a summary buffer.
9015 (and (eq major-mode 'gnus-summary-mode)
9016 ;; Also make sure this isn't bogus.
9017 gnus-newsgroup-prepared
9018 ;; Also make sure that this isn't a dead summary buffer.
9019 (not gnus-dead-summary-mode)))
9020 (push bufname buffers))
9021 (setq buflist (cdr buflist)))
9022 ;; Go through all these summary buffers and offer to save them.
9025 "Update summary buffer %s? "
9027 (switch-to-buffer buf)
9028 (gnus-summary-exit))
9032 ;;; @ for mime-partial
9035 (defun gnus-request-partial-message ()
9037 (let ((number (gnus-summary-article-number))
9038 (group gnus-newsgroup-name)
9039 (mother gnus-article-buffer))
9040 (set-buffer (get-buffer-create " *Partial Article*"))
9042 (setq mime-preview-buffer mother)
9043 (gnus-request-article-this-buffer number group)
9047 (autoload 'mime-combine-message/partial-pieces-automatically
9049 "Internal method to combine message/partial messages automatically.")
9052 'action '((type . message)(subtype . partial)
9053 (major-mode . gnus-original-article-mode)
9054 (method . mime-combine-message/partial-pieces-automatically)
9055 (summary-buffer-exp . gnus-summary-buffer)
9056 (request-partial-message-method . gnus-request-partial-message)
9067 (run-hooks 'gnus-sum-load-hook)
9069 ;;; gnus-sum.el ends here