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@ifi.uio.no>
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 nil
226 "*If non-nil, ignore subjects and do all threading based on the Reference header.
227 If nil, which is the default, articles that have different subjects
228 from their parents will 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 :group 'gnus-summary-maneuvering
293 (defcustom gnus-summary-check-current nil
294 "*If non-nil, consider the current article when moving.
295 The \"unread\" movement commands will stay on the same line if the
296 current article is unread."
297 :group 'gnus-summary-maneuvering
300 (defcustom gnus-auto-center-summary t
301 "*If non-nil, always center the current summary buffer.
302 In particular, if `vertical' do only vertical recentering. If non-nil
303 and non-`vertical', do both horizontal and vertical recentering."
304 :group 'gnus-summary-maneuvering
305 :type '(choice (const :tag "none" nil)
307 (sexp :menu-tag "both" t)))
309 (defcustom gnus-show-all-headers nil
310 "*If non-nil, don't hide any headers."
311 :group 'gnus-article-hiding
312 :group 'gnus-article-headers
315 (defcustom gnus-summary-ignore-duplicates nil
316 "*If non-nil, ignore articles with identical Message-ID headers."
320 (defcustom gnus-single-article-buffer t
321 "*If non-nil, display all articles in the same buffer.
322 If nil, each group will get its own article buffer."
323 :group 'gnus-article-various
326 (defcustom gnus-break-pages t
327 "*If non-nil, do page breaking on articles.
328 The page delimiter is specified by the `gnus-page-delimiter'
330 :group 'gnus-article-various
333 (defcustom gnus-show-mime t
334 "*If non-nil, do mime processing of articles.
335 The articles will simply be fed to the function given by
336 `gnus-show-mime-method'."
337 :group 'gnus-article-mime
340 (defcustom gnus-move-split-methods nil
341 "*Variable used to suggest where articles are to be moved to.
342 It uses the same syntax as the `gnus-split-methods' variable."
343 :group 'gnus-summary-mail
344 :type '(repeat (choice (list :value (fun) function)
345 (cons :value ("" "") regexp (repeat string))
348 (defcustom gnus-unread-mark ?
349 "*Mark used for unread articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-ticked-mark ?!
354 "*Mark used for ticked articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-dormant-mark ??
359 "*Mark used for dormant articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-del-mark ?r
364 "*Mark used for del'd articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-read-mark ?R
369 "*Mark used for read articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-expirable-mark ?E
374 "*Mark used for expirable articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-killed-mark ?K
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-souped-mark ?F
384 "*Mark used for killed articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-kill-file-mark ?X
389 "*Mark used for articles killed by kill files."
390 :group 'gnus-summary-marks
393 (defcustom gnus-low-score-mark ?Y
394 "*Mark used for articles with a low score."
395 :group 'gnus-summary-marks
398 (defcustom gnus-catchup-mark ?C
399 "*Mark used for articles that are caught up."
400 :group 'gnus-summary-marks
403 (defcustom gnus-replied-mark ?A
404 "*Mark used for articles that have been replied to."
405 :group 'gnus-summary-marks
408 (defcustom gnus-cached-mark ?*
409 "*Mark used for articles that are in the cache."
410 :group 'gnus-summary-marks
413 (defcustom gnus-saved-mark ?S
414 "*Mark used for articles that have been saved to."
415 :group 'gnus-summary-marks
418 (defcustom gnus-ancient-mark ?O
419 "*Mark used for ancient articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-sparse-mark ?Q
424 "*Mark used for sparsely reffed articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-canceled-mark ?G
429 "*Mark used for canceled articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-duplicate-mark ?M
434 "*Mark used for duplicate articles."
435 :group 'gnus-summary-marks
438 (defcustom gnus-undownloaded-mark ?@
439 "*Mark used for articles that weren't downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-downloadable-mark ?%
444 "*Mark used for articles that are to be downloaded."
445 :group 'gnus-summary-marks
448 (defcustom gnus-unsendable-mark ?=
449 "*Mark used for articles that won't be sent."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-over-mark ?+
454 "*Score mark used for articles with high scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-score-below-mark ?-
459 "*Score mark used for articles with low scores."
460 :group 'gnus-summary-marks
463 (defcustom gnus-empty-thread-mark ?
464 "*There is no thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-not-empty-thread-mark ?=
469 "*There is a thread under the article."
470 :group 'gnus-summary-marks
473 (defcustom gnus-view-pseudo-asynchronously nil
474 "*If non-nil, Gnus will view pseudo-articles asynchronously."
475 :group 'gnus-extract-view
478 (defcustom gnus-view-pseudos nil
479 "*If `automatic', pseudo-articles will be viewed automatically.
480 If `not-confirm', pseudos will be viewed automatically, and the user
481 will not be asked to confirm the command."
482 :group 'gnus-extract-view
483 :type '(choice (const :tag "off" nil)
485 (const not-confirm)))
487 (defcustom gnus-view-pseudos-separately t
488 "*If non-nil, one pseudo-article will be created for each file to be viewed.
489 If nil, all files that use the same viewing command will be given as a
490 list of parameters to that command."
491 :group 'gnus-extract-view
494 (defcustom gnus-insert-pseudo-articles t
495 "*If non-nil, insert pseudo-articles when decoding articles."
496 :group 'gnus-extract-view
499 (defcustom gnus-summary-dummy-line-format
501 "*The format specification for the dummy roots in the summary buffer.
502 It works along the same lines as a normal formatting string,
503 with some simple extensions.
506 :group 'gnus-threading
509 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
510 "*The format specification for the summary mode line.
511 It works along the same lines as a normal formatting string,
512 with some simple extensions:
515 %p Unprefixed group name
516 %A Current article number
518 %U Number of unread articles in the group
519 %e Number of unselected articles in the group
520 %Z A string with unread/unselected article counts
521 %g Shortish group name
522 %S Subject of the current article
524 %s Current score file name
525 %d Number of dormant articles
526 %r Number of articles that have been marked as read in this session
527 %E Number of articles expunged by the score files"
528 :group 'gnus-summary-format
531 (defcustom gnus-summary-mark-below 0
532 "*Mark all articles with a score below this variable as read.
533 This variable is local to each summary buffer and usually set by the
535 :group 'gnus-score-default
538 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
539 "*List of functions used for sorting articles in the summary buffer.
540 This variable is only used when not using a threaded display."
541 :group 'gnus-summary-sort
542 :type '(repeat (choice (function-item gnus-article-sort-by-number)
543 (function-item gnus-article-sort-by-author)
544 (function-item gnus-article-sort-by-subject)
545 (function-item gnus-article-sort-by-date)
546 (function-item gnus-article-sort-by-score)
547 (function :tag "other"))))
549 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
550 "*List of functions used for sorting threads in the summary buffer.
551 By default, threads are sorted by article number.
553 Each function takes two threads and return non-nil if the first thread
554 should be sorted before the other. If you use more than one function,
555 the primary sort function should be the last. You should probably
556 always include `gnus-thread-sort-by-number' in the list of sorting
557 functions -- preferably first.
559 Ready-made functions include `gnus-thread-sort-by-number',
560 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
561 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
562 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
563 :group 'gnus-summary-sort
564 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
565 (function-item gnus-thread-sort-by-author)
566 (function-item gnus-thread-sort-by-subject)
567 (function-item gnus-thread-sort-by-date)
568 (function-item gnus-thread-sort-by-score)
569 (function-item gnus-thread-sort-by-total-score)
570 (function :tag "other"))))
572 (defcustom gnus-thread-score-function '+
573 "*Function used for calculating the total score of a thread.
575 The function is called with the scores of the article and each
576 subthread and should then return the score of the thread.
578 Some functions you can use are `+', `max', or `min'."
579 :group 'gnus-summary-sort
582 (defcustom gnus-summary-expunge-below nil
583 "All articles that have a score less than this variable will be expunged.
584 This variable is local to the summary buffers."
585 :group 'gnus-score-default
586 :type '(choice (const :tag "off" nil)
589 (defcustom gnus-thread-expunge-below nil
590 "All threads that have a total score less than this variable will be expunged.
591 See `gnus-thread-score-function' for en explanation of what a
594 This variable is local to the summary buffers."
595 :group 'gnus-treading
596 :group 'gnus-score-default
597 :type '(choice (const :tag "off" nil)
600 (defcustom gnus-summary-mode-hook nil
601 "*A hook for Gnus summary mode.
602 This hook is run before any variables are set in the summary buffer."
603 :group 'gnus-summary-various
606 (defcustom gnus-summary-menu-hook nil
607 "*Hook run after the creation of the summary mode menu."
608 :group 'gnus-summary-visual
611 (defcustom gnus-summary-exit-hook nil
612 "*A hook called on exit from the summary buffer.
613 It will be called with point in the group buffer."
614 :group 'gnus-summary-exit
617 (defcustom gnus-summary-prepare-hook nil
618 "*A hook called after the summary buffer has been generated.
619 If you want to modify the summary buffer, you can use this hook."
620 :group 'gnus-summary-various
623 (defcustom gnus-summary-prepared-hook nil
624 "*A hook called as the last thing after the summary buffer has been generated."
625 :group 'gnus-summary-various
628 (defcustom gnus-summary-generate-hook nil
629 "*A hook run just before generating the summary buffer.
630 This hook is commonly used to customize threading variables and the
632 :group 'gnus-summary-various
635 (defcustom gnus-select-group-hook nil
636 "*A hook called when a newsgroup is selected.
638 If you'd like to simplify subjects like the
639 `gnus-summary-next-same-subject' command does, you can use the
642 (setq gnus-select-group-hook
645 (mapcar (lambda (header)
646 (mail-header-set-subject
648 (gnus-simplify-subject
649 (mail-header-subject header) 're-only)))
650 gnus-newsgroup-headers))))"
651 :group 'gnus-group-select
654 (defcustom gnus-select-article-hook nil
655 "*A hook called when an article is selected."
656 :group 'gnus-summary-choose
659 (defcustom gnus-visual-mark-article-hook
660 (list 'gnus-highlight-selected-summary)
661 "*Hook run after selecting an article in the summary buffer.
662 It is meant to be used for highlighting the article in some way. It
663 is not run if `gnus-visual' is nil."
664 :group 'gnus-summary-visual
667 (defcustom gnus-structured-field-decoder
668 #'eword-decode-and-unfold-structured-field
669 "Function to decode non-ASCII characters in structured field for summary."
673 (defcustom gnus-unstructured-field-decoder
676 (eword-decode-unstructured-field-body
677 (std11-unfold-string string) 'must-unfold)
679 "Function to decode non-ASCII characters in unstructured field for summary."
683 (defcustom gnus-parse-headers-hook
684 '(gnus-set-summary-default-charset)
685 "*A hook called before parsing the headers."
689 (defcustom gnus-exit-group-hook nil
690 "*A hook called when exiting (not quitting) summary mode."
694 (defcustom gnus-summary-update-hook
695 (list 'gnus-summary-highlight-line)
696 "*A hook called when a summary line is changed.
697 The hook will not be called if `gnus-visual' is nil.
699 The default function `gnus-summary-highlight-line' will
700 highlight the line according to the `gnus-summary-highlight'
702 :group 'gnus-summary-visual
705 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
706 "*A hook called when an article is selected for the first time.
707 The hook is intended to mark an article as read (or unread)
708 automatically when it is selected."
709 :group 'gnus-summary-choose
712 (defcustom gnus-group-no-more-groups-hook nil
713 "*A hook run when returning to group mode having no more (unread) groups."
714 :group 'gnus-group-select
717 (defcustom gnus-ps-print-hook nil
718 "*A hook run before ps-printing something from Gnus."
722 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
723 "Face used for highlighting the current article in the summary buffer."
724 :group 'gnus-summary-visual
727 (defcustom gnus-summary-highlight
728 '(((= mark gnus-canceled-mark)
729 . gnus-summary-cancelled-face)
730 ((and (> score default)
731 (or (= mark gnus-dormant-mark)
732 (= mark gnus-ticked-mark)))
733 . gnus-summary-high-ticked-face)
734 ((and (< score default)
735 (or (= mark gnus-dormant-mark)
736 (= mark gnus-ticked-mark)))
737 . gnus-summary-low-ticked-face)
738 ((or (= mark gnus-dormant-mark)
739 (= mark gnus-ticked-mark))
740 . gnus-summary-normal-ticked-face)
741 ((and (> score default) (= mark gnus-ancient-mark))
742 . gnus-summary-high-ancient-face)
743 ((and (< score default) (= mark gnus-ancient-mark))
744 . gnus-summary-low-ancient-face)
745 ((= mark gnus-ancient-mark)
746 . gnus-summary-normal-ancient-face)
747 ((and (> score default) (= mark gnus-unread-mark))
748 . gnus-summary-high-unread-face)
749 ((and (< score default) (= mark gnus-unread-mark))
750 . gnus-summary-low-unread-face)
751 ((= mark gnus-unread-mark)
752 . gnus-summary-normal-unread-face)
753 ((and (> score default) (memq mark (list gnus-downloadable-mark
754 gnus-undownloaded-mark)))
755 . gnus-summary-high-unread-face)
756 ((and (< score default) (memq mark (list gnus-downloadable-mark
757 gnus-undownloaded-mark)))
758 . gnus-summary-low-unread-face)
759 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
760 . gnus-summary-normal-unread-face)
762 . gnus-summary-high-read-face)
764 . gnus-summary-low-read-face)
766 . gnus-summary-normal-read-face))
767 "*Controls the highlighting of summary buffer lines.
769 A list of (FORM . FACE) pairs. When deciding how a a particular
770 summary line should be displayed, each form is evaluated. The content
771 of the face field after the first true form is used. You can change
772 how those summary lines are displayed, by editing the face field.
774 You can use the following variables in the FORM field.
776 score: The articles score
777 default: The default article score.
778 below: The score below which articles are automatically marked as read.
779 mark: The articles mark."
780 :group 'gnus-summary-visual
781 :type '(repeat (cons (sexp :tag "Form" nil)
784 (defcustom gnus-alter-header-function nil
785 "Function called to allow alteration of article header structures.
786 The function is called with one parameter, the article header vector,
787 which it may alter in any way.")
789 ;;; Internal variables
791 (defvar gnus-scores-exclude-files nil)
792 (defvar gnus-page-broken nil)
794 (defvar gnus-original-article nil)
795 (defvar gnus-article-internal-prepare-hook nil)
796 (defvar gnus-newsgroup-process-stack nil)
798 (defvar gnus-thread-indent-array nil)
799 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
801 ;; Avoid highlighting in kill files.
802 (defvar gnus-summary-inhibit-highlight nil)
803 (defvar gnus-newsgroup-selected-overlay nil)
804 (defvar gnus-inhibit-limiting nil)
805 (defvar gnus-newsgroup-adaptive-score-file nil)
806 (defvar gnus-current-score-file nil)
807 (defvar gnus-current-move-group nil)
808 (defvar gnus-current-copy-group nil)
809 (defvar gnus-current-crosspost-group nil)
811 (defvar gnus-newsgroup-dependencies nil)
812 (defvar gnus-newsgroup-adaptive nil)
813 (defvar gnus-summary-display-article-function nil)
814 (defvar gnus-summary-highlight-line-function nil
815 "Function called after highlighting a summary line.")
817 (defvar gnus-summary-line-format-alist
818 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
819 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
820 (?s gnus-tmp-subject-or-nil ?s)
821 (?n gnus-tmp-name ?s)
822 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
824 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
826 (?F gnus-tmp-from ?s)
827 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
828 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
829 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
830 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
831 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
832 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
833 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
834 (?L gnus-tmp-lines ?d)
835 (?I gnus-tmp-indentation ?s)
836 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
837 (?R gnus-tmp-replied ?c)
838 (?\[ gnus-tmp-opening-bracket ?c)
839 (?\] gnus-tmp-closing-bracket ?c)
840 (?\> (make-string gnus-tmp-level ? ) ?s)
841 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
842 (?i gnus-tmp-score ?d)
843 (?z gnus-tmp-score-char ?c)
844 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
845 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
846 (?U gnus-tmp-unread ?c)
847 (?t (gnus-summary-number-of-articles-in-thread
848 (and (boundp 'thread) (car thread)) gnus-tmp-level)
850 (?e (gnus-summary-number-of-articles-in-thread
851 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
853 (?u gnus-tmp-user-defined ?s)
854 (?P (gnus-pick-line-number) ?d))
855 "An alist of format specifications that can appear in summary lines,
856 and what variables they correspond with, along with the type of the
857 variable (string, integer, character, etc).")
859 (defvar gnus-summary-dummy-line-format-alist
860 `((?S gnus-tmp-subject ?s)
861 (?N gnus-tmp-number ?d)
862 (?u gnus-tmp-user-defined ?s)))
864 (defvar gnus-summary-mode-line-format-alist
865 `((?G gnus-tmp-group-name ?s)
866 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
867 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
868 (?A gnus-tmp-article-number ?d)
869 (?Z gnus-tmp-unread-and-unselected ?s)
871 (?U gnus-tmp-unread-and-unticked ?d)
872 (?S gnus-tmp-subject ?s)
873 (?e gnus-tmp-unselected ?d)
874 (?u gnus-tmp-user-defined ?s)
875 (?d (length gnus-newsgroup-dormant) ?d)
876 (?t (length gnus-newsgroup-marked) ?d)
877 (?r (length gnus-newsgroup-reads) ?d)
878 (?E gnus-newsgroup-expunged-tally ?d)
879 (?s (gnus-current-score-file-nondirectory) ?s)))
881 (defvar gnus-last-search-regexp nil
882 "Default regexp for article search command.")
884 (defvar gnus-last-shell-command nil
885 "Default shell command on article.")
887 (defvar gnus-newsgroup-begin nil)
888 (defvar gnus-newsgroup-end nil)
889 (defvar gnus-newsgroup-last-rmail nil)
890 (defvar gnus-newsgroup-last-mail nil)
891 (defvar gnus-newsgroup-last-folder nil)
892 (defvar gnus-newsgroup-last-file nil)
893 (defvar gnus-newsgroup-auto-expire nil)
894 (defvar gnus-newsgroup-active nil)
896 (defvar gnus-newsgroup-data nil)
897 (defvar gnus-newsgroup-data-reverse nil)
898 (defvar gnus-newsgroup-limit nil)
899 (defvar gnus-newsgroup-limits nil)
901 (defvar gnus-newsgroup-unreads nil
902 "List of unread articles in the current newsgroup.")
904 (defvar gnus-newsgroup-unselected nil
905 "List of unselected unread articles in the current newsgroup.")
907 (defvar gnus-newsgroup-reads nil
908 "Alist of read articles and article marks in the current newsgroup.")
910 (defvar gnus-newsgroup-expunged-tally nil)
912 (defvar gnus-newsgroup-marked nil
913 "List of ticked articles in the current newsgroup (a subset of unread art).")
915 (defvar gnus-newsgroup-killed nil
916 "List of ranges of articles that have been through the scoring process.")
918 (defvar gnus-newsgroup-cached nil
919 "List of articles that come from the article cache.")
921 (defvar gnus-newsgroup-saved nil
922 "List of articles that have been saved.")
924 (defvar gnus-newsgroup-kill-headers nil)
926 (defvar gnus-newsgroup-replied nil
927 "List of articles that have been replied to in the current newsgroup.")
929 (defvar gnus-newsgroup-expirable nil
930 "List of articles in the current newsgroup that can be expired.")
932 (defvar gnus-newsgroup-processable nil
933 "List of articles in the current newsgroup that can be processed.")
935 (defvar gnus-newsgroup-downloadable nil
936 "List of articles in the current newsgroup that can be processed.")
938 (defvar gnus-newsgroup-undownloaded nil
939 "List of articles in the current newsgroup that haven't been downloaded..")
941 (defvar gnus-newsgroup-unsendable nil
942 "List of articles in the current newsgroup that won't be sent.")
944 (defvar gnus-newsgroup-bookmarks nil
945 "List of articles in the current newsgroup that have bookmarks.")
947 (defvar gnus-newsgroup-dormant nil
948 "List of dormant articles in the current newsgroup.")
950 (defvar gnus-newsgroup-scored nil
951 "List of scored articles in the current newsgroup.")
953 (defvar gnus-newsgroup-headers nil
954 "List of article headers in the current newsgroup.")
956 (defvar gnus-newsgroup-threads nil)
958 (defvar gnus-newsgroup-prepared nil
959 "Whether the current group has been prepared properly.")
961 (defvar gnus-newsgroup-ancient nil
962 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
964 (defvar gnus-newsgroup-sparse nil)
966 (defvar gnus-current-article nil)
967 (defvar gnus-article-current nil)
968 (defvar gnus-current-headers nil)
969 (defvar gnus-have-all-headers nil)
970 (defvar gnus-last-article nil)
971 (defvar gnus-newsgroup-history nil)
973 (defconst gnus-summary-local-variables
974 '(gnus-newsgroup-name
975 gnus-newsgroup-begin gnus-newsgroup-end
976 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
977 gnus-newsgroup-last-folder gnus-newsgroup-last-file
978 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
979 gnus-newsgroup-unselected gnus-newsgroup-marked
980 gnus-newsgroup-reads gnus-newsgroup-saved
981 gnus-newsgroup-replied gnus-newsgroup-expirable
982 gnus-newsgroup-processable gnus-newsgroup-killed
983 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
984 gnus-newsgroup-unsendable
985 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
986 gnus-newsgroup-headers gnus-newsgroup-threads
987 gnus-newsgroup-prepared gnus-summary-highlight-line-function
988 gnus-current-article gnus-current-headers gnus-have-all-headers
989 gnus-last-article gnus-article-internal-prepare-hook
990 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
991 gnus-newsgroup-scored gnus-newsgroup-kill-headers
992 gnus-thread-expunge-below
993 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
994 (gnus-summary-mark-below . global)
995 gnus-newsgroup-active gnus-scores-exclude-files
996 gnus-newsgroup-history gnus-newsgroup-ancient
997 gnus-newsgroup-sparse gnus-newsgroup-process-stack
998 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
999 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1000 (gnus-newsgroup-expunged-tally . 0)
1001 gnus-cache-removable-articles gnus-newsgroup-cached
1002 gnus-newsgroup-data gnus-newsgroup-data-reverse
1003 gnus-newsgroup-limit gnus-newsgroup-limits)
1004 "Variables that are buffer-local to the summary buffers.")
1006 ;; Byte-compiler warning.
1007 (defvar gnus-article-mode-map)
1009 ;; Subject simplification.
1011 (defun gnus-simplify-whitespace (str)
1012 "Remove excessive whitespace."
1015 (while (string-match "[ \t][ \t]+" mystr)
1016 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1018 (substring mystr (match-end 0)))))
1020 (when (string-match "^[ \t]+" mystr)
1021 (setq mystr (substring mystr (match-end 0))))
1023 (when (string-match "[ \t]+$" mystr)
1024 (setq mystr (substring mystr 0 (match-beginning 0))))
1027 (defsubst gnus-simplify-subject-re (subject)
1028 "Remove \"Re:\" from subject lines."
1029 (if (string-match "^[Rr][Ee]: *" subject)
1030 (substring subject (match-end 0))
1033 (defun gnus-simplify-subject (subject &optional re-only)
1034 "Remove `Re:' and words in parentheses.
1035 If RE-ONLY is non-nil, strip leading `Re:'s only."
1036 (let ((case-fold-search t)) ;Ignore case.
1037 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1038 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1039 (setq subject (substring subject (match-end 0))))
1040 ;; Remove uninteresting prefixes.
1041 (when (and (not re-only)
1042 gnus-simplify-ignored-prefixes
1043 (string-match gnus-simplify-ignored-prefixes subject))
1044 (setq subject (substring subject (match-end 0))))
1045 ;; Remove words in parentheses from end.
1047 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1048 (setq subject (substring subject 0 (match-beginning 0)))))
1049 ;; Return subject string.
1052 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1054 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1055 (goto-char (point-min))
1056 (while (re-search-forward regexp nil t)
1057 (replace-match (or newtext ""))))
1059 (defun gnus-simplify-buffer-fuzzy ()
1060 "Simplify string in the buffer fuzzily.
1061 The string in the accessible portion of the current buffer is simplified.
1062 It is assumed to be a single-line subject.
1063 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1064 matter is removed. Additional things can be deleted by setting
1065 gnus-simplify-subject-fuzzy-regexp."
1066 (let ((case-fold-search t)
1068 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1070 (while (not (eq modified-tick (buffer-modified-tick)))
1071 (setq modified-tick (buffer-modified-tick))
1073 ((listp gnus-simplify-subject-fuzzy-regexp)
1074 (mapcar 'gnus-simplify-buffer-fuzzy-step
1075 gnus-simplify-subject-fuzzy-regexp))
1076 (gnus-simplify-subject-fuzzy-regexp
1077 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1078 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1079 (gnus-simplify-buffer-fuzzy-step
1080 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1081 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1083 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1084 (gnus-simplify-buffer-fuzzy-step " +" " ")
1085 (gnus-simplify-buffer-fuzzy-step " $")
1086 (gnus-simplify-buffer-fuzzy-step "^ +")))
1088 (defun gnus-simplify-subject-fuzzy (subject)
1089 "Simplify a subject string fuzzily.
1090 See `gnus-simplify-buffer-fuzzy' for details."
1092 (gnus-set-work-buffer)
1093 (let ((case-fold-search t))
1094 ;; Remove uninteresting prefixes.
1095 (when (and gnus-simplify-ignored-prefixes
1096 (string-match gnus-simplify-ignored-prefixes subject))
1097 (setq subject (substring subject (match-end 0))))
1099 (inline (gnus-simplify-buffer-fuzzy))
1102 (defsubst gnus-simplify-subject-fully (subject)
1103 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1105 (gnus-simplify-subject-functions
1106 (gnus-map-function gnus-simplify-subject-functions subject))
1107 ((null gnus-summary-gather-subject-limit)
1108 (gnus-simplify-subject-re subject))
1109 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1110 (gnus-simplify-subject-fuzzy subject))
1111 ((numberp gnus-summary-gather-subject-limit)
1112 (gnus-limit-string (gnus-simplify-subject-re subject)
1113 gnus-summary-gather-subject-limit))
1117 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1118 "Check whether two subjects are equal.
1119 If optional argument simple-first is t, first argument is already
1122 ((null simple-first)
1123 (equal (gnus-simplify-subject-fully s1)
1124 (gnus-simplify-subject-fully s2)))
1127 (gnus-simplify-subject-fully s2)))))
1129 (defun gnus-summary-bubble-group ()
1130 "Increase the score of the current group.
1131 This is a handy function to add to `gnus-summary-exit-hook' to
1132 increase the score of each group you read."
1133 (gnus-group-add-score gnus-newsgroup-name))
1137 ;;; Gnus summary mode
1140 (put 'gnus-summary-mode 'mode-class 'special)
1143 ;; Non-orthogonal keys
1145 (gnus-define-keys gnus-summary-mode-map
1146 " " gnus-summary-next-page
1147 "\177" gnus-summary-prev-page
1148 [delete] gnus-summary-prev-page
1149 [backspace] gnus-summary-prev-page
1150 "\r" gnus-summary-scroll-up
1151 "\e\r" gnus-summary-scroll-down
1152 "n" gnus-summary-next-unread-article
1153 "p" gnus-summary-prev-unread-article
1154 "N" gnus-summary-next-article
1155 "P" gnus-summary-prev-article
1156 "\M-\C-n" gnus-summary-next-same-subject
1157 "\M-\C-p" gnus-summary-prev-same-subject
1158 "\M-n" gnus-summary-next-unread-subject
1159 "\M-p" gnus-summary-prev-unread-subject
1160 "." gnus-summary-first-unread-article
1161 "," gnus-summary-best-unread-article
1162 "\M-s" gnus-summary-search-article-forward
1163 "\M-r" gnus-summary-search-article-backward
1164 "<" gnus-summary-beginning-of-article
1165 ">" gnus-summary-end-of-article
1166 "j" gnus-summary-goto-article
1167 "^" gnus-summary-refer-parent-article
1168 "\M-^" gnus-summary-refer-article
1169 "u" gnus-summary-tick-article-forward
1170 "!" gnus-summary-tick-article-forward
1171 "U" gnus-summary-tick-article-backward
1172 "d" gnus-summary-mark-as-read-forward
1173 "D" gnus-summary-mark-as-read-backward
1174 "E" gnus-summary-mark-as-expirable
1175 "\M-u" gnus-summary-clear-mark-forward
1176 "\M-U" gnus-summary-clear-mark-backward
1177 "k" gnus-summary-kill-same-subject-and-select
1178 "\C-k" gnus-summary-kill-same-subject
1179 "\M-\C-k" gnus-summary-kill-thread
1180 "\M-\C-l" gnus-summary-lower-thread
1181 "e" gnus-summary-edit-article
1182 "#" gnus-summary-mark-as-processable
1183 "\M-#" gnus-summary-unmark-as-processable
1184 "\M-\C-t" gnus-summary-toggle-threads
1185 "\M-\C-s" gnus-summary-show-thread
1186 "\M-\C-h" gnus-summary-hide-thread
1187 "\M-\C-f" gnus-summary-next-thread
1188 "\M-\C-b" gnus-summary-prev-thread
1189 "\M-\C-u" gnus-summary-up-thread
1190 "\M-\C-d" gnus-summary-down-thread
1191 "&" gnus-summary-execute-command
1192 "c" gnus-summary-catchup-and-exit
1193 "\C-w" gnus-summary-mark-region-as-read
1194 "\C-t" gnus-summary-toggle-truncation
1195 "?" gnus-summary-mark-as-dormant
1196 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1197 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1198 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1199 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1200 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1201 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1202 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1203 "=" gnus-summary-expand-window
1204 "\C-x\C-s" gnus-summary-reselect-current-group
1205 "\M-g" gnus-summary-rescan-group
1206 "w" gnus-summary-stop-page-breaking
1207 "\C-c\C-r" gnus-summary-caesar-message
1208 "\M-t" gnus-summary-toggle-mime
1209 "f" gnus-summary-followup
1210 "F" gnus-summary-followup-with-original
1211 "C" gnus-summary-cancel-article
1212 "r" gnus-summary-reply
1213 "R" gnus-summary-reply-with-original
1214 "\C-c\C-f" gnus-summary-mail-forward
1215 "o" gnus-summary-save-article
1216 "\C-o" gnus-summary-save-article-mail
1217 "|" gnus-summary-pipe-output
1218 "\M-k" gnus-summary-edit-local-kill
1219 "\M-K" gnus-summary-edit-global-kill
1221 "\C-c\C-d" gnus-summary-describe-group
1222 "q" gnus-summary-exit
1223 "Q" gnus-summary-exit-no-update
1224 "\C-c\C-i" gnus-info-find-node
1225 gnus-mouse-2 gnus-mouse-pick-article
1226 "m" gnus-summary-mail-other-window
1227 "a" gnus-summary-post-news
1228 "x" gnus-summary-limit-to-unread
1229 "s" gnus-summary-isearch-article
1230 "t" gnus-article-hide-headers
1231 "g" gnus-summary-show-article
1232 "l" gnus-summary-goto-last-article
1233 "v" gnus-summary-preview-mime-message
1234 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1235 "\C-d" gnus-summary-enter-digest-group
1236 "\M-\C-d" gnus-summary-read-document
1237 "\M-\C-e" gnus-summary-edit-parameters
1239 "*" gnus-cache-enter-article
1240 "\M-*" gnus-cache-remove-article
1241 "\M-&" gnus-summary-universal-argument
1242 "\C-l" gnus-recenter
1243 "I" gnus-summary-increase-score
1244 "L" gnus-summary-lower-score
1245 "\M-i" gnus-symbolic-argument
1246 "h" gnus-summary-select-article-buffer
1248 "V" gnus-summary-score-map
1249 "X" gnus-uu-extract-map
1250 "S" gnus-summary-send-map)
1252 ;; Sort of orthogonal keymap
1253 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1254 "t" gnus-summary-tick-article-forward
1255 "!" gnus-summary-tick-article-forward
1256 "d" gnus-summary-mark-as-read-forward
1257 "r" gnus-summary-mark-as-read-forward
1258 "c" gnus-summary-clear-mark-forward
1259 " " gnus-summary-clear-mark-forward
1260 "e" gnus-summary-mark-as-expirable
1261 "x" gnus-summary-mark-as-expirable
1262 "?" gnus-summary-mark-as-dormant
1263 "b" gnus-summary-set-bookmark
1264 "B" gnus-summary-remove-bookmark
1265 "#" gnus-summary-mark-as-processable
1266 "\M-#" gnus-summary-unmark-as-processable
1267 "S" gnus-summary-limit-include-expunged
1268 "C" gnus-summary-catchup
1269 "H" gnus-summary-catchup-to-here
1270 "\C-c" gnus-summary-catchup-all
1271 "k" gnus-summary-kill-same-subject-and-select
1272 "K" gnus-summary-kill-same-subject
1273 "P" gnus-uu-mark-map)
1275 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1276 "c" gnus-summary-clear-above
1277 "u" gnus-summary-tick-above
1278 "m" gnus-summary-mark-above
1279 "k" gnus-summary-kill-below)
1281 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1282 "/" gnus-summary-limit-to-subject
1283 "n" gnus-summary-limit-to-articles
1284 "w" gnus-summary-pop-limit
1285 "s" gnus-summary-limit-to-subject
1286 "a" gnus-summary-limit-to-author
1287 "u" gnus-summary-limit-to-unread
1288 "m" gnus-summary-limit-to-marks
1289 "v" gnus-summary-limit-to-score
1290 "*" gnus-summary-limit-include-cached
1291 "D" gnus-summary-limit-include-dormant
1292 "T" gnus-summary-limit-include-thread
1293 "d" gnus-summary-limit-exclude-dormant
1294 "t" gnus-summary-limit-to-age
1295 "E" gnus-summary-limit-include-expunged
1296 "c" gnus-summary-limit-exclude-childless-dormant
1297 "C" gnus-summary-limit-mark-excluded-as-read)
1299 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1300 "n" gnus-summary-next-unread-article
1301 "p" gnus-summary-prev-unread-article
1302 "N" gnus-summary-next-article
1303 "P" gnus-summary-prev-article
1304 "\C-n" gnus-summary-next-same-subject
1305 "\C-p" gnus-summary-prev-same-subject
1306 "\M-n" gnus-summary-next-unread-subject
1307 "\M-p" gnus-summary-prev-unread-subject
1308 "f" gnus-summary-first-unread-article
1309 "b" gnus-summary-best-unread-article
1310 "j" gnus-summary-goto-article
1311 "g" gnus-summary-goto-subject
1312 "l" gnus-summary-goto-last-article
1313 "o" gnus-summary-pop-article)
1315 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1316 "k" gnus-summary-kill-thread
1317 "l" gnus-summary-lower-thread
1318 "i" gnus-summary-raise-thread
1319 "T" gnus-summary-toggle-threads
1320 "t" gnus-summary-rethread-current
1321 "^" gnus-summary-reparent-thread
1322 "s" gnus-summary-show-thread
1323 "S" gnus-summary-show-all-threads
1324 "h" gnus-summary-hide-thread
1325 "H" gnus-summary-hide-all-threads
1326 "n" gnus-summary-next-thread
1327 "p" gnus-summary-prev-thread
1328 "u" gnus-summary-up-thread
1329 "o" gnus-summary-top-thread
1330 "d" gnus-summary-down-thread
1331 "#" gnus-uu-mark-thread
1332 "\M-#" gnus-uu-unmark-thread)
1334 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1335 "g" gnus-summary-prepare
1336 "c" gnus-summary-insert-cached-articles)
1338 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1339 "c" gnus-summary-catchup-and-exit
1340 "C" gnus-summary-catchup-all-and-exit
1341 "E" gnus-summary-exit-no-update
1342 "Q" gnus-summary-exit
1343 "Z" gnus-summary-exit
1344 "n" gnus-summary-catchup-and-goto-next-group
1345 "R" gnus-summary-reselect-current-group
1346 "G" gnus-summary-rescan-group
1347 "N" gnus-summary-next-group
1348 "s" gnus-summary-save-newsrc
1349 "P" gnus-summary-prev-group)
1351 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1352 " " gnus-summary-next-page
1353 "n" gnus-summary-next-page
1354 "\177" gnus-summary-prev-page
1355 [delete] gnus-summary-prev-page
1356 "p" gnus-summary-prev-page
1357 "\r" gnus-summary-scroll-up
1358 "<" gnus-summary-beginning-of-article
1359 ">" gnus-summary-end-of-article
1360 "b" gnus-summary-beginning-of-article
1361 "e" gnus-summary-end-of-article
1362 "^" gnus-summary-refer-parent-article
1363 "r" gnus-summary-refer-parent-article
1364 "R" gnus-summary-refer-references
1365 "T" gnus-summary-refer-thread
1366 "g" gnus-summary-show-article
1367 "s" gnus-summary-isearch-article
1368 "P" gnus-summary-print-article)
1370 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1371 "b" gnus-article-add-buttons
1372 "B" gnus-article-add-buttons-to-head
1373 "o" gnus-article-treat-overstrike
1374 "e" gnus-article-emphasize
1375 "w" gnus-article-fill-cited-article
1376 "c" gnus-article-remove-cr
1377 "f" gnus-article-display-x-face
1378 "l" gnus-summary-stop-page-breaking
1379 "r" gnus-summary-caesar-message
1380 "t" gnus-article-hide-headers
1381 "v" gnus-summary-verbose-headers
1382 "m" gnus-summary-toggle-mime
1383 "h" gnus-article-treat-html
1384 "d" gnus-article-treat-dumbquotes)
1386 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1387 "a" gnus-article-hide
1388 "h" gnus-article-hide-headers
1389 "b" gnus-article-hide-boring-headers
1390 "s" gnus-article-hide-signature
1391 "c" gnus-article-hide-citation
1392 "p" gnus-article-hide-pgp
1393 "P" gnus-article-hide-pem
1394 "\C-c" gnus-article-hide-citation-maybe)
1396 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1397 "a" gnus-article-highlight
1398 "h" gnus-article-highlight-headers
1399 "c" gnus-article-highlight-citation
1400 "s" gnus-article-highlight-signature)
1402 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1403 "z" gnus-article-date-ut
1404 "u" gnus-article-date-ut
1405 "l" gnus-article-date-local
1406 "e" gnus-article-date-lapsed
1407 "o" gnus-article-date-original
1408 "i" gnus-article-date-iso8601
1409 "s" gnus-article-date-user)
1411 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1412 "t" gnus-article-remove-trailing-blank-lines
1413 "l" gnus-article-strip-leading-blank-lines
1414 "m" gnus-article-strip-multiple-blank-lines
1415 "a" gnus-article-strip-blank-lines
1416 "A" gnus-article-strip-all-blank-lines
1417 "s" gnus-article-strip-leading-space)
1419 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1421 "f" gnus-summary-fetch-faq
1422 "d" gnus-summary-describe-group
1423 "h" gnus-summary-describe-briefly
1424 "i" gnus-info-find-node)
1426 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1427 "e" gnus-summary-expire-articles
1428 "\M-\C-e" gnus-summary-expire-articles-now
1429 "\177" gnus-summary-delete-article
1430 [delete] gnus-summary-delete-article
1431 "m" gnus-summary-move-article
1432 "r" gnus-summary-respool-article
1433 "w" gnus-summary-edit-article
1434 "c" gnus-summary-copy-article
1435 "B" gnus-summary-crosspost-article
1436 "q" gnus-summary-respool-query
1437 "i" gnus-summary-import-article
1438 "p" gnus-summary-article-posted-p)
1440 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1441 "o" gnus-summary-save-article
1442 "m" gnus-summary-save-article-mail
1443 "F" gnus-summary-write-article-file
1444 "r" gnus-summary-save-article-rmail
1445 "f" gnus-summary-save-article-file
1446 "b" gnus-summary-save-article-body-file
1447 "h" gnus-summary-save-article-folder
1448 "v" gnus-summary-save-article-vm
1449 "p" gnus-summary-pipe-output
1450 "s" gnus-soup-add-article))
1452 (defun gnus-summary-make-menu-bar ()
1453 (gnus-turn-off-edit-menu 'summary)
1455 (unless (boundp 'gnus-summary-misc-menu)
1458 gnus-summary-kill-menu gnus-summary-mode-map ""
1463 ["Enter score..." gnus-summary-score-entry t]
1464 ["Customize" gnus-score-customize t])
1465 (gnus-make-score-map 'increase)
1466 (gnus-make-score-map 'lower)
1468 ["Kill below" gnus-summary-kill-below t]
1469 ["Mark above" gnus-summary-mark-above t]
1470 ["Tick above" gnus-summary-tick-above t]
1471 ["Clear above" gnus-summary-clear-above t])
1472 ["Current score" gnus-summary-current-score t]
1473 ["Set score" gnus-summary-set-score t]
1474 ["Switch current score file..." gnus-score-change-score-file t]
1475 ["Set mark below..." gnus-score-set-mark-below t]
1476 ["Set expunge below..." gnus-score-set-expunge-below t]
1477 ["Edit current score file" gnus-score-edit-current-scores t]
1478 ["Edit score file" gnus-score-edit-file t]
1479 ["Trace score" gnus-score-find-trace t]
1480 ["Find words" gnus-score-find-favourite-words t]
1481 ["Rescore buffer" gnus-summary-rescore t]
1482 ["Increase score..." gnus-summary-increase-score t]
1483 ["Lower score..." gnus-summary-lower-score t]))))
1485 ;; Define both the Article menu in the summary buffer and the equivalent
1486 ;; Commands menu in the article buffer here for consistency.
1489 ["All" gnus-article-hide t]
1490 ["Headers" gnus-article-hide-headers t]
1491 ["Signature" gnus-article-hide-signature t]
1492 ["Citation" gnus-article-hide-citation t]
1493 ["PGP" gnus-article-hide-pgp t]
1494 ["Boring headers" gnus-article-hide-boring-headers t])
1496 ["All" gnus-article-highlight t]
1497 ["Headers" gnus-article-highlight-headers t]
1498 ["Signature" gnus-article-highlight-signature t]
1499 ["Citation" gnus-article-highlight-citation t])
1501 ["Local" gnus-article-date-local t]
1502 ["ISO8601" gnus-article-date-iso8601 t]
1503 ["UT" gnus-article-date-ut t]
1504 ["Original" gnus-article-date-original t]
1505 ["Lapsed" gnus-article-date-lapsed t]
1506 ["User-defined" gnus-article-date-user t])
1509 ["Leading" gnus-article-strip-leading-blank-lines t]
1510 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1511 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1512 ["All of the above" gnus-article-strip-blank-lines t]
1513 ["All" gnus-article-strip-all-blank-lines t]
1514 ["Leading space" gnus-article-strip-leading-space t])
1515 ["Overstrike" gnus-article-treat-overstrike t]
1516 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1517 ["Emphasis" gnus-article-emphasize t]
1518 ["Word wrap" gnus-article-fill-cited-article t]
1519 ["CR" gnus-article-remove-cr t]
1520 ["Show X-Face" gnus-article-display-x-face t]
1521 ["UnHTMLize" gnus-article-treat-html t]
1522 ["Rot 13" gnus-summary-caesar-message t]
1523 ["Unix pipe" gnus-summary-pipe-message t]
1524 ["Add buttons" gnus-article-add-buttons t]
1525 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1526 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1527 ["Toggle MIME" gnus-summary-toggle-mime t]
1528 ["Verbose header" gnus-summary-verbose-headers t]
1529 ["Toggle header" gnus-summary-toggle-header t])
1531 ["Save in default format" gnus-summary-save-article t]
1532 ["Save in file" gnus-summary-save-article-file t]
1533 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1534 ["Save in MH folder" gnus-summary-save-article-folder t]
1535 ["Save in VM folder" gnus-summary-save-article-vm t]
1536 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1537 ["Save body in file" gnus-summary-save-article-body-file t]
1538 ["Pipe through a filter" gnus-summary-pipe-output t]
1539 ["Add to SOUP packet" gnus-soup-add-article t]
1540 ["Print" gnus-summary-print-article t])
1542 ["Respool article..." gnus-summary-respool-article t]
1543 ["Move article..." gnus-summary-move-article
1544 (gnus-check-backend-function
1545 'request-move-article gnus-newsgroup-name)]
1546 ["Copy article..." gnus-summary-copy-article t]
1547 ["Crosspost article..." gnus-summary-crosspost-article
1548 (gnus-check-backend-function
1549 'request-replace-article gnus-newsgroup-name)]
1550 ["Import file..." gnus-summary-import-article t]
1551 ["Check if posted" gnus-summary-article-posted-p t]
1552 ["Edit article" gnus-summary-edit-article
1553 (not (gnus-group-read-only-p))]
1554 ["Delete article" gnus-summary-delete-article
1555 (gnus-check-backend-function
1556 'request-expire-articles gnus-newsgroup-name)]
1557 ["Query respool" gnus-summary-respool-query t]
1558 ["Delete expirable articles" gnus-summary-expire-articles-now
1559 (gnus-check-backend-function
1560 'request-expire-articles gnus-newsgroup-name)])
1562 ["Uudecode" gnus-uu-decode-uu t]
1563 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1564 ["Unshar" gnus-uu-decode-unshar t]
1565 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1566 ["Save" gnus-uu-decode-save t]
1567 ["Binhex" gnus-uu-decode-binhex t]
1568 ["Postscript" gnus-uu-decode-postscript t])
1570 ["Enter article" gnus-cache-enter-article t]
1571 ["Remove article" gnus-cache-remove-article t])
1572 ["Select article buffer" gnus-summary-select-article-buffer t]
1573 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1574 ["Isearch article..." gnus-summary-isearch-article t]
1575 ["Beginning of the article" gnus-summary-beginning-of-article t]
1576 ["End of the article" gnus-summary-end-of-article t]
1577 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1578 ["Fetch referenced articles" gnus-summary-refer-references t]
1579 ["Fetch current thread" gnus-summary-refer-thread t]
1580 ["Fetch article with id..." gnus-summary-refer-article t]
1581 ["Redisplay" gnus-summary-show-article t])))
1583 gnus-summary-article-menu gnus-summary-mode-map ""
1584 (cons "Article" innards))
1587 gnus-article-commands-menu gnus-article-mode-map ""
1588 (cons "Commands" innards)))
1591 gnus-summary-thread-menu gnus-summary-mode-map ""
1593 ["Toggle threading" gnus-summary-toggle-threads t]
1594 ["Hide threads" gnus-summary-hide-all-threads t]
1595 ["Show threads" gnus-summary-show-all-threads t]
1596 ["Hide thread" gnus-summary-hide-thread t]
1597 ["Show thread" gnus-summary-show-thread t]
1598 ["Go to next thread" gnus-summary-next-thread t]
1599 ["Go to previous thread" gnus-summary-prev-thread t]
1600 ["Go down thread" gnus-summary-down-thread t]
1601 ["Go up thread" gnus-summary-up-thread t]
1602 ["Top of thread" gnus-summary-top-thread t]
1603 ["Mark thread as read" gnus-summary-kill-thread t]
1604 ["Lower thread score" gnus-summary-lower-thread t]
1605 ["Raise thread score" gnus-summary-raise-thread t]
1606 ["Rethread current" gnus-summary-rethread-current t]
1610 gnus-summary-post-menu gnus-summary-mode-map ""
1612 ["Post an article" gnus-summary-post-news t]
1613 ["Followup" gnus-summary-followup t]
1614 ["Followup and yank" gnus-summary-followup-with-original t]
1615 ["Supersede article" gnus-summary-supersede-article t]
1616 ["Cancel article" gnus-summary-cancel-article t]
1617 ["Reply" gnus-summary-reply t]
1618 ["Reply and yank" gnus-summary-reply-with-original t]
1619 ["Wide reply" gnus-summary-wide-reply t]
1620 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1621 ["Mail forward" gnus-summary-mail-forward t]
1622 ["Post forward" gnus-summary-post-forward t]
1623 ["Digest and mail" gnus-uu-digest-mail-forward t]
1624 ["Digest and post" gnus-uu-digest-post-forward t]
1625 ["Resend message" gnus-summary-resend-message t]
1626 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1627 ["Send a mail" gnus-summary-mail-other-window t]
1628 ["Uuencode and post" gnus-uu-post-news t]
1629 ["Followup via news" gnus-summary-followup-to-mail t]
1630 ["Followup via news and yank"
1631 gnus-summary-followup-to-mail-with-original t]
1633 ;;["Send" gnus-summary-send-draft t]
1634 ;;["Send bounced" gnus-resend-bounced-mail t])
1638 gnus-summary-misc-menu gnus-summary-mode-map ""
1641 ["Mark as read" gnus-summary-mark-as-read-forward t]
1642 ["Mark same subject and select"
1643 gnus-summary-kill-same-subject-and-select t]
1644 ["Mark same subject" gnus-summary-kill-same-subject t]
1645 ["Catchup" gnus-summary-catchup t]
1646 ["Catchup all" gnus-summary-catchup-all t]
1647 ["Catchup to here" gnus-summary-catchup-to-here t]
1648 ["Catchup region" gnus-summary-mark-region-as-read t]
1649 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1651 ["Tick" gnus-summary-tick-article-forward t]
1652 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1653 ["Remove marks" gnus-summary-clear-mark-forward t]
1654 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1655 ["Set bookmark" gnus-summary-set-bookmark t]
1656 ["Remove bookmark" gnus-summary-remove-bookmark t])
1658 ["Marks..." gnus-summary-limit-to-marks t]
1659 ["Subject..." gnus-summary-limit-to-subject t]
1660 ["Author..." gnus-summary-limit-to-author t]
1661 ["Age..." gnus-summary-limit-to-age t]
1662 ["Score" gnus-summary-limit-to-score t]
1663 ["Unread" gnus-summary-limit-to-unread t]
1664 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1665 ["Articles" gnus-summary-limit-to-articles t]
1666 ["Pop limit" gnus-summary-pop-limit t]
1667 ["Show dormant" gnus-summary-limit-include-dormant t]
1668 ["Hide childless dormant"
1669 gnus-summary-limit-exclude-childless-dormant t]
1670 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1671 ["Show expunged" gnus-summary-show-all-expunged t])
1673 ["Set mark" gnus-summary-mark-as-processable t]
1674 ["Remove mark" gnus-summary-unmark-as-processable t]
1675 ["Remove all marks" gnus-summary-unmark-all-processable t]
1676 ["Mark above" gnus-uu-mark-over t]
1677 ["Mark series" gnus-uu-mark-series t]
1678 ["Mark region" gnus-uu-mark-region t]
1679 ["Unmark region" gnus-uu-unmark-region t]
1680 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1681 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1682 ["Mark all" gnus-uu-mark-all t]
1683 ["Mark buffer" gnus-uu-mark-buffer t]
1684 ["Mark sparse" gnus-uu-mark-sparse t]
1685 ["Mark thread" gnus-uu-mark-thread t]
1686 ["Unmark thread" gnus-uu-unmark-thread t]
1687 ("Process Mark Sets"
1688 ["Kill" gnus-summary-kill-process-mark t]
1689 ["Yank" gnus-summary-yank-process-mark
1690 gnus-newsgroup-process-stack]
1691 ["Save" gnus-summary-save-process-mark t]))
1693 ["Page forward" gnus-summary-next-page t]
1694 ["Page backward" gnus-summary-prev-page t]
1695 ["Line forward" gnus-summary-scroll-up t])
1697 ["Next unread article" gnus-summary-next-unread-article t]
1698 ["Previous unread article" gnus-summary-prev-unread-article t]
1699 ["Next article" gnus-summary-next-article t]
1700 ["Previous article" gnus-summary-prev-article t]
1701 ["Next unread subject" gnus-summary-next-unread-subject t]
1702 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1703 ["Next article same subject" gnus-summary-next-same-subject t]
1704 ["Previous article same subject" gnus-summary-prev-same-subject t]
1705 ["First unread article" gnus-summary-first-unread-article t]
1706 ["Best unread article" gnus-summary-best-unread-article t]
1707 ["Go to subject number..." gnus-summary-goto-subject t]
1708 ["Go to article number..." gnus-summary-goto-article t]
1709 ["Go to the last article" gnus-summary-goto-last-article t]
1710 ["Pop article off history" gnus-summary-pop-article t])
1712 ["Sort by number" gnus-summary-sort-by-number t]
1713 ["Sort by author" gnus-summary-sort-by-author t]
1714 ["Sort by subject" gnus-summary-sort-by-subject t]
1715 ["Sort by date" gnus-summary-sort-by-date t]
1716 ["Sort by score" gnus-summary-sort-by-score t]
1717 ["Sort by lines" gnus-summary-sort-by-lines t])
1719 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1720 ["Describe group" gnus-summary-describe-group t]
1721 ["Read manual" gnus-info-find-node t])
1723 ["Pick and read" gnus-pick-mode t]
1724 ["Binary" gnus-binary-mode t])
1726 ["Regenerate" gnus-summary-prepare t]
1727 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1728 ["Toggle threading" gnus-summary-toggle-threads t])
1729 ["Filter articles..." gnus-summary-execute-command t]
1730 ["Run command on subjects..." gnus-summary-universal-argument t]
1731 ["Search articles forward..." gnus-summary-search-article-forward t]
1732 ["Search articles backward..." gnus-summary-search-article-backward t]
1733 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1734 ["Expand window" gnus-summary-expand-window t]
1735 ["Expire expirable articles" gnus-summary-expire-articles
1736 (gnus-check-backend-function
1737 'request-expire-articles gnus-newsgroup-name)]
1738 ["Edit local kill file" gnus-summary-edit-local-kill t]
1739 ["Edit main kill file" gnus-summary-edit-global-kill t]
1740 ["Edit group parameters" gnus-summary-edit-parameters t]
1742 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1743 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1744 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1745 ["Exit group" gnus-summary-exit t]
1746 ["Exit group without updating" gnus-summary-exit-no-update t]
1747 ["Exit and goto next group" gnus-summary-next-group t]
1748 ["Exit and goto prev group" gnus-summary-prev-group t]
1749 ["Reselect group" gnus-summary-reselect-current-group t]
1750 ["Rescan group" gnus-summary-rescan-group t]
1751 ["Update dribble" gnus-summary-save-newsrc t])))
1753 (gnus-run-hooks 'gnus-summary-menu-hook)))
1755 (defun gnus-score-set-default (var value)
1756 "A version of set that updates the GNU Emacs menu-bar."
1758 ;; It is the message that forces the active status to be updated.
1761 (defun gnus-make-score-map (type)
1762 "Make a summary score map of type TYPE."
1765 (let ((headers '(("author" "from" string)
1766 ("subject" "subject" string)
1767 ("article body" "body" string)
1768 ("article head" "head" string)
1769 ("xref" "xref" string)
1770 ("lines" "lines" number)
1771 ("followups to author" "followup" string)))
1772 (types '((number ("less than" <)
1775 (string ("substring" s)
1779 (perms '(("temporary" (current-time-string))
1787 (if (eq type 'lower)
1792 (setq header (car headers))
1798 (let ((ts (cdr (assoc (nth 2 header) types)))
1814 'gnus-summary-score-entry
1816 (if (or (string= (nth 1 header)
1818 (string= (nth 1 header)
1821 (list 'gnus-summary-header
1823 (list 'quote (nth 1 (car ts)))
1824 (list 'gnus-score-default nil)
1830 (list (nreverse outp))))
1833 (list (nreverse outt))))
1835 (setq headers (cdr headers)))
1836 (list (nreverse outh))))))))
1840 (defun gnus-summary-mode (&optional group)
1841 "Major mode for reading articles.
1843 All normal editing commands are switched off.
1844 \\<gnus-summary-mode-map>
1845 Each line in this buffer represents one article. To read an
1846 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1847 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1850 You can also post articles and send mail from this buffer. To
1851 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1852 of an article, type `\\[gnus-summary-reply]'.
1854 There are approx. one gazillion commands you can execute in this
1855 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1857 The following commands are available:
1859 \\{gnus-summary-mode-map}"
1861 (when (gnus-visual-p 'summary-menu 'menu)
1862 (gnus-summary-make-menu-bar))
1863 (kill-all-local-variables)
1864 (gnus-summary-make-local-variables)
1865 (gnus-make-thread-indent-array)
1866 (gnus-simplify-mode-line)
1867 (setq major-mode 'gnus-summary-mode)
1868 (setq mode-name "Summary")
1869 (make-local-variable 'minor-mode-alist)
1870 (use-local-map gnus-summary-mode-map)
1871 (buffer-disable-undo (current-buffer))
1872 (setq buffer-read-only t) ;Disable modification
1873 (setq truncate-lines t)
1874 (setq selective-display t)
1875 (setq selective-display-ellipses t) ;Display `...'
1876 (gnus-summary-set-display-table)
1877 (gnus-set-default-directory)
1878 (setq gnus-newsgroup-name group)
1879 (make-local-variable 'gnus-summary-line-format)
1880 (make-local-variable 'gnus-summary-line-format-spec)
1881 (make-local-variable 'gnus-summary-dummy-line-format)
1882 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1883 (make-local-variable 'gnus-summary-mark-positions)
1884 (make-local-hook 'post-command-hook)
1885 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1886 (make-local-hook 'pre-command-hook)
1887 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1888 (gnus-run-hooks 'gnus-summary-mode-hook)
1889 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1890 (gnus-update-summary-mark-positions))
1892 (defun gnus-summary-make-local-variables ()
1893 "Make all the local summary buffer variables."
1894 (let ((locals gnus-summary-local-variables)
1896 (while (setq local (pop locals))
1899 (if (eq (cdr local) 'global)
1900 ;; Copy the global value of the variable.
1901 (setq global (symbol-value (car local)))
1902 ;; Use the value from the list.
1903 (setq global (eval (cdr local))))
1904 (make-local-variable (car local))
1905 (set (car local) global))
1906 ;; Simple nil-valued local variable.
1907 (make-local-variable local)
1910 (defun gnus-summary-clear-local-variables ()
1911 (let ((locals gnus-summary-local-variables))
1913 (if (consp (car locals))
1914 (and (vectorp (caar locals))
1915 (set (caar locals) nil))
1916 (and (vectorp (car locals))
1917 (set (car locals) nil)))
1918 (setq locals (cdr locals)))))
1920 ;; Summary data functions.
1922 (defmacro gnus-data-number (data)
1925 (defmacro gnus-data-set-number (data number)
1926 `(setcar ,data ,number))
1928 (defmacro gnus-data-mark (data)
1931 (defmacro gnus-data-set-mark (data mark)
1932 `(setcar (nthcdr 1 ,data) ,mark))
1934 (defmacro gnus-data-pos (data)
1937 (defmacro gnus-data-set-pos (data pos)
1938 `(setcar (nthcdr 2 ,data) ,pos))
1940 (defmacro gnus-data-header (data)
1943 (defmacro gnus-data-set-header (data header)
1944 `(setf (nth 3 ,data) ,header))
1946 (defmacro gnus-data-level (data)
1949 (defmacro gnus-data-unread-p (data)
1950 `(= (nth 1 ,data) gnus-unread-mark))
1952 (defmacro gnus-data-read-p (data)
1953 `(/= (nth 1 ,data) gnus-unread-mark))
1955 (defmacro gnus-data-pseudo-p (data)
1956 `(consp (nth 3 ,data)))
1958 (defmacro gnus-data-find (number)
1959 `(assq ,number gnus-newsgroup-data))
1961 (defmacro gnus-data-find-list (number &optional data)
1962 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1963 (memq (assq ,number bdata)
1966 (defmacro gnus-data-make (number mark pos header level)
1967 `(list ,number ,mark ,pos ,header ,level))
1969 (defun gnus-data-enter (after-article number mark pos header level offset)
1970 (let ((data (gnus-data-find-list after-article)))
1972 (error "No such article: %d" after-article))
1973 (setcdr data (cons (gnus-data-make number mark pos header level)
1975 (setq gnus-newsgroup-data-reverse nil)
1976 (gnus-data-update-list (cddr data) offset)))
1978 (defun gnus-data-enter-list (after-article list &optional offset)
1980 (let ((data (and after-article (gnus-data-find-list after-article)))
1982 (or data (not after-article) (error "No such article: %d" after-article))
1983 ;; Find the last element in the list to be spliced into the main
1986 (setq list (cdr list)))
1989 (setcdr list gnus-newsgroup-data)
1990 (setq gnus-newsgroup-data ilist)
1992 (gnus-data-update-list (cdr list) offset)))
1993 (setcdr list (cdr data))
1996 (gnus-data-update-list (cdr list) offset)))
1997 (setq gnus-newsgroup-data-reverse nil))))
1999 (defun gnus-data-remove (article &optional offset)
2000 (let ((data gnus-newsgroup-data))
2001 (if (= (gnus-data-number (car data)) article)
2003 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2004 gnus-newsgroup-data-reverse nil)
2006 (gnus-data-update-list gnus-newsgroup-data offset)))
2008 (when (= (gnus-data-number (cadr data)) article)
2009 (setcdr data (cddr data))
2011 (gnus-data-update-list (cdr data) offset))
2013 gnus-newsgroup-data-reverse nil))
2014 (setq data (cdr data))))))
2016 (defmacro gnus-data-list (backward)
2018 (or gnus-newsgroup-data-reverse
2019 (setq gnus-newsgroup-data-reverse
2020 (reverse gnus-newsgroup-data)))
2021 gnus-newsgroup-data))
2023 (defun gnus-data-update-list (data offset)
2024 "Add OFFSET to the POS of all data entries in DATA."
2026 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2027 (setq data (cdr data))))
2029 (defun gnus-data-compute-positions ()
2030 "Compute the positions of all articles."
2031 (let ((data gnus-newsgroup-data)
2034 (when (setq pos (text-property-any
2035 (point-min) (point-max)
2036 'gnus-number (gnus-data-number (car data))))
2037 (gnus-data-set-pos (car data) (+ pos 3)))
2038 (setq data (cdr data)))))
2040 (defun gnus-summary-article-pseudo-p (article)
2041 "Say whether this article is a pseudo article or not."
2042 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2044 (defmacro gnus-summary-article-sparse-p (article)
2045 "Say whether this article is a sparse article or not."
2046 `(memq ,article gnus-newsgroup-sparse))
2048 (defmacro gnus-summary-article-ancient-p (article)
2049 "Say whether this article is a sparse article or not."
2050 `(memq ,article gnus-newsgroup-ancient))
2052 (defun gnus-article-parent-p (number)
2053 "Say whether this article is a parent or not."
2054 (let ((data (gnus-data-find-list number)))
2055 (and (cdr data) ; There has to be an article after...
2056 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2057 (gnus-data-level (nth 1 data))))))
2059 (defun gnus-article-children (number)
2060 "Return a list of all children to NUMBER."
2061 (let* ((data (gnus-data-find-list number))
2062 (level (gnus-data-level (car data)))
2064 (setq data (cdr data))
2066 (= (gnus-data-level (car data)) (1+ level)))
2067 (push (gnus-data-number (car data)) children)
2068 (setq data (cdr data)))
2071 (defmacro gnus-summary-skip-intangible ()
2072 "If the current article is intangible, then jump to a different article."
2073 '(let ((to (get-text-property (point) 'gnus-intangible)))
2074 (and to (gnus-summary-goto-subject to))))
2076 (defmacro gnus-summary-article-intangible-p ()
2077 "Say whether this article is intangible or not."
2078 '(get-text-property (point) 'gnus-intangible))
2080 (defun gnus-article-read-p (article)
2081 "Say whether ARTICLE is read or not."
2082 (not (or (memq article gnus-newsgroup-marked)
2083 (memq article gnus-newsgroup-unreads)
2084 (memq article gnus-newsgroup-unselected)
2085 (memq article gnus-newsgroup-dormant))))
2087 ;; Some summary mode macros.
2089 (defmacro gnus-summary-article-number ()
2090 "The article number of the article on the current line.
2091 If there isn's an article number here, then we return the current
2094 (gnus-summary-skip-intangible)
2095 (or (get-text-property (point) 'gnus-number)
2096 (gnus-summary-last-subject))))
2098 (defmacro gnus-summary-article-header (&optional number)
2099 "Return the header of article NUMBER."
2100 `(gnus-data-header (gnus-data-find
2101 ,(or number '(gnus-summary-article-number)))))
2103 (defmacro gnus-summary-thread-level (&optional number)
2104 "Return the level of thread that starts with article NUMBER."
2105 `(if (and (eq gnus-summary-make-false-root 'dummy)
2106 (get-text-property (point) 'gnus-intangible))
2108 (gnus-data-level (gnus-data-find
2109 ,(or number '(gnus-summary-article-number))))))
2111 (defmacro gnus-summary-article-mark (&optional number)
2112 "Return the mark of article NUMBER."
2113 `(gnus-data-mark (gnus-data-find
2114 ,(or number '(gnus-summary-article-number)))))
2116 (defmacro gnus-summary-article-pos (&optional number)
2117 "Return the position of the line of article NUMBER."
2118 `(gnus-data-pos (gnus-data-find
2119 ,(or number '(gnus-summary-article-number)))))
2121 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2122 (defmacro gnus-summary-article-subject (&optional number)
2123 "Return current subject string or nil if nothing."
2126 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2127 '(gnus-data-header (assq (gnus-summary-article-number)
2128 gnus-newsgroup-data)))))
2131 (mail-header-subject headers))))
2133 (defmacro gnus-summary-article-score (&optional number)
2134 "Return current article score."
2135 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2136 gnus-newsgroup-scored))
2137 gnus-summary-default-score 0))
2139 (defun gnus-summary-article-children (&optional number)
2140 "Return a list of article numbers that are children of article NUMBER."
2141 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2142 (level (gnus-data-level (car data)))
2144 (while (and (setq data (cdr data))
2145 (> (setq l (gnus-data-level (car data))) level))
2146 (and (= (1+ level) l)
2147 (push (gnus-data-number (car data))
2149 (nreverse children)))
2151 (defun gnus-summary-article-parent (&optional number)
2152 "Return the article number of the parent of article NUMBER."
2153 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2154 (gnus-data-list t)))
2155 (level (gnus-data-level (car data))))
2157 () ; This is a root.
2158 ;; We search until we find an article with a level less than
2159 ;; this one. That function has to be the parent.
2160 (while (and (setq data (cdr data))
2161 (not (< (gnus-data-level (car data)) level))))
2162 (and data (gnus-data-number (car data))))))
2164 (defun gnus-unread-mark-p (mark)
2165 "Say whether MARK is the unread mark."
2166 (= mark gnus-unread-mark))
2168 (defun gnus-read-mark-p (mark)
2169 "Say whether MARK is one of the marks that mark as read.
2170 This is all marks except unread, ticked, dormant, and expirable."
2171 (not (or (= mark gnus-unread-mark)
2172 (= mark gnus-ticked-mark)
2173 (= mark gnus-dormant-mark)
2174 (= mark gnus-expirable-mark))))
2176 (defmacro gnus-article-mark (number)
2177 "Return the MARK of article NUMBER.
2178 This macro should only be used when computing the mark the \"first\"
2179 time; i.e., when generating the summary lines. After that,
2180 `gnus-summary-article-mark' should be used to examine the
2183 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2184 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2185 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2186 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2187 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2188 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2189 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2190 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2191 gnus-ancient-mark))))
2193 ;; Saving hidden threads.
2195 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2196 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2198 (defmacro gnus-save-hidden-threads (&rest forms)
2199 "Save hidden threads, eval FORMS, and restore the hidden threads."
2200 (let ((config (make-symbol "config")))
2201 `(let ((,config (gnus-hidden-threads-configuration)))
2205 (gnus-restore-hidden-threads-configuration ,config)))))
2207 (defun gnus-hidden-threads-configuration ()
2208 "Return the current hidden threads configuration."
2211 (goto-char (point-min))
2212 (while (search-forward "\r" nil t)
2213 (push (1- (point)) config))
2216 (defun gnus-restore-hidden-threads-configuration (config)
2217 "Restore hidden threads configuration from CONFIG."
2218 (let (point buffer-read-only)
2219 (while (setq point (pop config))
2220 (when (and (< point (point-max))
2222 (= (following-char) ?\n))
2223 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2225 ;; Various summary mode internalish functions.
2227 (defun gnus-mouse-pick-article (e)
2230 (gnus-summary-next-page nil t))
2232 (defun gnus-summary-set-display-table ()
2233 ;; Change the display table. Odd characters have a tendency to mess
2234 ;; up nicely formatted displays - we make all possible glyphs
2235 ;; display only a single character.
2237 ;; We start from the standard display table, if any.
2238 (let ((table (or (copy-sequence standard-display-table)
2239 (make-display-table)))
2241 ;; Nix out all the control chars...
2242 (while (>= (setq i (1- i)) 0)
2243 (aset table i [??]))
2244 ;; ... but not newline and cr, of course. (cr is necessary for the
2245 ;; selective display).
2246 (aset table ?\n nil)
2247 (aset table ?\r nil)
2248 ;; We keep TAB as well.
2249 (aset table ?\t nil)
2250 ;; We nix out any glyphs over 126 that are not set already.
2252 (while (>= (setq i (1- i)) 127)
2253 ;; Only modify if the entry is nil.
2254 (unless (aref table i)
2255 (aset table i [??]))))
2256 (setq buffer-display-table table)))
2258 (defun gnus-summary-setup-buffer (group)
2259 "Initialize summary buffer."
2260 (let ((buffer (concat "*Summary " group "*")))
2261 (if (get-buffer buffer)
2264 (setq gnus-summary-buffer (current-buffer))
2265 (not gnus-newsgroup-prepared))
2266 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2267 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2268 (gnus-add-current-to-buffer-list)
2269 (gnus-summary-mode group)
2271 (gnus-carpal-setup-buffer 'summary))
2272 (unless gnus-single-article-buffer
2273 (make-local-variable 'gnus-article-buffer)
2274 (make-local-variable 'gnus-article-current)
2275 (make-local-variable 'gnus-original-article-buffer))
2276 (setq gnus-newsgroup-name group)
2279 (defun gnus-set-global-variables ()
2280 ;; Set the global equivalents of the summary buffer-local variables
2281 ;; to the latest values they had. These reflect the summary buffer
2282 ;; that was in action when the last article was fetched.
2283 (when (eq major-mode 'gnus-summary-mode)
2284 (setq gnus-summary-buffer (current-buffer))
2285 (let ((name gnus-newsgroup-name)
2286 (marked gnus-newsgroup-marked)
2287 (unread gnus-newsgroup-unreads)
2288 (headers gnus-current-headers)
2289 (data gnus-newsgroup-data)
2290 (summary gnus-summary-buffer)
2291 (article-buffer gnus-article-buffer)
2292 (original gnus-original-article-buffer)
2293 (gac gnus-article-current)
2294 (reffed gnus-reffed-article-number)
2295 (score-file gnus-current-score-file))
2297 (set-buffer gnus-group-buffer)
2298 (setq gnus-newsgroup-name name
2299 gnus-newsgroup-marked marked
2300 gnus-newsgroup-unreads unread
2301 gnus-current-headers headers
2302 gnus-newsgroup-data data
2303 gnus-article-current gac
2304 gnus-summary-buffer summary
2305 gnus-article-buffer article-buffer
2306 gnus-original-article-buffer original
2307 gnus-reffed-article-number reffed
2308 gnus-current-score-file score-file)
2309 ;; The article buffer also has local variables.
2310 (when (gnus-buffer-live-p gnus-article-buffer)
2311 (set-buffer gnus-article-buffer)
2312 (setq gnus-summary-buffer summary))))))
2314 (defun gnus-summary-article-unread-p (article)
2315 "Say whether ARTICLE is unread or not."
2316 (memq article gnus-newsgroup-unreads))
2318 (defun gnus-summary-first-article-p (&optional article)
2319 "Return whether ARTICLE is the first article in the buffer."
2320 (if (not (setq article (or article (gnus-summary-article-number))))
2322 (eq article (caar gnus-newsgroup-data))))
2324 (defun gnus-summary-last-article-p (&optional article)
2325 "Return whether ARTICLE is the last article in the buffer."
2326 (if (not (setq article (or article (gnus-summary-article-number))))
2327 t ; All non-existent numbers are the last article. :-)
2328 (not (cdr (gnus-data-find-list article)))))
2330 (defun gnus-make-thread-indent-array ()
2332 (unless (and gnus-thread-indent-array
2333 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2334 (setq gnus-thread-indent-array (make-vector 201 "")
2335 gnus-thread-indent-array-level gnus-thread-indent-level)
2337 (aset gnus-thread-indent-array n
2338 (make-string (* n gnus-thread-indent-level) ? ))
2341 (defun gnus-update-summary-mark-positions ()
2342 "Compute where the summary marks are to go."
2344 (when (gnus-buffer-exists-p gnus-summary-buffer)
2345 (set-buffer gnus-summary-buffer))
2346 (let ((gnus-replied-mark 129)
2347 (gnus-score-below-mark 130)
2348 (gnus-score-over-mark 130)
2349 (gnus-download-mark 131)
2350 (spec gnus-summary-line-format-spec)
2351 thread gnus-visual pos)
2353 (gnus-set-work-buffer)
2354 (let ((gnus-summary-line-format-spec spec)
2355 (gnus-newsgroup-downloadable '((0 . t))))
2356 (gnus-summary-insert-line
2357 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2358 (goto-char (point-min))
2359 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2361 (goto-char (point-min))
2362 (push (cons 'replied (and (search-forward "\201" nil t)
2365 (goto-char (point-min))
2366 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2368 (goto-char (point-min))
2369 (push (cons 'download
2370 (and (search-forward "\203" nil t) (- (point) 2)))
2372 (setq gnus-summary-mark-positions pos))))
2374 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2375 "Insert a dummy root in the summary buffer."
2377 (gnus-add-text-properties
2378 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2379 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2381 (defun gnus-summary-insert-line (gnus-tmp-header
2382 gnus-tmp-level gnus-tmp-current
2383 gnus-tmp-unread gnus-tmp-replied
2384 gnus-tmp-expirable gnus-tmp-subject-or-nil
2385 &optional gnus-tmp-dummy gnus-tmp-score
2387 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2388 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2389 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2390 (gnus-tmp-score-char
2391 (if (or (null gnus-summary-default-score)
2392 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2393 gnus-summary-zcore-fuzz))
2395 (if (< gnus-tmp-score gnus-summary-default-score)
2396 gnus-score-below-mark gnus-score-over-mark)))
2398 (cond (gnus-tmp-process gnus-process-mark)
2399 ((memq gnus-tmp-current gnus-newsgroup-cached)
2401 (gnus-tmp-replied gnus-replied-mark)
2402 ((memq gnus-tmp-current gnus-newsgroup-saved)
2404 (t gnus-unread-mark)))
2405 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2408 ((string-match "<[^>]+> *$" gnus-tmp-from)
2409 (let ((beg (match-beginning 0)))
2410 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2411 (substring gnus-tmp-from (1+ (match-beginning 0))
2412 (1- (match-end 0))))
2413 (substring gnus-tmp-from 0 beg))))
2414 ((string-match "(.+)" gnus-tmp-from)
2415 (substring gnus-tmp-from
2416 (1+ (match-beginning 0)) (1- (match-end 0))))
2418 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2419 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2420 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2421 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2422 (buffer-read-only nil))
2423 (when (string= gnus-tmp-name "")
2424 (setq gnus-tmp-name gnus-tmp-from))
2425 (unless (numberp gnus-tmp-lines)
2426 (setq gnus-tmp-lines 0))
2427 (gnus-put-text-property
2429 (progn (eval gnus-summary-line-format-spec) (point))
2430 'gnus-number gnus-tmp-number)
2431 (when (gnus-visual-p 'summary-highlight 'highlight)
2433 (gnus-run-hooks 'gnus-summary-update-hook)
2436 (defun gnus-summary-update-line (&optional dont-update)
2437 ;; Update summary line after change.
2438 (when (and gnus-summary-default-score
2439 (not gnus-summary-inhibit-highlight))
2440 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2441 (article (gnus-summary-article-number))
2442 (score (gnus-summary-article-score article)))
2444 (if (and gnus-summary-mark-below
2445 (< (gnus-summary-article-score)
2446 gnus-summary-mark-below))
2447 ;; This article has a low score, so we mark it as read.
2448 (when (memq article gnus-newsgroup-unreads)
2449 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2450 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2451 ;; This article was previously marked as read on account
2452 ;; of a low score, but now it has risen, so we mark it as
2454 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2455 (gnus-summary-update-mark
2456 (if (or (null gnus-summary-default-score)
2457 (<= (abs (- score gnus-summary-default-score))
2458 gnus-summary-zcore-fuzz))
2460 (if (< score gnus-summary-default-score)
2461 gnus-score-below-mark gnus-score-over-mark))
2463 ;; Do visual highlighting.
2464 (when (gnus-visual-p 'summary-highlight 'highlight)
2465 (gnus-run-hooks 'gnus-summary-update-hook)))))
2467 (defvar gnus-tmp-new-adopts nil)
2469 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2470 "Return the number of articles in THREAD.
2471 This may be 0 in some cases -- if none of the articles in
2472 the thread are to be displayed."
2474 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2476 ((not (listp thread))
2478 ((and (consp thread) (cdr thread))
2481 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2484 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2487 (when (and level (zerop level) gnus-tmp-new-adopts)
2490 'gnus-summary-number-of-articles-in-thread
2491 gnus-tmp-new-adopts))))
2493 (if (> number 1) gnus-not-empty-thread-mark
2494 gnus-empty-thread-mark)
2497 (defun gnus-summary-set-local-parameters (group)
2498 "Go through the local params of GROUP and set all variable specs in that list."
2499 (let ((params (gnus-group-find-parameter group))
2502 (setq elem (car params)
2503 params (cdr params))
2504 (and (consp elem) ; Has to be a cons.
2505 (consp (cdr elem)) ; The cdr has to be a list.
2506 (symbolp (car elem)) ; Has to be a symbol in there.
2507 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2508 (ignore-errors ; So we set it.
2509 (make-local-variable (car elem))
2510 (set (car elem) (eval (nth 1 elem))))))))
2512 (defun gnus-summary-read-group (group &optional show-all no-article
2513 kill-buffer no-display backward)
2514 "Start reading news in newsgroup GROUP.
2515 If SHOW-ALL is non-nil, already read articles are also listed.
2516 If NO-ARTICLE is non-nil, no article is selected initially.
2517 If NO-DISPLAY, don't generate a summary buffer."
2521 (let ((gnus-auto-select-next nil))
2522 (or (gnus-summary-read-group-1
2523 group show-all no-article
2524 kill-buffer no-display)
2525 (setq show-all nil)))))
2526 (eq gnus-auto-select-next 'quietly))
2527 (set-buffer gnus-group-buffer)
2528 ;; The entry function called above goes to the next
2529 ;; group automatically, so we go two groups back
2530 ;; if we are searching for the previous group.
2532 (gnus-group-prev-unread-group 2))
2533 (if (not (equal group (gnus-group-group-name)))
2534 (setq group (gnus-group-group-name))
2538 (defun gnus-summary-read-group-1 (group show-all no-article
2539 kill-buffer no-display)
2540 ;; Killed foreign groups can't be entered.
2541 (when (and (not (gnus-group-native-p group))
2542 (not (gnus-gethash group gnus-newsrc-hashtb)))
2543 (error "Dead non-native groups can't be entered"))
2544 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2545 (let* ((new-group (gnus-summary-setup-buffer group))
2546 (quit-config (gnus-group-quit-config group))
2547 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2549 ;; This summary buffer exists already, so we just select it.
2551 (gnus-set-global-variables)
2553 (gnus-kill-or-deaden-summary kill-buffer))
2554 (gnus-configure-windows 'summary 'force)
2555 (gnus-set-mode-line 'summary)
2556 (gnus-summary-position-point)
2559 ;; We couldn't select this group.
2561 (when (and (eq major-mode 'gnus-summary-mode)
2562 (not (equal (current-buffer) kill-buffer)))
2563 (kill-buffer (current-buffer))
2564 (if (not quit-config)
2566 ;; Update the info -- marks might need to be removed,
2568 (gnus-summary-update-info)
2569 (set-buffer gnus-group-buffer)
2570 (gnus-group-jump-to-group group)
2571 (gnus-group-next-unread-group 1))
2572 (gnus-handle-ephemeral-exit quit-config)))
2573 (gnus-message 3 "Can't select group")
2575 ;; The user did a `C-g' while prompting for number of articles,
2576 ;; so we exit this group.
2577 ((eq did-select 'quit)
2578 (and (eq major-mode 'gnus-summary-mode)
2579 (not (equal (current-buffer) kill-buffer))
2580 (kill-buffer (current-buffer)))
2582 (gnus-kill-or-deaden-summary kill-buffer))
2583 (if (not quit-config)
2585 (set-buffer gnus-group-buffer)
2586 (gnus-group-jump-to-group group)
2587 (gnus-group-next-unread-group 1)
2588 (gnus-configure-windows 'group 'force))
2589 (gnus-handle-ephemeral-exit quit-config))
2590 ;; Finally signal the quit.
2592 ;; The group was successfully selected.
2594 (gnus-set-global-variables)
2595 ;; Save the active value in effect when the group was entered.
2596 (setq gnus-newsgroup-active
2598 (gnus-active gnus-newsgroup-name)))
2599 ;; You can change the summary buffer in some way with this hook.
2600 (gnus-run-hooks 'gnus-select-group-hook)
2601 ;; Set any local variables in the group parameters.
2602 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2603 (gnus-update-format-specifications
2604 nil 'summary 'summary-mode 'summary-dummy)
2605 ;; Do score processing.
2606 (when gnus-use-scoring
2607 (gnus-possibly-score-headers))
2608 ;; Check whether to fill in the gaps in the threads.
2609 (when gnus-build-sparse-threads
2610 (gnus-build-sparse-threads))
2611 ;; Find the initial limit.
2612 (if gnus-show-threads
2614 (let ((gnus-newsgroup-dormant nil))
2615 (gnus-summary-initial-limit show-all))
2616 (gnus-summary-initial-limit show-all))
2617 (setq gnus-newsgroup-limit
2619 (lambda (header) (mail-header-number header))
2620 gnus-newsgroup-headers)))
2621 ;; Generate the summary buffer.
2623 (gnus-summary-prepare))
2624 (when gnus-use-trees
2625 (gnus-tree-open group)
2626 (setq gnus-summary-highlight-line-function
2627 'gnus-tree-highlight-article))
2628 ;; If the summary buffer is empty, but there are some low-scored
2629 ;; articles or some excluded dormants, we include these in the
2631 (when (and (zerop (buffer-size))
2633 (cond (gnus-newsgroup-dormant
2634 (gnus-summary-limit-include-dormant))
2635 ((and gnus-newsgroup-scored show-all)
2636 (gnus-summary-limit-include-expunged t))))
2637 ;; Function `gnus-apply-kill-file' must be called in this hook.
2638 (gnus-run-hooks 'gnus-apply-kill-hook)
2639 (if (and (zerop (buffer-size))
2642 ;; This newsgroup is empty.
2643 (gnus-summary-catchup-and-exit nil t)
2644 (gnus-message 6 "No unread news")
2646 (gnus-kill-or-deaden-summary kill-buffer))
2647 ;; Return nil from this function.
2649 ;; Hide conversation thread subtrees. We cannot do this in
2650 ;; gnus-summary-prepare-hook since kill processing may not
2651 ;; work with hidden articles.
2652 (and gnus-show-threads
2653 gnus-thread-hide-subtree
2654 (gnus-summary-hide-all-threads))
2656 (gnus-kill-or-deaden-summary kill-buffer))
2657 ;; Show first unread article if requested.
2658 (if (and (not no-article)
2660 gnus-newsgroup-unreads
2661 gnus-auto-select-first)
2662 (unless (if (eq gnus-auto-select-first 'best)
2663 (gnus-summary-best-unread-article)
2664 (gnus-summary-first-unread-article))
2665 (gnus-configure-windows 'summary))
2666 ;; Don't select any articles, just move point to the first
2667 ;; article in the group.
2668 (goto-char (point-min))
2669 (gnus-summary-position-point)
2670 (gnus-configure-windows 'summary 'force)
2671 (gnus-set-mode-line 'summary))
2672 (when (get-buffer-window gnus-group-buffer t)
2673 ;; Gotta use windows, because recenter does weird stuff if
2674 ;; the current buffer ain't the displayed window.
2675 (let ((owin (selected-window)))
2676 (select-window (get-buffer-window gnus-group-buffer t))
2677 (when (gnus-group-goto-group group)
2679 (select-window owin)))
2680 ;; Mark this buffer as "prepared".
2681 (setq gnus-newsgroup-prepared t)
2682 (gnus-run-hooks 'gnus-summary-prepared-hook)
2685 (defun gnus-summary-prepare ()
2686 "Generate the summary buffer."
2688 (let ((buffer-read-only nil))
2690 (setq gnus-newsgroup-data nil
2691 gnus-newsgroup-data-reverse nil)
2692 (gnus-run-hooks 'gnus-summary-generate-hook)
2693 ;; Generate the buffer, either with threads or without.
2694 (when gnus-newsgroup-headers
2695 (gnus-summary-prepare-threads
2696 (if gnus-show-threads
2697 (gnus-sort-gathered-threads
2698 (funcall gnus-summary-thread-gathering-function
2700 (gnus-cut-threads (gnus-make-threads)))))
2701 ;; Unthreaded display.
2702 (gnus-sort-articles gnus-newsgroup-headers))))
2703 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2704 ;; Call hooks for modifying summary buffer.
2705 (goto-char (point-min))
2706 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2708 (defsubst gnus-general-simplify-subject (subject)
2709 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2712 ;; Truncate the subject.
2713 (gnus-simplify-subject-functions
2714 (gnus-map-function gnus-simplify-subject-functions subject))
2715 ((numberp gnus-summary-gather-subject-limit)
2716 (setq subject (gnus-simplify-subject-re subject))
2717 (if (> (length subject) gnus-summary-gather-subject-limit)
2718 (substring subject 0 gnus-summary-gather-subject-limit)
2720 ;; Fuzzily simplify it.
2721 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2722 (gnus-simplify-subject-fuzzy subject))
2723 ;; Just remove the leading "Re:".
2725 (gnus-simplify-subject-re subject))))
2727 (if (and gnus-summary-gather-exclude-subject
2728 (string-match gnus-summary-gather-exclude-subject subject))
2729 nil ; This article shouldn't be gathered
2732 (defun gnus-summary-simplify-subject-query ()
2733 "Query where the respool algorithm would put this article."
2735 (gnus-summary-select-article)
2736 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2738 (defun gnus-gather-threads-by-subject (threads)
2739 "Gather threads by looking at Subject headers."
2740 (if (not gnus-summary-make-false-root)
2742 (let ((hashtb (gnus-make-hashtable 1024))
2745 subject hthread whole-subject)
2747 (setq subject (gnus-general-simplify-subject
2748 (setq whole-subject (mail-header-subject
2751 (if (setq hthread (gnus-gethash subject hashtb))
2753 ;; We enter a dummy root into the thread, if we
2754 ;; haven't done that already.
2755 (unless (stringp (caar hthread))
2756 (setcar hthread (list whole-subject (car hthread))))
2757 ;; We add this new gathered thread to this gathered
2759 (setcdr (car hthread)
2760 (nconc (cdar hthread) (list (car threads))))
2761 ;; Remove it from the list of threads.
2762 (setcdr prev (cdr threads))
2763 (setq threads prev))
2764 ;; Enter this thread into the hash table.
2765 (gnus-sethash subject threads hashtb)))
2767 (setq threads (cdr threads)))
2770 (defun gnus-gather-threads-by-references (threads)
2771 "Gather threads by looking at References headers."
2772 (let ((idhashtb (gnus-make-hashtable 1024))
2773 (thhashtb (gnus-make-hashtable 1024))
2776 ids references id gthread gid entered ref)
2778 (when (setq references (mail-header-references (caar threads)))
2779 (setq id (mail-header-id (caar threads))
2780 ids (gnus-split-references references)
2782 (while (setq ref (pop ids))
2783 (setq ids (delete ref ids))
2784 (if (not (setq gid (gnus-gethash ref idhashtb)))
2786 (gnus-sethash ref id idhashtb)
2787 (gnus-sethash id threads thhashtb))
2788 (setq gthread (gnus-gethash gid thhashtb))
2790 ;; We enter a dummy root into the thread, if we
2791 ;; haven't done that already.
2792 (unless (stringp (caar gthread))
2793 (setcar gthread (list (mail-header-subject (caar gthread))
2795 ;; We add this new gathered thread to this gathered
2797 (setcdr (car gthread)
2798 (nconc (cdar gthread) (list (car threads)))))
2799 ;; Add it into the thread hash table.
2800 (gnus-sethash id gthread thhashtb)
2802 ;; Remove it from the list of threads.
2803 (setcdr prev (cdr threads))
2804 (setq threads prev))))
2806 (setq threads (cdr threads)))
2809 (defun gnus-sort-gathered-threads (threads)
2810 "Sort subtreads inside each gathered thread by article number."
2811 (let ((result threads))
2813 (when (stringp (caar threads))
2814 (setcdr (car threads)
2815 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2816 (setq threads (cdr threads)))
2819 (defun gnus-thread-loop-p (root thread)
2820 "Say whether ROOT is in THREAD."
2821 (let ((stack (list thread))
2824 (while (setq thread (pop stack))
2825 (setq th (cdr thread))
2827 (not (eq (caar th) root)))
2830 ;; We have found a loop.
2832 (setcdr thread (delq (car th) (cdr thread)))
2833 (if (boundp (setq ref-dep (intern "none"
2834 gnus-newsgroup-dependencies)))
2835 (setcdr (symbol-value ref-dep)
2836 (nconc (cdr (symbol-value ref-dep))
2838 (set ref-dep (list nil (car th))))
2841 ;; Push all the subthreads onto the stack.
2842 (push (cdr thread) stack)))
2845 (defun gnus-make-threads ()
2846 "Go through the dependency hashtb and find the roots. Return all threads."
2848 (while (catch 'infloop
2851 ;; Deal with self-referencing References loops.
2852 (when (and (car (symbol-value refs))
2859 (car (symbol-value refs)) thread))
2860 (cdr (symbol-value refs)))))))
2863 (unless (car (symbol-value refs))
2864 ;; These threads do not refer back to any other articles,
2865 ;; so they're roots.
2866 (setq threads (append (cdr (symbol-value refs)) threads))))
2867 gnus-newsgroup-dependencies)))
2870 (defun gnus-build-sparse-threads ()
2871 (let ((headers gnus-newsgroup-headers)
2872 (deps gnus-newsgroup-dependencies)
2873 header references generation relations
2874 cthread subject child end pthread relation new-child children)
2875 ;; First we create an alist of generations/relations, where
2876 ;; generations is how much we trust the relation, and the relation
2878 (gnus-message 7 "Making sparse threads...")
2880 (nnheader-set-temp-buffer " *gnus sparse threads*")
2881 (while (setq header (pop headers))
2882 (when (and (setq references (mail-header-references header))
2883 (not (string= references "")))
2885 (setq child (mail-header-id header)
2886 subject (mail-header-subject header))
2888 (while (search-backward ">" nil t)
2889 (setq end (1+ (point)))
2890 (when (search-backward "<" nil t)
2891 ;; This is a rather weak for of loop-checking, but if
2892 ;; an article contains the same Message-ID twice in
2893 ;; the References header, this will catch it. I haven't
2894 ;; considered other forms of thread loop preventions,
2895 ;; though -- I think one should probably go through
2896 ;; the entire thread after building it and break
2897 ;; any loops that are found.
2898 (unless (member (setq new-child (buffer-substring (point) end))
2900 (push (list (incf generation)
2901 child (setq child new-child)
2904 (push child children))))
2905 (push (list (1+ generation) child nil subject) relations)
2907 (kill-buffer (current-buffer)))
2908 ;; Sort over trustworthiness.
2909 (setq relations (sort relations 'car-less-than-car))
2910 (while (setq relation (pop relations))
2911 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2912 (unless (car (symbol-value cthread))
2913 ;; Make this article the parent of these threads.
2914 (setcar (symbol-value cthread)
2915 (vector gnus-reffed-article-number
2919 (or (caddr relation) "") 0 0 "")))
2920 (set cthread (list (vector gnus-reffed-article-number
2922 "" "" (cadr relation)
2923 (or (caddr relation) "") 0 0 ""))))
2924 (push gnus-reffed-article-number gnus-newsgroup-limit)
2925 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2926 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2927 gnus-newsgroup-reads)
2928 (decf gnus-reffed-article-number)
2929 ;; Make this new thread the child of its parent.
2930 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2931 (setcdr (symbol-value pthread)
2932 (nconc (cdr (symbol-value pthread))
2933 (list (symbol-value cthread))))
2934 (set pthread (list nil (symbol-value cthread))))))
2935 (gnus-message 7 "Making sparse threads...done")))
2937 (defun gnus-build-old-threads ()
2938 ;; Look at all the articles that refer back to old articles, and
2939 ;; fetch the headers for the articles that aren't there. This will
2940 ;; build complete threads - if the roots haven't been expired by the
2945 (when (not (car (symbol-value refs)))
2946 (setq heads (cdr (symbol-value refs)))
2948 (if (memq (mail-header-number (caar heads))
2949 gnus-newsgroup-dormant)
2950 (setq heads (cdr heads))
2951 (setq id (symbol-name refs))
2952 (while (and (setq id (gnus-build-get-header id))
2953 (not (car (gnus-gethash
2954 id gnus-newsgroup-dependencies)))))
2955 (setq heads nil)))))
2956 gnus-newsgroup-dependencies)))
2958 (defun gnus-build-get-header (id)
2959 ;; Look through the buffer of NOV lines and find the header to
2960 ;; ID. Enter this line into the dependencies hash table, and return
2961 ;; the id of the parent article (if any).
2962 (let ((deps gnus-newsgroup-dependencies)
2966 (set-buffer nntp-server-buffer)
2967 (let ((case-fold-search nil))
2968 (goto-char (point-min))
2969 (while (and (not found)
2970 (search-forward id nil t))
2972 (setq found (looking-at
2973 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2974 (regexp-quote id))))
2975 (or found (beginning-of-line 2)))
2979 (setq header (gnus-nov-parse-line
2980 (read (current-buffer)) deps))
2981 (gnus-parent-id (mail-header-references header))))))
2983 (let ((number (mail-header-number header)))
2984 (push number gnus-newsgroup-limit)
2985 (push header gnus-newsgroup-headers)
2986 (if (memq number gnus-newsgroup-unselected)
2988 (push number gnus-newsgroup-unreads)
2989 (setq gnus-newsgroup-unselected
2990 (delq number gnus-newsgroup-unselected)))
2991 (push number gnus-newsgroup-ancient)))))))
2993 (defun gnus-build-all-threads ()
2994 "Read all the headers."
2995 (let ((deps gnus-newsgroup-dependencies)
2996 (gnus-summary-ignore-duplicates t)
2997 found header article)
2999 (set-buffer nntp-server-buffer)
3000 (let ((case-fold-search nil))
3001 (goto-char (point-min))
3004 (setq article (read (current-buffer)))
3005 (setq header (gnus-nov-parse-line article deps)))
3007 (push header gnus-newsgroup-headers)
3008 (if (memq (setq article (mail-header-number header))
3009 gnus-newsgroup-unselected)
3011 (push article gnus-newsgroup-unreads)
3012 (setq gnus-newsgroup-unselected
3013 (delq article gnus-newsgroup-unselected)))
3014 (push article gnus-newsgroup-ancient))
3015 (forward-line 1)))))))
3017 (defun gnus-summary-update-article-line (article header)
3018 "Update the line for ARTICLE using HEADERS."
3019 (let* ((id (mail-header-id header))
3020 (thread (gnus-id-to-thread id)))
3022 (error "Article in no thread"))
3023 ;; Update the thread.
3024 (setcar thread header)
3025 (gnus-summary-goto-subject article)
3026 (let* ((datal (gnus-data-find-list article))
3028 (length (when (cdr datal)
3029 (- (gnus-data-pos data)
3030 (gnus-data-pos (cadr datal)))))
3031 (buffer-read-only nil)
3032 (level (gnus-summary-thread-level)))
3034 (gnus-summary-insert-line
3035 header level nil (gnus-article-mark article)
3036 (memq article gnus-newsgroup-replied)
3037 (memq article gnus-newsgroup-expirable)
3038 ;; Only insert the Subject string when it's different
3039 ;; from the previous Subject string.
3040 (if (gnus-subject-equal
3042 (mail-header-subject
3045 (gnus-data-find-list
3047 (gnus-data-list t)))))
3048 ;; Error on the side of excessive subjects.
3050 (mail-header-subject header))
3052 (mail-header-subject header))
3053 nil (cdr (assq article gnus-newsgroup-scored))
3054 (memq article gnus-newsgroup-processable))
3056 (gnus-data-update-list
3057 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3059 (defun gnus-summary-update-article (article &optional iheader)
3060 "Update ARTICLE in the summary buffer."
3061 (set-buffer gnus-summary-buffer)
3062 (let* ((header (or iheader (gnus-summary-article-header article)))
3063 (id (mail-header-id header))
3064 (data (gnus-data-find article))
3065 (thread (gnus-id-to-thread id))
3066 (references (mail-header-references header))
3070 (when (and references
3071 (not (equal "" references)))
3074 (buffer-read-only nil)
3076 (number (mail-header-number header))
3079 ;; !!! Should this be in or not?
3081 (setcar thread nil))
3083 (delq thread parent))
3084 (if (gnus-summary-insert-subject id header iheader)
3085 ;; Set the (possibly) new article number in the data structure.
3086 (gnus-data-set-number data (gnus-id-to-article id))
3090 (defun gnus-rebuild-thread (id)
3091 "Rebuild the thread containing ID."
3092 (let ((buffer-read-only nil)
3093 old-pos current thread data)
3094 (if (not gnus-show-threads)
3095 (setq thread (list (car (gnus-id-to-thread id))))
3096 ;; Get the thread this article is part of.
3097 (setq thread (gnus-remove-thread id)))
3098 (setq old-pos (gnus-point-at-bol))
3099 (setq current (save-excursion
3100 (and (zerop (forward-line -1))
3101 (gnus-summary-article-number))))
3102 ;; If this is a gathered thread, we have to go some re-gathering.
3103 (when (stringp (car thread))
3104 (let ((subject (car thread))
3106 (setq thread (cdr thread))
3108 (unless (memq (setq thr (gnus-id-to-thread
3110 (mail-header-id (caar thread)))))
3113 (setq thread (cdr thread)))
3114 ;; We now have all (unique) roots.
3115 (if (= (length roots) 1)
3116 ;; All the loose roots are now one solid root.
3117 (setq thread (car roots))
3118 (setq thread (cons subject (gnus-sort-threads roots))))))
3120 ;; We then insert this thread into the summary buffer.
3121 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3122 (if gnus-show-threads
3123 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3124 (gnus-summary-prepare-unthreaded thread))
3125 (setq data (nreverse gnus-newsgroup-data))
3126 (setq threads gnus-newsgroup-threads))
3127 ;; We splice the new data into the data structure.
3128 (gnus-data-enter-list current data (- (point) old-pos))
3129 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3131 (defun gnus-number-to-header (number)
3132 "Return the header for article NUMBER."
3133 (let ((headers gnus-newsgroup-headers))
3135 (not (= number (mail-header-number (car headers)))))
3140 (defun gnus-parent-headers (in-headers &optional generation)
3141 "Return the headers of the GENERATIONeth parent of HEADERS."
3143 (setq generation 1))
3145 (headers in-headers)
3149 (not (zerop generation))
3150 (setq references (mail-header-references headers)))
3151 (when (and references
3152 (setq parent (gnus-parent-id references))
3153 (setq headers (car (gnus-id-to-thread parent))))
3155 (and (not (eq headers in-headers))
3158 (defun gnus-id-to-thread (id)
3159 "Return the (sub-)thread where ID appears."
3160 (gnus-gethash id gnus-newsgroup-dependencies))
3162 (defun gnus-id-to-article (id)
3163 "Return the article number of ID."
3164 (let ((thread (gnus-id-to-thread id)))
3167 (mail-header-number (car thread)))))
3169 (defun gnus-id-to-header (id)
3170 "Return the article headers of ID."
3171 (car (gnus-id-to-thread id)))
3173 (defun gnus-article-displayed-root-p (article)
3174 "Say whether ARTICLE is a root(ish) article."
3175 (let ((level (gnus-summary-thread-level article))
3176 (refs (mail-header-references (gnus-summary-article-header article)))
3182 ((null (gnus-parent-id refs)) t)
3184 (null (setq particle (gnus-id-to-article
3185 (gnus-parent-id refs))))
3186 (null (gnus-summary-thread-level particle)))))))
3188 (defun gnus-root-id (id)
3189 "Return the id of the root of the thread where ID appears."
3191 (while (and id (setq prev (car (gnus-gethash
3192 id gnus-newsgroup-dependencies))))
3194 id (gnus-parent-id (mail-header-references prev))))
3197 (defun gnus-articles-in-thread (thread)
3198 "Return the list of articles in THREAD."
3199 (cons (mail-header-number (car thread))
3200 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3202 (defun gnus-remove-thread (id &optional dont-remove)
3203 "Remove the thread that has ID in it."
3204 (let ((dep gnus-newsgroup-dependencies)
3205 headers thread last-id)
3206 ;; First go up in this thread until we find the root.
3207 (setq last-id (gnus-root-id id))
3208 (setq headers (list (car (gnus-id-to-thread last-id))
3209 (caadr (gnus-id-to-thread last-id))))
3210 ;; We have now found the real root of this thread. It might have
3211 ;; been gathered into some loose thread, so we have to search
3212 ;; through the threads to find the thread we wanted.
3213 (let ((threads gnus-newsgroup-threads)
3216 (setq sub (car threads))
3217 (if (stringp (car sub))
3218 ;; This is a gathered thread, so we look at the roots
3219 ;; below it to find whether this article is in this
3222 (setq sub (cdr sub))
3224 (when (member (caar sub) headers)
3225 (setq thread (car threads)
3228 (setq sub (cdr sub))))
3229 ;; It's an ordinary thread, so we check it.
3230 (when (eq (car sub) (car headers))
3233 (setq threads (cdr threads)))
3234 ;; If this article is in no thread, then it's a root.
3237 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3238 (setq thread (gnus-gethash last-id dep)))
3241 thread ; We return this thread.
3243 (if (stringp (car thread))
3245 ;; If we use dummy roots, then we have to remove the
3246 ;; dummy root as well.
3247 (when (eq gnus-summary-make-false-root 'dummy)
3248 ;; We go to the dummy root by going to
3249 ;; the first sub-"thread", and then one line up.
3250 (gnus-summary-goto-article
3251 (mail-header-number (caadr thread)))
3254 (gnus-data-compute-positions))
3255 (setq thread (cdr thread))
3257 (gnus-remove-thread-1 (car thread))
3258 (setq thread (cdr thread))))
3259 (gnus-remove-thread-1 thread))))))))
3261 (defun gnus-remove-thread-1 (thread)
3262 "Remove the thread THREAD recursively."
3263 (let ((number (mail-header-number (pop thread)))
3265 (setq thread (reverse thread))
3267 (gnus-remove-thread-1 (pop thread)))
3268 (when (setq d (gnus-data-find number))
3269 (goto-char (gnus-data-pos d))
3272 (- (gnus-point-at-bol)
3274 (1+ (gnus-point-at-eol))
3275 (gnus-delete-line)))))))
3277 (defun gnus-sort-threads (threads)
3279 (if (not gnus-thread-sort-functions)
3281 (gnus-message 7 "Sorting threads...")
3283 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3284 (gnus-message 7 "Sorting threads...done"))))
3286 (defun gnus-sort-articles (articles)
3288 (when gnus-article-sort-functions
3289 (gnus-message 7 "Sorting articles...")
3291 (setq gnus-newsgroup-headers
3292 (sort articles (gnus-make-sort-function
3293 gnus-article-sort-functions)))
3294 (gnus-message 7 "Sorting articles...done"))))
3296 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3297 (defmacro gnus-thread-header (thread)
3298 ;; Return header of first article in THREAD.
3299 ;; Note that THREAD must never, ever be anything else than a variable -
3300 ;; using some other form will lead to serious barfage.
3301 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3302 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3303 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3306 (defsubst gnus-article-sort-by-number (h1 h2)
3307 "Sort articles by article number."
3308 (< (mail-header-number h1)
3309 (mail-header-number h2)))
3311 (defun gnus-thread-sort-by-number (h1 h2)
3312 "Sort threads by root article number."
3313 (gnus-article-sort-by-number
3314 (gnus-thread-header h1) (gnus-thread-header h2)))
3316 (defsubst gnus-article-sort-by-lines (h1 h2)
3317 "Sort articles by article Lines header."
3318 (< (mail-header-lines h1)
3319 (mail-header-lines h2)))
3321 (defun gnus-thread-sort-by-lines (h1 h2)
3322 "Sort threads by root article Lines header."
3323 (gnus-article-sort-by-lines
3324 (gnus-thread-header h1) (gnus-thread-header h2)))
3326 (defsubst gnus-article-sort-by-author (h1 h2)
3327 "Sort articles by root author."
3329 (let ((extract (funcall
3330 gnus-extract-address-components
3331 (mail-header-from h1))))
3332 (or (car extract) (cadr extract) ""))
3333 (let ((extract (funcall
3334 gnus-extract-address-components
3335 (mail-header-from h2))))
3336 (or (car extract) (cadr extract) ""))))
3338 (defun gnus-thread-sort-by-author (h1 h2)
3339 "Sort threads by root author."
3340 (gnus-article-sort-by-author
3341 (gnus-thread-header h1) (gnus-thread-header h2)))
3343 (defsubst gnus-article-sort-by-subject (h1 h2)
3344 "Sort articles by root subject."
3346 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3347 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3349 (defun gnus-thread-sort-by-subject (h1 h2)
3350 "Sort threads by root subject."
3351 (gnus-article-sort-by-subject
3352 (gnus-thread-header h1) (gnus-thread-header h2)))
3354 (defsubst gnus-article-sort-by-date (h1 h2)
3355 "Sort articles by root article date."
3357 (gnus-date-get-time (mail-header-date h1))
3358 (gnus-date-get-time (mail-header-date h2))))
3360 (defun gnus-thread-sort-by-date (h1 h2)
3361 "Sort threads by root article date."
3362 (gnus-article-sort-by-date
3363 (gnus-thread-header h1) (gnus-thread-header h2)))
3365 (defsubst gnus-article-sort-by-score (h1 h2)
3366 "Sort articles by root article score.
3367 Unscored articles will be counted as having a score of zero."
3368 (> (or (cdr (assq (mail-header-number h1)
3369 gnus-newsgroup-scored))
3370 gnus-summary-default-score 0)
3371 (or (cdr (assq (mail-header-number h2)
3372 gnus-newsgroup-scored))
3373 gnus-summary-default-score 0)))
3375 (defun gnus-thread-sort-by-score (h1 h2)
3376 "Sort threads by root article score."
3377 (gnus-article-sort-by-score
3378 (gnus-thread-header h1) (gnus-thread-header h2)))
3380 (defun gnus-thread-sort-by-total-score (h1 h2)
3381 "Sort threads by the sum of all scores in the thread.
3382 Unscored articles will be counted as having a score of zero."
3383 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3385 (defun gnus-thread-total-score (thread)
3386 ;; This function find the total score of THREAD.
3387 (cond ((null thread)
3390 (if (stringp (car thread))
3391 (apply gnus-thread-score-function 0
3392 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3393 (gnus-thread-total-score-1 thread)))
3395 (gnus-thread-total-score-1 (list thread)))))
3397 (defun gnus-thread-total-score-1 (root)
3398 ;; This function find the total score of the thread below ROOT.
3399 (setq root (car root))
3400 (apply gnus-thread-score-function
3402 (mapcar 'gnus-thread-total-score
3403 (cdr (gnus-gethash (mail-header-id root)
3404 gnus-newsgroup-dependencies)))
3405 (when (> (mail-header-number root) 0)
3406 (list (or (cdr (assq (mail-header-number root)
3407 gnus-newsgroup-scored))
3408 gnus-summary-default-score 0))))
3409 (list gnus-summary-default-score)
3412 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3413 (defvar gnus-tmp-prev-subject nil)
3414 (defvar gnus-tmp-false-parent nil)
3415 (defvar gnus-tmp-root-expunged nil)
3416 (defvar gnus-tmp-dummy-line nil)
3418 (defun gnus-summary-prepare-threads (threads)
3419 "Prepare summary buffer from THREADS and indentation LEVEL.
3420 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3421 or a straight list of headers."
3422 (gnus-message 7 "Generating summary...")
3424 (setq gnus-newsgroup-threads threads)
3427 (let ((gnus-tmp-level 0)
3428 (default-score (or gnus-summary-default-score 0))
3429 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3430 thread number subject stack state gnus-tmp-gathered beg-match
3431 new-roots gnus-tmp-new-adopts thread-end
3432 gnus-tmp-header gnus-tmp-unread
3433 gnus-tmp-replied gnus-tmp-subject-or-nil
3434 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3435 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3436 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3438 (setq gnus-tmp-prev-subject nil)
3440 (if (vectorp (car threads))
3441 ;; If this is a straight (sic) list of headers, then a
3442 ;; threaded summary display isn't required, so we just create
3443 ;; an unthreaded one.
3444 (gnus-summary-prepare-unthreaded threads)
3446 ;; Do the threaded display.
3448 (while (or threads stack gnus-tmp-new-adopts new-roots)
3450 (if (and (= gnus-tmp-level 0)
3453 (not gnus-tmp-false-parent)
3454 (or gnus-tmp-new-adopts new-roots))
3455 (if gnus-tmp-new-adopts
3456 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3457 thread (list (car gnus-tmp-new-adopts))
3458 gnus-tmp-header (caar thread)
3459 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3461 (setq thread (list (car new-roots))
3462 gnus-tmp-header (caar thread)
3463 new-roots (cdr new-roots))))
3466 ;; If there are some threads, we do them before the
3467 ;; threads on the stack.
3468 (setq thread threads
3469 gnus-tmp-header (caar thread))
3470 ;; There were no current threads, so we pop something off
3472 (setq state (car stack)
3473 gnus-tmp-level (car state)
3476 gnus-tmp-header (caar thread))))
3478 (setq gnus-tmp-false-parent nil)
3479 (setq gnus-tmp-root-expunged nil)
3480 (setq thread-end nil)
3482 (if (stringp gnus-tmp-header)
3483 ;; The header is a dummy root.
3485 ((eq gnus-summary-make-false-root 'adopt)
3486 ;; We let the first article adopt the rest.
3487 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3489 (setq gnus-tmp-gathered
3491 (lambda (h) (mail-header-number (car h)))
3494 (setq thread (cons (list (caar thread)
3497 (setq gnus-tmp-level -1
3498 gnus-tmp-false-parent t))
3499 ((eq gnus-summary-make-false-root 'empty)
3500 ;; We print adopted articles with empty subject fields.
3501 (setq gnus-tmp-gathered
3503 (lambda (h) (mail-header-number (car h)))
3506 (setq gnus-tmp-level -1))
3507 ((eq gnus-summary-make-false-root 'dummy)
3508 ;; We remember that we probably want to output a dummy
3510 (setq gnus-tmp-dummy-line gnus-tmp-header)
3511 (setq gnus-tmp-prev-subject gnus-tmp-header))
3513 ;; We do not make a root for the gathered
3514 ;; sub-threads at all.
3515 (setq gnus-tmp-level -1)))
3517 (setq number (mail-header-number gnus-tmp-header)
3518 subject (mail-header-subject gnus-tmp-header))
3521 ;; If the thread has changed subject, we might want to make
3522 ;; this subthread into a root.
3523 ((and (null gnus-thread-ignore-subject)
3524 (not (zerop gnus-tmp-level))
3525 gnus-tmp-prev-subject
3527 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3528 (setq new-roots (nconc new-roots (list (car thread)))
3530 gnus-tmp-header nil))
3531 ;; If the article lies outside the current limit,
3532 ;; then we do not display it.
3533 ((not (memq number gnus-newsgroup-limit))
3534 (setq gnus-tmp-gathered
3536 (lambda (h) (mail-header-number (car h)))
3539 (setq gnus-tmp-new-adopts (if (cdar thread)
3540 (append gnus-tmp-new-adopts
3542 gnus-tmp-new-adopts)
3544 gnus-tmp-header nil)
3545 (when (zerop gnus-tmp-level)
3546 (setq gnus-tmp-root-expunged t)))
3547 ;; Perhaps this article is to be marked as read?
3548 ((and gnus-summary-mark-below
3549 (< (or (cdr (assq number gnus-newsgroup-scored))
3551 gnus-summary-mark-below)
3552 ;; Don't touch sparse articles.
3553 (not (gnus-summary-article-sparse-p number))
3554 (not (gnus-summary-article-ancient-p number)))
3555 (setq gnus-newsgroup-unreads
3556 (delq number gnus-newsgroup-unreads))
3557 (if gnus-newsgroup-auto-expire
3558 (push number gnus-newsgroup-expirable)
3559 (push (cons number gnus-low-score-mark)
3560 gnus-newsgroup-reads))))
3562 (when gnus-tmp-header
3563 ;; We may have an old dummy line to output before this
3565 (when (and gnus-tmp-dummy-line
3568 (mail-header-subject gnus-tmp-header)))
3569 (gnus-summary-insert-dummy-line
3570 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3571 (setq gnus-tmp-dummy-line nil))
3573 ;; Compute the mark.
3574 (setq gnus-tmp-unread (gnus-article-mark number))
3576 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3577 gnus-tmp-header gnus-tmp-level)
3578 gnus-newsgroup-data)
3580 ;; Actually insert the line.
3582 gnus-tmp-subject-or-nil
3584 ((and gnus-thread-ignore-subject
3585 gnus-tmp-prev-subject
3586 (not (inline (gnus-subject-equal
3587 gnus-tmp-prev-subject subject))))
3589 ((zerop gnus-tmp-level)
3590 (if (and (eq gnus-summary-make-false-root 'empty)
3591 (memq number gnus-tmp-gathered)
3592 gnus-tmp-prev-subject
3593 (inline (gnus-subject-equal
3594 gnus-tmp-prev-subject subject)))
3595 gnus-summary-same-subject
3597 (t gnus-summary-same-subject)))
3598 (if (and (eq gnus-summary-make-false-root 'adopt)
3599 (= gnus-tmp-level 1)
3600 (memq number gnus-tmp-gathered))
3601 (setq gnus-tmp-opening-bracket ?\<
3602 gnus-tmp-closing-bracket ?\>)
3603 (setq gnus-tmp-opening-bracket ?\[
3604 gnus-tmp-closing-bracket ?\]))
3606 gnus-tmp-indentation
3607 (aref gnus-thread-indent-array gnus-tmp-level)
3608 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3609 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3610 gnus-summary-default-score 0)
3612 (if (or (null gnus-summary-default-score)
3613 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3614 gnus-summary-zcore-fuzz))
3616 (if (< gnus-tmp-score gnus-summary-default-score)
3617 gnus-score-below-mark gnus-score-over-mark))
3619 (cond ((memq number gnus-newsgroup-processable)
3621 ((memq number gnus-newsgroup-cached)
3623 ((memq number gnus-newsgroup-replied)
3625 ((memq number gnus-newsgroup-saved)
3627 (t gnus-unread-mark))
3628 gnus-tmp-from (mail-header-from gnus-tmp-header)
3631 ((string-match "<[^>]+> *$" gnus-tmp-from)
3632 (setq beg-match (match-beginning 0))
3633 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3634 (substring gnus-tmp-from (1+ (match-beginning 0))
3635 (1- (match-end 0))))
3636 (substring gnus-tmp-from 0 beg-match)))
3637 ((string-match "(.+)" gnus-tmp-from)
3638 (substring gnus-tmp-from
3639 (1+ (match-beginning 0)) (1- (match-end 0))))
3641 (when (string= gnus-tmp-name "")
3642 (setq gnus-tmp-name gnus-tmp-from))
3643 (unless (numberp gnus-tmp-lines)
3644 (setq gnus-tmp-lines 0))
3645 (gnus-put-text-property
3647 (progn (eval gnus-summary-line-format-spec) (point))
3648 'gnus-number number)
3651 (gnus-run-hooks 'gnus-summary-update-hook)
3654 (setq gnus-tmp-prev-subject subject)))
3656 (when (nth 1 thread)
3657 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3658 (incf gnus-tmp-level)
3659 (setq threads (if thread-end nil (cdar thread)))
3661 (setq gnus-tmp-level 0)))))
3662 (gnus-message 7 "Generating summary...done"))
3664 (defun gnus-summary-prepare-unthreaded (headers)
3665 "Generate an unthreaded summary buffer based on HEADERS."
3666 (let (header number mark)
3671 ;; We may have to root out some bad articles...
3672 (when (memq (setq number (mail-header-number
3673 (setq header (pop headers))))
3674 gnus-newsgroup-limit)
3675 ;; Mark article as read when it has a low score.
3676 (when (and gnus-summary-mark-below
3677 (< (or (cdr (assq number gnus-newsgroup-scored))
3678 gnus-summary-default-score 0)
3679 gnus-summary-mark-below)
3680 (not (gnus-summary-article-ancient-p number)))
3681 (setq gnus-newsgroup-unreads
3682 (delq number gnus-newsgroup-unreads))
3683 (if gnus-newsgroup-auto-expire
3684 (push number gnus-newsgroup-expirable)
3685 (push (cons number gnus-low-score-mark)
3686 gnus-newsgroup-reads)))
3688 (setq mark (gnus-article-mark number))
3689 (push (gnus-data-make number mark (1+ (point)) header 0)
3690 gnus-newsgroup-data)
3691 (gnus-summary-insert-line
3693 mark (memq number gnus-newsgroup-replied)
3694 (memq number gnus-newsgroup-expirable)
3695 (mail-header-subject header) nil
3696 (cdr (assq number gnus-newsgroup-scored))
3697 (memq number gnus-newsgroup-processable))))))
3699 (defun gnus-select-newsgroup (group &optional read-all)
3700 "Select newsgroup GROUP.
3701 If READ-ALL is non-nil, all articles in the group are selected."
3702 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3703 ;;!!! Dirty hack; should be removed.
3704 (gnus-summary-ignore-duplicates
3705 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3707 gnus-summary-ignore-duplicates))
3708 (info (nth 2 entry))
3709 articles fetched-articles cached)
3711 (unless (gnus-check-server
3712 (setq gnus-current-select-method
3713 (gnus-find-method-for-group group)))
3714 (error "Couldn't open server"))
3716 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3717 (gnus-activate-group group) ; Or we can activate it...
3718 (progn ; Or we bug out.
3719 (when (equal major-mode 'gnus-summary-mode)
3720 (kill-buffer (current-buffer)))
3721 (error "Couldn't request group %s: %s"
3722 group (gnus-status-message group))))
3724 (unless (gnus-request-group group t)
3725 (when (equal major-mode 'gnus-summary-mode)
3726 (kill-buffer (current-buffer)))
3727 (error "Couldn't request group %s: %s"
3728 group (gnus-status-message group)))
3730 (setq gnus-newsgroup-name group)
3731 (setq gnus-newsgroup-unselected nil)
3732 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3734 ;; Adjust and set lists of article marks.
3736 (gnus-adjust-marked-articles info))
3738 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3739 (when (gnus-virtual-group-p group)
3740 (setq cached gnus-newsgroup-cached))
3742 (setq gnus-newsgroup-unreads
3743 (gnus-set-difference
3744 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3745 gnus-newsgroup-dormant))
3747 (setq gnus-newsgroup-processable nil)
3749 (gnus-update-read-articles group gnus-newsgroup-unreads)
3750 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3751 (gnus-group-update-group group))
3753 (setq articles (gnus-articles-to-read group read-all))
3757 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3759 ((eq articles 0) nil)
3761 ;; Init the dependencies hash table.
3762 (setq gnus-newsgroup-dependencies
3763 (gnus-make-hashtable (length articles)))
3764 ;; Retrieve the headers and read them in.
3765 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3766 (setq gnus-newsgroup-headers
3768 (setq gnus-headers-retrieved-by
3769 (gnus-retrieve-headers
3770 articles gnus-newsgroup-name
3771 ;; We might want to fetch old headers, but
3772 ;; not if there is only 1 article.
3774 (not (eq gnus-fetch-old-headers 'some))
3775 (not (numberp gnus-fetch-old-headers)))
3776 (> (length articles) 1))
3777 gnus-fetch-old-headers))))
3778 (gnus-get-newsgroup-headers-xover
3779 articles nil nil gnus-newsgroup-name t)
3780 (gnus-get-newsgroup-headers)))
3781 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3783 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3785 (setq gnus-newsgroup-cached cached))
3787 ;; Suppress duplicates?
3788 (when gnus-suppress-duplicates
3789 (gnus-dup-suppress-articles))
3791 ;; Set the initial limit.
3792 (setq gnus-newsgroup-limit (copy-sequence articles))
3793 ;; Remove canceled articles from the list of unread articles.
3794 (setq gnus-newsgroup-unreads
3795 (gnus-set-sorted-intersection
3796 gnus-newsgroup-unreads
3797 (setq fetched-articles
3798 (mapcar (lambda (headers) (mail-header-number headers))
3799 gnus-newsgroup-headers))))
3800 ;; Removed marked articles that do not exist.
3801 (gnus-update-missing-marks
3802 (gnus-sorted-complement fetched-articles articles))
3803 ;; Let the Gnus agent mark articles as read.
3805 (gnus-agent-get-undownloaded-list))
3806 ;; We might want to build some more threads first.
3807 (when (and gnus-fetch-old-headers
3808 (eq gnus-headers-retrieved-by 'nov))
3809 (if (eq gnus-fetch-old-headers 'invisible)
3810 (gnus-build-all-threads)
3811 (gnus-build-old-threads)))
3812 ;; Check whether auto-expire is to be done in this group.
3813 (setq gnus-newsgroup-auto-expire
3814 (gnus-group-auto-expirable-p group))
3815 ;; Set up the article buffer now, if necessary.
3816 (unless gnus-single-article-buffer
3817 (gnus-article-setup-buffer))
3818 ;; First and last article in this newsgroup.
3819 (when gnus-newsgroup-headers
3820 (setq gnus-newsgroup-begin
3821 (mail-header-number (car gnus-newsgroup-headers))
3824 (gnus-last-element gnus-newsgroup-headers))))
3825 ;; GROUP is successfully selected.
3826 (or gnus-newsgroup-headers t)))))
3828 (defun gnus-articles-to-read (group &optional read-all)
3829 ;; Find out what articles the user wants to read.
3831 ;; Select all articles if `read-all' is non-nil, or if there
3832 ;; are no unread articles.
3834 (and (zerop (length gnus-newsgroup-marked))
3835 (zerop (length gnus-newsgroup-unreads)))
3836 (eq (gnus-group-find-parameter group 'display)
3838 (gnus-uncompress-range (gnus-active group))
3839 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3840 (copy-sequence gnus-newsgroup-unreads))
3842 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3843 (scored (length scored-list))
3844 (number (length articles))
3845 (marked (+ (length gnus-newsgroup-marked)
3846 (length gnus-newsgroup-dormant)))
3854 ((and (or (<= scored marked) (= scored number))
3855 (numberp gnus-large-newsgroup)
3856 (> number gnus-large-newsgroup))
3860 "How many articles from %s (default %d): "
3861 (gnus-limit-string gnus-newsgroup-name 35)
3863 (if (string-match "^[ \t]*$" input) number input)))
3864 ((and (> scored marked) (< scored number)
3865 (> (- scored number) 20))
3868 (format "%s %s (%d scored, %d total): "
3869 "How many articles from"
3870 group scored number))))
3871 (if (string-match "^[ \t]*$" input)
3875 (setq select (if (stringp select) (string-to-number select) select))
3876 (if (or (null select) (zerop select))
3878 (if (and (not (zerop scored)) (<= (abs select) scored))
3880 (setq articles (sort scored-list '<))
3881 (setq number (length articles)))
3882 (setq articles (copy-sequence articles)))
3884 (when (< (abs select) number)
3886 ;; Select the N oldest articles.
3887 (setcdr (nthcdr (1- (abs select)) articles) nil)
3888 ;; Select the N most recent articles.
3889 (setq articles (nthcdr (- number select) articles))))
3890 (setq gnus-newsgroup-unselected
3891 (gnus-sorted-intersection
3892 gnus-newsgroup-unreads
3893 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3896 (defun gnus-killed-articles (killed articles)
3899 (when (inline (gnus-member-of-range (car articles) killed))
3900 (push (car articles) out))
3901 (setq articles (cdr articles)))
3904 (defun gnus-uncompress-marks (marks)
3905 "Uncompress the mark ranges in MARKS."
3906 (let ((uncompressed '(score bookmark))
3909 (if (memq (caar marks) uncompressed)
3910 (push (car marks) out)
3911 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3912 (setq marks (cdr marks)))
3915 (defun gnus-adjust-marked-articles (info)
3916 "Set all article lists and remove all marks that are no longer legal."
3917 (let* ((marked-lists (gnus-info-marks info))
3918 (active (gnus-active (gnus-info-group info)))
3921 (types gnus-article-mark-lists)
3922 (uncompressed '(score bookmark killed))
3923 marks var articles article mark)
3926 (setq marks (pop marked-lists))
3927 (set (setq var (intern (format "gnus-newsgroup-%s"
3928 (car (rassq (setq mark (car marks))
3930 (if (memq (car marks) uncompressed) (cdr marks)
3931 (gnus-uncompress-range (cdr marks))))
3933 (setq articles (symbol-value var))
3935 ;; All articles have to be subsets of the active articles.
3937 ;; Adjust "simple" lists.
3938 ((memq mark '(tick dormant expire reply save))
3940 (when (or (< (setq article (pop articles)) min) (> article max))
3941 (set var (delq article (symbol-value var))))))
3943 ((memq mark uncompressed)
3944 (when (not (listp (cdr (symbol-value var))))
3945 (set var (list (symbol-value var))))
3946 (when (not (listp (cdr articles)))
3947 (setq articles (list articles)))
3949 (when (or (not (consp (setq article (pop articles))))
3950 (< (car article) min)
3951 (> (car article) max))
3952 (set var (delq article (symbol-value var))))))))))
3954 (defun gnus-update-missing-marks (missing)
3955 "Go through the list of MISSING articles and remove them from the mark lists."
3957 (let ((types gnus-article-mark-lists)
3959 ;; Go through all types.
3961 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3962 (when (symbol-value var)
3963 ;; This list has articles. So we delete all missing articles
3967 (set var (delq (pop m) (symbol-value var)))))))))
3969 (defun gnus-update-marks ()
3970 "Enter the various lists of marked articles into the newsgroup info list."
3971 (let ((types gnus-article-mark-lists)
3972 (info (gnus-get-info gnus-newsgroup-name))
3973 (uncompressed '(score bookmark killed))
3974 type list newmarked symbol)
3976 ;; Add all marks lists that are non-nil to the list of marks lists.
3977 (while (setq type (pop types))
3978 (when (setq list (symbol-value
3980 (intern (format "gnus-newsgroup-%s"
3983 ;; Get rid of the entries of the articles that have the
3985 (when (and (eq (cdr type) 'score)
3989 (prev (cons nil list))
3992 (if (or (not (consp (car arts)))
3993 (= (cdar arts) gnus-summary-default-score))
3994 (setcdr prev (cdr arts))
3996 (setq arts (cdr arts)))
3997 (setq list (cdr all))))
3999 (push (cons (cdr type)
4000 (if (memq (cdr type) uncompressed) list
4001 (gnus-compress-sequence
4002 (set symbol (sort list '<)) t)))
4005 ;; Enter these new marks into the info of the group.
4007 (setcar (nthcdr 3 info) newmarked)
4008 ;; Add the marks lists to the end of the info.
4010 (setcdr (nthcdr 2 info) (list newmarked))))
4012 ;; Cut off the end of the info if there's nothing else there.
4016 (when (nthcdr (decf i) info)
4017 (setcdr (nthcdr i info) nil)))))))
4019 (defun gnus-set-mode-line (where)
4020 "This function sets the mode line of the article or summary buffers.
4021 If WHERE is `summary', the summary mode line format will be used."
4022 ;; Is this mode line one we keep updated?
4023 (when (memq where gnus-updated-mode-lines)
4026 ;; We evaluate this in the summary buffer since these
4027 ;; variables are buffer-local to that buffer.
4028 (set-buffer gnus-summary-buffer)
4029 ;; We bind all these variables that are used in the `eval' form
4031 (let* ((mformat (symbol-value
4033 (format "gnus-%s-mode-line-format-spec" where))))
4034 (gnus-tmp-group-name gnus-newsgroup-name)
4035 (gnus-tmp-article-number (or gnus-current-article 0))
4036 (gnus-tmp-unread gnus-newsgroup-unreads)
4037 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4038 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4039 (gnus-tmp-unread-and-unselected
4040 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4041 (zerop gnus-tmp-unselected))
4043 ((zerop gnus-tmp-unselected)
4044 (format "{%d more}" gnus-tmp-unread-and-unticked))
4045 (t (format "{%d(+%d) more}"
4046 gnus-tmp-unread-and-unticked
4047 gnus-tmp-unselected))))
4049 (if (and gnus-current-headers
4050 (vectorp gnus-current-headers))
4051 (gnus-mode-string-quote
4052 (mail-header-subject gnus-current-headers))
4054 bufname-length max-len
4055 gnus-tmp-header);; passed as argument to any user-format-funcs
4056 (setq mode-string (eval mformat))
4057 (setq bufname-length (if (string-match "%b" mode-string)
4060 (if (eq where 'summary)
4062 (get-buffer gnus-article-buffer))))
4065 (setq max-len (max 4 (if gnus-mode-non-string-length
4067 gnus-mode-non-string-length
4069 (length mode-string))))
4070 ;; We might have to chop a bit of the string off...
4071 (when (> (length mode-string) max-len)
4073 (concat (gnus-truncate-string mode-string (- max-len 3))
4075 ;; Pad the mode string a bit.
4076 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4077 ;; Update the mode line.
4078 (setq mode-line-buffer-identification
4079 (gnus-mode-line-buffer-identification (list mode-string)))
4080 (set-buffer-modified-p t))))
4082 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4083 "Go through the HEADERS list and add all Xrefs to a hash table.
4084 The resulting hash table is returned, or nil if no Xrefs were found."
4085 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4086 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4087 (xref-hashtb (gnus-make-hashtable))
4088 start group entry number xrefs header)
4090 (setq header (pop headers))
4091 (when (and (setq xrefs (mail-header-xref header))
4092 (not (memq (setq number (mail-header-number header))
4095 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4096 (setq start (match-end 0))
4097 (setq group (if prefix
4098 (concat prefix (substring xrefs (match-beginning 1)
4100 (substring xrefs (match-beginning 1) (match-end 1))))
4102 (string-to-int (substring xrefs (match-beginning 2)
4104 (if (setq entry (gnus-gethash group xref-hashtb))
4105 (setcdr entry (cons number (cdr entry)))
4106 (gnus-sethash group (cons number nil) xref-hashtb)))))
4107 (and start xref-hashtb)))
4109 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4110 "Look through all the headers and mark the Xrefs as read."
4111 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4112 name entry info xref-hashtb idlist method nth4)
4114 (set-buffer gnus-group-buffer)
4115 (when (setq xref-hashtb
4116 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4119 (unless (string= from-newsgroup (setq name (symbol-name group)))
4120 (setq idlist (symbol-value group))
4121 ;; Dead groups are not updated.
4123 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4125 (when (stringp (setq nth4 (gnus-info-method info)))
4126 (setq nth4 (gnus-server-to-method nth4))))
4127 ;; Only do the xrefs if the group has the same
4128 ;; select method as the group we have just read.
4129 (or (gnus-methods-equal-p
4130 nth4 (gnus-find-method-for-group from-newsgroup))
4132 (equal nth4 (setq method (gnus-find-method-for-group
4134 (and (equal (car nth4) (car method))
4135 (equal (nth 1 nth4) (nth 1 method))))
4136 gnus-use-cross-reference
4137 (or (not (eq gnus-use-cross-reference t))
4139 ;; Only do cross-references on subscribed
4140 ;; groups, if that is what is wanted.
4141 (<= (gnus-info-level info) gnus-level-subscribed))
4142 (gnus-group-make-articles-read name idlist))))
4145 (defun gnus-compute-read-articles (group articles)
4146 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4147 (info (nth 2 entry))
4148 (active (gnus-active group))
4151 ;; First peel off all illegal article numbers.
4153 (let ((ids articles)
4155 (while (setq id (pop ids))
4156 (when (and first (> id (cdr active)))
4157 ;; We'll end up in this situation in one particular
4158 ;; obscure situation. If you re-scan a group and get
4159 ;; a new article that is cross-posted to a different
4160 ;; group that has not been re-scanned, you might get
4161 ;; crossposted article that has a higher number than
4162 ;; Gnus believes possible. So we re-activate this
4163 ;; group as well. This might mean doing the
4164 ;; crossposting thingy will *increase* the number
4165 ;; of articles in some groups. Tsk, tsk.
4166 (setq active (or (gnus-activate-group group) active)))
4167 (when (or (> id (cdr active))
4168 (< id (car active)))
4169 (setq articles (delq id articles))))))
4170 ;; If the read list is nil, we init it.
4172 (null (gnus-info-read info))
4174 (setq ninfo (cons 1 (1- (car active))))
4175 (setq ninfo (gnus-info-read info)))
4176 ;; Then we add the read articles to the range.
4178 ninfo (setq articles (sort articles '<))))))
4180 (defun gnus-group-make-articles-read (group articles)
4181 "Update the info of GROUP to say that ARTICLES are read."
4183 (entry (gnus-gethash group gnus-newsrc-hashtb))
4184 (info (nth 2 entry))
4185 (active (gnus-active group))
4188 (setq range (gnus-compute-read-articles group articles))
4190 (set-buffer gnus-group-buffer)
4193 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4194 (gnus-info-set-read ',info ',(gnus-info-read info))
4195 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4196 (gnus-group-update-group ,group t))))
4197 ;; Add the read articles to the range.
4198 (gnus-info-set-read info range)
4199 ;; Then we have to re-compute how many unread
4200 ;; articles there are in this group.
4204 (setq num (- (1+ (cdr active)) (car active))))
4205 ((not (listp (cdr range)))
4206 (setq num (- (cdr active) (- (1+ (cdr range))
4210 (if (numberp (car range))
4212 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4213 (setq range (cdr range)))
4214 (setq num (- (cdr active) num))))
4215 ;; Update the number of unread articles.
4217 ;; Update the group buffer.
4218 (gnus-group-update-group group t)))))
4220 (defun gnus-methods-equal-p (m1 m2)
4221 (let ((m1 (or m1 gnus-select-method))
4222 (m2 (or m2 gnus-select-method)))
4224 (and (eq (car m1) (car m2))
4225 (or (not (memq 'address (assoc (symbol-name (car m1))
4226 gnus-valid-select-methods)))
4227 (equal (nth 1 m1) (nth 1 m2)))))))
4229 (defvar gnus-newsgroup-none-id 0)
4231 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4232 (let ((cur nntp-server-buffer)
4235 (save-excursion (set-buffer gnus-summary-buffer)
4236 gnus-newsgroup-dependencies)))
4237 headers id id-dep ref-dep end ref)
4239 (set-buffer nntp-server-buffer)
4240 ;; Translate all TAB characters into SPACE characters.
4241 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4242 (gnus-run-hooks 'gnus-parse-headers-hook)
4243 (let ((case-fold-search t)
4244 in-reply-to header p lines)
4245 (goto-char (point-min))
4246 ;; Search to the beginning of the next header. Error messages
4247 ;; do not begin with 2 or 3.
4248 (while (re-search-forward "^[23][0-9]+ " nil t)
4251 ;; This implementation of this function, with nine
4252 ;; search-forwards instead of the one re-search-forward and
4253 ;; a case (which basically was the old function) is actually
4254 ;; about twice as fast, even though it looks messier. You
4255 ;; can't have everything, I guess. Speed and elegance
4256 ;; doesn't always go hand in hand.
4265 (narrow-to-region (point)
4266 (or (and (search-forward "\n.\n" nil t)
4272 (if (search-forward "\nsubject: " nil t)
4274 gnus-unstructured-field-decoder (nnheader-header-value))
4279 (if (search-forward "\nfrom: " nil t)
4281 gnus-structured-field-decoder (nnheader-header-value))
4286 (if (search-forward "\ndate: " nil t)
4287 (nnheader-header-value) ""))
4291 (setq id (if (re-search-forward
4292 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4293 ;; We do it this way to make sure the Message-ID
4294 ;; is (somewhat) syntactically valid.
4295 (buffer-substring (match-beginning 1)
4297 ;; If there was no message-id, we just fake one
4298 ;; to make subsequent routines simpler.
4299 (nnheader-generate-fake-message-id))))
4303 (if (search-forward "\nreferences: " nil t)
4307 (nnheader-header-value)
4312 (search-backward ">" end t)
4315 (search-backward "<" end t)
4317 ;; Get the references from the in-reply-to header if there
4318 ;; were no references and the in-reply-to header looks
4320 (if (and (search-forward "\nin-reply-to: " nil t)
4321 (setq in-reply-to (nnheader-header-value))
4322 (string-match "<[^>]+>" in-reply-to))
4324 (setq ref (substring in-reply-to (match-beginning 0)
4326 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4327 (setq ref2 (substring in-reply-to (match-beginning 0)
4329 (when (> (length ref2) (length ref))
4337 (if (search-forward "\nlines: " nil t)
4338 (if (numberp (setq lines (ignore-errors (read cur))))
4344 (and (search-forward "\nxref: " nil t)
4345 (nnheader-header-value)))))
4346 (when (equal id ref)
4349 (when gnus-alter-header-function
4350 (funcall gnus-alter-header-function header)
4351 (setq id (mail-header-id header)
4352 ref (gnus-parent-id (mail-header-references header))))
4354 ;; We do the threading while we read the headers. The
4355 ;; message-id and the last reference are both entered into
4356 ;; the same hash table. Some tippy-toeing around has to be
4357 ;; done in case an article has arrived before the article
4358 ;; which it refers to.
4359 (if (boundp (setq id-dep (intern id dependencies)))
4360 (if (and (car (symbol-value id-dep))
4362 ;; An article with this Message-ID has already been seen.
4363 (if gnus-summary-ignore-duplicates
4364 ;; We ignore this one, except we add
4365 ;; any additional Xrefs (in case the two articles
4366 ;; came from different servers).
4368 (mail-header-set-xref
4369 (car (symbol-value id-dep))
4370 (concat (or (mail-header-xref
4371 (car (symbol-value id-dep)))
4373 (or (mail-header-xref header) "")))
4375 ;; We rename the Message-ID.
4377 (setq id-dep (intern (setq id (nnmail-message-id))
4380 (mail-header-set-id header id))
4381 (setcar (symbol-value id-dep) header))
4382 (set id-dep (list header)))
4384 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4385 (setcdr (symbol-value ref-dep)
4386 (nconc (cdr (symbol-value ref-dep))
4387 (list (symbol-value id-dep))))
4388 (set ref-dep (list nil (symbol-value id-dep))))
4389 (push header headers))
4390 (goto-char (point-max))
4392 (nreverse headers)))))
4394 ;; The following macros and functions were written by Felix Lee
4395 ;; <flee@cse.psu.edu>.
4397 (defmacro gnus-nov-read-integer ()
4399 (if (= (following-char) ?\t)
4401 (let ((num (ignore-errors (read buffer))))
4402 (if (numberp num) num 0)))
4404 (search-forward "\t" eol 'move))))
4406 (defmacro gnus-nov-skip-field ()
4407 '(search-forward "\t" eol 'move))
4409 (defmacro gnus-nov-field ()
4410 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4412 ;; (defvar gnus-nov-none-counter 0)
4414 ;; This function has to be called with point after the article number
4415 ;; on the beginning of the line.
4416 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4417 (let ((eol (gnus-point-at-eol))
4418 (buffer (current-buffer))
4419 header ref id id-dep ref-dep)
4421 ;; overview: [num subject from date id refs chars lines misc]
4424 (narrow-to-region (point) eol)
4432 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4434 gnus-structured-field-decoder (gnus-nov-field)) ; from
4435 (gnus-nov-field) ; date
4436 (setq id (or (gnus-nov-field)
4437 (nnheader-generate-fake-message-id))) ; id
4439 (let ((beg (point)))
4440 (search-forward "\t" eol)
4441 (if (search-backward ">" beg t)
4445 (or (search-backward "<" beg t) beg)))
4448 (gnus-nov-field)) ; refs
4449 (gnus-nov-read-integer) ; chars
4450 (gnus-nov-read-integer) ; lines
4451 (if (= (following-char) ?\n)
4453 (gnus-nov-field))))) ; misc
4457 (when gnus-alter-header-function
4458 (funcall gnus-alter-header-function header)
4459 (setq id (mail-header-id header)
4460 ref (gnus-parent-id (mail-header-references header))))
4462 ;; We build the thread tree.
4463 (when (equal id ref)
4464 ;; This article refers back to itself. Naughty, naughty.
4466 (if (boundp (setq id-dep (intern id dependencies)))
4467 (if (and (car (symbol-value id-dep))
4469 ;; An article with this Message-ID has already been seen.
4470 (if gnus-summary-ignore-duplicates
4471 ;; We ignore this one, except we add any additional
4472 ;; Xrefs (in case the two articles came from different
4475 (mail-header-set-xref
4476 (car (symbol-value id-dep))
4477 (concat (or (mail-header-xref
4478 (car (symbol-value id-dep)))
4480 (or (mail-header-xref header) "")))
4482 ;; We rename the Message-ID.
4484 (setq id-dep (intern (setq id (nnmail-message-id))
4487 (mail-header-set-id header id))
4488 (setcar (symbol-value id-dep) header))
4489 (set id-dep (list header)))
4491 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4492 (setcdr (symbol-value ref-dep)
4493 (nconc (cdr (symbol-value ref-dep))
4494 (list (symbol-value id-dep))))
4495 (set ref-dep (list nil (symbol-value id-dep)))))
4498 ;; Goes through the xover lines and returns a list of vectors
4499 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4500 force-new dependencies
4501 group also-fetch-heads)
4502 "Parse the news overview data in the server buffer, and return a
4503 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4504 ;; Get the Xref when the users reads the articles since most/some
4505 ;; NNTP servers do not include Xrefs when using XOVER.
4506 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4507 (let ((cur nntp-server-buffer)
4508 (dependencies (or dependencies gnus-newsgroup-dependencies))
4509 number headers header)
4511 (set-buffer nntp-server-buffer)
4512 ;; Allow the user to mangle the headers before parsing them.
4513 (gnus-run-hooks 'gnus-parse-headers-hook)
4514 (goto-char (point-min))
4517 (while (and sequence (not (eobp)))
4518 (setq number (read cur))
4519 (while (and sequence
4520 (< (car sequence) number))
4521 (setq sequence (cdr sequence)))
4523 (eq number (car sequence))
4525 (setq sequence (cdr sequence))
4526 (setq header (inline
4527 (gnus-nov-parse-line
4528 number dependencies force-new))))
4529 (push header headers))
4532 (gnus-error 4 "Strange nov line (%d)"
4533 (count-lines (point-min) (point)))))
4535 ;; A common bug in inn is that if you have posted an article and
4536 ;; then retrieves the active file, it will answer correctly --
4537 ;; the new article is included. However, a NOV entry for the
4538 ;; article may not have been generated yet, so this may fail.
4539 ;; We work around this problem by retrieving the last few
4540 ;; headers using HEAD.
4541 (if (or (not also-fetch-heads)
4543 ;; We (probably) got all the headers.
4545 (let ((gnus-nov-is-evil t))
4548 (when (gnus-retrieve-headers sequence group)
4549 (gnus-get-newsgroup-headers))))))))
4551 (defun gnus-article-get-xrefs ()
4552 "Fill in the Xref value in `gnus-current-headers', if necessary.
4553 This is meant to be called in `gnus-article-internal-prepare-hook'."
4554 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4555 gnus-current-headers)))
4556 (or (not gnus-use-cross-reference)
4558 (and (mail-header-xref headers)
4559 (not (string= (mail-header-xref headers) "")))
4560 (let ((case-fold-search t)
4563 (nnheader-narrow-to-headers)
4564 (goto-char (point-min))
4565 (when (or (and (eq (downcase (following-char)) ?x)
4566 (looking-at "Xref:"))
4567 (search-forward "\nXref:" nil t))
4568 (goto-char (1+ (match-end 0)))
4569 (setq xref (buffer-substring (point)
4570 (progn (end-of-line) (point))))
4571 (mail-header-set-xref headers xref)))))))
4573 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4574 "Find article ID and insert the summary line for that article."
4575 (let ((header (cond ((and old-header use-old-header)
4578 (gnus-number-to-header id))
4579 (gnus-number-to-header id))
4581 (gnus-read-header id))))
4582 (number (and (numberp id) id))
4585 ;; Rebuild the thread that this article is part of and go to the
4586 ;; article we have fetched.
4587 (when (and (not gnus-show-threads)
4590 (setq d (gnus-data-find (mail-header-number old-header))))
4591 (goto-char (gnus-data-pos d))
4594 (- (gnus-point-at-bol)
4596 (1+ (gnus-point-at-eol))
4597 (gnus-delete-line))))))
4599 (mail-header-set-number header (mail-header-number old-header)))
4600 (setq gnus-newsgroup-sparse
4601 (delq (setq number (mail-header-number header))
4602 gnus-newsgroup-sparse))
4603 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4604 (push number gnus-newsgroup-limit)
4605 (gnus-rebuild-thread (mail-header-id header))
4606 (gnus-summary-goto-subject number nil t))
4607 (when (and (numberp number)
4609 ;; We have to update the boundaries even if we can't fetch the
4610 ;; article if ID is a number -- so that the next `P' or `N'
4611 ;; command will fetch the previous (or next) article even
4612 ;; if the one we tried to fetch this time has been canceled.
4613 (when (> number gnus-newsgroup-end)
4614 (setq gnus-newsgroup-end number))
4615 (when (< number gnus-newsgroup-begin)
4616 (setq gnus-newsgroup-begin number))
4617 (setq gnus-newsgroup-unselected
4618 (delq number gnus-newsgroup-unselected)))
4619 ;; Report back a success?
4620 (and header (mail-header-number header))))
4622 ;;; Process/prefix in the summary buffer
4624 (defun gnus-summary-work-articles (n)
4625 "Return a list of articles to be worked upon. The prefix argument,
4626 the list of process marked articles, and the current article will be
4627 taken into consideration."
4629 (set-buffer gnus-summary-buffer)
4632 ;; A numerical prefix has been given.
4633 (setq n (prefix-numeric-value n))
4634 (let ((backward (< n 0))
4635 (n (abs (prefix-numeric-value n)))
4640 (push (setq article (gnus-summary-article-number))
4643 (gnus-summary-find-prev nil article)
4644 (gnus-summary-find-next nil article)))
4646 (nreverse articles)))
4647 ((and (gnus-region-active-p) (mark))
4648 (message "region active")
4649 ;; Work on the region between point and mark.
4650 (let ((max (max (point) (mark)))
4653 (goto-char (min (point) (mark)))
4656 (push (setq article (gnus-summary-article-number)) articles)
4657 (gnus-summary-find-next nil article)
4659 (nreverse articles))))
4660 (gnus-newsgroup-processable
4661 ;; There are process-marked articles present.
4662 ;; Save current state.
4663 (gnus-summary-save-process-mark)
4665 (reverse gnus-newsgroup-processable))
4667 ;; Just return the current article.
4668 (list (gnus-summary-article-number))))))
4670 (defun gnus-summary-save-process-mark ()
4671 "Push the current set of process marked articles on the stack."
4673 (push (copy-sequence gnus-newsgroup-processable)
4674 gnus-newsgroup-process-stack))
4676 (defun gnus-summary-kill-process-mark ()
4677 "Push the current set of process marked articles on the stack and unmark."
4679 (gnus-summary-save-process-mark)
4680 (gnus-summary-unmark-all-processable))
4682 (defun gnus-summary-yank-process-mark ()
4683 "Pop the last process mark state off the stack and restore it."
4685 (unless gnus-newsgroup-process-stack
4686 (error "Empty mark stack"))
4687 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4689 (defun gnus-summary-process-mark-set (set)
4690 "Make SET into the current process marked articles."
4691 (gnus-summary-unmark-all-processable)
4693 (gnus-summary-set-process-mark (pop set))))
4695 ;;; Searching and stuff
4697 (defun gnus-summary-search-group (&optional backward use-level)
4698 "Search for next unread newsgroup.
4699 If optional argument BACKWARD is non-nil, search backward instead."
4701 (set-buffer gnus-group-buffer)
4702 (when (gnus-group-search-forward
4703 backward nil (if use-level (gnus-group-group-level) nil))
4704 (gnus-group-group-name))))
4706 (defun gnus-summary-best-group (&optional exclude-group)
4707 "Find the name of the best unread group.
4708 If EXCLUDE-GROUP, do not go to this group."
4710 (set-buffer gnus-group-buffer)
4712 (gnus-group-best-unread-group exclude-group))))
4714 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4715 (if backward (gnus-summary-find-prev)
4716 (let* ((dummy (gnus-summary-article-intangible-p))
4717 (article (or article (gnus-summary-article-number)))
4718 (arts (gnus-data-find-list article))
4720 (when (and (not dummy)
4721 (or (not gnus-summary-check-current)
4723 (not (gnus-data-unread-p (car arts)))))
4724 (setq arts (cdr arts)))
4729 (when (or (and undownloaded
4730 (eq gnus-undownloaded-mark
4731 (gnus-data-mark (car arts))))
4732 (gnus-data-unread-p (car arts)))
4733 (setq result (car arts)
4735 (setq arts (cdr arts)))
4738 (goto-char (gnus-data-pos result))
4739 (gnus-data-number result)))))
4741 (defun gnus-summary-find-prev (&optional unread article)
4742 (let* ((eobp (eobp))
4743 (article (or article (gnus-summary-article-number)))
4744 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4746 (when (and (not eobp)
4747 (or (not gnus-summary-check-current)
4749 (not (gnus-data-unread-p (car arts)))))
4750 (setq arts (cdr arts)))
4755 (when (gnus-data-unread-p (car arts))
4756 (setq result (car arts)
4758 (setq arts (cdr arts)))
4761 (goto-char (gnus-data-pos result))
4762 (gnus-data-number result))))
4764 (defun gnus-summary-find-subject (subject &optional unread backward article)
4765 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4766 (article (or article (gnus-summary-article-number)))
4767 (articles (gnus-data-list backward))
4768 (arts (gnus-data-find-list article articles))
4770 (when (or (not gnus-summary-check-current)
4772 (not (gnus-data-unread-p (car arts))))
4773 (setq arts (cdr arts)))
4775 (and (or (not unread)
4776 (gnus-data-unread-p (car arts)))
4777 (vectorp (gnus-data-header (car arts)))
4779 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4780 (setq result (car arts)
4782 (setq arts (cdr arts)))
4784 (goto-char (gnus-data-pos result))
4785 (gnus-data-number result))))
4787 (defun gnus-summary-search-forward (&optional unread subject backward)
4788 "Search forward for an article.
4789 If UNREAD, look for unread articles. If SUBJECT, look for
4790 articles with that subject. If BACKWARD, search backward instead."
4791 (cond (subject (gnus-summary-find-subject subject unread backward))
4792 (backward (gnus-summary-find-prev unread))
4793 (t (gnus-summary-find-next unread))))
4795 (defun gnus-recenter (&optional n)
4796 "Center point in window and redisplay frame.
4797 Also do horizontal recentering."
4799 (when (and gnus-auto-center-summary
4800 (not (eq gnus-auto-center-summary 'vertical)))
4801 (gnus-horizontal-recenter))
4804 (defun gnus-summary-recenter ()
4805 "Center point in the summary window.
4806 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4807 displayed, no centering will be performed."
4808 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4809 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4810 (let* ((top (cond ((< (window-height) 4) 0)
4811 ((< (window-height) 7) 1)
4813 (height (1- (window-height)))
4814 (bottom (save-excursion (goto-char (point-max))
4815 (forward-line (- height))
4817 (window (get-buffer-window (current-buffer))))
4818 ;; The user has to want it.
4819 (when gnus-auto-center-summary
4820 (when (get-buffer-window gnus-article-buffer)
4821 ;; Only do recentering when the article buffer is displayed,
4822 ;; Set the window start to either `bottom', which is the biggest
4823 ;; possible valid number, or the second line from the top,
4824 ;; whichever is the least.
4826 window (min bottom (save-excursion
4827 (forward-line (- top)) (point)))))
4828 ;; Do horizontal recentering while we're at it.
4829 (when (and (get-buffer-window (current-buffer) t)
4830 (not (eq gnus-auto-center-summary 'vertical)))
4831 (let ((selected (selected-window)))
4832 (select-window (get-buffer-window (current-buffer) t))
4833 (gnus-summary-position-point)
4834 (gnus-horizontal-recenter)
4835 (select-window selected))))))
4837 (defun gnus-summary-jump-to-group (newsgroup)
4838 "Move point to NEWSGROUP in group mode buffer."
4839 ;; Keep update point of group mode buffer if visible.
4840 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4841 (save-window-excursion
4842 ;; Take care of tree window mode.
4843 (when (get-buffer-window gnus-group-buffer)
4844 (pop-to-buffer gnus-group-buffer))
4845 (gnus-group-jump-to-group newsgroup))
4847 ;; Take care of tree window mode.
4848 (if (get-buffer-window gnus-group-buffer)
4849 (pop-to-buffer gnus-group-buffer)
4850 (set-buffer gnus-group-buffer))
4851 (gnus-group-jump-to-group newsgroup))))
4853 ;; This function returns a list of article numbers based on the
4854 ;; difference between the ranges of read articles in this group and
4855 ;; the range of active articles.
4856 (defun gnus-list-of-unread-articles (group)
4857 (let* ((read (gnus-info-read (gnus-get-info group)))
4858 (active (or (gnus-active group) (gnus-activate-group group)))
4861 ;; If none are read, then all are unread.
4863 (setq first (car active))
4864 ;; If the range of read articles is a single range, then the
4865 ;; first unread article is the article after the last read
4866 ;; article. Sounds logical, doesn't it?
4867 (if (not (listp (cdr read)))
4868 (setq first (1+ (cdr read)))
4869 ;; `read' is a list of ranges.
4870 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4876 (while (< first nlast)
4878 (setq first (1+ first))))
4879 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4880 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4881 (setq read (cdr read)))))
4882 ;; And add the last unread articles.
4883 (while (<= first last)
4885 (setq first (1+ first)))
4886 ;; Return the list of unread articles.
4887 (delq 0 (nreverse unread))))
4889 (defun gnus-list-of-read-articles (group)
4890 "Return a list of unread, unticked and non-dormant articles."
4891 (let* ((info (gnus-get-info group))
4892 (marked (gnus-info-marks info))
4893 (active (gnus-active group)))
4895 (gnus-set-difference
4896 (gnus-sorted-complement
4897 (gnus-uncompress-range active)
4898 (gnus-list-of-unread-articles group))
4900 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4901 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4903 ;; Various summary commands
4905 (defun gnus-summary-select-article-buffer ()
4906 "Reconfigure windows to show article buffer."
4908 (if (not (gnus-buffer-live-p gnus-article-buffer))
4909 (error "There is no article buffer for this summary buffer")
4910 (gnus-configure-windows 'article)
4911 (select-window (get-buffer-window gnus-article-buffer))))
4913 (defun gnus-summary-universal-argument (arg)
4914 "Perform any operation on all articles that are process/prefixed."
4916 (let ((articles (gnus-summary-work-articles arg))
4923 (substitute-command-keys
4924 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4927 (gnus-error 1 "Undefined key")
4930 (gnus-summary-goto-subject (setq article (pop articles)))
4931 (let (gnus-newsgroup-processable)
4932 (command-execute func))
4933 (gnus-summary-remove-process-mark article)))))
4934 (gnus-summary-position-point))
4936 (defun gnus-summary-toggle-truncation (&optional arg)
4937 "Toggle truncation of summary lines.
4938 With arg, turn line truncation on iff arg is positive."
4940 (setq truncate-lines
4941 (if (null arg) (not truncate-lines)
4942 (> (prefix-numeric-value arg) 0)))
4945 (defun gnus-summary-reselect-current-group (&optional all rescan)
4946 "Exit and then reselect the current newsgroup.
4947 The prefix argument ALL means to select all articles."
4949 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4950 (error "Ephemeral groups can't be reselected"))
4951 (let ((current-subject (gnus-summary-article-number))
4952 (group gnus-newsgroup-name))
4953 (setq gnus-newsgroup-begin nil)
4955 ;; We have to adjust the point of group mode buffer because
4956 ;; point was moved to the next unread newsgroup by exiting.
4957 (gnus-summary-jump-to-group group)
4960 (gnus-group-get-new-news-this-group 1)))
4961 (gnus-group-read-group all t)
4962 (gnus-summary-goto-subject current-subject nil t)))
4964 (defun gnus-summary-rescan-group (&optional all)
4965 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4967 (gnus-summary-reselect-current-group all t))
4969 (defun gnus-summary-update-info (&optional non-destructive)
4971 (let ((group gnus-newsgroup-name))
4973 (when gnus-newsgroup-kill-headers
4974 (setq gnus-newsgroup-killed
4975 (gnus-compress-sequence
4977 (gnus-set-sorted-intersection
4978 (gnus-uncompress-range gnus-newsgroup-killed)
4979 (setq gnus-newsgroup-unselected
4980 (sort gnus-newsgroup-unselected '<)))
4981 (setq gnus-newsgroup-unreads
4982 (sort gnus-newsgroup-unreads '<)))
4984 (unless (listp (cdr gnus-newsgroup-killed))
4985 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4986 (let ((headers gnus-newsgroup-headers))
4987 ;; Set the new ranges of read articles.
4989 (set-buffer gnus-group-buffer)
4990 (gnus-undo-force-boundary))
4991 (gnus-update-read-articles
4992 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4993 ;; Set the current article marks.
4994 (let ((gnus-newsgroup-scored
4995 (if (and (not gnus-save-score)
4996 (not non-destructive))
4998 gnus-newsgroup-scored)))
5000 (gnus-update-marks)))
5001 ;; Do the cross-ref thing.
5002 (when gnus-use-cross-reference
5003 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5004 ;; Do not switch windows but change the buffer to work.
5005 (set-buffer gnus-group-buffer)
5006 (unless (gnus-ephemeral-group-p group)
5007 (gnus-group-update-group group)))))))
5009 (defun gnus-summary-save-newsrc (&optional force)
5010 "Save the current number of read/marked articles in the dribble buffer.
5011 The dribble buffer will then be saved.
5012 If FORCE (the prefix), also save the .newsrc file(s)."
5014 (gnus-summary-update-info t)
5016 (gnus-save-newsrc-file)
5017 (gnus-dribble-save)))
5019 (defun gnus-summary-exit (&optional temporary)
5020 "Exit reading current newsgroup, and then return to group selection mode.
5021 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5023 (gnus-set-global-variables)
5024 (gnus-kill-save-kill-buffer)
5025 (gnus-async-halt-prefetch)
5026 (let* ((group gnus-newsgroup-name)
5027 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5030 (buf (current-buffer)))
5031 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5032 ;; If we have several article buffers, we kill them at exit.
5033 (unless gnus-single-article-buffer
5034 (gnus-kill-buffer gnus-original-article-buffer)
5035 (setq gnus-article-current nil))
5036 (when gnus-use-cache
5037 (gnus-cache-possibly-remove-articles)
5038 (gnus-cache-save-buffers))
5039 (gnus-async-prefetch-remove-group group)
5040 (when gnus-suppress-duplicates
5041 (gnus-dup-enter-articles))
5042 (when gnus-use-trees
5043 (gnus-tree-close group))
5044 ;; Remove entries for this group.
5045 (nnmail-purge-split-history (gnus-group-real-name group))
5046 ;; Make all changes in this group permanent.
5048 (gnus-run-hooks 'gnus-exit-group-hook)
5049 (gnus-summary-update-info)
5050 ;; Do adaptive scoring, and possibly save score files.
5051 (when gnus-newsgroup-adaptive
5052 (gnus-score-adaptive))
5053 (when gnus-use-scoring
5055 (gnus-close-group group)
5056 ;; Make sure where we were, and go to next newsgroup.
5057 (set-buffer gnus-group-buffer)
5059 (gnus-group-jump-to-group group))
5060 (gnus-run-hooks 'gnus-summary-exit-hook)
5061 (unless (or quit-config
5062 ;; If this group has disappeared from the summary
5063 ;; buffer, don't skip forwards.
5064 (not (string= group (gnus-group-group-name))))
5065 (gnus-group-next-unread-group 1))
5066 (setq group-point (point))
5069 ;; If we have several article buffers, we kill them at exit.
5070 (unless gnus-single-article-buffer
5071 (gnus-kill-buffer gnus-article-buffer)
5072 (gnus-kill-buffer gnus-original-article-buffer)
5073 (setq gnus-article-current nil))
5075 (if (not gnus-kill-summary-on-exit)
5076 (gnus-deaden-summary)
5077 ;; We set all buffer-local variables to nil. It is unclear why
5078 ;; this is needed, but if we don't, buffer-local variables are
5079 ;; not garbage-collected, it seems. This would the lead to en
5080 ;; ever-growing Emacs.
5081 (gnus-summary-clear-local-variables)
5082 (when (get-buffer gnus-article-buffer)
5083 (bury-buffer gnus-article-buffer))
5084 ;; We clear the global counterparts of the buffer-local
5085 ;; variables as well, just to be on the safe side.
5086 (set-buffer gnus-group-buffer)
5087 (gnus-summary-clear-local-variables)
5088 ;; Return to group mode buffer.
5089 (when (eq mode 'gnus-summary-mode)
5090 (gnus-kill-buffer buf)))
5091 (setq gnus-current-select-method gnus-select-method)
5092 (pop-to-buffer gnus-group-buffer)
5093 ;; Clear the current group name.
5094 (if (not quit-config)
5096 (goto-char group-point)
5097 (gnus-configure-windows 'group 'force))
5098 (gnus-handle-ephemeral-exit quit-config))
5100 (setq gnus-newsgroup-name nil)))))
5102 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5103 (defun gnus-summary-exit-no-update (&optional no-questions)
5104 "Quit reading current newsgroup without updating read article info."
5106 (let* ((group gnus-newsgroup-name)
5107 (quit-config (gnus-group-quit-config group)))
5108 (when (or no-questions
5110 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5111 (gnus-async-halt-prefetch)
5112 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5113 ;; If we have several article buffers, we kill them at exit.
5114 (unless gnus-single-article-buffer
5115 (gnus-kill-buffer gnus-article-buffer)
5116 (gnus-kill-buffer gnus-original-article-buffer)
5117 (setq gnus-article-current nil))
5118 (if (not gnus-kill-summary-on-exit)
5119 (gnus-deaden-summary)
5120 (gnus-close-group group)
5121 (gnus-summary-clear-local-variables)
5122 (set-buffer gnus-group-buffer)
5123 (gnus-summary-clear-local-variables)
5124 (when (get-buffer gnus-summary-buffer)
5125 (kill-buffer gnus-summary-buffer)))
5126 (unless gnus-single-article-buffer
5127 (setq gnus-article-current nil))
5128 (when gnus-use-trees
5129 (gnus-tree-close group))
5130 (gnus-async-prefetch-remove-group group)
5131 (when (get-buffer gnus-article-buffer)
5132 (bury-buffer gnus-article-buffer))
5133 ;; Return to the group buffer.
5134 (gnus-configure-windows 'group 'force)
5135 ;; Clear the current group name.
5136 (setq gnus-newsgroup-name nil)
5137 (when (equal (gnus-group-group-name) group)
5138 (gnus-group-next-unread-group 1))
5140 (gnus-handle-ephemeral-exit quit-config)))))
5142 (defun gnus-handle-ephemeral-exit (quit-config)
5143 "Handle movement when leaving an ephemeral group. The state
5144 which existed when entering the ephemeral is reset."
5145 (if (not (buffer-name (car quit-config)))
5146 (gnus-configure-windows 'group 'force)
5147 (set-buffer (car quit-config))
5148 (cond ((eq major-mode 'gnus-summary-mode)
5149 (gnus-set-global-variables))
5150 ((eq major-mode 'gnus-article-mode)
5152 ;; The `gnus-summary-buffer' variable may point
5153 ;; to the old summary buffer when using a single
5155 (unless (gnus-buffer-live-p gnus-summary-buffer)
5156 (set-buffer gnus-group-buffer))
5157 (set-buffer gnus-summary-buffer)
5158 (gnus-set-global-variables))))
5159 (if (or (eq (cdr quit-config) 'article)
5160 (eq (cdr quit-config) 'pick))
5162 ;; The current article may be from the ephemeral group
5163 ;; thus it is best that we reload this article
5164 (gnus-summary-show-article)
5165 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5166 (gnus-configure-windows 'pick 'force)
5167 (gnus-configure-windows (cdr quit-config) 'force)))
5168 (gnus-configure-windows (cdr quit-config) 'force))
5169 (when (eq major-mode 'gnus-summary-mode)
5170 (gnus-summary-next-subject 1 nil t)
5171 (gnus-summary-recenter)
5172 (gnus-summary-position-point))))
5174 (defun gnus-summary-preview-mime-message (arg)
5175 "MIME decode and play this message."
5177 (let ((gnus-break-pages nil))
5178 (gnus-summary-select-article t t)
5180 (pop-to-buffer gnus-original-article-buffer t)
5181 (let (buffer-read-only)
5182 (if (text-property-any (point-min) (point-max) 'invisible t)
5183 (remove-text-properties (point-min) (point-max)
5184 gnus-hidden-properties)
5186 (mime-view-mode nil nil nil gnus-original-article-buffer
5187 gnus-article-buffer)
5190 (defun gnus-summary-scroll-down ()
5191 "Scroll down one line current article."
5193 (gnus-summary-scroll-up -1)
5198 (defvar gnus-dead-summary-mode-map nil)
5200 (unless gnus-dead-summary-mode-map
5201 (setq gnus-dead-summary-mode-map (make-keymap))
5202 (suppress-keymap gnus-dead-summary-mode-map)
5203 (substitute-key-definition
5204 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5205 (let ((keys '("\C-d" "\r" "\177" [delete])))
5207 (define-key gnus-dead-summary-mode-map
5208 (pop keys) 'gnus-summary-wake-up-the-dead))))
5210 (defvar gnus-dead-summary-mode nil
5211 "Minor mode for Gnus summary buffers.")
5213 (defun gnus-dead-summary-mode (&optional arg)
5214 "Minor mode for Gnus summary buffers."
5216 (when (eq major-mode 'gnus-summary-mode)
5217 (make-local-variable 'gnus-dead-summary-mode)
5218 (setq gnus-dead-summary-mode
5219 (if (null arg) (not gnus-dead-summary-mode)
5220 (> (prefix-numeric-value arg) 0)))
5221 (when gnus-dead-summary-mode
5222 (gnus-add-minor-mode
5223 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5225 (defun gnus-deaden-summary ()
5226 "Make the current summary buffer into a dead summary buffer."
5227 ;; Kill any previous dead summary buffer.
5228 (when (and gnus-dead-summary
5229 (buffer-name gnus-dead-summary))
5231 (set-buffer gnus-dead-summary)
5232 (when gnus-dead-summary-mode
5233 (kill-buffer (current-buffer)))))
5234 ;; Make this the current dead summary.
5235 (setq gnus-dead-summary (current-buffer))
5236 (gnus-dead-summary-mode 1)
5237 (let ((name (buffer-name)))
5238 (when (string-match "Summary" name)
5240 (concat (substring name 0 (match-beginning 0)) "Dead "
5241 (substring name (match-beginning 0)))
5244 (defun gnus-kill-or-deaden-summary (buffer)
5245 "Kill or deaden the summary BUFFER."
5247 (when (and (buffer-name buffer)
5248 (not gnus-single-article-buffer))
5251 (gnus-kill-buffer gnus-article-buffer)
5252 (gnus-kill-buffer gnus-original-article-buffer)))
5253 (cond (gnus-kill-summary-on-exit
5254 (when (and gnus-use-trees
5255 (gnus-buffer-exists-p buffer))
5258 (gnus-tree-close gnus-newsgroup-name)))
5259 (gnus-kill-buffer buffer))
5260 ((gnus-buffer-exists-p buffer)
5263 (gnus-deaden-summary))))))
5265 (defun gnus-summary-wake-up-the-dead (&rest args)
5266 "Wake up the dead summary buffer."
5268 (gnus-dead-summary-mode -1)
5269 (let ((name (buffer-name)))
5270 (when (string-match "Dead " name)
5272 (concat (substring name 0 (match-beginning 0))
5273 (substring name (match-end 0)))
5275 (gnus-message 3 "This dead summary is now alive again"))
5277 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5278 (defun gnus-summary-fetch-faq (&optional faq-dir)
5279 "Fetch the FAQ for the current group.
5280 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5284 (when current-prefix-arg
5286 "Faq dir: " (and (listp gnus-group-faq-directory)
5287 (mapcar (lambda (file) (list file))
5288 gnus-group-faq-directory))))))
5289 (let (gnus-faq-buffer)
5290 (when (setq gnus-faq-buffer
5291 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5292 (gnus-configure-windows 'summary-faq))))
5294 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5295 (defun gnus-summary-describe-group (&optional force)
5296 "Describe the current newsgroup."
5298 (gnus-group-describe-group force gnus-newsgroup-name))
5300 (defun gnus-summary-describe-briefly ()
5301 "Describe summary mode commands briefly."
5304 (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")))
5306 ;; Walking around group mode buffer from summary mode.
5308 (defun gnus-summary-next-group (&optional no-article target-group backward)
5309 "Exit current newsgroup and then select next unread newsgroup.
5310 If prefix argument NO-ARTICLE is non-nil, no article is selected
5311 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5312 previous group instead."
5314 ;; Stop pre-fetching.
5315 (gnus-async-halt-prefetch)
5316 (let ((current-group gnus-newsgroup-name)
5317 (current-buffer (current-buffer))
5319 ;; First we semi-exit this group to update Xrefs and all variables.
5320 ;; We can't do a real exit, because the window conf must remain
5321 ;; the same in case the user is prompted for info, and we don't
5322 ;; want the window conf to change before that...
5323 (gnus-summary-exit t)
5324 (while (not entered)
5325 ;; Then we find what group we are supposed to enter.
5326 (set-buffer gnus-group-buffer)
5327 (gnus-group-jump-to-group current-group)
5330 (if (eq gnus-keep-same-level 'best)
5331 (gnus-summary-best-group gnus-newsgroup-name)
5332 (gnus-summary-search-group backward gnus-keep-same-level))))
5333 (if (not target-group)
5334 ;; There are no further groups, so we return to the group
5337 (gnus-message 5 "Returning to the group buffer")
5339 (when (gnus-buffer-live-p current-buffer)
5340 (set-buffer current-buffer)
5341 (gnus-summary-exit))
5342 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5343 ;; We try to enter the target group.
5344 (gnus-group-jump-to-group target-group)
5345 (let ((unreads (gnus-group-group-unread)))
5346 (if (and (or (eq t unreads)
5347 (and unreads (not (zerop unreads))))
5348 (gnus-summary-read-group
5349 target-group nil no-article
5350 (and (buffer-name current-buffer) current-buffer)
5353 (setq current-group target-group
5354 target-group nil)))))))
5356 (defun gnus-summary-prev-group (&optional no-article)
5357 "Exit current newsgroup and then select previous unread newsgroup.
5358 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5360 (gnus-summary-next-group no-article nil t))
5362 ;; Walking around summary lines.
5364 (defun gnus-summary-first-subject (&optional unread undownloaded)
5365 "Go to the first unread subject.
5366 If UNREAD is non-nil, go to the first unread article.
5367 Returns the article selected or nil if there are no unread articles."
5372 ((null gnus-newsgroup-data)
5373 (gnus-message 3 "No articles in the group")
5375 ;; Pick the first article.
5377 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5378 (gnus-data-number (car gnus-newsgroup-data)))
5379 ;; No unread articles.
5380 ((null gnus-newsgroup-unreads)
5381 (gnus-message 3 "No more unread articles")
5383 ;; Find the first unread article.
5385 (let ((data gnus-newsgroup-data))
5387 (and (not (and undownloaded
5388 (eq gnus-undownloaded-mark
5389 (gnus-data-mark (car data)))))
5390 (not (gnus-data-unread-p (car data)))))
5391 (setq data (cdr data)))
5393 (goto-char (gnus-data-pos (car data)))
5394 (gnus-data-number (car data))))))
5395 (gnus-summary-position-point)))
5397 (defun gnus-summary-next-subject (n &optional unread dont-display)
5398 "Go to next N'th summary line.
5399 If N is negative, go to the previous N'th subject line.
5400 If UNREAD is non-nil, only unread articles are selected.
5401 The difference between N and the actual number of steps taken is
5404 (let ((backward (< n 0))
5408 (gnus-summary-find-prev unread)
5409 (gnus-summary-find-next unread)))
5410 (gnus-summary-show-thread)
5413 (gnus-message 7 "No more%s articles"
5414 (if unread " unread" "")))
5415 (unless dont-display
5416 (gnus-summary-recenter)
5417 (gnus-summary-position-point))
5420 (defun gnus-summary-next-unread-subject (n)
5421 "Go to next N'th unread summary line."
5423 (gnus-summary-next-subject n t))
5425 (defun gnus-summary-prev-subject (n &optional unread)
5426 "Go to previous N'th summary line.
5427 If optional argument UNREAD is non-nil, only unread article is selected."
5429 (gnus-summary-next-subject (- n) unread))
5431 (defun gnus-summary-prev-unread-subject (n)
5432 "Go to previous N'th unread summary line."
5434 (gnus-summary-next-subject (- n) t))
5436 (defun gnus-summary-goto-subject (article &optional force silent)
5437 "Go the subject line of ARTICLE.
5438 If FORCE, also allow jumping to articles not currently shown."
5439 (interactive "nArticle number: ")
5441 (data (gnus-data-find article)))
5442 ;; We read in the article if we have to.
5445 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5446 (setq data (gnus-data-find article)))
5451 (gnus-message 3 "Can't find article %d" article))
5453 (goto-char (gnus-data-pos data))
5456 ;; Walking around summary lines with displaying articles.
5458 (defun gnus-summary-expand-window (&optional arg)
5459 "Make the summary buffer take up the entire Emacs frame.
5460 Given a prefix, will force an `article' buffer configuration."
5463 (gnus-configure-windows 'article 'force)
5464 (gnus-configure-windows 'summary 'force)))
5466 (defun gnus-summary-display-article (article &optional all-header)
5467 "Display ARTICLE in article buffer."
5468 (gnus-set-global-variables)
5472 (if gnus-summary-display-article-function
5473 (funcall gnus-summary-display-article-function article all-header)
5474 (gnus-article-prepare article all-header))
5475 (gnus-run-hooks 'gnus-select-article-hook)
5476 (when (and gnus-current-article
5477 (not (zerop gnus-current-article)))
5478 (gnus-summary-goto-subject gnus-current-article))
5479 (gnus-summary-recenter)
5480 (when (and gnus-use-trees gnus-show-threads)
5481 (gnus-possibly-generate-tree article)
5482 (gnus-highlight-selected-tree article))
5483 ;; Successfully display article.
5484 (gnus-article-set-window-start
5485 (cdr (assq article gnus-newsgroup-bookmarks))))))
5487 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5488 "Select the current article.
5489 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5490 non-nil, the article will be re-fetched even if it already present in
5491 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5493 ;; Make sure we are in the summary buffer to work around bbdb bug.
5494 (unless (eq major-mode 'gnus-summary-mode)
5495 (set-buffer gnus-summary-buffer))
5496 (let ((article (or article (gnus-summary-article-number)))
5497 (all-headers (not (not all-headers))) ;Must be T or NIL.
5498 gnus-summary-display-article-function
5501 (gnus-summary-article-pseudo-p article)
5502 (error "This is a pseudo-article"))
5505 (set-buffer gnus-summary-buffer)
5506 (if (or (and gnus-single-article-buffer
5507 (or (null gnus-current-article)
5508 (null gnus-article-current)
5509 (null (get-buffer gnus-article-buffer))
5510 (not (eq article (cdr gnus-article-current)))
5511 (not (equal (car gnus-article-current)
5512 gnus-newsgroup-name))))
5513 (and (not gnus-single-article-buffer)
5514 (or (null gnus-current-article)
5515 (not (eq gnus-current-article article))))
5517 ;; The requested article is different from the current article.
5519 (gnus-summary-display-article article all-headers)
5521 (when (or all-headers gnus-show-all-headers)
5522 (gnus-article-show-all-headers))
5525 (gnus-article-set-window-start
5526 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5528 (defun gnus-summary-set-current-mark (&optional current-mark)
5529 "Obsolete function."
5532 (defun gnus-summary-next-article (&optional unread subject backward push)
5533 "Select the next article.
5534 If UNREAD, only unread articles are selected.
5535 If SUBJECT, only articles with SUBJECT are selected.
5536 If BACKWARD, the previous article is selected instead of the next."
5539 ;; Is there such an article?
5540 ((and (gnus-summary-search-forward unread subject backward)
5541 (or (gnus-summary-display-article (gnus-summary-article-number))
5542 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5543 (gnus-summary-position-point))
5544 ;; If not, we try the first unread, if that is wanted.
5546 gnus-auto-select-same
5547 (gnus-summary-first-unread-article))
5548 (gnus-summary-position-point)
5549 (gnus-message 6 "Wrapped"))
5550 ;; Try to get next/previous article not displayed in this group.
5551 ((and gnus-auto-extend-newsgroup
5552 (not unread) (not subject))
5553 (gnus-summary-goto-article
5554 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5556 ;; Go to next/previous group.
5558 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5559 (gnus-summary-jump-to-group gnus-newsgroup-name))
5560 (let ((cmd last-command-char)
5563 (set-buffer gnus-group-buffer)
5566 (if (eq gnus-keep-same-level 'best)
5567 (gnus-summary-best-group gnus-newsgroup-name)
5568 (gnus-summary-search-group backward gnus-keep-same-level))))
5569 ;; For some reason, the group window gets selected. We change
5571 (select-window (get-buffer-window (current-buffer)))
5572 ;; Select next unread newsgroup automagically.
5574 ((or (not gnus-auto-select-next)
5576 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5577 ((or (eq gnus-auto-select-next 'quietly)
5578 (and (eq gnus-auto-select-next 'slightly-quietly)
5580 (and (eq gnus-auto-select-next 'almost-quietly)
5581 (gnus-summary-last-article-p)))
5583 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5585 (gnus-message 7 "No more%s articles (%s)..."
5586 (if unread " unread" "")
5587 (if group (concat "selecting " group)
5589 (gnus-summary-next-group nil group backward)))
5591 (when (gnus-key-press-event-p last-input-event)
5592 (gnus-summary-walk-group-buffer
5593 gnus-newsgroup-name cmd unread backward point))))))))
5595 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5596 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5597 (?\C-p (gnus-group-prev-unread-group 1))))
5598 (cursor-in-echo-area t)
5599 keve key group ended)
5601 (set-buffer gnus-group-buffer)
5604 (if (eq gnus-keep-same-level 'best)
5605 (gnus-summary-best-group gnus-newsgroup-name)
5606 (gnus-summary-search-group backward gnus-keep-same-level))))
5609 5 "No more%s articles%s" (if unread " unread" "")
5611 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5612 (format " (Type %s for %s [%s])"
5613 (single-key-description cmd) group
5614 (car (gnus-gethash group gnus-newsrc-hashtb)))
5615 (format " (Type %s to exit %s)"
5616 (single-key-description cmd)
5617 gnus-newsgroup-name)))
5618 ;; Confirm auto selection.
5619 (setq key (car (setq keve (gnus-read-event-char))))
5622 ((assq key keystrokes)
5623 (let ((obuf (current-buffer)))
5624 (switch-to-buffer gnus-group-buffer)
5626 (gnus-group-jump-to-group group))
5627 (eval (cadr (assq key keystrokes)))
5628 (setq group (gnus-group-group-name))
5629 (switch-to-buffer obuf))
5633 (gnus-ephemeral-group-p gnus-newsgroup-name))
5635 (gnus-summary-next-group nil group backward)))
5637 (push (cdr keve) unread-command-events))))))
5639 (defun gnus-summary-next-unread-article ()
5640 "Select unread article after current one."
5642 (gnus-summary-next-article
5643 (or (not (eq gnus-summary-goto-unread 'never))
5644 (gnus-summary-last-article-p (gnus-summary-article-number)))
5645 (and gnus-auto-select-same
5646 (gnus-summary-article-subject))))
5648 (defun gnus-summary-prev-article (&optional unread subject)
5649 "Select the article after the current one.
5650 If UNREAD is non-nil, only unread articles are selected."
5652 (gnus-summary-next-article unread subject t))
5654 (defun gnus-summary-prev-unread-article ()
5655 "Select unread article before current one."
5657 (gnus-summary-prev-article
5658 (or (not (eq gnus-summary-goto-unread 'never))
5659 (gnus-summary-first-article-p (gnus-summary-article-number)))
5660 (and gnus-auto-select-same
5661 (gnus-summary-article-subject))))
5663 (defun gnus-summary-next-page (&optional lines circular)
5664 "Show next page of the selected article.
5665 If at the end of the current article, select the next article.
5666 LINES says how many lines should be scrolled up.
5668 If CIRCULAR is non-nil, go to the start of the article instead of
5669 selecting the next article when reaching the end of the current
5672 (setq gnus-summary-buffer (current-buffer))
5673 (gnus-set-global-variables)
5674 (let ((article (gnus-summary-article-number))
5675 (article-window (get-buffer-window gnus-article-buffer t))
5677 ;; If the buffer is empty, we have no article.
5679 (error "No article to select"))
5680 (gnus-configure-windows 'article)
5681 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5682 (if (and (eq gnus-summary-goto-unread 'never)
5683 (not (gnus-summary-last-article-p article)))
5684 (gnus-summary-next-article)
5685 (gnus-summary-next-unread-article))
5686 (if (or (null gnus-current-article)
5687 (null gnus-article-current)
5688 (/= article (cdr gnus-article-current))
5689 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5690 ;; Selected subject is different from current article's.
5691 (gnus-summary-display-article article)
5692 (when article-window
5693 (gnus-eval-in-buffer-window gnus-article-buffer
5694 (setq endp (gnus-article-next-page lines)))
5697 (gnus-summary-beginning-of-article))
5699 (gnus-message 3 "End of message"))
5701 (if (and (eq gnus-summary-goto-unread 'never)
5702 (not (gnus-summary-last-article-p article)))
5703 (gnus-summary-next-article)
5704 (gnus-summary-next-unread-article))))))))
5705 (gnus-summary-recenter)
5706 (gnus-summary-position-point)))
5708 (defun gnus-summary-prev-page (&optional lines move)
5709 "Show previous page of selected article.
5710 Argument LINES specifies lines to be scrolled down.
5711 If MOVE, move to the previous unread article if point is at
5712 the beginning of the buffer."
5714 (let ((article (gnus-summary-article-number))
5715 (article-window (get-buffer-window gnus-article-buffer t))
5717 (gnus-configure-windows 'article)
5718 (if (or (null gnus-current-article)
5719 (null gnus-article-current)
5720 (/= article (cdr gnus-article-current))
5721 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5722 ;; Selected subject is different from current article's.
5723 (gnus-summary-display-article article)
5724 (gnus-summary-recenter)
5725 (when article-window
5726 (gnus-eval-in-buffer-window gnus-article-buffer
5727 (setq endp (gnus-article-prev-page lines)))
5728 (when (and move endp)
5730 (gnus-message 3 "Beginning of message"))
5732 (if (and (eq gnus-summary-goto-unread 'never)
5733 (not (gnus-summary-first-article-p article)))
5734 (gnus-summary-prev-article)
5735 (gnus-summary-prev-unread-article))))))))
5736 (gnus-summary-position-point))
5738 (defun gnus-summary-prev-page-or-article (&optional lines)
5739 "Show previous page of selected article.
5740 Argument LINES specifies lines to be scrolled down.
5741 If at the beginning of the article, go to the next article."
5743 (gnus-summary-prev-page lines t))
5745 (defun gnus-summary-scroll-up (lines)
5746 "Scroll up (or down) one line current article.
5747 Argument LINES specifies lines to be scrolled up (or down if negative)."
5749 (gnus-configure-windows 'article)
5750 (gnus-summary-show-thread)
5751 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5752 (gnus-eval-in-buffer-window gnus-article-buffer
5754 (when (gnus-article-next-page lines)
5755 (gnus-message 3 "End of message")))
5757 (gnus-article-prev-page (- lines))))))
5758 (gnus-summary-recenter)
5759 (gnus-summary-position-point))
5761 (defun gnus-summary-next-same-subject ()
5762 "Select next article which has the same subject as current one."
5764 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5766 (defun gnus-summary-prev-same-subject ()
5767 "Select previous article which has the same subject as current one."
5769 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5771 (defun gnus-summary-next-unread-same-subject ()
5772 "Select next unread article which has the same subject as current one."
5774 (gnus-summary-next-article t (gnus-summary-article-subject)))
5776 (defun gnus-summary-prev-unread-same-subject ()
5777 "Select previous unread article which has the same subject as current one."
5779 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5781 (defun gnus-summary-first-unread-article ()
5782 "Select the first unread article.
5783 Return nil if there are no unread articles."
5786 (when (gnus-summary-first-subject t)
5787 (gnus-summary-show-thread)
5788 (gnus-summary-first-subject t)
5789 (gnus-summary-display-article (gnus-summary-article-number)))
5790 (gnus-summary-position-point)))
5792 (defun gnus-summary-first-article ()
5793 "Select the first article.
5794 Return nil if there are no articles."
5797 (when (gnus-summary-first-subject)
5798 (gnus-summary-show-thread)
5799 (gnus-summary-first-subject)
5800 (gnus-summary-display-article (gnus-summary-article-number)))
5801 (gnus-summary-position-point)))
5803 (defun gnus-summary-best-unread-article ()
5804 "Select the unread article with the highest score."
5806 (let ((best -1000000)
5807 (data gnus-newsgroup-data)
5810 (and (gnus-data-unread-p (car data))
5812 (gnus-summary-article-score (gnus-data-number (car data))))
5815 article (gnus-data-number (car data))))
5816 (setq data (cdr data)))
5819 (gnus-summary-goto-article article)
5820 (error "No unread articles"))
5821 (gnus-summary-position-point))))
5823 (defun gnus-summary-last-subject ()
5824 "Go to the last displayed subject line in the group."
5825 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5827 (gnus-summary-goto-subject article))))
5829 (defun gnus-summary-goto-article (article &optional all-headers force)
5830 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5831 If ALL-HEADERS is non-nil, no header lines are hidden."
5835 "Article number or Message-ID: "
5836 (mapcar (lambda (number) (list (int-to-string number)))
5837 gnus-newsgroup-limit))
5841 (if (and (stringp article)
5842 (string-match "@" article))
5843 (gnus-summary-refer-article article)
5844 (when (stringp article)
5845 (setq article (string-to-number article)))
5846 (if (gnus-summary-goto-subject article force)
5847 (gnus-summary-display-article article all-headers)
5848 (gnus-message 4 "Couldn't go to article %s" article) nil))
5849 (gnus-summary-position-point)))
5851 (defun gnus-summary-goto-last-article ()
5852 "Go to the previously read article."
5855 (when gnus-last-article
5856 (gnus-summary-goto-article gnus-last-article nil t))
5857 (gnus-summary-position-point)))
5859 (defun gnus-summary-pop-article (number)
5860 "Pop one article off the history and go to the previous.
5861 NUMBER articles will be popped off."
5864 (setq gnus-newsgroup-history
5865 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5867 (gnus-summary-goto-article (car to) nil t)
5868 (error "Article history empty")))
5869 (gnus-summary-position-point))
5871 ;; Summary commands and functions for limiting the summary buffer.
5873 (defun gnus-summary-limit-to-articles (n)
5874 "Limit the summary buffer to the next N articles.
5875 If not given a prefix, use the process marked articles instead."
5878 (let ((articles (gnus-summary-work-articles n)))
5879 (setq gnus-newsgroup-processable nil)
5880 (gnus-summary-limit articles))
5881 (gnus-summary-position-point)))
5883 (defun gnus-summary-pop-limit (&optional total)
5884 "Restore the previous limit.
5885 If given a prefix, remove all limits."
5888 (setq gnus-newsgroup-limits
5889 (list (mapcar (lambda (h) (mail-header-number h))
5890 gnus-newsgroup-headers))))
5891 (unless gnus-newsgroup-limits
5892 (error "No limit to pop"))
5894 (gnus-summary-limit nil 'pop)
5895 (gnus-summary-position-point)))
5897 (defun gnus-summary-limit-to-subject (subject &optional header)
5898 "Limit the summary buffer to articles that have subjects that match a regexp."
5899 (interactive "sLimit to subject (regexp): ")
5901 (setq header "subject"))
5902 (when (not (equal "" subject))
5904 (let ((articles (gnus-summary-find-matching
5905 (or header "subject") subject 'all)))
5907 (error "Found no matches for \"%s\"" subject))
5908 (gnus-summary-limit articles))
5909 (gnus-summary-position-point))))
5911 (defun gnus-summary-limit-to-author (from)
5912 "Limit the summary buffer to articles that have authors that match a regexp."
5913 (interactive "sLimit to author (regexp): ")
5914 (gnus-summary-limit-to-subject from "from"))
5916 (defun gnus-summary-limit-to-age (age &optional younger-p)
5917 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5918 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5919 articles that are younger than AGE days."
5920 (interactive "nTime in days: \nP")
5922 (let ((data gnus-newsgroup-data)
5923 (cutoff (nnmail-days-to-time age))
5924 articles d date is-younger)
5925 (while (setq d (pop data))
5926 (when (and (vectorp (gnus-data-header d))
5927 (setq date (mail-header-date (gnus-data-header d))))
5928 (setq is-younger (nnmail-time-less
5929 (nnmail-time-since (nnmail-date-to-time date))
5931 (when (if younger-p is-younger (not is-younger))
5932 (push (gnus-data-number d) articles))))
5933 (gnus-summary-limit (nreverse articles)))
5934 (gnus-summary-position-point)))
5936 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5938 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5940 (defun gnus-summary-limit-to-unread (&optional all)
5941 "Limit the summary buffer to articles that are not marked as read.
5942 If ALL is non-nil, limit strictly to unread articles."
5945 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5946 (gnus-summary-limit-to-marks
5947 ;; Concat all the marks that say that an article is read and have
5949 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5950 gnus-killed-mark gnus-kill-file-mark
5951 gnus-low-score-mark gnus-expirable-mark
5952 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5953 gnus-duplicate-mark gnus-souped-mark)
5956 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5957 (make-obsolete 'gnus-summary-delete-marked-with
5958 'gnus-summary-limit-exlude-marks)
5960 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5961 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5962 If REVERSE, limit the summary buffer to articles that are marked
5963 with MARKS. MARKS can either be a string of marks or a list of marks.
5964 Returns how many articles were removed."
5965 (interactive "sMarks: ")
5966 (gnus-summary-limit-to-marks marks t))
5968 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5969 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5970 If REVERSE (the prefix), limit the summary buffer to articles that are
5971 not marked with MARKS. MARKS can either be a string of marks or a
5973 Returns how many articles were removed."
5974 (interactive "sMarks: \nP")
5976 (let ((data gnus-newsgroup-data)
5977 (marks (if (listp marks) marks
5978 (append marks nil))) ; Transform to list.
5981 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5982 (memq (gnus-data-mark (car data)) marks))
5983 (push (gnus-data-number (car data)) articles))
5984 (setq data (cdr data)))
5985 (gnus-summary-limit articles))
5986 (gnus-summary-position-point)))
5988 (defun gnus-summary-limit-to-score (&optional score)
5989 "Limit to articles with score at or above SCORE."
5991 (setq score (if score
5992 (prefix-numeric-value score)
5993 (or gnus-summary-default-score 0)))
5994 (let ((data gnus-newsgroup-data)
5997 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5999 (push (gnus-data-number (car data)) articles))
6000 (setq data (cdr data)))
6002 (gnus-summary-limit articles)
6003 (gnus-summary-position-point))))
6005 (defun gnus-summary-limit-include-thread (id)
6006 "Display all the hidden articles that in the current thread."
6007 (interactive (list (mail-header-id (gnus-summary-article-header))))
6008 (let ((articles (gnus-articles-in-thread
6009 (gnus-id-to-thread (gnus-root-id id)))))
6011 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6012 (gnus-summary-position-point))))
6014 (defun gnus-summary-limit-include-dormant ()
6015 "Display all the hidden articles that are marked as dormant.
6016 Note that this command only works on a subset of the articles currently
6017 fetched for this group."
6019 (unless gnus-newsgroup-dormant
6020 (error "There are no dormant articles in this group"))
6022 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6023 (gnus-summary-position-point)))
6025 (defun gnus-summary-limit-exclude-dormant ()
6026 "Hide all dormant articles."
6029 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6030 (gnus-summary-position-point)))
6032 (defun gnus-summary-limit-exclude-childless-dormant ()
6033 "Hide all dormant articles that have no children."
6035 (let ((data (gnus-data-list t))
6036 articles d children)
6037 ;; Find all articles that are either not dormant or have
6039 (while (setq d (pop data))
6040 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6042 (gnus-article-children (gnus-data-number d)))
6045 (when (memq (car children) articles)
6050 (push (gnus-data-number d) articles)))
6053 (gnus-summary-limit articles)
6054 (gnus-summary-position-point))))
6056 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6057 "Mark all unread excluded articles as read.
6058 If ALL, mark even excluded ticked and dormants as read."
6060 (let ((articles (gnus-sorted-complement
6062 (mapcar (lambda (h) (mail-header-number h))
6063 gnus-newsgroup-headers)
6065 (sort gnus-newsgroup-limit '<)))
6067 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6069 (setq gnus-newsgroup-dormant nil
6070 gnus-newsgroup-marked nil
6071 gnus-newsgroup-reads
6073 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6074 gnus-newsgroup-reads))
6075 (while (setq article (pop articles))
6076 (unless (or (memq article gnus-newsgroup-dormant)
6077 (memq article gnus-newsgroup-marked))
6078 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6080 (defun gnus-summary-limit (articles &optional pop)
6082 ;; We pop the previous limit off the stack and use that.
6083 (setq articles (car gnus-newsgroup-limits)
6084 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6085 ;; We use the new limit, so we push the old limit on the stack.
6086 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6088 (setq gnus-newsgroup-limit articles)
6089 (let ((total (length gnus-newsgroup-data))
6090 (data (gnus-data-find-list (gnus-summary-article-number)))
6091 (gnus-summary-mark-below nil) ; Inhibit this.
6093 ;; This will do all the work of generating the new summary buffer
6094 ;; according to the new limit.
6095 (gnus-summary-prepare)
6096 ;; Hide any threads, possibly.
6097 (and gnus-show-threads
6098 gnus-thread-hide-subtree
6099 (gnus-summary-hide-all-threads))
6100 ;; Try to return to the article you were at, or one in the
6103 ;; We try to find some article after the current one.
6105 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6108 (setq data (cdr data))))
6110 ;; If there is no data, that means that we were after the last
6111 ;; article. The same goes when we can't find any articles
6112 ;; after the current one.
6113 (goto-char (point-max))
6114 (gnus-summary-find-prev))
6115 ;; We return how many articles were removed from the summary
6116 ;; buffer as a result of the new limit.
6117 (- total (length gnus-newsgroup-data))))
6119 (defsubst gnus-invisible-cut-children (threads)
6122 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6127 (defsubst gnus-cut-thread (thread)
6128 "Go forwards in the thread until we find an article that we want to display."
6129 (when (or (eq gnus-fetch-old-headers 'some)
6130 (eq gnus-fetch-old-headers 'invisible)
6131 (eq gnus-build-sparse-threads 'some)
6132 (eq gnus-build-sparse-threads 'more))
6133 ;; Deal with old-fetched headers and sparse threads.
6137 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6138 (gnus-summary-article-ancient-p
6139 (mail-header-number (car thread))))
6140 (if (or (<= (length (cdr thread)) 1)
6141 (eq gnus-fetch-old-headers 'invisible))
6142 (setq gnus-newsgroup-limit
6143 (delq (mail-header-number (car thread))
6144 gnus-newsgroup-limit)
6145 thread (cadr thread))
6146 (when (gnus-invisible-cut-children (cdr thread))
6147 (let ((th (cdr thread)))
6149 (if (memq (mail-header-number (caar th))
6150 gnus-newsgroup-limit)
6151 (setq thread (car th)
6153 (setq th (cdr th))))))))))
6156 (defun gnus-cut-threads (threads)
6157 "Cut off all uninteresting articles from the beginning of threads."
6158 (when (or (eq gnus-fetch-old-headers 'some)
6159 (eq gnus-fetch-old-headers 'invisible)
6160 (eq gnus-build-sparse-threads 'some)
6161 (eq gnus-build-sparse-threads 'more))
6164 (setcar th (gnus-cut-thread (car th)))
6165 (setq th (cdr th)))))
6166 ;; Remove nixed out threads.
6169 (defun gnus-summary-initial-limit (&optional show-if-empty)
6170 "Figure out what the initial limit is supposed to be on group entry.
6171 This entails weeding out unwanted dormants, low-scored articles,
6172 fetch-old-headers verbiage, and so on."
6173 ;; Most groups have nothing to remove.
6174 (if (or gnus-inhibit-limiting
6175 (and (null gnus-newsgroup-dormant)
6176 (not (eq gnus-fetch-old-headers 'some))
6177 (not (eq gnus-fetch-old-headers 'invisible))
6178 (null gnus-summary-expunge-below)
6179 (not (eq gnus-build-sparse-threads 'some))
6180 (not (eq gnus-build-sparse-threads 'more))
6181 (null gnus-thread-expunge-below)
6182 (not gnus-use-nocem)))
6184 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6185 (setq gnus-newsgroup-limit nil)
6188 (unless (car (symbol-value node))
6189 ;; These threads have no parents -- they are roots.
6190 (let ((nodes (cdr (symbol-value node)))
6193 (if (and gnus-thread-expunge-below
6194 (< (gnus-thread-total-score (car nodes))
6195 gnus-thread-expunge-below))
6196 (gnus-expunge-thread (pop nodes))
6197 (setq thread (pop nodes))
6198 (gnus-summary-limit-children thread))))))
6199 gnus-newsgroup-dependencies)
6200 ;; If this limitation resulted in an empty group, we might
6201 ;; pop the previous limit and use it instead.
6202 (when (and (not gnus-newsgroup-limit)
6204 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6205 gnus-newsgroup-limit))
6207 (defun gnus-summary-limit-children (thread)
6208 "Return 1 if this subthread is visible and 0 if it is not."
6209 ;; First we get the number of visible children to this thread. This
6210 ;; is done by recursing down the thread using this function, so this
6211 ;; will really go down to a leaf article first, before slowly
6212 ;; working its way up towards the root.
6216 (apply '+ (mapcar 'gnus-summary-limit-children
6219 (number (mail-header-number (car thread)))
6222 (not (memq number gnus-newsgroup-marked))
6224 ;; If this article is dormant and has absolutely no visible
6225 ;; children, then this article isn't visible.
6226 (and (memq number gnus-newsgroup-dormant)
6228 ;; If this is "fetch-old-headered" and there is no
6229 ;; visible children, then we don't want this article.
6230 (and (eq gnus-fetch-old-headers 'some)
6231 (gnus-summary-article-ancient-p number)
6233 ;; If this is "fetch-old-headered" and `invisible', then
6234 ;; we don't want this article.
6235 (and (eq gnus-fetch-old-headers 'invisible)
6236 (gnus-summary-article-ancient-p number))
6237 ;; If this is a sparsely inserted article with no children,
6238 ;; we don't want it.
6239 (and (eq gnus-build-sparse-threads 'some)
6240 (gnus-summary-article-sparse-p number)
6242 ;; If we use expunging, and this article is really
6243 ;; low-scored, then we don't want this article.
6244 (when (and gnus-summary-expunge-below
6246 (or (cdr (assq number gnus-newsgroup-scored))
6247 gnus-summary-default-score))
6248 gnus-summary-expunge-below))
6249 ;; We increase the expunge-tally here, but that has
6250 ;; nothing to do with the limits, really.
6251 (incf gnus-newsgroup-expunged-tally)
6252 ;; We also mark as read here, if that's wanted.
6253 (when (and gnus-summary-mark-below
6254 (< score gnus-summary-mark-below))
6255 (setq gnus-newsgroup-unreads
6256 (delq number gnus-newsgroup-unreads))
6257 (if gnus-newsgroup-auto-expire
6258 (push number gnus-newsgroup-expirable)
6259 (push (cons number gnus-low-score-mark)
6260 gnus-newsgroup-reads)))
6262 ;; Check NoCeM things.
6263 (if (and gnus-use-nocem
6264 (gnus-nocem-unwanted-article-p
6265 (mail-header-id (car thread))))
6267 (setq gnus-newsgroup-unreads
6268 (delq number gnus-newsgroup-unreads))
6270 ;; Nope, invisible article.
6272 ;; Ok, this article is to be visible, so we add it to the limit
6274 (push number gnus-newsgroup-limit)
6277 (defun gnus-expunge-thread (thread)
6278 "Mark all articles in THREAD as read."
6279 (let* ((number (mail-header-number (car thread))))
6280 (incf gnus-newsgroup-expunged-tally)
6281 ;; We also mark as read here, if that's wanted.
6282 (setq gnus-newsgroup-unreads
6283 (delq number gnus-newsgroup-unreads))
6284 (if gnus-newsgroup-auto-expire
6285 (push number gnus-newsgroup-expirable)
6286 (push (cons number gnus-low-score-mark)
6287 gnus-newsgroup-reads)))
6288 ;; Go recursively through all subthreads.
6289 (mapcar 'gnus-expunge-thread (cdr thread)))
6291 ;; Summary article oriented commands
6293 (defun gnus-summary-refer-parent-article (n)
6294 "Refer parent article N times.
6295 If N is negative, go to ancestor -N instead.
6296 The difference between N and the number of articles fetched is returned."
6300 (when (not (natnump n))
6305 (setq header (gnus-summary-article-header))
6306 (if (and (eq (mail-header-number header)
6307 (cdr gnus-article-current))
6308 (equal gnus-newsgroup-name
6309 (car gnus-article-current)))
6310 ;; If we try to find the parent of the currently
6311 ;; displayed article, then we take a look at the actual
6312 ;; References header, since this is slightly more
6313 ;; reliable than the References field we got from the
6316 (set-buffer gnus-original-article-buffer)
6317 (nnheader-narrow-to-headers)
6318 (unless (setq ref (message-fetch-field "references"))
6319 (setq ref (message-fetch-field "in-reply-to")))
6322 ;; It's not the current article, so we take a bet on
6323 ;; the value we got from the server.
6324 (mail-header-references header)))
6326 (not (equal ref "")))
6327 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6328 (gnus-message 1 "Couldn't find parent"))
6329 (gnus-message 1 "No references in article %d"
6330 (gnus-summary-article-number))
6333 (gnus-summary-position-point)
6336 (defun gnus-summary-refer-references ()
6337 "Fetch all articles mentioned in the References header.
6338 Return the number of articles fetched."
6340 (let ((ref (mail-header-references (gnus-summary-article-header)))
6341 (current (gnus-summary-article-number))
6345 (error "No References in the current article")
6346 ;; For each Message-ID in the References header...
6347 (while (string-match "<[^>]*>" ref)
6349 ;; ... fetch that article.
6350 (gnus-summary-refer-article
6351 (prog1 (match-string 0 ref)
6352 (setq ref (substring ref (match-end 0))))))
6353 (gnus-summary-goto-subject current)
6354 (gnus-summary-position-point)
6357 (defun gnus-summary-refer-thread (&optional limit)
6358 "Fetch all articles in the current thread.
6359 If LIMIT (the numerical prefix), fetch that many old headers instead
6360 of what's specified by the `gnus-refer-thread-limit' variable."
6362 (let ((id (mail-header-id (gnus-summary-article-header)))
6363 (limit (if limit (prefix-numeric-value limit)
6364 gnus-refer-thread-limit))
6366 ;; We want to fetch LIMIT *old* headers, but we also have to
6367 ;; re-fetch all the headers in the current buffer, because many of
6368 ;; them may be undisplayed. So we adjust LIMIT.
6369 (when (numberp limit)
6370 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6371 (unless (eq gnus-fetch-old-headers 'invisible)
6372 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6373 ;; Retrieve the headers and read them in.
6374 (if (eq (gnus-retrieve-headers
6375 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6377 (gnus-build-all-threads)
6378 (error "Can't fetch thread from backends that don't support NOV"))
6379 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6380 (gnus-summary-limit-include-thread id)))
6382 (defun gnus-summary-refer-article (message-id &optional arg)
6383 "Fetch an article specified by MESSAGE-ID.
6384 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6385 or `gnus-select-method', no matter what backend the article comes from."
6386 (interactive "sMessage-ID: \nP")
6387 (when (and (stringp message-id)
6388 (not (zerop (length message-id))))
6389 ;; Construct the correct Message-ID if necessary.
6390 ;; Suggested by tale@pawl.rpi.edu.
6391 (unless (string-match "^<" message-id)
6392 (setq message-id (concat "<" message-id)))
6393 (unless (string-match ">$" message-id)
6394 (setq message-id (concat message-id ">")))
6395 (let* ((header (gnus-id-to-header message-id))
6397 (gnus-summary-article-sparse-p
6398 (mail-header-number header))
6399 (memq (mail-header-number header)
6400 gnus-newsgroup-limit)))
6403 ;; If the article is present in the buffer we just go to it.
6405 (or (not (gnus-summary-article-sparse-p
6406 (mail-header-number header)))
6409 (gnus-summary-goto-article
6410 (mail-header-number header) nil t)
6412 (gnus-summary-update-article (mail-header-number header)))))
6414 ;; We fetch the article
6415 (let ((gnus-override-method
6416 (cond ((gnus-news-group-p gnus-newsgroup-name)
6417 gnus-refer-article-method)
6419 (or gnus-refer-article-method gnus-select-method))
6422 ;; Start the special refer-article method, if necessary.
6423 (when (and gnus-refer-article-method
6424 (gnus-news-group-p gnus-newsgroup-name))
6425 (gnus-check-server gnus-refer-article-method))
6426 ;; Fetch the header, and display the article.
6427 (if (setq number (gnus-summary-insert-subject message-id))
6428 (gnus-summary-select-article nil nil nil number)
6429 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6431 (defun gnus-summary-edit-parameters ()
6432 "Edit the group parameters of the current group."
6434 (gnus-group-edit-group gnus-newsgroup-name 'params))
6436 (defun gnus-summary-enter-digest-group (&optional force)
6437 "Enter an nndoc group based on the current article.
6438 If FORCE, force a digest interpretation. If not, try
6439 to guess what the document format is."
6441 (let ((conf gnus-current-window-configuration))
6443 (gnus-summary-select-article))
6444 (setq gnus-current-window-configuration conf)
6445 (let* ((name (format "%s-%d"
6446 (gnus-group-prefixed-name
6447 gnus-newsgroup-name (list 'nndoc ""))
6449 (set-buffer gnus-summary-buffer)
6450 gnus-current-article)))
6451 (ogroup gnus-newsgroup-name)
6452 (params (append (gnus-info-params (gnus-get-info ogroup))
6453 (list (cons 'to-group ogroup))
6454 (list (cons 'save-article-group ogroup))))
6455 (case-fold-search t)
6456 (buf (current-buffer))
6459 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6460 (insert-buffer-substring gnus-original-article-buffer)
6461 ;; Remove lines that may lead nndoc to misinterpret the
6464 (goto-char (point-min))
6465 (or (search-forward "\n\n" nil t) (point)))
6466 (goto-char (point-min))
6467 (delete-matching-lines "^\\(Path\\):\\|^From ")
6470 (if (gnus-group-read-ephemeral-group
6471 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6473 ,(if force 'digest 'guess))) t)
6474 ;; Make all postings to this group go to the parent group.
6475 (nconc (gnus-info-params (gnus-get-info name))
6477 ;; Couldn't select this doc group.
6478 (switch-to-buffer buf)
6479 (gnus-set-global-variables)
6480 (gnus-configure-windows 'summary)
6481 (gnus-message 3 "Article couldn't be entered?"))
6482 (kill-buffer dig)))))
6484 (defun gnus-summary-read-document (n)
6485 "Open a new group based on the current article(s).
6486 This will allow you to read digests and other similar
6487 documents as newsgroups.
6488 Obeys the standard process/prefix convention."
6490 (let* ((articles (gnus-summary-work-articles n))
6491 (ogroup gnus-newsgroup-name)
6492 (params (append (gnus-info-params (gnus-get-info ogroup))
6493 (list (cons 'to-group ogroup))))
6494 article group egroup groups vgroup)
6495 (while (setq article (pop articles))
6496 (setq group (format "%s-%d" gnus-newsgroup-name article))
6497 (gnus-summary-remove-process-mark article)
6498 (when (gnus-summary-display-article article)
6500 (nnheader-temp-write nil
6501 (insert-buffer-substring gnus-original-article-buffer)
6502 ;; Remove some headers that may lead nndoc to make
6504 (message-narrow-to-head)
6505 (goto-char (point-min))
6506 (delete-matching-lines "^\\(Path\\):\\|^From ")
6509 (gnus-group-read-ephemeral-group
6510 group `(nndoc ,group (nndoc-address ,(current-buffer))
6511 (nndoc-article-type guess))
6514 ;; Make all postings to this group go to the parent group.
6515 (nconc (gnus-info-params (gnus-get-info egroup))
6517 (push egroup groups))
6518 ;; Couldn't select this doc group.
6519 (gnus-error 3 "Article couldn't be entered"))))))
6520 ;; Now we have selected all the documents.
6523 (error "None of the articles could be interpreted as documents"))
6524 ((gnus-group-read-ephemeral-group
6525 (setq vgroup (format
6526 "nnvirtual:%s-%s" gnus-newsgroup-name
6527 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6528 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6530 (cons (current-buffer) 'summary)))
6532 (error "Couldn't select virtual nndoc group")))))
6534 (defun gnus-summary-isearch-article (&optional regexp-p)
6535 "Do incremental search forward on the current article.
6536 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6538 (gnus-summary-select-article)
6539 (gnus-configure-windows 'article)
6540 (gnus-eval-in-buffer-window gnus-article-buffer
6543 (isearch-forward regexp-p))))
6545 (defun gnus-summary-search-article-forward (regexp &optional backward)
6546 "Search for an article containing REGEXP forward.
6547 If BACKWARD, search backward instead."
6550 (format "Search article %s (regexp%s): "
6551 (if current-prefix-arg "backward" "forward")
6552 (if gnus-last-search-regexp
6553 (concat ", default " gnus-last-search-regexp)
6555 current-prefix-arg))
6556 (if (string-equal regexp "")
6557 (setq regexp (or gnus-last-search-regexp ""))
6558 (setq gnus-last-search-regexp regexp))
6559 (if (gnus-summary-search-article regexp backward)
6560 (gnus-summary-show-thread)
6561 (error "Search failed: \"%s\"" regexp)))
6563 (defun gnus-summary-search-article-backward (regexp)
6564 "Search for an article containing REGEXP backward."
6567 (format "Search article backward (regexp%s): "
6568 (if gnus-last-search-regexp
6569 (concat ", default " gnus-last-search-regexp)
6571 (gnus-summary-search-article-forward regexp 'backward))
6573 (defun gnus-summary-search-article (regexp &optional backward)
6574 "Search for an article containing REGEXP.
6575 Optional argument BACKWARD means do search for backward.
6576 `gnus-select-article-hook' is not called during the search."
6577 ;; We have to require this here to make sure that the following
6578 ;; dynamic binding isn't shadowed by autoloading.
6579 (require 'gnus-async)
6580 (let ((gnus-select-article-hook nil) ;Disable hook.
6581 (gnus-article-display-hook nil)
6582 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6583 (gnus-use-article-prefetch nil)
6584 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6585 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6586 (sum (current-buffer))
6589 (gnus-save-hidden-threads
6590 (gnus-summary-select-article)
6591 (set-buffer gnus-article-buffer)
6595 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6597 (re-search-backward regexp nil t)
6598 (re-search-forward regexp nil t))
6599 ;; We found the regexp.
6604 (get-buffer-window (current-buffer))
6608 (setq point (point)))
6609 ;; We didn't find it, so we go to the next article.
6612 (while (eq found 'not)
6613 (if (not (if backward (gnus-summary-find-prev)
6614 (gnus-summary-find-next)))
6615 ;; No more articles.
6617 ;; Select the next article and adjust point.
6618 (unless (gnus-summary-article-sparse-p
6619 (gnus-summary-article-number))
6621 (gnus-summary-select-article)
6622 (set-buffer gnus-article-buffer)
6624 (goto-char (if backward (point-max) (point-min))))))))
6625 (gnus-message 7 ""))
6626 ;; Return whether we found the regexp.
6627 (when (eq found 'found)
6629 (gnus-summary-show-thread)
6630 (gnus-summary-goto-subject gnus-current-article)
6631 (gnus-summary-position-point)
6634 (defun gnus-summary-find-matching (header regexp &optional backward unread
6636 "Return a list of all articles that match REGEXP on HEADER.
6637 The search stars on the current article and goes forwards unless
6638 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6639 If UNREAD is non-nil, only unread articles will
6640 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6641 in the comparisons."
6642 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6643 (gnus-data-find-list
6644 (gnus-summary-article-number) (gnus-data-list backward))))
6645 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6646 (case-fold-search (not not-case-fold))
6648 (unless (fboundp (intern (concat "mail-header-" header)))
6649 (error "%s is not a valid header" header))
6652 (and (or (not unread) ; We want all articles...
6653 (gnus-data-unread-p d)) ; Or just unreads.
6654 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6655 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6656 (push (gnus-data-number d) articles)) ; Success!
6657 (setq data (cdr data)))
6658 (nreverse articles)))
6660 (defun gnus-summary-execute-command (header regexp command &optional backward)
6661 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6662 If HEADER is an empty string (or nil), the match is done on the entire
6663 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6665 (list (let ((completion-ignore-case t))
6668 (mapcar (lambda (string) (list string))
6669 '("Number" "Subject" "From" "Lines" "Date"
6670 "Message-ID" "Xref" "References" "Body"))
6671 nil 'require-match))
6672 (read-string "Regexp: ")
6673 (read-key-sequence "Command: ")
6674 current-prefix-arg))
6675 (when (equal header "Body")
6677 ;; Hidden thread subtrees must be searched as well.
6678 (gnus-summary-show-all-threads)
6679 ;; We don't want to change current point nor window configuration.
6681 (save-window-excursion
6682 (gnus-message 6 "Executing %s..." (key-description command))
6683 ;; We'd like to execute COMMAND interactively so as to give arguments.
6684 (gnus-execute header regexp
6685 `(call-interactively ',(key-binding command))
6687 (gnus-message 6 "Executing %s...done" (key-description command)))))
6689 (defun gnus-summary-beginning-of-article ()
6690 "Scroll the article back to the beginning."
6692 (gnus-summary-select-article)
6693 (gnus-configure-windows 'article)
6694 (gnus-eval-in-buffer-window gnus-article-buffer
6696 (goto-char (point-min))
6697 (when gnus-page-broken
6698 (gnus-narrow-to-page))))
6700 (defun gnus-summary-end-of-article ()
6701 "Scroll to the end of the article."
6703 (gnus-summary-select-article)
6704 (gnus-configure-windows 'article)
6705 (gnus-eval-in-buffer-window gnus-article-buffer
6707 (goto-char (point-max))
6709 (when gnus-page-broken
6710 (gnus-narrow-to-page))))
6712 (defun gnus-summary-print-article (&optional filename n)
6713 "Generate and print a PostScript image of the N next (mail) articles.
6715 If N is negative, print the N previous articles. If N is nil and articles
6716 have been marked with the process mark, print these instead.
6718 If the optional second argument FILENAME is nil, send the image to the
6719 printer. If FILENAME is a string, save the PostScript image in a file with
6720 that name. If FILENAME is a number, prompt the user for the name of the file
6722 (interactive (list (ps-print-preprint current-prefix-arg)
6723 current-prefix-arg))
6724 (dolist (article (gnus-summary-work-articles n))
6725 (gnus-summary-select-article nil nil 'pseudo article)
6726 (gnus-eval-in-buffer-window gnus-article-buffer
6727 (let ((buffer (generate-new-buffer " *print*")))
6730 (copy-to-buffer buffer (point-min) (point-max))
6732 (gnus-article-delete-invisible-text)
6733 (let ((ps-left-header
6736 (mail-header-subject gnus-current-headers) ")")
6738 (mail-header-from gnus-current-headers) ")")))
6741 "/pagenumberstring load"
6743 (mail-header-date gnus-current-headers) ")"))))
6744 (gnus-run-hooks 'gnus-ps-print-hook)
6746 (ps-print-buffer-with-faces filename))))
6747 (kill-buffer buffer))))))
6749 (defun gnus-summary-show-article (&optional arg)
6750 "Force re-fetching of the current article.
6751 If ARG (the prefix) is non-nil, show the raw article without any
6752 article massaging functions being run."
6755 ;; Select the article the normal way.
6756 (gnus-summary-select-article nil 'force)
6757 ;; Bind the article treatment functions to nil.
6758 (let ((gnus-have-all-headers t)
6759 gnus-article-display-hook
6760 gnus-article-prepare-hook
6764 (gnus-summary-select-article nil 'force)))
6765 (gnus-summary-goto-subject gnus-current-article)
6766 (gnus-summary-position-point))
6768 (defun gnus-summary-verbose-headers (&optional arg)
6769 "Toggle permanent full header display.
6770 If ARG is a positive number, turn header display on.
6771 If ARG is a negative number, turn header display off."
6773 (setq gnus-show-all-headers
6774 (cond ((or (not (numberp arg))
6776 (not gnus-show-all-headers))
6779 (gnus-summary-show-article))
6781 (defun gnus-summary-toggle-header (&optional arg)
6782 "Show the headers if they are hidden, or hide them if they are shown.
6783 If ARG is a positive number, show the entire header.
6784 If ARG is a negative number, hide the unwanted header lines."
6787 (set-buffer gnus-article-buffer)
6788 (let* ((buffer-read-only nil)
6789 (inhibit-point-motion-hooks t)
6790 (hidden (text-property-any
6791 (goto-char (point-min)) (search-forward "\n\n")
6794 (goto-char (point-min))
6795 (when (search-forward "\n\n" nil t)
6796 (delete-region (point-min) (1- (point))))
6797 (goto-char (point-min))
6799 (set-buffer gnus-original-article-buffer)
6800 (goto-char (point-min))
6801 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6802 (insert-buffer-substring gnus-original-article-buffer 1 e)
6803 (let ((article-inhibit-hiding t))
6804 (gnus-run-hooks 'gnus-article-display-hook))
6805 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6806 (gnus-article-hide-headers)))))
6808 (defun gnus-summary-show-all-headers ()
6809 "Make all header lines visible."
6811 (gnus-article-show-all-headers))
6813 (defun gnus-summary-toggle-mime (&optional arg)
6814 "Toggle MIME processing.
6815 If ARG is a positive number, turn MIME processing on."
6817 (setq gnus-show-mime
6818 (if (null arg) (not gnus-show-mime)
6819 (> (prefix-numeric-value arg) 0)))
6820 (gnus-summary-select-article t 'force))
6822 (defun gnus-summary-caesar-message (&optional arg)
6823 "Caesar rotate the current article by 13.
6824 The numerical prefix specifies how many places to rotate each letter
6827 (gnus-summary-select-article)
6828 (let ((mail-header-separator ""))
6829 (gnus-eval-in-buffer-window gnus-article-buffer
6832 (let ((start (window-start))
6834 (message-caesar-buffer-body arg)
6835 (set-window-start (get-buffer-window (current-buffer)) start))))))
6837 (defun gnus-summary-stop-page-breaking ()
6838 "Stop page breaking in the current article."
6840 (gnus-summary-select-article)
6841 (gnus-eval-in-buffer-window gnus-article-buffer
6843 (when (gnus-visual-p 'page-marker)
6844 (let ((buffer-read-only nil))
6845 (gnus-remove-text-with-property 'gnus-prev)
6846 (gnus-remove-text-with-property 'gnus-next))
6847 (setq gnus-page-broken nil))))
6849 (defun gnus-summary-move-article (&optional n to-newsgroup
6850 select-method action)
6851 "Move the current article to a different newsgroup.
6852 If N is a positive number, move the N next articles.
6853 If N is a negative number, move the N previous articles.
6854 If N is nil and any articles have been marked with the process mark,
6855 move those articles instead.
6856 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6857 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6858 re-spool using this method.
6860 For this function to work, both the current newsgroup and the
6861 newsgroup that you want to move to have to support the `request-move'
6862 and `request-accept' functions."
6865 (setq action 'move))
6866 ;; Disable marking as read.
6867 (let (gnus-mark-article-hook)
6868 (save-window-excursion
6869 (gnus-summary-select-article)))
6870 ;; Check whether the source group supports the required functions.
6871 (cond ((and (eq action 'move)
6872 (not (gnus-check-backend-function
6873 'request-move-article gnus-newsgroup-name)))
6874 (error "The current group does not support article moving"))
6875 ((and (eq action 'crosspost)
6876 (not (gnus-check-backend-function
6877 'request-replace-article gnus-newsgroup-name)))
6878 (error "The current group does not support article editing")))
6879 (let ((articles (gnus-summary-work-articles n))
6880 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6881 (names '((move "Move" "Moving")
6882 (copy "Copy" "Copying")
6883 (crosspost "Crosspost" "Crossposting")))
6884 (copy-buf (save-excursion
6885 (nnheader-set-temp-buffer " *copy article*")))
6886 art-group to-method new-xref article to-groups)
6887 (unless (assq action names)
6888 (error "Unknown action %s" action))
6889 ;; Read the newsgroup name.
6890 (when (and (not to-newsgroup)
6891 (not select-method))
6893 (gnus-read-move-group-name
6894 (cadr (assq action names))
6895 (symbol-value (intern (format "gnus-current-%s-group" action)))
6897 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6898 (setq to-method (or select-method
6899 (gnus-group-name-to-method to-newsgroup)))
6900 ;; Check the method we are to move this article to...
6901 (unless (gnus-check-backend-function
6902 'request-accept-article (car to-method))
6903 (error "%s does not support article copying" (car to-method)))
6904 (unless (gnus-check-server to-method)
6905 (error "Can't open server %s" (car to-method)))
6906 (gnus-message 6 "%s to %s: %s..."
6907 (caddr (assq action names))
6908 (or (car select-method) to-newsgroup) articles)
6910 (setq article (pop articles))
6914 ;; Move the article.
6916 ;; Remove this article from future suppression.
6917 (gnus-dup-unsuppress-article article)
6918 (gnus-request-move-article
6919 article ; Article to move
6920 gnus-newsgroup-name ; From newsgroup
6921 (nth 1 (gnus-find-method-for-group
6922 gnus-newsgroup-name)) ; Server
6923 (list 'gnus-request-accept-article
6924 to-newsgroup (list 'quote select-method)
6925 (not articles)) ; Accept form
6926 (not articles))) ; Only save nov last time
6927 ;; Copy the article.
6930 (set-buffer copy-buf)
6931 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6932 (gnus-request-accept-article
6933 to-newsgroup select-method (not articles)))))
6934 ;; Crosspost the article.
6935 ((eq action 'crosspost)
6936 (let ((xref (message-tokenize-header
6937 (mail-header-xref (gnus-summary-article-header article))
6939 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6942 (setq xref (list (system-name))))
6945 (mapconcat 'identity
6946 (delete "Xref:" (delete new-xref xref))
6950 (set-buffer copy-buf)
6951 ;; First put the article in the destination group.
6952 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6953 (when (consp (setq art-group
6954 (gnus-request-accept-article
6955 to-newsgroup select-method (not articles))))
6956 (setq new-xref (concat new-xref " " (car art-group)
6957 ":" (cdr art-group)))
6958 ;; Now we have the new Xrefs header, so we insert
6959 ;; it and replace the new article.
6960 (nnheader-replace-header "Xref" new-xref)
6961 (gnus-request-replace-article
6962 (cdr art-group) to-newsgroup (current-buffer))
6966 (gnus-message 1 "Couldn't %s article %s"
6967 (cadr (assq action names)) article))
6968 ((and (eq art-group 'junk)
6970 (gnus-summary-mark-article article gnus-canceled-mark)
6971 (gnus-message 4 "Deleted article %s" article))
6975 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6977 (gnus-group-prefixed-name
6980 (gnus-find-method-for-group to-newsgroup)))
6981 gnus-newsrc-hashtb)))
6982 (info (nth 2 entry))
6983 (to-group (gnus-info-group info)))
6984 ;; Update the group that has been moved to.
6986 (memq action '(move copy)))
6987 (unless (member to-group to-groups)
6988 (push to-group to-groups))
6990 (unless (memq article gnus-newsgroup-unreads)
6992 info (gnus-add-to-range (gnus-info-read info)
6993 (list (cdr art-group)))))
6995 ;; Copy any marks over to the new group.
6996 (let ((marks gnus-article-mark-lists)
6997 (to-article (cdr art-group)))
6999 ;; See whether the article is to be put in the cache.
7000 (when gnus-use-cache
7001 (gnus-cache-possibly-enter-article
7003 (let ((header (copy-sequence
7004 (gnus-summary-article-header article))))
7005 (mail-header-set-number header to-article)
7007 (memq article gnus-newsgroup-marked)
7008 (memq article gnus-newsgroup-dormant)
7009 (memq article gnus-newsgroup-unreads)))
7011 (when (and (equal to-group gnus-newsgroup-name)
7012 (not (memq article gnus-newsgroup-unreads)))
7013 ;; Mark this article as read in this group.
7014 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7015 (setcdr (gnus-active to-group) to-article)
7016 (setcdr gnus-newsgroup-active to-article))
7019 (when (memq article (symbol-value
7020 (intern (format "gnus-newsgroup-%s"
7022 ;; If the other group is the same as this group,
7023 ;; then we have to add the mark to the list.
7024 (when (equal to-group gnus-newsgroup-name)
7025 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7028 (intern (format "gnus-newsgroup-%s"
7030 ;; Copy the marks to other group.
7031 (gnus-add-marked-articles
7032 to-group (cdar marks) (list to-article) info))
7033 (setq marks (cdr marks)))
7036 (concat "(gnus-group-set-info '"
7037 (gnus-prin1-to-string (gnus-get-info to-group))
7040 ;; Update the Xref header in this article to point to
7041 ;; the new crossposted article we have just created.
7042 (when (eq action 'crosspost)
7044 (set-buffer copy-buf)
7045 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7046 (nnheader-replace-header "Xref" new-xref)
7047 (gnus-request-replace-article
7048 article gnus-newsgroup-name (current-buffer)))))
7050 ;;;!!!Why is this necessary?
7051 (set-buffer gnus-summary-buffer)
7053 (gnus-summary-goto-subject article)
7054 (when (eq action 'move)
7055 (gnus-summary-mark-article article gnus-canceled-mark))))
7056 (gnus-summary-remove-process-mark article))
7057 ;; Re-activate all groups that have been moved to.
7060 (set-buffer gnus-group-buffer)
7061 (when (gnus-group-goto-group (car to-groups) t)
7062 (gnus-group-get-new-news-this-group 1 t))
7065 (gnus-kill-buffer copy-buf)
7066 (gnus-summary-position-point)
7067 (gnus-set-mode-line 'summary)))
7069 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7070 "Move the current article to a different newsgroup.
7071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7072 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7073 re-spool using this method."
7075 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7077 (defun gnus-summary-crosspost-article (&optional n)
7078 "Crosspost the current article to some other group."
7080 (gnus-summary-move-article n nil nil 'crosspost))
7082 (defcustom gnus-summary-respool-default-method nil
7083 "Default method for respooling an article.
7084 If nil, use to the current newsgroup method."
7085 :type `(choice (gnus-select-method :value (nnml ""))
7087 :group 'gnus-summary-mail)
7089 (defun gnus-summary-respool-article (&optional n method)
7090 "Respool the current article.
7091 The article will be squeezed through the mail spooling process again,
7092 which means that it will be put in some mail newsgroup or other
7093 depending on `nnmail-split-methods'.
7094 If N is a positive number, respool the N next articles.
7095 If N is a negative number, respool the N previous articles.
7096 If N is nil and any articles have been marked with the process mark,
7097 respool those articles instead.
7099 Respooling can be done both from mail groups and \"real\" newsgroups.
7100 In the former case, the articles in question will be moved from the
7101 current group into whatever groups they are destined to. In the
7102 latter case, they will be copied into the relevant groups."
7104 (list current-prefix-arg
7105 (let* ((methods (gnus-methods-using 'respool))
7107 (symbol-name (or gnus-summary-respool-default-method
7108 (car (gnus-find-method-for-group
7109 gnus-newsgroup-name)))))
7111 (gnus-completing-read
7112 methname "What backend do you want to use when respooling?"
7113 methods nil t nil 'gnus-mail-method-history))
7116 ((zerop (length (setq ms (gnus-servers-using-backend
7118 (list (intern method) ""))
7122 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7123 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7126 (error "No method given for respooling"))
7127 (if (assoc (symbol-name
7128 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7129 (gnus-methods-using 'respool))
7130 (gnus-summary-move-article n nil method)
7131 (gnus-summary-copy-article n nil method)))
7133 (defun gnus-summary-import-article (file)
7134 "Import an arbitrary file into a mail newsgroup."
7135 (interactive "fImport file: ")
7136 (let ((group gnus-newsgroup-name)
7137 (now (current-time))
7139 (unless (gnus-check-backend-function 'request-accept-article group)
7140 (error "%s does not support article importing" group))
7141 (or (file-readable-p file)
7142 (not (file-regular-p file))
7143 (error "Can't read %s" file))
7145 (set-buffer (get-buffer-create " *import file*"))
7146 (buffer-disable-undo (current-buffer))
7148 (nnheader-insert-file-contents file)
7149 (goto-char (point-min))
7150 (unless (nnheader-article-p)
7151 ;; This doesn't look like an article, so we fudge some headers.
7152 (setq atts (file-attributes file)
7153 lines (count-lines (point-min) (point-max)))
7154 (insert "From: " (read-string "From: ") "\n"
7155 "Subject: " (read-string "Subject: ") "\n"
7156 "Date: " (timezone-make-date-arpa-standard
7157 (current-time-string (nth 5 atts))
7158 (current-time-zone now)
7159 (current-time-zone now))
7161 "Message-ID: " (message-make-message-id) "\n"
7162 "Lines: " (int-to-string lines) "\n"
7163 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7164 (gnus-request-accept-article group nil t)
7165 (kill-buffer (current-buffer)))))
7167 (defun gnus-summary-article-posted-p ()
7168 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7169 This will be the case if the article has both been mailed and posted."
7171 (let ((id (mail-header-references (gnus-summary-article-header)))
7172 (gnus-override-method
7173 (or gnus-refer-article-method gnus-select-method)))
7174 (if (gnus-request-head id "")
7175 (gnus-message 2 "The current message was found on %s"
7176 gnus-override-method)
7177 (gnus-message 2 "The current message couldn't be found on %s"
7178 gnus-override-method)
7181 (defun gnus-summary-expire-articles (&optional now)
7182 "Expire all articles that are marked as expirable in the current group."
7184 (when (gnus-check-backend-function
7185 'request-expire-articles gnus-newsgroup-name)
7186 ;; This backend supports expiry.
7187 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7188 (expirable (if total
7190 ;; We need to update the info for
7191 ;; this group for `gnus-list-of-read-articles'
7192 ;; to give us the right answer.
7193 (gnus-run-hooks 'gnus-exit-group-hook)
7194 (gnus-summary-update-info)
7195 (gnus-list-of-read-articles gnus-newsgroup-name))
7196 (setq gnus-newsgroup-expirable
7197 (sort gnus-newsgroup-expirable '<))))
7198 (expiry-wait (if now 'immediate
7199 (gnus-group-find-parameter
7200 gnus-newsgroup-name 'expiry-wait)))
7203 ;; There are expirable articles in this group, so we run them
7204 ;; through the expiry process.
7205 (gnus-message 6 "Expiring articles...")
7206 ;; The list of articles that weren't expired is returned.
7209 (let ((nnmail-expiry-wait-function nil)
7210 (nnmail-expiry-wait expiry-wait))
7211 (setq es (gnus-request-expire-articles
7212 expirable gnus-newsgroup-name)))
7213 (setq es (gnus-request-expire-articles
7214 expirable gnus-newsgroup-name))))
7216 (setq gnus-newsgroup-expirable es))
7217 ;; We go through the old list of expirable, and mark all
7218 ;; really expired articles as nonexistent.
7219 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7220 (let ((gnus-use-cache nil))
7222 (unless (memq (car expirable) es)
7223 (when (gnus-data-find (car expirable))
7224 (gnus-summary-mark-article
7225 (car expirable) gnus-canceled-mark)))
7226 (setq expirable (cdr expirable)))))
7227 (gnus-message 6 "Expiring articles...done")))))
7229 (defun gnus-summary-expire-articles-now ()
7230 "Expunge all expirable articles in the current group.
7231 This means that *all* articles that are marked as expirable will be
7232 deleted forever, right now."
7234 (or gnus-expert-user
7236 "Are you really, really, really sure you want to delete all these messages? ")
7238 (gnus-summary-expire-articles t))
7240 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7241 (defun gnus-summary-delete-article (&optional n)
7242 "Delete the N next (mail) articles.
7243 This command actually deletes articles. This is not a marking
7244 command. The article will disappear forever from your life, never to
7246 If N is negative, delete backwards.
7247 If N is nil and articles have been marked with the process mark,
7248 delete these instead."
7250 (unless (gnus-check-backend-function 'request-expire-articles
7251 gnus-newsgroup-name)
7252 (error "The current newsgroup does not support article deletion"))
7253 ;; Compute the list of articles to delete.
7254 (let ((articles (gnus-summary-work-articles n))
7256 (if (and gnus-novice-user
7257 (not (gnus-yes-or-no-p
7258 (format "Do you really want to delete %s forever? "
7259 (if (> (length articles) 1)
7260 (format "these %s articles" (length articles))
7263 ;; Delete the articles.
7264 (setq not-deleted (gnus-request-expire-articles
7265 articles gnus-newsgroup-name 'force))
7267 (gnus-summary-remove-process-mark (car articles))
7268 ;; The backend might not have been able to delete the article
7270 (unless (memq (car articles) not-deleted)
7271 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7272 (setq articles (cdr articles)))
7274 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7275 (gnus-summary-position-point)
7276 (gnus-set-mode-line 'summary)
7279 (defun gnus-summary-edit-article (&optional force)
7280 "Edit the current article.
7281 This will have permanent effect only in mail groups.
7282 If FORCE is non-nil, allow editing of articles even in read-only
7286 (set-buffer gnus-summary-buffer)
7287 (gnus-set-global-variables)
7288 (when (and (not force)
7289 (gnus-group-read-only-p))
7290 (error "The current newsgroup does not support article editing"))
7291 ;; Select article if needed.
7292 (unless (eq (gnus-summary-article-number)
7293 gnus-current-article)
7294 (gnus-summary-select-article t))
7295 (gnus-article-date-original)
7296 (gnus-article-edit-article
7297 `(lambda (no-highlight)
7298 (gnus-summary-edit-article-done
7299 ,(or (mail-header-references gnus-current-headers) "")
7300 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7302 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7304 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7306 "Make edits to the current article permanent."
7308 ;; Replace the article.
7309 (if (and (not read-only)
7310 (not (gnus-request-replace-article
7311 (cdr gnus-article-current) (car gnus-article-current)
7313 (error "Couldn't replace article")
7314 ;; Update the summary buffer.
7316 (equal (message-tokenize-header references " ")
7317 (message-tokenize-header
7318 (or (message-fetch-field "references") "") " ")))
7319 ;; We only have to update this line.
7322 (message-narrow-to-head)
7323 (let ((head (buffer-string))
7325 (nnheader-temp-write nil
7326 (insert (format "211 %d Article retrieved.\n"
7327 (cdr gnus-article-current)))
7330 (let ((nntp-server-buffer (current-buffer)))
7331 (setq header (car (gnus-get-newsgroup-headers
7333 (set-buffer gnus-summary-buffer)
7334 gnus-newsgroup-dependencies)
7337 (set-buffer gnus-summary-buffer)
7338 (gnus-data-set-header
7339 (gnus-data-find (cdr gnus-article-current))
7341 (gnus-summary-update-article-line
7342 (cdr gnus-article-current) header))))))
7344 (set-buffer (or buffer gnus-summary-buffer))
7345 (gnus-summary-update-article (cdr gnus-article-current)))
7346 ;; Prettify the article buffer again.
7347 (unless no-highlight
7349 (set-buffer gnus-article-buffer)
7350 (gnus-run-hooks 'gnus-article-display-hook)
7351 (set-buffer gnus-original-article-buffer)
7352 (gnus-request-article
7353 (cdr gnus-article-current)
7354 (car gnus-article-current) (current-buffer))))
7355 ;; Prettify the summary buffer line.
7356 (when (gnus-visual-p 'summary-highlight 'highlight)
7357 (gnus-run-hooks 'gnus-visual-mark-article-hook))))
7359 (defun gnus-summary-edit-wash (key)
7360 "Perform editing command KEY in the article buffer."
7364 (message "%s" (concat (this-command-keys) "- "))
7367 (gnus-summary-edit-article)
7368 (execute-kbd-macro (concat (this-command-keys) key))
7369 (gnus-article-edit-done))
7373 (defun gnus-summary-respool-query (&optional silent)
7374 "Query where the respool algorithm would put this article."
7376 (let (gnus-mark-article-hook)
7377 (gnus-summary-select-article)
7379 (set-buffer gnus-original-article-buffer)
7381 (message-narrow-to-head)
7382 (let ((groups (nnmail-article-group 'identity)))
7385 (message "This message would go to %s"
7386 (mapconcat 'car groups ", "))
7387 (message "This message would go to no groups"))
7390 ;; Summary marking commands.
7392 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7393 "Mark articles which has the same subject as read, and then select the next.
7394 If UNMARK is positive, remove any kind of mark.
7395 If UNMARK is negative, tick articles."
7398 (setq unmark (prefix-numeric-value unmark)))
7400 (gnus-summary-mark-same-subject
7401 (gnus-summary-article-subject) unmark)))
7402 ;; Select next unread article. If auto-select-same mode, should
7403 ;; select the first unread article.
7404 (gnus-summary-next-article t (and gnus-auto-select-same
7405 (gnus-summary-article-subject)))
7406 (gnus-message 7 "%d article%s marked as %s"
7407 count (if (= count 1) " is" "s are")
7408 (if unmark "unread" "read"))))
7410 (defun gnus-summary-kill-same-subject (&optional unmark)
7411 "Mark articles which has the same subject as read.
7412 If UNMARK is positive, remove any kind of mark.
7413 If UNMARK is negative, tick articles."
7416 (setq unmark (prefix-numeric-value unmark)))
7418 (gnus-summary-mark-same-subject
7419 (gnus-summary-article-subject) unmark)))
7420 ;; If marked as read, go to next unread subject.
7422 ;; Go to next unread subject.
7423 (gnus-summary-next-subject 1 t))
7424 (gnus-message 7 "%d articles are marked as %s"
7425 count (if unmark "unread" "read"))))
7427 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7428 "Mark articles with same SUBJECT as read, and return marked number.
7429 If optional argument UNMARK is positive, remove any kinds of marks.
7430 If optional argument UNMARK is negative, mark articles as unread instead."
7434 ((null unmark) ; Mark as read.
7437 (gnus-summary-mark-article-as-read gnus-killed-mark)
7438 (gnus-summary-show-thread) t)
7439 (gnus-summary-find-subject subject))
7440 (setq count (1+ count))))
7441 ((> unmark 0) ; Tick.
7444 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7445 (gnus-summary-show-thread) t)
7446 (gnus-summary-find-subject subject))
7447 (setq count (1+ count))))
7448 (t ; Mark as unread.
7451 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7452 (gnus-summary-show-thread) t)
7453 (gnus-summary-find-subject subject))
7454 (setq count (1+ count)))))
7455 (gnus-set-mode-line 'summary)
7456 ;; Return the number of marked articles.
7459 (defun gnus-summary-mark-as-processable (n &optional unmark)
7460 "Set the process mark on the next N articles.
7461 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7462 the process mark instead. The difference between N and the actual
7463 number of articles marked is returned."
7465 (let ((backward (< n 0))
7470 (gnus-summary-remove-process-mark
7471 (gnus-summary-article-number))
7472 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7473 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7476 (gnus-message 7 "No more articles"))
7477 (gnus-summary-recenter)
7478 (gnus-summary-position-point)
7481 (defun gnus-summary-unmark-as-processable (n)
7482 "Remove the process mark from the next N articles.
7483 If N is negative, unmark backward instead. The difference between N and
7484 the actual number of articles unmarked is returned."
7486 (gnus-summary-mark-as-processable n t))
7488 (defun gnus-summary-unmark-all-processable ()
7489 "Remove the process mark from all articles."
7492 (while gnus-newsgroup-processable
7493 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7494 (gnus-summary-position-point))
7496 (defun gnus-summary-mark-as-expirable (n)
7497 "Mark N articles forward as expirable.
7498 If N is negative, mark backward instead. The difference between N and
7499 the actual number of articles marked is returned."
7501 (gnus-summary-mark-forward n gnus-expirable-mark))
7503 (defun gnus-summary-mark-article-as-replied (article)
7504 "Mark ARTICLE replied and update the summary line."
7505 (push article gnus-newsgroup-replied)
7506 (let ((buffer-read-only nil))
7507 (when (gnus-summary-goto-subject article)
7508 (gnus-summary-update-secondary-mark article))))
7510 (defun gnus-summary-set-bookmark (article)
7511 "Set a bookmark in current article."
7512 (interactive (list (gnus-summary-article-number)))
7513 (when (or (not (get-buffer gnus-article-buffer))
7514 (not gnus-current-article)
7515 (not gnus-article-current)
7516 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7517 (error "No current article selected"))
7518 ;; Remove old bookmark, if one exists.
7519 (let ((old (assq article gnus-newsgroup-bookmarks)))
7521 (setq gnus-newsgroup-bookmarks
7522 (delq old gnus-newsgroup-bookmarks))))
7523 ;; Set the new bookmark, which is on the form
7524 ;; (article-number . line-number-in-body).
7528 (set-buffer gnus-article-buffer)
7532 (goto-char (point-min))
7533 (search-forward "\n\n" nil t)
7536 gnus-newsgroup-bookmarks)
7537 (gnus-message 6 "A bookmark has been added to the current article."))
7539 (defun gnus-summary-remove-bookmark (article)
7540 "Remove the bookmark from the current article."
7541 (interactive (list (gnus-summary-article-number)))
7542 ;; Remove old bookmark, if one exists.
7543 (let ((old (assq article gnus-newsgroup-bookmarks)))
7546 (setq gnus-newsgroup-bookmarks
7547 (delq old gnus-newsgroup-bookmarks))
7548 (gnus-message 6 "Removed bookmark."))
7549 (gnus-message 6 "No bookmark in current article."))))
7551 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7552 (defun gnus-summary-mark-as-dormant (n)
7553 "Mark N articles forward as dormant.
7554 If N is negative, mark backward instead. The difference between N and
7555 the actual number of articles marked is returned."
7557 (gnus-summary-mark-forward n gnus-dormant-mark))
7559 (defun gnus-summary-set-process-mark (article)
7560 "Set the process mark on ARTICLE and update the summary line."
7561 (setq gnus-newsgroup-processable
7563 (delq article gnus-newsgroup-processable)))
7564 (when (gnus-summary-goto-subject article)
7565 (gnus-summary-show-thread)
7566 (gnus-summary-update-secondary-mark article)))
7568 (defun gnus-summary-remove-process-mark (article)
7569 "Remove the process mark from ARTICLE and update the summary line."
7570 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7571 (when (gnus-summary-goto-subject article)
7572 (gnus-summary-show-thread)
7573 (gnus-summary-update-secondary-mark article)))
7575 (defun gnus-summary-set-saved-mark (article)
7576 "Set the process mark on ARTICLE and update the summary line."
7577 (push article gnus-newsgroup-saved)
7578 (when (gnus-summary-goto-subject article)
7579 (gnus-summary-update-secondary-mark article)))
7581 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7582 "Mark N articles as read forwards.
7583 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7584 The difference between N and the actual number of articles marked is
7587 (let ((backward (< n 0))
7588 (gnus-summary-goto-unread
7589 (and gnus-summary-goto-unread
7590 (not (eq gnus-summary-goto-unread 'never))
7591 (not (memq mark (list gnus-unread-mark
7592 gnus-ticked-mark gnus-dormant-mark)))))
7594 (mark (or mark gnus-del-mark)))
7596 (gnus-summary-mark-article nil mark no-expire)
7597 (zerop (gnus-summary-next-subject
7599 (and gnus-summary-goto-unread
7600 (not (eq gnus-summary-goto-unread 'never)))
7604 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7605 (gnus-summary-recenter)
7606 (gnus-summary-position-point)
7607 (gnus-set-mode-line 'summary)
7610 (defun gnus-summary-mark-article-as-read (mark)
7611 "Mark the current article quickly as read with MARK."
7612 (let ((article (gnus-summary-article-number)))
7613 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7614 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7615 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7616 (push (cons article mark) gnus-newsgroup-reads)
7617 ;; Possibly remove from cache, if that is used.
7618 (when gnus-use-cache
7619 (gnus-cache-enter-remove-article article))
7620 ;; Allow the backend to change the mark.
7621 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7622 ;; Check for auto-expiry.
7623 (when (and gnus-newsgroup-auto-expire
7624 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7625 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7626 (= mark gnus-ancient-mark)
7627 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7628 (= mark gnus-duplicate-mark)))
7629 (setq mark gnus-expirable-mark)
7630 (push article gnus-newsgroup-expirable))
7631 ;; Set the mark in the buffer.
7632 (gnus-summary-update-mark mark 'unread)
7635 (defun gnus-summary-mark-article-as-unread (mark)
7636 "Mark the current article quickly as unread with MARK."
7637 (let* ((article (gnus-summary-article-number))
7638 (old-mark (gnus-summary-article-mark article)))
7639 (if (eq mark old-mark)
7643 (gnus-error 1 "Can't mark negative article numbers")
7645 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7646 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7647 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7648 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7649 (cond ((= mark gnus-ticked-mark)
7650 (push article gnus-newsgroup-marked))
7651 ((= mark gnus-dormant-mark)
7652 (push article gnus-newsgroup-dormant))
7654 (push article gnus-newsgroup-unreads)))
7655 (setq gnus-newsgroup-reads
7656 (delq (assq article gnus-newsgroup-reads)
7657 gnus-newsgroup-reads))
7659 ;; See whether the article is to be put in the cache.
7661 (vectorp (gnus-summary-article-header article))
7663 (gnus-cache-possibly-enter-article
7664 gnus-newsgroup-name article
7665 (gnus-summary-article-header article)
7666 (= mark gnus-ticked-mark)
7667 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7670 (gnus-summary-update-mark mark 'unread)
7673 (defun gnus-summary-mark-article (&optional article mark no-expire)
7674 "Mark ARTICLE with MARK. MARK can be any character.
7675 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7676 `??' (dormant) and `?E' (expirable).
7677 If MARK is nil, then the default character `?D' is used.
7678 If ARTICLE is nil, then the article on the current line will be
7680 ;; The mark might be a string.
7681 (when (stringp mark)
7682 (setq mark (aref mark 0)))
7683 ;; If no mark is given, then we check auto-expiring.
7684 (and (not no-expire)
7685 gnus-newsgroup-auto-expire
7687 (and (gnus-characterp mark)
7688 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7689 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7690 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7691 (= mark gnus-duplicate-mark))))
7692 (setq mark gnus-expirable-mark))
7693 (let* ((mark (or mark gnus-del-mark))
7694 (article (or article (gnus-summary-article-number)))
7695 (old-mark (gnus-summary-article-mark article)))
7696 (if (eq mark old-mark)
7699 (error "No article on current line"))
7700 (if (not (if (or (= mark gnus-unread-mark)
7701 (= mark gnus-ticked-mark)
7702 (= mark gnus-dormant-mark))
7703 (gnus-mark-article-as-unread article mark)
7704 (gnus-mark-article-as-read article mark)))
7706 ;; See whether the article is to be put in the cache.
7708 (not (= mark gnus-canceled-mark))
7709 (vectorp (gnus-summary-article-header article))
7711 (gnus-cache-possibly-enter-article
7712 gnus-newsgroup-name article
7713 (gnus-summary-article-header article)
7714 (= mark gnus-ticked-mark)
7715 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7717 (when (gnus-summary-goto-subject article nil t)
7718 (let ((buffer-read-only nil))
7719 (gnus-summary-show-thread)
7721 (gnus-summary-update-mark mark 'unread)
7724 (defun gnus-summary-update-secondary-mark (article)
7725 "Update the secondary (read, process, cache) mark."
7726 (gnus-summary-update-mark
7727 (cond ((memq article gnus-newsgroup-processable)
7729 ((memq article gnus-newsgroup-cached)
7731 ((memq article gnus-newsgroup-replied)
7733 ((memq article gnus-newsgroup-saved)
7735 (t gnus-unread-mark))
7737 (when (gnus-visual-p 'summary-highlight 'highlight)
7738 (gnus-run-hooks 'gnus-summary-update-hook))
7741 (defun gnus-summary-update-mark (mark type)
7742 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7743 (buffer-read-only nil))
7744 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7745 (when (looking-at "\r")
7748 (<= (+ forward (point)) (point-max)))
7749 ;; Go to the right position on the line.
7750 (goto-char (+ forward (point)))
7751 ;; Replace the old mark with the new mark.
7752 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7753 ;; Optionally update the marks by some user rule.
7754 (when (eq type 'unread)
7756 (gnus-data-find (gnus-summary-article-number)) mark)
7757 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7759 (defun gnus-mark-article-as-read (article &optional mark)
7760 "Enter ARTICLE in the pertinent lists and remove it from others."
7761 ;; Make the article expirable.
7762 (let ((mark (or mark gnus-del-mark)))
7763 (if (= mark gnus-expirable-mark)
7764 (push article gnus-newsgroup-expirable)
7765 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7766 ;; Remove from unread and marked lists.
7767 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7768 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7769 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7770 (push (cons article mark) gnus-newsgroup-reads)
7771 ;; Possibly remove from cache, if that is used.
7772 (when gnus-use-cache
7773 (gnus-cache-enter-remove-article article))
7776 (defun gnus-mark-article-as-unread (article &optional mark)
7777 "Enter ARTICLE in the pertinent lists and remove it from others."
7778 (let ((mark (or mark gnus-ticked-mark)))
7781 (gnus-error 1 "Can't mark negative article numbers")
7783 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7784 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7785 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7786 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7788 ;; Unsuppress duplicates?
7789 (when gnus-suppress-duplicates
7790 (gnus-dup-unsuppress-article article))
7792 (cond ((= mark gnus-ticked-mark)
7793 (push article gnus-newsgroup-marked))
7794 ((= mark gnus-dormant-mark)
7795 (push article gnus-newsgroup-dormant))
7797 (push article gnus-newsgroup-unreads)))
7798 (setq gnus-newsgroup-reads
7799 (delq (assq article gnus-newsgroup-reads)
7800 gnus-newsgroup-reads))
7803 (defalias 'gnus-summary-mark-as-unread-forward
7804 'gnus-summary-tick-article-forward)
7805 (make-obsolete 'gnus-summary-mark-as-unread-forward
7806 'gnus-summary-tick-article-forward)
7807 (defun gnus-summary-tick-article-forward (n)
7808 "Tick N articles forwards.
7809 If N is negative, tick backwards instead.
7810 The difference between N and the number of articles ticked is returned."
7812 (gnus-summary-mark-forward n gnus-ticked-mark))
7814 (defalias 'gnus-summary-mark-as-unread-backward
7815 'gnus-summary-tick-article-backward)
7816 (make-obsolete 'gnus-summary-mark-as-unread-backward
7817 'gnus-summary-tick-article-backward)
7818 (defun gnus-summary-tick-article-backward (n)
7819 "Tick N articles backwards.
7820 The difference between N and the number of articles ticked is returned."
7822 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7824 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7825 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7826 (defun gnus-summary-tick-article (&optional article clear-mark)
7827 "Mark current article as unread.
7828 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7829 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7831 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7834 (defun gnus-summary-mark-as-read-forward (n)
7835 "Mark N articles as read forwards.
7836 If N is negative, mark backwards instead.
7837 The difference between N and the actual number of articles marked is
7840 (gnus-summary-mark-forward n gnus-del-mark t))
7842 (defun gnus-summary-mark-as-read-backward (n)
7843 "Mark the N articles as read backwards.
7844 The difference between N and the actual number of articles marked is
7847 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7849 (defun gnus-summary-mark-as-read (&optional article mark)
7850 "Mark current article as read.
7851 ARTICLE specifies the article to be marked as read.
7852 MARK specifies a string to be inserted at the beginning of the line."
7853 (gnus-summary-mark-article article mark))
7855 (defun gnus-summary-clear-mark-forward (n)
7856 "Clear marks from N articles forward.
7857 If N is negative, clear backward instead.
7858 The difference between N and the number of marks cleared is returned."
7860 (gnus-summary-mark-forward n gnus-unread-mark))
7862 (defun gnus-summary-clear-mark-backward (n)
7863 "Clear marks from N articles backward.
7864 The difference between N and the number of marks cleared is returned."
7866 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7868 (defun gnus-summary-mark-unread-as-read ()
7869 "Intended to be used by `gnus-summary-mark-article-hook'."
7870 (when (memq gnus-current-article gnus-newsgroup-unreads)
7871 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7873 (defun gnus-summary-mark-read-and-unread-as-read ()
7874 "Intended to be used by `gnus-summary-mark-article-hook'."
7875 (let ((mark (gnus-summary-article-mark)))
7876 (when (or (gnus-unread-mark-p mark)
7877 (gnus-read-mark-p mark))
7878 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7880 (defun gnus-summary-mark-region-as-read (point mark all)
7881 "Mark all unread articles between point and mark as read.
7882 If given a prefix, mark all articles between point and mark as read,
7883 even ticked and dormant ones."
7884 (interactive "r\nP")
7893 (memq (setq article (gnus-summary-article-number))
7894 gnus-newsgroup-unreads))
7895 (gnus-summary-mark-article article gnus-del-mark))
7897 (gnus-summary-find-next))))))
7899 (defun gnus-summary-mark-below (score mark)
7900 "Mark articles with score less than SCORE with MARK."
7901 (interactive "P\ncMark: ")
7902 (setq score (if score
7903 (prefix-numeric-value score)
7904 (or gnus-summary-default-score 0)))
7906 (set-buffer gnus-summary-buffer)
7907 (goto-char (point-min))
7910 (and (< (gnus-summary-article-score) score)
7911 (gnus-summary-mark-article nil mark))
7912 (gnus-summary-find-next)))))
7914 (defun gnus-summary-kill-below (&optional score)
7915 "Mark articles with score below SCORE as read."
7917 (gnus-summary-mark-below score gnus-killed-mark))
7919 (defun gnus-summary-clear-above (&optional score)
7920 "Clear all marks from articles with score above SCORE."
7922 (gnus-summary-mark-above score gnus-unread-mark))
7924 (defun gnus-summary-tick-above (&optional score)
7925 "Tick all articles with score above SCORE."
7927 (gnus-summary-mark-above score gnus-ticked-mark))
7929 (defun gnus-summary-mark-above (score mark)
7930 "Mark articles with score over SCORE with MARK."
7931 (interactive "P\ncMark: ")
7932 (setq score (if score
7933 (prefix-numeric-value score)
7934 (or gnus-summary-default-score 0)))
7936 (set-buffer gnus-summary-buffer)
7937 (goto-char (point-min))
7939 (when (> (gnus-summary-article-score) score)
7940 (gnus-summary-mark-article nil mark))
7942 (gnus-summary-find-next)))))
7944 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7945 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7946 (defun gnus-summary-limit-include-expunged (&optional no-error)
7947 "Display all the hidden articles that were expunged for low scores."
7949 (let ((buffer-read-only nil))
7950 (let ((scored gnus-newsgroup-scored)
7953 (unless (gnus-summary-goto-subject (caar scored))
7954 (and (setq h (gnus-summary-article-header (caar scored)))
7955 (< (cdar scored) gnus-summary-expunge-below)
7957 (setq scored (cdr scored)))
7959 (when (not no-error)
7960 (error "No expunged articles hidden"))
7961 (goto-char (point-min))
7962 (gnus-summary-prepare-unthreaded (nreverse headers))
7963 (goto-char (point-min))
7964 (gnus-summary-position-point)
7967 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7968 "Mark all unread articles in this newsgroup as read.
7969 If prefix argument ALL is non-nil, ticked and dormant articles will
7970 also be marked as read.
7971 If QUIETLY is non-nil, no questions will be asked.
7972 If TO-HERE is non-nil, it should be a point in the buffer. All
7973 articles before this point will be marked as read.
7974 Note that this function will only catch up the unread article
7975 in the current summary buffer limitation.
7976 The number of articles marked as read is returned."
7981 (not gnus-interactive-catchup) ;Without confirmation?
7985 "Mark absolutely all articles as read? "
7986 "Mark all unread articles as read? ")))
7988 (not gnus-newsgroup-adaptive)
7989 (not gnus-newsgroup-auto-expire)
7990 (not gnus-suppress-duplicates)
7991 (or (not gnus-use-cache)
7992 (eq gnus-use-cache 'passive)))
7995 (setq gnus-newsgroup-marked nil
7996 gnus-newsgroup-dormant nil))
7997 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
7998 ;; We actually mark all articles as canceled, which we
7999 ;; have to do when using auto-expiry or adaptive scoring.
8000 (gnus-summary-show-all-threads)
8001 (when (gnus-summary-first-subject (not all) t)
8003 (if to-here (< (point) to-here) t)
8004 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8005 (gnus-summary-find-next (not all) nil nil t))))
8006 (gnus-set-mode-line 'summary))
8008 (gnus-summary-position-point)))
8010 (defun gnus-summary-catchup-to-here (&optional all)
8011 "Mark all unticked articles before the current one as read.
8012 If ALL is non-nil, also mark ticked and dormant articles as read."
8015 (gnus-save-hidden-threads
8016 (let ((beg (point)))
8017 ;; We check that there are unread articles.
8018 (when (or all (gnus-summary-find-prev))
8019 (gnus-summary-catchup all t beg)))))
8020 (gnus-summary-position-point))
8022 (defun gnus-summary-catchup-all (&optional quietly)
8023 "Mark all articles in this newsgroup as read."
8025 (gnus-summary-catchup t quietly))
8027 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8028 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8029 If prefix argument ALL is non-nil, all articles are marked as read."
8031 (when (gnus-summary-catchup all quietly nil 'fast)
8032 ;; Select next newsgroup or exit.
8033 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8034 (eq gnus-auto-select-next 'quietly))
8035 (gnus-summary-next-group nil)
8036 (gnus-summary-exit))))
8038 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8039 "Mark all articles in this newsgroup as read, and then exit."
8041 (gnus-summary-catchup-and-exit t quietly))
8043 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8044 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8045 "Mark all articles in this group as read and select the next group.
8046 If given a prefix, mark all articles, unread as well as ticked, as
8050 (gnus-summary-catchup all))
8051 (gnus-summary-next-article t nil nil t))
8053 ;; Thread-based commands.
8055 (defun gnus-summary-articles-in-thread (&optional article)
8056 "Return a list of all articles in the current thread.
8057 If ARTICLE is non-nil, return all articles in the thread that starts
8059 (let* ((article (or article (gnus-summary-article-number)))
8060 (data (gnus-data-find-list article))
8061 (top-level (gnus-data-level (car data)))
8063 (cond ((null gnus-thread-operation-ignore-subject)
8064 (gnus-simplify-subject-re
8065 (mail-header-subject (gnus-data-header (car data)))))
8066 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8067 (gnus-simplify-subject-fuzzy
8068 (mail-header-subject (gnus-data-header (car data)))))
8070 (end-point (save-excursion
8071 (if (gnus-summary-go-to-next-thread)
8072 (point) (point-max))))
8075 (< (gnus-data-pos (car data)) end-point))
8076 (when (or (not top-subject)
8077 (string= top-subject
8078 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8079 (gnus-simplify-subject-fuzzy
8080 (mail-header-subject
8081 (gnus-data-header (car data))))
8082 (gnus-simplify-subject-re
8083 (mail-header-subject
8084 (gnus-data-header (car data)))))))
8085 (push (gnus-data-number (car data)) articles))
8086 (unless (and (setq data (cdr data))
8087 (> (gnus-data-level (car data)) top-level))
8089 ;; Return the list of articles.
8090 (nreverse articles)))
8092 (defun gnus-summary-rethread-current ()
8093 "Rethread the thread the current article is part of."
8095 (let* ((gnus-show-threads t)
8096 (article (gnus-summary-article-number))
8097 (id (mail-header-id (gnus-summary-article-header)))
8098 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8100 (error "No article on the current line"))
8101 (gnus-rebuild-thread id)
8102 (gnus-summary-goto-subject article)))
8104 (defun gnus-summary-reparent-thread ()
8105 "Make the current article child of the marked (or previous) article.
8107 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8108 is non-nil or the Subject: of both articles are the same."
8110 (unless (not (gnus-group-read-only-p))
8111 (error "The current newsgroup does not support article editing"))
8112 (unless (<= (length gnus-newsgroup-processable) 1)
8113 (error "No more than one article may be marked"))
8114 (save-window-excursion
8115 (let ((gnus-article-buffer " *reparent*")
8116 (current-article (gnus-summary-article-number))
8117 ;; First grab the marked article, otherwise one line up.
8118 (parent-article (if (not (null gnus-newsgroup-processable))
8119 (car gnus-newsgroup-processable)
8121 (if (eq (forward-line -1) 0)
8122 (gnus-summary-article-number)
8123 (error "Beginning of summary buffer"))))))
8124 (unless (not (eq current-article parent-article))
8125 (error "An article may not be self-referential"))
8126 (let ((message-id (mail-header-id
8127 (gnus-summary-article-header parent-article))))
8128 (unless (and message-id (not (equal message-id "")))
8129 (error "No message-id in desired parent"))
8130 ;; We don't want the article to be marked as read.
8131 (let (gnus-mark-article-hook)
8132 (gnus-summary-select-article t t nil current-article))
8133 (set-buffer gnus-original-article-buffer)
8134 (let ((buf (format "%s" (buffer-string))))
8135 (nnheader-temp-write nil
8137 (goto-char (point-min))
8138 (if (re-search-forward "^References: " nil t)
8140 (re-search-forward "^[^ \t]" nil t)
8143 (insert " " message-id))
8144 (insert "References: " message-id "\n"))
8145 (unless (gnus-request-replace-article
8146 current-article (car gnus-article-current)
8148 (error "Couldn't replace article"))))
8149 (set-buffer gnus-summary-buffer)
8150 (gnus-summary-unmark-all-processable)
8151 (gnus-summary-update-article current-article)
8152 (gnus-summary-rethread-current)
8153 (gnus-message 3 "Article %d is now the child of article %d"
8154 current-article parent-article)))))
8156 (defun gnus-summary-toggle-threads (&optional arg)
8157 "Toggle showing conversation threads.
8158 If ARG is positive number, turn showing conversation threads on."
8160 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8161 (setq gnus-show-threads
8162 (if (null arg) (not gnus-show-threads)
8163 (> (prefix-numeric-value arg) 0)))
8164 (gnus-summary-prepare)
8165 (gnus-summary-goto-subject current)
8166 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8167 (gnus-summary-position-point)))
8169 (defun gnus-summary-show-all-threads ()
8173 (let ((buffer-read-only nil))
8174 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8175 (gnus-summary-position-point))
8177 (defun gnus-summary-show-thread ()
8178 "Show thread subtrees.
8179 Returns nil if no thread was there to be shown."
8181 (let ((buffer-read-only nil)
8183 ;; first goto end then to beg, to have point at beg after let
8184 (end (progn (end-of-line) (point)))
8185 (beg (progn (beginning-of-line) (point))))
8187 ;; Any hidden lines here?
8188 (search-forward "\r" end t)
8189 (subst-char-in-region beg end ?\^M ?\n t)
8191 (gnus-summary-position-point))))
8193 (defun gnus-summary-hide-all-threads ()
8194 "Hide all thread subtrees."
8197 (goto-char (point-min))
8198 (gnus-summary-hide-thread)
8199 (while (zerop (gnus-summary-next-thread 1 t))
8200 (gnus-summary-hide-thread)))
8201 (gnus-summary-position-point))
8203 (defun gnus-summary-hide-thread ()
8204 "Hide thread subtrees.
8205 Returns nil if no threads were there to be hidden."
8207 (let ((buffer-read-only nil)
8209 (article (gnus-summary-article-number)))
8211 ;; Go forward until either the buffer ends or the subthread
8213 (when (and (not (eobp))
8214 (or (zerop (gnus-summary-next-thread 1 t))
8215 (goto-char (point-max))))
8217 (if (and (> (point) start)
8218 (search-backward "\n" start t))
8220 (subst-char-in-region start (point) ?\n ?\^M)
8221 (gnus-summary-goto-subject article))
8224 ;;(gnus-summary-position-point)
8227 (defun gnus-summary-go-to-next-thread (&optional previous)
8228 "Go to the same level (or less) next thread.
8229 If PREVIOUS is non-nil, go to previous thread instead.
8230 Return the article number moved to, or nil if moving was impossible."
8231 (let ((level (gnus-summary-thread-level))
8232 (way (if previous -1 1))
8235 (while (and (not (eobp))
8236 (< level (gnus-summary-thread-level)))
8244 (gnus-summary-article-number)
8247 (defun gnus-summary-next-thread (n &optional silent)
8248 "Go to the same level next N'th thread.
8249 If N is negative, search backward instead.
8250 Returns the difference between N and the number of skips actually
8253 If SILENT, don't output messages."
8255 (let ((backward (< n 0))
8258 (gnus-summary-go-to-next-thread backward))
8261 (gnus-summary-position-point))
8262 (when (and (not silent) (/= 0 n))
8263 (gnus-message 7 "No more threads"))
8266 (defun gnus-summary-prev-thread (n)
8267 "Go to the same level previous N'th thread.
8268 Returns the difference between N and the number of skips actually
8271 (gnus-summary-next-thread (- n)))
8273 (defun gnus-summary-go-down-thread ()
8274 "Go down one level in the current thread."
8275 (let ((children (gnus-summary-article-children)))
8277 (gnus-summary-goto-subject (car children)))))
8279 (defun gnus-summary-go-up-thread ()
8280 "Go up one level in the current thread."
8281 (let ((parent (gnus-summary-article-parent)))
8283 (gnus-summary-goto-subject parent))))
8285 (defun gnus-summary-down-thread (n)
8286 "Go down thread N steps.
8287 If N is negative, go up instead.
8288 Returns the difference between N and how many steps down that were
8294 (if up (gnus-summary-go-up-thread)
8295 (gnus-summary-go-down-thread)))
8297 (gnus-summary-position-point)
8299 (gnus-message 7 "Can't go further"))
8302 (defun gnus-summary-up-thread (n)
8303 "Go up thread N steps.
8304 If N is negative, go up instead.
8305 Returns the difference between N and how many steps down that were
8308 (gnus-summary-down-thread (- n)))
8310 (defun gnus-summary-top-thread ()
8311 "Go to the top of the thread."
8313 (while (gnus-summary-go-up-thread))
8314 (gnus-summary-article-number))
8316 (defun gnus-summary-kill-thread (&optional unmark)
8317 "Mark articles under current thread as read.
8318 If the prefix argument is positive, remove any kinds of marks.
8319 If the prefix argument is negative, tick articles instead."
8322 (setq unmark (prefix-numeric-value unmark)))
8323 (let ((articles (gnus-summary-articles-in-thread)))
8325 ;; Expand the thread.
8326 (gnus-summary-show-thread)
8327 ;; Mark all the articles.
8329 (gnus-summary-goto-subject (car articles))
8330 (cond ((null unmark)
8331 (gnus-summary-mark-article-as-read gnus-killed-mark))
8333 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8335 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8336 (setq articles (cdr articles))))
8337 ;; Hide killed subtrees.
8339 gnus-thread-hide-killed
8340 (gnus-summary-hide-thread))
8341 ;; If marked as read, go to next unread subject.
8343 ;; Go to next unread subject.
8344 (gnus-summary-next-subject 1 t)))
8345 (gnus-set-mode-line 'summary))
8347 ;; Summary sorting commands
8349 (defun gnus-summary-sort-by-number (&optional reverse)
8350 "Sort the summary buffer by article number.
8351 Argument REVERSE means reverse order."
8353 (gnus-summary-sort 'number reverse))
8355 (defun gnus-summary-sort-by-author (&optional reverse)
8356 "Sort the summary buffer by author name alphabetically.
8357 If case-fold-search is non-nil, case of letters is ignored.
8358 Argument REVERSE means reverse order."
8360 (gnus-summary-sort 'author reverse))
8362 (defun gnus-summary-sort-by-subject (&optional reverse)
8363 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8364 If case-fold-search is non-nil, case of letters is ignored.
8365 Argument REVERSE means reverse order."
8367 (gnus-summary-sort 'subject reverse))
8369 (defun gnus-summary-sort-by-date (&optional reverse)
8370 "Sort the summary buffer by date.
8371 Argument REVERSE means reverse order."
8373 (gnus-summary-sort 'date reverse))
8375 (defun gnus-summary-sort-by-score (&optional reverse)
8376 "Sort the summary buffer by score.
8377 Argument REVERSE means reverse order."
8379 (gnus-summary-sort 'score reverse))
8381 (defun gnus-summary-sort-by-lines (&optional reverse)
8382 "Sort the summary buffer by article length.
8383 Argument REVERSE means reverse order."
8385 (gnus-summary-sort 'lines reverse))
8387 (defun gnus-summary-sort (predicate reverse)
8388 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8389 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8390 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8391 (gnus-thread-sort-functions
8397 (gnus-article-sort-functions
8402 (,article t2 t1)))))
8404 (gnus-summary-prepare-hook nil))
8405 ;; We do the sorting by regenerating the threads.
8406 (gnus-summary-prepare)
8407 ;; Hide subthreads if needed.
8408 (when (and gnus-show-threads gnus-thread-hide-subtree)
8409 (gnus-summary-hide-all-threads))))
8411 ;; Summary saving commands.
8413 (defun gnus-summary-save-article (&optional n not-saved)
8414 "Save the current article using the default saver function.
8415 If N is a positive number, save the N next articles.
8416 If N is a negative number, save the N previous articles.
8417 If N is nil and any articles have been marked with the process mark,
8418 save those articles instead.
8419 The variable `gnus-default-article-saver' specifies the saver function."
8421 (let* ((articles (gnus-summary-work-articles n))
8422 (save-buffer (save-excursion
8423 (nnheader-set-temp-buffer " *Gnus Save*")))
8424 (num (length articles))
8425 header article file)
8427 (setq header (gnus-summary-article-header
8428 (setq article (pop articles))))
8429 (if (not (vectorp header))
8430 ;; This is a pseudo-article.
8431 (if (assq 'name header)
8432 (gnus-copy-file (cdr (assq 'name header)))
8433 (gnus-message 1 "Article %d is unsaveable" article))
8434 ;; This is a real article.
8435 (save-window-excursion
8436 (gnus-summary-select-article t nil nil article))
8438 (set-buffer save-buffer)
8440 (insert-buffer-substring gnus-original-article-buffer))
8441 (setq file (gnus-article-save save-buffer file num))
8442 (gnus-summary-remove-process-mark article)
8444 (gnus-summary-set-saved-mark article))))
8445 (gnus-kill-buffer save-buffer)
8446 (gnus-summary-position-point)
8447 (gnus-set-mode-line 'summary)
8450 (defun gnus-summary-pipe-output (&optional arg)
8451 "Pipe the current article to a subprocess.
8452 If N is a positive number, pipe the N next articles.
8453 If N is a negative number, pipe the N previous articles.
8454 If N is nil and any articles have been marked with the process mark,
8455 pipe those articles instead."
8457 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8458 (gnus-summary-save-article arg t))
8459 (gnus-configure-windows 'pipe))
8461 (defun gnus-summary-save-article-mail (&optional arg)
8462 "Append the current article to an mail file.
8463 If N is a positive number, save the N next articles.
8464 If N is a negative number, save the N previous articles.
8465 If N is nil and any articles have been marked with the process mark,
8466 save those articles instead."
8468 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8469 (gnus-summary-save-article arg)))
8471 (defun gnus-summary-save-article-rmail (&optional arg)
8472 "Append the current article to an rmail file.
8473 If N is a positive number, save the N next articles.
8474 If N is a negative number, save the N previous articles.
8475 If N is nil and any articles have been marked with the process mark,
8476 save those articles instead."
8478 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8479 (gnus-summary-save-article arg)))
8481 (defun gnus-summary-save-article-file (&optional arg)
8482 "Append the current article to a file.
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."
8488 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8489 (gnus-summary-save-article arg)))
8491 (defun gnus-summary-write-article-file (&optional arg)
8492 "Write the current article to a file, deleting the previous file.
8493 If N is a positive number, save the N next articles.
8494 If N is a negative number, save the N previous articles.
8495 If N is nil and any articles have been marked with the process mark,
8496 save those articles instead."
8498 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8499 (gnus-summary-save-article arg)))
8501 (defun gnus-summary-save-article-body-file (&optional arg)
8502 "Append the current article body to a file.
8503 If N is a positive number, save the N next articles.
8504 If N is a negative number, save the N previous articles.
8505 If N is nil and any articles have been marked with the process mark,
8506 save those articles instead."
8508 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8509 (gnus-summary-save-article arg)))
8511 (defun gnus-summary-pipe-message (program)
8512 "Pipe the current article through PROGRAM."
8513 (interactive "sProgram: ")
8514 (gnus-summary-select-article)
8515 (let ((mail-header-separator "")
8516 (art-buf (get-buffer gnus-article-buffer)))
8517 (gnus-eval-in-buffer-window gnus-article-buffer
8520 (let ((start (window-start))
8522 (message-pipe-buffer-body program)
8523 (set-window-start (get-buffer-window (current-buffer)) start))))))
8525 (defun gnus-get-split-value (methods)
8526 "Return a value based on the split METHODS."
8527 (let (split-name method result match)
8530 (set-buffer gnus-original-article-buffer)
8532 (nnheader-narrow-to-headers)
8534 (goto-char (point-min))
8535 (setq method (pop methods))
8536 (setq match (car method))
8539 ;; Regular expression.
8541 (re-search-forward match nil t)))
8542 ((gnus-functionp match)
8546 (setq result (funcall match gnus-newsgroup-name))))
8551 (setq result (eval match)))))
8552 (setq split-name (append (cdr method) split-name))
8553 (cond ((stringp result)
8554 (push (expand-file-name
8555 result gnus-article-save-directory)
8558 (setq split-name (append result split-name)))))))))
8561 (defun gnus-valid-move-group-p (group)
8566 (car (gnus-find-method-for-group
8567 (symbol-name group))))
8568 gnus-valid-select-methods))))
8570 (defun gnus-read-move-group-name (prompt default articles prefix)
8571 "Read a group name."
8572 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8573 (minibuffer-confirm-incomplete nil) ; XEmacs
8577 (if (> (length articles) 1)
8578 (format "these %d articles" (length articles))
8583 (gnus-completing-read default prom
8585 'gnus-valid-move-group-p
8587 'gnus-group-history))
8588 ((= 1 (length split-name))
8589 (gnus-completing-read (car split-name) prom
8591 'gnus-valid-move-group-p
8593 'gnus-group-history))
8595 (gnus-completing-read nil prom
8596 (mapcar (lambda (el) (list el))
8597 (nreverse split-name))
8599 'gnus-group-history)))))
8601 (if (or (string= to-newsgroup "")
8602 (string= to-newsgroup prefix))
8603 (setq to-newsgroup default))
8604 (unless to-newsgroup
8605 (error "No group name entered"))
8606 (or (gnus-active to-newsgroup)
8607 (gnus-activate-group to-newsgroup)
8608 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8610 (or (and (gnus-request-create-group
8611 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8612 (gnus-activate-group to-newsgroup nil nil
8613 (gnus-group-name-to-method
8615 (error "Couldn't create group %s" to-newsgroup)))
8616 (error "No such group: %s" to-newsgroup)))
8619 ;; Summary extract commands
8621 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8622 (let ((buffer-read-only nil)
8623 (article (gnus-summary-article-number))
8625 (unless (gnus-summary-goto-subject article)
8626 (error "No such article: %d" article))
8627 (gnus-summary-position-point)
8628 ;; If all commands are to be bunched up on one line, we collect
8630 (unless gnus-view-pseudos-separately
8631 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8634 (setq action (cdr (assq 'action (car ps))))
8635 (setq files (list (cdr (assq 'name (car ps)))))
8636 (while (and ps (cdr ps)
8637 (string= (or action "1")
8638 (or (cdr (assq 'action (cadr ps))) "2")))
8639 (push (cdr (assq 'name (cadr ps))) files)
8640 (setcdr ps (cddr ps)))
8642 (when (not (string-match "%s" action))
8645 (when (assq 'execute (car ps))
8646 (setcdr (assq 'execute (car ps))
8647 (funcall (if (string-match "%s" action)
8654 (gnus-quote-arg-for-sh-or-csh f)))
8656 (setq ps (cdr ps)))))
8657 (if (and gnus-view-pseudos (not not-view))
8659 (when (assq 'execute (car pslist))
8660 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8661 (eq gnus-view-pseudos 'not-confirm)))
8662 (setq pslist (cdr pslist)))
8665 (setq after-article (or (cdr (assq 'article (car pslist)))
8666 (gnus-summary-article-number)))
8667 (gnus-summary-goto-subject after-article)
8670 (insert " " (file-name-nondirectory
8671 (cdr (assq 'name (car pslist))))
8672 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8674 (forward-line -1) ; back to `b'
8675 (gnus-add-text-properties
8676 b (1- e) (list 'gnus-number gnus-reffed-article-number
8677 gnus-mouse-face-prop gnus-mouse-face))
8679 after-article gnus-reffed-article-number
8680 gnus-unread-mark b (car pslist) 0 (- e b))
8681 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8682 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8683 (setq pslist (cdr pslist)))))))
8685 (defun gnus-pseudos< (p1 p2)
8686 (let ((c1 (cdr (assq 'action p1)))
8687 (c2 (cdr (assq 'action p2))))
8688 (and c1 c2 (string< c1 c2))))
8690 (defun gnus-request-pseudo-article (props)
8691 (cond ((assq 'execute props)
8692 (gnus-execute-command (cdr (assq 'execute props)))))
8693 (let ((gnus-current-article (gnus-summary-article-number)))
8694 (gnus-run-hooks 'gnus-mark-article-hook)))
8696 (defun gnus-execute-command (command &optional automatic)
8698 (gnus-article-setup-buffer)
8699 (set-buffer gnus-article-buffer)
8700 (setq buffer-read-only nil)
8701 (let ((command (if automatic command
8702 (read-string "Command: " (cons command 0)))))
8704 (insert "$ " command "\n\n")
8705 (if gnus-view-pseudo-asynchronously
8706 (start-process "gnus-execute" (current-buffer) shell-file-name
8707 shell-command-switch command)
8708 (call-process shell-file-name nil t nil
8709 shell-command-switch command)))))
8711 ;; Summary kill commands.
8713 (defun gnus-summary-edit-global-kill (article)
8714 "Edit the \"global\" kill file."
8715 (interactive (list (gnus-summary-article-number)))
8716 (gnus-group-edit-global-kill article))
8718 (defun gnus-summary-edit-local-kill ()
8719 "Edit a local kill file applied to the current newsgroup."
8721 (setq gnus-current-headers (gnus-summary-article-header))
8722 (gnus-group-edit-local-kill
8723 (gnus-summary-article-number) gnus-newsgroup-name))
8727 (defun gnus-read-header (id &optional header)
8728 "Read the headers of article ID and enter them into the Gnus system."
8729 (let ((group gnus-newsgroup-name)
8730 (gnus-override-method
8731 (and (gnus-news-group-p gnus-newsgroup-name)
8732 gnus-refer-article-method))
8734 ;; First we check to see whether the header in question is already
8737 ;; This is a Message-ID.
8738 (setq header (or header (gnus-id-to-header id)))
8739 ;; This is an article number.
8740 (setq header (or header (gnus-summary-article-header id))))
8742 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8743 ;; We have found the header.
8745 ;; If this is a sparse article, we have to nix out its
8746 ;; previous entry in the thread hashtb.
8748 (gnus-summary-article-sparse-p (mail-header-number header)))
8749 (let* ((parent (gnus-parent-id (mail-header-references header)))
8752 (gnus-gethash parent gnus-newsgroup-dependencies))))
8754 (delq (assq header thread) thread))))
8755 ;; We have to really fetch the header to this article.
8757 (set-buffer nntp-server-buffer)
8758 (when (setq where (gnus-request-head id group))
8759 (nnheader-fold-continuation-lines)
8760 (goto-char (point-max))
8762 (goto-char (point-min))
8766 ((cdr where) (cdr where))
8767 (header (mail-header-number header))
8768 (t gnus-reffed-article-number))
8770 (insert " Article retrieved.\n"))
8772 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8773 () ; Malformed head.
8774 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8775 (when (and (stringp id)
8776 (not (string= (gnus-group-real-name group)
8778 ;; If we fetched by Message-ID and the article came
8779 ;; from a different group, we fudge some bogus article
8780 ;; numbers for this article.
8781 (mail-header-set-number header gnus-reffed-article-number))
8783 (set-buffer gnus-summary-buffer)
8784 (decf gnus-reffed-article-number)
8785 (gnus-remove-header (mail-header-number header))
8786 (push header gnus-newsgroup-headers)
8787 (setq gnus-current-headers header)
8788 (push (mail-header-number header) gnus-newsgroup-limit)))
8791 (defun gnus-remove-header (number)
8792 "Remove header NUMBER from `gnus-newsgroup-headers'."
8793 (if (and gnus-newsgroup-headers
8794 (= number (mail-header-number (car gnus-newsgroup-headers))))
8795 (pop gnus-newsgroup-headers)
8796 (let ((headers gnus-newsgroup-headers))
8797 (while (and (cdr headers)
8798 (not (= number (mail-header-number (cadr headers)))))
8801 (setcdr headers (cddr headers))))))
8804 ;;; summary highlights
8807 (defun gnus-highlight-selected-summary ()
8808 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8809 ;; Highlight selected article in summary buffer
8810 (when gnus-summary-selected-face
8812 (let* ((beg (progn (beginning-of-line) (point)))
8813 (end (progn (end-of-line) (point)))
8814 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8815 (from (if (get-text-property beg gnus-mouse-face-prop)
8817 (or (next-single-property-change
8818 beg gnus-mouse-face-prop nil end)
8823 (or (next-single-property-change
8824 from gnus-mouse-face-prop nil end)
8826 ;; If no mouse-face prop on line we will have to = from = end,
8827 ;; so we highlight the entire line instead.
8828 (when (= (+ to 2) from)
8831 (if gnus-newsgroup-selected-overlay
8832 ;; Move old overlay.
8834 gnus-newsgroup-selected-overlay from to (current-buffer))
8835 ;; Create new overlay.
8837 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8838 'face gnus-summary-selected-face))))))
8840 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8841 (defun gnus-summary-highlight-line ()
8842 "Highlight current line according to `gnus-summary-highlight'."
8843 (let* ((list gnus-summary-highlight)
8845 (end (progn (end-of-line) (point)))
8846 ;; now find out where the line starts and leave point there.
8847 (beg (progn (beginning-of-line) (point)))
8848 (article (gnus-summary-article-number))
8849 (score (or (cdr (assq (or article gnus-current-article)
8850 gnus-newsgroup-scored))
8851 gnus-summary-default-score 0))
8852 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8853 (inhibit-read-only t))
8854 ;; Eval the cars of the lists until we find a match.
8855 (let ((default gnus-summary-default-score))
8857 (not (eval (caar list))))
8858 (setq list (cdr list))))
8859 (let ((face (cdar list)))
8860 (unless (eq face (get-text-property beg 'face))
8861 (gnus-put-text-property
8863 (setq face (if (boundp face) (symbol-value face) face)))
8864 (when gnus-summary-highlight-line-function
8865 (funcall gnus-summary-highlight-line-function article face))))
8868 (defun gnus-update-read-articles (group unread &optional compute)
8869 "Update the list of read articles in GROUP."
8870 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8871 (entry (gnus-gethash group gnus-newsrc-hashtb))
8872 (info (nth 2 entry))
8874 (unread (sort (copy-sequence unread) '<))
8876 (if (or (not info) (not active))
8877 ;; There is no info on this group if it was, in fact,
8878 ;; killed. Gnus stores no information on killed groups, so
8879 ;; there's nothing to be done.
8880 ;; One could store the information somewhere temporarily,
8881 ;; perhaps... Hmmm...
8883 ;; Remove any negative articles numbers.
8884 (while (and unread (< (car unread) 0))
8885 (setq unread (cdr unread)))
8886 ;; Remove any expired article numbers
8887 (while (and unread (< (car unread) (car active)))
8888 (setq unread (cdr unread)))
8889 ;; Compute the ranges of read articles by looking at the list of
8892 (when (/= (car unread) prev)
8893 (push (if (= prev (1- (car unread))) prev
8894 (cons prev (1- (car unread))))
8896 (setq prev (1+ (car unread)))
8897 (setq unread (cdr unread)))
8898 (when (<= prev (cdr active))
8899 (push (cons prev (cdr active)) read))
8901 (if (> (length read) 1) (nreverse read) read)
8903 (set-buffer gnus-group-buffer)
8906 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8907 (gnus-info-set-read ',info ',(gnus-info-read info))
8908 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8909 (gnus-group-update-group ,group t))))
8910 ;; Enter this list into the group info.
8912 info (if (> (length read) 1) (nreverse read) read))
8913 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8914 (gnus-get-unread-articles-in-group info (gnus-active group))
8917 (defun gnus-offer-save-summaries ()
8918 "Offer to save all active summary buffers."
8920 (let ((buflist (buffer-list))
8922 ;; Go through all buffers and find all summaries.
8924 (and (setq bufname (buffer-name (car buflist)))
8925 (string-match "Summary" bufname)
8927 (set-buffer bufname)
8928 ;; We check that this is, indeed, a summary buffer.
8929 (and (eq major-mode 'gnus-summary-mode)
8930 ;; Also make sure this isn't bogus.
8931 gnus-newsgroup-prepared
8932 ;; Also make sure that this isn't a dead summary buffer.
8933 (not gnus-dead-summary-mode)))
8934 (push bufname buffers))
8935 (setq buflist (cdr buflist)))
8936 ;; Go through all these summary buffers and offer to save them.
8939 "Update summary buffer %s? "
8941 (switch-to-buffer buf)
8942 (gnus-summary-exit))
8946 ;;; @ for mime-partial
8949 (defun gnus-mime-partial-preview-function ()
8950 (gnus-summary-preview-mime-message (gnus-summary-article-number))
8953 (autoload 'mime-method-to-combine-message/partial-pieces
8955 "Internal method to combine message/partial messages automatically.")
8957 (ctree-set-calist-strictly
8958 'mime-acting-condition
8959 '((type . message)(subtype . partial)
8960 (method . mime-method-to-combine-message/partial-pieces)
8961 (major-mode . gnus-original-article-mode)
8962 (summary-buffer-exp . gnus-summary-buffer)
8965 (set-alist 'mime-view-partial-message-method-alist
8966 'gnus-original-article-mode
8967 'gnus-mime-partial-preview-function)
8977 (run-hooks 'gnus-sum-load-hook)
8979 ;;; gnus-sum.el ends here