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)
1013 ;; Subject simplification.
1015 (defun gnus-simplify-whitespace (str)
1016 "Remove excessive whitespace."
1019 (while (string-match "[ \t][ \t]+" mystr)
1020 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1022 (substring mystr (match-end 0)))))
1024 (when (string-match "^[ \t]+" mystr)
1025 (setq mystr (substring mystr (match-end 0))))
1027 (when (string-match "[ \t]+$" mystr)
1028 (setq mystr (substring mystr 0 (match-beginning 0))))
1031 (defsubst gnus-simplify-subject-re (subject)
1032 "Remove \"Re:\" from subject lines."
1033 (if (string-match "^[Rr][Ee]: *" subject)
1034 (substring subject (match-end 0))
1037 (defun gnus-simplify-subject (subject &optional re-only)
1038 "Remove `Re:' and words in parentheses.
1039 If RE-ONLY is non-nil, strip leading `Re:'s only."
1040 (let ((case-fold-search t)) ;Ignore case.
1041 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1042 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1043 (setq subject (substring subject (match-end 0))))
1044 ;; Remove uninteresting prefixes.
1045 (when (and (not re-only)
1046 gnus-simplify-ignored-prefixes
1047 (string-match gnus-simplify-ignored-prefixes subject))
1048 (setq subject (substring subject (match-end 0))))
1049 ;; Remove words in parentheses from end.
1051 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1052 (setq subject (substring subject 0 (match-beginning 0)))))
1053 ;; Return subject string.
1056 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1058 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1059 (goto-char (point-min))
1060 (while (re-search-forward regexp nil t)
1061 (replace-match (or newtext ""))))
1063 (defun gnus-simplify-buffer-fuzzy ()
1064 "Simplify string in the buffer fuzzily.
1065 The string in the accessible portion of the current buffer is simplified.
1066 It is assumed to be a single-line subject.
1067 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1068 matter is removed. Additional things can be deleted by setting
1069 gnus-simplify-subject-fuzzy-regexp."
1070 (let ((case-fold-search t)
1072 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1074 (while (not (eq modified-tick (buffer-modified-tick)))
1075 (setq modified-tick (buffer-modified-tick))
1077 ((listp gnus-simplify-subject-fuzzy-regexp)
1078 (mapcar 'gnus-simplify-buffer-fuzzy-step
1079 gnus-simplify-subject-fuzzy-regexp))
1080 (gnus-simplify-subject-fuzzy-regexp
1081 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1082 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1083 (gnus-simplify-buffer-fuzzy-step
1084 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1085 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1087 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1088 (gnus-simplify-buffer-fuzzy-step " +" " ")
1089 (gnus-simplify-buffer-fuzzy-step " $")
1090 (gnus-simplify-buffer-fuzzy-step "^ +")))
1092 (defun gnus-simplify-subject-fuzzy (subject)
1093 "Simplify a subject string fuzzily.
1094 See `gnus-simplify-buffer-fuzzy' for details."
1096 (gnus-set-work-buffer)
1097 (let ((case-fold-search t))
1098 ;; Remove uninteresting prefixes.
1099 (when (and gnus-simplify-ignored-prefixes
1100 (string-match gnus-simplify-ignored-prefixes subject))
1101 (setq subject (substring subject (match-end 0))))
1103 (inline (gnus-simplify-buffer-fuzzy))
1106 (defsubst gnus-simplify-subject-fully (subject)
1107 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1109 (gnus-simplify-subject-functions
1110 (gnus-map-function gnus-simplify-subject-functions subject))
1111 ((null gnus-summary-gather-subject-limit)
1112 (gnus-simplify-subject-re subject))
1113 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1114 (gnus-simplify-subject-fuzzy subject))
1115 ((numberp gnus-summary-gather-subject-limit)
1116 (gnus-limit-string (gnus-simplify-subject-re subject)
1117 gnus-summary-gather-subject-limit))
1121 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1122 "Check whether two subjects are equal.
1123 If optional argument simple-first is t, first argument is already
1126 ((null simple-first)
1127 (equal (gnus-simplify-subject-fully s1)
1128 (gnus-simplify-subject-fully s2)))
1131 (gnus-simplify-subject-fully s2)))))
1133 (defun gnus-summary-bubble-group ()
1134 "Increase the score of the current group.
1135 This is a handy function to add to `gnus-summary-exit-hook' to
1136 increase the score of each group you read."
1137 (gnus-group-add-score gnus-newsgroup-name))
1141 ;;; Gnus summary mode
1144 (put 'gnus-summary-mode 'mode-class 'special)
1147 ;; Non-orthogonal keys
1149 (gnus-define-keys gnus-summary-mode-map
1150 " " gnus-summary-next-page
1151 "\177" gnus-summary-prev-page
1152 [delete] gnus-summary-prev-page
1153 [backspace] gnus-summary-prev-page
1154 "\r" gnus-summary-scroll-up
1155 "\M-\r" gnus-summary-scroll-down
1156 "n" gnus-summary-next-unread-article
1157 "p" gnus-summary-prev-unread-article
1158 "N" gnus-summary-next-article
1159 "P" gnus-summary-prev-article
1160 "\M-\C-n" gnus-summary-next-same-subject
1161 "\M-\C-p" gnus-summary-prev-same-subject
1162 "\M-n" gnus-summary-next-unread-subject
1163 "\M-p" gnus-summary-prev-unread-subject
1164 "." gnus-summary-first-unread-article
1165 "," gnus-summary-best-unread-article
1166 "\M-s" gnus-summary-search-article-forward
1167 "\M-r" gnus-summary-search-article-backward
1168 "<" gnus-summary-beginning-of-article
1169 ">" gnus-summary-end-of-article
1170 "j" gnus-summary-goto-article
1171 "^" gnus-summary-refer-parent-article
1172 "\M-^" gnus-summary-refer-article
1173 "u" gnus-summary-tick-article-forward
1174 "!" gnus-summary-tick-article-forward
1175 "U" gnus-summary-tick-article-backward
1176 "d" gnus-summary-mark-as-read-forward
1177 "D" gnus-summary-mark-as-read-backward
1178 "E" gnus-summary-mark-as-expirable
1179 "\M-u" gnus-summary-clear-mark-forward
1180 "\M-U" gnus-summary-clear-mark-backward
1181 "k" gnus-summary-kill-same-subject-and-select
1182 "\C-k" gnus-summary-kill-same-subject
1183 "\M-\C-k" gnus-summary-kill-thread
1184 "\M-\C-l" gnus-summary-lower-thread
1185 "e" gnus-summary-edit-article
1186 "#" gnus-summary-mark-as-processable
1187 "\M-#" gnus-summary-unmark-as-processable
1188 "\M-\C-t" gnus-summary-toggle-threads
1189 "\M-\C-s" gnus-summary-show-thread
1190 "\M-\C-h" gnus-summary-hide-thread
1191 "\M-\C-f" gnus-summary-next-thread
1192 "\M-\C-b" gnus-summary-prev-thread
1193 "\M-\C-u" gnus-summary-up-thread
1194 "\M-\C-d" gnus-summary-down-thread
1195 "&" gnus-summary-execute-command
1196 "c" gnus-summary-catchup-and-exit
1197 "\C-w" gnus-summary-mark-region-as-read
1198 "\C-t" gnus-summary-toggle-truncation
1199 "?" gnus-summary-mark-as-dormant
1200 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1201 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1202 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1203 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1204 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1205 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1206 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1207 "=" gnus-summary-expand-window
1208 "\C-x\C-s" gnus-summary-reselect-current-group
1209 "\M-g" gnus-summary-rescan-group
1210 "w" gnus-summary-stop-page-breaking
1211 "\C-c\C-r" gnus-summary-caesar-message
1212 "\M-t" gnus-summary-toggle-mime
1213 "f" gnus-summary-followup
1214 "F" gnus-summary-followup-with-original
1215 "C" gnus-summary-cancel-article
1216 "r" gnus-summary-reply
1217 "R" gnus-summary-reply-with-original
1218 "\C-c\C-f" gnus-summary-mail-forward
1219 "o" gnus-summary-save-article
1220 "\C-o" gnus-summary-save-article-mail
1221 "|" gnus-summary-pipe-output
1222 "\M-k" gnus-summary-edit-local-kill
1223 "\M-K" gnus-summary-edit-global-kill
1225 "\C-c\C-d" gnus-summary-describe-group
1226 "q" gnus-summary-exit
1227 "Q" gnus-summary-exit-no-update
1228 "\C-c\C-i" gnus-info-find-node
1229 gnus-mouse-2 gnus-mouse-pick-article
1230 "m" gnus-summary-mail-other-window
1231 "a" gnus-summary-post-news
1232 "x" gnus-summary-limit-to-unread
1233 "s" gnus-summary-isearch-article
1234 "t" gnus-article-hide-headers
1235 "g" gnus-summary-show-article
1236 "l" gnus-summary-goto-last-article
1237 "v" gnus-summary-preview-mime-message
1238 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1239 "\C-d" gnus-summary-enter-digest-group
1240 "\M-\C-d" gnus-summary-read-document
1241 "\M-\C-e" gnus-summary-edit-parameters
1243 "*" gnus-cache-enter-article
1244 "\M-*" gnus-cache-remove-article
1245 "\M-&" gnus-summary-universal-argument
1246 "\C-l" gnus-recenter
1247 "I" gnus-summary-increase-score
1248 "L" gnus-summary-lower-score
1249 "\M-i" gnus-symbolic-argument
1250 "h" gnus-summary-select-article-buffer
1252 "V" gnus-summary-score-map
1253 "X" gnus-uu-extract-map
1254 "S" gnus-summary-send-map)
1256 ;; Sort of orthogonal keymap
1257 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1258 "t" gnus-summary-tick-article-forward
1259 "!" gnus-summary-tick-article-forward
1260 "d" gnus-summary-mark-as-read-forward
1261 "r" gnus-summary-mark-as-read-forward
1262 "c" gnus-summary-clear-mark-forward
1263 " " gnus-summary-clear-mark-forward
1264 "e" gnus-summary-mark-as-expirable
1265 "x" gnus-summary-mark-as-expirable
1266 "?" gnus-summary-mark-as-dormant
1267 "b" gnus-summary-set-bookmark
1268 "B" gnus-summary-remove-bookmark
1269 "#" gnus-summary-mark-as-processable
1270 "\M-#" gnus-summary-unmark-as-processable
1271 "S" gnus-summary-limit-include-expunged
1272 "C" gnus-summary-catchup
1273 "H" gnus-summary-catchup-to-here
1274 "\C-c" gnus-summary-catchup-all
1275 "k" gnus-summary-kill-same-subject-and-select
1276 "K" gnus-summary-kill-same-subject
1277 "P" gnus-uu-mark-map)
1279 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1280 "c" gnus-summary-clear-above
1281 "u" gnus-summary-tick-above
1282 "m" gnus-summary-mark-above
1283 "k" gnus-summary-kill-below)
1285 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1286 "/" gnus-summary-limit-to-subject
1287 "n" gnus-summary-limit-to-articles
1288 "w" gnus-summary-pop-limit
1289 "s" gnus-summary-limit-to-subject
1290 "a" gnus-summary-limit-to-author
1291 "u" gnus-summary-limit-to-unread
1292 "m" gnus-summary-limit-to-marks
1293 "v" gnus-summary-limit-to-score
1294 "*" gnus-summary-limit-include-cached
1295 "D" gnus-summary-limit-include-dormant
1296 "T" gnus-summary-limit-include-thread
1297 "d" gnus-summary-limit-exclude-dormant
1298 "t" gnus-summary-limit-to-age
1299 "E" gnus-summary-limit-include-expunged
1300 "c" gnus-summary-limit-exclude-childless-dormant
1301 "C" gnus-summary-limit-mark-excluded-as-read)
1303 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1304 "n" gnus-summary-next-unread-article
1305 "p" gnus-summary-prev-unread-article
1306 "N" gnus-summary-next-article
1307 "P" gnus-summary-prev-article
1308 "\C-n" gnus-summary-next-same-subject
1309 "\C-p" gnus-summary-prev-same-subject
1310 "\M-n" gnus-summary-next-unread-subject
1311 "\M-p" gnus-summary-prev-unread-subject
1312 "f" gnus-summary-first-unread-article
1313 "b" gnus-summary-best-unread-article
1314 "j" gnus-summary-goto-article
1315 "g" gnus-summary-goto-subject
1316 "l" gnus-summary-goto-last-article
1317 "o" gnus-summary-pop-article)
1319 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1320 "k" gnus-summary-kill-thread
1321 "l" gnus-summary-lower-thread
1322 "i" gnus-summary-raise-thread
1323 "T" gnus-summary-toggle-threads
1324 "t" gnus-summary-rethread-current
1325 "^" gnus-summary-reparent-thread
1326 "s" gnus-summary-show-thread
1327 "S" gnus-summary-show-all-threads
1328 "h" gnus-summary-hide-thread
1329 "H" gnus-summary-hide-all-threads
1330 "n" gnus-summary-next-thread
1331 "p" gnus-summary-prev-thread
1332 "u" gnus-summary-up-thread
1333 "o" gnus-summary-top-thread
1334 "d" gnus-summary-down-thread
1335 "#" gnus-uu-mark-thread
1336 "\M-#" gnus-uu-unmark-thread)
1338 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1339 "g" gnus-summary-prepare
1340 "c" gnus-summary-insert-cached-articles)
1342 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1343 "c" gnus-summary-catchup-and-exit
1344 "C" gnus-summary-catchup-all-and-exit
1345 "E" gnus-summary-exit-no-update
1346 "Q" gnus-summary-exit
1347 "Z" gnus-summary-exit
1348 "n" gnus-summary-catchup-and-goto-next-group
1349 "R" gnus-summary-reselect-current-group
1350 "G" gnus-summary-rescan-group
1351 "N" gnus-summary-next-group
1352 "s" gnus-summary-save-newsrc
1353 "P" gnus-summary-prev-group)
1355 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1356 " " gnus-summary-next-page
1357 "n" gnus-summary-next-page
1358 "\177" gnus-summary-prev-page
1359 [delete] gnus-summary-prev-page
1360 "p" gnus-summary-prev-page
1361 "\r" gnus-summary-scroll-up
1362 "\M-\r" gnus-summary-scroll-down
1363 "<" gnus-summary-beginning-of-article
1364 ">" gnus-summary-end-of-article
1365 "b" gnus-summary-beginning-of-article
1366 "e" gnus-summary-end-of-article
1367 "^" gnus-summary-refer-parent-article
1368 "r" gnus-summary-refer-parent-article
1369 "R" gnus-summary-refer-references
1370 "T" gnus-summary-refer-thread
1371 "g" gnus-summary-show-article
1372 "s" gnus-summary-isearch-article
1373 "P" gnus-summary-print-article)
1375 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1376 "b" gnus-article-add-buttons
1377 "B" gnus-article-add-buttons-to-head
1378 "o" gnus-article-treat-overstrike
1379 "e" gnus-article-emphasize
1380 "w" gnus-article-fill-cited-article
1381 "c" gnus-article-remove-cr
1382 "f" gnus-article-display-x-face
1383 "l" gnus-summary-stop-page-breaking
1384 "r" gnus-summary-caesar-message
1385 "t" gnus-article-hide-headers
1386 "v" gnus-summary-verbose-headers
1387 "m" gnus-summary-toggle-mime
1388 "h" gnus-article-treat-html
1389 "d" gnus-article-treat-dumbquotes)
1391 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1392 "a" gnus-article-hide
1393 "h" gnus-article-hide-headers
1394 "b" gnus-article-hide-boring-headers
1395 "s" gnus-article-hide-signature
1396 "c" gnus-article-hide-citation
1397 "C" gnus-article-hide-citation-in-followups
1398 "p" gnus-article-hide-pgp
1399 "P" gnus-article-hide-pem
1400 "\C-c" gnus-article-hide-citation-maybe)
1402 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1403 "a" gnus-article-highlight
1404 "h" gnus-article-highlight-headers
1405 "c" gnus-article-highlight-citation
1406 "s" gnus-article-highlight-signature)
1408 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1409 "z" gnus-article-date-ut
1410 "u" gnus-article-date-ut
1411 "l" gnus-article-date-local
1412 "e" gnus-article-date-lapsed
1413 "o" gnus-article-date-original
1414 "i" gnus-article-date-iso8601
1415 "s" gnus-article-date-user)
1417 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1418 "t" gnus-article-remove-trailing-blank-lines
1419 "l" gnus-article-strip-leading-blank-lines
1420 "m" gnus-article-strip-multiple-blank-lines
1421 "a" gnus-article-strip-blank-lines
1422 "A" gnus-article-strip-all-blank-lines
1423 "s" gnus-article-strip-leading-space)
1425 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1427 "f" gnus-summary-fetch-faq
1428 "d" gnus-summary-describe-group
1429 "h" gnus-summary-describe-briefly
1430 "i" gnus-info-find-node)
1432 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1433 "e" gnus-summary-expire-articles
1434 "\M-\C-e" gnus-summary-expire-articles-now
1435 "\177" gnus-summary-delete-article
1436 [delete] gnus-summary-delete-article
1437 "m" gnus-summary-move-article
1438 "r" gnus-summary-respool-article
1439 "w" gnus-summary-edit-article
1440 "c" gnus-summary-copy-article
1441 "B" gnus-summary-crosspost-article
1442 "q" gnus-summary-respool-query
1443 "t" gnus-summary-respool-trace
1444 "i" gnus-summary-import-article
1445 "p" gnus-summary-article-posted-p)
1447 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1448 "o" gnus-summary-save-article
1449 "m" gnus-summary-save-article-mail
1450 "F" gnus-summary-write-article-file
1451 "r" gnus-summary-save-article-rmail
1452 "f" gnus-summary-save-article-file
1453 "b" gnus-summary-save-article-body-file
1454 "h" gnus-summary-save-article-folder
1455 "v" gnus-summary-save-article-vm
1456 "p" gnus-summary-pipe-output
1457 "s" gnus-soup-add-article))
1459 (defun gnus-summary-make-menu-bar ()
1460 (gnus-turn-off-edit-menu 'summary)
1462 (unless (boundp 'gnus-summary-misc-menu)
1465 gnus-summary-kill-menu gnus-summary-mode-map ""
1470 ["Enter score..." gnus-summary-score-entry t]
1471 ["Customize" gnus-score-customize t])
1472 (gnus-make-score-map 'increase)
1473 (gnus-make-score-map 'lower)
1475 ["Kill below" gnus-summary-kill-below t]
1476 ["Mark above" gnus-summary-mark-above t]
1477 ["Tick above" gnus-summary-tick-above t]
1478 ["Clear above" gnus-summary-clear-above t])
1479 ["Current score" gnus-summary-current-score t]
1480 ["Set score" gnus-summary-set-score t]
1481 ["Switch current score file..." gnus-score-change-score-file t]
1482 ["Set mark below..." gnus-score-set-mark-below t]
1483 ["Set expunge below..." gnus-score-set-expunge-below t]
1484 ["Edit current score file" gnus-score-edit-current-scores t]
1485 ["Edit score file" gnus-score-edit-file t]
1486 ["Trace score" gnus-score-find-trace t]
1487 ["Find words" gnus-score-find-favourite-words t]
1488 ["Rescore buffer" gnus-summary-rescore t]
1489 ["Increase score..." gnus-summary-increase-score t]
1490 ["Lower score..." gnus-summary-lower-score t]))))
1492 ;; Define both the Article menu in the summary buffer and the equivalent
1493 ;; Commands menu in the article buffer here for consistency.
1496 ["All" gnus-article-hide t]
1497 ["Headers" gnus-article-hide-headers t]
1498 ["Signature" gnus-article-hide-signature t]
1499 ["Citation" gnus-article-hide-citation t]
1500 ["PGP" gnus-article-hide-pgp t]
1501 ["Boring headers" gnus-article-hide-boring-headers t])
1503 ["All" gnus-article-highlight t]
1504 ["Headers" gnus-article-highlight-headers t]
1505 ["Signature" gnus-article-highlight-signature t]
1506 ["Citation" gnus-article-highlight-citation t])
1508 ["Local" gnus-article-date-local t]
1509 ["ISO8601" gnus-article-date-iso8601 t]
1510 ["UT" gnus-article-date-ut t]
1511 ["Original" gnus-article-date-original t]
1512 ["Lapsed" gnus-article-date-lapsed t]
1513 ["User-defined" gnus-article-date-user t])
1516 ["Leading" gnus-article-strip-leading-blank-lines t]
1517 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1518 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1519 ["All of the above" gnus-article-strip-blank-lines t]
1520 ["All" gnus-article-strip-all-blank-lines t]
1521 ["Leading space" gnus-article-strip-leading-space t])
1522 ["Overstrike" gnus-article-treat-overstrike t]
1523 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1524 ["Emphasis" gnus-article-emphasize t]
1525 ["Word wrap" gnus-article-fill-cited-article t]
1526 ["CR" gnus-article-remove-cr t]
1527 ["Show X-Face" gnus-article-display-x-face t]
1528 ["UnHTMLize" gnus-article-treat-html t]
1529 ["Rot 13" gnus-summary-caesar-message t]
1530 ["Unix pipe" gnus-summary-pipe-message t]
1531 ["Add buttons" gnus-article-add-buttons t]
1532 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1533 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1534 ["Toggle MIME" gnus-summary-toggle-mime t]
1535 ["Verbose header" gnus-summary-verbose-headers t]
1536 ["Toggle header" gnus-summary-toggle-header t])
1538 ["Save in default format" gnus-summary-save-article t]
1539 ["Save in file" gnus-summary-save-article-file t]
1540 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1541 ["Save in MH folder" gnus-summary-save-article-folder t]
1542 ["Save in VM folder" gnus-summary-save-article-vm t]
1543 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1544 ["Save body in file" gnus-summary-save-article-body-file t]
1545 ["Pipe through a filter" gnus-summary-pipe-output t]
1546 ["Add to SOUP packet" gnus-soup-add-article t]
1547 ["Print" gnus-summary-print-article t])
1549 ["Respool article..." gnus-summary-respool-article t]
1550 ["Move article..." gnus-summary-move-article
1551 (gnus-check-backend-function
1552 'request-move-article gnus-newsgroup-name)]
1553 ["Copy article..." gnus-summary-copy-article t]
1554 ["Crosspost article..." gnus-summary-crosspost-article
1555 (gnus-check-backend-function
1556 'request-replace-article gnus-newsgroup-name)]
1557 ["Import file..." gnus-summary-import-article t]
1558 ["Check if posted" gnus-summary-article-posted-p t]
1559 ["Edit article" gnus-summary-edit-article
1560 (not (gnus-group-read-only-p))]
1561 ["Delete article" gnus-summary-delete-article
1562 (gnus-check-backend-function
1563 'request-expire-articles gnus-newsgroup-name)]
1564 ["Query respool" gnus-summary-respool-query t]
1565 ["Trace respool" gnus-summary-respool-trace t]
1566 ["Delete expirable articles" gnus-summary-expire-articles-now
1567 (gnus-check-backend-function
1568 'request-expire-articles gnus-newsgroup-name)])
1570 ["Uudecode" gnus-uu-decode-uu t]
1571 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1572 ["Unshar" gnus-uu-decode-unshar t]
1573 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1574 ["Save" gnus-uu-decode-save t]
1575 ["Binhex" gnus-uu-decode-binhex t]
1576 ["Postscript" gnus-uu-decode-postscript t])
1578 ["Enter article" gnus-cache-enter-article t]
1579 ["Remove article" gnus-cache-remove-article t])
1580 ["Select article buffer" gnus-summary-select-article-buffer t]
1581 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1582 ["Isearch article..." gnus-summary-isearch-article t]
1583 ["Beginning of the article" gnus-summary-beginning-of-article t]
1584 ["End of the article" gnus-summary-end-of-article t]
1585 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1586 ["Fetch referenced articles" gnus-summary-refer-references t]
1587 ["Fetch current thread" gnus-summary-refer-thread t]
1588 ["Fetch article with id..." gnus-summary-refer-article t]
1589 ["Redisplay" gnus-summary-show-article t])))
1591 gnus-summary-article-menu gnus-summary-mode-map ""
1592 (cons "Article" innards))
1595 gnus-article-commands-menu gnus-article-mode-map ""
1596 (cons "Commands" innards)))
1599 gnus-summary-thread-menu gnus-summary-mode-map ""
1601 ["Toggle threading" gnus-summary-toggle-threads t]
1602 ["Hide threads" gnus-summary-hide-all-threads t]
1603 ["Show threads" gnus-summary-show-all-threads t]
1604 ["Hide thread" gnus-summary-hide-thread t]
1605 ["Show thread" gnus-summary-show-thread t]
1606 ["Go to next thread" gnus-summary-next-thread t]
1607 ["Go to previous thread" gnus-summary-prev-thread t]
1608 ["Go down thread" gnus-summary-down-thread t]
1609 ["Go up thread" gnus-summary-up-thread t]
1610 ["Top of thread" gnus-summary-top-thread t]
1611 ["Mark thread as read" gnus-summary-kill-thread t]
1612 ["Lower thread score" gnus-summary-lower-thread t]
1613 ["Raise thread score" gnus-summary-raise-thread t]
1614 ["Rethread current" gnus-summary-rethread-current t]
1618 gnus-summary-post-menu gnus-summary-mode-map ""
1620 ["Post an article" gnus-summary-post-news t]
1621 ["Followup" gnus-summary-followup t]
1622 ["Followup and yank" gnus-summary-followup-with-original t]
1623 ["Supersede article" gnus-summary-supersede-article t]
1624 ["Cancel article" gnus-summary-cancel-article t]
1625 ["Reply" gnus-summary-reply t]
1626 ["Reply and yank" gnus-summary-reply-with-original t]
1627 ["Wide reply" gnus-summary-wide-reply t]
1628 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1629 ["Mail forward" gnus-summary-mail-forward t]
1630 ["Post forward" gnus-summary-post-forward t]
1631 ["Digest and mail" gnus-summary-mail-digest t]
1632 ["Digest and post" gnus-summary-post-digest t]
1633 ["Resend message" gnus-summary-resend-message t]
1634 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1635 ["Send a mail" gnus-summary-mail-other-window t]
1636 ["Uuencode and post" gnus-uu-post-news t]
1637 ["Followup via news" gnus-summary-followup-to-mail t]
1638 ["Followup via news and yank"
1639 gnus-summary-followup-to-mail-with-original t]
1641 ;;["Send" gnus-summary-send-draft t]
1642 ;;["Send bounced" gnus-resend-bounced-mail t])
1646 gnus-summary-misc-menu gnus-summary-mode-map ""
1649 ["Mark as read" gnus-summary-mark-as-read-forward t]
1650 ["Mark same subject and select"
1651 gnus-summary-kill-same-subject-and-select t]
1652 ["Mark same subject" gnus-summary-kill-same-subject t]
1653 ["Catchup" gnus-summary-catchup t]
1654 ["Catchup all" gnus-summary-catchup-all t]
1655 ["Catchup to here" gnus-summary-catchup-to-here t]
1656 ["Catchup region" gnus-summary-mark-region-as-read t]
1657 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1659 ["Tick" gnus-summary-tick-article-forward t]
1660 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1661 ["Remove marks" gnus-summary-clear-mark-forward t]
1662 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1663 ["Set bookmark" gnus-summary-set-bookmark t]
1664 ["Remove bookmark" gnus-summary-remove-bookmark t])
1666 ["Marks..." gnus-summary-limit-to-marks t]
1667 ["Subject..." gnus-summary-limit-to-subject t]
1668 ["Author..." gnus-summary-limit-to-author t]
1669 ["Age..." gnus-summary-limit-to-age t]
1670 ["Score" gnus-summary-limit-to-score t]
1671 ["Unread" gnus-summary-limit-to-unread t]
1672 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1673 ["Articles" gnus-summary-limit-to-articles t]
1674 ["Pop limit" gnus-summary-pop-limit t]
1675 ["Show dormant" gnus-summary-limit-include-dormant t]
1676 ["Hide childless dormant"
1677 gnus-summary-limit-exclude-childless-dormant t]
1678 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1679 ["Show expunged" gnus-summary-show-all-expunged t])
1681 ["Set mark" gnus-summary-mark-as-processable t]
1682 ["Remove mark" gnus-summary-unmark-as-processable t]
1683 ["Remove all marks" gnus-summary-unmark-all-processable t]
1684 ["Mark above" gnus-uu-mark-over t]
1685 ["Mark series" gnus-uu-mark-series t]
1686 ["Mark region" gnus-uu-mark-region t]
1687 ["Unmark region" gnus-uu-unmark-region t]
1688 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1689 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1690 ["Mark all" gnus-uu-mark-all t]
1691 ["Mark buffer" gnus-uu-mark-buffer t]
1692 ["Mark sparse" gnus-uu-mark-sparse t]
1693 ["Mark thread" gnus-uu-mark-thread t]
1694 ["Unmark thread" gnus-uu-unmark-thread t]
1695 ("Process Mark Sets"
1696 ["Kill" gnus-summary-kill-process-mark t]
1697 ["Yank" gnus-summary-yank-process-mark
1698 gnus-newsgroup-process-stack]
1699 ["Save" gnus-summary-save-process-mark t]))
1701 ["Page forward" gnus-summary-next-page t]
1702 ["Page backward" gnus-summary-prev-page t]
1703 ["Line forward" gnus-summary-scroll-up t])
1705 ["Next unread article" gnus-summary-next-unread-article t]
1706 ["Previous unread article" gnus-summary-prev-unread-article t]
1707 ["Next article" gnus-summary-next-article t]
1708 ["Previous article" gnus-summary-prev-article t]
1709 ["Next unread subject" gnus-summary-next-unread-subject t]
1710 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1711 ["Next article same subject" gnus-summary-next-same-subject t]
1712 ["Previous article same subject" gnus-summary-prev-same-subject t]
1713 ["First unread article" gnus-summary-first-unread-article t]
1714 ["Best unread article" gnus-summary-best-unread-article t]
1715 ["Go to subject number..." gnus-summary-goto-subject t]
1716 ["Go to article number..." gnus-summary-goto-article t]
1717 ["Go to the last article" gnus-summary-goto-last-article t]
1718 ["Pop article off history" gnus-summary-pop-article t])
1720 ["Sort by number" gnus-summary-sort-by-number t]
1721 ["Sort by author" gnus-summary-sort-by-author t]
1722 ["Sort by subject" gnus-summary-sort-by-subject t]
1723 ["Sort by date" gnus-summary-sort-by-date t]
1724 ["Sort by score" gnus-summary-sort-by-score t]
1725 ["Sort by lines" gnus-summary-sort-by-lines t])
1727 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1728 ["Describe group" gnus-summary-describe-group t]
1729 ["Read manual" gnus-info-find-node t])
1731 ["Pick and read" gnus-pick-mode t]
1732 ["Binary" gnus-binary-mode t])
1734 ["Regenerate" gnus-summary-prepare t]
1735 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1736 ["Toggle threading" gnus-summary-toggle-threads t])
1737 ["Filter articles..." gnus-summary-execute-command t]
1738 ["Run command on subjects..." gnus-summary-universal-argument t]
1739 ["Search articles forward..." gnus-summary-search-article-forward t]
1740 ["Search articles backward..." gnus-summary-search-article-backward t]
1741 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1742 ["Expand window" gnus-summary-expand-window t]
1743 ["Expire expirable articles" gnus-summary-expire-articles
1744 (gnus-check-backend-function
1745 'request-expire-articles gnus-newsgroup-name)]
1746 ["Edit local kill file" gnus-summary-edit-local-kill t]
1747 ["Edit main kill file" gnus-summary-edit-global-kill t]
1748 ["Edit group parameters" gnus-summary-edit-parameters t]
1749 ["Send a bug report" gnus-bug t]
1751 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1752 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1753 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1754 ["Exit group" gnus-summary-exit t]
1755 ["Exit group without updating" gnus-summary-exit-no-update t]
1756 ["Exit and goto next group" gnus-summary-next-group t]
1757 ["Exit and goto prev group" gnus-summary-prev-group t]
1758 ["Reselect group" gnus-summary-reselect-current-group t]
1759 ["Rescan group" gnus-summary-rescan-group t]
1760 ["Update dribble" gnus-summary-save-newsrc t])))
1762 (gnus-run-hooks 'gnus-summary-menu-hook)))
1764 (defun gnus-score-set-default (var value)
1765 "A version of set that updates the GNU Emacs menu-bar."
1767 ;; It is the message that forces the active status to be updated.
1770 (defun gnus-make-score-map (type)
1771 "Make a summary score map of type TYPE."
1774 (let ((headers '(("author" "from" string)
1775 ("subject" "subject" string)
1776 ("article body" "body" string)
1777 ("article head" "head" string)
1778 ("xref" "xref" string)
1779 ("lines" "lines" number)
1780 ("followups to author" "followup" string)))
1781 (types '((number ("less than" <)
1784 (string ("substring" s)
1788 (perms '(("temporary" (current-time-string))
1796 (if (eq type 'lower)
1801 (setq header (car headers))
1807 (let ((ts (cdr (assoc (nth 2 header) types)))
1823 'gnus-summary-score-entry
1825 (if (or (string= (nth 1 header)
1827 (string= (nth 1 header)
1830 (list 'gnus-summary-header
1832 (list 'quote (nth 1 (car ts)))
1833 (list 'gnus-score-default nil)
1839 (list (nreverse outp))))
1842 (list (nreverse outt))))
1844 (setq headers (cdr headers)))
1845 (list (nreverse outh))))))))
1849 (defun gnus-summary-mode (&optional group)
1850 "Major mode for reading articles.
1852 All normal editing commands are switched off.
1853 \\<gnus-summary-mode-map>
1854 Each line in this buffer represents one article. To read an
1855 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1856 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1859 You can also post articles and send mail from this buffer. To
1860 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1861 of an article, type `\\[gnus-summary-reply]'.
1863 There are approx. one gazillion commands you can execute in this
1864 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1866 The following commands are available:
1868 \\{gnus-summary-mode-map}"
1870 (when (gnus-visual-p 'summary-menu 'menu)
1871 (gnus-summary-make-menu-bar))
1872 (kill-all-local-variables)
1873 (gnus-summary-make-local-variables)
1874 (gnus-make-thread-indent-array)
1875 (gnus-simplify-mode-line)
1876 (setq major-mode 'gnus-summary-mode)
1877 (setq mode-name "Summary")
1878 (make-local-variable 'minor-mode-alist)
1879 (use-local-map gnus-summary-mode-map)
1880 (buffer-disable-undo (current-buffer))
1881 (setq buffer-read-only t) ;Disable modification
1882 (setq truncate-lines t)
1883 (setq selective-display t)
1884 (setq selective-display-ellipses t) ;Display `...'
1885 (gnus-summary-set-display-table)
1886 (gnus-set-default-directory)
1887 (setq gnus-newsgroup-name group)
1888 (make-local-variable 'gnus-summary-line-format)
1889 (make-local-variable 'gnus-summary-line-format-spec)
1890 (make-local-variable 'gnus-summary-dummy-line-format)
1891 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1892 (make-local-variable 'gnus-summary-mark-positions)
1893 (make-local-hook 'post-command-hook)
1894 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1895 (make-local-hook 'pre-command-hook)
1896 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1897 (gnus-run-hooks 'gnus-summary-mode-hook)
1898 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1899 (gnus-update-summary-mark-positions))
1901 (defun gnus-summary-make-local-variables ()
1902 "Make all the local summary buffer variables."
1903 (let ((locals gnus-summary-local-variables)
1905 (while (setq local (pop locals))
1908 (if (eq (cdr local) 'global)
1909 ;; Copy the global value of the variable.
1910 (setq global (symbol-value (car local)))
1911 ;; Use the value from the list.
1912 (setq global (eval (cdr local))))
1913 (make-local-variable (car local))
1914 (set (car local) global))
1915 ;; Simple nil-valued local variable.
1916 (make-local-variable local)
1919 (defun gnus-summary-clear-local-variables ()
1920 (let ((locals gnus-summary-local-variables))
1922 (if (consp (car locals))
1923 (and (vectorp (caar locals))
1924 (set (caar locals) nil))
1925 (and (vectorp (car locals))
1926 (set (car locals) nil)))
1927 (setq locals (cdr locals)))))
1929 ;; Summary data functions.
1931 (defmacro gnus-data-number (data)
1934 (defmacro gnus-data-set-number (data number)
1935 `(setcar ,data ,number))
1937 (defmacro gnus-data-mark (data)
1940 (defmacro gnus-data-set-mark (data mark)
1941 `(setcar (nthcdr 1 ,data) ,mark))
1943 (defmacro gnus-data-pos (data)
1946 (defmacro gnus-data-set-pos (data pos)
1947 `(setcar (nthcdr 2 ,data) ,pos))
1949 (defmacro gnus-data-header (data)
1952 (defmacro gnus-data-set-header (data header)
1953 `(setf (nth 3 ,data) ,header))
1955 (defmacro gnus-data-level (data)
1958 (defmacro gnus-data-unread-p (data)
1959 `(= (nth 1 ,data) gnus-unread-mark))
1961 (defmacro gnus-data-read-p (data)
1962 `(/= (nth 1 ,data) gnus-unread-mark))
1964 (defmacro gnus-data-pseudo-p (data)
1965 `(consp (nth 3 ,data)))
1967 (defmacro gnus-data-find (number)
1968 `(assq ,number gnus-newsgroup-data))
1970 (defmacro gnus-data-find-list (number &optional data)
1971 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1972 (memq (assq ,number bdata)
1975 (defmacro gnus-data-make (number mark pos header level)
1976 `(list ,number ,mark ,pos ,header ,level))
1978 (defun gnus-data-enter (after-article number mark pos header level offset)
1979 (let ((data (gnus-data-find-list after-article)))
1981 (error "No such article: %d" after-article))
1982 (setcdr data (cons (gnus-data-make number mark pos header level)
1984 (setq gnus-newsgroup-data-reverse nil)
1985 (gnus-data-update-list (cddr data) offset)))
1987 (defun gnus-data-enter-list (after-article list &optional offset)
1989 (let ((data (and after-article (gnus-data-find-list after-article)))
1993 (let ((odata gnus-newsgroup-data))
1994 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
1996 (gnus-data-update-list odata offset)))
1997 ;; Find the last element in the list to be spliced into the main
2000 (setq list (cdr list)))
2003 (setcdr list gnus-newsgroup-data)
2004 (setq gnus-newsgroup-data ilist)
2006 (gnus-data-update-list (cdr list) offset)))
2007 (setcdr list (cdr data))
2010 (gnus-data-update-list (cdr list) offset))))
2011 (setq gnus-newsgroup-data-reverse nil))))
2013 (defun gnus-data-remove (article &optional offset)
2014 (let ((data gnus-newsgroup-data))
2015 (if (= (gnus-data-number (car data)) article)
2017 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2018 gnus-newsgroup-data-reverse nil)
2020 (gnus-data-update-list gnus-newsgroup-data offset)))
2022 (when (= (gnus-data-number (cadr data)) article)
2023 (setcdr data (cddr data))
2025 (gnus-data-update-list (cdr data) offset))
2027 gnus-newsgroup-data-reverse nil))
2028 (setq data (cdr data))))))
2030 (defmacro gnus-data-list (backward)
2032 (or gnus-newsgroup-data-reverse
2033 (setq gnus-newsgroup-data-reverse
2034 (reverse gnus-newsgroup-data)))
2035 gnus-newsgroup-data))
2037 (defun gnus-data-update-list (data offset)
2038 "Add OFFSET to the POS of all data entries in DATA."
2039 (setq gnus-newsgroup-data-reverse nil)
2041 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2042 (setq data (cdr data))))
2044 (defun gnus-summary-article-pseudo-p (article)
2045 "Say whether this article is a pseudo article or not."
2046 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2048 (defmacro gnus-summary-article-sparse-p (article)
2049 "Say whether this article is a sparse article or not."
2050 `(memq ,article gnus-newsgroup-sparse))
2052 (defmacro gnus-summary-article-ancient-p (article)
2053 "Say whether this article is a sparse article or not."
2054 `(memq ,article gnus-newsgroup-ancient))
2056 (defun gnus-article-parent-p (number)
2057 "Say whether this article is a parent or not."
2058 (let ((data (gnus-data-find-list number)))
2059 (and (cdr data) ; There has to be an article after...
2060 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2061 (gnus-data-level (nth 1 data))))))
2063 (defun gnus-article-children (number)
2064 "Return a list of all children to NUMBER."
2065 (let* ((data (gnus-data-find-list number))
2066 (level (gnus-data-level (car data)))
2068 (setq data (cdr data))
2070 (= (gnus-data-level (car data)) (1+ level)))
2071 (push (gnus-data-number (car data)) children)
2072 (setq data (cdr data)))
2075 (defmacro gnus-summary-skip-intangible ()
2076 "If the current article is intangible, then jump to a different article."
2077 '(let ((to (get-text-property (point) 'gnus-intangible)))
2078 (and to (gnus-summary-goto-subject to))))
2080 (defmacro gnus-summary-article-intangible-p ()
2081 "Say whether this article is intangible or not."
2082 '(get-text-property (point) 'gnus-intangible))
2084 (defun gnus-article-read-p (article)
2085 "Say whether ARTICLE is read or not."
2086 (not (or (memq article gnus-newsgroup-marked)
2087 (memq article gnus-newsgroup-unreads)
2088 (memq article gnus-newsgroup-unselected)
2089 (memq article gnus-newsgroup-dormant))))
2091 ;; Some summary mode macros.
2093 (defmacro gnus-summary-article-number ()
2094 "The article number of the article on the current line.
2095 If there isn's an article number here, then we return the current
2098 (gnus-summary-skip-intangible)
2099 (or (get-text-property (point) 'gnus-number)
2100 (gnus-summary-last-subject))))
2102 (defmacro gnus-summary-article-header (&optional number)
2103 "Return the header of article NUMBER."
2104 `(gnus-data-header (gnus-data-find
2105 ,(or number '(gnus-summary-article-number)))))
2107 (defmacro gnus-summary-thread-level (&optional number)
2108 "Return the level of thread that starts with article NUMBER."
2109 `(if (and (eq gnus-summary-make-false-root 'dummy)
2110 (get-text-property (point) 'gnus-intangible))
2112 (gnus-data-level (gnus-data-find
2113 ,(or number '(gnus-summary-article-number))))))
2115 (defmacro gnus-summary-article-mark (&optional number)
2116 "Return the mark of article NUMBER."
2117 `(gnus-data-mark (gnus-data-find
2118 ,(or number '(gnus-summary-article-number)))))
2120 (defmacro gnus-summary-article-pos (&optional number)
2121 "Return the position of the line of article NUMBER."
2122 `(gnus-data-pos (gnus-data-find
2123 ,(or number '(gnus-summary-article-number)))))
2125 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2126 (defmacro gnus-summary-article-subject (&optional number)
2127 "Return current subject string or nil if nothing."
2130 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2131 '(gnus-data-header (assq (gnus-summary-article-number)
2132 gnus-newsgroup-data)))))
2135 (mail-header-subject headers))))
2137 (defmacro gnus-summary-article-score (&optional number)
2138 "Return current article score."
2139 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2140 gnus-newsgroup-scored))
2141 gnus-summary-default-score 0))
2143 (defun gnus-summary-article-children (&optional number)
2144 "Return a list of article numbers that are children of article NUMBER."
2145 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2146 (level (gnus-data-level (car data)))
2148 (while (and (setq data (cdr data))
2149 (> (setq l (gnus-data-level (car data))) level))
2150 (and (= (1+ level) l)
2151 (push (gnus-data-number (car data))
2153 (nreverse children)))
2155 (defun gnus-summary-article-parent (&optional number)
2156 "Return the article number of the parent of article NUMBER."
2157 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2158 (gnus-data-list t)))
2159 (level (gnus-data-level (car data))))
2161 () ; This is a root.
2162 ;; We search until we find an article with a level less than
2163 ;; this one. That function has to be the parent.
2164 (while (and (setq data (cdr data))
2165 (not (< (gnus-data-level (car data)) level))))
2166 (and data (gnus-data-number (car data))))))
2168 (defun gnus-unread-mark-p (mark)
2169 "Say whether MARK is the unread mark."
2170 (= mark gnus-unread-mark))
2172 (defun gnus-read-mark-p (mark)
2173 "Say whether MARK is one of the marks that mark as read.
2174 This is all marks except unread, ticked, dormant, and expirable."
2175 (not (or (= mark gnus-unread-mark)
2176 (= mark gnus-ticked-mark)
2177 (= mark gnus-dormant-mark)
2178 (= mark gnus-expirable-mark))))
2180 (defmacro gnus-article-mark (number)
2181 "Return the MARK of article NUMBER.
2182 This macro should only be used when computing the mark the \"first\"
2183 time; i.e., when generating the summary lines. After that,
2184 `gnus-summary-article-mark' should be used to examine the
2187 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2188 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2189 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2190 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2191 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2192 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2193 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2194 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2195 gnus-ancient-mark))))
2197 ;; Saving hidden threads.
2199 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2200 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2202 (defmacro gnus-save-hidden-threads (&rest forms)
2203 "Save hidden threads, eval FORMS, and restore the hidden threads."
2204 (let ((config (make-symbol "config")))
2205 `(let ((,config (gnus-hidden-threads-configuration)))
2209 (gnus-restore-hidden-threads-configuration ,config)))))
2211 (defun gnus-data-compute-positions ()
2212 "Compute the positions of all articles."
2213 (setq gnus-newsgroup-data-reverse nil)
2214 (let ((data gnus-newsgroup-data))
2216 (gnus-save-hidden-threads
2217 (gnus-summary-show-all-threads)
2218 (goto-char (point-min))
2220 (while (get-text-property (point) 'gnus-intangible)
2222 (gnus-data-set-pos (car data) (+ (point) 3))
2223 (setq data (cdr data))
2224 (forward-line 1))))))
2226 (defun gnus-hidden-threads-configuration ()
2227 "Return the current hidden threads configuration."
2230 (goto-char (point-min))
2231 (while (search-forward "\r" nil t)
2232 (push (1- (point)) config))
2235 (defun gnus-restore-hidden-threads-configuration (config)
2236 "Restore hidden threads configuration from CONFIG."
2237 (let (point buffer-read-only)
2238 (while (setq point (pop config))
2239 (when (and (< point (point-max))
2241 (= (following-char) ?\n))
2242 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2244 ;; Various summary mode internalish functions.
2246 (defun gnus-mouse-pick-article (e)
2249 (gnus-summary-next-page nil t))
2251 (defun gnus-summary-set-display-table ()
2252 ;; Change the display table. Odd characters have a tendency to mess
2253 ;; up nicely formatted displays - we make all possible glyphs
2254 ;; display only a single character.
2256 ;; We start from the standard display table, if any.
2257 (let ((table (or (copy-sequence standard-display-table)
2258 (make-display-table)))
2260 ;; Nix out all the control chars...
2261 (while (>= (setq i (1- i)) 0)
2262 (aset table i [??]))
2263 ;; ... but not newline and cr, of course. (cr is necessary for the
2264 ;; selective display).
2265 (aset table ?\n nil)
2266 (aset table ?\r nil)
2267 ;; We keep TAB as well.
2268 (aset table ?\t nil)
2269 ;; We nix out any glyphs over 126 that are not set already.
2271 (while (>= (setq i (1- i)) 127)
2272 ;; Only modify if the entry is nil.
2273 (unless (aref table i)
2274 (aset table i [??]))))
2275 (setq buffer-display-table table)))
2277 (defun gnus-summary-setup-buffer (group)
2278 "Initialize summary buffer."
2279 (let ((buffer (concat "*Summary " group "*")))
2280 (if (get-buffer buffer)
2283 (setq gnus-summary-buffer (current-buffer))
2284 (not gnus-newsgroup-prepared))
2285 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2286 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2287 (gnus-summary-mode group)
2289 (gnus-carpal-setup-buffer 'summary))
2290 (unless gnus-single-article-buffer
2291 (make-local-variable 'gnus-article-buffer)
2292 (make-local-variable 'gnus-article-current)
2293 (make-local-variable 'gnus-original-article-buffer))
2294 (setq gnus-newsgroup-name group)
2297 (defun gnus-set-global-variables ()
2298 ;; Set the global equivalents of the summary buffer-local variables
2299 ;; to the latest values they had. These reflect the summary buffer
2300 ;; that was in action when the last article was fetched.
2301 (when (eq major-mode 'gnus-summary-mode)
2302 (setq gnus-summary-buffer (current-buffer))
2303 (let ((name gnus-newsgroup-name)
2304 (marked gnus-newsgroup-marked)
2305 (unread gnus-newsgroup-unreads)
2306 (headers gnus-current-headers)
2307 (data gnus-newsgroup-data)
2308 (summary gnus-summary-buffer)
2309 (article-buffer gnus-article-buffer)
2310 (original gnus-original-article-buffer)
2311 (gac gnus-article-current)
2312 (reffed gnus-reffed-article-number)
2313 (score-file gnus-current-score-file))
2315 (set-buffer gnus-group-buffer)
2316 (setq gnus-newsgroup-name name
2317 gnus-newsgroup-marked marked
2318 gnus-newsgroup-unreads unread
2319 gnus-current-headers headers
2320 gnus-newsgroup-data data
2321 gnus-article-current gac
2322 gnus-summary-buffer summary
2323 gnus-article-buffer article-buffer
2324 gnus-original-article-buffer original
2325 gnus-reffed-article-number reffed
2326 gnus-current-score-file score-file)
2327 ;; The article buffer also has local variables.
2328 (when (gnus-buffer-live-p gnus-article-buffer)
2329 (set-buffer gnus-article-buffer)
2330 (setq gnus-summary-buffer summary))))))
2332 (defun gnus-summary-article-unread-p (article)
2333 "Say whether ARTICLE is unread or not."
2334 (memq article gnus-newsgroup-unreads))
2336 (defun gnus-summary-first-article-p (&optional article)
2337 "Return whether ARTICLE is the first article in the buffer."
2338 (if (not (setq article (or article (gnus-summary-article-number))))
2340 (eq article (caar gnus-newsgroup-data))))
2342 (defun gnus-summary-last-article-p (&optional article)
2343 "Return whether ARTICLE is the last article in the buffer."
2344 (if (not (setq article (or article (gnus-summary-article-number))))
2345 t ; All non-existent numbers are the last article. :-)
2346 (not (cdr (gnus-data-find-list article)))))
2348 (defun gnus-make-thread-indent-array ()
2350 (unless (and gnus-thread-indent-array
2351 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2352 (setq gnus-thread-indent-array (make-vector 201 "")
2353 gnus-thread-indent-array-level gnus-thread-indent-level)
2355 (aset gnus-thread-indent-array n
2356 (make-string (* n gnus-thread-indent-level) ? ))
2359 (defun gnus-update-summary-mark-positions ()
2360 "Compute where the summary marks are to go."
2362 (when (gnus-buffer-exists-p gnus-summary-buffer)
2363 (set-buffer gnus-summary-buffer))
2364 (let ((gnus-replied-mark 129)
2365 (gnus-score-below-mark 130)
2366 (gnus-score-over-mark 130)
2367 (gnus-download-mark 131)
2368 (spec gnus-summary-line-format-spec)
2371 (gnus-set-work-buffer)
2372 (let ((gnus-summary-line-format-spec spec)
2373 (gnus-newsgroup-downloadable '((0 . t))))
2374 (gnus-summary-insert-line
2375 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2376 (goto-char (point-min))
2377 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2379 (goto-char (point-min))
2380 (push (cons 'replied (and (search-forward "\201" nil t)
2383 (goto-char (point-min))
2384 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2386 (goto-char (point-min))
2387 (push (cons 'download
2388 (and (search-forward "\203" nil t) (- (point) 2)))
2390 (setq gnus-summary-mark-positions pos))))
2392 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2393 "Insert a dummy root in the summary buffer."
2395 (gnus-add-text-properties
2396 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2397 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2399 (defun gnus-summary-insert-line (gnus-tmp-header
2400 gnus-tmp-level gnus-tmp-current
2401 gnus-tmp-unread gnus-tmp-replied
2402 gnus-tmp-expirable gnus-tmp-subject-or-nil
2403 &optional gnus-tmp-dummy gnus-tmp-score
2405 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2406 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2407 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2408 (gnus-tmp-score-char
2409 (if (or (null gnus-summary-default-score)
2410 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2411 gnus-summary-zcore-fuzz))
2413 (if (< gnus-tmp-score gnus-summary-default-score)
2414 gnus-score-below-mark gnus-score-over-mark)))
2416 (cond (gnus-tmp-process gnus-process-mark)
2417 ((memq gnus-tmp-current gnus-newsgroup-cached)
2419 (gnus-tmp-replied gnus-replied-mark)
2420 ((memq gnus-tmp-current gnus-newsgroup-saved)
2422 (t gnus-unread-mark)))
2423 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2426 ((string-match "<[^>]+> *$" gnus-tmp-from)
2427 (let ((beg (match-beginning 0)))
2428 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2429 (substring gnus-tmp-from (1+ (match-beginning 0))
2430 (1- (match-end 0))))
2431 (substring gnus-tmp-from 0 beg))))
2432 ((string-match "(.+)" gnus-tmp-from)
2433 (substring gnus-tmp-from
2434 (1+ (match-beginning 0)) (1- (match-end 0))))
2436 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2437 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2438 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2439 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2440 (buffer-read-only nil))
2441 (when (string= gnus-tmp-name "")
2442 (setq gnus-tmp-name gnus-tmp-from))
2443 (unless (numberp gnus-tmp-lines)
2444 (setq gnus-tmp-lines 0))
2445 (gnus-put-text-property-excluding-characters-with-faces
2447 (progn (eval gnus-summary-line-format-spec) (point))
2448 'gnus-number gnus-tmp-number)
2449 (when (gnus-visual-p 'summary-highlight 'highlight)
2451 (gnus-run-hooks 'gnus-summary-update-hook)
2454 (defun gnus-summary-update-line (&optional dont-update)
2455 ;; Update summary line after change.
2456 (when (and gnus-summary-default-score
2457 (not gnus-summary-inhibit-highlight))
2458 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2459 (article (gnus-summary-article-number))
2460 (score (gnus-summary-article-score article)))
2462 (if (and gnus-summary-mark-below
2463 (< (gnus-summary-article-score)
2464 gnus-summary-mark-below))
2465 ;; This article has a low score, so we mark it as read.
2466 (when (memq article gnus-newsgroup-unreads)
2467 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2468 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2469 ;; This article was previously marked as read on account
2470 ;; of a low score, but now it has risen, so we mark it as
2472 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2473 (gnus-summary-update-mark
2474 (if (or (null gnus-summary-default-score)
2475 (<= (abs (- score gnus-summary-default-score))
2476 gnus-summary-zcore-fuzz))
2478 (if (< score gnus-summary-default-score)
2479 gnus-score-below-mark gnus-score-over-mark))
2481 ;; Do visual highlighting.
2482 (when (gnus-visual-p 'summary-highlight 'highlight)
2483 (gnus-run-hooks 'gnus-summary-update-hook)))))
2485 (defvar gnus-tmp-new-adopts nil)
2487 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2488 "Return the number of articles in THREAD.
2489 This may be 0 in some cases -- if none of the articles in
2490 the thread are to be displayed."
2492 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2494 ((not (listp thread))
2496 ((and (consp thread) (cdr thread))
2499 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2502 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2505 (when (and level (zerop level) gnus-tmp-new-adopts)
2508 'gnus-summary-number-of-articles-in-thread
2509 gnus-tmp-new-adopts))))
2511 (if (> number 1) gnus-not-empty-thread-mark
2512 gnus-empty-thread-mark)
2515 (defun gnus-summary-set-local-parameters (group)
2516 "Go through the local params of GROUP and set all variable specs in that list."
2517 (let ((params (gnus-group-find-parameter group))
2520 (setq elem (car params)
2521 params (cdr params))
2522 (and (consp elem) ; Has to be a cons.
2523 (consp (cdr elem)) ; The cdr has to be a list.
2524 (symbolp (car elem)) ; Has to be a symbol in there.
2525 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2526 (ignore-errors ; So we set it.
2527 (make-local-variable (car elem))
2528 (set (car elem) (eval (nth 1 elem))))))))
2530 (defun gnus-summary-read-group (group &optional show-all no-article
2531 kill-buffer no-display backward
2533 "Start reading news in newsgroup GROUP.
2534 If SHOW-ALL is non-nil, already read articles are also listed.
2535 If NO-ARTICLE is non-nil, no article is selected initially.
2536 If NO-DISPLAY, don't generate a summary buffer."
2540 (let ((gnus-auto-select-next nil))
2541 (or (gnus-summary-read-group-1
2542 group show-all no-article
2543 kill-buffer no-display
2546 select-articles nil)))))
2547 (eq gnus-auto-select-next 'quietly))
2548 (set-buffer gnus-group-buffer)
2549 ;; The entry function called above goes to the next
2550 ;; group automatically, so we go two groups back
2551 ;; if we are searching for the previous group.
2553 (gnus-group-prev-unread-group 2))
2554 (if (not (equal group (gnus-group-group-name)))
2555 (setq group (gnus-group-group-name))
2559 (defun gnus-summary-read-group-1 (group show-all no-article
2560 kill-buffer no-display
2561 &optional select-articles)
2562 ;; Killed foreign groups can't be entered.
2563 (when (and (not (gnus-group-native-p group))
2564 (not (gnus-gethash group gnus-newsrc-hashtb)))
2565 (error "Dead non-native groups can't be entered"))
2566 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2567 (let* ((new-group (gnus-summary-setup-buffer group))
2568 (quit-config (gnus-group-quit-config group))
2569 (did-select (and new-group (gnus-select-newsgroup
2570 group show-all select-articles))))
2572 ;; This summary buffer exists already, so we just select it.
2574 (gnus-set-global-variables)
2576 (gnus-kill-or-deaden-summary kill-buffer))
2577 (gnus-configure-windows 'summary 'force)
2578 (gnus-set-mode-line 'summary)
2579 (gnus-summary-position-point)
2582 ;; We couldn't select this group.
2584 (when (and (eq major-mode 'gnus-summary-mode)
2585 (not (equal (current-buffer) kill-buffer)))
2586 (kill-buffer (current-buffer))
2587 (if (not quit-config)
2589 ;; Update the info -- marks might need to be removed,
2591 (gnus-summary-update-info)
2592 (set-buffer gnus-group-buffer)
2593 (gnus-group-jump-to-group group)
2594 (gnus-group-next-unread-group 1))
2595 (gnus-handle-ephemeral-exit quit-config)))
2596 (gnus-message 3 "Can't select group")
2598 ;; The user did a `C-g' while prompting for number of articles,
2599 ;; so we exit this group.
2600 ((eq did-select 'quit)
2601 (and (eq major-mode 'gnus-summary-mode)
2602 (not (equal (current-buffer) kill-buffer))
2603 (kill-buffer (current-buffer)))
2605 (gnus-kill-or-deaden-summary kill-buffer))
2606 (if (not quit-config)
2608 (set-buffer gnus-group-buffer)
2609 (gnus-group-jump-to-group group)
2610 (gnus-group-next-unread-group 1)
2611 (gnus-configure-windows 'group 'force))
2612 (gnus-handle-ephemeral-exit quit-config))
2613 ;; Finally signal the quit.
2615 ;; The group was successfully selected.
2617 (gnus-set-global-variables)
2618 ;; Save the active value in effect when the group was entered.
2619 (setq gnus-newsgroup-active
2621 (gnus-active gnus-newsgroup-name)))
2622 ;; You can change the summary buffer in some way with this hook.
2623 (gnus-run-hooks 'gnus-select-group-hook)
2624 ;; Set any local variables in the group parameters.
2625 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2626 (gnus-update-format-specifications
2627 nil 'summary 'summary-mode 'summary-dummy)
2628 ;; Do score processing.
2629 (when gnus-use-scoring
2630 (gnus-possibly-score-headers))
2631 ;; Check whether to fill in the gaps in the threads.
2632 (when gnus-build-sparse-threads
2633 (gnus-build-sparse-threads))
2634 ;; Find the initial limit.
2635 (if gnus-show-threads
2637 (let ((gnus-newsgroup-dormant nil))
2638 (gnus-summary-initial-limit show-all))
2639 (gnus-summary-initial-limit show-all))
2640 (setq gnus-newsgroup-limit
2642 (lambda (header) (mail-header-number header))
2643 gnus-newsgroup-headers)))
2644 ;; Generate the summary buffer.
2646 (gnus-summary-prepare))
2647 (when gnus-use-trees
2648 (gnus-tree-open group)
2649 (setq gnus-summary-highlight-line-function
2650 'gnus-tree-highlight-article))
2651 ;; If the summary buffer is empty, but there are some low-scored
2652 ;; articles or some excluded dormants, we include these in the
2654 (when (and (zerop (buffer-size))
2656 (cond (gnus-newsgroup-dormant
2657 (gnus-summary-limit-include-dormant))
2658 ((and gnus-newsgroup-scored show-all)
2659 (gnus-summary-limit-include-expunged t))))
2660 ;; Function `gnus-apply-kill-file' must be called in this hook.
2661 (gnus-run-hooks 'gnus-apply-kill-hook)
2662 (if (and (zerop (buffer-size))
2665 ;; This newsgroup is empty.
2666 (gnus-summary-catchup-and-exit nil t)
2667 (gnus-message 6 "No unread news")
2669 (gnus-kill-or-deaden-summary kill-buffer))
2670 ;; Return nil from this function.
2672 ;; Hide conversation thread subtrees. We cannot do this in
2673 ;; gnus-summary-prepare-hook since kill processing may not
2674 ;; work with hidden articles.
2675 (and gnus-show-threads
2676 gnus-thread-hide-subtree
2677 (gnus-summary-hide-all-threads))
2679 (gnus-kill-or-deaden-summary kill-buffer))
2680 ;; Show first unread article if requested.
2681 (if (and (not no-article)
2683 gnus-newsgroup-unreads
2684 gnus-auto-select-first)
2685 (unless (if (eq gnus-auto-select-first 'best)
2686 (gnus-summary-best-unread-article)
2687 (gnus-summary-first-unread-article))
2688 (gnus-configure-windows 'summary))
2689 ;; Don't select any articles, just move point to the first
2690 ;; article in the group.
2691 (goto-char (point-min))
2692 (gnus-summary-position-point)
2693 (gnus-configure-windows 'summary 'force)
2694 (gnus-set-mode-line 'summary))
2695 (when (get-buffer-window gnus-group-buffer t)
2696 ;; Gotta use windows, because recenter does weird stuff if
2697 ;; the current buffer ain't the displayed window.
2698 (let ((owin (selected-window)))
2699 (select-window (get-buffer-window gnus-group-buffer t))
2700 (when (gnus-group-goto-group group)
2702 (select-window owin)))
2703 ;; Mark this buffer as "prepared".
2704 (setq gnus-newsgroup-prepared t)
2705 (gnus-run-hooks 'gnus-summary-prepared-hook)
2708 (defun gnus-summary-prepare ()
2709 "Generate the summary buffer."
2711 (let ((buffer-read-only nil))
2713 (setq gnus-newsgroup-data nil
2714 gnus-newsgroup-data-reverse nil)
2715 (gnus-run-hooks 'gnus-summary-generate-hook)
2716 ;; Generate the buffer, either with threads or without.
2717 (when gnus-newsgroup-headers
2718 (gnus-summary-prepare-threads
2719 (if gnus-show-threads
2720 (gnus-sort-gathered-threads
2721 (funcall gnus-summary-thread-gathering-function
2723 (gnus-cut-threads (gnus-make-threads)))))
2724 ;; Unthreaded display.
2725 (gnus-sort-articles gnus-newsgroup-headers))))
2726 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2727 ;; Call hooks for modifying summary buffer.
2728 (goto-char (point-min))
2729 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2731 (defsubst gnus-general-simplify-subject (subject)
2732 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2735 ;; Truncate the subject.
2736 (gnus-simplify-subject-functions
2737 (gnus-map-function gnus-simplify-subject-functions subject))
2738 ((numberp gnus-summary-gather-subject-limit)
2739 (setq subject (gnus-simplify-subject-re subject))
2740 (if (> (length subject) gnus-summary-gather-subject-limit)
2741 (substring subject 0 gnus-summary-gather-subject-limit)
2743 ;; Fuzzily simplify it.
2744 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2745 (gnus-simplify-subject-fuzzy subject))
2746 ;; Just remove the leading "Re:".
2748 (gnus-simplify-subject-re subject))))
2750 (if (and gnus-summary-gather-exclude-subject
2751 (string-match gnus-summary-gather-exclude-subject subject))
2752 nil ; This article shouldn't be gathered
2755 (defun gnus-summary-simplify-subject-query ()
2756 "Query where the respool algorithm would put this article."
2758 (gnus-summary-select-article)
2759 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2761 (defun gnus-gather-threads-by-subject (threads)
2762 "Gather threads by looking at Subject headers."
2763 (if (not gnus-summary-make-false-root)
2765 (let ((hashtb (gnus-make-hashtable 1024))
2768 subject hthread whole-subject)
2770 (setq subject (gnus-general-simplify-subject
2771 (setq whole-subject (mail-header-subject
2774 (if (setq hthread (gnus-gethash subject hashtb))
2776 ;; We enter a dummy root into the thread, if we
2777 ;; haven't done that already.
2778 (unless (stringp (caar hthread))
2779 (setcar hthread (list whole-subject (car hthread))))
2780 ;; We add this new gathered thread to this gathered
2782 (setcdr (car hthread)
2783 (nconc (cdar hthread) (list (car threads))))
2784 ;; Remove it from the list of threads.
2785 (setcdr prev (cdr threads))
2786 (setq threads prev))
2787 ;; Enter this thread into the hash table.
2788 (gnus-sethash subject threads hashtb)))
2790 (setq threads (cdr threads)))
2793 (defun gnus-gather-threads-by-references (threads)
2794 "Gather threads by looking at References headers."
2795 (let ((idhashtb (gnus-make-hashtable 1024))
2796 (thhashtb (gnus-make-hashtable 1024))
2799 ids references id gthread gid entered ref)
2801 (when (setq references (mail-header-references (caar threads)))
2802 (setq id (mail-header-id (caar threads))
2803 ids (gnus-split-references references)
2805 (while (setq ref (pop ids))
2806 (setq ids (delete ref ids))
2807 (if (not (setq gid (gnus-gethash ref idhashtb)))
2809 (gnus-sethash ref id idhashtb)
2810 (gnus-sethash id threads thhashtb))
2811 (setq gthread (gnus-gethash gid thhashtb))
2813 ;; We enter a dummy root into the thread, if we
2814 ;; haven't done that already.
2815 (unless (stringp (caar gthread))
2816 (setcar gthread (list (mail-header-subject (caar gthread))
2818 ;; We add this new gathered thread to this gathered
2820 (setcdr (car gthread)
2821 (nconc (cdar gthread) (list (car threads)))))
2822 ;; Add it into the thread hash table.
2823 (gnus-sethash id gthread thhashtb)
2825 ;; Remove it from the list of threads.
2826 (setcdr prev (cdr threads))
2827 (setq threads prev))))
2829 (setq threads (cdr threads)))
2832 (defun gnus-sort-gathered-threads (threads)
2833 "Sort subtreads inside each gathered thread by article number."
2834 (let ((result threads))
2836 (when (stringp (caar threads))
2837 (setcdr (car threads)
2838 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2839 (setq threads (cdr threads)))
2842 (defun gnus-thread-loop-p (root thread)
2843 "Say whether ROOT is in THREAD."
2844 (let ((stack (list thread))
2847 (while (setq thread (pop stack))
2848 (setq th (cdr thread))
2850 (not (eq (caar th) root)))
2853 ;; We have found a loop.
2855 (setcdr thread (delq (car th) (cdr thread)))
2856 (if (boundp (setq ref-dep (intern "none"
2857 gnus-newsgroup-dependencies)))
2858 (setcdr (symbol-value ref-dep)
2859 (nconc (cdr (symbol-value ref-dep))
2861 (set ref-dep (list nil (car th))))
2864 ;; Push all the subthreads onto the stack.
2865 (push (cdr thread) stack)))
2868 (defun gnus-make-threads ()
2869 "Go through the dependency hashtb and find the roots. Return all threads."
2871 (while (catch 'infloop
2874 ;; Deal with self-referencing References loops.
2875 (when (and (car (symbol-value refs))
2882 (car (symbol-value refs)) thread))
2883 (cdr (symbol-value refs)))))))
2886 (unless (car (symbol-value refs))
2887 ;; These threads do not refer back to any other articles,
2888 ;; so they're roots.
2889 (setq threads (append (cdr (symbol-value refs)) threads))))
2890 gnus-newsgroup-dependencies)))
2893 ;; Build the thread tree.
2894 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2895 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2897 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2898 if it was already present.
2900 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2901 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2902 Message-IDs will be renamed be renamed to a unique Message-ID before
2905 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2906 (let* ((id (mail-header-id header))
2907 (id-dep (and id (intern id dependencies)))
2908 ref ref-dep ref-header)
2909 ;; Enter this `header' in the `dependencies' table.
2913 ;; The first two cases do the normal part: enter a new `header'
2914 ;; in the `dependencies' table.
2915 ((not (boundp id-dep))
2916 (set id-dep (list header)))
2917 ((null (car (symbol-value id-dep)))
2918 (setcar (symbol-value id-dep) header))
2920 ;; From here the `header' was already present in the
2921 ;; `dependencies' table.
2923 ;; Overrides an existing entry;
2924 ;; just set the header part of the entry.
2925 (setcar (symbol-value id-dep) header))
2927 ;; Renames the existing `header' to a unique Message-ID.
2928 ((not gnus-summary-ignore-duplicates)
2929 ;; An article with this Message-ID has already been seen.
2930 ;; We rename the Message-ID.
2931 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2933 (mail-header-set-id header id))
2935 ;; The last case ignores an existing entry, except it adds any
2936 ;; additional Xrefs (in case the two articles came from different
2938 ;; Also sets `header' to `nil' meaning that the `dependencies'
2939 ;; table was *not* modified.
2941 (mail-header-set-xref
2942 (car (symbol-value id-dep))
2943 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2945 (or (mail-header-xref header) "")))
2949 ;; First check if that we are not creating a References loop.
2950 (setq ref (gnus-parent-id (mail-header-references header)))
2952 (setq ref-dep (intern-soft ref dependencies))
2954 (setq ref-header (car (symbol-value ref-dep))))
2955 (if (string= id ref)
2956 ;; Yuk! This is a reference loop. Make the article be a
2959 (mail-header-set-references (car (symbol-value id-dep)) "none")
2961 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2962 (setq ref (gnus-parent-id (mail-header-references header)))
2963 (setq ref-dep (intern (or ref "none") dependencies))
2964 (if (boundp ref-dep)
2965 (setcdr (symbol-value ref-dep)
2966 (nconc (cdr (symbol-value ref-dep))
2967 (list (symbol-value id-dep))))
2968 (set ref-dep (list nil (symbol-value id-dep)))))
2971 (defun gnus-build-sparse-threads ()
2972 (let ((headers gnus-newsgroup-headers)
2973 (gnus-summary-ignore-duplicates t)
2974 header references generation relations
2975 subject child end new-child date)
2976 ;; First we create an alist of generations/relations, where
2977 ;; generations is how much we trust the relation, and the relation
2979 (gnus-message 7 "Making sparse threads...")
2981 (nnheader-set-temp-buffer " *gnus sparse threads*")
2982 (while (setq header (pop headers))
2983 (when (and (setq references (mail-header-references header))
2984 (not (string= references "")))
2986 (setq child (mail-header-id header)
2987 subject (mail-header-subject header)
2988 date (mail-header-date header)
2990 (while (search-backward ">" nil t)
2991 (setq end (1+ (point)))
2992 (when (search-backward "<" nil t)
2993 (setq new-child (buffer-substring (point) end))
2994 (push (list (incf generation)
2995 child (setq child new-child)
2999 (push (list (1+ generation) child nil subject) relations))
3001 (kill-buffer (current-buffer)))
3002 ;; Sort over trustworthiness.
3005 (when (gnus-dependencies-add-header
3006 (make-full-mail-header
3007 gnus-reffed-article-number
3008 (nth 3 relation) "" (or (nth 4 relation) "")
3010 (or (nth 2 relation) "") 0 0 "")
3011 gnus-newsgroup-dependencies nil)
3012 (push gnus-reffed-article-number gnus-newsgroup-limit)
3013 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3014 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3015 gnus-newsgroup-reads)
3016 (decf gnus-reffed-article-number)))
3017 (sort relations 'car-less-than-car))
3018 (gnus-message 7 "Making sparse threads...done")))
3020 (defun gnus-build-old-threads ()
3021 ;; Look at all the articles that refer back to old articles, and
3022 ;; fetch the headers for the articles that aren't there. This will
3023 ;; build complete threads - if the roots haven't been expired by the
3028 (when (not (car (symbol-value refs)))
3029 (setq heads (cdr (symbol-value refs)))
3031 (if (memq (mail-header-number (caar heads))
3032 gnus-newsgroup-dormant)
3033 (setq heads (cdr heads))
3034 (setq id (symbol-name refs))
3035 (while (and (setq id (gnus-build-get-header id))
3036 (not (car (gnus-id-to-thread id)))))
3037 (setq heads nil)))))
3038 gnus-newsgroup-dependencies)))
3040 ;; The following macros and functions were written by Felix Lee
3041 ;; <flee@cse.psu.edu>.
3043 (defmacro gnus-nov-read-integer ()
3045 (if (= (following-char) ?\t)
3047 (let ((num (ignore-errors (read buffer))))
3048 (if (numberp num) num 0)))
3050 (search-forward "\t" eol 'move))))
3052 (defmacro gnus-nov-skip-field ()
3053 '(search-forward "\t" eol 'move))
3055 (defmacro gnus-nov-field ()
3056 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3058 ;; This function has to be called with point after the article number
3059 ;; on the beginning of the line.
3060 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3061 (let ((eol (gnus-point-at-eol))
3062 (buffer (current-buffer))
3063 header rawtext decoded)
3065 ;; overview: [num subject from date id refs chars lines misc]
3068 (narrow-to-region (point) eol)
3073 (make-full-mail-header
3076 (setq rawtext (gnus-nov-field) ; subject
3078 gnus-unstructured-field-decoder rawtext))
3079 (if (string= rawtext decoded)
3081 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
3084 (setq rawtext (gnus-nov-field) ; from
3086 gnus-structured-field-decoder rawtext))
3087 (if (string= rawtext decoded)
3089 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
3091 (gnus-nov-field) ; date
3092 (or (gnus-nov-field)
3093 (nnheader-generate-fake-message-id)) ; id
3094 (gnus-nov-field) ; refs
3095 (gnus-nov-read-integer) ; chars
3096 (gnus-nov-read-integer) ; lines
3097 (unless (= (following-char) ?\n)
3098 (gnus-nov-field))))) ; misc
3102 (when gnus-alter-header-function
3103 (funcall gnus-alter-header-function header))
3104 (gnus-dependencies-add-header header dependencies force-new)))
3106 (defun gnus-build-get-header (id)
3107 ;; Look through the buffer of NOV lines and find the header to
3108 ;; ID. Enter this line into the dependencies hash table, and return
3109 ;; the id of the parent article (if any).
3110 (let ((deps gnus-newsgroup-dependencies)
3114 (set-buffer nntp-server-buffer)
3115 (let ((case-fold-search nil))
3116 (goto-char (point-min))
3117 (while (and (not found)
3118 (search-forward id nil t))
3120 (setq found (looking-at
3121 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3122 (regexp-quote id))))
3123 (or found (beginning-of-line 2)))
3127 (setq header (gnus-nov-parse-line
3128 (read (current-buffer)) deps))
3129 (gnus-parent-id (mail-header-references header))))))
3131 (let ((number (mail-header-number header)))
3132 (push number gnus-newsgroup-limit)
3133 (push header gnus-newsgroup-headers)
3134 (if (memq number gnus-newsgroup-unselected)
3136 (push number gnus-newsgroup-unreads)
3137 (setq gnus-newsgroup-unselected
3138 (delq number gnus-newsgroup-unselected)))
3139 (push number gnus-newsgroup-ancient)))))))
3141 (defun gnus-build-all-threads ()
3142 "Read all the headers."
3143 (let ((gnus-summary-ignore-duplicates t)
3144 (dependencies gnus-newsgroup-dependencies)
3147 (set-buffer nntp-server-buffer)
3148 (let ((case-fold-search nil))
3149 (goto-char (point-min))
3152 (setq article (read (current-buffer))
3153 header (gnus-nov-parse-line
3154 article dependencies)))
3157 (set-buffer gnus-summary-buffer)
3158 (push header gnus-newsgroup-headers)
3159 (if (memq (setq article (mail-header-number header))
3160 gnus-newsgroup-unselected)
3162 (push article gnus-newsgroup-unreads)
3163 (setq gnus-newsgroup-unselected
3164 (delq article gnus-newsgroup-unselected)))
3165 (push article gnus-newsgroup-ancient)))
3166 (forward-line 1)))))))
3168 (defun gnus-summary-update-article-line (article header)
3169 "Update the line for ARTICLE using HEADERS."
3170 (let* ((id (mail-header-id header))
3171 (thread (gnus-id-to-thread id)))
3173 (error "Article in no thread"))
3174 ;; Update the thread.
3175 (setcar thread header)
3176 (gnus-summary-goto-subject article)
3177 (let* ((datal (gnus-data-find-list article))
3179 (length (when (cdr datal)
3180 (- (gnus-data-pos data)
3181 (gnus-data-pos (cadr datal)))))
3182 (buffer-read-only nil)
3183 (level (gnus-summary-thread-level)))
3185 (gnus-summary-insert-line
3186 header level nil (gnus-article-mark article)
3187 (memq article gnus-newsgroup-replied)
3188 (memq article gnus-newsgroup-expirable)
3189 ;; Only insert the Subject string when it's different
3190 ;; from the previous Subject string.
3191 (if (gnus-subject-equal
3193 (mail-header-subject
3196 (gnus-data-find-list
3198 (gnus-data-list t)))))
3199 ;; Error on the side of excessive subjects.
3201 (mail-header-subject header))
3203 (mail-header-subject header))
3204 nil (cdr (assq article gnus-newsgroup-scored))
3205 (memq article gnus-newsgroup-processable))
3207 (gnus-data-update-list
3208 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3210 (defun gnus-summary-update-article (article &optional iheader)
3211 "Update ARTICLE in the summary buffer."
3212 (set-buffer gnus-summary-buffer)
3213 (let* ((header (gnus-summary-article-header article))
3214 (id (mail-header-id header))
3215 (data (gnus-data-find article))
3216 (thread (gnus-id-to-thread id))
3217 (references (mail-header-references header))
3221 (when (and references
3222 (not (equal "" references)))
3225 (buffer-read-only nil)
3231 (delq thread parent)))
3232 (if (gnus-summary-insert-subject id header)
3233 ;; Set the (possibly) new article number in the data structure.
3234 (gnus-data-set-number data (gnus-id-to-article id))
3238 (defun gnus-rebuild-thread (id &optional line)
3239 "Rebuild the thread containing ID.
3240 If LINE, insert the rebuilt thread starting on line LINE."
3241 (let ((buffer-read-only nil)
3242 old-pos current thread data)
3243 (if (not gnus-show-threads)
3244 (setq thread (list (car (gnus-id-to-thread id))))
3245 ;; Get the thread this article is part of.
3246 (setq thread (gnus-remove-thread id)))
3247 (setq old-pos (gnus-point-at-bol))
3248 (setq current (save-excursion
3249 (and (zerop (forward-line -1))
3250 (gnus-summary-article-number))))
3251 ;; If this is a gathered thread, we have to go some re-gathering.
3252 (when (stringp (car thread))
3253 (let ((subject (car thread))
3255 (setq thread (cdr thread))
3257 (unless (memq (setq thr (gnus-id-to-thread
3259 (mail-header-id (caar thread)))))
3262 (setq thread (cdr thread)))
3263 ;; We now have all (unique) roots.
3264 (if (= (length roots) 1)
3265 ;; All the loose roots are now one solid root.
3266 (setq thread (car roots))
3267 (setq thread (cons subject (gnus-sort-threads roots))))))
3269 ;; We then insert this thread into the summary buffer.
3271 (goto-char (point-min))
3272 (forward-line (1- line)))
3273 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3274 (if gnus-show-threads
3275 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3276 (gnus-summary-prepare-unthreaded thread))
3277 (setq data (nreverse gnus-newsgroup-data))
3278 (setq threads gnus-newsgroup-threads))
3279 ;; We splice the new data into the data structure.
3280 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3281 ;;!!! then we want to insert at the beginning of the buffer.
3282 ;;!!! That happens to be true with Gnus now, but that may
3283 ;;!!! change in the future. Perhaps.
3284 (gnus-data-enter-list
3285 (if line nil current) data (- (point) old-pos))
3286 (setq gnus-newsgroup-threads
3287 (nconc threads gnus-newsgroup-threads))
3288 (gnus-data-compute-positions))))
3290 (defun gnus-number-to-header (number)
3291 "Return the header for article NUMBER."
3292 (let ((headers gnus-newsgroup-headers))
3294 (not (= number (mail-header-number (car headers)))))
3299 (defun gnus-parent-headers (in-headers &optional generation)
3300 "Return the headers of the GENERATIONeth parent of HEADERS."
3302 (setq generation 1))
3304 (headers in-headers)
3307 (not (zerop generation))
3308 (setq references (mail-header-references headers)))
3309 (setq headers (if (and references
3310 (setq parent (gnus-parent-id references)))
3311 (car (gnus-id-to-thread parent))
3314 (and (not (eq headers in-headers))
3317 (defun gnus-id-to-thread (id)
3318 "Return the (sub-)thread where ID appears."
3319 (gnus-gethash id gnus-newsgroup-dependencies))
3321 (defun gnus-id-to-article (id)
3322 "Return the article number of ID."
3323 (let ((thread (gnus-id-to-thread id)))
3326 (mail-header-number (car thread)))))
3328 (defun gnus-id-to-header (id)
3329 "Return the article headers of ID."
3330 (car (gnus-id-to-thread id)))
3332 (defun gnus-article-displayed-root-p (article)
3333 "Say whether ARTICLE is a root(ish) article."
3334 (let ((level (gnus-summary-thread-level article))
3335 (refs (mail-header-references (gnus-summary-article-header article)))
3341 ((null (gnus-parent-id refs)) t)
3343 (null (setq particle (gnus-id-to-article
3344 (gnus-parent-id refs))))
3345 (null (gnus-summary-thread-level particle)))))))
3347 (defun gnus-root-id (id)
3348 "Return the id of the root of the thread where ID appears."
3350 (while (and id (setq prev (car (gnus-id-to-thread id))))
3352 id (gnus-parent-id (mail-header-references prev))))
3355 (defun gnus-articles-in-thread (thread)
3356 "Return the list of articles in THREAD."
3357 (cons (mail-header-number (car thread))
3358 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3360 (defun gnus-remove-thread (id &optional dont-remove)
3361 "Remove the thread that has ID in it."
3362 (let (headers thread last-id)
3363 ;; First go up in this thread until we find the root.
3364 (setq last-id (gnus-root-id id)
3365 headers (message-flatten-list (gnus-id-to-thread last-id)))
3366 ;; We have now found the real root of this thread. It might have
3367 ;; been gathered into some loose thread, so we have to search
3368 ;; through the threads to find the thread we wanted.
3369 (let ((threads gnus-newsgroup-threads)
3372 (setq sub (car threads))
3373 (if (stringp (car sub))
3374 ;; This is a gathered thread, so we look at the roots
3375 ;; below it to find whether this article is in this
3378 (setq sub (cdr sub))
3380 (when (member (caar sub) headers)
3381 (setq thread (car threads)
3384 (setq sub (cdr sub))))
3385 ;; It's an ordinary thread, so we check it.
3386 (when (eq (car sub) (car headers))
3389 (setq threads (cdr threads)))
3390 ;; If this article is in no thread, then it's a root.
3393 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3394 (setq thread (gnus-id-to-thread last-id)))
3397 thread ; We return this thread.
3399 (if (stringp (car thread))
3401 ;; If we use dummy roots, then we have to remove the
3402 ;; dummy root as well.
3403 (when (eq gnus-summary-make-false-root 'dummy)
3404 ;; We go to the dummy root by going to
3405 ;; the first sub-"thread", and then one line up.
3406 (gnus-summary-goto-article
3407 (mail-header-number (caadr thread)))
3410 (gnus-data-compute-positions))
3411 (setq thread (cdr thread))
3413 (gnus-remove-thread-1 (car thread))
3414 (setq thread (cdr thread))))
3415 (gnus-summary-show-all-threads)
3416 (gnus-remove-thread-1 thread))))))))
3418 (defun gnus-remove-thread-1 (thread)
3419 "Remove the thread THREAD recursively."
3420 (let ((number (mail-header-number (pop thread)))
3422 (setq thread (reverse thread))
3424 (gnus-remove-thread-1 (pop thread)))
3425 (when (setq d (gnus-data-find number))
3426 (goto-char (gnus-data-pos d))
3429 (- (gnus-point-at-bol)
3431 (1+ (gnus-point-at-eol))
3432 (gnus-delete-line)))))))
3434 (defun gnus-sort-threads (threads)
3436 (if (not gnus-thread-sort-functions)
3438 (gnus-message 8 "Sorting threads...")
3440 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3441 (gnus-message 8 "Sorting threads...done"))))
3443 (defun gnus-sort-articles (articles)
3445 (when gnus-article-sort-functions
3446 (gnus-message 7 "Sorting articles...")
3448 (setq gnus-newsgroup-headers
3449 (sort articles (gnus-make-sort-function
3450 gnus-article-sort-functions)))
3451 (gnus-message 7 "Sorting articles...done"))))
3453 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3454 (defmacro gnus-thread-header (thread)
3455 ;; Return header of first article in THREAD.
3456 ;; Note that THREAD must never, ever be anything else than a variable -
3457 ;; using some other form will lead to serious barfage.
3458 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3459 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3460 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3463 (defsubst gnus-article-sort-by-number (h1 h2)
3464 "Sort articles by article number."
3465 (< (mail-header-number h1)
3466 (mail-header-number h2)))
3468 (defun gnus-thread-sort-by-number (h1 h2)
3469 "Sort threads by root article number."
3470 (gnus-article-sort-by-number
3471 (gnus-thread-header h1) (gnus-thread-header h2)))
3473 (defsubst gnus-article-sort-by-lines (h1 h2)
3474 "Sort articles by article Lines header."
3475 (< (mail-header-lines h1)
3476 (mail-header-lines h2)))
3478 (defun gnus-thread-sort-by-lines (h1 h2)
3479 "Sort threads by root article Lines header."
3480 (gnus-article-sort-by-lines
3481 (gnus-thread-header h1) (gnus-thread-header h2)))
3483 (defsubst gnus-article-sort-by-author (h1 h2)
3484 "Sort articles by root author."
3486 (let ((extract (funcall
3487 gnus-extract-address-components
3488 (mail-header-from h1))))
3489 (or (car extract) (cadr extract) ""))
3490 (let ((extract (funcall
3491 gnus-extract-address-components
3492 (mail-header-from h2))))
3493 (or (car extract) (cadr extract) ""))))
3495 (defun gnus-thread-sort-by-author (h1 h2)
3496 "Sort threads by root author."
3497 (gnus-article-sort-by-author
3498 (gnus-thread-header h1) (gnus-thread-header h2)))
3500 (defsubst gnus-article-sort-by-subject (h1 h2)
3501 "Sort articles by root subject."
3503 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3504 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3506 (defun gnus-thread-sort-by-subject (h1 h2)
3507 "Sort threads by root subject."
3508 (gnus-article-sort-by-subject
3509 (gnus-thread-header h1) (gnus-thread-header h2)))
3511 (defsubst gnus-article-sort-by-date (h1 h2)
3512 "Sort articles by root article date."
3514 (gnus-date-get-time (mail-header-date h1))
3515 (gnus-date-get-time (mail-header-date h2))))
3517 (defun gnus-thread-sort-by-date (h1 h2)
3518 "Sort threads by root article date."
3519 (gnus-article-sort-by-date
3520 (gnus-thread-header h1) (gnus-thread-header h2)))
3522 (defsubst gnus-article-sort-by-score (h1 h2)
3523 "Sort articles by root article score.
3524 Unscored articles will be counted as having a score of zero."
3525 (> (or (cdr (assq (mail-header-number h1)
3526 gnus-newsgroup-scored))
3527 gnus-summary-default-score 0)
3528 (or (cdr (assq (mail-header-number h2)
3529 gnus-newsgroup-scored))
3530 gnus-summary-default-score 0)))
3532 (defun gnus-thread-sort-by-score (h1 h2)
3533 "Sort threads by root article score."
3534 (gnus-article-sort-by-score
3535 (gnus-thread-header h1) (gnus-thread-header h2)))
3537 (defun gnus-thread-sort-by-total-score (h1 h2)
3538 "Sort threads by the sum of all scores in the thread.
3539 Unscored articles will be counted as having a score of zero."
3540 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3542 (defun gnus-thread-total-score (thread)
3543 ;; This function find the total score of THREAD.
3544 (cond ((null thread)
3547 (if (stringp (car thread))
3548 (apply gnus-thread-score-function 0
3549 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3550 (gnus-thread-total-score-1 thread)))
3552 (gnus-thread-total-score-1 (list thread)))))
3554 (defun gnus-thread-total-score-1 (root)
3555 ;; This function find the total score of the thread below ROOT.
3556 (setq root (car root))
3557 (apply gnus-thread-score-function
3559 (mapcar 'gnus-thread-total-score
3560 (cdr (gnus-id-to-thread (mail-header-id root))))
3561 (when (> (mail-header-number root) 0)
3562 (list (or (cdr (assq (mail-header-number root)
3563 gnus-newsgroup-scored))
3564 gnus-summary-default-score 0))))
3565 (list gnus-summary-default-score)
3568 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3569 (defvar gnus-tmp-prev-subject nil)
3570 (defvar gnus-tmp-false-parent nil)
3571 (defvar gnus-tmp-root-expunged nil)
3572 (defvar gnus-tmp-dummy-line nil)
3574 (defun gnus-summary-prepare-threads (threads)
3575 "Prepare summary buffer from THREADS and indentation LEVEL.
3576 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3577 or a straight list of headers."
3578 (gnus-message 7 "Generating summary...")
3580 (setq gnus-newsgroup-threads threads)
3583 (let ((gnus-tmp-level 0)
3584 (default-score (or gnus-summary-default-score 0))
3585 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3586 thread number subject stack state gnus-tmp-gathered beg-match
3587 new-roots gnus-tmp-new-adopts thread-end
3588 gnus-tmp-header gnus-tmp-unread
3589 gnus-tmp-replied gnus-tmp-subject-or-nil
3590 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3591 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3592 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3594 (setq gnus-tmp-prev-subject nil)
3596 (if (vectorp (car threads))
3597 ;; If this is a straight (sic) list of headers, then a
3598 ;; threaded summary display isn't required, so we just create
3599 ;; an unthreaded one.
3600 (gnus-summary-prepare-unthreaded threads)
3602 ;; Do the threaded display.
3604 (while (or threads stack gnus-tmp-new-adopts new-roots)
3606 (if (and (= gnus-tmp-level 0)
3609 (not gnus-tmp-false-parent)
3610 (or gnus-tmp-new-adopts new-roots))
3611 (if gnus-tmp-new-adopts
3612 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3613 thread (list (car gnus-tmp-new-adopts))
3614 gnus-tmp-header (caar thread)
3615 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3617 (setq thread (list (car new-roots))
3618 gnus-tmp-header (caar thread)
3619 new-roots (cdr new-roots))))
3622 ;; If there are some threads, we do them before the
3623 ;; threads on the stack.
3624 (setq thread threads
3625 gnus-tmp-header (caar thread))
3626 ;; There were no current threads, so we pop something off
3628 (setq state (car stack)
3629 gnus-tmp-level (car state)
3632 gnus-tmp-header (caar thread))))
3634 (setq gnus-tmp-false-parent nil)
3635 (setq gnus-tmp-root-expunged nil)
3636 (setq thread-end nil)
3638 (if (stringp gnus-tmp-header)
3639 ;; The header is a dummy root.
3641 ((eq gnus-summary-make-false-root 'adopt)
3642 ;; We let the first article adopt the rest.
3643 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3645 (setq gnus-tmp-gathered
3647 (lambda (h) (mail-header-number (car h)))
3650 (setq thread (cons (list (caar thread)
3653 (setq gnus-tmp-level -1
3654 gnus-tmp-false-parent t))
3655 ((eq gnus-summary-make-false-root 'empty)
3656 ;; We print adopted articles with empty subject fields.
3657 (setq gnus-tmp-gathered
3659 (lambda (h) (mail-header-number (car h)))
3662 (setq gnus-tmp-level -1))
3663 ((eq gnus-summary-make-false-root 'dummy)
3664 ;; We remember that we probably want to output a dummy
3666 (setq gnus-tmp-dummy-line gnus-tmp-header)
3667 (setq gnus-tmp-prev-subject gnus-tmp-header))
3669 ;; We do not make a root for the gathered
3670 ;; sub-threads at all.
3671 (setq gnus-tmp-level -1)))
3673 (setq number (mail-header-number gnus-tmp-header)
3674 subject (mail-header-subject gnus-tmp-header))
3677 ;; If the thread has changed subject, we might want to make
3678 ;; this subthread into a root.
3679 ((and (null gnus-thread-ignore-subject)
3680 (not (zerop gnus-tmp-level))
3681 gnus-tmp-prev-subject
3683 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3684 (setq new-roots (nconc new-roots (list (car thread)))
3686 gnus-tmp-header nil))
3687 ;; If the article lies outside the current limit,
3688 ;; then we do not display it.
3689 ((not (memq number gnus-newsgroup-limit))
3690 (setq gnus-tmp-gathered
3692 (lambda (h) (mail-header-number (car h)))
3695 (setq gnus-tmp-new-adopts (if (cdar thread)
3696 (append gnus-tmp-new-adopts
3698 gnus-tmp-new-adopts)
3700 gnus-tmp-header nil)
3701 (when (zerop gnus-tmp-level)
3702 (setq gnus-tmp-root-expunged t)))
3703 ;; Perhaps this article is to be marked as read?
3704 ((and gnus-summary-mark-below
3705 (< (or (cdr (assq number gnus-newsgroup-scored))
3707 gnus-summary-mark-below)
3708 ;; Don't touch sparse articles.
3709 (not (gnus-summary-article-sparse-p number))
3710 (not (gnus-summary-article-ancient-p number)))
3711 (setq gnus-newsgroup-unreads
3712 (delq number gnus-newsgroup-unreads))
3713 (if gnus-newsgroup-auto-expire
3714 (push number gnus-newsgroup-expirable)
3715 (push (cons number gnus-low-score-mark)
3716 gnus-newsgroup-reads))))
3718 (when gnus-tmp-header
3719 ;; We may have an old dummy line to output before this
3721 (when (and gnus-tmp-dummy-line
3724 (mail-header-subject gnus-tmp-header)))
3725 (gnus-summary-insert-dummy-line
3726 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3727 (setq gnus-tmp-dummy-line nil))
3729 ;; Compute the mark.
3730 (setq gnus-tmp-unread (gnus-article-mark number))
3732 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3733 gnus-tmp-header gnus-tmp-level)
3734 gnus-newsgroup-data)
3736 ;; Actually insert the line.
3738 gnus-tmp-subject-or-nil
3740 ((and gnus-thread-ignore-subject
3741 gnus-tmp-prev-subject
3742 (not (inline (gnus-subject-equal
3743 gnus-tmp-prev-subject subject))))
3745 ((zerop gnus-tmp-level)
3746 (if (and (eq gnus-summary-make-false-root 'empty)
3747 (memq number gnus-tmp-gathered)
3748 gnus-tmp-prev-subject
3749 (inline (gnus-subject-equal
3750 gnus-tmp-prev-subject subject)))
3751 gnus-summary-same-subject
3753 (t gnus-summary-same-subject)))
3754 (if (and (eq gnus-summary-make-false-root 'adopt)
3755 (= gnus-tmp-level 1)
3756 (memq number gnus-tmp-gathered))
3757 (setq gnus-tmp-opening-bracket ?\<
3758 gnus-tmp-closing-bracket ?\>)
3759 (setq gnus-tmp-opening-bracket ?\[
3760 gnus-tmp-closing-bracket ?\]))
3762 gnus-tmp-indentation
3763 (aref gnus-thread-indent-array gnus-tmp-level)
3764 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3765 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3766 gnus-summary-default-score 0)
3768 (if (or (null gnus-summary-default-score)
3769 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3770 gnus-summary-zcore-fuzz))
3772 (if (< gnus-tmp-score gnus-summary-default-score)
3773 gnus-score-below-mark gnus-score-over-mark))
3775 (cond ((memq number gnus-newsgroup-processable)
3777 ((memq number gnus-newsgroup-cached)
3779 ((memq number gnus-newsgroup-replied)
3781 ((memq number gnus-newsgroup-saved)
3783 (t gnus-unread-mark))
3784 gnus-tmp-from (mail-header-from gnus-tmp-header)
3787 ((string-match "<[^>]+> *$" gnus-tmp-from)
3788 (setq beg-match (match-beginning 0))
3789 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3790 (substring gnus-tmp-from (1+ (match-beginning 0))
3791 (1- (match-end 0))))
3792 (substring gnus-tmp-from 0 beg-match)))
3793 ((string-match "(.+)" gnus-tmp-from)
3794 (substring gnus-tmp-from
3795 (1+ (match-beginning 0)) (1- (match-end 0))))
3797 (when (string= gnus-tmp-name "")
3798 (setq gnus-tmp-name gnus-tmp-from))
3799 (unless (numberp gnus-tmp-lines)
3800 (setq gnus-tmp-lines 0))
3801 (gnus-put-text-property-excluding-characters-with-faces
3803 (progn (eval gnus-summary-line-format-spec) (point))
3804 'gnus-number number)
3807 (gnus-run-hooks 'gnus-summary-update-hook)
3810 (setq gnus-tmp-prev-subject subject)))
3812 (when (nth 1 thread)
3813 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3814 (incf gnus-tmp-level)
3815 (setq threads (if thread-end nil (cdar thread)))
3817 (setq gnus-tmp-level 0)))))
3818 (gnus-message 7 "Generating summary...done"))
3820 (defun gnus-summary-prepare-unthreaded (headers)
3821 "Generate an unthreaded summary buffer based on HEADERS."
3822 (let (header number mark)
3827 ;; We may have to root out some bad articles...
3828 (when (memq (setq number (mail-header-number
3829 (setq header (pop headers))))
3830 gnus-newsgroup-limit)
3831 ;; Mark article as read when it has a low score.
3832 (when (and gnus-summary-mark-below
3833 (< (or (cdr (assq number gnus-newsgroup-scored))
3834 gnus-summary-default-score 0)
3835 gnus-summary-mark-below)
3836 (not (gnus-summary-article-ancient-p number)))
3837 (setq gnus-newsgroup-unreads
3838 (delq number gnus-newsgroup-unreads))
3839 (if gnus-newsgroup-auto-expire
3840 (push number gnus-newsgroup-expirable)
3841 (push (cons number gnus-low-score-mark)
3842 gnus-newsgroup-reads)))
3844 (setq mark (gnus-article-mark number))
3845 (push (gnus-data-make number mark (1+ (point)) header 0)
3846 gnus-newsgroup-data)
3847 (gnus-summary-insert-line
3849 mark (memq number gnus-newsgroup-replied)
3850 (memq number gnus-newsgroup-expirable)
3851 (mail-header-subject header) nil
3852 (cdr (assq number gnus-newsgroup-scored))
3853 (memq number gnus-newsgroup-processable))))))
3855 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3856 "Select newsgroup GROUP.
3857 If READ-ALL is non-nil, all articles in the group are selected.
3858 If SELECT-ARTICLES, only select those articles from GROUP."
3859 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3860 ;;!!! Dirty hack; should be removed.
3861 (gnus-summary-ignore-duplicates
3862 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3864 gnus-summary-ignore-duplicates))
3865 (info (nth 2 entry))
3866 articles fetched-articles cached)
3868 (unless (gnus-check-server
3869 (setq gnus-current-select-method
3870 (gnus-find-method-for-group group)))
3871 (error "Couldn't open server"))
3873 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3874 (gnus-activate-group group) ; Or we can activate it...
3875 (progn ; Or we bug out.
3876 (when (equal major-mode 'gnus-summary-mode)
3877 (kill-buffer (current-buffer)))
3878 (error "Couldn't request group %s: %s"
3879 group (gnus-status-message group))))
3881 (unless (gnus-request-group group t)
3882 (when (equal major-mode 'gnus-summary-mode)
3883 (kill-buffer (current-buffer)))
3884 (error "Couldn't request group %s: %s"
3885 group (gnus-status-message group)))
3887 (setq gnus-newsgroup-name group)
3888 (setq gnus-newsgroup-unselected nil)
3889 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3891 ;; Adjust and set lists of article marks.
3893 (gnus-adjust-marked-articles info))
3895 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3896 (when (gnus-virtual-group-p group)
3897 (setq cached gnus-newsgroup-cached))
3899 (setq gnus-newsgroup-unreads
3900 (gnus-set-difference
3901 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3902 gnus-newsgroup-dormant))
3904 (setq gnus-newsgroup-processable nil)
3906 (gnus-update-read-articles group gnus-newsgroup-unreads)
3908 (if (setq articles select-articles)
3909 (setq gnus-newsgroup-unselected
3910 (gnus-sorted-intersection
3911 gnus-newsgroup-unreads
3912 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3913 (setq articles (gnus-articles-to-read group read-all)))
3917 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3919 ((eq articles 0) nil)
3921 ;; Init the dependencies hash table.
3922 (setq gnus-newsgroup-dependencies
3923 (gnus-make-hashtable (length articles)))
3924 ;; Retrieve the headers and read them in.
3925 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3926 (setq gnus-newsgroup-headers
3928 (setq gnus-headers-retrieved-by
3929 (gnus-retrieve-headers
3930 articles gnus-newsgroup-name
3931 ;; We might want to fetch old headers, but
3932 ;; not if there is only 1 article.
3934 (not (eq gnus-fetch-old-headers 'some))
3935 (not (numberp gnus-fetch-old-headers)))
3936 (> (length articles) 1))
3937 gnus-fetch-old-headers))))
3938 (gnus-get-newsgroup-headers-xover
3939 articles nil nil gnus-newsgroup-name t)
3940 (gnus-get-newsgroup-headers)))
3941 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3943 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3945 (setq gnus-newsgroup-cached cached))
3947 ;; Suppress duplicates?
3948 (when gnus-suppress-duplicates
3949 (gnus-dup-suppress-articles))
3951 ;; Set the initial limit.
3952 (setq gnus-newsgroup-limit (copy-sequence articles))
3953 ;; Remove canceled articles from the list of unread articles.
3954 (setq gnus-newsgroup-unreads
3955 (gnus-set-sorted-intersection
3956 gnus-newsgroup-unreads
3957 (setq fetched-articles
3958 (mapcar (lambda (headers) (mail-header-number headers))
3959 gnus-newsgroup-headers))))
3960 ;; Removed marked articles that do not exist.
3961 (gnus-update-missing-marks
3962 (gnus-sorted-complement fetched-articles articles))
3963 ;; We might want to build some more threads first.
3964 (when (and gnus-fetch-old-headers
3965 (eq gnus-headers-retrieved-by 'nov))
3966 (if (eq gnus-fetch-old-headers 'invisible)
3967 (gnus-build-all-threads)
3968 (gnus-build-old-threads)))
3969 ;; Let the Gnus agent mark articles as read.
3971 (gnus-agent-get-undownloaded-list))
3972 ;; Check whether auto-expire is to be done in this group.
3973 (setq gnus-newsgroup-auto-expire
3974 (gnus-group-auto-expirable-p group))
3975 ;; Set up the article buffer now, if necessary.
3976 (unless gnus-single-article-buffer
3977 (gnus-article-setup-buffer))
3978 ;; First and last article in this newsgroup.
3979 (when gnus-newsgroup-headers
3980 (setq gnus-newsgroup-begin
3981 (mail-header-number (car gnus-newsgroup-headers))
3984 (gnus-last-element gnus-newsgroup-headers))))
3985 ;; GROUP is successfully selected.
3986 (or gnus-newsgroup-headers t)))))
3988 (defun gnus-articles-to-read (group &optional read-all)
3989 ;; Find out what articles the user wants to read.
3991 ;; Select all articles if `read-all' is non-nil, or if there
3992 ;; are no unread articles.
3994 (and (zerop (length gnus-newsgroup-marked))
3995 (zerop (length gnus-newsgroup-unreads)))
3996 (eq (gnus-group-find-parameter group 'display)
3998 (gnus-uncompress-range (gnus-active group))
3999 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4000 (copy-sequence gnus-newsgroup-unreads))
4002 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4003 (scored (length scored-list))
4004 (number (length articles))
4005 (marked (+ (length gnus-newsgroup-marked)
4006 (length gnus-newsgroup-dormant)))
4014 ((and (or (<= scored marked) (= scored number))
4015 (numberp gnus-large-newsgroup)
4016 (> number gnus-large-newsgroup))
4020 "How many articles from %s (default %d): "
4021 (gnus-limit-string gnus-newsgroup-name 35)
4023 (if (string-match "^[ \t]*$" input) number input)))
4024 ((and (> scored marked) (< scored number)
4025 (> (- scored number) 20))
4028 (format "%s %s (%d scored, %d total): "
4029 "How many articles from"
4030 group scored number))))
4031 (if (string-match "^[ \t]*$" input)
4035 (setq select (if (stringp select) (string-to-number select) select))
4036 (if (or (null select) (zerop select))
4038 (if (and (not (zerop scored)) (<= (abs select) scored))
4040 (setq articles (sort scored-list '<))
4041 (setq number (length articles)))
4042 (setq articles (copy-sequence articles)))
4044 (when (< (abs select) number)
4046 ;; Select the N oldest articles.
4047 (setcdr (nthcdr (1- (abs select)) articles) nil)
4048 ;; Select the N most recent articles.
4049 (setq articles (nthcdr (- number select) articles))))
4050 (setq gnus-newsgroup-unselected
4051 (gnus-sorted-intersection
4052 gnus-newsgroup-unreads
4053 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4056 (defun gnus-killed-articles (killed articles)
4059 (when (inline (gnus-member-of-range (car articles) killed))
4060 (push (car articles) out))
4061 (setq articles (cdr articles)))
4064 (defun gnus-uncompress-marks (marks)
4065 "Uncompress the mark ranges in MARKS."
4066 (let ((uncompressed '(score bookmark))
4069 (if (memq (caar marks) uncompressed)
4070 (push (car marks) out)
4071 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4072 (setq marks (cdr marks)))
4075 (defun gnus-adjust-marked-articles (info)
4076 "Set all article lists and remove all marks that are no longer legal."
4077 (let* ((marked-lists (gnus-info-marks info))
4078 (active (gnus-active (gnus-info-group info)))
4081 (types gnus-article-mark-lists)
4082 (uncompressed '(score bookmark killed))
4083 marks var articles article mark)
4086 (setq marks (pop marked-lists))
4087 (set (setq var (intern (format "gnus-newsgroup-%s"
4088 (car (rassq (setq mark (car marks))
4090 (if (memq (car marks) uncompressed) (cdr marks)
4091 (gnus-uncompress-range (cdr marks))))
4093 (setq articles (symbol-value var))
4095 ;; All articles have to be subsets of the active articles.
4097 ;; Adjust "simple" lists.
4098 ((memq mark '(tick dormant expire reply save))
4100 (when (or (< (setq article (pop articles)) min) (> article max))
4101 (set var (delq article (symbol-value var))))))
4103 ((memq mark uncompressed)
4104 (when (not (listp (cdr (symbol-value var))))
4105 (set var (list (symbol-value var))))
4106 (when (not (listp (cdr articles)))
4107 (setq articles (list articles)))
4109 (when (or (not (consp (setq article (pop articles))))
4110 (< (car article) min)
4111 (> (car article) max))
4112 (set var (delq article (symbol-value var))))))))))
4114 (defun gnus-update-missing-marks (missing)
4115 "Go through the list of MISSING articles and remove them from the mark lists."
4117 (let ((types gnus-article-mark-lists)
4119 ;; Go through all types.
4121 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4122 (when (symbol-value var)
4123 ;; This list has articles. So we delete all missing articles
4127 (set var (delq (pop m) (symbol-value var)))))))))
4129 (defun gnus-update-marks ()
4130 "Enter the various lists of marked articles into the newsgroup info list."
4131 (let ((types gnus-article-mark-lists)
4132 (info (gnus-get-info gnus-newsgroup-name))
4133 (uncompressed '(score bookmark killed))
4134 type list newmarked symbol)
4136 ;; Add all marks lists that are non-nil to the list of marks lists.
4137 (while (setq type (pop types))
4138 (when (setq list (symbol-value
4140 (intern (format "gnus-newsgroup-%s"
4143 ;; Get rid of the entries of the articles that have the
4145 (when (and (eq (cdr type) 'score)
4149 (prev (cons nil list))
4152 (if (or (not (consp (car arts)))
4153 (= (cdar arts) gnus-summary-default-score))
4154 (setcdr prev (cdr arts))
4156 (setq arts (cdr arts)))
4157 (setq list (cdr all))))
4159 (push (cons (cdr type)
4160 (if (memq (cdr type) uncompressed) list
4161 (gnus-compress-sequence
4162 (set symbol (sort list '<)) t)))
4165 ;; Enter these new marks into the info of the group.
4167 (setcar (nthcdr 3 info) newmarked)
4168 ;; Add the marks lists to the end of the info.
4170 (setcdr (nthcdr 2 info) (list newmarked))))
4172 ;; Cut off the end of the info if there's nothing else there.
4176 (when (nthcdr (decf i) info)
4177 (setcdr (nthcdr i info) nil)))))))
4179 (defun gnus-set-mode-line (where)
4180 "This function sets the mode line of the article or summary buffers.
4181 If WHERE is `summary', the summary mode line format will be used."
4182 ;; Is this mode line one we keep updated?
4183 (when (memq where gnus-updated-mode-lines)
4186 ;; We evaluate this in the summary buffer since these
4187 ;; variables are buffer-local to that buffer.
4188 (set-buffer gnus-summary-buffer)
4189 ;; We bind all these variables that are used in the `eval' form
4191 (let* ((mformat (symbol-value
4193 (format "gnus-%s-mode-line-format-spec" where))))
4194 (gnus-tmp-group-name gnus-newsgroup-name)
4195 (gnus-tmp-article-number (or gnus-current-article 0))
4196 (gnus-tmp-unread gnus-newsgroup-unreads)
4197 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4198 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4199 (gnus-tmp-unread-and-unselected
4200 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4201 (zerop gnus-tmp-unselected))
4203 ((zerop gnus-tmp-unselected)
4204 (format "{%d more}" gnus-tmp-unread-and-unticked))
4205 (t (format "{%d(+%d) more}"
4206 gnus-tmp-unread-and-unticked
4207 gnus-tmp-unselected))))
4209 (if (and gnus-current-headers
4210 (vectorp gnus-current-headers))
4211 (gnus-mode-string-quote
4212 (mail-header-subject gnus-current-headers))
4214 bufname-length max-len
4215 gnus-tmp-header);; passed as argument to any user-format-funcs
4216 (setq mode-string (eval mformat))
4217 (setq bufname-length (if (string-match "%b" mode-string)
4220 (if (eq where 'summary)
4222 (get-buffer gnus-article-buffer))))
4225 (setq max-len (max 4 (if gnus-mode-non-string-length
4227 gnus-mode-non-string-length
4229 (length mode-string))))
4230 ;; We might have to chop a bit of the string off...
4231 (when (> (length mode-string) max-len)
4233 (concat (gnus-truncate-string mode-string (- max-len 3))
4235 ;; Pad the mode string a bit.
4236 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4237 ;; Update the mode line.
4238 (setq mode-line-buffer-identification
4239 (gnus-mode-line-buffer-identification (list mode-string)))
4240 (set-buffer-modified-p t))))
4242 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4243 "Go through the HEADERS list and add all Xrefs to a hash table.
4244 The resulting hash table is returned, or nil if no Xrefs were found."
4245 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4246 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4247 (xref-hashtb (gnus-make-hashtable))
4248 start group entry number xrefs header)
4250 (setq header (pop headers))
4251 (when (and (setq xrefs (mail-header-xref header))
4252 (not (memq (setq number (mail-header-number header))
4255 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4256 (setq start (match-end 0))
4257 (setq group (if prefix
4258 (concat prefix (substring xrefs (match-beginning 1)
4260 (substring xrefs (match-beginning 1) (match-end 1))))
4262 (string-to-int (substring xrefs (match-beginning 2)
4264 (if (setq entry (gnus-gethash group xref-hashtb))
4265 (setcdr entry (cons number (cdr entry)))
4266 (gnus-sethash group (cons number nil) xref-hashtb)))))
4267 (and start xref-hashtb)))
4269 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4270 "Look through all the headers and mark the Xrefs as read."
4271 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4272 name entry info xref-hashtb idlist method nth4)
4274 (set-buffer gnus-group-buffer)
4275 (when (setq xref-hashtb
4276 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4279 (unless (string= from-newsgroup (setq name (symbol-name group)))
4280 (setq idlist (symbol-value group))
4281 ;; Dead groups are not updated.
4283 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4285 (when (stringp (setq nth4 (gnus-info-method info)))
4286 (setq nth4 (gnus-server-to-method nth4))))
4287 ;; Only do the xrefs if the group has the same
4288 ;; select method as the group we have just read.
4289 (or (gnus-methods-equal-p
4290 nth4 (gnus-find-method-for-group from-newsgroup))
4292 (equal nth4 (setq method (gnus-find-method-for-group
4294 (and (equal (car nth4) (car method))
4295 (equal (nth 1 nth4) (nth 1 method))))
4296 gnus-use-cross-reference
4297 (or (not (eq gnus-use-cross-reference t))
4299 ;; Only do cross-references on subscribed
4300 ;; groups, if that is what is wanted.
4301 (<= (gnus-info-level info) gnus-level-subscribed))
4302 (gnus-group-make-articles-read name idlist))))
4305 (defun gnus-compute-read-articles (group articles)
4306 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4307 (info (nth 2 entry))
4308 (active (gnus-active group))
4311 ;; First peel off all illegal article numbers.
4313 (let ((ids articles)
4315 (while (setq id (pop ids))
4316 (when (and first (> id (cdr active)))
4317 ;; We'll end up in this situation in one particular
4318 ;; obscure situation. If you re-scan a group and get
4319 ;; a new article that is cross-posted to a different
4320 ;; group that has not been re-scanned, you might get
4321 ;; crossposted article that has a higher number than
4322 ;; Gnus believes possible. So we re-activate this
4323 ;; group as well. This might mean doing the
4324 ;; crossposting thingy will *increase* the number
4325 ;; of articles in some groups. Tsk, tsk.
4326 (setq active (or (gnus-activate-group group) active)))
4327 (when (or (> id (cdr active))
4328 (< id (car active)))
4329 (setq articles (delq id articles))))))
4330 ;; If the read list is nil, we init it.
4332 (null (gnus-info-read info))
4334 (setq ninfo (cons 1 (1- (car active))))
4335 (setq ninfo (gnus-info-read info)))
4336 ;; Then we add the read articles to the range.
4338 ninfo (setq articles (sort articles '<))))))
4340 (defun gnus-group-make-articles-read (group articles)
4341 "Update the info of GROUP to say that ARTICLES are read."
4343 (entry (gnus-gethash group gnus-newsrc-hashtb))
4344 (info (nth 2 entry))
4345 (active (gnus-active group))
4348 (setq range (gnus-compute-read-articles group articles))
4350 (set-buffer gnus-group-buffer)
4353 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4354 (gnus-info-set-read ',info ',(gnus-info-read info))
4355 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4356 (gnus-group-update-group ,group t))))
4357 ;; Add the read articles to the range.
4358 (gnus-info-set-read info range)
4359 ;; Then we have to re-compute how many unread
4360 ;; articles there are in this group.
4364 (setq num (- (1+ (cdr active)) (car active))))
4365 ((not (listp (cdr range)))
4366 (setq num (- (cdr active) (- (1+ (cdr range))
4370 (if (numberp (car range))
4372 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4373 (setq range (cdr range)))
4374 (setq num (- (cdr active) num))))
4375 ;; Update the number of unread articles.
4377 ;; Update the group buffer.
4378 (gnus-group-update-group group t)))))
4380 (defun gnus-methods-equal-p (m1 m2)
4381 (let ((m1 (or m1 gnus-select-method))
4382 (m2 (or m2 gnus-select-method)))
4384 (and (eq (car m1) (car m2))
4385 (or (not (memq 'address (assoc (symbol-name (car m1))
4386 gnus-valid-select-methods)))
4387 (equal (nth 1 m1) (nth 1 m2)))))))
4389 (defvar gnus-newsgroup-none-id 0)
4391 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4392 (let ((cur nntp-server-buffer)
4395 (save-excursion (set-buffer gnus-summary-buffer)
4396 gnus-newsgroup-dependencies)))
4399 (set-buffer nntp-server-buffer)
4400 ;; Translate all TAB characters into SPACE characters.
4401 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4402 (gnus-run-hooks 'gnus-parse-headers-hook)
4403 (let ((case-fold-search t)
4405 in-reply-to header p lines chars)
4406 (goto-char (point-min))
4407 ;; Search to the beginning of the next header. Error messages
4408 ;; do not begin with 2 or 3.
4409 (while (re-search-forward "^[23][0-9]+ " nil t)
4412 ;; This implementation of this function, with nine
4413 ;; search-forwards instead of the one re-search-forward and
4414 ;; a case (which basically was the old function) is actually
4415 ;; about twice as fast, even though it looks messier. You
4416 ;; can't have everything, I guess. Speed and elegance
4417 ;; doesn't always go hand in hand.
4426 (narrow-to-region (point)
4427 (or (and (search-forward "\n.\n" nil t)
4433 (if (search-forward "\nsubject: " nil t)
4435 (setq rawtext (nnheader-header-value)
4437 gnus-unstructured-field-decoder rawtext))
4438 (if (string-equal rawtext decoded)
4440 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
4446 (if (search-forward "\nfrom: " nil t)
4448 (setq rawtext (nnheader-header-value)
4450 gnus-structured-field-decoder rawtext))
4451 (if (string-equal rawtext decoded)
4453 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
4459 (if (search-forward "\ndate: " nil t)
4460 (nnheader-header-value) ""))
4464 (setq id (if (re-search-forward
4465 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4466 ;; We do it this way to make sure the Message-ID
4467 ;; is (somewhat) syntactically valid.
4468 (buffer-substring (match-beginning 1)
4470 ;; If there was no message-id, we just fake one
4471 ;; to make subsequent routines simpler.
4472 (nnheader-generate-fake-message-id))))
4476 (if (search-forward "\nreferences: " nil t)
4480 (nnheader-header-value)
4485 (search-backward ">" end t)
4488 (search-backward "<" end t)
4490 ;; Get the references from the in-reply-to header if there
4491 ;; were no references and the in-reply-to header looks
4493 (if (and (search-forward "\nin-reply-to: " nil t)
4494 (setq in-reply-to (nnheader-header-value))
4495 (string-match "<[^>]+>" in-reply-to))
4497 (setq ref (substring in-reply-to (match-beginning 0)
4499 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4500 (setq ref2 (substring in-reply-to (match-beginning 0)
4502 (when (> (length ref2) (length ref))
4509 (if (search-forward "\nchars: " nil t)
4510 (if (numberp (setq chars (ignore-errors (read cur))))
4516 (if (search-forward "\nlines: " nil t)
4517 (if (numberp (setq lines (ignore-errors (read cur))))
4523 (and (search-forward "\nxref: " nil t)
4524 (nnheader-header-value)))))
4525 (when (equal id ref)
4528 (when gnus-alter-header-function
4529 (funcall gnus-alter-header-function header)
4530 (setq id (mail-header-id header)
4531 ref (gnus-parent-id (mail-header-references header))))
4534 (gnus-dependencies-add-header
4535 header dependencies force-new))
4536 (push header headers))
4537 (goto-char (point-max))
4539 (nreverse headers)))))
4541 ;; Goes through the xover lines and returns a list of vectors
4542 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4543 force-new dependencies
4544 group also-fetch-heads)
4545 "Parse the news overview data in the server buffer, and return a
4546 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4547 ;; Get the Xref when the users reads the articles since most/some
4548 ;; NNTP servers do not include Xrefs when using XOVER.
4549 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4550 (let ((cur nntp-server-buffer)
4551 (dependencies (or dependencies gnus-newsgroup-dependencies))
4552 number headers header)
4554 (set-buffer nntp-server-buffer)
4555 ;; Allow the user to mangle the headers before parsing them.
4556 (gnus-run-hooks 'gnus-parse-headers-hook)
4557 (goto-char (point-min))
4560 (while (and sequence (not (eobp)))
4561 (setq number (read cur))
4562 (while (and sequence
4563 (< (car sequence) number))
4564 (setq sequence (cdr sequence)))
4566 (eq number (car sequence))
4568 (setq sequence (cdr sequence))
4569 (setq header (inline
4570 (gnus-nov-parse-line
4571 number dependencies force-new))))
4572 (push header headers))
4575 (gnus-error 4 "Strange nov line (%d)"
4576 (count-lines (point-min) (point)))))
4578 ;; A common bug in inn is that if you have posted an article and
4579 ;; then retrieves the active file, it will answer correctly --
4580 ;; the new article is included. However, a NOV entry for the
4581 ;; article may not have been generated yet, so this may fail.
4582 ;; We work around this problem by retrieving the last few
4583 ;; headers using HEAD.
4584 (if (or (not also-fetch-heads)
4586 ;; We (probably) got all the headers.
4588 (let ((gnus-nov-is-evil t))
4591 (when (gnus-retrieve-headers sequence group)
4592 (gnus-get-newsgroup-headers))))))))
4594 (defun gnus-article-get-xrefs ()
4595 "Fill in the Xref value in `gnus-current-headers', if necessary.
4596 This is meant to be called in `gnus-article-internal-prepare-hook'."
4597 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4598 gnus-current-headers)))
4599 (or (not gnus-use-cross-reference)
4601 (and (mail-header-xref headers)
4602 (not (string= (mail-header-xref headers) "")))
4603 (let ((case-fold-search t)
4606 (nnheader-narrow-to-headers)
4607 (goto-char (point-min))
4608 (when (or (and (eq (downcase (following-char)) ?x)
4609 (looking-at "Xref:"))
4610 (search-forward "\nXref:" nil t))
4611 (goto-char (1+ (match-end 0)))
4612 (setq xref (buffer-substring (point)
4613 (progn (end-of-line) (point))))
4614 (mail-header-set-xref headers xref)))))))
4616 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4617 "Find article ID and insert the summary line for that article.
4618 OLD-HEADER can either be a header or a line number to insert
4619 the subject line on."
4620 (let* ((line (and (numberp old-header) old-header))
4621 (old-header (and (vectorp old-header) old-header))
4622 (header (cond ((and old-header use-old-header)
4625 (gnus-number-to-header id))
4626 (gnus-number-to-header id))
4628 (gnus-read-header id))))
4629 (number (and (numberp id) id))
4632 ;; Rebuild the thread that this article is part of and go to the
4633 ;; article we have fetched.
4634 (when (and (not gnus-show-threads)
4637 (setq d (gnus-data-find (mail-header-number old-header))))
4638 (goto-char (gnus-data-pos d))
4641 (- (gnus-point-at-bol)
4643 (1+ (gnus-point-at-eol))
4644 (gnus-delete-line))))))
4646 (mail-header-set-number header (mail-header-number old-header)))
4647 (setq gnus-newsgroup-sparse
4648 (delq (setq number (mail-header-number header))
4649 gnus-newsgroup-sparse))
4650 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4651 (push number gnus-newsgroup-limit)
4652 (gnus-rebuild-thread (mail-header-id header) line)
4653 (gnus-summary-goto-subject number nil t))
4654 (when (and (numberp number)
4656 ;; We have to update the boundaries even if we can't fetch the
4657 ;; article if ID is a number -- so that the next `P' or `N'
4658 ;; command will fetch the previous (or next) article even
4659 ;; if the one we tried to fetch this time has been canceled.
4660 (when (> number gnus-newsgroup-end)
4661 (setq gnus-newsgroup-end number))
4662 (when (< number gnus-newsgroup-begin)
4663 (setq gnus-newsgroup-begin number))
4664 (setq gnus-newsgroup-unselected
4665 (delq number gnus-newsgroup-unselected)))
4666 ;; Report back a success?
4667 (and header (mail-header-number header))))
4669 ;;; Process/prefix in the summary buffer
4671 (defun gnus-summary-work-articles (n)
4672 "Return a list of articles to be worked upon.
4673 The prefix argument, the list of process marked articles, and the
4674 current article will be taken into consideration."
4676 (set-buffer gnus-summary-buffer)
4679 ;; A numerical prefix has been given.
4680 (setq n (prefix-numeric-value n))
4681 (let ((backward (< n 0))
4682 (n (abs (prefix-numeric-value n)))
4687 (push (setq article (gnus-summary-article-number))
4690 (gnus-summary-find-prev nil article)
4691 (gnus-summary-find-next nil article)))
4693 (nreverse articles)))
4694 ((and (gnus-region-active-p) (mark))
4695 (message "region active")
4696 ;; Work on the region between point and mark.
4697 (let ((max (max (point) (mark)))
4700 (goto-char (min (point) (mark)))
4703 (push (setq article (gnus-summary-article-number)) articles)
4704 (gnus-summary-find-next nil article)
4706 (nreverse articles))))
4707 (gnus-newsgroup-processable
4708 ;; There are process-marked articles present.
4709 ;; Save current state.
4710 (gnus-summary-save-process-mark)
4712 (reverse gnus-newsgroup-processable))
4714 ;; Just return the current article.
4715 (list (gnus-summary-article-number))))))
4717 (defmacro gnus-summary-iterate (arg &rest forms)
4718 "Iterate over the process/prefixed articles and do FORMS.
4719 ARG is the interactive prefix given to the command. FORMS will be
4720 executed with point over the summary line of the articles."
4721 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4722 `(let ((,articles (gnus-summary-work-articles ,arg)))
4724 (gnus-summary-goto-subject (car ,articles))
4727 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4728 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4730 (defun gnus-summary-save-process-mark ()
4731 "Push the current set of process marked articles on the stack."
4733 (push (copy-sequence gnus-newsgroup-processable)
4734 gnus-newsgroup-process-stack))
4736 (defun gnus-summary-kill-process-mark ()
4737 "Push the current set of process marked articles on the stack and unmark."
4739 (gnus-summary-save-process-mark)
4740 (gnus-summary-unmark-all-processable))
4742 (defun gnus-summary-yank-process-mark ()
4743 "Pop the last process mark state off the stack and restore it."
4745 (unless gnus-newsgroup-process-stack
4746 (error "Empty mark stack"))
4747 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4749 (defun gnus-summary-process-mark-set (set)
4750 "Make SET into the current process marked articles."
4751 (gnus-summary-unmark-all-processable)
4753 (gnus-summary-set-process-mark (pop set))))
4755 ;;; Searching and stuff
4757 (defun gnus-summary-search-group (&optional backward use-level)
4758 "Search for next unread newsgroup.
4759 If optional argument BACKWARD is non-nil, search backward instead."
4761 (set-buffer gnus-group-buffer)
4762 (when (gnus-group-search-forward
4763 backward nil (if use-level (gnus-group-group-level) nil))
4764 (gnus-group-group-name))))
4766 (defun gnus-summary-best-group (&optional exclude-group)
4767 "Find the name of the best unread group.
4768 If EXCLUDE-GROUP, do not go to this group."
4770 (set-buffer gnus-group-buffer)
4772 (gnus-group-best-unread-group exclude-group))))
4774 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4775 (if backward (gnus-summary-find-prev)
4776 (let* ((dummy (gnus-summary-article-intangible-p))
4777 (article (or article (gnus-summary-article-number)))
4778 (arts (gnus-data-find-list article))
4780 (when (and (not dummy)
4781 (or (not gnus-summary-check-current)
4783 (not (gnus-data-unread-p (car arts)))))
4784 (setq arts (cdr arts)))
4789 (when (or (and undownloaded
4790 (eq gnus-undownloaded-mark
4791 (gnus-data-mark (car arts))))
4792 (gnus-data-unread-p (car arts)))
4793 (setq result (car arts)
4795 (setq arts (cdr arts)))
4798 (goto-char (gnus-data-pos result))
4799 (gnus-data-number result)))))
4801 (defun gnus-summary-find-prev (&optional unread article)
4802 (let* ((eobp (eobp))
4803 (article (or article (gnus-summary-article-number)))
4804 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4806 (when (and (not eobp)
4807 (or (not gnus-summary-check-current)
4809 (not (gnus-data-unread-p (car arts)))))
4810 (setq arts (cdr arts)))
4815 (when (gnus-data-unread-p (car arts))
4816 (setq result (car arts)
4818 (setq arts (cdr arts)))
4821 (goto-char (gnus-data-pos result))
4822 (gnus-data-number result))))
4824 (defun gnus-summary-find-subject (subject &optional unread backward article)
4825 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4826 (article (or article (gnus-summary-article-number)))
4827 (articles (gnus-data-list backward))
4828 (arts (gnus-data-find-list article articles))
4830 (when (or (not gnus-summary-check-current)
4832 (not (gnus-data-unread-p (car arts))))
4833 (setq arts (cdr arts)))
4835 (and (or (not unread)
4836 (gnus-data-unread-p (car arts)))
4837 (vectorp (gnus-data-header (car arts)))
4839 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4840 (setq result (car arts)
4842 (setq arts (cdr arts)))
4844 (goto-char (gnus-data-pos result))
4845 (gnus-data-number result))))
4847 (defun gnus-summary-search-forward (&optional unread subject backward)
4848 "Search forward for an article.
4849 If UNREAD, look for unread articles. If SUBJECT, look for
4850 articles with that subject. If BACKWARD, search backward instead."
4851 (cond (subject (gnus-summary-find-subject subject unread backward))
4852 (backward (gnus-summary-find-prev unread))
4853 (t (gnus-summary-find-next unread))))
4855 (defun gnus-recenter (&optional n)
4856 "Center point in window and redisplay frame.
4857 Also do horizontal recentering."
4859 (when (and gnus-auto-center-summary
4860 (not (eq gnus-auto-center-summary 'vertical)))
4861 (gnus-horizontal-recenter))
4864 (defun gnus-summary-recenter ()
4865 "Center point in the summary window.
4866 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4867 displayed, no centering will be performed."
4868 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4869 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4870 (let* ((top (cond ((< (window-height) 4) 0)
4871 ((< (window-height) 7) 1)
4873 (height (1- (window-height)))
4874 (bottom (save-excursion (goto-char (point-max))
4875 (forward-line (- height))
4877 (window (get-buffer-window (current-buffer))))
4878 ;; The user has to want it.
4879 (when gnus-auto-center-summary
4880 (when (get-buffer-window gnus-article-buffer)
4881 ;; Only do recentering when the article buffer is displayed,
4882 ;; Set the window start to either `bottom', which is the biggest
4883 ;; possible valid number, or the second line from the top,
4884 ;; whichever is the least.
4886 window (min bottom (save-excursion
4887 (forward-line (- top)) (point)))))
4888 ;; Do horizontal recentering while we're at it.
4889 (when (and (get-buffer-window (current-buffer) t)
4890 (not (eq gnus-auto-center-summary 'vertical)))
4891 (let ((selected (selected-window)))
4892 (select-window (get-buffer-window (current-buffer) t))
4893 (gnus-summary-position-point)
4894 (gnus-horizontal-recenter)
4895 (select-window selected))))))
4897 (defun gnus-summary-jump-to-group (newsgroup)
4898 "Move point to NEWSGROUP in group mode buffer."
4899 ;; Keep update point of group mode buffer if visible.
4900 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4901 (save-window-excursion
4902 ;; Take care of tree window mode.
4903 (when (get-buffer-window gnus-group-buffer)
4904 (pop-to-buffer gnus-group-buffer))
4905 (gnus-group-jump-to-group newsgroup))
4907 ;; Take care of tree window mode.
4908 (if (get-buffer-window gnus-group-buffer)
4909 (pop-to-buffer gnus-group-buffer)
4910 (set-buffer gnus-group-buffer))
4911 (gnus-group-jump-to-group newsgroup))))
4913 ;; This function returns a list of article numbers based on the
4914 ;; difference between the ranges of read articles in this group and
4915 ;; the range of active articles.
4916 (defun gnus-list-of-unread-articles (group)
4917 (let* ((read (gnus-info-read (gnus-get-info group)))
4918 (active (or (gnus-active group) (gnus-activate-group group)))
4921 ;; If none are read, then all are unread.
4923 (setq first (car active))
4924 ;; If the range of read articles is a single range, then the
4925 ;; first unread article is the article after the last read
4926 ;; article. Sounds logical, doesn't it?
4927 (if (not (listp (cdr read)))
4928 (setq first (max (car active) (1+ (cdr read))))
4929 ;; `read' is a list of ranges.
4930 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4933 (setq first (car active)))
4936 (while (< first nlast)
4938 (setq first (1+ first))))
4939 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4940 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4941 (setq read (cdr read)))))
4942 ;; And add the last unread articles.
4943 (while (<= first last)
4945 (setq first (1+ first)))
4946 ;; Return the list of unread articles.
4947 (delq 0 (nreverse unread))))
4949 (defun gnus-list-of-read-articles (group)
4950 "Return a list of unread, unticked and non-dormant articles."
4951 (let* ((info (gnus-get-info group))
4952 (marked (gnus-info-marks info))
4953 (active (gnus-active group)))
4955 (gnus-set-difference
4956 (gnus-sorted-complement
4957 (gnus-uncompress-range active)
4958 (gnus-list-of-unread-articles group))
4960 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4961 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4963 ;; Various summary commands
4965 (defun gnus-summary-select-article-buffer ()
4966 "Reconfigure windows to show article buffer."
4968 (if (not (gnus-buffer-live-p gnus-article-buffer))
4969 (error "There is no article buffer for this summary buffer")
4970 (gnus-configure-windows 'article)
4971 (select-window (get-buffer-window gnus-article-buffer))))
4973 (defun gnus-summary-universal-argument (arg)
4974 "Perform any operation on all articles that are process/prefixed."
4976 (let ((articles (gnus-summary-work-articles arg))
4983 (substitute-command-keys
4984 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4987 (gnus-error 1 "Undefined key")
4990 (gnus-summary-goto-subject (setq article (pop articles)))
4991 (let (gnus-newsgroup-processable)
4992 (command-execute func))
4993 (gnus-summary-remove-process-mark article)))))
4994 (gnus-summary-position-point))
4996 (defun gnus-summary-toggle-truncation (&optional arg)
4997 "Toggle truncation of summary lines.
4998 With arg, turn line truncation on iff arg is positive."
5000 (setq truncate-lines
5001 (if (null arg) (not truncate-lines)
5002 (> (prefix-numeric-value arg) 0)))
5005 (defun gnus-summary-reselect-current-group (&optional all rescan)
5006 "Exit and then reselect the current newsgroup.
5007 The prefix argument ALL means to select all articles."
5009 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5010 (error "Ephemeral groups can't be reselected"))
5011 (let ((current-subject (gnus-summary-article-number))
5012 (group gnus-newsgroup-name))
5013 (setq gnus-newsgroup-begin nil)
5015 ;; We have to adjust the point of group mode buffer because
5016 ;; point was moved to the next unread newsgroup by exiting.
5017 (gnus-summary-jump-to-group group)
5020 (gnus-group-get-new-news-this-group 1)))
5021 (gnus-group-read-group all t)
5022 (gnus-summary-goto-subject current-subject nil t)))
5024 (defun gnus-summary-rescan-group (&optional all)
5025 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5027 (gnus-summary-reselect-current-group all t))
5029 (defun gnus-summary-update-info (&optional non-destructive)
5031 (let ((group gnus-newsgroup-name))
5033 (when gnus-newsgroup-kill-headers
5034 (setq gnus-newsgroup-killed
5035 (gnus-compress-sequence
5037 (gnus-set-sorted-intersection
5038 (gnus-uncompress-range gnus-newsgroup-killed)
5039 (setq gnus-newsgroup-unselected
5040 (sort gnus-newsgroup-unselected '<)))
5041 (setq gnus-newsgroup-unreads
5042 (sort gnus-newsgroup-unreads '<)))
5044 (unless (listp (cdr gnus-newsgroup-killed))
5045 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5046 (let ((headers gnus-newsgroup-headers))
5047 ;; Set the new ranges of read articles.
5049 (set-buffer gnus-group-buffer)
5050 (gnus-undo-force-boundary))
5051 (gnus-update-read-articles
5052 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5053 ;; Set the current article marks.
5054 (let ((gnus-newsgroup-scored
5055 (if (and (not gnus-save-score)
5056 (not non-destructive))
5058 gnus-newsgroup-scored)))
5060 (gnus-update-marks)))
5061 ;; Do the cross-ref thing.
5062 (when gnus-use-cross-reference
5063 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5064 ;; Do not switch windows but change the buffer to work.
5065 (set-buffer gnus-group-buffer)
5066 (unless (gnus-ephemeral-group-p group)
5067 (gnus-group-update-group group)))))))
5069 (defun gnus-summary-save-newsrc (&optional force)
5070 "Save the current number of read/marked articles in the dribble buffer.
5071 The dribble buffer will then be saved.
5072 If FORCE (the prefix), also save the .newsrc file(s)."
5074 (gnus-summary-update-info t)
5076 (gnus-save-newsrc-file)
5077 (gnus-dribble-save)))
5079 (defun gnus-summary-exit (&optional temporary)
5080 "Exit reading current newsgroup, and then return to group selection mode.
5081 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5083 (gnus-set-global-variables)
5084 (gnus-kill-save-kill-buffer)
5085 (gnus-async-halt-prefetch)
5086 (let* ((group gnus-newsgroup-name)
5087 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5090 (buf (current-buffer)))
5091 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5092 ;; If we have several article buffers, we kill them at exit.
5093 (unless gnus-single-article-buffer
5094 (gnus-kill-buffer gnus-original-article-buffer)
5095 (setq gnus-article-current nil))
5096 (when gnus-use-cache
5097 (gnus-cache-possibly-remove-articles)
5098 (gnus-cache-save-buffers))
5099 (gnus-async-prefetch-remove-group group)
5100 (when gnus-suppress-duplicates
5101 (gnus-dup-enter-articles))
5102 (when gnus-use-trees
5103 (gnus-tree-close group))
5104 ;; Remove entries for this group.
5105 (nnmail-purge-split-history (gnus-group-real-name group))
5106 ;; Make all changes in this group permanent.
5108 (gnus-run-hooks 'gnus-exit-group-hook)
5109 (gnus-summary-update-info)
5110 ;; Do adaptive scoring, and possibly save score files.
5111 (when gnus-newsgroup-adaptive
5112 (gnus-score-adaptive))
5113 (when gnus-use-scoring
5115 (gnus-close-group group)
5116 ;; Make sure where we were, and go to next newsgroup.
5117 (set-buffer gnus-group-buffer)
5119 (gnus-group-jump-to-group group))
5120 (gnus-run-hooks 'gnus-summary-exit-hook)
5121 (unless (or quit-config
5122 ;; If this group has disappeared from the summary
5123 ;; buffer, don't skip forwards.
5124 (not (string= group (gnus-group-group-name))))
5125 (gnus-group-next-unread-group 1))
5126 (setq group-point (point))
5129 ;; If we have several article buffers, we kill them at exit.
5130 (unless gnus-single-article-buffer
5131 (gnus-kill-buffer gnus-article-buffer)
5132 (gnus-kill-buffer gnus-original-article-buffer)
5133 (setq gnus-article-current nil))
5135 (if (not gnus-kill-summary-on-exit)
5136 (gnus-deaden-summary)
5137 ;; We set all buffer-local variables to nil. It is unclear why
5138 ;; this is needed, but if we don't, buffer-local variables are
5139 ;; not garbage-collected, it seems. This would the lead to en
5140 ;; ever-growing Emacs.
5141 (gnus-summary-clear-local-variables)
5142 (when (get-buffer gnus-article-buffer)
5143 (bury-buffer gnus-article-buffer))
5144 ;; We clear the global counterparts of the buffer-local
5145 ;; variables as well, just to be on the safe side.
5146 (set-buffer gnus-group-buffer)
5147 (gnus-summary-clear-local-variables)
5148 ;; Return to group mode buffer.
5149 (when (eq mode 'gnus-summary-mode)
5150 (gnus-kill-buffer buf)))
5151 (setq gnus-current-select-method gnus-select-method)
5152 (pop-to-buffer gnus-group-buffer)
5153 (if (not quit-config)
5155 (goto-char group-point)
5156 (gnus-configure-windows 'group 'force))
5157 (gnus-handle-ephemeral-exit quit-config))
5158 ;; Clear the current group name.
5160 (setq gnus-newsgroup-name nil)))))
5162 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5163 (defun gnus-summary-exit-no-update (&optional no-questions)
5164 "Quit reading current newsgroup without updating read article info."
5166 (let* ((group gnus-newsgroup-name)
5167 (quit-config (gnus-group-quit-config group)))
5168 (when (or no-questions
5170 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5171 (gnus-async-halt-prefetch)
5172 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5173 ;; If we have several article buffers, we kill them at exit.
5174 (unless gnus-single-article-buffer
5175 (gnus-kill-buffer gnus-article-buffer)
5176 (gnus-kill-buffer gnus-original-article-buffer)
5177 (setq gnus-article-current nil))
5178 (if (not gnus-kill-summary-on-exit)
5179 (gnus-deaden-summary)
5180 (gnus-close-group group)
5181 (gnus-summary-clear-local-variables)
5182 (set-buffer gnus-group-buffer)
5183 (gnus-summary-clear-local-variables)
5184 (when (get-buffer gnus-summary-buffer)
5185 (kill-buffer gnus-summary-buffer)))
5186 (unless gnus-single-article-buffer
5187 (setq gnus-article-current nil))
5188 (when gnus-use-trees
5189 (gnus-tree-close group))
5190 (gnus-async-prefetch-remove-group group)
5191 (when (get-buffer gnus-article-buffer)
5192 (bury-buffer gnus-article-buffer))
5193 ;; Return to the group buffer.
5194 (gnus-configure-windows 'group 'force)
5195 ;; Clear the current group name.
5196 (setq gnus-newsgroup-name nil)
5197 (when (equal (gnus-group-group-name) group)
5198 (gnus-group-next-unread-group 1))
5200 (gnus-handle-ephemeral-exit quit-config)))))
5202 (defun gnus-handle-ephemeral-exit (quit-config)
5203 "Handle movement when leaving an ephemeral group.
5204 The state which existed when entering the ephemeral is reset."
5205 (if (not (buffer-name (car quit-config)))
5206 (gnus-configure-windows 'group 'force)
5207 (set-buffer (car quit-config))
5208 (cond ((eq major-mode 'gnus-summary-mode)
5209 (gnus-set-global-variables))
5210 ((eq major-mode 'gnus-article-mode)
5212 ;; The `gnus-summary-buffer' variable may point
5213 ;; to the old summary buffer when using a single
5215 (unless (gnus-buffer-live-p gnus-summary-buffer)
5216 (set-buffer gnus-group-buffer))
5217 (set-buffer gnus-summary-buffer)
5218 (gnus-set-global-variables))))
5219 (if (or (eq (cdr quit-config) 'article)
5220 (eq (cdr quit-config) 'pick))
5222 ;; The current article may be from the ephemeral group
5223 ;; thus it is best that we reload this article
5224 (gnus-summary-show-article)
5225 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5226 (gnus-configure-windows 'pick 'force)
5227 (gnus-configure-windows (cdr quit-config) 'force)))
5228 (gnus-configure-windows (cdr quit-config) 'force))
5229 (when (eq major-mode 'gnus-summary-mode)
5230 (gnus-summary-next-subject 1 nil t)
5231 (gnus-summary-recenter)
5232 (gnus-summary-position-point))))
5234 (defun gnus-summary-preview-mime-message (arg)
5235 "MIME decode and play this message."
5238 (let ((gnus-break-pages nil)
5240 (gnus-summary-select-article t t)
5242 (select-window (get-buffer-window gnus-article-buffer))
5247 (defvar gnus-dead-summary-mode-map nil)
5249 (unless gnus-dead-summary-mode-map
5250 (setq gnus-dead-summary-mode-map (make-keymap))
5251 (suppress-keymap gnus-dead-summary-mode-map)
5252 (substitute-key-definition
5253 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5254 (let ((keys '("\C-d" "\r" "\177" [delete])))
5256 (define-key gnus-dead-summary-mode-map
5257 (pop keys) 'gnus-summary-wake-up-the-dead))))
5259 (defvar gnus-dead-summary-mode nil
5260 "Minor mode for Gnus summary buffers.")
5262 (defun gnus-dead-summary-mode (&optional arg)
5263 "Minor mode for Gnus summary buffers."
5265 (when (eq major-mode 'gnus-summary-mode)
5266 (make-local-variable 'gnus-dead-summary-mode)
5267 (setq gnus-dead-summary-mode
5268 (if (null arg) (not gnus-dead-summary-mode)
5269 (> (prefix-numeric-value arg) 0)))
5270 (when gnus-dead-summary-mode
5271 (gnus-add-minor-mode
5272 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5274 (defun gnus-deaden-summary ()
5275 "Make the current summary buffer into a dead summary buffer."
5276 ;; Kill any previous dead summary buffer.
5277 (when (and gnus-dead-summary
5278 (buffer-name gnus-dead-summary))
5280 (set-buffer gnus-dead-summary)
5281 (when gnus-dead-summary-mode
5282 (kill-buffer (current-buffer)))))
5283 ;; Make this the current dead summary.
5284 (setq gnus-dead-summary (current-buffer))
5285 (gnus-dead-summary-mode 1)
5286 (let ((name (buffer-name)))
5287 (when (string-match "Summary" name)
5289 (concat (substring name 0 (match-beginning 0)) "Dead "
5290 (substring name (match-beginning 0)))
5293 (defun gnus-kill-or-deaden-summary (buffer)
5294 "Kill or deaden the summary BUFFER."
5296 (when (and (buffer-name buffer)
5297 (not gnus-single-article-buffer))
5300 (gnus-kill-buffer gnus-article-buffer)
5301 (gnus-kill-buffer gnus-original-article-buffer)))
5302 (cond (gnus-kill-summary-on-exit
5303 (when (and gnus-use-trees
5304 (gnus-buffer-exists-p buffer))
5307 (gnus-tree-close gnus-newsgroup-name)))
5308 (gnus-kill-buffer buffer))
5309 ((gnus-buffer-exists-p buffer)
5312 (gnus-deaden-summary))))))
5314 (defun gnus-summary-wake-up-the-dead (&rest args)
5315 "Wake up the dead summary buffer."
5317 (gnus-dead-summary-mode -1)
5318 (let ((name (buffer-name)))
5319 (when (string-match "Dead " name)
5321 (concat (substring name 0 (match-beginning 0))
5322 (substring name (match-end 0)))
5324 (gnus-message 3 "This dead summary is now alive again"))
5326 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5327 (defun gnus-summary-fetch-faq (&optional faq-dir)
5328 "Fetch the FAQ for the current group.
5329 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5333 (when current-prefix-arg
5335 "Faq dir: " (and (listp gnus-group-faq-directory)
5336 (mapcar (lambda (file) (list file))
5337 gnus-group-faq-directory))))))
5338 (let (gnus-faq-buffer)
5339 (when (setq gnus-faq-buffer
5340 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5341 (gnus-configure-windows 'summary-faq))))
5343 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5344 (defun gnus-summary-describe-group (&optional force)
5345 "Describe the current newsgroup."
5347 (gnus-group-describe-group force gnus-newsgroup-name))
5349 (defun gnus-summary-describe-briefly ()
5350 "Describe summary mode commands briefly."
5353 (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")))
5355 ;; Walking around group mode buffer from summary mode.
5357 (defun gnus-summary-next-group (&optional no-article target-group backward)
5358 "Exit current newsgroup and then select next unread newsgroup.
5359 If prefix argument NO-ARTICLE is non-nil, no article is selected
5360 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5361 previous group instead."
5363 ;; Stop pre-fetching.
5364 (gnus-async-halt-prefetch)
5365 (let ((current-group gnus-newsgroup-name)
5366 (current-buffer (current-buffer))
5368 ;; First we semi-exit this group to update Xrefs and all variables.
5369 ;; We can't do a real exit, because the window conf must remain
5370 ;; the same in case the user is prompted for info, and we don't
5371 ;; want the window conf to change before that...
5372 (gnus-summary-exit t)
5373 (while (not entered)
5374 ;; Then we find what group we are supposed to enter.
5375 (set-buffer gnus-group-buffer)
5376 (gnus-group-jump-to-group current-group)
5379 (if (eq gnus-keep-same-level 'best)
5380 (gnus-summary-best-group gnus-newsgroup-name)
5381 (gnus-summary-search-group backward gnus-keep-same-level))))
5382 (if (not target-group)
5383 ;; There are no further groups, so we return to the group
5386 (gnus-message 5 "Returning to the group buffer")
5388 (when (gnus-buffer-live-p current-buffer)
5389 (set-buffer current-buffer)
5390 (gnus-summary-exit))
5391 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5392 ;; We try to enter the target group.
5393 (gnus-group-jump-to-group target-group)
5394 (let ((unreads (gnus-group-group-unread)))
5395 (if (and (or (eq t unreads)
5396 (and unreads (not (zerop unreads))))
5397 (gnus-summary-read-group
5398 target-group nil no-article
5399 (and (buffer-name current-buffer) current-buffer)
5402 (setq current-group target-group
5403 target-group nil)))))))
5405 (defun gnus-summary-prev-group (&optional no-article)
5406 "Exit current newsgroup and then select previous unread newsgroup.
5407 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5409 (gnus-summary-next-group no-article nil t))
5411 ;; Walking around summary lines.
5413 (defun gnus-summary-first-subject (&optional unread undownloaded)
5414 "Go to the first unread subject.
5415 If UNREAD is non-nil, go to the first unread article.
5416 Returns the article selected or nil if there are no unread articles."
5421 ((null gnus-newsgroup-data)
5422 (gnus-message 3 "No articles in the group")
5424 ;; Pick the first article.
5426 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5427 (gnus-data-number (car gnus-newsgroup-data)))
5428 ;; No unread articles.
5429 ((null gnus-newsgroup-unreads)
5430 (gnus-message 3 "No more unread articles")
5432 ;; Find the first unread article.
5434 (let ((data gnus-newsgroup-data))
5436 (and (not (and undownloaded
5437 (eq gnus-undownloaded-mark
5438 (gnus-data-mark (car data)))))
5439 (not (gnus-data-unread-p (car data)))))
5440 (setq data (cdr data)))
5442 (goto-char (gnus-data-pos (car data)))
5443 (gnus-data-number (car data))))))
5444 (gnus-summary-position-point)))
5446 (defun gnus-summary-next-subject (n &optional unread dont-display)
5447 "Go to next N'th summary line.
5448 If N is negative, go to the previous N'th subject line.
5449 If UNREAD is non-nil, only unread articles are selected.
5450 The difference between N and the actual number of steps taken is
5453 (let ((backward (< n 0))
5457 (gnus-summary-find-prev unread)
5458 (gnus-summary-find-next unread)))
5459 (gnus-summary-show-thread)
5462 (gnus-message 7 "No more%s articles"
5463 (if unread " unread" "")))
5464 (unless dont-display
5465 (gnus-summary-recenter)
5466 (gnus-summary-position-point))
5469 (defun gnus-summary-next-unread-subject (n)
5470 "Go to next N'th unread summary line."
5472 (gnus-summary-next-subject n t))
5474 (defun gnus-summary-prev-subject (n &optional unread)
5475 "Go to previous N'th summary line.
5476 If optional argument UNREAD is non-nil, only unread article is selected."
5478 (gnus-summary-next-subject (- n) unread))
5480 (defun gnus-summary-prev-unread-subject (n)
5481 "Go to previous N'th unread summary line."
5483 (gnus-summary-next-subject (- n) t))
5485 (defun gnus-summary-goto-subject (article &optional force silent)
5486 "Go the subject line of ARTICLE.
5487 If FORCE, also allow jumping to articles not currently shown."
5488 (interactive "nArticle number: ")
5490 (data (gnus-data-find article)))
5491 ;; We read in the article if we have to.
5494 (gnus-summary-insert-subject
5496 (if (or (numberp force) (vectorp force)) force)
5498 (setq data (gnus-data-find article)))
5503 (gnus-message 3 "Can't find article %d" article))
5505 (goto-char (gnus-data-pos data))
5506 (gnus-summary-position-point)
5509 ;; Walking around summary lines with displaying articles.
5511 (defun gnus-summary-expand-window (&optional arg)
5512 "Make the summary buffer take up the entire Emacs frame.
5513 Given a prefix, will force an `article' buffer configuration."
5516 (gnus-configure-windows 'article 'force)
5517 (gnus-configure-windows 'summary 'force)))
5519 (defun gnus-summary-display-article (article &optional all-header)
5520 "Display ARTICLE in article buffer."
5521 (gnus-set-global-variables)
5525 (if gnus-summary-display-article-function
5526 (funcall gnus-summary-display-article-function article all-header)
5527 (gnus-article-prepare article all-header))
5528 (gnus-run-hooks 'gnus-select-article-hook)
5529 (when (and gnus-current-article
5530 (not (zerop gnus-current-article)))
5531 (gnus-summary-goto-subject gnus-current-article))
5532 (gnus-summary-recenter)
5533 (when (and gnus-use-trees gnus-show-threads)
5534 (gnus-possibly-generate-tree article)
5535 (gnus-highlight-selected-tree article))
5536 ;; Successfully display article.
5537 (gnus-article-set-window-start
5538 (cdr (assq article gnus-newsgroup-bookmarks))))))
5540 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5541 "Select the current article.
5542 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5543 non-nil, the article will be re-fetched even if it already present in
5544 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5546 ;; Make sure we are in the summary buffer to work around bbdb bug.
5547 (unless (eq major-mode 'gnus-summary-mode)
5548 (set-buffer gnus-summary-buffer))
5549 (let ((article (or article (gnus-summary-article-number)))
5550 (all-headers (not (not all-headers))) ;Must be T or NIL.
5551 gnus-summary-display-article-function
5554 (gnus-summary-article-pseudo-p article)
5555 (error "This is a pseudo-article"))
5558 (set-buffer gnus-summary-buffer)
5559 (if (or (and gnus-single-article-buffer
5560 (or (null gnus-current-article)
5561 (null gnus-article-current)
5562 (null (get-buffer gnus-article-buffer))
5563 (not (eq article (cdr gnus-article-current)))
5564 (not (equal (car gnus-article-current)
5565 gnus-newsgroup-name))))
5566 (and (not gnus-single-article-buffer)
5567 (or (null gnus-current-article)
5568 (not (eq gnus-current-article article))))
5570 ;; The requested article is different from the current article.
5572 (gnus-summary-display-article article all-headers)
5574 (when (or all-headers gnus-show-all-headers)
5575 (gnus-article-show-all-headers))
5578 (gnus-article-set-window-start
5579 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5581 (defun gnus-summary-set-current-mark (&optional current-mark)
5582 "Obsolete function."
5585 (defun gnus-summary-next-article (&optional unread subject backward push)
5586 "Select the next article.
5587 If UNREAD, only unread articles are selected.
5588 If SUBJECT, only articles with SUBJECT are selected.
5589 If BACKWARD, the previous article is selected instead of the next."
5592 ;; Is there such an article?
5593 ((and (gnus-summary-search-forward unread subject backward)
5594 (or (gnus-summary-display-article (gnus-summary-article-number))
5595 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5596 (gnus-summary-position-point))
5597 ;; If not, we try the first unread, if that is wanted.
5599 gnus-auto-select-same
5600 (gnus-summary-first-unread-article))
5601 (gnus-summary-position-point)
5602 (gnus-message 6 "Wrapped"))
5603 ;; Try to get next/previous article not displayed in this group.
5604 ((and gnus-auto-extend-newsgroup
5605 (not unread) (not subject))
5606 (gnus-summary-goto-article
5607 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5608 nil (count-lines (point-min) (point))))
5609 ;; Go to next/previous group.
5611 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5612 (gnus-summary-jump-to-group gnus-newsgroup-name))
5613 (let ((cmd last-command-char)
5616 (set-buffer gnus-group-buffer)
5619 (if (eq gnus-keep-same-level 'best)
5620 (gnus-summary-best-group gnus-newsgroup-name)
5621 (gnus-summary-search-group backward gnus-keep-same-level))))
5622 ;; For some reason, the group window gets selected. We change
5624 (select-window (get-buffer-window (current-buffer)))
5625 ;; Select next unread newsgroup automagically.
5627 ((or (not gnus-auto-select-next)
5629 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5630 ((or (eq gnus-auto-select-next 'quietly)
5631 (and (eq gnus-auto-select-next 'slightly-quietly)
5633 (and (eq gnus-auto-select-next 'almost-quietly)
5634 (gnus-summary-last-article-p)))
5636 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5638 (gnus-message 7 "No more%s articles (%s)..."
5639 (if unread " unread" "")
5640 (if group (concat "selecting " group)
5642 (gnus-summary-next-group nil group backward)))
5644 (when (gnus-key-press-event-p last-input-event)
5645 (gnus-summary-walk-group-buffer
5646 gnus-newsgroup-name cmd unread backward point))))))))
5648 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5649 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5650 (?\C-p (gnus-group-prev-unread-group 1))))
5651 (cursor-in-echo-area t)
5652 keve key group ended)
5654 (set-buffer gnus-group-buffer)
5657 (if (eq gnus-keep-same-level 'best)
5658 (gnus-summary-best-group gnus-newsgroup-name)
5659 (gnus-summary-search-group backward gnus-keep-same-level))))
5662 5 "No more%s articles%s" (if unread " unread" "")
5664 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5665 (format " (Type %s for %s [%s])"
5666 (single-key-description cmd) group
5667 (car (gnus-gethash group gnus-newsrc-hashtb)))
5668 (format " (Type %s to exit %s)"
5669 (single-key-description cmd)
5670 gnus-newsgroup-name)))
5671 ;; Confirm auto selection.
5672 (setq key (car (setq keve (gnus-read-event-char))))
5675 ((assq key keystrokes)
5676 (let ((obuf (current-buffer)))
5677 (switch-to-buffer gnus-group-buffer)
5679 (gnus-group-jump-to-group group))
5680 (eval (cadr (assq key keystrokes)))
5681 (setq group (gnus-group-group-name))
5682 (switch-to-buffer obuf))
5686 (gnus-ephemeral-group-p gnus-newsgroup-name))
5688 (gnus-summary-next-group nil group backward)))
5690 (push (cdr keve) unread-command-events))))))
5692 (defun gnus-summary-next-unread-article ()
5693 "Select unread article after current one."
5695 (gnus-summary-next-article
5696 (or (not (eq gnus-summary-goto-unread 'never))
5697 (gnus-summary-last-article-p (gnus-summary-article-number)))
5698 (and gnus-auto-select-same
5699 (gnus-summary-article-subject))))
5701 (defun gnus-summary-prev-article (&optional unread subject)
5702 "Select the article after the current one.
5703 If UNREAD is non-nil, only unread articles are selected."
5705 (gnus-summary-next-article unread subject t))
5707 (defun gnus-summary-prev-unread-article ()
5708 "Select unread article before current one."
5710 (gnus-summary-prev-article
5711 (or (not (eq gnus-summary-goto-unread 'never))
5712 (gnus-summary-first-article-p (gnus-summary-article-number)))
5713 (and gnus-auto-select-same
5714 (gnus-summary-article-subject))))
5716 (defun gnus-summary-next-page (&optional lines circular)
5717 "Show next page of the selected article.
5718 If at the end of the current article, select the next article.
5719 LINES says how many lines should be scrolled up.
5721 If CIRCULAR is non-nil, go to the start of the article instead of
5722 selecting the next article when reaching the end of the current
5725 (setq gnus-summary-buffer (current-buffer))
5726 (gnus-set-global-variables)
5727 (let ((article (gnus-summary-article-number))
5728 (article-window (get-buffer-window gnus-article-buffer t))
5730 ;; If the buffer is empty, we have no article.
5732 (error "No article to select"))
5733 (gnus-configure-windows 'article)
5734 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5735 (if (and (eq gnus-summary-goto-unread 'never)
5736 (not (gnus-summary-last-article-p article)))
5737 (gnus-summary-next-article)
5738 (gnus-summary-next-unread-article))
5739 (if (or (null gnus-current-article)
5740 (null gnus-article-current)
5741 (/= article (cdr gnus-article-current))
5742 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5743 ;; Selected subject is different from current article's.
5744 (gnus-summary-display-article article)
5745 (when article-window
5746 (gnus-eval-in-buffer-window gnus-article-buffer
5747 (setq endp (gnus-article-next-page lines)))
5750 (gnus-summary-beginning-of-article))
5752 (gnus-message 3 "End of message"))
5754 (if (and (eq gnus-summary-goto-unread 'never)
5755 (not (gnus-summary-last-article-p article)))
5756 (gnus-summary-next-article)
5757 (gnus-summary-next-unread-article))))))))
5758 (gnus-summary-recenter)
5759 (gnus-summary-position-point)))
5761 (defun gnus-summary-prev-page (&optional lines move)
5762 "Show previous page of selected article.
5763 Argument LINES specifies lines to be scrolled down.
5764 If MOVE, move to the previous unread article if point is at
5765 the beginning of the buffer."
5767 (let ((article (gnus-summary-article-number))
5768 (article-window (get-buffer-window gnus-article-buffer t))
5770 (gnus-configure-windows 'article)
5771 (if (or (null gnus-current-article)
5772 (null gnus-article-current)
5773 (/= article (cdr gnus-article-current))
5774 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5775 ;; Selected subject is different from current article's.
5776 (gnus-summary-display-article article)
5777 (gnus-summary-recenter)
5778 (when article-window
5779 (gnus-eval-in-buffer-window gnus-article-buffer
5780 (setq endp (gnus-article-prev-page lines)))
5781 (when (and move endp)
5783 (gnus-message 3 "Beginning of message"))
5785 (if (and (eq gnus-summary-goto-unread 'never)
5786 (not (gnus-summary-first-article-p article)))
5787 (gnus-summary-prev-article)
5788 (gnus-summary-prev-unread-article))))))))
5789 (gnus-summary-position-point))
5791 (defun gnus-summary-prev-page-or-article (&optional lines)
5792 "Show previous page of selected article.
5793 Argument LINES specifies lines to be scrolled down.
5794 If at the beginning of the article, go to the next article."
5796 (gnus-summary-prev-page lines t))
5798 (defun gnus-summary-scroll-up (lines)
5799 "Scroll up (or down) one line current article.
5800 Argument LINES specifies lines to be scrolled up (or down if negative)."
5802 (gnus-configure-windows 'article)
5803 (gnus-summary-show-thread)
5804 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5805 (gnus-eval-in-buffer-window gnus-article-buffer
5807 (when (gnus-article-next-page lines)
5808 (gnus-message 3 "End of message")))
5810 (gnus-article-prev-page (- lines))))))
5811 (gnus-summary-recenter)
5812 (gnus-summary-position-point))
5814 (defun gnus-summary-scroll-down (lines)
5815 "Scroll down (or up) one line current article.
5816 Argument LINES specifies lines to be scrolled down (or up if negative)."
5818 (gnus-summary-scroll-up (- lines)))
5820 (defun gnus-summary-next-same-subject ()
5821 "Select next article which has the same subject as current one."
5823 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5825 (defun gnus-summary-prev-same-subject ()
5826 "Select previous article which has the same subject as current one."
5828 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5830 (defun gnus-summary-next-unread-same-subject ()
5831 "Select next unread article which has the same subject as current one."
5833 (gnus-summary-next-article t (gnus-summary-article-subject)))
5835 (defun gnus-summary-prev-unread-same-subject ()
5836 "Select previous unread article which has the same subject as current one."
5838 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5840 (defun gnus-summary-first-unread-article ()
5841 "Select the first unread article.
5842 Return nil if there are no unread articles."
5845 (when (gnus-summary-first-subject t)
5846 (gnus-summary-show-thread)
5847 (gnus-summary-first-subject t)
5848 (gnus-summary-display-article (gnus-summary-article-number)))
5849 (gnus-summary-position-point)))
5851 (defun gnus-summary-first-article ()
5852 "Select the first article.
5853 Return nil if there are no articles."
5856 (when (gnus-summary-first-subject)
5857 (gnus-summary-show-thread)
5858 (gnus-summary-first-subject)
5859 (gnus-summary-display-article (gnus-summary-article-number)))
5860 (gnus-summary-position-point)))
5862 (defun gnus-summary-best-unread-article ()
5863 "Select the unread article with the highest score."
5865 (let ((best -1000000)
5866 (data gnus-newsgroup-data)
5869 (and (gnus-data-unread-p (car data))
5871 (gnus-summary-article-score (gnus-data-number (car data))))
5874 article (gnus-data-number (car data))))
5875 (setq data (cdr data)))
5878 (gnus-summary-goto-article article)
5879 (error "No unread articles"))
5880 (gnus-summary-position-point))))
5882 (defun gnus-summary-last-subject ()
5883 "Go to the last displayed subject line in the group."
5884 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5886 (gnus-summary-goto-subject article))))
5888 (defun gnus-summary-goto-article (article &optional all-headers force)
5889 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5890 If ALL-HEADERS is non-nil, no header lines are hidden.
5891 If FORCE, go to the article even if it isn't displayed. If FORCE
5892 is a number, it is the line the article is to be displayed on."
5896 "Article number or Message-ID: "
5897 (mapcar (lambda (number) (list (int-to-string number)))
5898 gnus-newsgroup-limit))
5902 (if (and (stringp article)
5903 (string-match "@" article))
5904 (gnus-summary-refer-article article)
5905 (when (stringp article)
5906 (setq article (string-to-number article)))
5907 (if (gnus-summary-goto-subject article force)
5908 (gnus-summary-display-article article all-headers)
5909 (gnus-message 4 "Couldn't go to article %s" article) nil))
5910 (gnus-summary-position-point)))
5912 (defun gnus-summary-goto-last-article ()
5913 "Go to the previously read article."
5916 (when gnus-last-article
5917 (gnus-summary-goto-article gnus-last-article nil t))
5918 (gnus-summary-position-point)))
5920 (defun gnus-summary-pop-article (number)
5921 "Pop one article off the history and go to the previous.
5922 NUMBER articles will be popped off."
5925 (setq gnus-newsgroup-history
5926 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5928 (gnus-summary-goto-article (car to) nil t)
5929 (error "Article history empty")))
5930 (gnus-summary-position-point))
5932 ;; Summary commands and functions for limiting the summary buffer.
5934 (defun gnus-summary-limit-to-articles (n)
5935 "Limit the summary buffer to the next N articles.
5936 If not given a prefix, use the process marked articles instead."
5939 (let ((articles (gnus-summary-work-articles n)))
5940 (setq gnus-newsgroup-processable nil)
5941 (gnus-summary-limit articles))
5942 (gnus-summary-position-point)))
5944 (defun gnus-summary-pop-limit (&optional total)
5945 "Restore the previous limit.
5946 If given a prefix, remove all limits."
5949 (setq gnus-newsgroup-limits
5950 (list (mapcar (lambda (h) (mail-header-number h))
5951 gnus-newsgroup-headers))))
5952 (unless gnus-newsgroup-limits
5953 (error "No limit to pop"))
5955 (gnus-summary-limit nil 'pop)
5956 (gnus-summary-position-point)))
5958 (defun gnus-summary-limit-to-subject (subject &optional header)
5959 "Limit the summary buffer to articles that have subjects that match a regexp."
5960 (interactive "sLimit to subject (regexp): ")
5962 (setq header "subject"))
5963 (when (not (equal "" subject))
5965 (let ((articles (gnus-summary-find-matching
5966 (or header "subject") subject 'all)))
5968 (error "Found no matches for \"%s\"" subject))
5969 (gnus-summary-limit articles))
5970 (gnus-summary-position-point))))
5972 (defun gnus-summary-limit-to-author (from)
5973 "Limit the summary buffer to articles that have authors that match a regexp."
5974 (interactive "sLimit to author (regexp): ")
5975 (gnus-summary-limit-to-subject from "from"))
5977 (defun gnus-summary-limit-to-age (age &optional younger-p)
5978 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5979 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5980 articles that are younger than AGE days."
5981 (interactive "nTime in days: \nP")
5983 (let ((data gnus-newsgroup-data)
5984 (cutoff (days-to-time age))
5985 articles d date is-younger)
5986 (while (setq d (pop data))
5987 (when (and (vectorp (gnus-data-header d))
5988 (setq date (mail-header-date (gnus-data-header d))))
5989 (setq is-younger (time-less-p
5990 (time-since (date-to-time date))
5995 (push (gnus-data-number d) articles))))
5996 (gnus-summary-limit (nreverse articles)))
5997 (gnus-summary-position-point)))
5999 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6001 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6003 (defun gnus-summary-limit-to-unread (&optional all)
6004 "Limit the summary buffer to articles that are not marked as read.
6005 If ALL is non-nil, limit strictly to unread articles."
6008 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6009 (gnus-summary-limit-to-marks
6010 ;; Concat all the marks that say that an article is read and have
6012 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6013 gnus-killed-mark gnus-kill-file-mark
6014 gnus-low-score-mark gnus-expirable-mark
6015 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6016 gnus-duplicate-mark gnus-souped-mark)
6019 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6020 (make-obsolete 'gnus-summary-delete-marked-with
6021 'gnus-summary-limit-exlude-marks)
6023 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6024 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6025 If REVERSE, limit the summary buffer to articles that are marked
6026 with MARKS. MARKS can either be a string of marks or a list of marks.
6027 Returns how many articles were removed."
6028 (interactive "sMarks: ")
6029 (gnus-summary-limit-to-marks marks t))
6031 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6032 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6033 If REVERSE (the prefix), limit the summary buffer to articles that are
6034 not marked with MARKS. MARKS can either be a string of marks or a
6036 Returns how many articles were removed."
6037 (interactive "sMarks: \nP")
6039 (let ((data gnus-newsgroup-data)
6040 (marks (if (listp marks) marks
6041 (append marks nil))) ; Transform to list.
6044 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6045 (memq (gnus-data-mark (car data)) marks))
6046 (push (gnus-data-number (car data)) articles))
6047 (setq data (cdr data)))
6048 (gnus-summary-limit articles))
6049 (gnus-summary-position-point)))
6051 (defun gnus-summary-limit-to-score (&optional score)
6052 "Limit to articles with score at or above SCORE."
6054 (setq score (if score
6055 (prefix-numeric-value score)
6056 (or gnus-summary-default-score 0)))
6057 (let ((data gnus-newsgroup-data)
6060 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6062 (push (gnus-data-number (car data)) articles))
6063 (setq data (cdr data)))
6065 (gnus-summary-limit articles)
6066 (gnus-summary-position-point))))
6068 (defun gnus-summary-limit-include-thread (id)
6069 "Display all the hidden articles that in the current thread."
6070 (interactive (list (mail-header-id (gnus-summary-article-header))))
6071 (let ((articles (gnus-articles-in-thread
6072 (gnus-id-to-thread (gnus-root-id id)))))
6074 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6075 (gnus-summary-position-point))))
6077 (defun gnus-summary-limit-include-dormant ()
6078 "Display all the hidden articles that are marked as dormant.
6079 Note that this command only works on a subset of the articles currently
6080 fetched for this group."
6082 (unless gnus-newsgroup-dormant
6083 (error "There are no dormant articles in this group"))
6085 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6086 (gnus-summary-position-point)))
6088 (defun gnus-summary-limit-exclude-dormant ()
6089 "Hide all dormant articles."
6092 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6093 (gnus-summary-position-point)))
6095 (defun gnus-summary-limit-exclude-childless-dormant ()
6096 "Hide all dormant articles that have no children."
6098 (let ((data (gnus-data-list t))
6099 articles d children)
6100 ;; Find all articles that are either not dormant or have
6102 (while (setq d (pop data))
6103 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6105 (gnus-article-children (gnus-data-number d)))
6108 (when (memq (car children) articles)
6113 (push (gnus-data-number d) articles)))
6116 (gnus-summary-limit articles)
6117 (gnus-summary-position-point))))
6119 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6120 "Mark all unread excluded articles as read.
6121 If ALL, mark even excluded ticked and dormants as read."
6123 (let ((articles (gnus-sorted-complement
6125 (mapcar (lambda (h) (mail-header-number h))
6126 gnus-newsgroup-headers)
6128 (sort gnus-newsgroup-limit '<)))
6130 (setq gnus-newsgroup-unreads
6131 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6133 (setq gnus-newsgroup-dormant nil
6134 gnus-newsgroup-marked nil
6135 gnus-newsgroup-reads
6137 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6138 gnus-newsgroup-reads))
6139 (while (setq article (pop articles))
6140 (unless (or (memq article gnus-newsgroup-dormant)
6141 (memq article gnus-newsgroup-marked))
6142 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6144 (defun gnus-summary-limit (articles &optional pop)
6146 ;; We pop the previous limit off the stack and use that.
6147 (setq articles (car gnus-newsgroup-limits)
6148 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6149 ;; We use the new limit, so we push the old limit on the stack.
6150 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6152 (setq gnus-newsgroup-limit articles)
6153 (let ((total (length gnus-newsgroup-data))
6154 (data (gnus-data-find-list (gnus-summary-article-number)))
6155 (gnus-summary-mark-below nil) ; Inhibit this.
6157 ;; This will do all the work of generating the new summary buffer
6158 ;; according to the new limit.
6159 (gnus-summary-prepare)
6160 ;; Hide any threads, possibly.
6161 (and gnus-show-threads
6162 gnus-thread-hide-subtree
6163 (gnus-summary-hide-all-threads))
6164 ;; Try to return to the article you were at, or one in the
6167 ;; We try to find some article after the current one.
6169 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6172 (setq data (cdr data))))
6174 ;; If there is no data, that means that we were after the last
6175 ;; article. The same goes when we can't find any articles
6176 ;; after the current one.
6177 (goto-char (point-max))
6178 (gnus-summary-find-prev))
6179 (gnus-set-mode-line 'summary)
6180 ;; We return how many articles were removed from the summary
6181 ;; buffer as a result of the new limit.
6182 (- total (length gnus-newsgroup-data))))
6184 (defsubst gnus-invisible-cut-children (threads)
6187 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6192 (defsubst gnus-cut-thread (thread)
6193 "Go forwards in the thread until we find an article that we want to display."
6194 (when (or (eq gnus-fetch-old-headers 'some)
6195 (eq gnus-fetch-old-headers 'invisible)
6196 (eq gnus-build-sparse-threads 'some)
6197 (eq gnus-build-sparse-threads 'more))
6198 ;; Deal with old-fetched headers and sparse threads.
6202 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6203 (gnus-summary-article-ancient-p
6204 (mail-header-number (car thread))))
6205 (if (or (<= (length (cdr thread)) 1)
6206 (eq gnus-fetch-old-headers 'invisible))
6207 (setq gnus-newsgroup-limit
6208 (delq (mail-header-number (car thread))
6209 gnus-newsgroup-limit)
6210 thread (cadr thread))
6211 (when (gnus-invisible-cut-children (cdr thread))
6212 (let ((th (cdr thread)))
6214 (if (memq (mail-header-number (caar th))
6215 gnus-newsgroup-limit)
6216 (setq thread (car th)
6218 (setq th (cdr th))))))))))
6221 (defun gnus-cut-threads (threads)
6222 "Cut off all uninteresting articles from the beginning of threads."
6223 (when (or (eq gnus-fetch-old-headers 'some)
6224 (eq gnus-fetch-old-headers 'invisible)
6225 (eq gnus-build-sparse-threads 'some)
6226 (eq gnus-build-sparse-threads 'more))
6229 (setcar th (gnus-cut-thread (car th)))
6230 (setq th (cdr th)))))
6231 ;; Remove nixed out threads.
6234 (defun gnus-summary-initial-limit (&optional show-if-empty)
6235 "Figure out what the initial limit is supposed to be on group entry.
6236 This entails weeding out unwanted dormants, low-scored articles,
6237 fetch-old-headers verbiage, and so on."
6238 ;; Most groups have nothing to remove.
6239 (if (or gnus-inhibit-limiting
6240 (and (null gnus-newsgroup-dormant)
6241 (not (eq gnus-fetch-old-headers 'some))
6242 (not (eq gnus-fetch-old-headers 'invisible))
6243 (null gnus-summary-expunge-below)
6244 (not (eq gnus-build-sparse-threads 'some))
6245 (not (eq gnus-build-sparse-threads 'more))
6246 (null gnus-thread-expunge-below)
6247 (not gnus-use-nocem)))
6249 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6250 (setq gnus-newsgroup-limit nil)
6253 (unless (car (symbol-value node))
6254 ;; These threads have no parents -- they are roots.
6255 (let ((nodes (cdr (symbol-value node)))
6258 (if (and gnus-thread-expunge-below
6259 (< (gnus-thread-total-score (car nodes))
6260 gnus-thread-expunge-below))
6261 (gnus-expunge-thread (pop nodes))
6262 (setq thread (pop nodes))
6263 (gnus-summary-limit-children thread))))))
6264 gnus-newsgroup-dependencies)
6265 ;; If this limitation resulted in an empty group, we might
6266 ;; pop the previous limit and use it instead.
6267 (when (and (not gnus-newsgroup-limit)
6269 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6270 gnus-newsgroup-limit))
6272 (defun gnus-summary-limit-children (thread)
6273 "Return 1 if this subthread is visible and 0 if it is not."
6274 ;; First we get the number of visible children to this thread. This
6275 ;; is done by recursing down the thread using this function, so this
6276 ;; will really go down to a leaf article first, before slowly
6277 ;; working its way up towards the root.
6281 (apply '+ (mapcar 'gnus-summary-limit-children
6284 (number (mail-header-number (car thread)))
6287 (not (memq number gnus-newsgroup-marked))
6289 ;; If this article is dormant and has absolutely no visible
6290 ;; children, then this article isn't visible.
6291 (and (memq number gnus-newsgroup-dormant)
6293 ;; If this is "fetch-old-headered" and there is no
6294 ;; visible children, then we don't want this article.
6295 (and (eq gnus-fetch-old-headers 'some)
6296 (gnus-summary-article-ancient-p number)
6298 ;; If this is "fetch-old-headered" and `invisible', then
6299 ;; we don't want this article.
6300 (and (eq gnus-fetch-old-headers 'invisible)
6301 (gnus-summary-article-ancient-p number))
6302 ;; If this is a sparsely inserted article with no children,
6303 ;; we don't want it.
6304 (and (eq gnus-build-sparse-threads 'some)
6305 (gnus-summary-article-sparse-p number)
6307 ;; If we use expunging, and this article is really
6308 ;; low-scored, then we don't want this article.
6309 (when (and gnus-summary-expunge-below
6311 (or (cdr (assq number gnus-newsgroup-scored))
6312 gnus-summary-default-score))
6313 gnus-summary-expunge-below))
6314 ;; We increase the expunge-tally here, but that has
6315 ;; nothing to do with the limits, really.
6316 (incf gnus-newsgroup-expunged-tally)
6317 ;; We also mark as read here, if that's wanted.
6318 (when (and gnus-summary-mark-below
6319 (< score gnus-summary-mark-below))
6320 (setq gnus-newsgroup-unreads
6321 (delq number gnus-newsgroup-unreads))
6322 (if gnus-newsgroup-auto-expire
6323 (push number gnus-newsgroup-expirable)
6324 (push (cons number gnus-low-score-mark)
6325 gnus-newsgroup-reads)))
6327 ;; Check NoCeM things.
6328 (if (and gnus-use-nocem
6329 (gnus-nocem-unwanted-article-p
6330 (mail-header-id (car thread))))
6332 (setq gnus-newsgroup-unreads
6333 (delq number gnus-newsgroup-unreads))
6335 ;; Nope, invisible article.
6337 ;; Ok, this article is to be visible, so we add it to the limit
6339 (push number gnus-newsgroup-limit)
6342 (defun gnus-expunge-thread (thread)
6343 "Mark all articles in THREAD as read."
6344 (let* ((number (mail-header-number (car thread))))
6345 (incf gnus-newsgroup-expunged-tally)
6346 ;; We also mark as read here, if that's wanted.
6347 (setq gnus-newsgroup-unreads
6348 (delq number gnus-newsgroup-unreads))
6349 (if gnus-newsgroup-auto-expire
6350 (push number gnus-newsgroup-expirable)
6351 (push (cons number gnus-low-score-mark)
6352 gnus-newsgroup-reads)))
6353 ;; Go recursively through all subthreads.
6354 (mapcar 'gnus-expunge-thread (cdr thread)))
6356 ;; Summary article oriented commands
6358 (defun gnus-summary-refer-parent-article (n)
6359 "Refer parent article N times.
6360 If N is negative, go to ancestor -N instead.
6361 The difference between N and the number of articles fetched is returned."
6365 (when (not (natnump n))
6370 (setq header (gnus-summary-article-header))
6371 (if (and (eq (mail-header-number header)
6372 (cdr gnus-article-current))
6373 (equal gnus-newsgroup-name
6374 (car gnus-article-current)))
6375 ;; If we try to find the parent of the currently
6376 ;; displayed article, then we take a look at the actual
6377 ;; References header, since this is slightly more
6378 ;; reliable than the References field we got from the
6381 (set-buffer gnus-original-article-buffer)
6382 (nnheader-narrow-to-headers)
6383 (unless (setq ref (message-fetch-field "references"))
6384 (setq ref (message-fetch-field "in-reply-to")))
6387 ;; It's not the current article, so we take a bet on
6388 ;; the value we got from the server.
6389 (mail-header-references header)))
6391 (not (equal ref "")))
6392 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6393 (gnus-message 1 "Couldn't find parent"))
6394 (gnus-message 1 "No references in article %d"
6395 (gnus-summary-article-number))
6398 (gnus-summary-position-point)
6401 (defun gnus-summary-refer-references ()
6402 "Fetch all articles mentioned in the References header.
6403 Return the number of articles fetched."
6405 (let ((ref (mail-header-references (gnus-summary-article-header)))
6406 (current (gnus-summary-article-number))
6410 (error "No References in the current article")
6411 ;; For each Message-ID in the References header...
6412 (while (string-match "<[^>]*>" ref)
6414 ;; ... fetch that article.
6415 (gnus-summary-refer-article
6416 (prog1 (match-string 0 ref)
6417 (setq ref (substring ref (match-end 0))))))
6418 (gnus-summary-goto-subject current)
6419 (gnus-summary-position-point)
6422 (defun gnus-summary-refer-thread (&optional limit)
6423 "Fetch all articles in the current thread.
6424 If LIMIT (the numerical prefix), fetch that many old headers instead
6425 of what's specified by the `gnus-refer-thread-limit' variable."
6427 (let ((id (mail-header-id (gnus-summary-article-header)))
6428 (limit (if limit (prefix-numeric-value limit)
6429 gnus-refer-thread-limit)))
6430 ;; We want to fetch LIMIT *old* headers, but we also have to
6431 ;; re-fetch all the headers in the current buffer, because many of
6432 ;; them may be undisplayed. So we adjust LIMIT.
6433 (when (numberp limit)
6434 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6435 (unless (eq gnus-fetch-old-headers 'invisible)
6436 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6437 ;; Retrieve the headers and read them in.
6438 (if (eq (gnus-retrieve-headers
6439 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6441 (gnus-build-all-threads)
6442 (error "Can't fetch thread from backends that don't support NOV"))
6443 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6444 (gnus-summary-limit-include-thread id)))
6446 (defun gnus-summary-refer-article (message-id &optional arg)
6447 "Fetch an article specified by MESSAGE-ID.
6448 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6449 or `gnus-select-method', no matter what backend the article comes from."
6450 (interactive "sMessage-ID: \nP")
6451 (when (and (stringp message-id)
6452 (not (zerop (length message-id))))
6453 ;; Construct the correct Message-ID if necessary.
6454 ;; Suggested by tale@pawl.rpi.edu.
6455 (unless (string-match "^<" message-id)
6456 (setq message-id (concat "<" message-id)))
6457 (unless (string-match ">$" message-id)
6458 (setq message-id (concat message-id ">")))
6459 (let* ((header (gnus-id-to-header message-id))
6461 (gnus-summary-article-sparse-p
6462 (mail-header-number header))
6463 (memq (mail-header-number header)
6464 gnus-newsgroup-limit))))
6466 ;; If the article is present in the buffer we just go to it.
6468 (or (not (gnus-summary-article-sparse-p
6469 (mail-header-number header)))
6472 (gnus-summary-goto-article
6473 (mail-header-number header) nil t)
6475 (gnus-summary-update-article (mail-header-number header)))))
6477 ;; We fetch the article
6478 (let ((gnus-override-method
6479 (cond ((gnus-news-group-p gnus-newsgroup-name)
6480 gnus-refer-article-method)
6482 (or gnus-refer-article-method gnus-select-method))
6485 ;; Start the special refer-article method, if necessary.
6486 (when (and gnus-refer-article-method
6487 (gnus-news-group-p gnus-newsgroup-name))
6488 (gnus-check-server gnus-refer-article-method))
6489 ;; Fetch the header, and display the article.
6490 (if (setq number (gnus-summary-insert-subject message-id))
6491 (gnus-summary-select-article nil nil nil number)
6492 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6494 (defun gnus-summary-edit-parameters ()
6495 "Edit the group parameters of the current group."
6497 (gnus-group-edit-group gnus-newsgroup-name 'params))
6499 (defun gnus-summary-enter-digest-group (&optional force)
6500 "Enter an nndoc group based on the current article.
6501 If FORCE, force a digest interpretation. If not, try
6502 to guess what the document format is."
6504 (let ((conf gnus-current-window-configuration))
6506 (gnus-summary-select-article))
6507 (setq gnus-current-window-configuration conf)
6508 (let* ((name (format "%s-%d"
6509 (gnus-group-prefixed-name
6510 gnus-newsgroup-name (list 'nndoc ""))
6512 (set-buffer gnus-summary-buffer)
6513 gnus-current-article)))
6514 (ogroup gnus-newsgroup-name)
6515 (params (append (gnus-info-params (gnus-get-info ogroup))
6516 (list (cons 'to-group ogroup))
6517 (list (cons 'save-article-group ogroup))))
6518 (case-fold-search t)
6519 (buf (current-buffer))
6522 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6523 (insert-buffer-substring gnus-original-article-buffer)
6524 ;; Remove lines that may lead nndoc to misinterpret the
6527 (goto-char (point-min))
6528 (or (search-forward "\n\n" nil t) (point)))
6529 (goto-char (point-min))
6530 (delete-matching-lines "^\\(Path\\):\\|^From ")
6533 (if (gnus-group-read-ephemeral-group
6534 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6536 ,(if force 'digest 'guess))) t)
6537 ;; Make all postings to this group go to the parent group.
6538 (nconc (gnus-info-params (gnus-get-info name))
6540 ;; Couldn't select this doc group.
6541 (switch-to-buffer buf)
6542 (gnus-set-global-variables)
6543 (gnus-configure-windows 'summary)
6544 (gnus-message 3 "Article couldn't be entered?"))
6545 (kill-buffer dig)))))
6547 (defun gnus-summary-read-document (n)
6548 "Open a new group based on the current article(s).
6549 This will allow you to read digests and other similar
6550 documents as newsgroups.
6551 Obeys the standard process/prefix convention."
6553 (let* ((articles (gnus-summary-work-articles n))
6554 (ogroup gnus-newsgroup-name)
6555 (params (append (gnus-info-params (gnus-get-info ogroup))
6556 (list (cons 'to-group ogroup))))
6557 article group egroup groups vgroup)
6558 (while (setq article (pop articles))
6559 (setq group (format "%s-%d" gnus-newsgroup-name article))
6560 (gnus-summary-remove-process-mark article)
6561 (when (gnus-summary-display-article article)
6564 (insert-buffer-substring gnus-original-article-buffer)
6565 ;; Remove some headers that may lead nndoc to make
6567 (message-narrow-to-head)
6568 (goto-char (point-min))
6569 (delete-matching-lines "^\\(Path\\):\\|^From ")
6572 (gnus-group-read-ephemeral-group
6573 group `(nndoc ,group (nndoc-address ,(current-buffer))
6574 (nndoc-article-type guess))
6577 ;; Make all postings to this group go to the parent group.
6578 (nconc (gnus-info-params (gnus-get-info egroup))
6580 (push egroup groups))
6581 ;; Couldn't select this doc group.
6582 (gnus-error 3 "Article couldn't be entered"))))))
6583 ;; Now we have selected all the documents.
6586 (error "None of the articles could be interpreted as documents"))
6587 ((gnus-group-read-ephemeral-group
6588 (setq vgroup (format
6589 "nnvirtual:%s-%s" gnus-newsgroup-name
6590 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6591 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6593 (cons (current-buffer) 'summary)))
6595 (error "Couldn't select virtual nndoc group")))))
6597 (defun gnus-summary-isearch-article (&optional regexp-p)
6598 "Do incremental search forward on the current article.
6599 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6601 (gnus-summary-select-article)
6602 (gnus-configure-windows 'article)
6603 (gnus-eval-in-buffer-window gnus-article-buffer
6606 (isearch-forward regexp-p))))
6608 (defun gnus-summary-search-article-forward (regexp &optional backward)
6609 "Search for an article containing REGEXP forward.
6610 If BACKWARD, search backward instead."
6613 (format "Search article %s (regexp%s): "
6614 (if current-prefix-arg "backward" "forward")
6615 (if gnus-last-search-regexp
6616 (concat ", default " gnus-last-search-regexp)
6618 current-prefix-arg))
6619 (if (string-equal regexp "")
6620 (setq regexp (or gnus-last-search-regexp ""))
6621 (setq gnus-last-search-regexp regexp))
6622 (if (gnus-summary-search-article regexp backward)
6623 (gnus-summary-show-thread)
6624 (error "Search failed: \"%s\"" regexp)))
6626 (defun gnus-summary-search-article-backward (regexp)
6627 "Search for an article containing REGEXP backward."
6630 (format "Search article backward (regexp%s): "
6631 (if gnus-last-search-regexp
6632 (concat ", default " gnus-last-search-regexp)
6634 (gnus-summary-search-article-forward regexp 'backward))
6636 (defun gnus-summary-search-article (regexp &optional backward)
6637 "Search for an article containing REGEXP.
6638 Optional argument BACKWARD means do search for backward.
6639 `gnus-select-article-hook' is not called during the search."
6640 ;; We have to require this here to make sure that the following
6641 ;; dynamic binding isn't shadowed by autoloading.
6642 (require 'gnus-async)
6643 (let ((gnus-select-article-hook nil) ;Disable hook.
6644 (gnus-article-display-hook nil)
6645 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6646 (gnus-use-article-prefetch nil)
6647 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6648 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6649 (sum (current-buffer))
6652 (gnus-save-hidden-threads
6653 (gnus-summary-select-article)
6654 (set-buffer gnus-article-buffer)
6658 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6660 (re-search-backward regexp nil t)
6661 (re-search-forward regexp nil t))
6662 ;; We found the regexp.
6667 (get-buffer-window (current-buffer))
6671 (setq point (point)))
6672 ;; We didn't find it, so we go to the next article.
6675 (while (eq found 'not)
6676 (if (not (if backward (gnus-summary-find-prev)
6677 (gnus-summary-find-next)))
6678 ;; No more articles.
6680 ;; Select the next article and adjust point.
6681 (unless (gnus-summary-article-sparse-p
6682 (gnus-summary-article-number))
6684 (gnus-summary-select-article)
6685 (set-buffer gnus-article-buffer)
6687 (goto-char (if backward (point-max) (point-min))))))))
6688 (gnus-message 7 ""))
6689 ;; Return whether we found the regexp.
6690 (when (eq found 'found)
6692 (gnus-summary-show-thread)
6693 (gnus-summary-goto-subject gnus-current-article)
6694 (gnus-summary-position-point)
6697 (defun gnus-summary-find-matching (header regexp &optional backward unread
6699 "Return a list of all articles that match REGEXP on HEADER.
6700 The search stars on the current article and goes forwards unless
6701 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6702 If UNREAD is non-nil, only unread articles will
6703 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6704 in the comparisons."
6705 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6706 (gnus-data-find-list
6707 (gnus-summary-article-number) (gnus-data-list backward))))
6708 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6709 (case-fold-search (not not-case-fold))
6711 (unless (fboundp (intern (concat "mail-header-" header)))
6712 (error "%s is not a valid header" header))
6715 (and (or (not unread) ; We want all articles...
6716 (gnus-data-unread-p d)) ; Or just unreads.
6717 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6718 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6719 (push (gnus-data-number d) articles)) ; Success!
6720 (setq data (cdr data)))
6721 (nreverse articles)))
6723 (defun gnus-summary-execute-command (header regexp command &optional backward)
6724 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6725 If HEADER is an empty string (or nil), the match is done on the entire
6726 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6728 (list (let ((completion-ignore-case t))
6731 (mapcar (lambda (string) (list string))
6732 '("Number" "Subject" "From" "Lines" "Date"
6733 "Message-ID" "Xref" "References" "Body"))
6734 nil 'require-match))
6735 (read-string "Regexp: ")
6736 (read-key-sequence "Command: ")
6737 current-prefix-arg))
6738 (when (equal header "Body")
6740 ;; Hidden thread subtrees must be searched as well.
6741 (gnus-summary-show-all-threads)
6742 ;; We don't want to change current point nor window configuration.
6744 (save-window-excursion
6745 (gnus-message 6 "Executing %s..." (key-description command))
6746 ;; We'd like to execute COMMAND interactively so as to give arguments.
6747 (gnus-execute header regexp
6748 `(call-interactively ',(key-binding command))
6750 (gnus-message 6 "Executing %s...done" (key-description command)))))
6752 (defun gnus-summary-beginning-of-article ()
6753 "Scroll the article back to the beginning."
6755 (gnus-summary-select-article)
6756 (gnus-configure-windows 'article)
6757 (gnus-eval-in-buffer-window gnus-article-buffer
6759 (goto-char (point-min))
6760 (when gnus-page-broken
6761 (gnus-narrow-to-page))))
6763 (defun gnus-summary-end-of-article ()
6764 "Scroll to the end of the article."
6766 (gnus-summary-select-article)
6767 (gnus-configure-windows 'article)
6768 (gnus-eval-in-buffer-window gnus-article-buffer
6770 (goto-char (point-max))
6772 (when gnus-page-broken
6773 (gnus-narrow-to-page))))
6775 (defun gnus-summary-print-article (&optional filename n)
6776 "Generate and print a PostScript image of the N next (mail) articles.
6778 If N is negative, print the N previous articles. If N is nil and articles
6779 have been marked with the process mark, print these instead.
6781 If the optional second argument FILENAME is nil, send the image to the
6782 printer. If FILENAME is a string, save the PostScript image in a file with
6783 that name. If FILENAME is a number, prompt the user for the name of the file
6785 (interactive (list (ps-print-preprint current-prefix-arg)
6786 current-prefix-arg))
6787 (dolist (article (gnus-summary-work-articles n))
6788 (gnus-summary-select-article nil nil 'pseudo article)
6789 (gnus-eval-in-buffer-window gnus-article-buffer
6790 (let ((buffer (generate-new-buffer " *print*")))
6793 (copy-to-buffer buffer (point-min) (point-max))
6795 (gnus-article-delete-invisible-text)
6796 (let ((ps-left-header
6799 (mail-header-subject gnus-current-headers) ")")
6801 (mail-header-from gnus-current-headers) ")")))
6804 "/pagenumberstring load"
6806 (mail-header-date gnus-current-headers) ")"))))
6807 (gnus-run-hooks 'gnus-ps-print-hook)
6809 (ps-print-buffer-with-faces filename))))
6810 (kill-buffer buffer))))))
6812 (defun gnus-summary-show-article (&optional arg)
6813 "Force re-fetching of the current article.
6814 If ARG (the prefix) is non-nil, show the raw article without any
6815 article massaging functions being run."
6818 ;; Select the article the normal way.
6819 (gnus-summary-select-article nil 'force)
6820 ;; Bind the article treatment functions to nil.
6821 (let ((gnus-have-all-headers t)
6822 gnus-article-display-hook
6823 gnus-article-prepare-hook
6824 gnus-article-decode-hook
6828 (gnus-summary-select-article nil 'force)))
6829 (gnus-summary-goto-subject gnus-current-article)
6830 (gnus-summary-position-point))
6832 (defun gnus-summary-verbose-headers (&optional arg)
6833 "Toggle permanent full header display.
6834 If ARG is a positive number, turn header display on.
6835 If ARG is a negative number, turn header display off."
6837 (setq gnus-show-all-headers
6838 (cond ((or (not (numberp arg))
6840 (not gnus-show-all-headers))
6843 (gnus-summary-show-article))
6845 (defun gnus-summary-toggle-header (&optional arg)
6846 "Show the headers if they are hidden, or hide them if they are shown.
6847 If ARG is a positive number, show the entire header.
6848 If ARG is a negative number, hide the unwanted header lines."
6851 (set-buffer gnus-article-buffer)
6852 (let* ((buffer-read-only nil)
6853 (inhibit-point-motion-hooks t)
6854 (hidden (text-property-any
6855 (goto-char (point-min)) (search-forward "\n\n")
6858 (goto-char (point-min))
6859 (when (search-forward "\n\n" nil t)
6860 (delete-region (point-min) (1- (point))))
6861 (goto-char (point-min))
6863 (set-buffer gnus-original-article-buffer)
6864 (goto-char (point-min))
6865 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6866 (insert-buffer-substring gnus-original-article-buffer 1 e)
6867 (let ((article-inhibit-hiding t))
6868 (gnus-run-hooks 'gnus-article-display-hook))
6869 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6870 (gnus-article-hide-headers)))))
6872 (defun gnus-summary-show-all-headers ()
6873 "Make all header lines visible."
6875 (gnus-article-show-all-headers))
6877 (defun gnus-summary-toggle-mime (&optional arg)
6878 "Toggle MIME processing.
6879 If ARG is a positive number, turn MIME processing on."
6881 (setq gnus-show-mime
6882 (if (null arg) (not gnus-show-mime)
6883 (> (prefix-numeric-value arg) 0)))
6884 (gnus-summary-select-article t 'force))
6886 (defun gnus-summary-caesar-message (&optional arg)
6887 "Caesar rotate the current article by 13.
6888 The numerical prefix specifies how many places to rotate each letter
6891 (gnus-summary-select-article)
6892 (let ((mail-header-separator ""))
6893 (gnus-eval-in-buffer-window gnus-article-buffer
6896 (let ((start (window-start))
6898 (message-caesar-buffer-body arg)
6899 (set-window-start (get-buffer-window (current-buffer)) start))))))
6901 (defun gnus-summary-stop-page-breaking ()
6902 "Stop page breaking in the current article."
6904 (gnus-summary-select-article)
6905 (gnus-eval-in-buffer-window gnus-article-buffer
6907 (when (gnus-visual-p 'page-marker)
6908 (let ((buffer-read-only nil))
6909 (gnus-remove-text-with-property 'gnus-prev)
6910 (gnus-remove-text-with-property 'gnus-next))
6911 (setq gnus-page-broken nil))))
6913 (defun gnus-summary-move-article (&optional n to-newsgroup
6914 select-method action)
6915 "Move the current article to a different newsgroup.
6916 If N is a positive number, move the N next articles.
6917 If N is a negative number, move the N previous articles.
6918 If N is nil and any articles have been marked with the process mark,
6919 move those articles instead.
6920 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6921 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6922 re-spool using this method.
6924 For this function to work, both the current newsgroup and the
6925 newsgroup that you want to move to have to support the `request-move'
6926 and `request-accept' functions."
6929 (setq action 'move))
6930 ;; Disable marking as read.
6931 (let (gnus-mark-article-hook)
6932 (save-window-excursion
6933 (gnus-summary-select-article)))
6934 ;; Check whether the source group supports the required functions.
6935 (cond ((and (eq action 'move)
6936 (not (gnus-check-backend-function
6937 'request-move-article gnus-newsgroup-name)))
6938 (error "The current group does not support article moving"))
6939 ((and (eq action 'crosspost)
6940 (not (gnus-check-backend-function
6941 'request-replace-article gnus-newsgroup-name)))
6942 (error "The current group does not support article editing")))
6943 (let ((articles (gnus-summary-work-articles n))
6944 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6945 (names '((move "Move" "Moving")
6946 (copy "Copy" "Copying")
6947 (crosspost "Crosspost" "Crossposting")))
6948 (copy-buf (save-excursion
6949 (nnheader-set-temp-buffer " *copy article*")))
6950 art-group to-method new-xref article to-groups)
6951 (unless (assq action names)
6952 (error "Unknown action %s" action))
6953 ;; Read the newsgroup name.
6954 (when (and (not to-newsgroup)
6955 (not select-method))
6957 (gnus-read-move-group-name
6958 (cadr (assq action names))
6959 (symbol-value (intern (format "gnus-current-%s-group" action)))
6961 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6962 (setq to-method (or select-method
6963 (gnus-group-name-to-method to-newsgroup)))
6964 ;; Check the method we are to move this article to...
6965 (unless (gnus-check-backend-function
6966 'request-accept-article (car to-method))
6967 (error "%s does not support article copying" (car to-method)))
6968 (unless (gnus-check-server to-method)
6969 (error "Can't open server %s" (car to-method)))
6970 (gnus-message 6 "%s to %s: %s..."
6971 (caddr (assq action names))
6972 (or (car select-method) to-newsgroup) articles)
6974 (setq article (pop articles))
6978 ;; Move the article.
6980 ;; Remove this article from future suppression.
6981 (gnus-dup-unsuppress-article article)
6982 (gnus-request-move-article
6983 article ; Article to move
6984 gnus-newsgroup-name ; From newsgroup
6985 (nth 1 (gnus-find-method-for-group
6986 gnus-newsgroup-name)) ; Server
6987 (list 'gnus-request-accept-article
6988 to-newsgroup (list 'quote select-method)
6989 (not articles)) ; Accept form
6990 (not articles))) ; Only save nov last time
6991 ;; Copy the article.
6994 (set-buffer copy-buf)
6995 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6996 (gnus-request-accept-article
6997 to-newsgroup select-method (not articles) t))))
6998 ;; Crosspost the article.
6999 ((eq action 'crosspost)
7000 (let ((xref (message-tokenize-header
7001 (mail-header-xref (gnus-summary-article-header article))
7003 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7006 (setq xref (list (system-name))))
7009 (mapconcat 'identity
7010 (delete "Xref:" (delete new-xref xref))
7014 (set-buffer copy-buf)
7015 ;; First put the article in the destination group.
7016 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7017 (when (consp (setq art-group
7018 (gnus-request-accept-article
7019 to-newsgroup select-method (not articles))))
7020 (setq new-xref (concat new-xref " " (car art-group)
7021 ":" (cdr art-group)))
7022 ;; Now we have the new Xrefs header, so we insert
7023 ;; it and replace the new article.
7024 (nnheader-replace-header "Xref" new-xref)
7025 (gnus-request-replace-article
7026 (cdr art-group) to-newsgroup (current-buffer))
7030 (gnus-message 1 "Couldn't %s article %s"
7031 (cadr (assq action names)) article))
7032 ((and (eq art-group 'junk)
7034 (gnus-summary-mark-article article gnus-canceled-mark)
7035 (gnus-message 4 "Deleted article %s" article))
7037 (let* ((pto-group (gnus-group-prefixed-name
7038 (car art-group) to-method))
7040 (gnus-gethash pto-group gnus-newsrc-hashtb))
7041 (info (nth 2 entry))
7042 (to-group (gnus-info-group info)))
7043 ;; Update the group that has been moved to.
7045 (memq action '(move copy)))
7046 (unless (member to-group to-groups)
7047 (push to-group to-groups))
7049 (unless (memq article gnus-newsgroup-unreads)
7051 info (gnus-add-to-range (gnus-info-read info)
7052 (list (cdr art-group)))))
7054 ;; Copy any marks over to the new group.
7055 (let ((marks gnus-article-mark-lists)
7056 (to-article (cdr art-group)))
7058 ;; See whether the article is to be put in the cache.
7059 (when gnus-use-cache
7060 (gnus-cache-possibly-enter-article
7062 (let ((header (copy-sequence
7063 (gnus-summary-article-header article))))
7064 (mail-header-set-number header to-article)
7066 (memq article gnus-newsgroup-marked)
7067 (memq article gnus-newsgroup-dormant)
7068 (memq article gnus-newsgroup-unreads)))
7070 (when (and (equal to-group gnus-newsgroup-name)
7071 (not (memq article gnus-newsgroup-unreads)))
7072 ;; Mark this article as read in this group.
7073 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7074 (setcdr (gnus-active to-group) to-article)
7075 (setcdr gnus-newsgroup-active to-article))
7078 (when (memq article (symbol-value
7079 (intern (format "gnus-newsgroup-%s"
7081 ;; If the other group is the same as this group,
7082 ;; then we have to add the mark to the list.
7083 (when (equal to-group gnus-newsgroup-name)
7084 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7087 (intern (format "gnus-newsgroup-%s"
7089 ;; Copy the marks to other group.
7090 (gnus-add-marked-articles
7091 to-group (cdar marks) (list to-article) info))
7092 (setq marks (cdr marks)))
7095 (concat "(gnus-group-set-info '"
7096 (gnus-prin1-to-string (gnus-get-info to-group))
7099 ;; Update the Xref header in this article to point to
7100 ;; the new crossposted article we have just created.
7101 (when (eq action 'crosspost)
7103 (set-buffer copy-buf)
7104 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7105 (nnheader-replace-header "Xref" new-xref)
7106 (gnus-request-replace-article
7107 article gnus-newsgroup-name (current-buffer)))))
7109 ;;;!!!Why is this necessary?
7110 (set-buffer gnus-summary-buffer)
7112 (gnus-summary-goto-subject article)
7113 (when (eq action 'move)
7114 (gnus-summary-mark-article article gnus-canceled-mark))))
7115 (gnus-summary-remove-process-mark article))
7116 ;; Re-activate all groups that have been moved to.
7119 (set-buffer gnus-group-buffer)
7120 (when (gnus-group-goto-group (car to-groups) t)
7121 (gnus-group-get-new-news-this-group 1 t))
7124 (gnus-kill-buffer copy-buf)
7125 (gnus-summary-position-point)
7126 (gnus-set-mode-line 'summary)))
7128 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7129 "Move the current article to a different newsgroup.
7130 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7131 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7132 re-spool using this method."
7134 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7136 (defun gnus-summary-crosspost-article (&optional n)
7137 "Crosspost the current article to some other group."
7139 (gnus-summary-move-article n nil nil 'crosspost))
7141 (defcustom gnus-summary-respool-default-method nil
7142 "Default method for respooling an article.
7143 If nil, use to the current newsgroup method."
7144 :type `(choice (gnus-select-method :value (nnml ""))
7146 :group 'gnus-summary-mail)
7148 (defun gnus-summary-respool-article (&optional n method)
7149 "Respool the current article.
7150 The article will be squeezed through the mail spooling process again,
7151 which means that it will be put in some mail newsgroup or other
7152 depending on `nnmail-split-methods'.
7153 If N is a positive number, respool the N next articles.
7154 If N is a negative number, respool the N previous articles.
7155 If N is nil and any articles have been marked with the process mark,
7156 respool those articles instead.
7158 Respooling can be done both from mail groups and \"real\" newsgroups.
7159 In the former case, the articles in question will be moved from the
7160 current group into whatever groups they are destined to. In the
7161 latter case, they will be copied into the relevant groups."
7163 (list current-prefix-arg
7164 (let* ((methods (gnus-methods-using 'respool))
7166 (symbol-name (or gnus-summary-respool-default-method
7167 (car (gnus-find-method-for-group
7168 gnus-newsgroup-name)))))
7170 (gnus-completing-read
7171 methname "What backend do you want to use when respooling?"
7172 methods nil t nil 'gnus-mail-method-history))
7175 ((zerop (length (setq ms (gnus-servers-using-backend
7177 (list (intern method) ""))
7181 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7182 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7185 (error "No method given for respooling"))
7186 (if (assoc (symbol-name
7187 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7188 (gnus-methods-using 'respool))
7189 (gnus-summary-move-article n nil method)
7190 (gnus-summary-copy-article n nil method)))
7192 (defun gnus-summary-import-article (file)
7193 "Import an arbitrary file into a mail newsgroup."
7194 (interactive "fImport file: ")
7195 (let ((group gnus-newsgroup-name)
7196 (now (current-time))
7198 (unless (gnus-check-backend-function 'request-accept-article group)
7199 (error "%s does not support article importing" group))
7200 (or (file-readable-p file)
7201 (not (file-regular-p file))
7202 (error "Can't read %s" file))
7204 (set-buffer (gnus-get-buffer-create " *import file*"))
7206 (nnheader-insert-file-contents file)
7207 (goto-char (point-min))
7208 (unless (nnheader-article-p)
7209 ;; This doesn't look like an article, so we fudge some headers.
7210 (setq atts (file-attributes file)
7211 lines (count-lines (point-min) (point-max)))
7212 (insert "From: " (read-string "From: ") "\n"
7213 "Subject: " (read-string "Subject: ") "\n"
7214 "Date: " (message-make-date (nth 5 atts))
7216 "Message-ID: " (message-make-message-id) "\n"
7217 "Lines: " (int-to-string lines) "\n"
7218 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7219 (gnus-request-accept-article group nil t)
7220 (kill-buffer (current-buffer)))))
7222 (defun gnus-summary-article-posted-p ()
7223 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7224 This will be the case if the article has both been mailed and posted."
7226 (let ((id (mail-header-references (gnus-summary-article-header)))
7227 (gnus-override-method
7228 (or gnus-refer-article-method gnus-select-method)))
7229 (if (gnus-request-head id "")
7230 (gnus-message 2 "The current message was found on %s"
7231 gnus-override-method)
7232 (gnus-message 2 "The current message couldn't be found on %s"
7233 gnus-override-method)
7236 (defun gnus-summary-expire-articles (&optional now)
7237 "Expire all articles that are marked as expirable in the current group."
7239 (when (gnus-check-backend-function
7240 'request-expire-articles gnus-newsgroup-name)
7241 ;; This backend supports expiry.
7242 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7243 (expirable (if total
7245 ;; We need to update the info for
7246 ;; this group for `gnus-list-of-read-articles'
7247 ;; to give us the right answer.
7248 (gnus-run-hooks 'gnus-exit-group-hook)
7249 (gnus-summary-update-info)
7250 (gnus-list-of-read-articles gnus-newsgroup-name))
7251 (setq gnus-newsgroup-expirable
7252 (sort gnus-newsgroup-expirable '<))))
7253 (expiry-wait (if now 'immediate
7254 (gnus-group-find-parameter
7255 gnus-newsgroup-name 'expiry-wait)))
7258 ;; There are expirable articles in this group, so we run them
7259 ;; through the expiry process.
7260 (gnus-message 6 "Expiring articles...")
7261 ;; The list of articles that weren't expired is returned.
7264 (let ((nnmail-expiry-wait-function nil)
7265 (nnmail-expiry-wait expiry-wait))
7266 (setq es (gnus-request-expire-articles
7267 expirable gnus-newsgroup-name)))
7268 (setq es (gnus-request-expire-articles
7269 expirable gnus-newsgroup-name))))
7271 (setq gnus-newsgroup-expirable es))
7272 ;; We go through the old list of expirable, and mark all
7273 ;; really expired articles as nonexistent.
7274 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7275 (let ((gnus-use-cache nil))
7277 (unless (memq (car expirable) es)
7278 (when (gnus-data-find (car expirable))
7279 (gnus-summary-mark-article
7280 (car expirable) gnus-canceled-mark)))
7281 (setq expirable (cdr expirable)))))
7282 (gnus-message 6 "Expiring articles...done")))))
7284 (defun gnus-summary-expire-articles-now ()
7285 "Expunge all expirable articles in the current group.
7286 This means that *all* articles that are marked as expirable will be
7287 deleted forever, right now."
7289 (or gnus-expert-user
7291 "Are you really, really, really sure you want to delete all these messages? ")
7293 (gnus-summary-expire-articles t))
7295 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7296 (defun gnus-summary-delete-article (&optional n)
7297 "Delete the N next (mail) articles.
7298 This command actually deletes articles. This is not a marking
7299 command. The article will disappear forever from your life, never to
7301 If N is negative, delete backwards.
7302 If N is nil and articles have been marked with the process mark,
7303 delete these instead."
7305 (unless (gnus-check-backend-function 'request-expire-articles
7306 gnus-newsgroup-name)
7307 (error "The current newsgroup does not support article deletion"))
7308 ;; Compute the list of articles to delete.
7309 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7311 (if (and gnus-novice-user
7312 (not (gnus-yes-or-no-p
7313 (format "Do you really want to delete %s forever? "
7314 (if (> (length articles) 1)
7315 (format "these %s articles" (length articles))
7318 ;; Delete the articles.
7319 (setq not-deleted (gnus-request-expire-articles
7320 articles gnus-newsgroup-name 'force))
7322 (gnus-summary-remove-process-mark (car articles))
7323 ;; The backend might not have been able to delete the article
7325 (unless (memq (car articles) not-deleted)
7326 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7327 (setq articles (cdr articles)))
7329 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7330 (gnus-summary-position-point)
7331 (gnus-set-mode-line 'summary)
7334 (defun gnus-summary-edit-article (&optional force)
7335 "Edit the current article.
7336 This will have permanent effect only in mail groups.
7337 If FORCE is non-nil, allow editing of articles even in read-only
7341 (set-buffer gnus-summary-buffer)
7342 (gnus-set-global-variables)
7343 (when (and (not force)
7344 (gnus-group-read-only-p))
7345 (error "The current newsgroup does not support article editing"))
7346 ;; Select article if needed.
7347 (unless (eq (gnus-summary-article-number)
7348 gnus-current-article)
7349 (gnus-summary-select-article t))
7350 (gnus-article-date-original)
7351 (gnus-article-edit-article
7352 `(lambda (no-highlight)
7353 (gnus-summary-edit-article-done
7354 ,(or (mail-header-references gnus-current-headers) "")
7355 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7357 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7359 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7361 "Make edits to the current article permanent."
7363 ;; Replace the article.
7364 (let ((buf (current-buffer)))
7367 (if (and (not read-only)
7368 (not (gnus-request-replace-article
7369 (cdr gnus-article-current) (car gnus-article-current)
7371 (error "Couldn't replace article")
7372 ;; Update the summary buffer.
7374 (equal (message-tokenize-header references " ")
7375 (message-tokenize-header
7376 (or (message-fetch-field "references") "") " ")))
7377 ;; We only have to update this line.
7380 (message-narrow-to-head)
7381 (let ((head (buffer-string))
7384 (insert (format "211 %d Article retrieved.\n"
7385 (cdr gnus-article-current)))
7388 (let ((nntp-server-buffer (current-buffer)))
7389 (setq header (car (gnus-get-newsgroup-headers
7391 (set-buffer gnus-summary-buffer)
7392 gnus-newsgroup-dependencies)
7395 (set-buffer gnus-summary-buffer)
7396 (gnus-data-set-header
7397 (gnus-data-find (cdr gnus-article-current))
7399 (gnus-summary-update-article-line
7400 (cdr gnus-article-current) header))))))
7402 (set-buffer (or buffer gnus-summary-buffer))
7403 (gnus-summary-update-article (cdr gnus-article-current)))
7404 ;; Prettify the article buffer again.
7405 (unless no-highlight
7407 (set-buffer gnus-article-buffer)
7408 (gnus-run-hooks 'gnus-article-display-hook)
7409 (set-buffer gnus-original-article-buffer)
7410 (gnus-request-article
7411 (cdr gnus-article-current)
7412 (car gnus-article-current) (current-buffer))))
7413 ;; Prettify the summary buffer line.
7414 (when (gnus-visual-p 'summary-highlight 'highlight)
7415 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7417 (defun gnus-summary-edit-wash (key)
7418 "Perform editing command KEY in the article buffer."
7422 (message "%s" (concat (this-command-keys) "- "))
7425 (gnus-summary-edit-article)
7426 (execute-kbd-macro (concat (this-command-keys) key))
7427 (gnus-article-edit-done))
7431 (defun gnus-summary-respool-query (&optional silent trace)
7432 "Query where the respool algorithm would put this article."
7434 (let (gnus-mark-article-hook)
7435 (gnus-summary-select-article)
7437 (set-buffer gnus-original-article-buffer)
7439 (message-narrow-to-head)
7440 (let ((groups (nnmail-article-group 'identity trace)))
7443 (message "This message would go to %s"
7444 (mapconcat 'car groups ", "))
7445 (message "This message would go to no groups"))
7448 (defun gnus-summary-respool-trace ()
7449 "Trace where the respool algorithm would put this article.
7450 Display a buffer showing all fancy splitting patterns which matched."
7452 (gnus-summary-respool-query nil t))
7454 ;; Summary marking commands.
7456 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7457 "Mark articles which has the same subject as read, and then select the next.
7458 If UNMARK is positive, remove any kind of mark.
7459 If UNMARK is negative, tick articles."
7462 (setq unmark (prefix-numeric-value unmark)))
7464 (gnus-summary-mark-same-subject
7465 (gnus-summary-article-subject) unmark)))
7466 ;; Select next unread article. If auto-select-same mode, should
7467 ;; select the first unread article.
7468 (gnus-summary-next-article t (and gnus-auto-select-same
7469 (gnus-summary-article-subject)))
7470 (gnus-message 7 "%d article%s marked as %s"
7471 count (if (= count 1) " is" "s are")
7472 (if unmark "unread" "read"))))
7474 (defun gnus-summary-kill-same-subject (&optional unmark)
7475 "Mark articles which has the same subject as read.
7476 If UNMARK is positive, remove any kind of mark.
7477 If UNMARK is negative, tick articles."
7480 (setq unmark (prefix-numeric-value unmark)))
7482 (gnus-summary-mark-same-subject
7483 (gnus-summary-article-subject) unmark)))
7484 ;; If marked as read, go to next unread subject.
7486 ;; Go to next unread subject.
7487 (gnus-summary-next-subject 1 t))
7488 (gnus-message 7 "%d articles are marked as %s"
7489 count (if unmark "unread" "read"))))
7491 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7492 "Mark articles with same SUBJECT as read, and return marked number.
7493 If optional argument UNMARK is positive, remove any kinds of marks.
7494 If optional argument UNMARK is negative, mark articles as unread instead."
7498 ((null unmark) ; Mark as read.
7501 (gnus-summary-mark-article-as-read gnus-killed-mark)
7502 (gnus-summary-show-thread) t)
7503 (gnus-summary-find-subject subject))
7504 (setq count (1+ count))))
7505 ((> unmark 0) ; Tick.
7508 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7509 (gnus-summary-show-thread) t)
7510 (gnus-summary-find-subject subject))
7511 (setq count (1+ count))))
7512 (t ; Mark as unread.
7515 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7516 (gnus-summary-show-thread) t)
7517 (gnus-summary-find-subject subject))
7518 (setq count (1+ count)))))
7519 (gnus-set-mode-line 'summary)
7520 ;; Return the number of marked articles.
7523 (defun gnus-summary-mark-as-processable (n &optional unmark)
7524 "Set the process mark on the next N articles.
7525 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7526 the process mark instead. The difference between N and the actual
7527 number of articles marked is returned."
7529 (let ((backward (< n 0))
7534 (gnus-summary-remove-process-mark
7535 (gnus-summary-article-number))
7536 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7537 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7540 (gnus-message 7 "No more articles"))
7541 (gnus-summary-recenter)
7542 (gnus-summary-position-point)
7545 (defun gnus-summary-unmark-as-processable (n)
7546 "Remove the process mark from the next N articles.
7547 If N is negative, unmark backward instead. The difference between N and
7548 the actual number of articles unmarked is returned."
7550 (gnus-summary-mark-as-processable n t))
7552 (defun gnus-summary-unmark-all-processable ()
7553 "Remove the process mark from all articles."
7556 (while gnus-newsgroup-processable
7557 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7558 (gnus-summary-position-point))
7560 (defun gnus-summary-mark-as-expirable (n)
7561 "Mark N articles forward as expirable.
7562 If N is negative, mark backward instead. The difference between N and
7563 the actual number of articles marked is returned."
7565 (gnus-summary-mark-forward n gnus-expirable-mark))
7567 (defun gnus-summary-mark-article-as-replied (article)
7568 "Mark ARTICLE replied and update the summary line."
7569 (push article gnus-newsgroup-replied)
7570 (let ((buffer-read-only nil))
7571 (when (gnus-summary-goto-subject article)
7572 (gnus-summary-update-secondary-mark article))))
7574 (defun gnus-summary-set-bookmark (article)
7575 "Set a bookmark in current article."
7576 (interactive (list (gnus-summary-article-number)))
7577 (when (or (not (get-buffer gnus-article-buffer))
7578 (not gnus-current-article)
7579 (not gnus-article-current)
7580 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7581 (error "No current article selected"))
7582 ;; Remove old bookmark, if one exists.
7583 (let ((old (assq article gnus-newsgroup-bookmarks)))
7585 (setq gnus-newsgroup-bookmarks
7586 (delq old gnus-newsgroup-bookmarks))))
7587 ;; Set the new bookmark, which is on the form
7588 ;; (article-number . line-number-in-body).
7592 (set-buffer gnus-article-buffer)
7596 (goto-char (point-min))
7597 (search-forward "\n\n" nil t)
7600 gnus-newsgroup-bookmarks)
7601 (gnus-message 6 "A bookmark has been added to the current article."))
7603 (defun gnus-summary-remove-bookmark (article)
7604 "Remove the bookmark from the current article."
7605 (interactive (list (gnus-summary-article-number)))
7606 ;; Remove old bookmark, if one exists.
7607 (let ((old (assq article gnus-newsgroup-bookmarks)))
7610 (setq gnus-newsgroup-bookmarks
7611 (delq old gnus-newsgroup-bookmarks))
7612 (gnus-message 6 "Removed bookmark."))
7613 (gnus-message 6 "No bookmark in current article."))))
7615 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7616 (defun gnus-summary-mark-as-dormant (n)
7617 "Mark N articles forward as dormant.
7618 If N is negative, mark backward instead. The difference between N and
7619 the actual number of articles marked is returned."
7621 (gnus-summary-mark-forward n gnus-dormant-mark))
7623 (defun gnus-summary-set-process-mark (article)
7624 "Set the process mark on ARTICLE and update the summary line."
7625 (setq gnus-newsgroup-processable
7627 (delq article gnus-newsgroup-processable)))
7628 (when (gnus-summary-goto-subject article)
7629 (gnus-summary-show-thread)
7630 (gnus-summary-goto-subject article)
7631 (gnus-summary-update-secondary-mark article)))
7633 (defun gnus-summary-remove-process-mark (article)
7634 "Remove the process mark from ARTICLE and update the summary line."
7635 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7636 (when (gnus-summary-goto-subject article)
7637 (gnus-summary-show-thread)
7638 (gnus-summary-goto-subject article)
7639 (gnus-summary-update-secondary-mark article)))
7641 (defun gnus-summary-set-saved-mark (article)
7642 "Set the process mark on ARTICLE and update the summary line."
7643 (push article gnus-newsgroup-saved)
7644 (when (gnus-summary-goto-subject article)
7645 (gnus-summary-update-secondary-mark article)))
7647 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7648 "Mark N articles as read forwards.
7649 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7650 The difference between N and the actual number of articles marked is
7653 (let ((backward (< n 0))
7654 (gnus-summary-goto-unread
7655 (and gnus-summary-goto-unread
7656 (not (eq gnus-summary-goto-unread 'never))
7657 (not (memq mark (list gnus-unread-mark
7658 gnus-ticked-mark gnus-dormant-mark)))))
7660 (mark (or mark gnus-del-mark)))
7662 (gnus-summary-mark-article nil mark no-expire)
7663 (zerop (gnus-summary-next-subject
7665 (and gnus-summary-goto-unread
7666 (not (eq gnus-summary-goto-unread 'never)))
7670 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7671 (gnus-summary-recenter)
7672 (gnus-summary-position-point)
7673 (gnus-set-mode-line 'summary)
7676 (defun gnus-summary-mark-article-as-read (mark)
7677 "Mark the current article quickly as read with MARK."
7678 (let ((article (gnus-summary-article-number)))
7679 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7680 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7681 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7682 (push (cons article mark) gnus-newsgroup-reads)
7683 ;; Possibly remove from cache, if that is used.
7684 (when gnus-use-cache
7685 (gnus-cache-enter-remove-article article))
7686 ;; Allow the backend to change the mark.
7687 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7688 ;; Check for auto-expiry.
7689 (when (and gnus-newsgroup-auto-expire
7690 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7691 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7692 (= mark gnus-ancient-mark)
7693 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7694 (= mark gnus-duplicate-mark)))
7695 (setq mark gnus-expirable-mark)
7696 ;; Let the backend know about the mark change.
7697 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7698 (push article gnus-newsgroup-expirable))
7699 ;; Set the mark in the buffer.
7700 (gnus-summary-update-mark mark 'unread)
7703 (defun gnus-summary-mark-article-as-unread (mark)
7704 "Mark the current article quickly as unread with MARK."
7705 (let* ((article (gnus-summary-article-number))
7706 (old-mark (gnus-summary-article-mark article)))
7707 ;; Allow the backend to change the mark.
7708 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7709 (if (eq mark old-mark)
7713 (gnus-error 1 "Can't mark negative article numbers")
7715 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7716 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7717 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7718 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7719 (cond ((= mark gnus-ticked-mark)
7720 (push article gnus-newsgroup-marked))
7721 ((= mark gnus-dormant-mark)
7722 (push article gnus-newsgroup-dormant))
7724 (push article gnus-newsgroup-unreads)))
7725 (gnus-pull article gnus-newsgroup-reads)
7727 ;; See whether the article is to be put in the cache.
7729 (vectorp (gnus-summary-article-header article))
7731 (gnus-cache-possibly-enter-article
7732 gnus-newsgroup-name article
7733 (gnus-summary-article-header article)
7734 (= mark gnus-ticked-mark)
7735 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7738 (gnus-summary-update-mark mark 'unread)
7741 (defun gnus-summary-mark-article (&optional article mark no-expire)
7742 "Mark ARTICLE with MARK. MARK can be any character.
7743 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7744 `??' (dormant) and `?E' (expirable).
7745 If MARK is nil, then the default character `?D' is used.
7746 If ARTICLE is nil, then the article on the current line will be
7748 ;; The mark might be a string.
7749 (when (stringp mark)
7750 (setq mark (aref mark 0)))
7751 ;; If no mark is given, then we check auto-expiring.
7752 (and (not no-expire)
7753 gnus-newsgroup-auto-expire
7755 (and (gnus-characterp mark)
7756 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7757 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7758 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7759 (= mark gnus-duplicate-mark))))
7760 (setq mark gnus-expirable-mark))
7761 (let* ((mark (or mark gnus-del-mark))
7762 (article (or article (gnus-summary-article-number)))
7763 (old-mark (gnus-summary-article-mark article)))
7764 ;; Allow the backend to change the mark.
7765 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7766 (if (eq mark old-mark)
7769 (error "No article on current line"))
7770 (if (not (if (or (= mark gnus-unread-mark)
7771 (= mark gnus-ticked-mark)
7772 (= mark gnus-dormant-mark))
7773 (gnus-mark-article-as-unread article mark)
7774 (gnus-mark-article-as-read article mark)))
7776 ;; See whether the article is to be put in the cache.
7778 (not (= mark gnus-canceled-mark))
7779 (vectorp (gnus-summary-article-header article))
7781 (gnus-cache-possibly-enter-article
7782 gnus-newsgroup-name article
7783 (gnus-summary-article-header article)
7784 (= mark gnus-ticked-mark)
7785 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7787 (when (gnus-summary-goto-subject article nil t)
7788 (let ((buffer-read-only nil))
7789 (gnus-summary-show-thread)
7791 (gnus-summary-update-mark mark 'unread)
7794 (defun gnus-summary-update-secondary-mark (article)
7795 "Update the secondary (read, process, cache) mark."
7796 (gnus-summary-update-mark
7797 (cond ((memq article gnus-newsgroup-processable)
7799 ((memq article gnus-newsgroup-cached)
7801 ((memq article gnus-newsgroup-replied)
7803 ((memq article gnus-newsgroup-saved)
7805 (t gnus-unread-mark))
7807 (when (gnus-visual-p 'summary-highlight 'highlight)
7808 (gnus-run-hooks 'gnus-summary-update-hook))
7811 (defun gnus-summary-update-mark (mark type)
7812 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7813 (buffer-read-only nil))
7814 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7815 (when (looking-at "\r")
7818 (<= (+ forward (point)) (point-max)))
7819 ;; Go to the right position on the line.
7820 (goto-char (+ forward (point)))
7821 ;; Replace the old mark with the new mark.
7822 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7823 ;; Optionally update the marks by some user rule.
7824 (when (eq type 'unread)
7826 (gnus-data-find (gnus-summary-article-number)) mark)
7827 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7829 (defun gnus-mark-article-as-read (article &optional mark)
7830 "Enter ARTICLE in the pertinent lists and remove it from others."
7831 ;; Make the article expirable.
7832 (let ((mark (or mark gnus-del-mark)))
7833 (if (= mark gnus-expirable-mark)
7834 (push article gnus-newsgroup-expirable)
7835 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7836 ;; Remove from unread and marked lists.
7837 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7838 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7839 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7840 (push (cons article mark) gnus-newsgroup-reads)
7841 ;; Possibly remove from cache, if that is used.
7842 (when gnus-use-cache
7843 (gnus-cache-enter-remove-article article))
7846 (defun gnus-mark-article-as-unread (article &optional mark)
7847 "Enter ARTICLE in the pertinent lists and remove it from others."
7848 (let ((mark (or mark gnus-ticked-mark)))
7851 (gnus-error 1 "Can't mark negative article numbers")
7853 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7854 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7855 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7856 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7858 ;; Unsuppress duplicates?
7859 (when gnus-suppress-duplicates
7860 (gnus-dup-unsuppress-article article))
7862 (cond ((= mark gnus-ticked-mark)
7863 (push article gnus-newsgroup-marked))
7864 ((= mark gnus-dormant-mark)
7865 (push article gnus-newsgroup-dormant))
7867 (push article gnus-newsgroup-unreads)))
7868 (gnus-pull article gnus-newsgroup-reads)
7871 (defalias 'gnus-summary-mark-as-unread-forward
7872 'gnus-summary-tick-article-forward)
7873 (make-obsolete 'gnus-summary-mark-as-unread-forward
7874 'gnus-summary-tick-article-forward)
7875 (defun gnus-summary-tick-article-forward (n)
7876 "Tick N articles forwards.
7877 If N is negative, tick backwards instead.
7878 The difference between N and the number of articles ticked is returned."
7880 (gnus-summary-mark-forward n gnus-ticked-mark))
7882 (defalias 'gnus-summary-mark-as-unread-backward
7883 'gnus-summary-tick-article-backward)
7884 (make-obsolete 'gnus-summary-mark-as-unread-backward
7885 'gnus-summary-tick-article-backward)
7886 (defun gnus-summary-tick-article-backward (n)
7887 "Tick N articles backwards.
7888 The difference between N and the number of articles ticked is returned."
7890 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7892 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7893 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7894 (defun gnus-summary-tick-article (&optional article clear-mark)
7895 "Mark current article as unread.
7896 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7897 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7899 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7902 (defun gnus-summary-mark-as-read-forward (n)
7903 "Mark N articles as read forwards.
7904 If N is negative, mark backwards instead.
7905 The difference between N and the actual number of articles marked is
7908 (gnus-summary-mark-forward n gnus-del-mark t))
7910 (defun gnus-summary-mark-as-read-backward (n)
7911 "Mark the N articles as read backwards.
7912 The difference between N and the actual number of articles marked is
7915 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7917 (defun gnus-summary-mark-as-read (&optional article mark)
7918 "Mark current article as read.
7919 ARTICLE specifies the article to be marked as read.
7920 MARK specifies a string to be inserted at the beginning of the line."
7921 (gnus-summary-mark-article article mark))
7923 (defun gnus-summary-clear-mark-forward (n)
7924 "Clear marks from N articles forward.
7925 If N is negative, clear backward instead.
7926 The difference between N and the number of marks cleared is returned."
7928 (gnus-summary-mark-forward n gnus-unread-mark))
7930 (defun gnus-summary-clear-mark-backward (n)
7931 "Clear marks from N articles backward.
7932 The difference between N and the number of marks cleared is returned."
7934 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7936 (defun gnus-summary-mark-unread-as-read ()
7937 "Intended to be used by `gnus-summary-mark-article-hook'."
7938 (when (memq gnus-current-article gnus-newsgroup-unreads)
7939 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7941 (defun gnus-summary-mark-read-and-unread-as-read ()
7942 "Intended to be used by `gnus-summary-mark-article-hook'."
7943 (let ((mark (gnus-summary-article-mark)))
7944 (when (or (gnus-unread-mark-p mark)
7945 (gnus-read-mark-p mark))
7946 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7948 (defun gnus-summary-mark-region-as-read (point mark all)
7949 "Mark all unread articles between point and mark as read.
7950 If given a prefix, mark all articles between point and mark as read,
7951 even ticked and dormant ones."
7952 (interactive "r\nP")
7961 (memq (setq article (gnus-summary-article-number))
7962 gnus-newsgroup-unreads))
7963 (gnus-summary-mark-article article gnus-del-mark))
7965 (gnus-summary-find-next))))))
7967 (defun gnus-summary-mark-below (score mark)
7968 "Mark articles with score less than SCORE with MARK."
7969 (interactive "P\ncMark: ")
7970 (setq score (if score
7971 (prefix-numeric-value score)
7972 (or gnus-summary-default-score 0)))
7974 (set-buffer gnus-summary-buffer)
7975 (goto-char (point-min))
7978 (and (< (gnus-summary-article-score) score)
7979 (gnus-summary-mark-article nil mark))
7980 (gnus-summary-find-next)))))
7982 (defun gnus-summary-kill-below (&optional score)
7983 "Mark articles with score below SCORE as read."
7985 (gnus-summary-mark-below score gnus-killed-mark))
7987 (defun gnus-summary-clear-above (&optional score)
7988 "Clear all marks from articles with score above SCORE."
7990 (gnus-summary-mark-above score gnus-unread-mark))
7992 (defun gnus-summary-tick-above (&optional score)
7993 "Tick all articles with score above SCORE."
7995 (gnus-summary-mark-above score gnus-ticked-mark))
7997 (defun gnus-summary-mark-above (score mark)
7998 "Mark articles with score over SCORE with MARK."
7999 (interactive "P\ncMark: ")
8000 (setq score (if score
8001 (prefix-numeric-value score)
8002 (or gnus-summary-default-score 0)))
8004 (set-buffer gnus-summary-buffer)
8005 (goto-char (point-min))
8007 (when (> (gnus-summary-article-score) score)
8008 (gnus-summary-mark-article nil mark))
8010 (gnus-summary-find-next)))))
8012 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8013 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8014 (defun gnus-summary-limit-include-expunged (&optional no-error)
8015 "Display all the hidden articles that were expunged for low scores."
8017 (let ((buffer-read-only nil))
8018 (let ((scored gnus-newsgroup-scored)
8021 (unless (gnus-summary-goto-subject (caar scored))
8022 (and (setq h (gnus-summary-article-header (caar scored)))
8023 (< (cdar scored) gnus-summary-expunge-below)
8025 (setq scored (cdr scored)))
8027 (when (not no-error)
8028 (error "No expunged articles hidden"))
8029 (goto-char (point-min))
8030 (gnus-summary-prepare-unthreaded (nreverse headers))
8031 (goto-char (point-min))
8032 (gnus-summary-position-point)
8035 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8036 "Mark all unread articles in this newsgroup as read.
8037 If prefix argument ALL is non-nil, ticked and dormant articles will
8038 also be marked as read.
8039 If QUIETLY is non-nil, no questions will be asked.
8040 If TO-HERE is non-nil, it should be a point in the buffer. All
8041 articles before this point will be marked as read.
8042 Note that this function will only catch up the unread article
8043 in the current summary buffer limitation.
8044 The number of articles marked as read is returned."
8049 (not gnus-interactive-catchup) ;Without confirmation?
8053 "Mark absolutely all articles as read? "
8054 "Mark all unread articles as read? ")))
8056 (not gnus-newsgroup-adaptive)
8057 (not gnus-newsgroup-auto-expire)
8058 (not gnus-suppress-duplicates)
8059 (or (not gnus-use-cache)
8060 (eq gnus-use-cache 'passive)))
8063 (setq gnus-newsgroup-marked nil
8064 gnus-newsgroup-dormant nil))
8065 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8066 ;; We actually mark all articles as canceled, which we
8067 ;; have to do when using auto-expiry or adaptive scoring.
8068 (gnus-summary-show-all-threads)
8069 (when (gnus-summary-first-subject (not all) t)
8071 (if to-here (< (point) to-here) t)
8072 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8073 (gnus-summary-find-next (not all) nil nil t))))
8074 (gnus-set-mode-line 'summary))
8076 (gnus-summary-position-point)))
8078 (defun gnus-summary-catchup-to-here (&optional all)
8079 "Mark all unticked articles before the current one as read.
8080 If ALL is non-nil, also mark ticked and dormant articles as read."
8083 (gnus-save-hidden-threads
8084 (let ((beg (point)))
8085 ;; We check that there are unread articles.
8086 (when (or all (gnus-summary-find-prev))
8087 (gnus-summary-catchup all t beg)))))
8088 (gnus-summary-position-point))
8090 (defun gnus-summary-catchup-all (&optional quietly)
8091 "Mark all articles in this newsgroup as read."
8093 (gnus-summary-catchup t quietly))
8095 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8096 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8097 If prefix argument ALL is non-nil, all articles are marked as read."
8099 (when (gnus-summary-catchup all quietly nil 'fast)
8100 ;; Select next newsgroup or exit.
8101 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8102 (eq gnus-auto-select-next 'quietly))
8103 (gnus-summary-next-group nil)
8104 (gnus-summary-exit))))
8106 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8107 "Mark all articles in this newsgroup as read, and then exit."
8109 (gnus-summary-catchup-and-exit t quietly))
8111 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8112 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8113 "Mark all articles in this group as read and select the next group.
8114 If given a prefix, mark all articles, unread as well as ticked, as
8118 (gnus-summary-catchup all))
8119 (gnus-summary-next-article t nil nil t))
8121 ;; Thread-based commands.
8123 (defun gnus-summary-articles-in-thread (&optional article)
8124 "Return a list of all articles in the current thread.
8125 If ARTICLE is non-nil, return all articles in the thread that starts
8127 (let* ((article (or article (gnus-summary-article-number)))
8128 (data (gnus-data-find-list article))
8129 (top-level (gnus-data-level (car data)))
8131 (cond ((null gnus-thread-operation-ignore-subject)
8132 (gnus-simplify-subject-re
8133 (mail-header-subject (gnus-data-header (car data)))))
8134 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8135 (gnus-simplify-subject-fuzzy
8136 (mail-header-subject (gnus-data-header (car data)))))
8138 (end-point (save-excursion
8139 (if (gnus-summary-go-to-next-thread)
8140 (point) (point-max))))
8143 (< (gnus-data-pos (car data)) end-point))
8144 (when (or (not top-subject)
8145 (string= top-subject
8146 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8147 (gnus-simplify-subject-fuzzy
8148 (mail-header-subject
8149 (gnus-data-header (car data))))
8150 (gnus-simplify-subject-re
8151 (mail-header-subject
8152 (gnus-data-header (car data)))))))
8153 (push (gnus-data-number (car data)) articles))
8154 (unless (and (setq data (cdr data))
8155 (> (gnus-data-level (car data)) top-level))
8157 ;; Return the list of articles.
8158 (nreverse articles)))
8160 (defun gnus-summary-rethread-current ()
8161 "Rethread the thread the current article is part of."
8163 (let* ((gnus-show-threads t)
8164 (article (gnus-summary-article-number))
8165 (id (mail-header-id (gnus-summary-article-header)))
8166 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8168 (error "No article on the current line"))
8169 (gnus-rebuild-thread id)
8170 (gnus-summary-goto-subject article)))
8172 (defun gnus-summary-reparent-thread ()
8173 "Make the current article child of the marked (or previous) article.
8175 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8176 is non-nil or the Subject: of both articles are the same."
8178 (unless (not (gnus-group-read-only-p))
8179 (error "The current newsgroup does not support article editing"))
8180 (unless (<= (length gnus-newsgroup-processable) 1)
8181 (error "No more than one article may be marked"))
8182 (save-window-excursion
8183 (let ((gnus-article-buffer " *reparent*")
8184 (current-article (gnus-summary-article-number))
8185 ;; First grab the marked article, otherwise one line up.
8186 (parent-article (if (not (null gnus-newsgroup-processable))
8187 (car gnus-newsgroup-processable)
8189 (if (eq (forward-line -1) 0)
8190 (gnus-summary-article-number)
8191 (error "Beginning of summary buffer"))))))
8192 (unless (not (eq current-article parent-article))
8193 (error "An article may not be self-referential"))
8194 (let ((message-id (mail-header-id
8195 (gnus-summary-article-header parent-article))))
8196 (unless (and message-id (not (equal message-id "")))
8197 (error "No message-id in desired parent"))
8198 ;; We don't want the article to be marked as read.
8199 (let (gnus-mark-article-hook)
8200 (gnus-summary-select-article t t nil current-article))
8201 (set-buffer gnus-original-article-buffer)
8202 (let ((buf (format "%s" (buffer-string))))
8205 (goto-char (point-min))
8206 (if (re-search-forward "^References: " nil t)
8208 (re-search-forward "^[^ \t]" nil t)
8211 (insert " " message-id))
8212 (insert "References: " message-id "\n"))
8213 (unless (gnus-request-replace-article
8214 current-article (car gnus-article-current)
8216 (error "Couldn't replace article"))))
8217 (set-buffer gnus-summary-buffer)
8218 (gnus-summary-unmark-all-processable)
8219 (gnus-summary-update-article current-article)
8220 (gnus-summary-rethread-current)
8221 (gnus-message 3 "Article %d is now the child of article %d"
8222 current-article parent-article)))))
8224 (defun gnus-summary-toggle-threads (&optional arg)
8225 "Toggle showing conversation threads.
8226 If ARG is positive number, turn showing conversation threads on."
8228 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8229 (setq gnus-show-threads
8230 (if (null arg) (not gnus-show-threads)
8231 (> (prefix-numeric-value arg) 0)))
8232 (gnus-summary-prepare)
8233 (gnus-summary-goto-subject current)
8234 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8235 (gnus-summary-position-point)))
8237 (defun gnus-summary-show-all-threads ()
8241 (let ((buffer-read-only nil))
8242 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8243 (gnus-summary-position-point))
8245 (defun gnus-summary-show-thread ()
8246 "Show thread subtrees.
8247 Returns nil if no thread was there to be shown."
8249 (let ((buffer-read-only nil)
8251 ;; first goto end then to beg, to have point at beg after let
8252 (end (progn (end-of-line) (point)))
8253 (beg (progn (beginning-of-line) (point))))
8255 ;; Any hidden lines here?
8256 (search-forward "\r" end t)
8257 (subst-char-in-region beg end ?\^M ?\n t)
8259 (gnus-summary-position-point))))
8261 (defun gnus-summary-hide-all-threads ()
8262 "Hide all thread subtrees."
8265 (goto-char (point-min))
8266 (gnus-summary-hide-thread)
8267 (while (zerop (gnus-summary-next-thread 1 t))
8268 (gnus-summary-hide-thread)))
8269 (gnus-summary-position-point))
8271 (defun gnus-summary-hide-thread ()
8272 "Hide thread subtrees.
8273 Returns nil if no threads were there to be hidden."
8275 (let ((buffer-read-only nil)
8277 (article (gnus-summary-article-number)))
8279 ;; Go forward until either the buffer ends or the subthread
8281 (when (and (not (eobp))
8282 (or (zerop (gnus-summary-next-thread 1 t))
8283 (goto-char (point-max))))
8285 (if (and (> (point) start)
8286 (search-backward "\n" start t))
8288 (subst-char-in-region start (point) ?\n ?\^M)
8289 (gnus-summary-goto-subject article))
8292 ;;(gnus-summary-position-point)
8295 (defun gnus-summary-go-to-next-thread (&optional previous)
8296 "Go to the same level (or less) next thread.
8297 If PREVIOUS is non-nil, go to previous thread instead.
8298 Return the article number moved to, or nil if moving was impossible."
8299 (let ((level (gnus-summary-thread-level))
8300 (way (if previous -1 1))
8303 (while (and (not (eobp))
8304 (< level (gnus-summary-thread-level)))
8312 (gnus-summary-article-number)
8315 (defun gnus-summary-next-thread (n &optional silent)
8316 "Go to the same level next N'th thread.
8317 If N is negative, search backward instead.
8318 Returns the difference between N and the number of skips actually
8321 If SILENT, don't output messages."
8323 (let ((backward (< n 0))
8326 (gnus-summary-go-to-next-thread backward))
8329 (gnus-summary-position-point))
8330 (when (and (not silent) (/= 0 n))
8331 (gnus-message 7 "No more threads"))
8334 (defun gnus-summary-prev-thread (n)
8335 "Go to the same level previous N'th thread.
8336 Returns the difference between N and the number of skips actually
8339 (gnus-summary-next-thread (- n)))
8341 (defun gnus-summary-go-down-thread ()
8342 "Go down one level in the current thread."
8343 (let ((children (gnus-summary-article-children)))
8345 (gnus-summary-goto-subject (car children)))))
8347 (defun gnus-summary-go-up-thread ()
8348 "Go up one level in the current thread."
8349 (let ((parent (gnus-summary-article-parent)))
8351 (gnus-summary-goto-subject parent))))
8353 (defun gnus-summary-down-thread (n)
8354 "Go down thread N steps.
8355 If N is negative, go up instead.
8356 Returns the difference between N and how many steps down that were
8362 (if up (gnus-summary-go-up-thread)
8363 (gnus-summary-go-down-thread)))
8365 (gnus-summary-position-point)
8367 (gnus-message 7 "Can't go further"))
8370 (defun gnus-summary-up-thread (n)
8371 "Go up thread N steps.
8372 If N is negative, go up instead.
8373 Returns the difference between N and how many steps down that were
8376 (gnus-summary-down-thread (- n)))
8378 (defun gnus-summary-top-thread ()
8379 "Go to the top of the thread."
8381 (while (gnus-summary-go-up-thread))
8382 (gnus-summary-article-number))
8384 (defun gnus-summary-kill-thread (&optional unmark)
8385 "Mark articles under current thread as read.
8386 If the prefix argument is positive, remove any kinds of marks.
8387 If the prefix argument is negative, tick articles instead."
8390 (setq unmark (prefix-numeric-value unmark)))
8391 (let ((articles (gnus-summary-articles-in-thread)))
8393 ;; Expand the thread.
8394 (gnus-summary-show-thread)
8395 ;; Mark all the articles.
8397 (gnus-summary-goto-subject (car articles))
8398 (cond ((null unmark)
8399 (gnus-summary-mark-article-as-read gnus-killed-mark))
8401 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8403 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8404 (setq articles (cdr articles))))
8405 ;; Hide killed subtrees.
8407 gnus-thread-hide-killed
8408 (gnus-summary-hide-thread))
8409 ;; If marked as read, go to next unread subject.
8411 ;; Go to next unread subject.
8412 (gnus-summary-next-subject 1 t)))
8413 (gnus-set-mode-line 'summary))
8415 ;; Summary sorting commands
8417 (defun gnus-summary-sort-by-number (&optional reverse)
8418 "Sort the summary buffer by article number.
8419 Argument REVERSE means reverse order."
8421 (gnus-summary-sort 'number reverse))
8423 (defun gnus-summary-sort-by-author (&optional reverse)
8424 "Sort the summary buffer by author name alphabetically.
8425 If case-fold-search is non-nil, case of letters is ignored.
8426 Argument REVERSE means reverse order."
8428 (gnus-summary-sort 'author reverse))
8430 (defun gnus-summary-sort-by-subject (&optional reverse)
8431 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8432 If case-fold-search is non-nil, case of letters is ignored.
8433 Argument REVERSE means reverse order."
8435 (gnus-summary-sort 'subject reverse))
8437 (defun gnus-summary-sort-by-date (&optional reverse)
8438 "Sort the summary buffer by date.
8439 Argument REVERSE means reverse order."
8441 (gnus-summary-sort 'date reverse))
8443 (defun gnus-summary-sort-by-score (&optional reverse)
8444 "Sort the summary buffer by score.
8445 Argument REVERSE means reverse order."
8447 (gnus-summary-sort 'score reverse))
8449 (defun gnus-summary-sort-by-lines (&optional reverse)
8450 "Sort the summary buffer by article length.
8451 Argument REVERSE means reverse order."
8453 (gnus-summary-sort 'lines reverse))
8455 (defun gnus-summary-sort (predicate reverse)
8456 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8457 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8458 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8459 (gnus-thread-sort-functions
8465 (gnus-article-sort-functions
8470 (,article t2 t1)))))
8472 (gnus-summary-prepare-hook nil))
8473 ;; We do the sorting by regenerating the threads.
8474 (gnus-summary-prepare)
8475 ;; Hide subthreads if needed.
8476 (when (and gnus-show-threads gnus-thread-hide-subtree)
8477 (gnus-summary-hide-all-threads))))
8479 ;; Summary saving commands.
8481 (defun gnus-summary-save-article (&optional n not-saved)
8482 "Save the current article using the default saver function.
8483 If N is a positive number, save the N next articles.
8484 If N is a negative number, save the N previous articles.
8485 If N is nil and any articles have been marked with the process mark,
8486 save those articles instead.
8487 The variable `gnus-default-article-saver' specifies the saver function."
8489 (let* ((articles (gnus-summary-work-articles n))
8490 (save-buffer (save-excursion
8491 (nnheader-set-temp-buffer " *Gnus Save*")))
8492 (num (length articles))
8493 header article file)
8495 (setq header (gnus-summary-article-header
8496 (setq article (pop articles))))
8497 (if (not (vectorp header))
8498 ;; This is a pseudo-article.
8499 (if (assq 'name header)
8500 (gnus-copy-file (cdr (assq 'name header)))
8501 (gnus-message 1 "Article %d is unsaveable" article))
8502 ;; This is a real article.
8503 (save-window-excursion
8504 (gnus-summary-select-article t nil nil article))
8506 (set-buffer save-buffer)
8508 (insert-buffer-substring gnus-original-article-buffer))
8509 (setq file (gnus-article-save save-buffer file num))
8510 (gnus-summary-remove-process-mark article)
8512 (gnus-summary-set-saved-mark article))))
8513 (gnus-kill-buffer save-buffer)
8514 (gnus-summary-position-point)
8515 (gnus-set-mode-line 'summary)
8518 (defun gnus-summary-pipe-output (&optional arg)
8519 "Pipe the current article to a subprocess.
8520 If N is a positive number, pipe the N next articles.
8521 If N is a negative number, pipe the N previous articles.
8522 If N is nil and any articles have been marked with the process mark,
8523 pipe those articles instead."
8525 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8526 (gnus-summary-save-article arg t))
8527 (gnus-configure-windows 'pipe))
8529 (defun gnus-summary-save-article-mail (&optional arg)
8530 "Append the current article to an mail file.
8531 If N is a positive number, save the N next articles.
8532 If N is a negative number, save the N previous articles.
8533 If N is nil and any articles have been marked with the process mark,
8534 save those articles instead."
8536 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8537 (gnus-summary-save-article arg)))
8539 (defun gnus-summary-save-article-rmail (&optional arg)
8540 "Append the current article to an rmail file.
8541 If N is a positive number, save the N next articles.
8542 If N is a negative number, save the N previous articles.
8543 If N is nil and any articles have been marked with the process mark,
8544 save those articles instead."
8546 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8547 (gnus-summary-save-article arg)))
8549 (defun gnus-summary-save-article-file (&optional arg)
8550 "Append the current article to a file.
8551 If N is a positive number, save the N next articles.
8552 If N is a negative number, save the N previous articles.
8553 If N is nil and any articles have been marked with the process mark,
8554 save those articles instead."
8556 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8557 (gnus-summary-save-article arg)))
8559 (defun gnus-summary-write-article-file (&optional arg)
8560 "Write the current article to a file, deleting the previous file.
8561 If N is a positive number, save the N next articles.
8562 If N is a negative number, save the N previous articles.
8563 If N is nil and any articles have been marked with the process mark,
8564 save those articles instead."
8566 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8567 (gnus-summary-save-article arg)))
8569 (defun gnus-summary-save-article-body-file (&optional arg)
8570 "Append the current article body to a file.
8571 If N is a positive number, save the N next articles.
8572 If N is a negative number, save the N previous articles.
8573 If N is nil and any articles have been marked with the process mark,
8574 save those articles instead."
8576 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8577 (gnus-summary-save-article arg)))
8579 (defun gnus-summary-pipe-message (program)
8580 "Pipe the current article through PROGRAM."
8581 (interactive "sProgram: ")
8582 (gnus-summary-select-article)
8583 (let ((mail-header-separator ""))
8584 (gnus-eval-in-buffer-window gnus-article-buffer
8587 (let ((start (window-start))
8589 (message-pipe-buffer-body program)
8590 (set-window-start (get-buffer-window (current-buffer)) start))))))
8592 (defun gnus-get-split-value (methods)
8593 "Return a value based on the split METHODS."
8594 (let (split-name method result match)
8597 (set-buffer gnus-original-article-buffer)
8599 (nnheader-narrow-to-headers)
8601 (goto-char (point-min))
8602 (setq method (pop methods))
8603 (setq match (car method))
8606 ;; Regular expression.
8608 (re-search-forward match nil t)))
8609 ((gnus-functionp match)
8613 (setq result (funcall match gnus-newsgroup-name))))
8618 (setq result (eval match)))))
8619 (setq split-name (append (cdr method) split-name))
8620 (cond ((stringp result)
8621 (push (expand-file-name
8622 result gnus-article-save-directory)
8625 (setq split-name (append result split-name)))))))))
8628 (defun gnus-valid-move-group-p (group)
8633 (car (gnus-find-method-for-group
8634 (symbol-name group))))
8635 gnus-valid-select-methods))))
8637 (defun gnus-read-move-group-name (prompt default articles prefix)
8638 "Read a group name."
8639 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8640 (minibuffer-confirm-incomplete nil) ; XEmacs
8644 (if (> (length articles) 1)
8645 (format "these %d articles" (length articles))
8650 (gnus-completing-read default prom
8652 'gnus-valid-move-group-p
8654 'gnus-group-history))
8655 ((= 1 (length split-name))
8656 (gnus-completing-read (car split-name) prom
8658 'gnus-valid-move-group-p
8660 'gnus-group-history))
8662 (gnus-completing-read nil prom
8663 (mapcar (lambda (el) (list el))
8664 (nreverse split-name))
8666 'gnus-group-history)))))
8668 (if (or (string= to-newsgroup "")
8669 (string= to-newsgroup prefix))
8670 (setq to-newsgroup default))
8671 (unless to-newsgroup
8672 (error "No group name entered"))
8673 (or (gnus-active to-newsgroup)
8674 (gnus-activate-group to-newsgroup)
8675 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8677 (or (and (gnus-request-create-group
8678 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8679 (gnus-activate-group to-newsgroup nil nil
8680 (gnus-group-name-to-method
8682 (error "Couldn't create group %s" to-newsgroup)))
8683 (error "No such group: %s" to-newsgroup)))
8686 ;; Summary extract commands
8688 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8689 (let ((buffer-read-only nil)
8690 (article (gnus-summary-article-number))
8692 (unless (gnus-summary-goto-subject article)
8693 (error "No such article: %d" article))
8694 (gnus-summary-position-point)
8695 ;; If all commands are to be bunched up on one line, we collect
8697 (unless gnus-view-pseudos-separately
8698 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8701 (setq action (cdr (assq 'action (car ps))))
8702 (setq files (list (cdr (assq 'name (car ps)))))
8703 (while (and ps (cdr ps)
8704 (string= (or action "1")
8705 (or (cdr (assq 'action (cadr ps))) "2")))
8706 (push (cdr (assq 'name (cadr ps))) files)
8707 (setcdr ps (cddr ps)))
8709 (when (not (string-match "%s" action))
8712 (when (assq 'execute (car ps))
8713 (setcdr (assq 'execute (car ps))
8714 (funcall (if (string-match "%s" action)
8721 (gnus-quote-arg-for-sh-or-csh f)))
8723 (setq ps (cdr ps)))))
8724 (if (and gnus-view-pseudos (not not-view))
8726 (when (assq 'execute (car pslist))
8727 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8728 (eq gnus-view-pseudos 'not-confirm)))
8729 (setq pslist (cdr pslist)))
8732 (setq after-article (or (cdr (assq 'article (car pslist)))
8733 (gnus-summary-article-number)))
8734 (gnus-summary-goto-subject after-article)
8737 (insert " " (file-name-nondirectory
8738 (cdr (assq 'name (car pslist))))
8739 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8741 (forward-line -1) ; back to `b'
8742 (gnus-add-text-properties
8743 b (1- e) (list 'gnus-number gnus-reffed-article-number
8744 gnus-mouse-face-prop gnus-mouse-face))
8746 after-article gnus-reffed-article-number
8747 gnus-unread-mark b (car pslist) 0 (- e b))
8748 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8749 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8750 (setq pslist (cdr pslist)))))))
8752 (defun gnus-pseudos< (p1 p2)
8753 (let ((c1 (cdr (assq 'action p1)))
8754 (c2 (cdr (assq 'action p2))))
8755 (and c1 c2 (string< c1 c2))))
8757 (defun gnus-request-pseudo-article (props)
8758 (cond ((assq 'execute props)
8759 (gnus-execute-command (cdr (assq 'execute props)))))
8760 (let ((gnus-current-article (gnus-summary-article-number)))
8761 (gnus-run-hooks 'gnus-mark-article-hook)))
8763 (defun gnus-execute-command (command &optional automatic)
8765 (gnus-article-setup-buffer)
8766 (set-buffer gnus-article-buffer)
8767 (setq buffer-read-only nil)
8768 (let ((command (if automatic command
8769 (read-string "Command: " (cons command 0)))))
8771 (insert "$ " command "\n\n")
8772 (if gnus-view-pseudo-asynchronously
8773 (start-process "gnus-execute" (current-buffer) shell-file-name
8774 shell-command-switch command)
8775 (call-process shell-file-name nil t nil
8776 shell-command-switch command)))))
8778 ;; Summary kill commands.
8780 (defun gnus-summary-edit-global-kill (article)
8781 "Edit the \"global\" kill file."
8782 (interactive (list (gnus-summary-article-number)))
8783 (gnus-group-edit-global-kill article))
8785 (defun gnus-summary-edit-local-kill ()
8786 "Edit a local kill file applied to the current newsgroup."
8788 (setq gnus-current-headers (gnus-summary-article-header))
8789 (gnus-group-edit-local-kill
8790 (gnus-summary-article-number) gnus-newsgroup-name))
8794 (defun gnus-read-header (id &optional header)
8795 "Read the headers of article ID and enter them into the Gnus system."
8796 (let ((group gnus-newsgroup-name)
8797 (gnus-override-method
8798 (and (gnus-news-group-p gnus-newsgroup-name)
8799 gnus-refer-article-method))
8801 ;; First we check to see whether the header in question is already
8804 ;; This is a Message-ID.
8805 (setq header (or header (gnus-id-to-header id)))
8806 ;; This is an article number.
8807 (setq header (or header (gnus-summary-article-header id))))
8809 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8810 ;; We have found the header.
8812 ;; If this is a sparse article, we have to nix out its
8813 ;; previous entry in the thread hashtb.
8815 (gnus-summary-article-sparse-p (mail-header-number header)))
8816 (let* ((parent (gnus-parent-id (mail-header-references header)))
8817 (thread (and parent (gnus-id-to-thread parent))))
8819 (delq (assq header thread) thread))))
8820 ;; We have to really fetch the header to this article.
8822 (set-buffer nntp-server-buffer)
8823 (when (setq where (gnus-request-head id group))
8824 (nnheader-fold-continuation-lines)
8825 (goto-char (point-max))
8827 (goto-char (point-min))
8831 ((cdr where) (cdr where))
8832 (header (mail-header-number header))
8833 (t gnus-reffed-article-number))
8835 (insert " Article retrieved.\n"))
8837 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8838 () ; Malformed head.
8839 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8840 (when (and (stringp id)
8841 (not (string= (gnus-group-real-name group)
8843 ;; If we fetched by Message-ID and the article came
8844 ;; from a different group, we fudge some bogus article
8845 ;; numbers for this article.
8846 (mail-header-set-number header gnus-reffed-article-number))
8848 (set-buffer gnus-summary-buffer)
8849 (decf gnus-reffed-article-number)
8850 (gnus-remove-header (mail-header-number header))
8851 (push header gnus-newsgroup-headers)
8852 (setq gnus-current-headers header)
8853 (push (mail-header-number header) gnus-newsgroup-limit)))
8856 (defun gnus-remove-header (number)
8857 "Remove header NUMBER from `gnus-newsgroup-headers'."
8858 (if (and gnus-newsgroup-headers
8859 (= number (mail-header-number (car gnus-newsgroup-headers))))
8860 (pop gnus-newsgroup-headers)
8861 (let ((headers gnus-newsgroup-headers))
8862 (while (and (cdr headers)
8863 (not (= number (mail-header-number (cadr headers)))))
8866 (setcdr headers (cddr headers))))))
8869 ;;; summary highlights
8872 (defun gnus-highlight-selected-summary ()
8873 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8874 ;; Highlight selected article in summary buffer
8875 (when gnus-summary-selected-face
8877 (let* ((beg (progn (beginning-of-line) (point)))
8878 (end (progn (end-of-line) (point)))
8879 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8880 (from (if (get-text-property beg gnus-mouse-face-prop)
8882 (or (next-single-property-change
8883 beg gnus-mouse-face-prop nil end)
8888 (or (next-single-property-change
8889 from gnus-mouse-face-prop nil end)
8891 ;; If no mouse-face prop on line we will have to = from = end,
8892 ;; so we highlight the entire line instead.
8893 (when (= (+ to 2) from)
8896 (if gnus-newsgroup-selected-overlay
8897 ;; Move old overlay.
8899 gnus-newsgroup-selected-overlay from to (current-buffer))
8900 ;; Create new overlay.
8902 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8903 'face gnus-summary-selected-face))))))
8905 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8906 (defun gnus-summary-highlight-line ()
8907 "Highlight current line according to `gnus-summary-highlight'."
8908 (let* ((list gnus-summary-highlight)
8910 (end (progn (end-of-line) (point)))
8911 ;; now find out where the line starts and leave point there.
8912 (beg (progn (beginning-of-line) (point)))
8913 (article (gnus-summary-article-number))
8914 (score (or (cdr (assq (or article gnus-current-article)
8915 gnus-newsgroup-scored))
8916 gnus-summary-default-score 0))
8917 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8918 (inhibit-read-only t))
8919 ;; Eval the cars of the lists until we find a match.
8920 (let ((default gnus-summary-default-score))
8922 (not (eval (caar list))))
8923 (setq list (cdr list))))
8924 (let ((face (cdar list)))
8925 (unless (eq face (get-text-property beg 'face))
8926 (gnus-put-text-property-excluding-characters-with-faces
8928 (setq face (if (boundp face) (symbol-value face) face)))
8929 (when gnus-summary-highlight-line-function
8930 (funcall gnus-summary-highlight-line-function article face))))
8933 (defun gnus-update-read-articles (group unread &optional compute)
8934 "Update the list of read articles in GROUP."
8935 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8936 (entry (gnus-gethash group gnus-newsrc-hashtb))
8937 (info (nth 2 entry))
8939 (unread (sort (copy-sequence unread) '<))
8941 (if (or (not info) (not active))
8942 ;; There is no info on this group if it was, in fact,
8943 ;; killed. Gnus stores no information on killed groups, so
8944 ;; there's nothing to be done.
8945 ;; One could store the information somewhere temporarily,
8946 ;; perhaps... Hmmm...
8948 ;; Remove any negative articles numbers.
8949 (while (and unread (< (car unread) 0))
8950 (setq unread (cdr unread)))
8951 ;; Remove any expired article numbers
8952 (while (and unread (< (car unread) (car active)))
8953 (setq unread (cdr unread)))
8954 ;; Compute the ranges of read articles by looking at the list of
8957 (when (/= (car unread) prev)
8958 (push (if (= prev (1- (car unread))) prev
8959 (cons prev (1- (car unread))))
8961 (setq prev (1+ (car unread)))
8962 (setq unread (cdr unread)))
8963 (when (<= prev (cdr active))
8964 (push (cons prev (cdr active)) read))
8966 (if (> (length read) 1) (nreverse read) read)
8968 (set-buffer gnus-group-buffer)
8971 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8972 (gnus-info-set-read ',info ',(gnus-info-read info))
8973 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8974 (gnus-group-update-group ,group t))))
8975 ;; Enter this list into the group info.
8977 info (if (> (length read) 1) (nreverse read) read))
8978 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8979 (gnus-get-unread-articles-in-group info (gnus-active group))
8982 (defun gnus-offer-save-summaries ()
8983 "Offer to save all active summary buffers."
8985 (let ((buflist (buffer-list))
8987 ;; Go through all buffers and find all summaries.
8989 (and (setq bufname (buffer-name (car buflist)))
8990 (string-match "Summary" bufname)
8992 (set-buffer bufname)
8993 ;; We check that this is, indeed, a summary buffer.
8994 (and (eq major-mode 'gnus-summary-mode)
8995 ;; Also make sure this isn't bogus.
8996 gnus-newsgroup-prepared
8997 ;; Also make sure that this isn't a dead summary buffer.
8998 (not gnus-dead-summary-mode)))
8999 (push bufname buffers))
9000 (setq buflist (cdr buflist)))
9001 ;; Go through all these summary buffers and offer to save them.
9004 "Update summary buffer %s? "
9006 (switch-to-buffer buf)
9007 (gnus-summary-exit))
9011 ;;; @ for mime-partial
9014 (defun gnus-request-partial-message ()
9016 (let ((number (gnus-summary-article-number))
9017 (group gnus-newsgroup-name)
9018 (mother gnus-article-buffer))
9019 (set-buffer (get-buffer-create " *Partial Article*"))
9021 (setq mime-preview-buffer mother)
9022 (gnus-request-article-this-buffer number group)
9026 (autoload 'mime-combine-message/partial-pieces-automatically
9028 "Internal method to combine message/partial messages automatically.")
9031 'action '((type . message)(subtype . partial)
9032 (major-mode . gnus-original-article-mode)
9033 (method . mime-combine-message/partial-pieces-automatically)
9034 (summary-buffer-exp . gnus-summary-buffer)
9035 (request-partial-message-method . gnus-request-partial-message)
9046 (run-hooks 'gnus-sum-load-hook)
9048 ;;; gnus-sum.el ends here