1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
41 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
43 (defcustom gnus-kill-summary-on-exit t
44 "*If non-nil, kill the summary buffer when you exit from it.
45 If nil, the summary will become a \"*Dead Summary*\" buffer, and
46 it will be killed sometime later."
47 :group 'gnus-summary-exit
50 (defcustom gnus-fetch-old-headers nil
51 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
52 If an unread article in the group refers to an older, already read (or
53 just marked as read) article, the old article will not normally be
54 displayed in the Summary buffer. If this variable is non-nil, Gnus
55 will attempt to grab the headers to the old articles, and thereby
56 build complete threads. If it has the value `some', only enough
57 headers to connect otherwise loose threads will be displayed. This
58 variable can also be a number. In that case, no more than that number
59 of old headers will be fetched. If it has the value `invisible', all
60 old headers will be fetched, but none will be displayed.
62 The server has to support NOV for any of this to work."
64 :type '(choice (const :tag "off" nil)
67 (sexp :menu-tag "other" t)))
69 (defcustom gnus-refer-thread-limit 200
70 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
71 If t, fetch all the available old headers."
74 (sexp :menu-tag "other" t)))
76 (defcustom gnus-summary-make-false-root 'adopt
77 "*nil means that Gnus won't gather loose threads.
78 If the root of a thread has expired or been read in a previous
79 session, the information necessary to build a complete thread has been
80 lost. Instead of having many small sub-threads from this original thread
81 scattered all over the summary buffer, Gnus can gather them.
83 If non-nil, Gnus will try to gather all loose sub-threads from an
84 original thread into one large thread.
86 If this variable is non-nil, it should be one of `none', `adopt',
89 If this variable is `none', Gnus will not make a false root, but just
90 present the sub-threads after another.
91 If this variable is `dummy', Gnus will create a dummy root that will
92 have all the sub-threads as children.
93 If this variable is `adopt', Gnus will make one of the \"children\"
94 the parent and mark all the step-children as such.
95 If this variable is `empty', the \"children\" are printed with empty
96 subject fields. (Or rather, they will be printed with a string
97 given by the `gnus-summary-same-subject' variable.)"
99 :type '(choice (const :tag "off" nil)
105 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
106 "*A regexp to match subjects to be excluded from loose thread gathering.
107 As loose thread gathering is done on subjects only, that means that
108 there can be many false gatherings performed. By rooting out certain
109 common subjects, gathering might become saner."
113 (defcustom gnus-summary-gather-subject-limit nil
114 "*Maximum length of subject comparisons when gathering loose threads.
115 Use nil to compare full subjects. Setting this variable to a low
116 number will help gather threads that have been corrupted by
117 newsreaders chopping off subject lines, but it might also mean that
118 unrelated articles that have subject that happen to begin with the
119 same few characters will be incorrectly gathered.
121 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
124 :type '(choice (const :tag "off" nil)
126 (sexp :menu-tag "on" t)))
128 (defcustom gnus-simplify-subject-functions nil
129 "List of functions taking a string argument that simplify subjects.
130 The functions are applied recursively.
132 Useful functions to put in this list include: `gnus-simplify-subject-re',
133 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
135 :type '(repeat function))
137 (defcustom gnus-simplify-ignored-prefixes nil
138 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
140 :type '(choice (const :tag "off" nil)
143 (defcustom gnus-build-sparse-threads nil
144 "*If non-nil, fill in the gaps in threads.
145 If `some', only fill in the gaps that are needed to tie loose threads
146 together. If `more', fill in all leaf nodes that Gnus can find. If
147 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
149 :type '(choice (const :tag "off" nil)
152 (sexp :menu-tag "all" t)))
154 (defcustom gnus-summary-thread-gathering-function
155 'gnus-gather-threads-by-subject
156 "*Function used for gathering loose threads.
157 There are two pre-defined functions: `gnus-gather-threads-by-subject',
158 which only takes Subjects into consideration; and
159 `gnus-gather-threads-by-references', which compared the References
160 headers of the articles to find matches."
162 :type '(radio (function-item gnus-gather-threads-by-subject)
163 (function-item gnus-gather-threads-by-references)
164 (function :tag "other")))
166 (defcustom gnus-summary-same-subject ""
167 "*String indicating that the current article has the same subject as the previous.
168 This variable will only be used if the value of
169 `gnus-summary-make-false-root' is `empty'."
170 :group 'gnus-summary-format
173 (defcustom gnus-summary-goto-unread t
174 "*If t, marking commands will go to the next unread article.
175 If `never', commands that usually go to the next unread article, will
176 go to the next article, whether it is read or not.
177 If nil, only the marking commands will go to the next (un)read article."
178 :group 'gnus-summary-marks
179 :link '(custom-manual "(gnus)Setting Marks")
180 :type '(choice (const :tag "off" nil)
182 (sexp :menu-tag "on" t)))
184 (defcustom gnus-summary-default-score 0
185 "*Default article score level.
186 All scores generated by the score files will be added to this score.
187 If this variable is nil, scoring will be disabled."
188 :group 'gnus-score-default
189 :type '(choice (const :tag "disable")
192 (defcustom gnus-summary-zcore-fuzz 0
193 "*Fuzziness factor for the zcore in the summary buffer.
194 Articles with scores closer than this to `gnus-summary-default-score'
196 :group 'gnus-summary-format
199 (defcustom gnus-simplify-subject-fuzzy-regexp nil
200 "*Strings to be removed when doing fuzzy matches.
201 This can either be a regular expression or list of regular expressions
202 that will be removed from subject strings if fuzzy subject
203 simplification is selected."
205 :type '(repeat regexp))
207 (defcustom gnus-show-threads t
208 "*If non-nil, display threads in summary mode."
212 (defcustom gnus-thread-hide-subtree nil
213 "*If non-nil, hide all threads initially.
214 If threads are hidden, you have to run the command
215 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
216 to expose hidden threads."
220 (defcustom gnus-thread-hide-killed t
221 "*If non-nil, hide killed threads automatically."
225 (defcustom gnus-thread-ignore-subject t
226 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
227 If nil, articles that have different subjects from their parents will
228 start separate threads."
232 (defcustom gnus-thread-operation-ignore-subject t
233 "*If non-nil, subjects will be ignored when doing thread commands.
234 This affects commands like `gnus-summary-kill-thread' and
235 `gnus-summary-lower-thread'.
237 If this variable is nil, articles in the same thread with different
238 subjects will not be included in the operation in question. If this
239 variable is `fuzzy', only articles that have subjects that are fuzzily
240 equal will be included."
242 :type '(choice (const :tag "off" nil)
246 (defcustom gnus-thread-indent-level 4
247 "*Number that says how much each sub-thread should be indented."
251 (defcustom gnus-auto-extend-newsgroup t
252 "*If non-nil, extend newsgroup forward and backward when requested."
253 :group 'gnus-summary-choose
256 (defcustom gnus-auto-select-first t
257 "*If nil, don't select the first unread article when entering a group.
258 If this variable is `best', select the highest-scored unread article
259 in the group. If t, select the first unread article.
261 This variable can also be a function to place point on a likely
262 subject line. Useful values include `gnus-summary-first-unread-subject',
263 `gnus-summary-first-unread-article' and
264 `gnus-summary-best-unread-article'.
266 If you want to prevent automatic selection of the first unread article
267 in some newsgroups, set the variable to nil in
268 `gnus-select-group-hook'."
269 :group 'gnus-group-select
270 :type '(choice (const :tag "none" nil)
272 (sexp :menu-tag "first" t)
273 (function-item gnus-summary-first-unread-subject)
274 (function-item gnus-summary-first-unread-article)
275 (function-item gnus-summary-best-unread-article)))
277 (defcustom gnus-auto-select-next t
278 "*If non-nil, offer to go to the next group from the end of the previous.
279 If the value is t and the next newsgroup is empty, Gnus will exit
280 summary mode and go back to group mode. If the value is neither nil
281 nor t, Gnus will select the following unread newsgroup. In
282 particular, if the value is the symbol `quietly', the next unread
283 newsgroup will be selected without any confirmation, and if it is
284 `almost-quietly', the next group will be selected without any
285 confirmation if you are located on the last article in the group.
286 Finally, if this variable is `slightly-quietly', the `Z n' command
287 will go to the next group without confirmation."
288 :group 'gnus-summary-maneuvering
289 :type '(choice (const :tag "off" nil)
291 (const almost-quietly)
292 (const slightly-quietly)
293 (sexp :menu-tag "on" t)))
295 (defcustom gnus-auto-select-same nil
296 "*If non-nil, select the next article with the same subject.
297 If there are no more articles with the same subject, go to
298 the first unread article."
299 :group 'gnus-summary-maneuvering
302 (defcustom gnus-summary-check-current nil
303 "*If non-nil, consider the current article when moving.
304 The \"unread\" movement commands will stay on the same line if the
305 current article is unread."
306 :group 'gnus-summary-maneuvering
309 (defcustom gnus-auto-center-summary t
310 "*If non-nil, always center the current summary buffer.
311 In particular, if `vertical' do only vertical recentering. If non-nil
312 and non-`vertical', do both horizontal and vertical recentering."
313 :group 'gnus-summary-maneuvering
314 :type '(choice (const :tag "none" nil)
316 (sexp :menu-tag "both" t)))
318 (defcustom gnus-show-all-headers nil
319 "*If non-nil, don't hide any headers."
320 :group 'gnus-article-hiding
321 :group 'gnus-article-headers
324 (defcustom gnus-summary-ignore-duplicates nil
325 "*If non-nil, ignore articles with identical Message-ID headers."
329 (defcustom gnus-single-article-buffer t
330 "*If non-nil, display all articles in the same buffer.
331 If nil, each group will get its own article buffer."
332 :group 'gnus-article-various
335 (defcustom gnus-break-pages t
336 "*If non-nil, do page breaking on articles.
337 The page delimiter is specified by the `gnus-page-delimiter'
339 :group 'gnus-article-various
342 (defcustom gnus-show-mime t
343 "*If non-nil, do mime processing of articles.
344 The articles will simply be fed to the function given by
345 `gnus-article-display-method-for-mime'."
346 :group 'gnus-article-mime
349 (defcustom gnus-move-split-methods nil
350 "*Variable used to suggest where articles are to be moved to.
351 It uses the same syntax as the `gnus-split-methods' variable."
352 :group 'gnus-summary-mail
353 :type '(repeat (choice (list :value (fun) function)
354 (cons :value ("" "") regexp (repeat string))
357 (defcustom gnus-unread-mark ?
358 "*Mark used for unread articles."
359 :group 'gnus-summary-marks
362 (defcustom gnus-ticked-mark ?!
363 "*Mark used for ticked articles."
364 :group 'gnus-summary-marks
367 (defcustom gnus-dormant-mark ??
368 "*Mark used for dormant articles."
369 :group 'gnus-summary-marks
372 (defcustom gnus-del-mark ?r
373 "*Mark used for del'd articles."
374 :group 'gnus-summary-marks
377 (defcustom gnus-read-mark ?R
378 "*Mark used for read articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-expirable-mark ?E
383 "*Mark used for expirable articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-killed-mark ?K
388 "*Mark used for killed articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-souped-mark ?F
393 "*Mark used for killed articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-kill-file-mark ?X
398 "*Mark used for articles killed by kill files."
399 :group 'gnus-summary-marks
402 (defcustom gnus-low-score-mark ?Y
403 "*Mark used for articles with a low score."
404 :group 'gnus-summary-marks
407 (defcustom gnus-catchup-mark ?C
408 "*Mark used for articles that are caught up."
409 :group 'gnus-summary-marks
412 (defcustom gnus-replied-mark ?A
413 "*Mark used for articles that have been replied to."
414 :group 'gnus-summary-marks
417 (defcustom gnus-cached-mark ?*
418 "*Mark used for articles that are in the cache."
419 :group 'gnus-summary-marks
422 (defcustom gnus-saved-mark ?S
423 "*Mark used for articles that have been saved to."
424 :group 'gnus-summary-marks
427 (defcustom gnus-ancient-mark ?O
428 "*Mark used for ancient articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-sparse-mark ?Q
433 "*Mark used for sparsely reffed articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-canceled-mark ?G
438 "*Mark used for canceled articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-duplicate-mark ?M
443 "*Mark used for duplicate articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-undownloaded-mark ?@
448 "*Mark used for articles that weren't downloaded."
449 :group 'gnus-summary-marks
452 (defcustom gnus-downloadable-mark ?%
453 "*Mark used for articles that are to be downloaded."
454 :group 'gnus-summary-marks
457 (defcustom gnus-unsendable-mark ?=
458 "*Mark used for articles that won't be sent."
459 :group 'gnus-summary-marks
462 (defcustom gnus-score-over-mark ?+
463 "*Score mark used for articles with high scores."
464 :group 'gnus-summary-marks
467 (defcustom gnus-score-below-mark ?-
468 "*Score mark used for articles with low scores."
469 :group 'gnus-summary-marks
472 (defcustom gnus-empty-thread-mark ?
473 "*There is no thread under the article."
474 :group 'gnus-summary-marks
477 (defcustom gnus-not-empty-thread-mark ?=
478 "*There is a thread under the article."
479 :group 'gnus-summary-marks
482 (defcustom gnus-view-pseudo-asynchronously nil
483 "*If non-nil, Gnus will view pseudo-articles asynchronously."
484 :group 'gnus-extract-view
487 (defcustom gnus-view-pseudos nil
488 "*If `automatic', pseudo-articles will be viewed automatically.
489 If `not-confirm', pseudos will be viewed automatically, and the user
490 will not be asked to confirm the command."
491 :group 'gnus-extract-view
492 :type '(choice (const :tag "off" nil)
494 (const not-confirm)))
496 (defcustom gnus-view-pseudos-separately t
497 "*If non-nil, one pseudo-article will be created for each file to be viewed.
498 If nil, all files that use the same viewing command will be given as a
499 list of parameters to that command."
500 :group 'gnus-extract-view
503 (defcustom gnus-insert-pseudo-articles t
504 "*If non-nil, insert pseudo-articles when decoding articles."
505 :group 'gnus-extract-view
508 (defcustom gnus-summary-dummy-line-format
510 "*The format specification for the dummy roots in the summary buffer.
511 It works along the same lines as a normal formatting string,
512 with some simple extensions.
515 :group 'gnus-threading
518 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
519 "*The format specification for the summary mode line.
520 It works along the same lines as a normal formatting string,
521 with some simple extensions:
524 %p Unprefixed group name
525 %A Current article number
526 %z Current article score
528 %U Number of unread articles in the group
529 %e Number of unselected articles in the group
530 %Z A string with unread/unselected article counts
531 %g Shortish group name
532 %S Subject of the current article
534 %s Current score file name
535 %d Number of dormant articles
536 %r Number of articles that have been marked as read in this session
537 %E Number of articles expunged by the score files"
538 :group 'gnus-summary-format
541 (defcustom gnus-summary-mark-below 0
542 "*Mark all articles with a score below this variable as read.
543 This variable is local to each summary buffer and usually set by the
545 :group 'gnus-score-default
548 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
549 "*List of functions used for sorting articles in the summary buffer.
550 This variable is only used when not using a threaded display."
551 :group 'gnus-summary-sort
552 :type '(repeat (choice (function-item gnus-article-sort-by-number)
553 (function-item gnus-article-sort-by-author)
554 (function-item gnus-article-sort-by-subject)
555 (function-item gnus-article-sort-by-date)
556 (function-item gnus-article-sort-by-score)
557 (function :tag "other"))))
559 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
560 "*List of functions used for sorting threads in the summary buffer.
561 By default, threads are sorted by article number.
563 Each function takes two threads and return non-nil if the first thread
564 should be sorted before the other. If you use more than one function,
565 the primary sort function should be the last. You should probably
566 always include `gnus-thread-sort-by-number' in the list of sorting
567 functions -- preferably first.
569 Ready-made functions include `gnus-thread-sort-by-number',
570 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
571 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
572 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
573 :group 'gnus-summary-sort
574 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
575 (function-item gnus-thread-sort-by-author)
576 (function-item gnus-thread-sort-by-subject)
577 (function-item gnus-thread-sort-by-date)
578 (function-item gnus-thread-sort-by-score)
579 (function-item gnus-thread-sort-by-total-score)
580 (function :tag "other"))))
582 (defcustom gnus-thread-score-function '+
583 "*Function used for calculating the total score of a thread.
585 The function is called with the scores of the article and each
586 subthread and should then return the score of the thread.
588 Some functions you can use are `+', `max', or `min'."
589 :group 'gnus-summary-sort
592 (defcustom gnus-summary-expunge-below nil
593 "All articles that have a score less than this variable will be expunged.
594 This variable is local to the summary buffers."
595 :group 'gnus-score-default
596 :type '(choice (const :tag "off" nil)
599 (defcustom gnus-thread-expunge-below nil
600 "All threads that have a total score less than this variable will be expunged.
601 See `gnus-thread-score-function' for en explanation of what a
604 This variable is local to the summary buffers."
605 :group 'gnus-treading
606 :group 'gnus-score-default
607 :type '(choice (const :tag "off" nil)
610 (defcustom gnus-summary-mode-hook nil
611 "*A hook for Gnus summary mode.
612 This hook is run before any variables are set in the summary buffer."
613 :group 'gnus-summary-various
616 (defcustom gnus-summary-menu-hook nil
617 "*Hook run after the creation of the summary mode menu."
618 :group 'gnus-summary-visual
621 (defcustom gnus-summary-exit-hook nil
622 "*A hook called on exit from the summary buffer.
623 It will be called with point in the group buffer."
624 :group 'gnus-summary-exit
627 (defcustom gnus-summary-prepare-hook nil
628 "*A hook called after the summary buffer has been generated.
629 If you want to modify the summary buffer, you can use this hook."
630 :group 'gnus-summary-various
633 (defcustom gnus-summary-prepared-hook nil
634 "*A hook called as the last thing after the summary buffer has been generated."
635 :group 'gnus-summary-various
638 (defcustom gnus-summary-generate-hook nil
639 "*A hook run just before generating the summary buffer.
640 This hook is commonly used to customize threading variables and the
642 :group 'gnus-summary-various
645 (defcustom gnus-select-group-hook nil
646 "*A hook called when a newsgroup is selected.
648 If you'd like to simplify subjects like the
649 `gnus-summary-next-same-subject' command does, you can use the
652 (setq gnus-select-group-hook
655 (mapcar (lambda (header)
656 (mail-header-set-subject
658 (gnus-simplify-subject
659 (mail-header-subject header) 're-only)))
660 gnus-newsgroup-headers))))"
661 :group 'gnus-group-select
664 (defcustom gnus-select-article-hook nil
665 "*A hook called when an article is selected."
666 :group 'gnus-summary-choose
669 (defcustom gnus-visual-mark-article-hook
670 (list 'gnus-highlight-selected-summary)
671 "*Hook run after selecting an article in the summary buffer.
672 It is meant to be used for highlighting the article in some way. It
673 is not run if `gnus-visual' is nil."
674 :group 'gnus-summary-visual
677 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
678 "*A hook called before parsing the headers."
682 (defcustom gnus-exit-group-hook nil
683 "*A hook called when exiting (not quitting) summary mode."
687 (defcustom gnus-summary-update-hook
688 (list 'gnus-summary-highlight-line)
689 "*A hook called when a summary line is changed.
690 The hook will not be called if `gnus-visual' is nil.
692 The default function `gnus-summary-highlight-line' will
693 highlight the line according to the `gnus-summary-highlight'
695 :group 'gnus-summary-visual
698 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
699 "*A hook called when an article is selected for the first time.
700 The hook is intended to mark an article as read (or unread)
701 automatically when it is selected."
702 :group 'gnus-summary-choose
705 (defcustom gnus-group-no-more-groups-hook nil
706 "*A hook run when returning to group mode having no more (unread) groups."
707 :group 'gnus-group-select
710 (defcustom gnus-ps-print-hook nil
711 "*A hook run before ps-printing something from Gnus."
715 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
716 "Face used for highlighting the current article in the summary buffer."
717 :group 'gnus-summary-visual
720 (defcustom gnus-summary-highlight
721 '(((= mark gnus-canceled-mark)
722 . gnus-summary-cancelled-face)
723 ((and (> score default)
724 (or (= mark gnus-dormant-mark)
725 (= mark gnus-ticked-mark)))
726 . gnus-summary-high-ticked-face)
727 ((and (< score default)
728 (or (= mark gnus-dormant-mark)
729 (= mark gnus-ticked-mark)))
730 . gnus-summary-low-ticked-face)
731 ((or (= mark gnus-dormant-mark)
732 (= mark gnus-ticked-mark))
733 . gnus-summary-normal-ticked-face)
734 ((and (> score default) (= mark gnus-ancient-mark))
735 . gnus-summary-high-ancient-face)
736 ((and (< score default) (= mark gnus-ancient-mark))
737 . gnus-summary-low-ancient-face)
738 ((= mark gnus-ancient-mark)
739 . gnus-summary-normal-ancient-face)
740 ((and (> score default) (= mark gnus-unread-mark))
741 . gnus-summary-high-unread-face)
742 ((and (< score default) (= mark gnus-unread-mark))
743 . gnus-summary-low-unread-face)
744 ((= mark gnus-unread-mark)
745 . gnus-summary-normal-unread-face)
746 ((and (> score default) (memq mark (list gnus-downloadable-mark
747 gnus-undownloaded-mark)))
748 . gnus-summary-high-unread-face)
749 ((and (< score default) (memq mark (list gnus-downloadable-mark
750 gnus-undownloaded-mark)))
751 . gnus-summary-low-unread-face)
752 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
753 . gnus-summary-normal-unread-face)
755 . gnus-summary-high-read-face)
757 . gnus-summary-low-read-face)
759 . gnus-summary-normal-read-face))
760 "*Controls the highlighting of summary buffer lines.
762 A list of (FORM . FACE) pairs. When deciding how a a particular
763 summary line should be displayed, each form is evaluated. The content
764 of the face field after the first true form is used. You can change
765 how those summary lines are displayed, by editing the face field.
767 You can use the following variables in the FORM field.
769 score: The articles score
770 default: The default article score.
771 below: The score below which articles are automatically marked as read.
772 mark: The articles mark."
773 :group 'gnus-summary-visual
774 :type '(repeat (cons (sexp :tag "Form" nil)
777 (defcustom gnus-alter-header-function nil
778 "Function called to allow alteration of article header structures.
779 The function is called with one parameter, the article header vector,
780 which it may alter in any way.")
782 ;;; Internal variables
784 (defvar gnus-scores-exclude-files nil)
785 (defvar gnus-page-broken nil)
787 (defvar gnus-original-article nil)
788 (defvar gnus-article-internal-prepare-hook nil)
789 (defvar gnus-newsgroup-process-stack nil)
791 (defvar gnus-thread-indent-array nil)
792 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
794 ;; Avoid highlighting in kill files.
795 (defvar gnus-summary-inhibit-highlight nil)
796 (defvar gnus-newsgroup-selected-overlay nil)
797 (defvar gnus-inhibit-limiting nil)
798 (defvar gnus-newsgroup-adaptive-score-file nil)
799 (defvar gnus-current-score-file nil)
800 (defvar gnus-current-move-group nil)
801 (defvar gnus-current-copy-group nil)
802 (defvar gnus-current-crosspost-group nil)
804 (defvar gnus-newsgroup-dependencies nil)
805 (defvar gnus-newsgroup-adaptive nil)
806 (defvar gnus-summary-display-article-function nil)
807 (defvar gnus-summary-highlight-line-function nil
808 "Function called after highlighting a summary line.")
810 (defvar gnus-summary-line-format-alist
811 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
812 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
813 (?s gnus-tmp-subject-or-nil ?s)
814 (?n gnus-tmp-name ?s)
815 (?A (std11-address-string
816 (car (mime-read-field 'From gnus-tmp-header))) ?s)
817 (?a (or (std11-full-name-string
818 (car (mime-read-field 'From gnus-tmp-header)))
820 (?F gnus-tmp-from ?s)
821 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
822 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
823 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
824 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
825 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
826 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
827 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
828 (?L gnus-tmp-lines ?d)
829 (?I gnus-tmp-indentation ?s)
830 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
831 (?R gnus-tmp-replied ?c)
832 (?\[ gnus-tmp-opening-bracket ?c)
833 (?\] gnus-tmp-closing-bracket ?c)
834 (?\> (make-string gnus-tmp-level ? ) ?s)
835 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
836 (?i gnus-tmp-score ?d)
837 (?z gnus-tmp-score-char ?c)
838 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
839 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
840 (?U gnus-tmp-unread ?c)
841 (?t (gnus-summary-number-of-articles-in-thread
842 (and (boundp 'thread) (car thread)) gnus-tmp-level)
844 (?e (gnus-summary-number-of-articles-in-thread
845 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
847 (?u gnus-tmp-user-defined ?s)
848 (?P (gnus-pick-line-number) ?d))
849 "An alist of format specifications that can appear in summary lines,
850 and what variables they correspond with, along with the type of the
851 variable (string, integer, character, etc).")
853 (defvar gnus-summary-dummy-line-format-alist
854 `((?S gnus-tmp-subject ?s)
855 (?N gnus-tmp-number ?d)
856 (?u gnus-tmp-user-defined ?s)))
858 (defvar gnus-summary-mode-line-format-alist
859 `((?G gnus-tmp-group-name ?s)
860 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
861 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
862 (?A gnus-tmp-article-number ?d)
863 (?Z gnus-tmp-unread-and-unselected ?s)
865 (?U gnus-tmp-unread-and-unticked ?d)
866 (?S gnus-tmp-subject ?s)
867 (?e gnus-tmp-unselected ?d)
868 (?u gnus-tmp-user-defined ?s)
869 (?d (length gnus-newsgroup-dormant) ?d)
870 (?t (length gnus-newsgroup-marked) ?d)
871 (?r (length gnus-newsgroup-reads) ?d)
872 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
873 (?E gnus-newsgroup-expunged-tally ?d)
874 (?s (gnus-current-score-file-nondirectory) ?s)))
876 (defvar gnus-last-search-regexp nil
877 "Default regexp for article search command.")
879 (defvar gnus-last-shell-command nil
880 "Default shell command on article.")
882 (defvar gnus-newsgroup-begin nil)
883 (defvar gnus-newsgroup-end nil)
884 (defvar gnus-newsgroup-last-rmail nil)
885 (defvar gnus-newsgroup-last-mail nil)
886 (defvar gnus-newsgroup-last-folder nil)
887 (defvar gnus-newsgroup-last-file nil)
888 (defvar gnus-newsgroup-auto-expire nil)
889 (defvar gnus-newsgroup-active nil)
891 (defvar gnus-newsgroup-data nil)
892 (defvar gnus-newsgroup-data-reverse nil)
893 (defvar gnus-newsgroup-limit nil)
894 (defvar gnus-newsgroup-limits nil)
896 (defvar gnus-newsgroup-unreads nil
897 "List of unread articles in the current newsgroup.")
899 (defvar gnus-newsgroup-unselected nil
900 "List of unselected unread articles in the current newsgroup.")
902 (defvar gnus-newsgroup-reads nil
903 "Alist of read articles and article marks in the current newsgroup.")
905 (defvar gnus-newsgroup-expunged-tally nil)
907 (defvar gnus-newsgroup-marked nil
908 "List of ticked articles in the current newsgroup (a subset of unread art).")
910 (defvar gnus-newsgroup-killed nil
911 "List of ranges of articles that have been through the scoring process.")
913 (defvar gnus-newsgroup-cached nil
914 "List of articles that come from the article cache.")
916 (defvar gnus-newsgroup-saved nil
917 "List of articles that have been saved.")
919 (defvar gnus-newsgroup-kill-headers nil)
921 (defvar gnus-newsgroup-replied nil
922 "List of articles that have been replied to in the current newsgroup.")
924 (defvar gnus-newsgroup-expirable nil
925 "List of articles in the current newsgroup that can be expired.")
927 (defvar gnus-newsgroup-processable nil
928 "List of articles in the current newsgroup that can be processed.")
930 (defvar gnus-newsgroup-downloadable nil
931 "List of articles in the current newsgroup that can be processed.")
933 (defvar gnus-newsgroup-undownloaded nil
934 "List of articles in the current newsgroup that haven't been downloaded..")
936 (defvar gnus-newsgroup-unsendable nil
937 "List of articles in the current newsgroup that won't be sent.")
939 (defvar gnus-newsgroup-bookmarks nil
940 "List of articles in the current newsgroup that have bookmarks.")
942 (defvar gnus-newsgroup-dormant nil
943 "List of dormant articles in the current newsgroup.")
945 (defvar gnus-newsgroup-scored nil
946 "List of scored articles in the current newsgroup.")
948 (defvar gnus-newsgroup-headers nil
949 "List of article headers in the current newsgroup.")
951 (defvar gnus-newsgroup-threads nil)
953 (defvar gnus-newsgroup-prepared nil
954 "Whether the current group has been prepared properly.")
956 (defvar gnus-newsgroup-ancient nil
957 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
959 (defvar gnus-newsgroup-sparse nil)
961 (defvar gnus-current-article nil)
962 (defvar gnus-article-current nil)
963 (defvar gnus-current-headers nil)
964 (defvar gnus-have-all-headers nil)
965 (defvar gnus-last-article nil)
966 (defvar gnus-newsgroup-history nil)
968 (defconst gnus-summary-local-variables
969 '(gnus-newsgroup-name
970 gnus-newsgroup-begin gnus-newsgroup-end
971 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
972 gnus-newsgroup-last-folder gnus-newsgroup-last-file
973 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
974 gnus-newsgroup-unselected gnus-newsgroup-marked
975 gnus-newsgroup-reads gnus-newsgroup-saved
976 gnus-newsgroup-replied gnus-newsgroup-expirable
977 gnus-newsgroup-processable gnus-newsgroup-killed
978 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
979 gnus-newsgroup-unsendable
980 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
981 gnus-newsgroup-headers gnus-newsgroup-threads
982 gnus-newsgroup-prepared gnus-summary-highlight-line-function
983 gnus-current-article gnus-current-headers gnus-have-all-headers
984 gnus-last-article gnus-article-internal-prepare-hook
985 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
986 gnus-newsgroup-scored gnus-newsgroup-kill-headers
987 gnus-thread-expunge-below
988 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
989 (gnus-summary-mark-below . global)
990 gnus-newsgroup-active gnus-scores-exclude-files
991 gnus-newsgroup-history gnus-newsgroup-ancient
992 gnus-newsgroup-sparse gnus-newsgroup-process-stack
993 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
994 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
995 (gnus-newsgroup-expunged-tally . 0)
996 gnus-cache-removable-articles gnus-newsgroup-cached
997 gnus-newsgroup-data gnus-newsgroup-data-reverse
998 gnus-newsgroup-limit gnus-newsgroup-limits)
999 "Variables that are buffer-local to the summary buffers.")
1001 ;; Byte-compiler warning.
1002 (defvar gnus-article-mode-map)
1004 ;; Subject simplification.
1006 (defun gnus-simplify-whitespace (str)
1007 "Remove excessive whitespace."
1010 (while (string-match "[ \t][ \t]+" mystr)
1011 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1013 (substring mystr (match-end 0)))))
1015 (when (string-match "^[ \t]+" mystr)
1016 (setq mystr (substring mystr (match-end 0))))
1018 (when (string-match "[ \t]+$" mystr)
1019 (setq mystr (substring mystr 0 (match-beginning 0))))
1022 (defsubst gnus-simplify-subject-re (subject)
1023 "Remove \"Re:\" from subject lines."
1024 (if (string-match "^[Rr][Ee]: *" subject)
1025 (substring subject (match-end 0))
1028 (defun gnus-simplify-subject (subject &optional re-only)
1029 "Remove `Re:' and words in parentheses.
1030 If RE-ONLY is non-nil, strip leading `Re:'s only."
1031 (let ((case-fold-search t)) ;Ignore case.
1032 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1033 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1034 (setq subject (substring subject (match-end 0))))
1035 ;; Remove uninteresting prefixes.
1036 (when (and (not re-only)
1037 gnus-simplify-ignored-prefixes
1038 (string-match gnus-simplify-ignored-prefixes subject))
1039 (setq subject (substring subject (match-end 0))))
1040 ;; Remove words in parentheses from end.
1042 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1043 (setq subject (substring subject 0 (match-beginning 0)))))
1044 ;; Return subject string.
1047 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1049 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1050 (goto-char (point-min))
1051 (while (re-search-forward regexp nil t)
1052 (replace-match (or newtext ""))))
1054 (defun gnus-simplify-buffer-fuzzy ()
1055 "Simplify string in the buffer fuzzily.
1056 The string in the accessible portion of the current buffer is simplified.
1057 It is assumed to be a single-line subject.
1058 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1059 matter is removed. Additional things can be deleted by setting
1060 gnus-simplify-subject-fuzzy-regexp."
1061 (let ((case-fold-search t)
1063 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1065 (while (not (eq modified-tick (buffer-modified-tick)))
1066 (setq modified-tick (buffer-modified-tick))
1068 ((listp gnus-simplify-subject-fuzzy-regexp)
1069 (mapcar 'gnus-simplify-buffer-fuzzy-step
1070 gnus-simplify-subject-fuzzy-regexp))
1071 (gnus-simplify-subject-fuzzy-regexp
1072 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1073 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1074 (gnus-simplify-buffer-fuzzy-step
1075 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1076 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1078 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1079 (gnus-simplify-buffer-fuzzy-step " +" " ")
1080 (gnus-simplify-buffer-fuzzy-step " $")
1081 (gnus-simplify-buffer-fuzzy-step "^ +")))
1083 (defun gnus-simplify-subject-fuzzy (subject)
1084 "Simplify a subject string fuzzily.
1085 See `gnus-simplify-buffer-fuzzy' for details."
1087 (gnus-set-work-buffer)
1088 (let ((case-fold-search t))
1089 ;; Remove uninteresting prefixes.
1090 (when (and gnus-simplify-ignored-prefixes
1091 (string-match gnus-simplify-ignored-prefixes subject))
1092 (setq subject (substring subject (match-end 0))))
1094 (inline (gnus-simplify-buffer-fuzzy))
1097 (defsubst gnus-simplify-subject-fully (subject)
1098 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1100 (gnus-simplify-subject-functions
1101 (gnus-map-function gnus-simplify-subject-functions subject))
1102 ((null gnus-summary-gather-subject-limit)
1103 (gnus-simplify-subject-re subject))
1104 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1105 (gnus-simplify-subject-fuzzy subject))
1106 ((numberp gnus-summary-gather-subject-limit)
1107 (gnus-limit-string (gnus-simplify-subject-re subject)
1108 gnus-summary-gather-subject-limit))
1112 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1113 "Check whether two subjects are equal.
1114 If optional argument simple-first is t, first argument is already
1117 ((null simple-first)
1118 (equal (gnus-simplify-subject-fully s1)
1119 (gnus-simplify-subject-fully s2)))
1122 (gnus-simplify-subject-fully s2)))))
1124 (defun gnus-summary-bubble-group ()
1125 "Increase the score of the current group.
1126 This is a handy function to add to `gnus-summary-exit-hook' to
1127 increase the score of each group you read."
1128 (gnus-group-add-score gnus-newsgroup-name))
1132 ;;; Gnus summary mode
1135 (put 'gnus-summary-mode 'mode-class 'special)
1138 ;; Non-orthogonal keys
1140 (gnus-define-keys gnus-summary-mode-map
1141 " " gnus-summary-next-page
1142 "\177" gnus-summary-prev-page
1143 [delete] gnus-summary-prev-page
1144 [backspace] gnus-summary-prev-page
1145 "\r" gnus-summary-scroll-up
1146 "\M-\r" gnus-summary-scroll-down
1147 "n" gnus-summary-next-unread-article
1148 "p" gnus-summary-prev-unread-article
1149 "N" gnus-summary-next-article
1150 "P" gnus-summary-prev-article
1151 "\M-\C-n" gnus-summary-next-same-subject
1152 "\M-\C-p" gnus-summary-prev-same-subject
1153 "\M-n" gnus-summary-next-unread-subject
1154 "\M-p" gnus-summary-prev-unread-subject
1155 "." gnus-summary-first-unread-article
1156 "," gnus-summary-best-unread-article
1157 "\M-s" gnus-summary-search-article-forward
1158 "\M-r" gnus-summary-search-article-backward
1159 "<" gnus-summary-beginning-of-article
1160 ">" gnus-summary-end-of-article
1161 "j" gnus-summary-goto-article
1162 "^" gnus-summary-refer-parent-article
1163 "\M-^" gnus-summary-refer-article
1164 "u" gnus-summary-tick-article-forward
1165 "!" gnus-summary-tick-article-forward
1166 "U" gnus-summary-tick-article-backward
1167 "d" gnus-summary-mark-as-read-forward
1168 "D" gnus-summary-mark-as-read-backward
1169 "E" gnus-summary-mark-as-expirable
1170 "\M-u" gnus-summary-clear-mark-forward
1171 "\M-U" gnus-summary-clear-mark-backward
1172 "k" gnus-summary-kill-same-subject-and-select
1173 "\C-k" gnus-summary-kill-same-subject
1174 "\M-\C-k" gnus-summary-kill-thread
1175 "\M-\C-l" gnus-summary-lower-thread
1176 "e" gnus-summary-edit-article
1177 "#" gnus-summary-mark-as-processable
1178 "\M-#" gnus-summary-unmark-as-processable
1179 "\M-\C-t" gnus-summary-toggle-threads
1180 "\M-\C-s" gnus-summary-show-thread
1181 "\M-\C-h" gnus-summary-hide-thread
1182 "\M-\C-f" gnus-summary-next-thread
1183 "\M-\C-b" gnus-summary-prev-thread
1184 "\M-\C-u" gnus-summary-up-thread
1185 "\M-\C-d" gnus-summary-down-thread
1186 "&" gnus-summary-execute-command
1187 "c" gnus-summary-catchup-and-exit
1188 "\C-w" gnus-summary-mark-region-as-read
1189 "\C-t" gnus-summary-toggle-truncation
1190 "?" gnus-summary-mark-as-dormant
1191 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1192 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1193 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1194 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1195 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1196 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1197 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1198 "=" gnus-summary-expand-window
1199 "\C-x\C-s" gnus-summary-reselect-current-group
1200 "\M-g" gnus-summary-rescan-group
1201 "w" gnus-summary-stop-page-breaking
1202 "\C-c\C-r" gnus-summary-caesar-message
1203 "\M-t" gnus-summary-toggle-mime
1204 "f" gnus-summary-followup
1205 "F" gnus-summary-followup-with-original
1206 "C" gnus-summary-cancel-article
1207 "r" gnus-summary-reply
1208 "R" gnus-summary-reply-with-original
1209 "\C-c\C-f" gnus-summary-mail-forward
1210 "o" gnus-summary-save-article
1211 "\C-o" gnus-summary-save-article-mail
1212 "|" gnus-summary-pipe-output
1213 "\M-k" gnus-summary-edit-local-kill
1214 "\M-K" gnus-summary-edit-global-kill
1216 "\C-c\C-d" gnus-summary-describe-group
1217 "q" gnus-summary-exit
1218 "Q" gnus-summary-exit-no-update
1219 "\C-c\C-i" gnus-info-find-node
1220 gnus-mouse-2 gnus-mouse-pick-article
1221 "m" gnus-summary-mail-other-window
1222 "a" gnus-summary-post-news
1223 "x" gnus-summary-limit-to-unread
1224 "s" gnus-summary-isearch-article
1225 "t" gnus-article-hide-headers
1226 "g" gnus-summary-show-article
1227 "l" gnus-summary-goto-last-article
1228 "v" gnus-summary-preview-mime-message
1229 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1230 "\C-d" gnus-summary-enter-digest-group
1231 "\M-\C-d" gnus-summary-read-document
1232 "\M-\C-e" gnus-summary-edit-parameters
1234 "*" gnus-cache-enter-article
1235 "\M-*" gnus-cache-remove-article
1236 "\M-&" gnus-summary-universal-argument
1237 "\C-l" gnus-recenter
1238 "I" gnus-summary-increase-score
1239 "L" gnus-summary-lower-score
1240 "\M-i" gnus-symbolic-argument
1241 "h" gnus-summary-select-article-buffer
1243 "V" gnus-summary-score-map
1244 "X" gnus-uu-extract-map
1245 "S" gnus-summary-send-map)
1247 ;; Sort of orthogonal keymap
1248 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1249 "t" gnus-summary-tick-article-forward
1250 "!" gnus-summary-tick-article-forward
1251 "d" gnus-summary-mark-as-read-forward
1252 "r" gnus-summary-mark-as-read-forward
1253 "c" gnus-summary-clear-mark-forward
1254 " " gnus-summary-clear-mark-forward
1255 "e" gnus-summary-mark-as-expirable
1256 "x" gnus-summary-mark-as-expirable
1257 "?" gnus-summary-mark-as-dormant
1258 "b" gnus-summary-set-bookmark
1259 "B" gnus-summary-remove-bookmark
1260 "#" gnus-summary-mark-as-processable
1261 "\M-#" gnus-summary-unmark-as-processable
1262 "S" gnus-summary-limit-include-expunged
1263 "C" gnus-summary-catchup
1264 "H" gnus-summary-catchup-to-here
1265 "\C-c" gnus-summary-catchup-all
1266 "k" gnus-summary-kill-same-subject-and-select
1267 "K" gnus-summary-kill-same-subject
1268 "P" gnus-uu-mark-map)
1270 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1271 "c" gnus-summary-clear-above
1272 "u" gnus-summary-tick-above
1273 "m" gnus-summary-mark-above
1274 "k" gnus-summary-kill-below)
1276 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1277 "/" gnus-summary-limit-to-subject
1278 "n" gnus-summary-limit-to-articles
1279 "w" gnus-summary-pop-limit
1280 "s" gnus-summary-limit-to-subject
1281 "a" gnus-summary-limit-to-author
1282 "u" gnus-summary-limit-to-unread
1283 "m" gnus-summary-limit-to-marks
1284 "v" gnus-summary-limit-to-score
1285 "*" gnus-summary-limit-include-cached
1286 "D" gnus-summary-limit-include-dormant
1287 "T" gnus-summary-limit-include-thread
1288 "d" gnus-summary-limit-exclude-dormant
1289 "t" gnus-summary-limit-to-age
1290 "E" gnus-summary-limit-include-expunged
1291 "c" gnus-summary-limit-exclude-childless-dormant
1292 "C" gnus-summary-limit-mark-excluded-as-read)
1294 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1295 "n" gnus-summary-next-unread-article
1296 "p" gnus-summary-prev-unread-article
1297 "N" gnus-summary-next-article
1298 "P" gnus-summary-prev-article
1299 "\C-n" gnus-summary-next-same-subject
1300 "\C-p" gnus-summary-prev-same-subject
1301 "\M-n" gnus-summary-next-unread-subject
1302 "\M-p" gnus-summary-prev-unread-subject
1303 "f" gnus-summary-first-unread-article
1304 "b" gnus-summary-best-unread-article
1305 "j" gnus-summary-goto-article
1306 "g" gnus-summary-goto-subject
1307 "l" gnus-summary-goto-last-article
1308 "o" gnus-summary-pop-article)
1310 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1311 "k" gnus-summary-kill-thread
1312 "l" gnus-summary-lower-thread
1313 "i" gnus-summary-raise-thread
1314 "T" gnus-summary-toggle-threads
1315 "t" gnus-summary-rethread-current
1316 "^" gnus-summary-reparent-thread
1317 "s" gnus-summary-show-thread
1318 "S" gnus-summary-show-all-threads
1319 "h" gnus-summary-hide-thread
1320 "H" gnus-summary-hide-all-threads
1321 "n" gnus-summary-next-thread
1322 "p" gnus-summary-prev-thread
1323 "u" gnus-summary-up-thread
1324 "o" gnus-summary-top-thread
1325 "d" gnus-summary-down-thread
1326 "#" gnus-uu-mark-thread
1327 "\M-#" gnus-uu-unmark-thread)
1329 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1330 "g" gnus-summary-prepare
1331 "c" gnus-summary-insert-cached-articles)
1333 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1334 "c" gnus-summary-catchup-and-exit
1335 "C" gnus-summary-catchup-all-and-exit
1336 "E" gnus-summary-exit-no-update
1337 "Q" gnus-summary-exit
1338 "Z" gnus-summary-exit
1339 "n" gnus-summary-catchup-and-goto-next-group
1340 "R" gnus-summary-reselect-current-group
1341 "G" gnus-summary-rescan-group
1342 "N" gnus-summary-next-group
1343 "s" gnus-summary-save-newsrc
1344 "P" gnus-summary-prev-group)
1346 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1347 " " gnus-summary-next-page
1348 "n" gnus-summary-next-page
1349 "\177" gnus-summary-prev-page
1350 [delete] gnus-summary-prev-page
1351 "p" gnus-summary-prev-page
1352 "\r" gnus-summary-scroll-up
1353 "\M-\r" gnus-summary-scroll-down
1354 "<" gnus-summary-beginning-of-article
1355 ">" gnus-summary-end-of-article
1356 "b" gnus-summary-beginning-of-article
1357 "e" gnus-summary-end-of-article
1358 "^" gnus-summary-refer-parent-article
1359 "r" gnus-summary-refer-parent-article
1360 "R" gnus-summary-refer-references
1361 "T" gnus-summary-refer-thread
1362 "g" gnus-summary-show-article
1363 "s" gnus-summary-isearch-article
1364 "P" gnus-summary-print-article)
1366 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1367 "b" gnus-article-add-buttons
1368 "B" gnus-article-add-buttons-to-head
1369 "o" gnus-article-treat-overstrike
1370 "e" gnus-article-emphasize
1371 "w" gnus-article-fill-cited-article
1372 "c" gnus-article-remove-cr
1373 "f" gnus-article-display-x-face
1374 "l" gnus-summary-stop-page-breaking
1375 "r" gnus-summary-caesar-message
1376 "t" gnus-article-hide-headers
1377 "v" gnus-summary-verbose-headers
1378 "m" gnus-summary-toggle-mime
1379 "h" gnus-article-treat-html
1380 "d" gnus-article-treat-dumbquotes)
1382 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1383 "a" gnus-article-hide
1384 "h" gnus-article-hide-headers
1385 "b" gnus-article-hide-boring-headers
1386 "s" gnus-article-hide-signature
1387 "c" gnus-article-hide-citation
1388 "C" gnus-article-hide-citation-in-followups
1389 "p" gnus-article-hide-pgp
1390 "P" gnus-article-hide-pem
1391 "\C-c" gnus-article-hide-citation-maybe)
1393 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1394 "a" gnus-article-highlight
1395 "h" gnus-article-highlight-headers
1396 "c" gnus-article-highlight-citation
1397 "s" gnus-article-highlight-signature)
1399 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1400 "z" gnus-article-date-ut
1401 "u" gnus-article-date-ut
1402 "l" gnus-article-date-local
1403 "e" gnus-article-date-lapsed
1404 "o" gnus-article-date-original
1405 "i" gnus-article-date-iso8601
1406 "s" gnus-article-date-user)
1408 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1409 "t" gnus-article-remove-trailing-blank-lines
1410 "l" gnus-article-strip-leading-blank-lines
1411 "m" gnus-article-strip-multiple-blank-lines
1412 "a" gnus-article-strip-blank-lines
1413 "A" gnus-article-strip-all-blank-lines
1414 "s" gnus-article-strip-leading-space)
1416 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1418 "f" gnus-summary-fetch-faq
1419 "d" gnus-summary-describe-group
1420 "h" gnus-summary-describe-briefly
1421 "i" gnus-info-find-node)
1423 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1424 "e" gnus-summary-expire-articles
1425 "\M-\C-e" gnus-summary-expire-articles-now
1426 "\177" gnus-summary-delete-article
1427 [delete] gnus-summary-delete-article
1428 "m" gnus-summary-move-article
1429 "r" gnus-summary-respool-article
1430 "w" gnus-summary-edit-article
1431 "c" gnus-summary-copy-article
1432 "B" gnus-summary-crosspost-article
1433 "q" gnus-summary-respool-query
1434 "t" gnus-summary-respool-trace
1435 "i" gnus-summary-import-article
1436 "p" gnus-summary-article-posted-p)
1438 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1439 "o" gnus-summary-save-article
1440 "m" gnus-summary-save-article-mail
1441 "F" gnus-summary-write-article-file
1442 "r" gnus-summary-save-article-rmail
1443 "f" gnus-summary-save-article-file
1444 "b" gnus-summary-save-article-body-file
1445 "h" gnus-summary-save-article-folder
1446 "v" gnus-summary-save-article-vm
1447 "p" gnus-summary-pipe-output
1448 "s" gnus-soup-add-article))
1450 (defun gnus-summary-make-menu-bar ()
1451 (gnus-turn-off-edit-menu 'summary)
1453 (unless (boundp 'gnus-summary-misc-menu)
1456 gnus-summary-kill-menu gnus-summary-mode-map ""
1461 ["Enter score..." gnus-summary-score-entry t]
1462 ["Customize" gnus-score-customize t])
1463 (gnus-make-score-map 'increase)
1464 (gnus-make-score-map 'lower)
1466 ["Kill below" gnus-summary-kill-below t]
1467 ["Mark above" gnus-summary-mark-above t]
1468 ["Tick above" gnus-summary-tick-above t]
1469 ["Clear above" gnus-summary-clear-above t])
1470 ["Current score" gnus-summary-current-score t]
1471 ["Set score" gnus-summary-set-score t]
1472 ["Switch current score file..." gnus-score-change-score-file t]
1473 ["Set mark below..." gnus-score-set-mark-below t]
1474 ["Set expunge below..." gnus-score-set-expunge-below t]
1475 ["Edit current score file" gnus-score-edit-current-scores t]
1476 ["Edit score file" gnus-score-edit-file t]
1477 ["Trace score" gnus-score-find-trace t]
1478 ["Find words" gnus-score-find-favourite-words t]
1479 ["Rescore buffer" gnus-summary-rescore t]
1480 ["Increase score..." gnus-summary-increase-score t]
1481 ["Lower score..." gnus-summary-lower-score t]))))
1483 ;; Define both the Article menu in the summary buffer and the equivalent
1484 ;; Commands menu in the article buffer here for consistency.
1487 ["All" gnus-article-hide t]
1488 ["Headers" gnus-article-hide-headers t]
1489 ["Signature" gnus-article-hide-signature t]
1490 ["Citation" gnus-article-hide-citation t]
1491 ["PGP" gnus-article-hide-pgp t]
1492 ["Boring headers" gnus-article-hide-boring-headers t])
1494 ["All" gnus-article-highlight t]
1495 ["Headers" gnus-article-highlight-headers t]
1496 ["Signature" gnus-article-highlight-signature t]
1497 ["Citation" gnus-article-highlight-citation t])
1499 ["Local" gnus-article-date-local t]
1500 ["ISO8601" gnus-article-date-iso8601 t]
1501 ["UT" gnus-article-date-ut t]
1502 ["Original" gnus-article-date-original t]
1503 ["Lapsed" gnus-article-date-lapsed t]
1504 ["User-defined" gnus-article-date-user t])
1507 ["Leading" gnus-article-strip-leading-blank-lines t]
1508 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1509 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1510 ["All of the above" gnus-article-strip-blank-lines t]
1511 ["All" gnus-article-strip-all-blank-lines t]
1512 ["Leading space" gnus-article-strip-leading-space t])
1513 ["Overstrike" gnus-article-treat-overstrike t]
1514 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1515 ["Emphasis" gnus-article-emphasize t]
1516 ["Word wrap" gnus-article-fill-cited-article t]
1517 ["CR" gnus-article-remove-cr t]
1518 ["Show X-Face" gnus-article-display-x-face t]
1519 ["UnHTMLize" gnus-article-treat-html t]
1520 ["Rot 13" gnus-summary-caesar-message t]
1521 ["Unix pipe" gnus-summary-pipe-message t]
1522 ["Add buttons" gnus-article-add-buttons t]
1523 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1524 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1525 ["Toggle MIME" gnus-summary-toggle-mime t]
1526 ["Verbose header" gnus-summary-verbose-headers t]
1527 ["Toggle header" gnus-summary-toggle-header t])
1529 ["Save in default format" gnus-summary-save-article t]
1530 ["Save in file" gnus-summary-save-article-file t]
1531 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1532 ["Save in MH folder" gnus-summary-save-article-folder t]
1533 ["Save in VM folder" gnus-summary-save-article-vm t]
1534 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1535 ["Save body in file" gnus-summary-save-article-body-file t]
1536 ["Pipe through a filter" gnus-summary-pipe-output t]
1537 ["Add to SOUP packet" gnus-soup-add-article t]
1538 ["Print" gnus-summary-print-article t])
1540 ["Respool article..." gnus-summary-respool-article t]
1541 ["Move article..." gnus-summary-move-article
1542 (gnus-check-backend-function
1543 'request-move-article gnus-newsgroup-name)]
1544 ["Copy article..." gnus-summary-copy-article t]
1545 ["Crosspost article..." gnus-summary-crosspost-article
1546 (gnus-check-backend-function
1547 'request-replace-article gnus-newsgroup-name)]
1548 ["Import file..." gnus-summary-import-article t]
1549 ["Check if posted" gnus-summary-article-posted-p t]
1550 ["Edit article" gnus-summary-edit-article
1551 (not (gnus-group-read-only-p))]
1552 ["Delete article" gnus-summary-delete-article
1553 (gnus-check-backend-function
1554 'request-expire-articles gnus-newsgroup-name)]
1555 ["Query respool" gnus-summary-respool-query t]
1556 ["Trace respool" gnus-summary-respool-trace t]
1557 ["Delete expirable articles" gnus-summary-expire-articles-now
1558 (gnus-check-backend-function
1559 'request-expire-articles gnus-newsgroup-name)])
1561 ["Uudecode" gnus-uu-decode-uu t]
1562 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1563 ["Unshar" gnus-uu-decode-unshar t]
1564 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1565 ["Save" gnus-uu-decode-save t]
1566 ["Binhex" gnus-uu-decode-binhex t]
1567 ["Postscript" gnus-uu-decode-postscript t])
1569 ["Enter article" gnus-cache-enter-article t]
1570 ["Remove article" gnus-cache-remove-article t])
1571 ["Select article buffer" gnus-summary-select-article-buffer t]
1572 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1573 ["Isearch article..." gnus-summary-isearch-article t]
1574 ["Beginning of the article" gnus-summary-beginning-of-article t]
1575 ["End of the article" gnus-summary-end-of-article t]
1576 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1577 ["Fetch referenced articles" gnus-summary-refer-references t]
1578 ["Fetch current thread" gnus-summary-refer-thread t]
1579 ["Fetch article with id..." gnus-summary-refer-article t]
1580 ["Redisplay" gnus-summary-show-article t])))
1582 gnus-summary-article-menu gnus-summary-mode-map ""
1583 (cons "Article" innards))
1586 gnus-article-commands-menu gnus-article-mode-map ""
1587 (cons "Commands" innards)))
1590 gnus-summary-thread-menu gnus-summary-mode-map ""
1592 ["Toggle threading" gnus-summary-toggle-threads t]
1593 ["Hide threads" gnus-summary-hide-all-threads t]
1594 ["Show threads" gnus-summary-show-all-threads t]
1595 ["Hide thread" gnus-summary-hide-thread t]
1596 ["Show thread" gnus-summary-show-thread t]
1597 ["Go to next thread" gnus-summary-next-thread t]
1598 ["Go to previous thread" gnus-summary-prev-thread t]
1599 ["Go down thread" gnus-summary-down-thread t]
1600 ["Go up thread" gnus-summary-up-thread t]
1601 ["Top of thread" gnus-summary-top-thread t]
1602 ["Mark thread as read" gnus-summary-kill-thread t]
1603 ["Lower thread score" gnus-summary-lower-thread t]
1604 ["Raise thread score" gnus-summary-raise-thread t]
1605 ["Rethread current" gnus-summary-rethread-current t]
1609 gnus-summary-post-menu gnus-summary-mode-map ""
1611 ["Post an article" gnus-summary-post-news t]
1612 ["Followup" gnus-summary-followup t]
1613 ["Followup and yank" gnus-summary-followup-with-original t]
1614 ["Supersede article" gnus-summary-supersede-article t]
1615 ["Cancel article" gnus-summary-cancel-article t]
1616 ["Reply" gnus-summary-reply t]
1617 ["Reply and yank" gnus-summary-reply-with-original t]
1618 ["Wide reply" gnus-summary-wide-reply t]
1619 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1620 ["Mail forward" gnus-summary-mail-forward t]
1621 ["Post forward" gnus-summary-post-forward t]
1622 ["Digest and mail" gnus-summary-mail-digest t]
1623 ["Digest and post" gnus-summary-post-digest t]
1624 ["Resend message" gnus-summary-resend-message t]
1625 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1626 ["Send a mail" gnus-summary-mail-other-window t]
1627 ["Uuencode and post" gnus-uu-post-news t]
1628 ["Followup via news" gnus-summary-followup-to-mail t]
1629 ["Followup via news and yank"
1630 gnus-summary-followup-to-mail-with-original t]
1632 ;;["Send" gnus-summary-send-draft t]
1633 ;;["Send bounced" gnus-resend-bounced-mail t])
1637 gnus-summary-misc-menu gnus-summary-mode-map ""
1640 ["Mark as read" gnus-summary-mark-as-read-forward t]
1641 ["Mark same subject and select"
1642 gnus-summary-kill-same-subject-and-select t]
1643 ["Mark same subject" gnus-summary-kill-same-subject t]
1644 ["Catchup" gnus-summary-catchup t]
1645 ["Catchup all" gnus-summary-catchup-all t]
1646 ["Catchup to here" gnus-summary-catchup-to-here t]
1647 ["Catchup region" gnus-summary-mark-region-as-read t]
1648 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1650 ["Tick" gnus-summary-tick-article-forward t]
1651 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1652 ["Remove marks" gnus-summary-clear-mark-forward t]
1653 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1654 ["Set bookmark" gnus-summary-set-bookmark t]
1655 ["Remove bookmark" gnus-summary-remove-bookmark t])
1657 ["Marks..." gnus-summary-limit-to-marks t]
1658 ["Subject..." gnus-summary-limit-to-subject t]
1659 ["Author..." gnus-summary-limit-to-author t]
1660 ["Age..." gnus-summary-limit-to-age t]
1661 ["Score" gnus-summary-limit-to-score t]
1662 ["Unread" gnus-summary-limit-to-unread t]
1663 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1664 ["Articles" gnus-summary-limit-to-articles t]
1665 ["Pop limit" gnus-summary-pop-limit t]
1666 ["Show dormant" gnus-summary-limit-include-dormant t]
1667 ["Hide childless dormant"
1668 gnus-summary-limit-exclude-childless-dormant t]
1669 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1670 ["Show expunged" gnus-summary-show-all-expunged t])
1672 ["Set mark" gnus-summary-mark-as-processable t]
1673 ["Remove mark" gnus-summary-unmark-as-processable t]
1674 ["Remove all marks" gnus-summary-unmark-all-processable t]
1675 ["Mark above" gnus-uu-mark-over t]
1676 ["Mark series" gnus-uu-mark-series t]
1677 ["Mark region" gnus-uu-mark-region t]
1678 ["Unmark region" gnus-uu-unmark-region t]
1679 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1680 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1681 ["Mark all" gnus-uu-mark-all t]
1682 ["Mark buffer" gnus-uu-mark-buffer t]
1683 ["Mark sparse" gnus-uu-mark-sparse t]
1684 ["Mark thread" gnus-uu-mark-thread t]
1685 ["Unmark thread" gnus-uu-unmark-thread t]
1686 ("Process Mark Sets"
1687 ["Kill" gnus-summary-kill-process-mark t]
1688 ["Yank" gnus-summary-yank-process-mark
1689 gnus-newsgroup-process-stack]
1690 ["Save" gnus-summary-save-process-mark t]))
1692 ["Page forward" gnus-summary-next-page t]
1693 ["Page backward" gnus-summary-prev-page t]
1694 ["Line forward" gnus-summary-scroll-up t])
1696 ["Next unread article" gnus-summary-next-unread-article t]
1697 ["Previous unread article" gnus-summary-prev-unread-article t]
1698 ["Next article" gnus-summary-next-article t]
1699 ["Previous article" gnus-summary-prev-article t]
1700 ["Next unread subject" gnus-summary-next-unread-subject t]
1701 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1702 ["Next article same subject" gnus-summary-next-same-subject t]
1703 ["Previous article same subject" gnus-summary-prev-same-subject t]
1704 ["First unread article" gnus-summary-first-unread-article t]
1705 ["Best unread article" gnus-summary-best-unread-article t]
1706 ["Go to subject number..." gnus-summary-goto-subject t]
1707 ["Go to article number..." gnus-summary-goto-article t]
1708 ["Go to the last article" gnus-summary-goto-last-article t]
1709 ["Pop article off history" gnus-summary-pop-article t])
1711 ["Sort by number" gnus-summary-sort-by-number t]
1712 ["Sort by author" gnus-summary-sort-by-author t]
1713 ["Sort by subject" gnus-summary-sort-by-subject t]
1714 ["Sort by date" gnus-summary-sort-by-date t]
1715 ["Sort by score" gnus-summary-sort-by-score t]
1716 ["Sort by lines" gnus-summary-sort-by-lines t])
1718 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1719 ["Describe group" gnus-summary-describe-group t]
1720 ["Read manual" gnus-info-find-node t])
1722 ["Pick and read" gnus-pick-mode t]
1723 ["Binary" gnus-binary-mode t])
1725 ["Regenerate" gnus-summary-prepare t]
1726 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1727 ["Toggle threading" gnus-summary-toggle-threads t])
1728 ["Filter articles..." gnus-summary-execute-command t]
1729 ["Run command on subjects..." gnus-summary-universal-argument t]
1730 ["Search articles forward..." gnus-summary-search-article-forward t]
1731 ["Search articles backward..." gnus-summary-search-article-backward t]
1732 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1733 ["Expand window" gnus-summary-expand-window t]
1734 ["Expire expirable articles" gnus-summary-expire-articles
1735 (gnus-check-backend-function
1736 'request-expire-articles gnus-newsgroup-name)]
1737 ["Edit local kill file" gnus-summary-edit-local-kill t]
1738 ["Edit main kill file" gnus-summary-edit-global-kill t]
1739 ["Edit group parameters" gnus-summary-edit-parameters t]
1740 ["Send a bug report" gnus-bug t]
1742 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1743 ["Catchup all and exit" gnus-summary-catchup-all-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)
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)))
1984 (let ((odata gnus-newsgroup-data))
1985 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
1987 (gnus-data-update-list odata offset)))
1988 ;; Find the last element in the list to be spliced into the main
1991 (setq list (cdr list)))
1994 (setcdr list gnus-newsgroup-data)
1995 (setq gnus-newsgroup-data ilist)
1997 (gnus-data-update-list (cdr list) offset)))
1998 (setcdr list (cdr data))
2001 (gnus-data-update-list (cdr list) offset))))
2002 (setq gnus-newsgroup-data-reverse nil))))
2004 (defun gnus-data-remove (article &optional offset)
2005 (let ((data gnus-newsgroup-data))
2006 (if (= (gnus-data-number (car data)) article)
2008 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2009 gnus-newsgroup-data-reverse nil)
2011 (gnus-data-update-list gnus-newsgroup-data offset)))
2013 (when (= (gnus-data-number (cadr data)) article)
2014 (setcdr data (cddr data))
2016 (gnus-data-update-list (cdr data) offset))
2018 gnus-newsgroup-data-reverse nil))
2019 (setq data (cdr data))))))
2021 (defmacro gnus-data-list (backward)
2023 (or gnus-newsgroup-data-reverse
2024 (setq gnus-newsgroup-data-reverse
2025 (reverse gnus-newsgroup-data)))
2026 gnus-newsgroup-data))
2028 (defun gnus-data-update-list (data offset)
2029 "Add OFFSET to the POS of all data entries in DATA."
2030 (setq gnus-newsgroup-data-reverse nil)
2032 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2033 (setq data (cdr data))))
2035 (defun gnus-summary-article-pseudo-p (article)
2036 "Say whether this article is a pseudo article or not."
2037 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2039 (defmacro gnus-summary-article-sparse-p (article)
2040 "Say whether this article is a sparse article or not."
2041 `(memq ,article gnus-newsgroup-sparse))
2043 (defmacro gnus-summary-article-ancient-p (article)
2044 "Say whether this article is a sparse article or not."
2045 `(memq ,article gnus-newsgroup-ancient))
2047 (defun gnus-article-parent-p (number)
2048 "Say whether this article is a parent or not."
2049 (let ((data (gnus-data-find-list number)))
2050 (and (cdr data) ; There has to be an article after...
2051 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2052 (gnus-data-level (nth 1 data))))))
2054 (defun gnus-article-children (number)
2055 "Return a list of all children to NUMBER."
2056 (let* ((data (gnus-data-find-list number))
2057 (level (gnus-data-level (car data)))
2059 (setq data (cdr data))
2061 (= (gnus-data-level (car data)) (1+ level)))
2062 (push (gnus-data-number (car data)) children)
2063 (setq data (cdr data)))
2066 (defmacro gnus-summary-skip-intangible ()
2067 "If the current article is intangible, then jump to a different article."
2068 '(let ((to (get-text-property (point) 'gnus-intangible)))
2069 (and to (gnus-summary-goto-subject to))))
2071 (defmacro gnus-summary-article-intangible-p ()
2072 "Say whether this article is intangible or not."
2073 '(get-text-property (point) 'gnus-intangible))
2075 (defun gnus-article-read-p (article)
2076 "Say whether ARTICLE is read or not."
2077 (not (or (memq article gnus-newsgroup-marked)
2078 (memq article gnus-newsgroup-unreads)
2079 (memq article gnus-newsgroup-unselected)
2080 (memq article gnus-newsgroup-dormant))))
2082 ;; Some summary mode macros.
2084 (defmacro gnus-summary-article-number ()
2085 "The article number of the article on the current line.
2086 If there isn's an article number here, then we return the current
2089 (gnus-summary-skip-intangible)
2090 (or (get-text-property (point) 'gnus-number)
2091 (gnus-summary-last-subject))))
2093 (defmacro gnus-summary-article-header (&optional number)
2094 "Return the header of article NUMBER."
2095 `(gnus-data-header (gnus-data-find
2096 ,(or number '(gnus-summary-article-number)))))
2098 (defmacro gnus-summary-thread-level (&optional number)
2099 "Return the level of thread that starts with article NUMBER."
2100 `(if (and (eq gnus-summary-make-false-root 'dummy)
2101 (get-text-property (point) 'gnus-intangible))
2103 (gnus-data-level (gnus-data-find
2104 ,(or number '(gnus-summary-article-number))))))
2106 (defmacro gnus-summary-article-mark (&optional number)
2107 "Return the mark of article NUMBER."
2108 `(gnus-data-mark (gnus-data-find
2109 ,(or number '(gnus-summary-article-number)))))
2111 (defmacro gnus-summary-article-pos (&optional number)
2112 "Return the position of the line of article NUMBER."
2113 `(gnus-data-pos (gnus-data-find
2114 ,(or number '(gnus-summary-article-number)))))
2116 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2117 (defmacro gnus-summary-article-subject (&optional number)
2118 "Return current subject string or nil if nothing."
2121 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2122 '(gnus-data-header (assq (gnus-summary-article-number)
2123 gnus-newsgroup-data)))))
2126 (mail-header-subject headers))))
2128 (defmacro gnus-summary-article-score (&optional number)
2129 "Return current article score."
2130 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2131 gnus-newsgroup-scored))
2132 gnus-summary-default-score 0))
2134 (defun gnus-summary-article-children (&optional number)
2135 "Return a list of article numbers that are children of article NUMBER."
2136 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2137 (level (gnus-data-level (car data)))
2139 (while (and (setq data (cdr data))
2140 (> (setq l (gnus-data-level (car data))) level))
2141 (and (= (1+ level) l)
2142 (push (gnus-data-number (car data))
2144 (nreverse children)))
2146 (defun gnus-summary-article-parent (&optional number)
2147 "Return the article number of the parent of article NUMBER."
2148 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2149 (gnus-data-list t)))
2150 (level (gnus-data-level (car data))))
2152 () ; This is a root.
2153 ;; We search until we find an article with a level less than
2154 ;; this one. That function has to be the parent.
2155 (while (and (setq data (cdr data))
2156 (not (< (gnus-data-level (car data)) level))))
2157 (and data (gnus-data-number (car data))))))
2159 (defun gnus-unread-mark-p (mark)
2160 "Say whether MARK is the unread mark."
2161 (= mark gnus-unread-mark))
2163 (defun gnus-read-mark-p (mark)
2164 "Say whether MARK is one of the marks that mark as read.
2165 This is all marks except unread, ticked, dormant, and expirable."
2166 (not (or (= mark gnus-unread-mark)
2167 (= mark gnus-ticked-mark)
2168 (= mark gnus-dormant-mark)
2169 (= mark gnus-expirable-mark))))
2171 (defmacro gnus-article-mark (number)
2172 "Return the MARK of article NUMBER.
2173 This macro should only be used when computing the mark the \"first\"
2174 time; i.e., when generating the summary lines. After that,
2175 `gnus-summary-article-mark' should be used to examine the
2178 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2179 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2180 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2181 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2182 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2183 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2184 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2185 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2186 gnus-ancient-mark))))
2188 ;; Saving hidden threads.
2190 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2191 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2193 (defmacro gnus-save-hidden-threads (&rest forms)
2194 "Save hidden threads, eval FORMS, and restore the hidden threads."
2195 (let ((config (make-symbol "config")))
2196 `(let ((,config (gnus-hidden-threads-configuration)))
2200 (gnus-restore-hidden-threads-configuration ,config)))))
2202 (defun gnus-data-compute-positions ()
2203 "Compute the positions of all articles."
2204 (setq gnus-newsgroup-data-reverse nil)
2205 (let ((data gnus-newsgroup-data))
2207 (gnus-save-hidden-threads
2208 (gnus-summary-show-all-threads)
2209 (goto-char (point-min))
2211 (while (get-text-property (point) 'gnus-intangible)
2213 (gnus-data-set-pos (car data) (+ (point) 3))
2214 (setq data (cdr data))
2215 (forward-line 1))))))
2217 (defun gnus-hidden-threads-configuration ()
2218 "Return the current hidden threads configuration."
2221 (goto-char (point-min))
2222 (while (search-forward "\r" nil t)
2223 (push (1- (point)) config))
2226 (defun gnus-restore-hidden-threads-configuration (config)
2227 "Restore hidden threads configuration from CONFIG."
2228 (let (point buffer-read-only)
2229 (while (setq point (pop config))
2230 (when (and (< point (point-max))
2232 (= (following-char) ?\n))
2233 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2235 ;; Various summary mode internalish functions.
2237 (defun gnus-mouse-pick-article (e)
2240 (gnus-summary-next-page nil t))
2242 (defun gnus-summary-set-display-table ()
2243 ;; Change the display table. Odd characters have a tendency to mess
2244 ;; up nicely formatted displays - we make all possible glyphs
2245 ;; display only a single character.
2247 ;; We start from the standard display table, if any.
2248 (let ((table (or (copy-sequence standard-display-table)
2249 (make-display-table)))
2251 ;; Nix out all the control chars...
2252 (while (>= (setq i (1- i)) 0)
2253 (aset table i [??]))
2254 ;; ... but not newline and cr, of course. (cr is necessary for the
2255 ;; selective display).
2256 (aset table ?\n nil)
2257 (aset table ?\r nil)
2258 ;; We keep TAB as well.
2259 (aset table ?\t nil)
2260 ;; We nix out any glyphs over 126 that are not set already.
2262 (while (>= (setq i (1- i)) 127)
2263 ;; Only modify if the entry is nil.
2264 (unless (aref table i)
2265 (aset table i [??]))))
2266 (setq buffer-display-table table)))
2268 (defun gnus-summary-setup-buffer (group)
2269 "Initialize summary buffer."
2270 (let ((buffer (concat "*Summary " group "*")))
2271 (if (get-buffer buffer)
2274 (setq gnus-summary-buffer (current-buffer))
2275 (not gnus-newsgroup-prepared))
2276 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2277 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2278 (gnus-summary-mode group)
2280 (gnus-carpal-setup-buffer 'summary))
2281 (unless gnus-single-article-buffer
2282 (make-local-variable 'gnus-article-buffer)
2283 (make-local-variable 'gnus-article-current)
2284 (make-local-variable 'gnus-original-article-buffer))
2285 (setq gnus-newsgroup-name group)
2288 (defun gnus-set-global-variables ()
2289 ;; Set the global equivalents of the summary buffer-local variables
2290 ;; to the latest values they had. These reflect the summary buffer
2291 ;; that was in action when the last article was fetched.
2292 (when (eq major-mode 'gnus-summary-mode)
2293 (setq gnus-summary-buffer (current-buffer))
2294 (let ((name gnus-newsgroup-name)
2295 (marked gnus-newsgroup-marked)
2296 (unread gnus-newsgroup-unreads)
2297 (headers gnus-current-headers)
2298 (data gnus-newsgroup-data)
2299 (summary gnus-summary-buffer)
2300 (article-buffer gnus-article-buffer)
2301 (original gnus-original-article-buffer)
2302 (gac gnus-article-current)
2303 (reffed gnus-reffed-article-number)
2304 (score-file gnus-current-score-file))
2306 (set-buffer gnus-group-buffer)
2307 (setq gnus-newsgroup-name name
2308 gnus-newsgroup-marked marked
2309 gnus-newsgroup-unreads unread
2310 gnus-current-headers headers
2311 gnus-newsgroup-data data
2312 gnus-article-current gac
2313 gnus-summary-buffer summary
2314 gnus-article-buffer article-buffer
2315 gnus-original-article-buffer original
2316 gnus-reffed-article-number reffed
2317 gnus-current-score-file score-file)
2318 ;; The article buffer also has local variables.
2319 (when (gnus-buffer-live-p gnus-article-buffer)
2320 (set-buffer gnus-article-buffer)
2321 (setq gnus-summary-buffer summary))))))
2323 (defun gnus-summary-article-unread-p (article)
2324 "Say whether ARTICLE is unread or not."
2325 (memq article gnus-newsgroup-unreads))
2327 (defun gnus-summary-first-article-p (&optional article)
2328 "Return whether ARTICLE is the first article in the buffer."
2329 (if (not (setq article (or article (gnus-summary-article-number))))
2331 (eq article (caar gnus-newsgroup-data))))
2333 (defun gnus-summary-last-article-p (&optional article)
2334 "Return whether ARTICLE is the last article in the buffer."
2335 (if (not (setq article (or article (gnus-summary-article-number))))
2336 t ; All non-existent numbers are the last article. :-)
2337 (not (cdr (gnus-data-find-list article)))))
2339 (defun gnus-make-thread-indent-array ()
2341 (unless (and gnus-thread-indent-array
2342 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2343 (setq gnus-thread-indent-array (make-vector 201 "")
2344 gnus-thread-indent-array-level gnus-thread-indent-level)
2346 (aset gnus-thread-indent-array n
2347 (make-string (* n gnus-thread-indent-level) ? ))
2350 (defun gnus-update-summary-mark-positions ()
2351 "Compute where the summary marks are to go."
2353 (when (gnus-buffer-exists-p gnus-summary-buffer)
2354 (set-buffer gnus-summary-buffer))
2355 (let ((gnus-replied-mark 129)
2356 (gnus-score-below-mark 130)
2357 (gnus-score-over-mark 130)
2358 (gnus-download-mark 131)
2359 (spec gnus-summary-line-format-spec)
2362 (gnus-set-work-buffer)
2363 (let ((gnus-summary-line-format-spec spec)
2364 (gnus-newsgroup-downloadable '((0 . t))))
2365 (gnus-summary-insert-line
2366 (make-full-mail-header 0 "" "" "" "" "" 0 0 "")
2367 0 nil 128 t nil "" nil 1)
2368 (goto-char (point-min))
2369 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2371 (goto-char (point-min))
2372 (push (cons 'replied (and (search-forward "\201" nil t)
2375 (goto-char (point-min))
2376 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2378 (goto-char (point-min))
2379 (push (cons 'download
2380 (and (search-forward "\203" nil t) (- (point) 2)))
2382 (setq gnus-summary-mark-positions pos))))
2384 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2385 "Insert a dummy root in the summary buffer."
2387 (gnus-add-text-properties
2388 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2389 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2391 (defun gnus-summary-insert-line (gnus-tmp-header
2392 gnus-tmp-level gnus-tmp-current
2393 gnus-tmp-unread gnus-tmp-replied
2394 gnus-tmp-expirable gnus-tmp-subject-or-nil
2395 &optional gnus-tmp-dummy gnus-tmp-score
2397 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2398 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2399 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2400 (gnus-tmp-score-char
2401 (if (or (null gnus-summary-default-score)
2402 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2403 gnus-summary-zcore-fuzz))
2405 (if (< gnus-tmp-score gnus-summary-default-score)
2406 gnus-score-below-mark gnus-score-over-mark)))
2408 (cond (gnus-tmp-process gnus-process-mark)
2409 ((memq gnus-tmp-current gnus-newsgroup-cached)
2411 (gnus-tmp-replied gnus-replied-mark)
2412 ((memq gnus-tmp-current gnus-newsgroup-saved)
2414 (t gnus-unread-mark)))
2415 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2418 ((string-match "<[^>]+> *$" gnus-tmp-from)
2419 (let ((beg (match-beginning 0)))
2420 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2421 (substring gnus-tmp-from (1+ (match-beginning 0))
2422 (1- (match-end 0))))
2423 (substring gnus-tmp-from 0 beg))))
2424 ((string-match "(.+)" gnus-tmp-from)
2425 (substring gnus-tmp-from
2426 (1+ (match-beginning 0)) (1- (match-end 0))))
2428 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2429 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2430 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2431 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2432 (buffer-read-only nil))
2433 (when (string= gnus-tmp-name "")
2434 (setq gnus-tmp-name gnus-tmp-from))
2435 (unless (numberp gnus-tmp-lines)
2436 (setq gnus-tmp-lines 0))
2437 (gnus-put-text-property-excluding-characters-with-faces
2439 (progn (eval gnus-summary-line-format-spec) (point))
2440 'gnus-number gnus-tmp-number)
2441 (when (gnus-visual-p 'summary-highlight 'highlight)
2443 (gnus-run-hooks 'gnus-summary-update-hook)
2446 (defun gnus-summary-update-line (&optional dont-update)
2447 ;; Update summary line after change.
2448 (when (and gnus-summary-default-score
2449 (not gnus-summary-inhibit-highlight))
2450 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2451 (article (gnus-summary-article-number))
2452 (score (gnus-summary-article-score article)))
2454 (if (and gnus-summary-mark-below
2455 (< (gnus-summary-article-score)
2456 gnus-summary-mark-below))
2457 ;; This article has a low score, so we mark it as read.
2458 (when (memq article gnus-newsgroup-unreads)
2459 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2460 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2461 ;; This article was previously marked as read on account
2462 ;; of a low score, but now it has risen, so we mark it as
2464 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2465 (gnus-summary-update-mark
2466 (if (or (null gnus-summary-default-score)
2467 (<= (abs (- score gnus-summary-default-score))
2468 gnus-summary-zcore-fuzz))
2470 (if (< score gnus-summary-default-score)
2471 gnus-score-below-mark gnus-score-over-mark))
2473 ;; Do visual highlighting.
2474 (when (gnus-visual-p 'summary-highlight 'highlight)
2475 (gnus-run-hooks 'gnus-summary-update-hook)))))
2477 (defvar gnus-tmp-new-adopts nil)
2479 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2480 "Return the number of articles in THREAD.
2481 This may be 0 in some cases -- if none of the articles in
2482 the thread are to be displayed."
2484 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2486 ((not (listp thread))
2488 ((and (consp thread) (cdr thread))
2491 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2494 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2497 (when (and level (zerop level) gnus-tmp-new-adopts)
2500 'gnus-summary-number-of-articles-in-thread
2501 gnus-tmp-new-adopts))))
2503 (if (> number 1) gnus-not-empty-thread-mark
2504 gnus-empty-thread-mark)
2507 (defun gnus-summary-set-local-parameters (group)
2508 "Go through the local params of GROUP and set all variable specs in that list."
2509 (let ((params (gnus-group-find-parameter group))
2512 (setq elem (car params)
2513 params (cdr params))
2514 (and (consp elem) ; Has to be a cons.
2515 (consp (cdr elem)) ; The cdr has to be a list.
2516 (symbolp (car elem)) ; Has to be a symbol in there.
2517 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2518 (ignore-errors ; So we set it.
2519 (make-local-variable (car elem))
2520 (set (car elem) (eval (nth 1 elem))))))))
2522 (defun gnus-summary-read-group (group &optional show-all no-article
2523 kill-buffer no-display backward
2525 "Start reading news in newsgroup GROUP.
2526 If SHOW-ALL is non-nil, already read articles are also listed.
2527 If NO-ARTICLE is non-nil, no article is selected initially.
2528 If NO-DISPLAY, don't generate a summary buffer."
2532 (let ((gnus-auto-select-next nil))
2533 (or (gnus-summary-read-group-1
2534 group show-all no-article
2535 kill-buffer no-display
2538 select-articles nil)))))
2539 (eq gnus-auto-select-next 'quietly))
2540 (set-buffer gnus-group-buffer)
2541 ;; The entry function called above goes to the next
2542 ;; group automatically, so we go two groups back
2543 ;; if we are searching for the previous group.
2545 (gnus-group-prev-unread-group 2))
2546 (if (not (equal group (gnus-group-group-name)))
2547 (setq group (gnus-group-group-name))
2551 (defun gnus-summary-read-group-1 (group show-all no-article
2552 kill-buffer no-display
2553 &optional select-articles)
2554 ;; Killed foreign groups can't be entered.
2555 (when (and (not (gnus-group-native-p group))
2556 (not (gnus-gethash group gnus-newsrc-hashtb)))
2557 (error "Dead non-native groups can't be entered"))
2558 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2559 (let* ((new-group (gnus-summary-setup-buffer group))
2560 (quit-config (gnus-group-quit-config group))
2561 (did-select (and new-group (gnus-select-newsgroup
2562 group show-all select-articles))))
2564 ;; This summary buffer exists already, so we just select it.
2566 (gnus-set-global-variables)
2568 (gnus-kill-or-deaden-summary kill-buffer))
2569 (gnus-configure-windows 'summary 'force)
2570 (gnus-set-mode-line 'summary)
2571 (gnus-summary-position-point)
2574 ;; We couldn't select this group.
2576 (when (and (eq major-mode 'gnus-summary-mode)
2577 (not (equal (current-buffer) kill-buffer)))
2578 (kill-buffer (current-buffer))
2579 (if (not quit-config)
2581 ;; Update the info -- marks might need to be removed,
2583 (gnus-summary-update-info)
2584 (set-buffer gnus-group-buffer)
2585 (gnus-group-jump-to-group group)
2586 (gnus-group-next-unread-group 1))
2587 (gnus-handle-ephemeral-exit quit-config)))
2588 (gnus-message 3 "Can't select group")
2590 ;; The user did a `C-g' while prompting for number of articles,
2591 ;; so we exit this group.
2592 ((eq did-select 'quit)
2593 (and (eq major-mode 'gnus-summary-mode)
2594 (not (equal (current-buffer) kill-buffer))
2595 (kill-buffer (current-buffer)))
2597 (gnus-kill-or-deaden-summary kill-buffer))
2598 (if (not quit-config)
2600 (set-buffer gnus-group-buffer)
2601 (gnus-group-jump-to-group group)
2602 (gnus-group-next-unread-group 1)
2603 (gnus-configure-windows 'group 'force))
2604 (gnus-handle-ephemeral-exit quit-config))
2605 ;; Finally signal the quit.
2607 ;; The group was successfully selected.
2609 (gnus-set-global-variables)
2610 ;; Save the active value in effect when the group was entered.
2611 (setq gnus-newsgroup-active
2613 (gnus-active gnus-newsgroup-name)))
2614 ;; You can change the summary buffer in some way with this hook.
2615 (gnus-run-hooks 'gnus-select-group-hook)
2616 ;; Set any local variables in the group parameters.
2617 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2618 (gnus-update-format-specifications
2619 nil 'summary 'summary-mode 'summary-dummy)
2620 ;; Do score processing.
2621 (when gnus-use-scoring
2622 (gnus-possibly-score-headers))
2623 ;; Check whether to fill in the gaps in the threads.
2624 (when gnus-build-sparse-threads
2625 (gnus-build-sparse-threads))
2626 ;; Find the initial limit.
2627 (if gnus-show-threads
2629 (let ((gnus-newsgroup-dormant nil))
2630 (gnus-summary-initial-limit show-all))
2631 (gnus-summary-initial-limit show-all))
2632 (setq gnus-newsgroup-limit
2634 (lambda (header) (mail-header-number header))
2635 gnus-newsgroup-headers)))
2636 ;; Generate the summary buffer.
2638 (gnus-summary-prepare))
2639 (when gnus-use-trees
2640 (gnus-tree-open group)
2641 (setq gnus-summary-highlight-line-function
2642 'gnus-tree-highlight-article))
2643 ;; If the summary buffer is empty, but there are some low-scored
2644 ;; articles or some excluded dormants, we include these in the
2646 (when (and (zerop (buffer-size))
2648 (cond (gnus-newsgroup-dormant
2649 (gnus-summary-limit-include-dormant))
2650 ((and gnus-newsgroup-scored show-all)
2651 (gnus-summary-limit-include-expunged t))))
2652 ;; Function `gnus-apply-kill-file' must be called in this hook.
2653 (gnus-run-hooks 'gnus-apply-kill-hook)
2654 (if (and (zerop (buffer-size))
2657 ;; This newsgroup is empty.
2658 (gnus-summary-catchup-and-exit nil t)
2659 (gnus-message 6 "No unread news")
2661 (gnus-kill-or-deaden-summary kill-buffer))
2662 ;; Return nil from this function.
2664 ;; Hide conversation thread subtrees. We cannot do this in
2665 ;; gnus-summary-prepare-hook since kill processing may not
2666 ;; work with hidden articles.
2667 (and gnus-show-threads
2668 gnus-thread-hide-subtree
2669 (gnus-summary-hide-all-threads))
2671 (gnus-kill-or-deaden-summary kill-buffer))
2672 ;; Show first unread article if requested.
2673 (if (and (not no-article)
2675 gnus-newsgroup-unreads
2676 gnus-auto-select-first)
2678 (gnus-configure-windows 'summary)
2680 ((eq gnus-auto-select-first 'best)
2681 (gnus-summary-best-unread-article))
2682 ((eq gnus-auto-select-first t)
2683 (gnus-summary-first-unread-article))
2684 ((gnus-functionp gnus-auto-select-first)
2685 (funcall gnus-auto-select-first))))
2686 ;; Don't select any articles, just move point to the first
2687 ;; article in the group.
2688 (goto-char (point-min))
2689 (gnus-summary-position-point)
2690 (gnus-configure-windows 'summary 'force)
2691 (gnus-set-mode-line 'summary))
2692 (when (get-buffer-window gnus-group-buffer t)
2693 ;; Gotta use windows, because recenter does weird stuff if
2694 ;; the current buffer ain't the displayed window.
2695 (let ((owin (selected-window)))
2696 (select-window (get-buffer-window gnus-group-buffer t))
2697 (when (gnus-group-goto-group group)
2699 (select-window owin)))
2700 ;; Mark this buffer as "prepared".
2701 (setq gnus-newsgroup-prepared t)
2702 (gnus-run-hooks 'gnus-summary-prepared-hook)
2705 (defun gnus-summary-prepare ()
2706 "Generate the summary buffer."
2708 (let ((buffer-read-only nil))
2710 (setq gnus-newsgroup-data nil
2711 gnus-newsgroup-data-reverse nil)
2712 (gnus-run-hooks 'gnus-summary-generate-hook)
2713 ;; Generate the buffer, either with threads or without.
2714 (when gnus-newsgroup-headers
2715 (gnus-summary-prepare-threads
2716 (if gnus-show-threads
2717 (gnus-sort-gathered-threads
2718 (funcall gnus-summary-thread-gathering-function
2720 (gnus-cut-threads (gnus-make-threads)))))
2721 ;; Unthreaded display.
2722 (gnus-sort-articles gnus-newsgroup-headers))))
2723 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2724 ;; Call hooks for modifying summary buffer.
2725 (goto-char (point-min))
2726 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2728 (defsubst gnus-general-simplify-subject (subject)
2729 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2732 ;; Truncate the subject.
2733 (gnus-simplify-subject-functions
2734 (gnus-map-function gnus-simplify-subject-functions subject))
2735 ((numberp gnus-summary-gather-subject-limit)
2736 (setq subject (gnus-simplify-subject-re subject))
2737 (if (> (length subject) gnus-summary-gather-subject-limit)
2738 (substring subject 0 gnus-summary-gather-subject-limit)
2740 ;; Fuzzily simplify it.
2741 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2742 (gnus-simplify-subject-fuzzy subject))
2743 ;; Just remove the leading "Re:".
2745 (gnus-simplify-subject-re subject))))
2747 (if (and gnus-summary-gather-exclude-subject
2748 (string-match gnus-summary-gather-exclude-subject subject))
2749 nil ; This article shouldn't be gathered
2752 (defun gnus-summary-simplify-subject-query ()
2753 "Query where the respool algorithm would put this article."
2755 (gnus-summary-select-article)
2756 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2758 (defun gnus-gather-threads-by-subject (threads)
2759 "Gather threads by looking at Subject headers."
2760 (if (not gnus-summary-make-false-root)
2762 (let ((hashtb (gnus-make-hashtable 1024))
2765 subject hthread whole-subject)
2767 (setq subject (gnus-general-simplify-subject
2768 (setq whole-subject (mail-header-subject
2771 (if (setq hthread (gnus-gethash subject hashtb))
2773 ;; We enter a dummy root into the thread, if we
2774 ;; haven't done that already.
2775 (unless (stringp (caar hthread))
2776 (setcar hthread (list whole-subject (car hthread))))
2777 ;; We add this new gathered thread to this gathered
2779 (setcdr (car hthread)
2780 (nconc (cdar hthread) (list (car threads))))
2781 ;; Remove it from the list of threads.
2782 (setcdr prev (cdr threads))
2783 (setq threads prev))
2784 ;; Enter this thread into the hash table.
2785 (gnus-sethash subject threads hashtb)))
2787 (setq threads (cdr threads)))
2790 (defun gnus-gather-threads-by-references (threads)
2791 "Gather threads by looking at References headers."
2792 (let ((idhashtb (gnus-make-hashtable 1024))
2793 (thhashtb (gnus-make-hashtable 1024))
2796 ids references id gthread gid entered ref)
2798 (when (setq references (mail-header-references (caar threads)))
2799 (setq id (mail-header-id (caar threads))
2800 ids (gnus-split-references references)
2802 (while (setq ref (pop ids))
2803 (setq ids (delete ref ids))
2804 (if (not (setq gid (gnus-gethash ref idhashtb)))
2806 (gnus-sethash ref id idhashtb)
2807 (gnus-sethash id threads thhashtb))
2808 (setq gthread (gnus-gethash gid thhashtb))
2810 ;; We enter a dummy root into the thread, if we
2811 ;; haven't done that already.
2812 (unless (stringp (caar gthread))
2813 (setcar gthread (list (mail-header-subject (caar gthread))
2815 ;; We add this new gathered thread to this gathered
2817 (setcdr (car gthread)
2818 (nconc (cdar gthread) (list (car threads)))))
2819 ;; Add it into the thread hash table.
2820 (gnus-sethash id gthread thhashtb)
2822 ;; Remove it from the list of threads.
2823 (setcdr prev (cdr threads))
2824 (setq threads prev))))
2826 (setq threads (cdr threads)))
2829 (defun gnus-sort-gathered-threads (threads)
2830 "Sort subtreads inside each gathered thread by article number."
2831 (let ((result threads))
2833 (when (stringp (caar threads))
2834 (setcdr (car threads)
2835 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2836 (setq threads (cdr threads)))
2839 (defun gnus-thread-loop-p (root thread)
2840 "Say whether ROOT is in THREAD."
2841 (let ((stack (list thread))
2844 (while (setq thread (pop stack))
2845 (setq th (cdr thread))
2847 (not (eq (caar th) root)))
2850 ;; We have found a loop.
2852 (setcdr thread (delq (car th) (cdr thread)))
2853 (if (boundp (setq ref-dep (intern "none"
2854 gnus-newsgroup-dependencies)))
2855 (setcdr (symbol-value ref-dep)
2856 (nconc (cdr (symbol-value ref-dep))
2858 (set ref-dep (list nil (car th))))
2861 ;; Push all the subthreads onto the stack.
2862 (push (cdr thread) stack)))
2865 (defun gnus-make-threads ()
2866 "Go through the dependency hashtb and find the roots. Return all threads."
2868 (while (catch 'infloop
2871 ;; Deal with self-referencing References loops.
2872 (when (and (car (symbol-value refs))
2879 (car (symbol-value refs)) thread))
2880 (cdr (symbol-value refs)))))))
2883 (unless (car (symbol-value refs))
2884 ;; These threads do not refer back to any other articles,
2885 ;; so they're roots.
2886 (setq threads (append (cdr (symbol-value refs)) threads))))
2887 gnus-newsgroup-dependencies)))
2890 ;; Build the thread tree.
2891 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2892 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2894 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2895 if it was already present.
2897 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2898 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2899 Message-IDs will be renamed be renamed to a unique Message-ID before
2902 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2903 (let* ((id (mail-header-id header))
2904 (id-dep (and id (intern id dependencies)))
2905 ref ref-dep ref-header)
2906 ;; Enter this `header' in the `dependencies' table.
2910 ;; The first two cases do the normal part: enter a new `header'
2911 ;; in the `dependencies' table.
2912 ((not (boundp id-dep))
2913 (set id-dep (list header)))
2914 ((null (car (symbol-value id-dep)))
2915 (setcar (symbol-value id-dep) header))
2917 ;; From here the `header' was already present in the
2918 ;; `dependencies' table.
2920 ;; Overrides an existing entry;
2921 ;; just set the header part of the entry.
2922 (setcar (symbol-value id-dep) header))
2924 ;; Renames the existing `header' to a unique Message-ID.
2925 ((not gnus-summary-ignore-duplicates)
2926 ;; An article with this Message-ID has already been seen.
2927 ;; We rename the Message-ID.
2928 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2930 (mail-header-set-id header id))
2932 ;; The last case ignores an existing entry, except it adds any
2933 ;; additional Xrefs (in case the two articles came from different
2935 ;; Also sets `header' to `nil' meaning that the `dependencies'
2936 ;; table was *not* modified.
2938 (mail-header-set-xref
2939 (car (symbol-value id-dep))
2940 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2942 (or (mail-header-xref header) "")))
2946 ;; First check if that we are not creating a References loop.
2947 (setq ref (gnus-parent-id (mail-header-references header)))
2949 (setq ref-dep (intern-soft ref dependencies))
2951 (setq ref-header (car (symbol-value ref-dep))))
2952 (if (string= id ref)
2953 ;; Yuk! This is a reference loop. Make the article be a
2956 (mail-header-set-references (car (symbol-value id-dep)) "none")
2958 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2959 (setq ref (gnus-parent-id (mail-header-references header)))
2960 (setq ref-dep (intern (or ref "none") dependencies))
2961 (if (boundp ref-dep)
2962 (setcdr (symbol-value ref-dep)
2963 (nconc (cdr (symbol-value ref-dep))
2964 (list (symbol-value id-dep))))
2965 (set ref-dep (list nil (symbol-value id-dep)))))
2968 (defun gnus-build-sparse-threads ()
2969 (let ((headers gnus-newsgroup-headers)
2970 (gnus-summary-ignore-duplicates t)
2971 header references generation relations
2972 subject child end new-child date)
2973 ;; First we create an alist of generations/relations, where
2974 ;; generations is how much we trust the relation, and the relation
2976 (gnus-message 7 "Making sparse threads...")
2978 (nnheader-set-temp-buffer " *gnus sparse threads*")
2979 (while (setq header (pop headers))
2980 (when (and (setq references (mail-header-references header))
2981 (not (string= references "")))
2983 (setq child (mail-header-id header)
2984 subject (mail-header-subject header)
2985 date (mail-header-date header)
2987 (while (search-backward ">" nil t)
2988 (setq end (1+ (point)))
2989 (when (search-backward "<" nil t)
2990 (setq new-child (buffer-substring (point) end))
2991 (push (list (incf generation)
2992 child (setq child new-child)
2996 (push (list (1+ generation) child nil subject) relations))
2998 (kill-buffer (current-buffer)))
2999 ;; Sort over trustworthiness.
3002 (when (gnus-dependencies-add-header
3003 (make-full-mail-header
3004 gnus-reffed-article-number
3005 (nth 3 relation) "" (or (nth 4 relation) "")
3007 (or (nth 2 relation) "") 0 0 "")
3008 gnus-newsgroup-dependencies nil)
3009 (push gnus-reffed-article-number gnus-newsgroup-limit)
3010 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3011 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3012 gnus-newsgroup-reads)
3013 (decf gnus-reffed-article-number)))
3014 (sort relations 'car-less-than-car))
3015 (gnus-message 7 "Making sparse threads...done")))
3017 (defun gnus-build-old-threads ()
3018 ;; Look at all the articles that refer back to old articles, and
3019 ;; fetch the headers for the articles that aren't there. This will
3020 ;; build complete threads - if the roots haven't been expired by the
3025 (when (not (car (symbol-value refs)))
3026 (setq heads (cdr (symbol-value refs)))
3028 (if (memq (mail-header-number (caar heads))
3029 gnus-newsgroup-dormant)
3030 (setq heads (cdr heads))
3031 (setq id (symbol-name refs))
3032 (while (and (setq id (gnus-build-get-header id))
3033 (not (car (gnus-id-to-thread id)))))
3034 (setq heads nil)))))
3035 gnus-newsgroup-dependencies)))
3037 ;; The following macros and functions were written by Felix Lee
3038 ;; <flee@cse.psu.edu>.
3040 (defmacro gnus-nov-read-integer ()
3042 (if (= (following-char) ?\t)
3044 (let ((num (ignore-errors (read buffer))))
3045 (if (numberp num) num 0)))
3047 (search-forward "\t" eol 'move))))
3049 (defmacro gnus-nov-skip-field ()
3050 '(search-forward "\t" eol 'move))
3052 (defmacro gnus-nov-field ()
3053 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3055 ;; This function has to be called with point after the article number
3056 ;; on the beginning of the line.
3057 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3058 (let ((eol (gnus-point-at-eol))
3059 (buffer (current-buffer))
3062 ;; overview: [num subject from date id refs chars lines misc]
3065 (narrow-to-region (point) eol)
3070 (make-full-mail-header
3072 (gnus-nov-field) ; subject
3073 (gnus-nov-field) ; from
3074 (gnus-nov-field) ; date
3075 (or (gnus-nov-field)
3076 (nnheader-generate-fake-message-id)) ; id
3077 (gnus-nov-field) ; refs
3078 (gnus-nov-read-integer) ; chars
3079 (gnus-nov-read-integer) ; lines
3080 (unless (= (following-char) ?\n)
3081 (gnus-nov-field))))) ; misc
3085 (when gnus-alter-header-function
3086 (funcall gnus-alter-header-function header))
3087 (gnus-dependencies-add-header header dependencies force-new)))
3089 (defun gnus-build-get-header (id)
3090 ;; Look through the buffer of NOV lines and find the header to
3091 ;; ID. Enter this line into the dependencies hash table, and return
3092 ;; the id of the parent article (if any).
3093 (let ((deps gnus-newsgroup-dependencies)
3097 (set-buffer nntp-server-buffer)
3098 (let ((case-fold-search nil))
3099 (goto-char (point-min))
3100 (while (and (not found)
3101 (search-forward id nil t))
3103 (setq found (looking-at
3104 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3105 (regexp-quote id))))
3106 (or found (beginning-of-line 2)))
3110 (setq header (gnus-nov-parse-line
3111 (read (current-buffer)) deps))
3112 (gnus-parent-id (mail-header-references header))))))
3114 (let ((number (mail-header-number header)))
3115 (push number gnus-newsgroup-limit)
3116 (push header gnus-newsgroup-headers)
3117 (if (memq number gnus-newsgroup-unselected)
3119 (push number gnus-newsgroup-unreads)
3120 (setq gnus-newsgroup-unselected
3121 (delq number gnus-newsgroup-unselected)))
3122 (push number gnus-newsgroup-ancient)))))))
3124 (defun gnus-build-all-threads ()
3125 "Read all the headers."
3126 (let ((gnus-summary-ignore-duplicates t)
3127 (dependencies gnus-newsgroup-dependencies)
3130 (set-buffer nntp-server-buffer)
3131 (let ((case-fold-search nil))
3132 (goto-char (point-min))
3135 (setq article (read (current-buffer))
3136 header (gnus-nov-parse-line
3137 article dependencies)))
3140 (set-buffer gnus-summary-buffer)
3141 (push header gnus-newsgroup-headers)
3142 (if (memq (setq article (mail-header-number header))
3143 gnus-newsgroup-unselected)
3145 (push article gnus-newsgroup-unreads)
3146 (setq gnus-newsgroup-unselected
3147 (delq article gnus-newsgroup-unselected)))
3148 (push article gnus-newsgroup-ancient)))
3149 (forward-line 1)))))))
3151 (defun gnus-summary-update-article-line (article header)
3152 "Update the line for ARTICLE using HEADERS."
3153 (let* ((id (mail-header-id header))
3154 (thread (gnus-id-to-thread id)))
3156 (error "Article in no thread"))
3157 ;; Update the thread.
3158 (setcar thread header)
3159 (gnus-summary-goto-subject article)
3160 (let* ((datal (gnus-data-find-list article))
3162 (length (when (cdr datal)
3163 (- (gnus-data-pos data)
3164 (gnus-data-pos (cadr datal)))))
3165 (buffer-read-only nil)
3166 (level (gnus-summary-thread-level)))
3168 (gnus-summary-insert-line
3169 header level nil (gnus-article-mark article)
3170 (memq article gnus-newsgroup-replied)
3171 (memq article gnus-newsgroup-expirable)
3172 ;; Only insert the Subject string when it's different
3173 ;; from the previous Subject string.
3174 (if (gnus-subject-equal
3176 (mail-header-subject
3179 (gnus-data-find-list
3181 (gnus-data-list t)))))
3182 ;; Error on the side of excessive subjects.
3184 (mail-header-subject header))
3186 (mail-header-subject header))
3187 nil (cdr (assq article gnus-newsgroup-scored))
3188 (memq article gnus-newsgroup-processable))
3190 (gnus-data-update-list
3191 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3193 (defun gnus-summary-update-article (article &optional iheader)
3194 "Update ARTICLE in the summary buffer."
3195 (set-buffer gnus-summary-buffer)
3196 (let* ((header (gnus-summary-article-header article))
3197 (id (mail-header-id header))
3198 (data (gnus-data-find article))
3199 (thread (gnus-id-to-thread id))
3200 (references (mail-header-references header))
3204 (when (and references
3205 (not (equal "" references)))
3208 (buffer-read-only nil)
3214 (delq thread parent)))
3215 (if (gnus-summary-insert-subject id header)
3216 ;; Set the (possibly) new article number in the data structure.
3217 (gnus-data-set-number data (gnus-id-to-article id))
3221 (defun gnus-rebuild-thread (id &optional line)
3222 "Rebuild the thread containing ID.
3223 If LINE, insert the rebuilt thread starting on line LINE."
3224 (let ((buffer-read-only nil)
3225 old-pos current thread data)
3226 (if (not gnus-show-threads)
3227 (setq thread (list (car (gnus-id-to-thread id))))
3228 ;; Get the thread this article is part of.
3229 (setq thread (gnus-remove-thread id)))
3230 (setq old-pos (gnus-point-at-bol))
3231 (setq current (save-excursion
3232 (and (zerop (forward-line -1))
3233 (gnus-summary-article-number))))
3234 ;; If this is a gathered thread, we have to go some re-gathering.
3235 (when (stringp (car thread))
3236 (let ((subject (car thread))
3238 (setq thread (cdr thread))
3240 (unless (memq (setq thr (gnus-id-to-thread
3242 (mail-header-id (caar thread)))))
3245 (setq thread (cdr thread)))
3246 ;; We now have all (unique) roots.
3247 (if (= (length roots) 1)
3248 ;; All the loose roots are now one solid root.
3249 (setq thread (car roots))
3250 (setq thread (cons subject (gnus-sort-threads roots))))))
3252 ;; We then insert this thread into the summary buffer.
3254 (goto-char (point-min))
3255 (forward-line (1- line)))
3256 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3257 (if gnus-show-threads
3258 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3259 (gnus-summary-prepare-unthreaded thread))
3260 (setq data (nreverse gnus-newsgroup-data))
3261 (setq threads gnus-newsgroup-threads))
3262 ;; We splice the new data into the data structure.
3263 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3264 ;;!!! then we want to insert at the beginning of the buffer.
3265 ;;!!! That happens to be true with Gnus now, but that may
3266 ;;!!! change in the future. Perhaps.
3267 (gnus-data-enter-list
3268 (if line nil current) data (- (point) old-pos))
3269 (setq gnus-newsgroup-threads
3270 (nconc threads gnus-newsgroup-threads))
3271 (gnus-data-compute-positions))))
3273 (defun gnus-number-to-header (number)
3274 "Return the header for article NUMBER."
3275 (let ((headers gnus-newsgroup-headers))
3277 (not (= number (mail-header-number (car headers)))))
3282 (defun gnus-parent-headers (in-headers &optional generation)
3283 "Return the headers of the GENERATIONeth parent of HEADERS."
3285 (setq generation 1))
3287 (headers in-headers)
3290 (not (zerop generation))
3291 (setq references (mail-header-references headers)))
3292 (setq headers (if (and references
3293 (setq parent (gnus-parent-id references)))
3294 (car (gnus-id-to-thread parent))
3297 (and (not (eq headers in-headers))
3300 (defun gnus-id-to-thread (id)
3301 "Return the (sub-)thread where ID appears."
3302 (gnus-gethash id gnus-newsgroup-dependencies))
3304 (defun gnus-id-to-article (id)
3305 "Return the article number of ID."
3306 (let ((thread (gnus-id-to-thread id)))
3309 (mail-header-number (car thread)))))
3311 (defun gnus-id-to-header (id)
3312 "Return the article headers of ID."
3313 (car (gnus-id-to-thread id)))
3315 (defun gnus-article-displayed-root-p (article)
3316 "Say whether ARTICLE is a root(ish) article."
3317 (let ((level (gnus-summary-thread-level article))
3318 (refs (mail-header-references (gnus-summary-article-header article)))
3324 ((null (gnus-parent-id refs)) t)
3326 (null (setq particle (gnus-id-to-article
3327 (gnus-parent-id refs))))
3328 (null (gnus-summary-thread-level particle)))))))
3330 (defun gnus-root-id (id)
3331 "Return the id of the root of the thread where ID appears."
3333 (while (and id (setq prev (car (gnus-id-to-thread id))))
3335 id (gnus-parent-id (mail-header-references prev))))
3338 (defun gnus-articles-in-thread (thread)
3339 "Return the list of articles in THREAD."
3340 (cons (mail-header-number (car thread))
3341 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3343 (defun gnus-remove-thread (id &optional dont-remove)
3344 "Remove the thread that has ID in it."
3345 (let (headers thread last-id)
3346 ;; First go up in this thread until we find the root.
3347 (setq last-id (gnus-root-id id)
3348 headers (message-flatten-list (gnus-id-to-thread last-id)))
3349 ;; We have now found the real root of this thread. It might have
3350 ;; been gathered into some loose thread, so we have to search
3351 ;; through the threads to find the thread we wanted.
3352 (let ((threads gnus-newsgroup-threads)
3355 (setq sub (car threads))
3356 (if (stringp (car sub))
3357 ;; This is a gathered thread, so we look at the roots
3358 ;; below it to find whether this article is in this
3361 (setq sub (cdr sub))
3363 (when (member (caar sub) headers)
3364 (setq thread (car threads)
3367 (setq sub (cdr sub))))
3368 ;; It's an ordinary thread, so we check it.
3369 (when (eq (car sub) (car headers))
3372 (setq threads (cdr threads)))
3373 ;; If this article is in no thread, then it's a root.
3376 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3377 (setq thread (gnus-id-to-thread last-id)))
3380 thread ; We return this thread.
3382 (if (stringp (car thread))
3384 ;; If we use dummy roots, then we have to remove the
3385 ;; dummy root as well.
3386 (when (eq gnus-summary-make-false-root 'dummy)
3387 ;; We go to the dummy root by going to
3388 ;; the first sub-"thread", and then one line up.
3389 (gnus-summary-goto-article
3390 (mail-header-number (caadr thread)))
3393 (gnus-data-compute-positions))
3394 (setq thread (cdr thread))
3396 (gnus-remove-thread-1 (car thread))
3397 (setq thread (cdr thread))))
3398 (gnus-summary-show-all-threads)
3399 (gnus-remove-thread-1 thread))))))))
3401 (defun gnus-remove-thread-1 (thread)
3402 "Remove the thread THREAD recursively."
3403 (let ((number (mail-header-number (pop thread)))
3405 (setq thread (reverse thread))
3407 (gnus-remove-thread-1 (pop thread)))
3408 (when (setq d (gnus-data-find number))
3409 (goto-char (gnus-data-pos d))
3412 (- (gnus-point-at-bol)
3414 (1+ (gnus-point-at-eol))
3415 (gnus-delete-line)))))))
3417 (defun gnus-sort-threads (threads)
3419 (if (not gnus-thread-sort-functions)
3421 (gnus-message 8 "Sorting threads...")
3423 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3424 (gnus-message 8 "Sorting threads...done"))))
3426 (defun gnus-sort-articles (articles)
3428 (when gnus-article-sort-functions
3429 (gnus-message 7 "Sorting articles...")
3431 (setq gnus-newsgroup-headers
3432 (sort articles (gnus-make-sort-function
3433 gnus-article-sort-functions)))
3434 (gnus-message 7 "Sorting articles...done"))))
3436 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3437 (defmacro gnus-thread-header (thread)
3438 ;; Return header of first article in THREAD.
3439 ;; Note that THREAD must never, ever be anything else than a variable -
3440 ;; using some other form will lead to serious barfage.
3441 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3442 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3443 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3446 (defsubst gnus-article-sort-by-number (h1 h2)
3447 "Sort articles by article number."
3448 (< (mail-header-number h1)
3449 (mail-header-number h2)))
3451 (defun gnus-thread-sort-by-number (h1 h2)
3452 "Sort threads by root article number."
3453 (gnus-article-sort-by-number
3454 (gnus-thread-header h1) (gnus-thread-header h2)))
3456 (defsubst gnus-article-sort-by-lines (h1 h2)
3457 "Sort articles by article Lines header."
3458 (< (mail-header-lines h1)
3459 (mail-header-lines h2)))
3461 (defun gnus-thread-sort-by-lines (h1 h2)
3462 "Sort threads by root article Lines header."
3463 (gnus-article-sort-by-lines
3464 (gnus-thread-header h1) (gnus-thread-header h2)))
3466 (defsubst gnus-article-sort-by-author (h1 h2)
3467 "Sort articles by root author."
3469 (let ((addr (mime-read-field 'From h1)))
3470 (or (std11-full-name-string addr)
3471 (std11-address-string addr)
3473 (let ((addr (mime-read-field 'From h2)))
3474 (or (std11-full-name-string addr)
3475 (std11-address-string addr)
3479 (defun gnus-thread-sort-by-author (h1 h2)
3480 "Sort threads by root author."
3481 (gnus-article-sort-by-author
3482 (gnus-thread-header h1) (gnus-thread-header h2)))
3484 (defsubst gnus-article-sort-by-subject (h1 h2)
3485 "Sort articles by root subject."
3487 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3488 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3490 (defun gnus-thread-sort-by-subject (h1 h2)
3491 "Sort threads by root subject."
3492 (gnus-article-sort-by-subject
3493 (gnus-thread-header h1) (gnus-thread-header h2)))
3495 (defsubst gnus-article-sort-by-date (h1 h2)
3496 "Sort articles by root article date."
3498 (gnus-date-get-time (mail-header-date h1))
3499 (gnus-date-get-time (mail-header-date h2))))
3501 (defun gnus-thread-sort-by-date (h1 h2)
3502 "Sort threads by root article date."
3503 (gnus-article-sort-by-date
3504 (gnus-thread-header h1) (gnus-thread-header h2)))
3506 (defsubst gnus-article-sort-by-score (h1 h2)
3507 "Sort articles by root article score.
3508 Unscored articles will be counted as having a score of zero."
3509 (> (or (cdr (assq (mail-header-number h1)
3510 gnus-newsgroup-scored))
3511 gnus-summary-default-score 0)
3512 (or (cdr (assq (mail-header-number h2)
3513 gnus-newsgroup-scored))
3514 gnus-summary-default-score 0)))
3516 (defun gnus-thread-sort-by-score (h1 h2)
3517 "Sort threads by root article score."
3518 (gnus-article-sort-by-score
3519 (gnus-thread-header h1) (gnus-thread-header h2)))
3521 (defun gnus-thread-sort-by-total-score (h1 h2)
3522 "Sort threads by the sum of all scores in the thread.
3523 Unscored articles will be counted as having a score of zero."
3524 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3526 (defun gnus-thread-total-score (thread)
3527 ;; This function find the total score of THREAD.
3528 (cond ((null thread)
3531 (if (stringp (car thread))
3532 (apply gnus-thread-score-function 0
3533 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3534 (gnus-thread-total-score-1 thread)))
3536 (gnus-thread-total-score-1 (list thread)))))
3538 (defun gnus-thread-total-score-1 (root)
3539 ;; This function find the total score of the thread below ROOT.
3540 (setq root (car root))
3541 (apply gnus-thread-score-function
3543 (mapcar 'gnus-thread-total-score
3544 (cdr (gnus-id-to-thread (mail-header-id root))))
3545 (when (> (mail-header-number root) 0)
3546 (list (or (cdr (assq (mail-header-number root)
3547 gnus-newsgroup-scored))
3548 gnus-summary-default-score 0))))
3549 (list gnus-summary-default-score)
3552 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3553 (defvar gnus-tmp-prev-subject nil)
3554 (defvar gnus-tmp-false-parent nil)
3555 (defvar gnus-tmp-root-expunged nil)
3556 (defvar gnus-tmp-dummy-line nil)
3558 (defun gnus-summary-prepare-threads (threads)
3559 "Prepare summary buffer from THREADS and indentation LEVEL.
3560 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3561 or a straight list of headers."
3562 (gnus-message 7 "Generating summary...")
3564 (setq gnus-newsgroup-threads threads)
3567 (let ((gnus-tmp-level 0)
3568 (default-score (or gnus-summary-default-score 0))
3569 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3570 thread number subject stack state gnus-tmp-gathered beg-match
3571 new-roots gnus-tmp-new-adopts thread-end
3572 gnus-tmp-header gnus-tmp-unread
3573 gnus-tmp-replied gnus-tmp-subject-or-nil
3574 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3575 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3576 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3578 (setq gnus-tmp-prev-subject nil)
3580 (if (vectorp (car threads))
3581 ;; If this is a straight (sic) list of headers, then a
3582 ;; threaded summary display isn't required, so we just create
3583 ;; an unthreaded one.
3584 (gnus-summary-prepare-unthreaded threads)
3586 ;; Do the threaded display.
3588 (while (or threads stack gnus-tmp-new-adopts new-roots)
3590 (if (and (= gnus-tmp-level 0)
3593 (not gnus-tmp-false-parent)
3594 (or gnus-tmp-new-adopts new-roots))
3595 (if gnus-tmp-new-adopts
3596 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3597 thread (list (car gnus-tmp-new-adopts))
3598 gnus-tmp-header (caar thread)
3599 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3601 (setq thread (list (car new-roots))
3602 gnus-tmp-header (caar thread)
3603 new-roots (cdr new-roots))))
3606 ;; If there are some threads, we do them before the
3607 ;; threads on the stack.
3608 (setq thread threads
3609 gnus-tmp-header (caar thread))
3610 ;; There were no current threads, so we pop something off
3612 (setq state (car stack)
3613 gnus-tmp-level (car state)
3616 gnus-tmp-header (caar thread))))
3618 (setq gnus-tmp-false-parent nil)
3619 (setq gnus-tmp-root-expunged nil)
3620 (setq thread-end nil)
3622 (if (stringp gnus-tmp-header)
3623 ;; The header is a dummy root.
3625 ((eq gnus-summary-make-false-root 'adopt)
3626 ;; We let the first article adopt the rest.
3627 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3629 (setq gnus-tmp-gathered
3631 (lambda (h) (mail-header-number (car h)))
3634 (setq thread (cons (list (caar thread)
3637 (setq gnus-tmp-level -1
3638 gnus-tmp-false-parent t))
3639 ((eq gnus-summary-make-false-root 'empty)
3640 ;; We print adopted articles with empty subject fields.
3641 (setq gnus-tmp-gathered
3643 (lambda (h) (mail-header-number (car h)))
3646 (setq gnus-tmp-level -1))
3647 ((eq gnus-summary-make-false-root 'dummy)
3648 ;; We remember that we probably want to output a dummy
3650 (setq gnus-tmp-dummy-line gnus-tmp-header)
3651 (setq gnus-tmp-prev-subject gnus-tmp-header))
3653 ;; We do not make a root for the gathered
3654 ;; sub-threads at all.
3655 (setq gnus-tmp-level -1)))
3657 (setq number (mail-header-number gnus-tmp-header)
3658 subject (mail-header-subject gnus-tmp-header))
3661 ;; If the thread has changed subject, we might want to make
3662 ;; this subthread into a root.
3663 ((and (null gnus-thread-ignore-subject)
3664 (not (zerop gnus-tmp-level))
3665 gnus-tmp-prev-subject
3667 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3668 (setq new-roots (nconc new-roots (list (car thread)))
3670 gnus-tmp-header nil))
3671 ;; If the article lies outside the current limit,
3672 ;; then we do not display it.
3673 ((not (memq number gnus-newsgroup-limit))
3674 (setq gnus-tmp-gathered
3676 (lambda (h) (mail-header-number (car h)))
3679 (setq gnus-tmp-new-adopts (if (cdar thread)
3680 (append gnus-tmp-new-adopts
3682 gnus-tmp-new-adopts)
3684 gnus-tmp-header nil)
3685 (when (zerop gnus-tmp-level)
3686 (setq gnus-tmp-root-expunged t)))
3687 ;; Perhaps this article is to be marked as read?
3688 ((and gnus-summary-mark-below
3689 (< (or (cdr (assq number gnus-newsgroup-scored))
3691 gnus-summary-mark-below)
3692 ;; Don't touch sparse articles.
3693 (not (gnus-summary-article-sparse-p number))
3694 (not (gnus-summary-article-ancient-p number)))
3695 (setq gnus-newsgroup-unreads
3696 (delq number gnus-newsgroup-unreads))
3697 (if gnus-newsgroup-auto-expire
3698 (push number gnus-newsgroup-expirable)
3699 (push (cons number gnus-low-score-mark)
3700 gnus-newsgroup-reads))))
3702 (when gnus-tmp-header
3703 ;; We may have an old dummy line to output before this
3705 (when (and gnus-tmp-dummy-line
3708 (mail-header-subject gnus-tmp-header)))
3709 (gnus-summary-insert-dummy-line
3710 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3711 (setq gnus-tmp-dummy-line nil))
3713 ;; Compute the mark.
3714 (setq gnus-tmp-unread (gnus-article-mark number))
3716 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3717 gnus-tmp-header gnus-tmp-level)
3718 gnus-newsgroup-data)
3720 ;; Actually insert the line.
3722 gnus-tmp-subject-or-nil
3724 ((and gnus-thread-ignore-subject
3725 gnus-tmp-prev-subject
3726 (not (inline (gnus-subject-equal
3727 gnus-tmp-prev-subject subject))))
3729 ((zerop gnus-tmp-level)
3730 (if (and (eq gnus-summary-make-false-root 'empty)
3731 (memq number gnus-tmp-gathered)
3732 gnus-tmp-prev-subject
3733 (inline (gnus-subject-equal
3734 gnus-tmp-prev-subject subject)))
3735 gnus-summary-same-subject
3737 (t gnus-summary-same-subject)))
3738 (if (and (eq gnus-summary-make-false-root 'adopt)
3739 (= gnus-tmp-level 1)
3740 (memq number gnus-tmp-gathered))
3741 (setq gnus-tmp-opening-bracket ?\<
3742 gnus-tmp-closing-bracket ?\>)
3743 (setq gnus-tmp-opening-bracket ?\[
3744 gnus-tmp-closing-bracket ?\]))
3746 gnus-tmp-indentation
3747 (aref gnus-thread-indent-array gnus-tmp-level)
3748 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3749 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3750 gnus-summary-default-score 0)
3752 (if (or (null gnus-summary-default-score)
3753 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3754 gnus-summary-zcore-fuzz))
3756 (if (< gnus-tmp-score gnus-summary-default-score)
3757 gnus-score-below-mark gnus-score-over-mark))
3759 (cond ((memq number gnus-newsgroup-processable)
3761 ((memq number gnus-newsgroup-cached)
3763 ((memq number gnus-newsgroup-replied)
3765 ((memq number gnus-newsgroup-saved)
3767 (t gnus-unread-mark))
3768 gnus-tmp-from (mail-header-from gnus-tmp-header)
3771 ((string-match "<[^>]+> *$" gnus-tmp-from)
3772 (setq beg-match (match-beginning 0))
3773 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3774 (substring gnus-tmp-from (1+ (match-beginning 0))
3775 (1- (match-end 0))))
3776 (substring gnus-tmp-from 0 beg-match)))
3777 ((string-match "(.+)" gnus-tmp-from)
3778 (substring gnus-tmp-from
3779 (1+ (match-beginning 0)) (1- (match-end 0))))
3781 (when (string= gnus-tmp-name "")
3782 (setq gnus-tmp-name gnus-tmp-from))
3783 (unless (numberp gnus-tmp-lines)
3784 (setq gnus-tmp-lines 0))
3785 (gnus-put-text-property
3787 (progn (eval gnus-summary-line-format-spec) (point))
3788 'gnus-number number)
3791 (gnus-run-hooks 'gnus-summary-update-hook)
3794 (setq gnus-tmp-prev-subject subject)))
3796 (when (nth 1 thread)
3797 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3798 (incf gnus-tmp-level)
3799 (setq threads (if thread-end nil (cdar thread)))
3801 (setq gnus-tmp-level 0)))))
3802 (gnus-message 7 "Generating summary...done"))
3804 (defun gnus-summary-prepare-unthreaded (headers)
3805 "Generate an unthreaded summary buffer based on HEADERS."
3806 (let (header number mark)
3811 ;; We may have to root out some bad articles...
3812 (when (memq (setq number (mail-header-number
3813 (setq header (pop headers))))
3814 gnus-newsgroup-limit)
3815 ;; Mark article as read when it has a low score.
3816 (when (and gnus-summary-mark-below
3817 (< (or (cdr (assq number gnus-newsgroup-scored))
3818 gnus-summary-default-score 0)
3819 gnus-summary-mark-below)
3820 (not (gnus-summary-article-ancient-p number)))
3821 (setq gnus-newsgroup-unreads
3822 (delq number gnus-newsgroup-unreads))
3823 (if gnus-newsgroup-auto-expire
3824 (push number gnus-newsgroup-expirable)
3825 (push (cons number gnus-low-score-mark)
3826 gnus-newsgroup-reads)))
3828 (setq mark (gnus-article-mark number))
3829 (push (gnus-data-make number mark (1+ (point)) header 0)
3830 gnus-newsgroup-data)
3831 (gnus-summary-insert-line
3833 mark (memq number gnus-newsgroup-replied)
3834 (memq number gnus-newsgroup-expirable)
3835 (mail-header-subject header) nil
3836 (cdr (assq number gnus-newsgroup-scored))
3837 (memq number gnus-newsgroup-processable))))))
3839 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3840 "Select newsgroup GROUP.
3841 If READ-ALL is non-nil, all articles in the group are selected.
3842 If SELECT-ARTICLES, only select those articles from GROUP."
3843 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3844 ;;!!! Dirty hack; should be removed.
3845 (gnus-summary-ignore-duplicates
3846 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3848 gnus-summary-ignore-duplicates))
3849 (info (nth 2 entry))
3850 articles fetched-articles cached)
3852 (unless (gnus-check-server
3853 (setq gnus-current-select-method
3854 (gnus-find-method-for-group group)))
3855 (error "Couldn't open server"))
3857 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3858 (gnus-activate-group group) ; Or we can activate it...
3859 (progn ; Or we bug out.
3860 (when (equal major-mode 'gnus-summary-mode)
3861 (kill-buffer (current-buffer)))
3862 (error "Couldn't request group %s: %s"
3863 group (gnus-status-message group))))
3865 (unless (gnus-request-group group t)
3866 (when (equal major-mode 'gnus-summary-mode)
3867 (kill-buffer (current-buffer)))
3868 (error "Couldn't request group %s: %s"
3869 group (gnus-status-message group)))
3871 (setq gnus-newsgroup-name group)
3872 (setq gnus-newsgroup-unselected nil)
3873 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3875 ;; Adjust and set lists of article marks.
3877 (gnus-adjust-marked-articles info))
3879 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3880 (when (gnus-virtual-group-p group)
3881 (setq cached gnus-newsgroup-cached))
3883 (setq gnus-newsgroup-unreads
3884 (gnus-set-difference
3885 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3886 gnus-newsgroup-dormant))
3888 (setq gnus-newsgroup-processable nil)
3890 (gnus-update-read-articles group gnus-newsgroup-unreads)
3892 (if (setq articles select-articles)
3893 (setq gnus-newsgroup-unselected
3894 (gnus-sorted-intersection
3895 gnus-newsgroup-unreads
3896 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3897 (setq articles (gnus-articles-to-read group read-all)))
3901 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3903 ((eq articles 0) nil)
3905 ;; Init the dependencies hash table.
3906 (setq gnus-newsgroup-dependencies
3907 (gnus-make-hashtable (length articles)))
3908 (gnus-set-global-variables)
3909 ;; Retrieve the headers and read them in.
3910 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3911 (setq gnus-newsgroup-headers
3913 (setq gnus-headers-retrieved-by
3914 (gnus-retrieve-headers
3915 articles gnus-newsgroup-name
3916 ;; We might want to fetch old headers, but
3917 ;; not if there is only 1 article.
3919 (not (eq gnus-fetch-old-headers 'some))
3920 (not (numberp gnus-fetch-old-headers)))
3921 (> (length articles) 1))
3922 gnus-fetch-old-headers))))
3923 (gnus-get-newsgroup-headers-xover
3924 articles nil nil gnus-newsgroup-name t)
3925 (gnus-get-newsgroup-headers)))
3926 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3928 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3930 (setq gnus-newsgroup-cached cached))
3932 ;; Suppress duplicates?
3933 (when gnus-suppress-duplicates
3934 (gnus-dup-suppress-articles))
3936 ;; Set the initial limit.
3937 (setq gnus-newsgroup-limit (copy-sequence articles))
3938 ;; Remove canceled articles from the list of unread articles.
3939 (setq gnus-newsgroup-unreads
3940 (gnus-set-sorted-intersection
3941 gnus-newsgroup-unreads
3942 (setq fetched-articles
3943 (mapcar (lambda (headers) (mail-header-number headers))
3944 gnus-newsgroup-headers))))
3945 ;; Removed marked articles that do not exist.
3946 (gnus-update-missing-marks
3947 (gnus-sorted-complement fetched-articles articles))
3948 ;; We might want to build some more threads first.
3949 (when (and gnus-fetch-old-headers
3950 (eq gnus-headers-retrieved-by 'nov))
3951 (if (eq gnus-fetch-old-headers 'invisible)
3952 (gnus-build-all-threads)
3953 (gnus-build-old-threads)))
3954 ;; Let the Gnus agent mark articles as read.
3956 (gnus-agent-get-undownloaded-list))
3957 ;; Check whether auto-expire is to be done in this group.
3958 (setq gnus-newsgroup-auto-expire
3959 (gnus-group-auto-expirable-p group))
3960 ;; Set up the article buffer now, if necessary.
3961 (unless gnus-single-article-buffer
3962 (gnus-article-setup-buffer))
3963 ;; First and last article in this newsgroup.
3964 (when gnus-newsgroup-headers
3965 (setq gnus-newsgroup-begin
3966 (mail-header-number (car gnus-newsgroup-headers))
3969 (gnus-last-element gnus-newsgroup-headers))))
3970 ;; GROUP is successfully selected.
3971 (or gnus-newsgroup-headers t)))))
3973 (defun gnus-articles-to-read (group &optional read-all)
3974 ;; Find out what articles the user wants to read.
3976 ;; Select all articles if `read-all' is non-nil, or if there
3977 ;; are no unread articles.
3979 (and (zerop (length gnus-newsgroup-marked))
3980 (zerop (length gnus-newsgroup-unreads)))
3981 (eq (gnus-group-find-parameter group 'display)
3983 (gnus-uncompress-range (gnus-active group))
3984 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3985 (copy-sequence gnus-newsgroup-unreads))
3987 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3988 (scored (length scored-list))
3989 (number (length articles))
3990 (marked (+ (length gnus-newsgroup-marked)
3991 (length gnus-newsgroup-dormant)))
3999 ((and (or (<= scored marked) (= scored number))
4000 (numberp gnus-large-newsgroup)
4001 (> number gnus-large-newsgroup))
4005 "How many articles from %s (default %d): "
4006 (gnus-limit-string gnus-newsgroup-name 35)
4008 (if (string-match "^[ \t]*$" input) number input)))
4009 ((and (> scored marked) (< scored number)
4010 (> (- scored number) 20))
4013 (format "%s %s (%d scored, %d total): "
4014 "How many articles from"
4015 group scored number))))
4016 (if (string-match "^[ \t]*$" input)
4020 (setq select (if (stringp select) (string-to-number select) select))
4021 (if (or (null select) (zerop select))
4023 (if (and (not (zerop scored)) (<= (abs select) scored))
4025 (setq articles (sort scored-list '<))
4026 (setq number (length articles)))
4027 (setq articles (copy-sequence articles)))
4029 (when (< (abs select) number)
4031 ;; Select the N oldest articles.
4032 (setcdr (nthcdr (1- (abs select)) articles) nil)
4033 ;; Select the N most recent articles.
4034 (setq articles (nthcdr (- number select) articles))))
4035 (setq gnus-newsgroup-unselected
4036 (gnus-sorted-intersection
4037 gnus-newsgroup-unreads
4038 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4041 (defun gnus-killed-articles (killed articles)
4044 (when (inline (gnus-member-of-range (car articles) killed))
4045 (push (car articles) out))
4046 (setq articles (cdr articles)))
4049 (defun gnus-uncompress-marks (marks)
4050 "Uncompress the mark ranges in MARKS."
4051 (let ((uncompressed '(score bookmark))
4054 (if (memq (caar marks) uncompressed)
4055 (push (car marks) out)
4056 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4057 (setq marks (cdr marks)))
4060 (defun gnus-adjust-marked-articles (info)
4061 "Set all article lists and remove all marks that are no longer legal."
4062 (let* ((marked-lists (gnus-info-marks info))
4063 (active (gnus-active (gnus-info-group info)))
4066 (types gnus-article-mark-lists)
4067 (uncompressed '(score bookmark killed))
4068 marks var articles article mark)
4071 (setq marks (pop marked-lists))
4072 (set (setq var (intern (format "gnus-newsgroup-%s"
4073 (car (rassq (setq mark (car marks))
4075 (if (memq (car marks) uncompressed) (cdr marks)
4076 (gnus-uncompress-range (cdr marks))))
4078 (setq articles (symbol-value var))
4080 ;; All articles have to be subsets of the active articles.
4082 ;; Adjust "simple" lists.
4083 ((memq mark '(tick dormant expire reply save))
4085 (when (or (< (setq article (pop articles)) min) (> article max))
4086 (set var (delq article (symbol-value var))))))
4088 ((memq mark uncompressed)
4089 (when (not (listp (cdr (symbol-value var))))
4090 (set var (list (symbol-value var))))
4091 (when (not (listp (cdr articles)))
4092 (setq articles (list articles)))
4094 (when (or (not (consp (setq article (pop articles))))
4095 (< (car article) min)
4096 (> (car article) max))
4097 (set var (delq article (symbol-value var))))))))))
4099 (defun gnus-update-missing-marks (missing)
4100 "Go through the list of MISSING articles and remove them from the mark lists."
4102 (let ((types gnus-article-mark-lists)
4104 ;; Go through all types.
4106 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4107 (when (symbol-value var)
4108 ;; This list has articles. So we delete all missing articles
4112 (set var (delq (pop m) (symbol-value var)))))))))
4114 (defun gnus-update-marks ()
4115 "Enter the various lists of marked articles into the newsgroup info list."
4116 (let ((types gnus-article-mark-lists)
4117 (info (gnus-get-info gnus-newsgroup-name))
4118 (uncompressed '(score bookmark killed))
4119 type list newmarked symbol delta-marks)
4121 ;; Add all marks lists that are non-nil to the list of marks lists.
4122 (while (setq type (pop types))
4123 (when (setq list (symbol-value
4125 (intern (format "gnus-newsgroup-%s"
4128 ;; Get rid of the entries of the articles that have the
4130 (when (and (eq (cdr type) 'score)
4134 (prev (cons nil list))
4137 (if (or (not (consp (car arts)))
4138 (= (cdar arts) gnus-summary-default-score))
4139 (setcdr prev (cdr arts))
4141 (setq arts (cdr arts)))
4142 (setq list (cdr all))))
4144 (push (cons (cdr type)
4145 (if (memq (cdr type) uncompressed) list
4146 (gnus-compress-sequence
4147 (set symbol (sort list '<)) t)))
4150 ;; Enter these new marks into the info of the group.
4152 (setcar (nthcdr 3 info) newmarked)
4153 ;; Add the marks lists to the end of the info.
4155 (setcdr (nthcdr 2 info) (list newmarked))))
4157 ;; Cut off the end of the info if there's nothing else there.
4161 (when (nthcdr (decf i) info)
4162 (setcdr (nthcdr i info) nil)))))))
4164 (defun gnus-set-mode-line (where)
4165 "This function sets the mode line of the article or summary buffers.
4166 If WHERE is `summary', the summary mode line format will be used."
4167 ;; Is this mode line one we keep updated?
4168 (when (memq where gnus-updated-mode-lines)
4171 ;; We evaluate this in the summary buffer since these
4172 ;; variables are buffer-local to that buffer.
4173 (set-buffer gnus-summary-buffer)
4174 ;; We bind all these variables that are used in the `eval' form
4176 (let* ((mformat (symbol-value
4178 (format "gnus-%s-mode-line-format-spec" where))))
4179 (gnus-tmp-group-name gnus-newsgroup-name)
4180 (gnus-tmp-article-number (or gnus-current-article 0))
4181 (gnus-tmp-unread gnus-newsgroup-unreads)
4182 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4183 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4184 (gnus-tmp-unread-and-unselected
4185 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4186 (zerop gnus-tmp-unselected))
4188 ((zerop gnus-tmp-unselected)
4189 (format "{%d more}" gnus-tmp-unread-and-unticked))
4190 (t (format "{%d(+%d) more}"
4191 gnus-tmp-unread-and-unticked
4192 gnus-tmp-unselected))))
4194 (if (and gnus-current-headers
4195 (vectorp gnus-current-headers))
4196 (gnus-mode-string-quote
4197 (mail-header-subject gnus-current-headers))
4199 bufname-length max-len
4200 gnus-tmp-header);; passed as argument to any user-format-funcs
4201 (setq mode-string (eval mformat))
4202 (setq bufname-length (if (string-match "%b" mode-string)
4205 (if (eq where 'summary)
4207 (get-buffer gnus-article-buffer))))
4210 (setq max-len (max 4 (if gnus-mode-non-string-length
4212 gnus-mode-non-string-length
4214 (length mode-string))))
4215 ;; We might have to chop a bit of the string off...
4216 (when (> (length mode-string) max-len)
4218 (concat (gnus-truncate-string mode-string (- max-len 3))
4220 ;; Pad the mode string a bit.
4221 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4222 ;; Update the mode line.
4223 (setq mode-line-buffer-identification
4224 (gnus-mode-line-buffer-identification (list mode-string)))
4225 (set-buffer-modified-p t))))
4227 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4228 "Go through the HEADERS list and add all Xrefs to a hash table.
4229 The resulting hash table is returned, or nil if no Xrefs were found."
4230 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4231 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4232 (xref-hashtb (gnus-make-hashtable))
4233 start group entry number xrefs header)
4235 (setq header (pop headers))
4236 (when (and (setq xrefs (mail-header-xref header))
4237 (not (memq (setq number (mail-header-number header))
4240 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4241 (setq start (match-end 0))
4242 (setq group (if prefix
4243 (concat prefix (substring xrefs (match-beginning 1)
4245 (substring xrefs (match-beginning 1) (match-end 1))))
4247 (string-to-int (substring xrefs (match-beginning 2)
4249 (if (setq entry (gnus-gethash group xref-hashtb))
4250 (setcdr entry (cons number (cdr entry)))
4251 (gnus-sethash group (cons number nil) xref-hashtb)))))
4252 (and start xref-hashtb)))
4254 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4255 "Look through all the headers and mark the Xrefs as read."
4256 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4257 name entry info xref-hashtb idlist method nth4)
4259 (set-buffer gnus-group-buffer)
4260 (when (setq xref-hashtb
4261 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4264 (unless (string= from-newsgroup (setq name (symbol-name group)))
4265 (setq idlist (symbol-value group))
4266 ;; Dead groups are not updated.
4268 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4270 (when (stringp (setq nth4 (gnus-info-method info)))
4271 (setq nth4 (gnus-server-to-method nth4))))
4272 ;; Only do the xrefs if the group has the same
4273 ;; select method as the group we have just read.
4274 (or (gnus-methods-equal-p
4275 nth4 (gnus-find-method-for-group from-newsgroup))
4277 (equal nth4 (setq method (gnus-find-method-for-group
4279 (and (equal (car nth4) (car method))
4280 (equal (nth 1 nth4) (nth 1 method))))
4281 gnus-use-cross-reference
4282 (or (not (eq gnus-use-cross-reference t))
4284 ;; Only do cross-references on subscribed
4285 ;; groups, if that is what is wanted.
4286 (<= (gnus-info-level info) gnus-level-subscribed))
4287 (gnus-group-make-articles-read name idlist))))
4290 (defun gnus-compute-read-articles (group articles)
4291 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4292 (info (nth 2 entry))
4293 (active (gnus-active group))
4296 ;; First peel off all illegal article numbers.
4298 (let ((ids articles)
4300 (while (setq id (pop ids))
4301 (when (and first (> id (cdr active)))
4302 ;; We'll end up in this situation in one particular
4303 ;; obscure situation. If you re-scan a group and get
4304 ;; a new article that is cross-posted to a different
4305 ;; group that has not been re-scanned, you might get
4306 ;; crossposted article that has a higher number than
4307 ;; Gnus believes possible. So we re-activate this
4308 ;; group as well. This might mean doing the
4309 ;; crossposting thingy will *increase* the number
4310 ;; of articles in some groups. Tsk, tsk.
4311 (setq active (or (gnus-activate-group group) active)))
4312 (when (or (> id (cdr active))
4313 (< id (car active)))
4314 (setq articles (delq id articles))))))
4315 ;; If the read list is nil, we init it.
4317 (null (gnus-info-read info))
4319 (setq ninfo (cons 1 (1- (car active))))
4320 (setq ninfo (gnus-info-read info)))
4321 ;; Then we add the read articles to the range.
4323 ninfo (setq articles (sort articles '<))))))
4325 (defun gnus-group-make-articles-read (group articles)
4326 "Update the info of GROUP to say that ARTICLES are read."
4328 (entry (gnus-gethash group gnus-newsrc-hashtb))
4329 (info (nth 2 entry))
4330 (active (gnus-active group))
4333 (setq range (gnus-compute-read-articles group articles))
4335 (set-buffer gnus-group-buffer)
4338 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4339 (gnus-info-set-read ',info ',(gnus-info-read info))
4340 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4341 (gnus-group-update-group ,group t))))
4342 ;; Add the read articles to the range.
4343 (gnus-info-set-read info range)
4344 ;; Then we have to re-compute how many unread
4345 ;; articles there are in this group.
4349 (setq num (- (1+ (cdr active)) (car active))))
4350 ((not (listp (cdr range)))
4351 (setq num (- (cdr active) (- (1+ (cdr range))
4355 (if (numberp (car range))
4357 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4358 (setq range (cdr range)))
4359 (setq num (- (cdr active) num))))
4360 ;; Update the number of unread articles.
4362 ;; Update the group buffer.
4363 (gnus-group-update-group group t)))))
4365 (defun gnus-methods-equal-p (m1 m2)
4366 (let ((m1 (or m1 gnus-select-method))
4367 (m2 (or m2 gnus-select-method)))
4369 (and (eq (car m1) (car m2))
4370 (or (not (memq 'address (assoc (symbol-name (car m1))
4371 gnus-valid-select-methods)))
4372 (equal (nth 1 m1) (nth 1 m2)))))))
4374 (defvar gnus-newsgroup-none-id 0)
4376 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4377 (let ((cur nntp-server-buffer)
4380 (save-excursion (set-buffer gnus-summary-buffer)
4381 gnus-newsgroup-dependencies)))
4384 (set-buffer nntp-server-buffer)
4385 ;; Translate all TAB characters into SPACE characters.
4386 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4387 (gnus-run-hooks 'gnus-parse-headers-hook)
4388 (let ((case-fold-search t)
4389 in-reply-to header p lines chars ctype)
4390 (goto-char (point-min))
4391 ;; Search to the beginning of the next header. Error messages
4392 ;; do not begin with 2 or 3.
4393 (while (re-search-forward "^[23][0-9]+ " nil t)
4396 ;; This implementation of this function, with nine
4397 ;; search-forwards instead of the one re-search-forward and
4398 ;; a case (which basically was the old function) is actually
4399 ;; about twice as fast, even though it looks messier. You
4400 ;; can't have everything, I guess. Speed and elegance
4401 ;; doesn't always go hand in hand.
4404 (make-full-mail-header
4410 (narrow-to-region (point)
4411 (or (and (search-forward "\n.\n" nil t)
4417 (if (search-forward "\nsubject: " nil t)
4418 (nnheader-header-value)
4423 (if (search-forward "\nfrom: " nil t)
4424 (nnheader-header-value)
4429 (if (search-forward "\ndate: " nil t)
4430 (nnheader-header-value) ""))
4434 (setq id (if (re-search-forward
4435 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4436 ;; We do it this way to make sure the Message-ID
4437 ;; is (somewhat) syntactically valid.
4438 (buffer-substring (match-beginning 1)
4440 ;; If there was no message-id, we just fake one
4441 ;; to make subsequent routines simpler.
4442 (nnheader-generate-fake-message-id))))
4446 (if (search-forward "\nreferences: " nil t)
4450 (nnheader-header-value)
4455 (search-backward ">" end t)
4458 (search-backward "<" end t)
4460 ;; Get the references from the in-reply-to header if there
4461 ;; were no references and the in-reply-to header looks
4463 (if (and (search-forward "\nin-reply-to: " nil t)
4464 (setq in-reply-to (nnheader-header-value))
4465 (string-match "<[^>]+>" in-reply-to))
4467 (setq ref (substring in-reply-to (match-beginning 0)
4469 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4470 (setq ref2 (substring in-reply-to (match-beginning 0)
4472 (when (> (length ref2) (length ref))
4479 (if (search-forward "\nchars: " nil t)
4480 (if (numberp (setq chars (ignore-errors (read cur))))
4486 (if (search-forward "\nlines: " nil t)
4487 (if (numberp (setq lines (ignore-errors (read cur))))
4493 (and (search-forward "\nxref: " nil t)
4494 (nnheader-header-value)))))
4496 (if (and (search-forward "\ncontent-type: " nil t)
4497 (setq ctype (nnheader-header-value)))
4498 (mime-entity-set-content-type-internal
4499 header (mime-parse-Content-Type ctype)))
4500 (when (equal id ref)
4503 (when gnus-alter-header-function
4504 (funcall gnus-alter-header-function header)
4505 (setq id (mail-header-id header)
4506 ref (gnus-parent-id (mail-header-references header))))
4509 (gnus-dependencies-add-header
4510 header dependencies force-new))
4511 (push header headers))
4512 (goto-char (point-max))
4514 (nreverse headers)))))
4516 ;; Goes through the xover lines and returns a list of vectors
4517 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4518 force-new dependencies
4519 group also-fetch-heads)
4520 "Parse the news overview data in the server buffer, and return a
4521 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4522 ;; Get the Xref when the users reads the articles since most/some
4523 ;; NNTP servers do not include Xrefs when using XOVER.
4524 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4525 (let ((cur nntp-server-buffer)
4526 (dependencies (or dependencies gnus-newsgroup-dependencies))
4527 number headers header)
4529 (set-buffer nntp-server-buffer)
4530 ;; Allow the user to mangle the headers before parsing them.
4531 (gnus-run-hooks 'gnus-parse-headers-hook)
4532 (goto-char (point-min))
4535 (while (and sequence (not (eobp)))
4536 (setq number (read cur))
4537 (while (and sequence
4538 (< (car sequence) number))
4539 (setq sequence (cdr sequence)))
4541 (eq number (car sequence))
4543 (setq sequence (cdr sequence))
4544 (setq header (inline
4545 (gnus-nov-parse-line
4546 number dependencies force-new))))
4547 (push header headers))
4550 (gnus-error 4 "Strange nov line (%d)"
4551 (count-lines (point-min) (point)))))
4553 ;; A common bug in inn is that if you have posted an article and
4554 ;; then retrieves the active file, it will answer correctly --
4555 ;; the new article is included. However, a NOV entry for the
4556 ;; article may not have been generated yet, so this may fail.
4557 ;; We work around this problem by retrieving the last few
4558 ;; headers using HEAD.
4559 (if (or (not also-fetch-heads)
4561 ;; We (probably) got all the headers.
4563 (let ((gnus-nov-is-evil t))
4566 (when (gnus-retrieve-headers sequence group)
4567 (gnus-get-newsgroup-headers))))))))
4569 (defun gnus-article-get-xrefs ()
4570 "Fill in the Xref value in `gnus-current-headers', if necessary.
4571 This is meant to be called in `gnus-article-internal-prepare-hook'."
4572 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4573 gnus-current-headers)))
4574 (or (not gnus-use-cross-reference)
4576 (and (mail-header-xref headers)
4577 (not (string= (mail-header-xref headers) "")))
4578 (let ((case-fold-search t)
4581 (nnheader-narrow-to-headers)
4582 (goto-char (point-min))
4583 (when (or (and (eq (downcase (following-char)) ?x)
4584 (looking-at "Xref:"))
4585 (search-forward "\nXref:" nil t))
4586 (goto-char (1+ (match-end 0)))
4587 (setq xref (buffer-substring (point)
4588 (progn (end-of-line) (point))))
4589 (mail-header-set-xref headers xref)))))))
4591 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4592 "Find article ID and insert the summary line for that article.
4593 OLD-HEADER can either be a header or a line number to insert
4594 the subject line on."
4595 (let* ((line (and (numberp old-header) old-header))
4596 (old-header (and (vectorp old-header) old-header))
4597 (header (cond ((and old-header use-old-header)
4600 (gnus-number-to-header id))
4601 (gnus-number-to-header id))
4603 (gnus-read-header id))))
4604 (number (and (numberp id) id))
4607 ;; Rebuild the thread that this article is part of and go to the
4608 ;; article we have fetched.
4609 (when (and (not gnus-show-threads)
4612 (setq d (gnus-data-find (mail-header-number old-header))))
4613 (goto-char (gnus-data-pos d))
4616 (- (gnus-point-at-bol)
4618 (1+ (gnus-point-at-eol))
4619 (gnus-delete-line))))))
4621 (mail-header-set-number header (mail-header-number old-header)))
4622 (setq gnus-newsgroup-sparse
4623 (delq (setq number (mail-header-number header))
4624 gnus-newsgroup-sparse))
4625 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4626 (push number gnus-newsgroup-limit)
4627 (gnus-rebuild-thread (mail-header-id header) line)
4628 (gnus-summary-goto-subject number nil t))
4629 (when (and (numberp number)
4631 ;; We have to update the boundaries even if we can't fetch the
4632 ;; article if ID is a number -- so that the next `P' or `N'
4633 ;; command will fetch the previous (or next) article even
4634 ;; if the one we tried to fetch this time has been canceled.
4635 (when (> number gnus-newsgroup-end)
4636 (setq gnus-newsgroup-end number))
4637 (when (< number gnus-newsgroup-begin)
4638 (setq gnus-newsgroup-begin number))
4639 (setq gnus-newsgroup-unselected
4640 (delq number gnus-newsgroup-unselected)))
4641 ;; Report back a success?
4642 (and header (mail-header-number header))))
4644 ;;; Process/prefix in the summary buffer
4646 (defun gnus-summary-work-articles (n)
4647 "Return a list of articles to be worked upon.
4648 The prefix argument, the list of process marked articles, and the
4649 current article will be taken into consideration."
4651 (set-buffer gnus-summary-buffer)
4654 ;; A numerical prefix has been given.
4655 (setq n (prefix-numeric-value n))
4656 (let ((backward (< n 0))
4657 (n (abs (prefix-numeric-value n)))
4662 (push (setq article (gnus-summary-article-number))
4665 (gnus-summary-find-prev nil article)
4666 (gnus-summary-find-next nil article)))
4668 (nreverse articles)))
4669 ((and (gnus-region-active-p) (mark))
4670 (message "region active")
4671 ;; Work on the region between point and mark.
4672 (let ((max (max (point) (mark)))
4675 (goto-char (min (point) (mark)))
4678 (push (setq article (gnus-summary-article-number)) articles)
4679 (gnus-summary-find-next nil article)
4681 (nreverse articles))))
4682 (gnus-newsgroup-processable
4683 ;; There are process-marked articles present.
4684 ;; Save current state.
4685 (gnus-summary-save-process-mark)
4687 (reverse gnus-newsgroup-processable))
4689 ;; Just return the current article.
4690 (list (gnus-summary-article-number))))))
4692 (defmacro gnus-summary-iterate (arg &rest forms)
4693 "Iterate over the process/prefixed articles and do FORMS.
4694 ARG is the interactive prefix given to the command. FORMS will be
4695 executed with point over the summary line of the articles."
4696 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4697 `(let ((,articles (gnus-summary-work-articles ,arg)))
4699 (gnus-summary-goto-subject (car ,articles))
4702 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4703 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4705 (defun gnus-summary-save-process-mark ()
4706 "Push the current set of process marked articles on the stack."
4708 (push (copy-sequence gnus-newsgroup-processable)
4709 gnus-newsgroup-process-stack))
4711 (defun gnus-summary-kill-process-mark ()
4712 "Push the current set of process marked articles on the stack and unmark."
4714 (gnus-summary-save-process-mark)
4715 (gnus-summary-unmark-all-processable))
4717 (defun gnus-summary-yank-process-mark ()
4718 "Pop the last process mark state off the stack and restore it."
4720 (unless gnus-newsgroup-process-stack
4721 (error "Empty mark stack"))
4722 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4724 (defun gnus-summary-process-mark-set (set)
4725 "Make SET into the current process marked articles."
4726 (gnus-summary-unmark-all-processable)
4728 (gnus-summary-set-process-mark (pop set))))
4730 ;;; Searching and stuff
4732 (defun gnus-summary-search-group (&optional backward use-level)
4733 "Search for next unread newsgroup.
4734 If optional argument BACKWARD is non-nil, search backward instead."
4736 (set-buffer gnus-group-buffer)
4737 (when (gnus-group-search-forward
4738 backward nil (if use-level (gnus-group-group-level) nil))
4739 (gnus-group-group-name))))
4741 (defun gnus-summary-best-group (&optional exclude-group)
4742 "Find the name of the best unread group.
4743 If EXCLUDE-GROUP, do not go to this group."
4745 (set-buffer gnus-group-buffer)
4747 (gnus-group-best-unread-group exclude-group))))
4749 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4750 (if backward (gnus-summary-find-prev)
4751 (let* ((dummy (gnus-summary-article-intangible-p))
4752 (article (or article (gnus-summary-article-number)))
4753 (arts (gnus-data-find-list article))
4755 (when (and (not dummy)
4756 (or (not gnus-summary-check-current)
4758 (not (gnus-data-unread-p (car arts)))))
4759 (setq arts (cdr arts)))
4764 (when (or (and undownloaded
4765 (eq gnus-undownloaded-mark
4766 (gnus-data-mark (car arts))))
4767 (gnus-data-unread-p (car arts)))
4768 (setq result (car arts)
4770 (setq arts (cdr arts)))
4773 (goto-char (gnus-data-pos result))
4774 (gnus-data-number result)))))
4776 (defun gnus-summary-find-prev (&optional unread article)
4777 (let* ((eobp (eobp))
4778 (article (or article (gnus-summary-article-number)))
4779 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4781 (when (and (not eobp)
4782 (or (not gnus-summary-check-current)
4784 (not (gnus-data-unread-p (car arts)))))
4785 (setq arts (cdr arts)))
4790 (when (gnus-data-unread-p (car arts))
4791 (setq result (car arts)
4793 (setq arts (cdr arts)))
4796 (goto-char (gnus-data-pos result))
4797 (gnus-data-number result))))
4799 (defun gnus-summary-find-subject (subject &optional unread backward article)
4800 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4801 (article (or article (gnus-summary-article-number)))
4802 (articles (gnus-data-list backward))
4803 (arts (gnus-data-find-list article articles))
4805 (when (or (not gnus-summary-check-current)
4807 (not (gnus-data-unread-p (car arts))))
4808 (setq arts (cdr arts)))
4810 (and (or (not unread)
4811 (gnus-data-unread-p (car arts)))
4812 (vectorp (gnus-data-header (car arts)))
4814 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4815 (setq result (car arts)
4817 (setq arts (cdr arts)))
4819 (goto-char (gnus-data-pos result))
4820 (gnus-data-number result))))
4822 (defun gnus-summary-search-forward (&optional unread subject backward)
4823 "Search forward for an article.
4824 If UNREAD, look for unread articles. If SUBJECT, look for
4825 articles with that subject. If BACKWARD, search backward instead."
4826 (cond (subject (gnus-summary-find-subject subject unread backward))
4827 (backward (gnus-summary-find-prev unread))
4828 (t (gnus-summary-find-next unread))))
4830 (defun gnus-recenter (&optional n)
4831 "Center point in window and redisplay frame.
4832 Also do horizontal recentering."
4834 (when (and gnus-auto-center-summary
4835 (not (eq gnus-auto-center-summary 'vertical)))
4836 (gnus-horizontal-recenter))
4839 (defun gnus-summary-recenter ()
4840 "Center point in the summary window.
4841 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4842 displayed, no centering will be performed."
4843 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4844 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4845 (let* ((top (cond ((< (window-height) 4) 0)
4846 ((< (window-height) 7) 1)
4848 (height (1- (window-height)))
4849 (bottom (save-excursion (goto-char (point-max))
4850 (forward-line (- height))
4852 (window (get-buffer-window (current-buffer))))
4853 ;; The user has to want it.
4854 (when gnus-auto-center-summary
4855 (when (get-buffer-window gnus-article-buffer)
4856 ;; Only do recentering when the article buffer is displayed,
4857 ;; Set the window start to either `bottom', which is the biggest
4858 ;; possible valid number, or the second line from the top,
4859 ;; whichever is the least.
4861 window (min bottom (save-excursion
4862 (forward-line (- top)) (point)))))
4863 ;; Do horizontal recentering while we're at it.
4864 (when (and (get-buffer-window (current-buffer) t)
4865 (not (eq gnus-auto-center-summary 'vertical)))
4866 (let ((selected (selected-window)))
4867 (select-window (get-buffer-window (current-buffer) t))
4868 (gnus-summary-position-point)
4869 (gnus-horizontal-recenter)
4870 (select-window selected))))))
4872 (defun gnus-summary-jump-to-group (newsgroup)
4873 "Move point to NEWSGROUP in group mode buffer."
4874 ;; Keep update point of group mode buffer if visible.
4875 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4876 (save-window-excursion
4877 ;; Take care of tree window mode.
4878 (when (get-buffer-window gnus-group-buffer)
4879 (pop-to-buffer gnus-group-buffer))
4880 (gnus-group-jump-to-group newsgroup))
4882 ;; Take care of tree window mode.
4883 (if (get-buffer-window gnus-group-buffer)
4884 (pop-to-buffer gnus-group-buffer)
4885 (set-buffer gnus-group-buffer))
4886 (gnus-group-jump-to-group newsgroup))))
4888 ;; This function returns a list of article numbers based on the
4889 ;; difference between the ranges of read articles in this group and
4890 ;; the range of active articles.
4891 (defun gnus-list-of-unread-articles (group)
4892 (let* ((read (gnus-info-read (gnus-get-info group)))
4893 (active (or (gnus-active group) (gnus-activate-group group)))
4896 ;; If none are read, then all are unread.
4898 (setq first (car active))
4899 ;; If the range of read articles is a single range, then the
4900 ;; first unread article is the article after the last read
4901 ;; article. Sounds logical, doesn't it?
4902 (if (not (listp (cdr read)))
4903 (setq first (max (car active) (1+ (cdr read))))
4904 ;; `read' is a list of ranges.
4905 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4908 (setq first (car active)))
4911 (while (< first nlast)
4913 (setq first (1+ first))))
4914 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4915 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4916 (setq read (cdr read)))))
4917 ;; And add the last unread articles.
4918 (while (<= first last)
4920 (setq first (1+ first)))
4921 ;; Return the list of unread articles.
4922 (delq 0 (nreverse unread))))
4924 (defun gnus-list-of-read-articles (group)
4925 "Return a list of unread, unticked and non-dormant articles."
4926 (let* ((info (gnus-get-info group))
4927 (marked (gnus-info-marks info))
4928 (active (gnus-active group)))
4930 (gnus-set-difference
4931 (gnus-sorted-complement
4932 (gnus-uncompress-range active)
4933 (gnus-list-of-unread-articles group))
4935 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4936 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4938 ;; Various summary commands
4940 (defun gnus-summary-select-article-buffer ()
4941 "Reconfigure windows to show article buffer."
4943 (if (not (gnus-buffer-live-p gnus-article-buffer))
4944 (error "There is no article buffer for this summary buffer")
4945 (gnus-configure-windows 'article)
4946 (select-window (get-buffer-window gnus-article-buffer))))
4948 (defun gnus-summary-universal-argument (arg)
4949 "Perform any operation on all articles that are process/prefixed."
4951 (let ((articles (gnus-summary-work-articles arg))
4958 (substitute-command-keys
4959 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4962 (gnus-error 1 "Undefined key")
4965 (gnus-summary-goto-subject (setq article (pop articles)))
4966 (let (gnus-newsgroup-processable)
4967 (command-execute func))
4968 (gnus-summary-remove-process-mark article)))))
4969 (gnus-summary-position-point))
4971 (defun gnus-summary-toggle-truncation (&optional arg)
4972 "Toggle truncation of summary lines.
4973 With arg, turn line truncation on iff arg is positive."
4975 (setq truncate-lines
4976 (if (null arg) (not truncate-lines)
4977 (> (prefix-numeric-value arg) 0)))
4980 (defun gnus-summary-reselect-current-group (&optional all rescan)
4981 "Exit and then reselect the current newsgroup.
4982 The prefix argument ALL means to select all articles."
4984 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4985 (error "Ephemeral groups can't be reselected"))
4986 (let ((current-subject (gnus-summary-article-number))
4987 (group gnus-newsgroup-name))
4988 (setq gnus-newsgroup-begin nil)
4990 ;; We have to adjust the point of group mode buffer because
4991 ;; point was moved to the next unread newsgroup by exiting.
4992 (gnus-summary-jump-to-group group)
4995 (gnus-group-get-new-news-this-group 1)))
4996 (gnus-group-read-group all t)
4997 (gnus-summary-goto-subject current-subject nil t)))
4999 (defun gnus-summary-rescan-group (&optional all)
5000 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5002 (gnus-summary-reselect-current-group all t))
5004 (defun gnus-summary-update-info (&optional non-destructive)
5006 (let ((group gnus-newsgroup-name))
5008 (when gnus-newsgroup-kill-headers
5009 (setq gnus-newsgroup-killed
5010 (gnus-compress-sequence
5012 (gnus-set-sorted-intersection
5013 (gnus-uncompress-range gnus-newsgroup-killed)
5014 (setq gnus-newsgroup-unselected
5015 (sort gnus-newsgroup-unselected '<)))
5016 (setq gnus-newsgroup-unreads
5017 (sort gnus-newsgroup-unreads '<)))
5019 (unless (listp (cdr gnus-newsgroup-killed))
5020 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5021 (let ((headers gnus-newsgroup-headers))
5022 ;; Set the new ranges of read articles.
5024 (set-buffer gnus-group-buffer)
5025 (gnus-undo-force-boundary))
5026 (gnus-update-read-articles
5027 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5028 ;; Set the current article marks.
5029 (let ((gnus-newsgroup-scored
5030 (if (and (not gnus-save-score)
5031 (not non-destructive))
5033 gnus-newsgroup-scored)))
5035 (gnus-update-marks)))
5036 ;; Do the cross-ref thing.
5037 (when gnus-use-cross-reference
5038 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5039 ;; Do not switch windows but change the buffer to work.
5040 (set-buffer gnus-group-buffer)
5041 (unless (gnus-ephemeral-group-p group)
5042 (gnus-group-update-group group)))))))
5044 (defun gnus-summary-save-newsrc (&optional force)
5045 "Save the current number of read/marked articles in the dribble buffer.
5046 The dribble buffer will then be saved.
5047 If FORCE (the prefix), also save the .newsrc file(s)."
5049 (gnus-summary-update-info t)
5051 (gnus-save-newsrc-file)
5052 (gnus-dribble-save)))
5054 (defun gnus-summary-exit (&optional temporary)
5055 "Exit reading current newsgroup, and then return to group selection mode.
5056 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5058 (gnus-set-global-variables)
5059 (gnus-kill-save-kill-buffer)
5060 (gnus-async-halt-prefetch)
5061 (let* ((group gnus-newsgroup-name)
5062 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5065 (buf (current-buffer)))
5066 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5067 ;; If we have several article buffers, we kill them at exit.
5068 (unless gnus-single-article-buffer
5069 (gnus-kill-buffer gnus-original-article-buffer)
5070 (setq gnus-article-current nil))
5071 (when gnus-use-cache
5072 (gnus-cache-possibly-remove-articles)
5073 (gnus-cache-save-buffers))
5074 (gnus-async-prefetch-remove-group group)
5075 (when gnus-suppress-duplicates
5076 (gnus-dup-enter-articles))
5077 (when gnus-use-trees
5078 (gnus-tree-close group))
5079 ;; Remove entries for this group.
5080 (nnmail-purge-split-history (gnus-group-real-name group))
5081 ;; Make all changes in this group permanent.
5083 (gnus-run-hooks 'gnus-exit-group-hook)
5084 (gnus-summary-update-info)
5085 ;; Do adaptive scoring, and possibly save score files.
5086 (when gnus-newsgroup-adaptive
5087 (gnus-score-adaptive))
5088 (when gnus-use-scoring
5090 (gnus-close-group group)
5091 ;; Make sure where we were, and go to next newsgroup.
5092 (set-buffer gnus-group-buffer)
5094 (gnus-group-jump-to-group group))
5095 (gnus-run-hooks 'gnus-summary-exit-hook)
5096 (unless (or quit-config
5097 ;; If this group has disappeared from the summary
5098 ;; buffer, don't skip forwards.
5099 (not (string= group (gnus-group-group-name))))
5100 (gnus-group-next-unread-group 1))
5101 (setq group-point (point))
5104 ;; If we have several article buffers, we kill them at exit.
5105 (unless gnus-single-article-buffer
5106 (gnus-kill-buffer gnus-article-buffer)
5107 (gnus-kill-buffer gnus-original-article-buffer)
5108 (setq gnus-article-current nil))
5110 (if (not gnus-kill-summary-on-exit)
5111 (gnus-deaden-summary)
5112 ;; We set all buffer-local variables to nil. It is unclear why
5113 ;; this is needed, but if we don't, buffer-local variables are
5114 ;; not garbage-collected, it seems. This would the lead to en
5115 ;; ever-growing Emacs.
5116 (gnus-summary-clear-local-variables)
5117 (when (get-buffer gnus-article-buffer)
5118 (bury-buffer gnus-article-buffer))
5119 ;; We clear the global counterparts of the buffer-local
5120 ;; variables as well, just to be on the safe side.
5121 (set-buffer gnus-group-buffer)
5122 (gnus-summary-clear-local-variables)
5123 ;; Return to group mode buffer.
5124 (when (eq mode 'gnus-summary-mode)
5125 (gnus-kill-buffer buf)))
5126 (setq gnus-current-select-method gnus-select-method)
5127 (pop-to-buffer gnus-group-buffer)
5128 (if (not quit-config)
5130 (goto-char group-point)
5131 (gnus-configure-windows 'group 'force))
5132 (gnus-handle-ephemeral-exit quit-config))
5133 ;; Clear the current group name.
5135 (setq gnus-newsgroup-name nil)))))
5137 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5138 (defun gnus-summary-exit-no-update (&optional no-questions)
5139 "Quit reading current newsgroup without updating read article info."
5141 (let* ((group gnus-newsgroup-name)
5142 (quit-config (gnus-group-quit-config group)))
5143 (when (or no-questions
5145 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5146 (gnus-async-halt-prefetch)
5147 (gnus-run-hooks (delq 'gnus-summary-expire-articles
5148 (copy-list gnus-summary-prepare-exit-hook)))
5149 ;; If we have several article buffers, we kill them at exit.
5150 (unless gnus-single-article-buffer
5151 (gnus-kill-buffer gnus-article-buffer)
5152 (gnus-kill-buffer gnus-original-article-buffer)
5153 (setq gnus-article-current nil))
5154 (if (not gnus-kill-summary-on-exit)
5155 (gnus-deaden-summary)
5156 (gnus-close-group group)
5157 (gnus-summary-clear-local-variables)
5158 (set-buffer gnus-group-buffer)
5159 (gnus-summary-clear-local-variables)
5160 (when (get-buffer gnus-summary-buffer)
5161 (kill-buffer gnus-summary-buffer)))
5162 (unless gnus-single-article-buffer
5163 (setq gnus-article-current nil))
5164 (when gnus-use-trees
5165 (gnus-tree-close group))
5166 (gnus-async-prefetch-remove-group group)
5167 (when (get-buffer gnus-article-buffer)
5168 (bury-buffer gnus-article-buffer))
5169 ;; Return to the group buffer.
5170 (gnus-configure-windows 'group 'force)
5171 ;; Clear the current group name.
5172 (setq gnus-newsgroup-name nil)
5173 (when (equal (gnus-group-group-name) group)
5174 (gnus-group-next-unread-group 1))
5176 (gnus-handle-ephemeral-exit quit-config)))))
5178 (defun gnus-handle-ephemeral-exit (quit-config)
5179 "Handle movement when leaving an ephemeral group.
5180 The state which existed when entering the ephemeral is reset."
5181 (if (not (buffer-name (car quit-config)))
5182 (gnus-configure-windows 'group 'force)
5183 (set-buffer (car quit-config))
5184 (cond ((eq major-mode 'gnus-summary-mode)
5185 (gnus-set-global-variables))
5186 ((eq major-mode 'gnus-article-mode)
5188 ;; The `gnus-summary-buffer' variable may point
5189 ;; to the old summary buffer when using a single
5191 (unless (gnus-buffer-live-p gnus-summary-buffer)
5192 (set-buffer gnus-group-buffer))
5193 (set-buffer gnus-summary-buffer)
5194 (gnus-set-global-variables))))
5195 (if (or (eq (cdr quit-config) 'article)
5196 (eq (cdr quit-config) 'pick))
5198 ;; The current article may be from the ephemeral group
5199 ;; thus it is best that we reload this article
5200 (gnus-summary-show-article)
5201 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5202 (gnus-configure-windows 'pick 'force)
5203 (gnus-configure-windows (cdr quit-config) 'force)))
5204 (gnus-configure-windows (cdr quit-config) 'force))
5205 (when (eq major-mode 'gnus-summary-mode)
5206 (gnus-summary-next-subject 1 nil t)
5207 (gnus-summary-recenter)
5208 (gnus-summary-position-point))))
5210 (defun gnus-summary-preview-mime-message (arg)
5211 "MIME decode and play this message."
5214 (let ((gnus-break-pages nil)
5216 (gnus-summary-select-article t t)
5218 (select-window (get-buffer-window gnus-article-buffer))
5223 (defvar gnus-dead-summary-mode-map nil)
5225 (unless gnus-dead-summary-mode-map
5226 (setq gnus-dead-summary-mode-map (make-keymap))
5227 (suppress-keymap gnus-dead-summary-mode-map)
5228 (substitute-key-definition
5229 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5230 (let ((keys '("\C-d" "\r" "\177" [delete])))
5232 (define-key gnus-dead-summary-mode-map
5233 (pop keys) 'gnus-summary-wake-up-the-dead))))
5235 (defvar gnus-dead-summary-mode nil
5236 "Minor mode for Gnus summary buffers.")
5238 (defun gnus-dead-summary-mode (&optional arg)
5239 "Minor mode for Gnus summary buffers."
5241 (when (eq major-mode 'gnus-summary-mode)
5242 (make-local-variable 'gnus-dead-summary-mode)
5243 (setq gnus-dead-summary-mode
5244 (if (null arg) (not gnus-dead-summary-mode)
5245 (> (prefix-numeric-value arg) 0)))
5246 (when gnus-dead-summary-mode
5247 (gnus-add-minor-mode
5248 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5250 (defun gnus-deaden-summary ()
5251 "Make the current summary buffer into a dead summary buffer."
5252 ;; Kill any previous dead summary buffer.
5253 (when (and gnus-dead-summary
5254 (buffer-name gnus-dead-summary))
5256 (set-buffer gnus-dead-summary)
5257 (when gnus-dead-summary-mode
5258 (kill-buffer (current-buffer)))))
5259 ;; Make this the current dead summary.
5260 (setq gnus-dead-summary (current-buffer))
5261 (gnus-dead-summary-mode 1)
5262 (let ((name (buffer-name)))
5263 (when (string-match "Summary" name)
5265 (concat (substring name 0 (match-beginning 0)) "Dead "
5266 (substring name (match-beginning 0)))
5269 (defun gnus-kill-or-deaden-summary (buffer)
5270 "Kill or deaden the summary BUFFER."
5272 (when (and (buffer-name buffer)
5273 (not gnus-single-article-buffer))
5276 (gnus-kill-buffer gnus-article-buffer)
5277 (gnus-kill-buffer gnus-original-article-buffer)))
5278 (cond (gnus-kill-summary-on-exit
5279 (when (and gnus-use-trees
5280 (gnus-buffer-exists-p buffer))
5283 (gnus-tree-close gnus-newsgroup-name)))
5284 (gnus-kill-buffer buffer))
5285 ((gnus-buffer-exists-p buffer)
5288 (gnus-deaden-summary))))))
5290 (defun gnus-summary-wake-up-the-dead (&rest args)
5291 "Wake up the dead summary buffer."
5293 (gnus-dead-summary-mode -1)
5294 (let ((name (buffer-name)))
5295 (when (string-match "Dead " name)
5297 (concat (substring name 0 (match-beginning 0))
5298 (substring name (match-end 0)))
5300 (gnus-message 3 "This dead summary is now alive again"))
5302 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5303 (defun gnus-summary-fetch-faq (&optional faq-dir)
5304 "Fetch the FAQ for the current group.
5305 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5309 (when current-prefix-arg
5311 "Faq dir: " (and (listp gnus-group-faq-directory)
5312 (mapcar (lambda (file) (list file))
5313 gnus-group-faq-directory))))))
5314 (let (gnus-faq-buffer)
5315 (when (setq gnus-faq-buffer
5316 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5317 (gnus-configure-windows 'summary-faq))))
5319 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5320 (defun gnus-summary-describe-group (&optional force)
5321 "Describe the current newsgroup."
5323 (gnus-group-describe-group force gnus-newsgroup-name))
5325 (defun gnus-summary-describe-briefly ()
5326 "Describe summary mode commands briefly."
5329 (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")))
5331 ;; Walking around group mode buffer from summary mode.
5333 (defun gnus-summary-next-group (&optional no-article target-group backward)
5334 "Exit current newsgroup and then select next unread newsgroup.
5335 If prefix argument NO-ARTICLE is non-nil, no article is selected
5336 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5337 previous group instead."
5339 ;; Stop pre-fetching.
5340 (gnus-async-halt-prefetch)
5341 (let ((current-group gnus-newsgroup-name)
5342 (current-buffer (current-buffer))
5344 ;; First we semi-exit this group to update Xrefs and all variables.
5345 ;; We can't do a real exit, because the window conf must remain
5346 ;; the same in case the user is prompted for info, and we don't
5347 ;; want the window conf to change before that...
5348 (gnus-summary-exit t)
5349 (while (not entered)
5350 ;; Then we find what group we are supposed to enter.
5351 (set-buffer gnus-group-buffer)
5352 (gnus-group-jump-to-group current-group)
5355 (if (eq gnus-keep-same-level 'best)
5356 (gnus-summary-best-group gnus-newsgroup-name)
5357 (gnus-summary-search-group backward gnus-keep-same-level))))
5358 (if (not target-group)
5359 ;; There are no further groups, so we return to the group
5362 (gnus-message 5 "Returning to the group buffer")
5364 (when (gnus-buffer-live-p current-buffer)
5365 (set-buffer current-buffer)
5366 (gnus-summary-exit))
5367 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5368 ;; We try to enter the target group.
5369 (gnus-group-jump-to-group target-group)
5370 (let ((unreads (gnus-group-group-unread)))
5371 (if (and (or (eq t unreads)
5372 (and unreads (not (zerop unreads))))
5373 (gnus-summary-read-group
5374 target-group nil no-article
5375 (and (buffer-name current-buffer) current-buffer)
5378 (setq current-group target-group
5379 target-group nil)))))))
5381 (defun gnus-summary-prev-group (&optional no-article)
5382 "Exit current newsgroup and then select previous unread newsgroup.
5383 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5385 (gnus-summary-next-group no-article nil t))
5387 ;; Walking around summary lines.
5389 (defun gnus-summary-first-subject (&optional unread undownloaded)
5390 "Go to the first unread subject.
5391 If UNREAD is non-nil, go to the first unread article.
5392 Returns the article selected or nil if there are no unread articles."
5397 ((null gnus-newsgroup-data)
5398 (gnus-message 3 "No articles in the group")
5400 ;; Pick the first article.
5402 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5403 (gnus-data-number (car gnus-newsgroup-data)))
5404 ;; No unread articles.
5405 ((null gnus-newsgroup-unreads)
5406 (gnus-message 3 "No more unread articles")
5408 ;; Find the first unread article.
5410 (let ((data gnus-newsgroup-data))
5412 (and (not (and undownloaded
5413 (eq gnus-undownloaded-mark
5414 (gnus-data-mark (car data)))))
5415 (not (gnus-data-unread-p (car data)))))
5416 (setq data (cdr data)))
5418 (goto-char (gnus-data-pos (car data)))
5419 (gnus-data-number (car data))))))
5420 (gnus-summary-position-point)))
5422 (defun gnus-summary-next-subject (n &optional unread dont-display)
5423 "Go to next N'th summary line.
5424 If N is negative, go to the previous N'th subject line.
5425 If UNREAD is non-nil, only unread articles are selected.
5426 The difference between N and the actual number of steps taken is
5429 (let ((backward (< n 0))
5433 (gnus-summary-find-prev unread)
5434 (gnus-summary-find-next unread)))
5435 (gnus-summary-show-thread)
5438 (gnus-message 7 "No more%s articles"
5439 (if unread " unread" "")))
5440 (unless dont-display
5441 (gnus-summary-recenter)
5442 (gnus-summary-position-point))
5445 (defun gnus-summary-next-unread-subject (n)
5446 "Go to next N'th unread summary line."
5448 (gnus-summary-next-subject n t))
5450 (defun gnus-summary-prev-subject (n &optional unread)
5451 "Go to previous N'th summary line.
5452 If optional argument UNREAD is non-nil, only unread article is selected."
5454 (gnus-summary-next-subject (- n) unread))
5456 (defun gnus-summary-prev-unread-subject (n)
5457 "Go to previous N'th unread summary line."
5459 (gnus-summary-next-subject (- n) t))
5461 (defun gnus-summary-goto-subject (article &optional force silent)
5462 "Go the subject line of ARTICLE.
5463 If FORCE, also allow jumping to articles not currently shown."
5464 (interactive "nArticle number: ")
5466 (data (gnus-data-find article)))
5467 ;; We read in the article if we have to.
5470 (gnus-summary-insert-subject
5472 (if (or (numberp force) (vectorp force)) force)
5474 (setq data (gnus-data-find article)))
5479 (gnus-message 3 "Can't find article %d" article))
5481 (goto-char (gnus-data-pos data))
5482 (gnus-summary-position-point)
5485 ;; Walking around summary lines with displaying articles.
5487 (defun gnus-summary-expand-window (&optional arg)
5488 "Make the summary buffer take up the entire Emacs frame.
5489 Given a prefix, will force an `article' buffer configuration."
5492 (gnus-configure-windows 'article 'force)
5493 (gnus-configure-windows 'summary 'force)))
5495 (defun gnus-summary-display-article (article &optional all-header)
5496 "Display ARTICLE in article buffer."
5497 (gnus-set-global-variables)
5501 (if gnus-summary-display-article-function
5502 (funcall gnus-summary-display-article-function article all-header)
5503 (gnus-article-prepare article all-header))
5504 (gnus-run-hooks 'gnus-select-article-hook)
5505 (when (and gnus-current-article
5506 (not (zerop gnus-current-article)))
5507 (gnus-summary-goto-subject gnus-current-article))
5508 (gnus-summary-recenter)
5509 (when (and gnus-use-trees gnus-show-threads)
5510 (gnus-possibly-generate-tree article)
5511 (gnus-highlight-selected-tree article))
5512 ;; Successfully display article.
5513 (gnus-article-set-window-start
5514 (cdr (assq article gnus-newsgroup-bookmarks))))))
5516 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5517 "Select the current article.
5518 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5519 non-nil, the article will be re-fetched even if it already present in
5520 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5522 ;; Make sure we are in the summary buffer to work around bbdb bug.
5523 (unless (eq major-mode 'gnus-summary-mode)
5524 (set-buffer gnus-summary-buffer))
5525 (let ((article (or article (gnus-summary-article-number)))
5526 (all-headers (not (not all-headers))) ;Must be T or NIL.
5527 gnus-summary-display-article-function
5530 (gnus-summary-article-pseudo-p article)
5531 (error "This is a pseudo-article"))
5534 (set-buffer gnus-summary-buffer)
5535 (if (or (and gnus-single-article-buffer
5536 (or (null gnus-current-article)
5537 (null gnus-article-current)
5538 (null (get-buffer gnus-article-buffer))
5539 (not (eq article (cdr gnus-article-current)))
5540 (not (equal (car gnus-article-current)
5541 gnus-newsgroup-name))))
5542 (and (not gnus-single-article-buffer)
5543 (or (null gnus-current-article)
5544 (not (eq gnus-current-article article))))
5546 ;; The requested article is different from the current article.
5548 (gnus-summary-display-article article all-headers)
5550 (when (or all-headers gnus-show-all-headers)
5551 (gnus-article-show-all-headers))
5554 (gnus-article-set-window-start
5555 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5557 (defun gnus-summary-set-current-mark (&optional current-mark)
5558 "Obsolete function."
5561 (defun gnus-summary-next-article (&optional unread subject backward push)
5562 "Select the next article.
5563 If UNREAD, only unread articles are selected.
5564 If SUBJECT, only articles with SUBJECT are selected.
5565 If BACKWARD, the previous article is selected instead of the next."
5568 ;; Is there such an article?
5569 ((and (gnus-summary-search-forward unread subject backward)
5570 (or (gnus-summary-display-article (gnus-summary-article-number))
5571 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5572 (gnus-summary-position-point))
5573 ;; If not, we try the first unread, if that is wanted.
5575 gnus-auto-select-same
5576 (gnus-summary-first-unread-article))
5577 (gnus-summary-position-point)
5578 (gnus-message 6 "Wrapped"))
5579 ;; Try to get next/previous article not displayed in this group.
5580 ((and gnus-auto-extend-newsgroup
5581 (not unread) (not subject))
5582 (gnus-summary-goto-article
5583 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5584 nil (count-lines (point-min) (point))))
5585 ;; Go to next/previous group.
5587 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5588 (gnus-summary-jump-to-group gnus-newsgroup-name))
5589 (let ((cmd last-command-char)
5592 (set-buffer gnus-group-buffer)
5595 (if (eq gnus-keep-same-level 'best)
5596 (gnus-summary-best-group gnus-newsgroup-name)
5597 (gnus-summary-search-group backward gnus-keep-same-level))))
5598 ;; For some reason, the group window gets selected. We change
5600 (select-window (get-buffer-window (current-buffer)))
5601 ;; Select next unread newsgroup automagically.
5603 ((or (not gnus-auto-select-next)
5605 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5606 ((or (eq gnus-auto-select-next 'quietly)
5607 (and (eq gnus-auto-select-next 'slightly-quietly)
5609 (and (eq gnus-auto-select-next 'almost-quietly)
5610 (gnus-summary-last-article-p)))
5612 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5614 (gnus-message 7 "No more%s articles (%s)..."
5615 (if unread " unread" "")
5616 (if group (concat "selecting " group)
5618 (gnus-summary-next-group nil group backward)))
5620 (when (gnus-key-press-event-p last-input-event)
5621 (gnus-summary-walk-group-buffer
5622 gnus-newsgroup-name cmd unread backward point))))))))
5624 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5625 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5626 (?\C-p (gnus-group-prev-unread-group 1))))
5627 (cursor-in-echo-area t)
5628 keve key group ended)
5630 (set-buffer gnus-group-buffer)
5633 (if (eq gnus-keep-same-level 'best)
5634 (gnus-summary-best-group gnus-newsgroup-name)
5635 (gnus-summary-search-group backward gnus-keep-same-level))))
5638 5 "No more%s articles%s" (if unread " unread" "")
5640 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5641 (format " (Type %s for %s [%s])"
5642 (single-key-description cmd) group
5643 (car (gnus-gethash group gnus-newsrc-hashtb)))
5644 (format " (Type %s to exit %s)"
5645 (single-key-description cmd)
5646 gnus-newsgroup-name)))
5647 ;; Confirm auto selection.
5648 (setq key (car (setq keve (gnus-read-event-char))))
5651 ((assq key keystrokes)
5652 (let ((obuf (current-buffer)))
5653 (switch-to-buffer gnus-group-buffer)
5655 (gnus-group-jump-to-group group))
5656 (eval (cadr (assq key keystrokes)))
5657 (setq group (gnus-group-group-name))
5658 (switch-to-buffer obuf))
5662 (gnus-ephemeral-group-p gnus-newsgroup-name))
5664 (gnus-summary-next-group nil group backward)))
5666 (push (cdr keve) unread-command-events))))))
5668 (defun gnus-summary-next-unread-article ()
5669 "Select unread article after current one."
5671 (gnus-summary-next-article
5672 (or (not (eq gnus-summary-goto-unread 'never))
5673 (gnus-summary-last-article-p (gnus-summary-article-number)))
5674 (and gnus-auto-select-same
5675 (gnus-summary-article-subject))))
5677 (defun gnus-summary-prev-article (&optional unread subject)
5678 "Select the article after the current one.
5679 If UNREAD is non-nil, only unread articles are selected."
5681 (gnus-summary-next-article unread subject t))
5683 (defun gnus-summary-prev-unread-article ()
5684 "Select unread article before current one."
5686 (gnus-summary-prev-article
5687 (or (not (eq gnus-summary-goto-unread 'never))
5688 (gnus-summary-first-article-p (gnus-summary-article-number)))
5689 (and gnus-auto-select-same
5690 (gnus-summary-article-subject))))
5692 (defun gnus-summary-next-page (&optional lines circular)
5693 "Show next page of the selected article.
5694 If at the end of the current article, select the next article.
5695 LINES says how many lines should be scrolled up.
5697 If CIRCULAR is non-nil, go to the start of the article instead of
5698 selecting the next article when reaching the end of the current
5701 (setq gnus-summary-buffer (current-buffer))
5702 (gnus-set-global-variables)
5703 (let ((article (gnus-summary-article-number))
5704 (article-window (get-buffer-window gnus-article-buffer t))
5706 ;; If the buffer is empty, we have no article.
5708 (error "No article to select"))
5709 (gnus-configure-windows 'article)
5710 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5711 (if (and (eq gnus-summary-goto-unread 'never)
5712 (not (gnus-summary-last-article-p article)))
5713 (gnus-summary-next-article)
5714 (gnus-summary-next-unread-article))
5715 (if (or (null gnus-current-article)
5716 (null gnus-article-current)
5717 (/= article (cdr gnus-article-current))
5718 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5719 ;; Selected subject is different from current article's.
5720 (gnus-summary-display-article article)
5721 (when article-window
5722 (gnus-eval-in-buffer-window gnus-article-buffer
5723 (setq endp (gnus-article-next-page lines)))
5726 (gnus-summary-beginning-of-article))
5728 (gnus-message 3 "End of message"))
5730 (if (and (eq gnus-summary-goto-unread 'never)
5731 (not (gnus-summary-last-article-p article)))
5732 (gnus-summary-next-article)
5733 (gnus-summary-next-unread-article))))))))
5734 (gnus-summary-recenter)
5735 (gnus-summary-position-point)))
5737 (defun gnus-summary-prev-page (&optional lines move)
5738 "Show previous page of selected article.
5739 Argument LINES specifies lines to be scrolled down.
5740 If MOVE, move to the previous unread article if point is at
5741 the beginning of the buffer."
5743 (let ((article (gnus-summary-article-number))
5744 (article-window (get-buffer-window gnus-article-buffer t))
5746 (gnus-configure-windows 'article)
5747 (if (or (null gnus-current-article)
5748 (null gnus-article-current)
5749 (/= article (cdr gnus-article-current))
5750 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5751 ;; Selected subject is different from current article's.
5752 (gnus-summary-display-article article)
5753 (gnus-summary-recenter)
5754 (when article-window
5755 (gnus-eval-in-buffer-window gnus-article-buffer
5756 (setq endp (gnus-article-prev-page lines)))
5757 (when (and move endp)
5759 (gnus-message 3 "Beginning of message"))
5761 (if (and (eq gnus-summary-goto-unread 'never)
5762 (not (gnus-summary-first-article-p article)))
5763 (gnus-summary-prev-article)
5764 (gnus-summary-prev-unread-article))))))))
5765 (gnus-summary-position-point))
5767 (defun gnus-summary-prev-page-or-article (&optional lines)
5768 "Show previous page of selected article.
5769 Argument LINES specifies lines to be scrolled down.
5770 If at the beginning of the article, go to the next article."
5772 (gnus-summary-prev-page lines t))
5774 (defun gnus-summary-scroll-up (lines)
5775 "Scroll up (or down) one line current article.
5776 Argument LINES specifies lines to be scrolled up (or down if negative)."
5778 (gnus-configure-windows 'article)
5779 (gnus-summary-show-thread)
5780 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5781 (gnus-eval-in-buffer-window gnus-article-buffer
5783 (when (gnus-article-next-page lines)
5784 (gnus-message 3 "End of message")))
5786 (gnus-article-prev-page (- lines))))))
5787 (gnus-summary-recenter)
5788 (gnus-summary-position-point))
5790 (defun gnus-summary-scroll-down (lines)
5791 "Scroll down (or up) one line current article.
5792 Argument LINES specifies lines to be scrolled down (or up if negative)."
5794 (gnus-summary-scroll-up (- lines)))
5796 (defun gnus-summary-next-same-subject ()
5797 "Select next article which has the same subject as current one."
5799 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5801 (defun gnus-summary-prev-same-subject ()
5802 "Select previous article which has the same subject as current one."
5804 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5806 (defun gnus-summary-next-unread-same-subject ()
5807 "Select next unread article which has the same subject as current one."
5809 (gnus-summary-next-article t (gnus-summary-article-subject)))
5811 (defun gnus-summary-prev-unread-same-subject ()
5812 "Select previous unread article which has the same subject as current one."
5814 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5816 (defun gnus-summary-first-unread-article ()
5817 "Select the first unread article.
5818 Return nil if there are no unread articles."
5821 (when (gnus-summary-first-subject t)
5822 (gnus-summary-show-thread)
5823 (gnus-summary-first-subject t)
5824 (gnus-summary-display-article (gnus-summary-article-number)))
5825 (gnus-summary-position-point)))
5827 (defun gnus-summary-first-unread-subject ()
5828 "Place the point on the subject line of the first unread article.
5829 Return nil if there are no unread articles."
5832 (when (gnus-summary-first-subject t)
5833 (gnus-summary-show-thread)
5834 (gnus-summary-first-subject t))
5835 (gnus-summary-position-point)))
5837 (defun gnus-summary-first-article ()
5838 "Select the first article.
5839 Return nil if there are no articles."
5842 (when (gnus-summary-first-subject)
5843 (gnus-summary-show-thread)
5844 (gnus-summary-first-subject)
5845 (gnus-summary-display-article (gnus-summary-article-number)))
5846 (gnus-summary-position-point)))
5848 (defun gnus-summary-best-unread-article ()
5849 "Select the unread article with the highest score."
5851 (let ((best -1000000)
5852 (data gnus-newsgroup-data)
5855 (and (gnus-data-unread-p (car data))
5857 (gnus-summary-article-score (gnus-data-number (car data))))
5860 article (gnus-data-number (car data))))
5861 (setq data (cdr data)))
5864 (gnus-summary-goto-article article)
5865 (error "No unread articles"))
5866 (gnus-summary-position-point))))
5868 (defun gnus-summary-last-subject ()
5869 "Go to the last displayed subject line in the group."
5870 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5872 (gnus-summary-goto-subject article))))
5874 (defun gnus-summary-goto-article (article &optional all-headers force)
5875 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5876 If ALL-HEADERS is non-nil, no header lines are hidden.
5877 If FORCE, go to the article even if it isn't displayed. If FORCE
5878 is a number, it is the line the article is to be displayed on."
5882 "Article number or Message-ID: "
5883 (mapcar (lambda (number) (list (int-to-string number)))
5884 gnus-newsgroup-limit))
5888 (if (and (stringp article)
5889 (string-match "@" article))
5890 (gnus-summary-refer-article article)
5891 (when (stringp article)
5892 (setq article (string-to-number article)))
5893 (if (gnus-summary-goto-subject article force)
5894 (gnus-summary-display-article article all-headers)
5895 (gnus-message 4 "Couldn't go to article %s" article) nil))
5896 (gnus-summary-position-point)))
5898 (defun gnus-summary-goto-last-article ()
5899 "Go to the previously read article."
5902 (when gnus-last-article
5903 (gnus-summary-goto-article gnus-last-article nil t))
5904 (gnus-summary-position-point)))
5906 (defun gnus-summary-pop-article (number)
5907 "Pop one article off the history and go to the previous.
5908 NUMBER articles will be popped off."
5911 (setq gnus-newsgroup-history
5912 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5914 (gnus-summary-goto-article (car to) nil t)
5915 (error "Article history empty")))
5916 (gnus-summary-position-point))
5918 ;; Summary commands and functions for limiting the summary buffer.
5920 (defun gnus-summary-limit-to-articles (n)
5921 "Limit the summary buffer to the next N articles.
5922 If not given a prefix, use the process marked articles instead."
5925 (let ((articles (gnus-summary-work-articles n)))
5926 (setq gnus-newsgroup-processable nil)
5927 (gnus-summary-limit articles))
5928 (gnus-summary-position-point)))
5930 (defun gnus-summary-pop-limit (&optional total)
5931 "Restore the previous limit.
5932 If given a prefix, remove all limits."
5935 (setq gnus-newsgroup-limits
5936 (list (mapcar (lambda (h) (mail-header-number h))
5937 gnus-newsgroup-headers))))
5938 (unless gnus-newsgroup-limits
5939 (error "No limit to pop"))
5941 (gnus-summary-limit nil 'pop)
5942 (gnus-summary-position-point)))
5944 (defun gnus-summary-limit-to-subject (subject &optional header)
5945 "Limit the summary buffer to articles that have subjects that match a regexp."
5946 (interactive "sLimit to subject (regexp): ")
5948 (setq header "subject"))
5949 (when (not (equal "" subject))
5951 (let ((articles (gnus-summary-find-matching
5952 (or header "subject") subject 'all)))
5954 (error "Found no matches for \"%s\"" subject))
5955 (gnus-summary-limit articles))
5956 (gnus-summary-position-point))))
5958 (defun gnus-summary-limit-to-author (from)
5959 "Limit the summary buffer to articles that have authors that match a regexp."
5960 (interactive "sLimit to author (regexp): ")
5961 (gnus-summary-limit-to-subject from "from"))
5963 (defun gnus-summary-limit-to-age (age &optional younger-p)
5964 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5965 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5966 articles that are younger than AGE days."
5967 (interactive "nTime in days: \nP")
5969 (let ((data gnus-newsgroup-data)
5970 (cutoff (days-to-time age))
5971 articles d date is-younger)
5972 (while (setq d (pop data))
5973 (when (and (vectorp (gnus-data-header d))
5974 (setq date (mail-header-date (gnus-data-header d))))
5975 (setq is-younger (time-less-p
5976 (time-since (date-to-time date))
5981 (push (gnus-data-number d) articles))))
5982 (gnus-summary-limit (nreverse articles)))
5983 (gnus-summary-position-point)))
5985 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5987 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5989 (defun gnus-summary-limit-to-unread (&optional all)
5990 "Limit the summary buffer to articles that are not marked as read.
5991 If ALL is non-nil, limit strictly to unread articles."
5994 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5995 (gnus-summary-limit-to-marks
5996 ;; Concat all the marks that say that an article is read and have
5998 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5999 gnus-killed-mark gnus-kill-file-mark
6000 gnus-low-score-mark gnus-expirable-mark
6001 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6002 gnus-duplicate-mark gnus-souped-mark)
6005 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6006 (make-obsolete 'gnus-summary-delete-marked-with
6007 'gnus-summary-limit-exlude-marks)
6009 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6010 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6011 If REVERSE, limit the summary buffer to articles that are marked
6012 with MARKS. MARKS can either be a string of marks or a list of marks.
6013 Returns how many articles were removed."
6014 (interactive "sMarks: ")
6015 (gnus-summary-limit-to-marks marks t))
6017 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6018 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6019 If REVERSE (the prefix), limit the summary buffer to articles that are
6020 not marked with MARKS. MARKS can either be a string of marks or a
6022 Returns how many articles were removed."
6023 (interactive "sMarks: \nP")
6025 (let ((data gnus-newsgroup-data)
6026 (marks (if (listp marks) marks
6027 (append marks nil))) ; Transform to list.
6030 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6031 (memq (gnus-data-mark (car data)) marks))
6032 (push (gnus-data-number (car data)) articles))
6033 (setq data (cdr data)))
6034 (gnus-summary-limit articles))
6035 (gnus-summary-position-point)))
6037 (defun gnus-summary-limit-to-score (&optional score)
6038 "Limit to articles with score at or above SCORE."
6040 (setq score (if score
6041 (prefix-numeric-value score)
6042 (or gnus-summary-default-score 0)))
6043 (let ((data gnus-newsgroup-data)
6046 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6048 (push (gnus-data-number (car data)) articles))
6049 (setq data (cdr data)))
6051 (gnus-summary-limit articles)
6052 (gnus-summary-position-point))))
6054 (defun gnus-summary-limit-include-thread (id)
6055 "Display all the hidden articles that in the current thread."
6056 (interactive (list (mail-header-id (gnus-summary-article-header))))
6057 (let ((articles (gnus-articles-in-thread
6058 (gnus-id-to-thread (gnus-root-id id)))))
6060 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6061 (gnus-summary-position-point))))
6063 (defun gnus-summary-limit-include-dormant ()
6064 "Display all the hidden articles that are marked as dormant.
6065 Note that this command only works on a subset of the articles currently
6066 fetched for this group."
6068 (unless gnus-newsgroup-dormant
6069 (error "There are no dormant articles in this group"))
6071 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6072 (gnus-summary-position-point)))
6074 (defun gnus-summary-limit-exclude-dormant ()
6075 "Hide all dormant articles."
6078 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6079 (gnus-summary-position-point)))
6081 (defun gnus-summary-limit-exclude-childless-dormant ()
6082 "Hide all dormant articles that have no children."
6084 (let ((data (gnus-data-list t))
6085 articles d children)
6086 ;; Find all articles that are either not dormant or have
6088 (while (setq d (pop data))
6089 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6091 (gnus-article-children (gnus-data-number d)))
6094 (when (memq (car children) articles)
6099 (push (gnus-data-number d) articles)))
6102 (gnus-summary-limit articles)
6103 (gnus-summary-position-point))))
6105 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6106 "Mark all unread excluded articles as read.
6107 If ALL, mark even excluded ticked and dormants as read."
6109 (let ((articles (gnus-sorted-complement
6111 (mapcar (lambda (h) (mail-header-number h))
6112 gnus-newsgroup-headers)
6114 (sort gnus-newsgroup-limit '<)))
6116 (setq gnus-newsgroup-unreads
6117 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6119 (setq gnus-newsgroup-dormant nil
6120 gnus-newsgroup-marked nil
6121 gnus-newsgroup-reads
6123 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6124 gnus-newsgroup-reads))
6125 (while (setq article (pop articles))
6126 (unless (or (memq article gnus-newsgroup-dormant)
6127 (memq article gnus-newsgroup-marked))
6128 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6130 (defun gnus-summary-limit (articles &optional pop)
6132 ;; We pop the previous limit off the stack and use that.
6133 (setq articles (car gnus-newsgroup-limits)
6134 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6135 ;; We use the new limit, so we push the old limit on the stack.
6136 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6138 (setq gnus-newsgroup-limit articles)
6139 (let ((total (length gnus-newsgroup-data))
6140 (data (gnus-data-find-list (gnus-summary-article-number)))
6141 (gnus-summary-mark-below nil) ; Inhibit this.
6143 ;; This will do all the work of generating the new summary buffer
6144 ;; according to the new limit.
6145 (gnus-summary-prepare)
6146 ;; Hide any threads, possibly.
6147 (and gnus-show-threads
6148 gnus-thread-hide-subtree
6149 (gnus-summary-hide-all-threads))
6150 ;; Try to return to the article you were at, or one in the
6153 ;; We try to find some article after the current one.
6155 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6158 (setq data (cdr data))))
6160 ;; If there is no data, that means that we were after the last
6161 ;; article. The same goes when we can't find any articles
6162 ;; after the current one.
6163 (goto-char (point-max))
6164 (gnus-summary-find-prev))
6165 (gnus-set-mode-line 'summary)
6166 ;; We return how many articles were removed from the summary
6167 ;; buffer as a result of the new limit.
6168 (- total (length gnus-newsgroup-data))))
6170 (defsubst gnus-invisible-cut-children (threads)
6173 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6178 (defsubst gnus-cut-thread (thread)
6179 "Go forwards in the thread until we find an article that we want to display."
6180 (when (or (eq gnus-fetch-old-headers 'some)
6181 (eq gnus-fetch-old-headers 'invisible)
6182 (eq gnus-build-sparse-threads 'some)
6183 (eq gnus-build-sparse-threads 'more))
6184 ;; Deal with old-fetched headers and sparse threads.
6188 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6189 (gnus-summary-article-ancient-p
6190 (mail-header-number (car thread))))
6191 (if (or (<= (length (cdr thread)) 1)
6192 (eq gnus-fetch-old-headers 'invisible))
6193 (setq gnus-newsgroup-limit
6194 (delq (mail-header-number (car thread))
6195 gnus-newsgroup-limit)
6196 thread (cadr thread))
6197 (when (gnus-invisible-cut-children (cdr thread))
6198 (let ((th (cdr thread)))
6200 (if (memq (mail-header-number (caar th))
6201 gnus-newsgroup-limit)
6202 (setq thread (car th)
6204 (setq th (cdr th))))))))))
6207 (defun gnus-cut-threads (threads)
6208 "Cut off all uninteresting articles from the beginning of threads."
6209 (when (or (eq gnus-fetch-old-headers 'some)
6210 (eq gnus-fetch-old-headers 'invisible)
6211 (eq gnus-build-sparse-threads 'some)
6212 (eq gnus-build-sparse-threads 'more))
6215 (setcar th (gnus-cut-thread (car th)))
6216 (setq th (cdr th)))))
6217 ;; Remove nixed out threads.
6220 (defun gnus-summary-initial-limit (&optional show-if-empty)
6221 "Figure out what the initial limit is supposed to be on group entry.
6222 This entails weeding out unwanted dormants, low-scored articles,
6223 fetch-old-headers verbiage, and so on."
6224 ;; Most groups have nothing to remove.
6225 (if (or gnus-inhibit-limiting
6226 (and (null gnus-newsgroup-dormant)
6227 (not (eq gnus-fetch-old-headers 'some))
6228 (not (eq gnus-fetch-old-headers 'invisible))
6229 (null gnus-summary-expunge-below)
6230 (not (eq gnus-build-sparse-threads 'some))
6231 (not (eq gnus-build-sparse-threads 'more))
6232 (null gnus-thread-expunge-below)
6233 (not gnus-use-nocem)))
6235 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6236 (setq gnus-newsgroup-limit nil)
6239 (unless (car (symbol-value node))
6240 ;; These threads have no parents -- they are roots.
6241 (let ((nodes (cdr (symbol-value node)))
6244 (if (and gnus-thread-expunge-below
6245 (< (gnus-thread-total-score (car nodes))
6246 gnus-thread-expunge-below))
6247 (gnus-expunge-thread (pop nodes))
6248 (setq thread (pop nodes))
6249 (gnus-summary-limit-children thread))))))
6250 gnus-newsgroup-dependencies)
6251 ;; If this limitation resulted in an empty group, we might
6252 ;; pop the previous limit and use it instead.
6253 (when (and (not gnus-newsgroup-limit)
6255 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6256 gnus-newsgroup-limit))
6258 (defun gnus-summary-limit-children (thread)
6259 "Return 1 if this subthread is visible and 0 if it is not."
6260 ;; First we get the number of visible children to this thread. This
6261 ;; is done by recursing down the thread using this function, so this
6262 ;; will really go down to a leaf article first, before slowly
6263 ;; working its way up towards the root.
6267 (apply '+ (mapcar 'gnus-summary-limit-children
6270 (number (mail-header-number (car thread)))
6273 (not (memq number gnus-newsgroup-marked))
6275 ;; If this article is dormant and has absolutely no visible
6276 ;; children, then this article isn't visible.
6277 (and (memq number gnus-newsgroup-dormant)
6279 ;; If this is "fetch-old-headered" and there is no
6280 ;; visible children, then we don't want this article.
6281 (and (eq gnus-fetch-old-headers 'some)
6282 (gnus-summary-article-ancient-p number)
6284 ;; If this is "fetch-old-headered" and `invisible', then
6285 ;; we don't want this article.
6286 (and (eq gnus-fetch-old-headers 'invisible)
6287 (gnus-summary-article-ancient-p number))
6288 ;; If this is a sparsely inserted article with no children,
6289 ;; we don't want it.
6290 (and (eq gnus-build-sparse-threads 'some)
6291 (gnus-summary-article-sparse-p number)
6293 ;; If we use expunging, and this article is really
6294 ;; low-scored, then we don't want this article.
6295 (when (and gnus-summary-expunge-below
6297 (or (cdr (assq number gnus-newsgroup-scored))
6298 gnus-summary-default-score))
6299 gnus-summary-expunge-below))
6300 ;; We increase the expunge-tally here, but that has
6301 ;; nothing to do with the limits, really.
6302 (incf gnus-newsgroup-expunged-tally)
6303 ;; We also mark as read here, if that's wanted.
6304 (when (and gnus-summary-mark-below
6305 (< score gnus-summary-mark-below))
6306 (setq gnus-newsgroup-unreads
6307 (delq number gnus-newsgroup-unreads))
6308 (if gnus-newsgroup-auto-expire
6309 (push number gnus-newsgroup-expirable)
6310 (push (cons number gnus-low-score-mark)
6311 gnus-newsgroup-reads)))
6313 ;; Check NoCeM things.
6314 (if (and gnus-use-nocem
6315 (gnus-nocem-unwanted-article-p
6316 (mail-header-id (car thread))))
6318 (setq gnus-newsgroup-unreads
6319 (delq number gnus-newsgroup-unreads))
6321 ;; Nope, invisible article.
6323 ;; Ok, this article is to be visible, so we add it to the limit
6325 (push number gnus-newsgroup-limit)
6328 (defun gnus-expunge-thread (thread)
6329 "Mark all articles in THREAD as read."
6330 (let* ((number (mail-header-number (car thread))))
6331 (incf gnus-newsgroup-expunged-tally)
6332 ;; We also mark as read here, if that's wanted.
6333 (setq gnus-newsgroup-unreads
6334 (delq number gnus-newsgroup-unreads))
6335 (if gnus-newsgroup-auto-expire
6336 (push number gnus-newsgroup-expirable)
6337 (push (cons number gnus-low-score-mark)
6338 gnus-newsgroup-reads)))
6339 ;; Go recursively through all subthreads.
6340 (mapcar 'gnus-expunge-thread (cdr thread)))
6342 ;; Summary article oriented commands
6344 (defun gnus-summary-refer-parent-article (n)
6345 "Refer parent article N times.
6346 If N is negative, go to ancestor -N instead.
6347 The difference between N and the number of articles fetched is returned."
6351 (when (not (natnump n))
6356 (setq header (gnus-summary-article-header))
6357 (if (and (eq (mail-header-number header)
6358 (cdr gnus-article-current))
6359 (equal gnus-newsgroup-name
6360 (car gnus-article-current)))
6361 ;; If we try to find the parent of the currently
6362 ;; displayed article, then we take a look at the actual
6363 ;; References header, since this is slightly more
6364 ;; reliable than the References field we got from the
6367 (set-buffer gnus-original-article-buffer)
6368 (nnheader-narrow-to-headers)
6369 (unless (setq ref (message-fetch-field "references"))
6370 (setq ref (message-fetch-field "in-reply-to")))
6373 ;; It's not the current article, so we take a bet on
6374 ;; the value we got from the server.
6375 (mail-header-references header)))
6377 (not (equal ref "")))
6378 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6379 (gnus-message 1 "Couldn't find parent"))
6380 (gnus-message 1 "No references in article %d"
6381 (gnus-summary-article-number))
6384 (gnus-summary-position-point)
6387 (defun gnus-summary-refer-references ()
6388 "Fetch all articles mentioned in the References header.
6389 Return the number of articles fetched."
6391 (let ((ref (mail-header-references (gnus-summary-article-header)))
6392 (current (gnus-summary-article-number))
6396 (error "No References in the current article")
6397 ;; For each Message-ID in the References header...
6398 (while (string-match "<[^>]*>" ref)
6400 ;; ... fetch that article.
6401 (gnus-summary-refer-article
6402 (prog1 (match-string 0 ref)
6403 (setq ref (substring ref (match-end 0))))))
6404 (gnus-summary-goto-subject current)
6405 (gnus-summary-position-point)
6408 (defun gnus-summary-refer-thread (&optional limit)
6409 "Fetch all articles in the current thread.
6410 If LIMIT (the numerical prefix), fetch that many old headers instead
6411 of what's specified by the `gnus-refer-thread-limit' variable."
6413 (let ((id (mail-header-id (gnus-summary-article-header)))
6414 (limit (if limit (prefix-numeric-value limit)
6415 gnus-refer-thread-limit)))
6416 ;; We want to fetch LIMIT *old* headers, but we also have to
6417 ;; re-fetch all the headers in the current buffer, because many of
6418 ;; them may be undisplayed. So we adjust LIMIT.
6419 (when (numberp limit)
6420 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6421 (unless (eq gnus-fetch-old-headers 'invisible)
6422 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6423 ;; Retrieve the headers and read them in.
6424 (if (eq (gnus-retrieve-headers
6425 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6427 (gnus-build-all-threads)
6428 (error "Can't fetch thread from backends that don't support NOV"))
6429 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6430 (gnus-summary-limit-include-thread id)))
6432 (defun gnus-summary-refer-article (message-id &optional arg)
6433 "Fetch an article specified by MESSAGE-ID.
6434 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6435 or `gnus-select-method', no matter what backend the article comes from."
6436 (interactive "sMessage-ID: \nP")
6437 (when (and (stringp message-id)
6438 (not (zerop (length message-id))))
6439 ;; Construct the correct Message-ID if necessary.
6440 ;; Suggested by tale@pawl.rpi.edu.
6441 (unless (string-match "^<" message-id)
6442 (setq message-id (concat "<" message-id)))
6443 (unless (string-match ">$" message-id)
6444 (setq message-id (concat message-id ">")))
6445 (let* ((header (gnus-id-to-header message-id))
6447 (gnus-summary-article-sparse-p
6448 (mail-header-number header))
6449 (memq (mail-header-number header)
6450 gnus-newsgroup-limit))))
6452 ;; If the article is present in the buffer we just go to it.
6454 (or (not (gnus-summary-article-sparse-p
6455 (mail-header-number header)))
6458 (gnus-summary-goto-article
6459 (mail-header-number header) nil t)
6461 (gnus-summary-update-article (mail-header-number header)))))
6463 ;; We fetch the article
6464 (let ((gnus-override-method
6465 (cond ((gnus-news-group-p gnus-newsgroup-name)
6466 gnus-refer-article-method)
6468 (or gnus-refer-article-method gnus-select-method))
6471 ;; Start the special refer-article method, if necessary.
6472 (when (and gnus-refer-article-method
6473 (gnus-news-group-p gnus-newsgroup-name))
6474 (gnus-check-server gnus-refer-article-method))
6475 ;; Fetch the header, and display the article.
6476 (if (setq number (gnus-summary-insert-subject message-id))
6477 (gnus-summary-select-article nil nil nil number)
6478 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6480 (defun gnus-summary-edit-parameters ()
6481 "Edit the group parameters of the current group."
6483 (gnus-group-edit-group gnus-newsgroup-name 'params))
6485 (defun gnus-summary-enter-digest-group (&optional force)
6486 "Enter an nndoc group based on the current article.
6487 If FORCE, force a digest interpretation. If not, try
6488 to guess what the document format is."
6490 (let ((conf gnus-current-window-configuration))
6492 (gnus-summary-select-article))
6493 (setq gnus-current-window-configuration conf)
6494 (let* ((name (format "%s-%d"
6495 (gnus-group-prefixed-name
6496 gnus-newsgroup-name (list 'nndoc ""))
6498 (set-buffer gnus-summary-buffer)
6499 gnus-current-article)))
6500 (ogroup gnus-newsgroup-name)
6501 (params (append (gnus-info-params (gnus-get-info ogroup))
6502 (list (cons 'to-group ogroup))
6503 (list (cons 'save-article-group ogroup))))
6504 (case-fold-search t)
6505 (buf (current-buffer))
6508 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6509 (insert-buffer-substring gnus-original-article-buffer)
6510 ;; Remove lines that may lead nndoc to misinterpret the
6513 (goto-char (point-min))
6514 (or (search-forward "\n\n" nil t) (point)))
6515 (goto-char (point-min))
6516 (delete-matching-lines "^\\(Path\\):\\|^From ")
6519 (if (gnus-group-read-ephemeral-group
6520 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6522 ,(if force 'digest 'guess))) t)
6523 ;; Make all postings to this group go to the parent group.
6524 (nconc (gnus-info-params (gnus-get-info name))
6526 ;; Couldn't select this doc group.
6527 (switch-to-buffer buf)
6528 (gnus-set-global-variables)
6529 (gnus-configure-windows 'summary)
6530 (gnus-message 3 "Article couldn't be entered?"))
6531 (kill-buffer dig)))))
6533 (defun gnus-summary-read-document (n)
6534 "Open a new group based on the current article(s).
6535 This will allow you to read digests and other similar
6536 documents as newsgroups.
6537 Obeys the standard process/prefix convention."
6539 (let* ((articles (gnus-summary-work-articles n))
6540 (ogroup gnus-newsgroup-name)
6541 (params (append (gnus-info-params (gnus-get-info ogroup))
6542 (list (cons 'to-group ogroup))))
6543 article group egroup groups vgroup)
6544 (while (setq article (pop articles))
6545 (setq group (format "%s-%d" gnus-newsgroup-name article))
6546 (gnus-summary-remove-process-mark article)
6547 (when (gnus-summary-display-article article)
6550 (insert-buffer-substring gnus-original-article-buffer)
6551 ;; Remove some headers that may lead nndoc to make
6553 (message-narrow-to-head)
6554 (goto-char (point-min))
6555 (delete-matching-lines "^\\(Path\\):\\|^From ")
6558 (gnus-group-read-ephemeral-group
6559 group `(nndoc ,group (nndoc-address ,(current-buffer))
6560 (nndoc-article-type guess))
6563 ;; Make all postings to this group go to the parent group.
6564 (nconc (gnus-info-params (gnus-get-info egroup))
6566 (push egroup groups))
6567 ;; Couldn't select this doc group.
6568 (gnus-error 3 "Article couldn't be entered"))))))
6569 ;; Now we have selected all the documents.
6572 (error "None of the articles could be interpreted as documents"))
6573 ((gnus-group-read-ephemeral-group
6574 (setq vgroup (format
6575 "nnvirtual:%s-%s" gnus-newsgroup-name
6576 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6577 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6579 (cons (current-buffer) 'summary)))
6581 (error "Couldn't select virtual nndoc group")))))
6583 (defun gnus-summary-isearch-article (&optional regexp-p)
6584 "Do incremental search forward on the current article.
6585 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6587 (gnus-summary-select-article)
6588 (gnus-configure-windows 'article)
6589 (gnus-eval-in-buffer-window gnus-article-buffer
6592 (isearch-forward regexp-p))))
6594 (defun gnus-summary-search-article-forward (regexp &optional backward)
6595 "Search for an article containing REGEXP forward.
6596 If BACKWARD, search backward instead."
6599 (format "Search article %s (regexp%s): "
6600 (if current-prefix-arg "backward" "forward")
6601 (if gnus-last-search-regexp
6602 (concat ", default " gnus-last-search-regexp)
6604 current-prefix-arg))
6605 (if (string-equal regexp "")
6606 (setq regexp (or gnus-last-search-regexp ""))
6607 (setq gnus-last-search-regexp regexp))
6608 (if (gnus-summary-search-article regexp backward)
6609 (gnus-summary-show-thread)
6610 (error "Search failed: \"%s\"" regexp)))
6612 (defun gnus-summary-search-article-backward (regexp)
6613 "Search for an article containing REGEXP backward."
6616 (format "Search article backward (regexp%s): "
6617 (if gnus-last-search-regexp
6618 (concat ", default " gnus-last-search-regexp)
6620 (gnus-summary-search-article-forward regexp 'backward))
6622 (defun gnus-summary-search-article (regexp &optional backward)
6623 "Search for an article containing REGEXP.
6624 Optional argument BACKWARD means do search for backward.
6625 `gnus-select-article-hook' is not called during the search."
6626 ;; We have to require this here to make sure that the following
6627 ;; dynamic binding isn't shadowed by autoloading.
6628 (require 'gnus-async)
6629 (let ((gnus-select-article-hook nil) ;Disable hook.
6630 (gnus-article-display-hook nil)
6631 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6632 (gnus-use-article-prefetch nil)
6633 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6634 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6635 (sum (current-buffer))
6638 (gnus-save-hidden-threads
6639 (gnus-summary-select-article)
6640 (set-buffer gnus-article-buffer)
6644 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6646 (re-search-backward regexp nil t)
6647 (re-search-forward regexp nil t))
6648 ;; We found the regexp.
6653 (get-buffer-window (current-buffer))
6657 (setq point (point)))
6658 ;; We didn't find it, so we go to the next article.
6661 (while (eq found 'not)
6662 (if (not (if backward (gnus-summary-find-prev)
6663 (gnus-summary-find-next)))
6664 ;; No more articles.
6666 ;; Select the next article and adjust point.
6667 (unless (gnus-summary-article-sparse-p
6668 (gnus-summary-article-number))
6670 (gnus-summary-select-article)
6671 (set-buffer gnus-article-buffer)
6673 (goto-char (if backward (point-max) (point-min))))))))
6674 (gnus-message 7 ""))
6675 ;; Return whether we found the regexp.
6676 (when (eq found 'found)
6678 (gnus-summary-show-thread)
6679 (gnus-summary-goto-subject gnus-current-article)
6680 (gnus-summary-position-point)
6683 (defun gnus-summary-find-matching (header regexp &optional backward unread
6685 "Return a list of all articles that match REGEXP on HEADER.
6686 The search stars on the current article and goes forwards unless
6687 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6688 If UNREAD is non-nil, only unread articles will
6689 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6690 in the comparisons."
6691 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6692 (gnus-data-find-list
6693 (gnus-summary-article-number) (gnus-data-list backward))))
6694 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6695 (case-fold-search (not not-case-fold))
6697 (unless (fboundp (intern (concat "mail-header-" header)))
6698 (error "%s is not a valid header" header))
6701 (and (or (not unread) ; We want all articles...
6702 (gnus-data-unread-p d)) ; Or just unreads.
6703 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6704 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6705 (push (gnus-data-number d) articles)) ; Success!
6706 (setq data (cdr data)))
6707 (nreverse articles)))
6709 (defun gnus-summary-execute-command (header regexp command &optional backward)
6710 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6711 If HEADER is an empty string (or nil), the match is done on the entire
6712 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6714 (list (let ((completion-ignore-case t))
6717 (mapcar (lambda (string) (list string))
6718 '("Number" "Subject" "From" "Lines" "Date"
6719 "Message-ID" "Xref" "References" "Body"))
6720 nil 'require-match))
6721 (read-string "Regexp: ")
6722 (read-key-sequence "Command: ")
6723 current-prefix-arg))
6724 (when (equal header "Body")
6726 ;; Hidden thread subtrees must be searched as well.
6727 (gnus-summary-show-all-threads)
6728 ;; We don't want to change current point nor window configuration.
6730 (save-window-excursion
6731 (gnus-message 6 "Executing %s..." (key-description command))
6732 ;; We'd like to execute COMMAND interactively so as to give arguments.
6733 (gnus-execute header regexp
6734 `(call-interactively ',(key-binding command))
6736 (gnus-message 6 "Executing %s...done" (key-description command)))))
6738 (defun gnus-summary-beginning-of-article ()
6739 "Scroll the article back to the beginning."
6741 (gnus-summary-select-article)
6742 (gnus-configure-windows 'article)
6743 (gnus-eval-in-buffer-window gnus-article-buffer
6745 (goto-char (point-min))
6746 (when gnus-page-broken
6747 (gnus-narrow-to-page))))
6749 (defun gnus-summary-end-of-article ()
6750 "Scroll to the end of the article."
6752 (gnus-summary-select-article)
6753 (gnus-configure-windows 'article)
6754 (gnus-eval-in-buffer-window gnus-article-buffer
6756 (goto-char (point-max))
6758 (when gnus-page-broken
6759 (gnus-narrow-to-page))))
6761 (defun gnus-summary-print-article (&optional filename n)
6762 "Generate and print a PostScript image of the N next (mail) articles.
6764 If N is negative, print the N previous articles. If N is nil and articles
6765 have been marked with the process mark, print these instead.
6767 If the optional second argument FILENAME is nil, send the image to the
6768 printer. If FILENAME is a string, save the PostScript image in a file with
6769 that name. If FILENAME is a number, prompt the user for the name of the file
6771 (interactive (list (ps-print-preprint current-prefix-arg)
6772 current-prefix-arg))
6773 (dolist (article (gnus-summary-work-articles n))
6774 (gnus-summary-select-article nil nil 'pseudo article)
6775 (gnus-eval-in-buffer-window gnus-article-buffer
6776 (let ((buffer (generate-new-buffer " *print*")))
6779 (copy-to-buffer buffer (point-min) (point-max))
6781 (gnus-article-delete-invisible-text)
6782 (let ((ps-left-header
6785 (mail-header-subject gnus-current-headers) ")")
6787 (mail-header-from gnus-current-headers) ")")))
6790 "/pagenumberstring load"
6792 (mail-header-date gnus-current-headers) ")"))))
6793 (gnus-run-hooks 'gnus-ps-print-hook)
6795 (ps-print-buffer-with-faces filename))))
6796 (kill-buffer buffer))))))
6798 (defun gnus-summary-show-article (&optional arg)
6799 "Force re-fetching of the current article.
6800 If ARG (the prefix) is non-nil, show the raw article without any
6801 article massaging functions being run."
6804 ;; Select the article the normal way.
6805 (gnus-summary-select-article nil 'force)
6806 ;; Bind the article treatment functions to nil.
6807 (let ((gnus-have-all-headers t)
6808 gnus-article-display-hook
6809 gnus-article-prepare-hook
6810 gnus-article-decode-hook
6814 (gnus-summary-select-article nil 'force)))
6815 (gnus-summary-goto-subject gnus-current-article)
6816 (gnus-summary-position-point))
6818 (defun gnus-summary-verbose-headers (&optional arg)
6819 "Toggle permanent full header display.
6820 If ARG is a positive number, turn header display on.
6821 If ARG is a negative number, turn header display off."
6823 (setq gnus-show-all-headers
6824 (cond ((or (not (numberp arg))
6826 (not gnus-show-all-headers))
6829 (gnus-summary-show-article))
6831 (defun gnus-summary-toggle-header (&optional arg)
6832 "Show the headers if they are hidden, or hide them if they are shown.
6833 If ARG is a positive number, show the entire header.
6834 If ARG is a negative number, hide the unwanted header lines."
6837 (set-buffer gnus-article-buffer)
6838 (let* ((buffer-read-only nil)
6839 (inhibit-point-motion-hooks t)
6840 (hidden (text-property-any
6841 (goto-char (point-min)) (search-forward "\n\n")
6844 (goto-char (point-min))
6845 (when (search-forward "\n\n" nil t)
6846 (delete-region (point-min) (1- (point))))
6847 (goto-char (point-min))
6849 (set-buffer gnus-original-article-buffer)
6850 (goto-char (point-min))
6851 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6852 (insert-buffer-substring gnus-original-article-buffer 1 e)
6853 (let ((article-inhibit-hiding t))
6854 (gnus-run-hooks 'gnus-article-display-hook))
6855 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6856 (gnus-article-hide-headers)))))
6858 (defun gnus-summary-show-all-headers ()
6859 "Make all header lines visible."
6861 (gnus-article-show-all-headers))
6863 (defun gnus-summary-toggle-mime (&optional arg)
6864 "Toggle MIME processing.
6865 If ARG is a positive number, turn MIME processing on."
6867 (setq gnus-show-mime
6868 (if (null arg) (not gnus-show-mime)
6869 (> (prefix-numeric-value arg) 0)))
6870 (gnus-summary-select-article t 'force))
6872 (defun gnus-summary-caesar-message (&optional arg)
6873 "Caesar rotate the current article by 13.
6874 The numerical prefix specifies how many places to rotate each letter
6877 (gnus-summary-select-article)
6878 (let ((mail-header-separator ""))
6879 (gnus-eval-in-buffer-window gnus-article-buffer
6882 (let ((start (window-start))
6884 (message-caesar-buffer-body arg)
6885 (set-window-start (get-buffer-window (current-buffer)) start))))))
6887 (defun gnus-summary-stop-page-breaking ()
6888 "Stop page breaking in the current article."
6890 (gnus-summary-select-article)
6891 (gnus-eval-in-buffer-window gnus-article-buffer
6893 (when (gnus-visual-p 'page-marker)
6894 (let ((buffer-read-only nil))
6895 (gnus-remove-text-with-property 'gnus-prev)
6896 (gnus-remove-text-with-property 'gnus-next))
6897 (setq gnus-page-broken nil))))
6899 (defun gnus-summary-move-article (&optional n to-newsgroup
6900 select-method action)
6901 "Move the current article to a different newsgroup.
6902 If N is a positive number, move the N next articles.
6903 If N is a negative number, move the N previous articles.
6904 If N is nil and any articles have been marked with the process mark,
6905 move those articles instead.
6906 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6907 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6908 re-spool using this method.
6910 For this function to work, both the current newsgroup and the
6911 newsgroup that you want to move to have to support the `request-move'
6912 and `request-accept' functions."
6915 (setq action 'move))
6916 ;; Disable marking as read.
6917 (let (gnus-mark-article-hook)
6918 (save-window-excursion
6919 (gnus-summary-select-article)))
6920 ;; Check whether the source group supports the required functions.
6921 (cond ((and (eq action 'move)
6922 (not (gnus-check-backend-function
6923 'request-move-article gnus-newsgroup-name)))
6924 (error "The current group does not support article moving"))
6925 ((and (eq action 'crosspost)
6926 (not (gnus-check-backend-function
6927 'request-replace-article gnus-newsgroup-name)))
6928 (error "The current group does not support article editing")))
6929 (let ((articles (gnus-summary-work-articles n))
6930 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6931 (names '((move "Move" "Moving")
6932 (copy "Copy" "Copying")
6933 (crosspost "Crosspost" "Crossposting")))
6934 (copy-buf (save-excursion
6935 (nnheader-set-temp-buffer " *copy article*")))
6936 art-group to-method new-xref article to-groups)
6937 (unless (assq action names)
6938 (error "Unknown action %s" action))
6939 ;; Read the newsgroup name.
6940 (when (and (not to-newsgroup)
6941 (not select-method))
6943 (gnus-read-move-group-name
6944 (cadr (assq action names))
6945 (symbol-value (intern (format "gnus-current-%s-group" action)))
6947 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6948 (setq to-method (or select-method
6949 (gnus-group-name-to-method to-newsgroup)))
6950 ;; Check the method we are to move this article to...
6951 (unless (gnus-check-backend-function
6952 'request-accept-article (car to-method))
6953 (error "%s does not support article copying" (car to-method)))
6954 (unless (gnus-check-server to-method)
6955 (error "Can't open server %s" (car to-method)))
6956 (gnus-message 6 "%s to %s: %s..."
6957 (caddr (assq action names))
6958 (or (car select-method) to-newsgroup) articles)
6960 (setq article (pop articles))
6964 ;; Move the article.
6966 ;; Remove this article from future suppression.
6967 (gnus-dup-unsuppress-article article)
6968 (gnus-request-move-article
6969 article ; Article to move
6970 gnus-newsgroup-name ; From newsgroup
6971 (nth 1 (gnus-find-method-for-group
6972 gnus-newsgroup-name)) ; Server
6973 (list 'gnus-request-accept-article
6974 to-newsgroup (list 'quote select-method)
6975 (not articles)) ; Accept form
6976 (not articles))) ; Only save nov last time
6977 ;; Copy the article.
6980 (set-buffer copy-buf)
6981 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6982 (gnus-request-accept-article
6983 to-newsgroup select-method (not articles) t))))
6984 ;; Crosspost the article.
6985 ((eq action 'crosspost)
6986 (let ((xref (message-tokenize-header
6987 (mail-header-xref (gnus-summary-article-header article))
6989 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6992 (setq xref (list (system-name))))
6995 (mapconcat 'identity
6996 (delete "Xref:" (delete new-xref xref))
7000 (set-buffer copy-buf)
7001 ;; First put the article in the destination group.
7002 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7003 (when (consp (setq art-group
7004 (gnus-request-accept-article
7005 to-newsgroup select-method (not articles))))
7006 (setq new-xref (concat new-xref " " (car art-group)
7007 ":" (cdr art-group)))
7008 ;; Now we have the new Xrefs header, so we insert
7009 ;; it and replace the new article.
7010 (nnheader-replace-header "Xref" new-xref)
7011 (gnus-request-replace-article
7012 (cdr art-group) to-newsgroup (current-buffer))
7016 (gnus-message 1 "Couldn't %s article %s"
7017 (cadr (assq action names)) article))
7018 ((and (eq art-group 'junk)
7020 (gnus-summary-mark-article article gnus-canceled-mark)
7021 (gnus-message 4 "Deleted article %s" article))
7023 (let* ((pto-group (gnus-group-prefixed-name
7024 (car art-group) to-method))
7026 (gnus-gethash pto-group gnus-newsrc-hashtb))
7027 (info (nth 2 entry))
7028 (to-group (gnus-info-group info)))
7029 ;; Update the group that has been moved to.
7031 (memq action '(move copy)))
7032 (unless (member to-group to-groups)
7033 (push to-group to-groups))
7035 (unless (memq article gnus-newsgroup-unreads)
7037 info (gnus-add-to-range (gnus-info-read info)
7038 (list (cdr art-group)))))
7040 ;; Copy any marks over to the new group.
7041 (let ((marks gnus-article-mark-lists)
7042 (to-article (cdr art-group)))
7044 ;; See whether the article is to be put in the cache.
7045 (when gnus-use-cache
7046 (gnus-cache-possibly-enter-article
7048 (let ((header (copy-sequence
7049 (gnus-summary-article-header article))))
7050 (mail-header-set-number header to-article)
7052 (memq article gnus-newsgroup-marked)
7053 (memq article gnus-newsgroup-dormant)
7054 (memq article gnus-newsgroup-unreads)))
7056 (when (and (equal to-group gnus-newsgroup-name)
7057 (not (memq article gnus-newsgroup-unreads)))
7058 ;; Mark this article as read in this group.
7059 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7060 (setcdr (gnus-active to-group) to-article)
7061 (setcdr gnus-newsgroup-active to-article))
7064 (when (memq article (symbol-value
7065 (intern (format "gnus-newsgroup-%s"
7067 ;; If the other group is the same as this group,
7068 ;; then we have to add the mark to the list.
7069 (when (equal to-group gnus-newsgroup-name)
7070 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7073 (intern (format "gnus-newsgroup-%s"
7075 ;; Copy the marks to other group.
7076 (gnus-add-marked-articles
7077 to-group (cdar marks) (list to-article) info))
7078 (setq marks (cdr marks)))
7081 (concat "(gnus-group-set-info '"
7082 (gnus-prin1-to-string (gnus-get-info to-group))
7085 ;; Update the Xref header in this article to point to
7086 ;; the new crossposted article we have just created.
7087 (when (eq action 'crosspost)
7089 (set-buffer copy-buf)
7090 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7091 (nnheader-replace-header "Xref" new-xref)
7092 (gnus-request-replace-article
7093 article gnus-newsgroup-name (current-buffer)))))
7095 ;;;!!!Why is this necessary?
7096 (set-buffer gnus-summary-buffer)
7098 (gnus-summary-goto-subject article)
7099 (when (eq action 'move)
7100 (gnus-summary-mark-article article gnus-canceled-mark))))
7101 (gnus-summary-remove-process-mark article))
7102 ;; Re-activate all groups that have been moved to.
7105 (set-buffer gnus-group-buffer)
7106 (when (gnus-group-goto-group (car to-groups) t)
7107 (gnus-group-get-new-news-this-group 1 t))
7110 (gnus-kill-buffer copy-buf)
7111 (gnus-summary-position-point)
7112 (gnus-set-mode-line 'summary)))
7114 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7115 "Move the current article to a different newsgroup.
7116 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7117 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7118 re-spool using this method."
7120 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7122 (defun gnus-summary-crosspost-article (&optional n)
7123 "Crosspost the current article to some other group."
7125 (gnus-summary-move-article n nil nil 'crosspost))
7127 (defcustom gnus-summary-respool-default-method nil
7128 "Default method for respooling an article.
7129 If nil, use to the current newsgroup method."
7130 :type '(choice (gnus-select-method :value (nnml ""))
7132 :group 'gnus-summary-mail)
7134 (defun gnus-summary-respool-article (&optional n method)
7135 "Respool the current article.
7136 The article will be squeezed through the mail spooling process again,
7137 which means that it will be put in some mail newsgroup or other
7138 depending on `nnmail-split-methods'.
7139 If N is a positive number, respool the N next articles.
7140 If N is a negative number, respool the N previous articles.
7141 If N is nil and any articles have been marked with the process mark,
7142 respool those articles instead.
7144 Respooling can be done both from mail groups and \"real\" newsgroups.
7145 In the former case, the articles in question will be moved from the
7146 current group into whatever groups they are destined to. In the
7147 latter case, they will be copied into the relevant groups."
7149 (list current-prefix-arg
7150 (let* ((methods (gnus-methods-using 'respool))
7152 (symbol-name (or gnus-summary-respool-default-method
7153 (car (gnus-find-method-for-group
7154 gnus-newsgroup-name)))))
7156 (gnus-completing-read
7157 methname "What backend do you want to use when respooling?"
7158 methods nil t nil 'gnus-mail-method-history))
7161 ((zerop (length (setq ms (gnus-servers-using-backend
7163 (list (intern method) ""))
7167 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7168 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7171 (error "No method given for respooling"))
7172 (if (assoc (symbol-name
7173 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7174 (gnus-methods-using 'respool))
7175 (gnus-summary-move-article n nil method)
7176 (gnus-summary-copy-article n nil method)))
7178 (defun gnus-summary-import-article (file)
7179 "Import an arbitrary file into a mail newsgroup."
7180 (interactive "fImport file: ")
7181 (let ((group gnus-newsgroup-name)
7182 (now (current-time))
7184 (unless (gnus-check-backend-function 'request-accept-article group)
7185 (error "%s does not support article importing" group))
7186 (or (file-readable-p file)
7187 (not (file-regular-p file))
7188 (error "Can't read %s" file))
7190 (set-buffer (gnus-get-buffer-create " *import file*"))
7192 (nnheader-insert-file-contents file)
7193 (goto-char (point-min))
7194 (unless (nnheader-article-p)
7195 ;; This doesn't look like an article, so we fudge some headers.
7196 (setq atts (file-attributes file)
7197 lines (count-lines (point-min) (point-max)))
7198 (insert "From: " (read-string "From: ") "\n"
7199 "Subject: " (read-string "Subject: ") "\n"
7200 "Date: " (message-make-date (nth 5 atts))
7202 "Message-ID: " (message-make-message-id) "\n"
7203 "Lines: " (int-to-string lines) "\n"
7204 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7205 (gnus-request-accept-article group nil t)
7206 (kill-buffer (current-buffer)))))
7208 (defun gnus-summary-article-posted-p ()
7209 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7210 This will be the case if the article has both been mailed and posted."
7212 (let ((id (mail-header-references (gnus-summary-article-header)))
7213 (gnus-override-method
7214 (or gnus-refer-article-method gnus-select-method)))
7215 (if (gnus-request-head id "")
7216 (gnus-message 2 "The current message was found on %s"
7217 gnus-override-method)
7218 (gnus-message 2 "The current message couldn't be found on %s"
7219 gnus-override-method)
7222 (defun gnus-summary-expire-articles (&optional now)
7223 "Expire all articles that are marked as expirable in the current group."
7225 (when (gnus-check-backend-function
7226 'request-expire-articles gnus-newsgroup-name)
7227 ;; This backend supports expiry.
7228 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7229 (expirable (if total
7231 ;; We need to update the info for
7232 ;; this group for `gnus-list-of-read-articles'
7233 ;; to give us the right answer.
7234 (gnus-run-hooks 'gnus-exit-group-hook)
7235 (gnus-summary-update-info)
7236 (gnus-list-of-read-articles gnus-newsgroup-name))
7237 (setq gnus-newsgroup-expirable
7238 (sort gnus-newsgroup-expirable '<))))
7239 (expiry-wait (if now 'immediate
7240 (gnus-group-find-parameter
7241 gnus-newsgroup-name 'expiry-wait)))
7244 ;; There are expirable articles in this group, so we run them
7245 ;; through the expiry process.
7246 (gnus-message 6 "Expiring articles...")
7247 ;; The list of articles that weren't expired is returned.
7250 (let ((nnmail-expiry-wait-function nil)
7251 (nnmail-expiry-wait expiry-wait))
7252 (setq es (gnus-request-expire-articles
7253 expirable gnus-newsgroup-name)))
7254 (setq es (gnus-request-expire-articles
7255 expirable gnus-newsgroup-name))))
7257 (setq gnus-newsgroup-expirable es))
7258 ;; We go through the old list of expirable, and mark all
7259 ;; really expired articles as nonexistent.
7260 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7261 (let ((gnus-use-cache nil))
7263 (unless (memq (car expirable) es)
7264 (when (gnus-data-find (car expirable))
7265 (gnus-summary-mark-article
7266 (car expirable) gnus-canceled-mark)))
7267 (setq expirable (cdr expirable)))))
7268 (gnus-message 6 "Expiring articles...done")))))
7270 (defun gnus-summary-expire-articles-now ()
7271 "Expunge all expirable articles in the current group.
7272 This means that *all* articles that are marked as expirable will be
7273 deleted forever, right now."
7275 (or gnus-expert-user
7277 "Are you really, really, really sure you want to delete all these messages? ")
7279 (gnus-summary-expire-articles t))
7281 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7282 (defun gnus-summary-delete-article (&optional n)
7283 "Delete the N next (mail) articles.
7284 This command actually deletes articles. This is not a marking
7285 command. The article will disappear forever from your life, never to
7287 If N is negative, delete backwards.
7288 If N is nil and articles have been marked with the process mark,
7289 delete these instead."
7291 (unless (gnus-check-backend-function 'request-expire-articles
7292 gnus-newsgroup-name)
7293 (error "The current newsgroup does not support article deletion"))
7294 ;; Compute the list of articles to delete.
7295 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7297 (if (and gnus-novice-user
7298 (not (gnus-yes-or-no-p
7299 (format "Do you really want to delete %s forever? "
7300 (if (> (length articles) 1)
7301 (format "these %s articles" (length articles))
7304 ;; Delete the articles.
7305 (setq not-deleted (gnus-request-expire-articles
7306 articles gnus-newsgroup-name 'force))
7308 (gnus-summary-remove-process-mark (car articles))
7309 ;; The backend might not have been able to delete the article
7311 (unless (memq (car articles) not-deleted)
7312 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7313 (setq articles (cdr articles)))
7315 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7316 (gnus-summary-position-point)
7317 (gnus-set-mode-line 'summary)
7320 (defun gnus-summary-edit-article (&optional force)
7321 "Edit the current article.
7322 This will have permanent effect only in mail groups.
7323 If FORCE is non-nil, allow editing of articles even in read-only
7327 (set-buffer gnus-summary-buffer)
7328 (gnus-set-global-variables)
7329 (when (and (not force)
7330 (gnus-group-read-only-p))
7331 (error "The current newsgroup does not support article editing"))
7332 ;; Select article if needed.
7333 (unless (eq (gnus-summary-article-number)
7334 gnus-current-article)
7335 (gnus-summary-select-article t))
7336 (gnus-article-date-original)
7337 (gnus-article-edit-article
7338 `(lambda (no-highlight)
7339 (gnus-summary-edit-article-done
7340 ,(or (mail-header-references gnus-current-headers) "")
7341 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7343 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7345 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7347 "Make edits to the current article permanent."
7349 ;; Replace the article.
7350 (let ((buf (current-buffer)))
7353 (if (and (not read-only)
7354 (not (gnus-request-replace-article
7355 (cdr gnus-article-current) (car gnus-article-current)
7357 (not gnus-article-decoded-p))))
7358 (error "Couldn't replace article")
7359 ;; Update the summary buffer.
7361 (equal (message-tokenize-header references " ")
7362 (message-tokenize-header
7363 (or (message-fetch-field "references") "") " ")))
7364 ;; We only have to update this line.
7367 (message-narrow-to-head)
7368 (let ((head (buffer-string))
7371 (insert (format "211 %d Article retrieved.\n"
7372 (cdr gnus-article-current)))
7375 (let ((nntp-server-buffer (current-buffer)))
7376 (setq header (car (gnus-get-newsgroup-headers
7378 (set-buffer gnus-summary-buffer)
7379 gnus-newsgroup-dependencies)
7382 (set-buffer gnus-summary-buffer)
7383 (gnus-data-set-header
7384 (gnus-data-find (cdr gnus-article-current))
7386 (gnus-summary-update-article-line
7387 (cdr gnus-article-current) header))))))
7389 (set-buffer (or buffer gnus-summary-buffer))
7390 (gnus-summary-update-article (cdr gnus-article-current)))
7391 ;; Prettify the article buffer again.
7392 (unless no-highlight
7394 (set-buffer gnus-article-buffer)
7395 (gnus-run-hooks 'gnus-article-display-hook)
7396 (set-buffer gnus-original-article-buffer)
7397 (gnus-request-article
7398 (cdr gnus-article-current)
7399 (car gnus-article-current) (current-buffer))))
7400 ;; Prettify the summary buffer line.
7401 (when (gnus-visual-p 'summary-highlight 'highlight)
7402 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7404 (defun gnus-summary-edit-wash (key)
7405 "Perform editing command KEY in the article buffer."
7409 (message "%s" (concat (this-command-keys) "- "))
7412 (gnus-summary-edit-article)
7413 (execute-kbd-macro (concat (this-command-keys) key))
7414 (gnus-article-edit-done))
7418 (defun gnus-summary-respool-query (&optional silent trace)
7419 "Query where the respool algorithm would put this article."
7421 (let (gnus-mark-article-hook)
7422 (gnus-summary-select-article)
7424 (set-buffer gnus-original-article-buffer)
7426 (message-narrow-to-head)
7427 (let ((groups (nnmail-article-group 'identity trace)))
7430 (message "This message would go to %s"
7431 (mapconcat 'car groups ", "))
7432 (message "This message would go to no groups"))
7435 (defun gnus-summary-respool-trace ()
7436 "Trace where the respool algorithm would put this article.
7437 Display a buffer showing all fancy splitting patterns which matched."
7439 (gnus-summary-respool-query nil t))
7441 ;; Summary marking commands.
7443 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7444 "Mark articles which has the same subject as read, and then select the next.
7445 If UNMARK is positive, remove any kind of mark.
7446 If UNMARK is negative, tick articles."
7449 (setq unmark (prefix-numeric-value unmark)))
7451 (gnus-summary-mark-same-subject
7452 (gnus-summary-article-subject) unmark)))
7453 ;; Select next unread article. If auto-select-same mode, should
7454 ;; select the first unread article.
7455 (gnus-summary-next-article t (and gnus-auto-select-same
7456 (gnus-summary-article-subject)))
7457 (gnus-message 7 "%d article%s marked as %s"
7458 count (if (= count 1) " is" "s are")
7459 (if unmark "unread" "read"))))
7461 (defun gnus-summary-kill-same-subject (&optional unmark)
7462 "Mark articles which has the same subject as read.
7463 If UNMARK is positive, remove any kind of mark.
7464 If UNMARK is negative, tick articles."
7467 (setq unmark (prefix-numeric-value unmark)))
7469 (gnus-summary-mark-same-subject
7470 (gnus-summary-article-subject) unmark)))
7471 ;; If marked as read, go to next unread subject.
7473 ;; Go to next unread subject.
7474 (gnus-summary-next-subject 1 t))
7475 (gnus-message 7 "%d articles are marked as %s"
7476 count (if unmark "unread" "read"))))
7478 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7479 "Mark articles with same SUBJECT as read, and return marked number.
7480 If optional argument UNMARK is positive, remove any kinds of marks.
7481 If optional argument UNMARK is negative, mark articles as unread instead."
7485 ((null unmark) ; Mark as read.
7488 (gnus-summary-mark-article-as-read gnus-killed-mark)
7489 (gnus-summary-show-thread) t)
7490 (gnus-summary-find-subject subject))
7491 (setq count (1+ count))))
7492 ((> unmark 0) ; Tick.
7495 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7496 (gnus-summary-show-thread) t)
7497 (gnus-summary-find-subject subject))
7498 (setq count (1+ count))))
7499 (t ; Mark as unread.
7502 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7503 (gnus-summary-show-thread) t)
7504 (gnus-summary-find-subject subject))
7505 (setq count (1+ count)))))
7506 (gnus-set-mode-line 'summary)
7507 ;; Return the number of marked articles.
7510 (defun gnus-summary-mark-as-processable (n &optional unmark)
7511 "Set the process mark on the next N articles.
7512 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7513 the process mark instead. The difference between N and the actual
7514 number of articles marked is returned."
7516 (let ((backward (< n 0))
7521 (gnus-summary-remove-process-mark
7522 (gnus-summary-article-number))
7523 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7524 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7527 (gnus-message 7 "No more articles"))
7528 (gnus-summary-recenter)
7529 (gnus-summary-position-point)
7532 (defun gnus-summary-unmark-as-processable (n)
7533 "Remove the process mark from the next N articles.
7534 If N is negative, unmark backward instead. The difference between N and
7535 the actual number of articles unmarked is returned."
7537 (gnus-summary-mark-as-processable n t))
7539 (defun gnus-summary-unmark-all-processable ()
7540 "Remove the process mark from all articles."
7543 (while gnus-newsgroup-processable
7544 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7545 (gnus-summary-position-point))
7547 (defun gnus-summary-mark-as-expirable (n)
7548 "Mark N articles forward as expirable.
7549 If N is negative, mark backward instead. The difference between N and
7550 the actual number of articles marked is returned."
7552 (gnus-summary-mark-forward n gnus-expirable-mark))
7554 (defun gnus-summary-mark-article-as-replied (article)
7555 "Mark ARTICLE replied and update the summary line."
7556 (push article gnus-newsgroup-replied)
7557 (let ((buffer-read-only nil))
7558 (when (gnus-summary-goto-subject article nil t)
7559 (gnus-summary-update-secondary-mark article))))
7561 (defun gnus-summary-set-bookmark (article)
7562 "Set a bookmark in current article."
7563 (interactive (list (gnus-summary-article-number)))
7564 (when (or (not (get-buffer gnus-article-buffer))
7565 (not gnus-current-article)
7566 (not gnus-article-current)
7567 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7568 (error "No current article selected"))
7569 ;; Remove old bookmark, if one exists.
7570 (let ((old (assq article gnus-newsgroup-bookmarks)))
7572 (setq gnus-newsgroup-bookmarks
7573 (delq old gnus-newsgroup-bookmarks))))
7574 ;; Set the new bookmark, which is on the form
7575 ;; (article-number . line-number-in-body).
7579 (set-buffer gnus-article-buffer)
7583 (goto-char (point-min))
7584 (search-forward "\n\n" nil t)
7587 gnus-newsgroup-bookmarks)
7588 (gnus-message 6 "A bookmark has been added to the current article."))
7590 (defun gnus-summary-remove-bookmark (article)
7591 "Remove the bookmark from the current article."
7592 (interactive (list (gnus-summary-article-number)))
7593 ;; Remove old bookmark, if one exists.
7594 (let ((old (assq article gnus-newsgroup-bookmarks)))
7597 (setq gnus-newsgroup-bookmarks
7598 (delq old gnus-newsgroup-bookmarks))
7599 (gnus-message 6 "Removed bookmark."))
7600 (gnus-message 6 "No bookmark in current article."))))
7602 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7603 (defun gnus-summary-mark-as-dormant (n)
7604 "Mark N articles forward as dormant.
7605 If N is negative, mark backward instead. The difference between N and
7606 the actual number of articles marked is returned."
7608 (gnus-summary-mark-forward n gnus-dormant-mark))
7610 (defun gnus-summary-set-process-mark (article)
7611 "Set the process mark on ARTICLE and update the summary line."
7612 (setq gnus-newsgroup-processable
7614 (delq article gnus-newsgroup-processable)))
7615 (when (gnus-summary-goto-subject article)
7616 (gnus-summary-show-thread)
7617 (gnus-summary-goto-subject article)
7618 (gnus-summary-update-secondary-mark article)))
7620 (defun gnus-summary-remove-process-mark (article)
7621 "Remove the process mark from ARTICLE and update the summary line."
7622 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7623 (when (gnus-summary-goto-subject article)
7624 (gnus-summary-show-thread)
7625 (gnus-summary-goto-subject article)
7626 (gnus-summary-update-secondary-mark article)))
7628 (defun gnus-summary-set-saved-mark (article)
7629 "Set the process mark on ARTICLE and update the summary line."
7630 (push article gnus-newsgroup-saved)
7631 (when (gnus-summary-goto-subject article)
7632 (gnus-summary-update-secondary-mark article)))
7634 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7635 "Mark N articles as read forwards.
7636 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7637 The difference between N and the actual number of articles marked is
7640 (let ((backward (< n 0))
7641 (gnus-summary-goto-unread
7642 (and gnus-summary-goto-unread
7643 (not (eq gnus-summary-goto-unread 'never))
7644 (not (memq mark (list gnus-unread-mark
7645 gnus-ticked-mark gnus-dormant-mark)))))
7647 (mark (or mark gnus-del-mark)))
7649 (gnus-summary-mark-article nil mark no-expire)
7650 (zerop (gnus-summary-next-subject
7652 (and gnus-summary-goto-unread
7653 (not (eq gnus-summary-goto-unread 'never)))
7657 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7658 (gnus-summary-recenter)
7659 (gnus-summary-position-point)
7660 (gnus-set-mode-line 'summary)
7663 (defun gnus-summary-mark-article-as-read (mark)
7664 "Mark the current article quickly as read with MARK."
7665 (let ((article (gnus-summary-article-number)))
7666 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7667 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7668 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7669 (push (cons article mark) gnus-newsgroup-reads)
7670 ;; Possibly remove from cache, if that is used.
7671 (when gnus-use-cache
7672 (gnus-cache-enter-remove-article article))
7673 ;; Allow the backend to change the mark.
7674 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7675 ;; Check for auto-expiry.
7676 (when (and gnus-newsgroup-auto-expire
7677 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7678 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7679 (= mark gnus-ancient-mark)
7680 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7681 (= mark gnus-duplicate-mark)))
7682 (setq mark gnus-expirable-mark)
7683 ;; Let the backend know about the mark change.
7684 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7685 (push article gnus-newsgroup-expirable))
7686 ;; Set the mark in the buffer.
7687 (gnus-summary-update-mark mark 'unread)
7690 (defun gnus-summary-mark-article-as-unread (mark)
7691 "Mark the current article quickly as unread with MARK."
7692 (let* ((article (gnus-summary-article-number))
7693 (old-mark (gnus-summary-article-mark article)))
7694 ;; Allow the backend to change the mark.
7695 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7696 (if (eq mark old-mark)
7700 (gnus-error 1 "Can't mark negative article numbers")
7702 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7703 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7704 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7705 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7706 (cond ((= mark gnus-ticked-mark)
7707 (push article gnus-newsgroup-marked))
7708 ((= mark gnus-dormant-mark)
7709 (push article gnus-newsgroup-dormant))
7711 (push article gnus-newsgroup-unreads)))
7712 (gnus-pull article gnus-newsgroup-reads)
7714 ;; See whether the article is to be put in the cache.
7716 (vectorp (gnus-summary-article-header article))
7718 (gnus-cache-possibly-enter-article
7719 gnus-newsgroup-name article
7720 (gnus-summary-article-header article)
7721 (= mark gnus-ticked-mark)
7722 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7725 (gnus-summary-update-mark mark 'unread)
7728 (defun gnus-summary-mark-article (&optional article mark no-expire)
7729 "Mark ARTICLE with MARK. MARK can be any character.
7730 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7731 `??' (dormant) and `?E' (expirable).
7732 If MARK is nil, then the default character `?D' is used.
7733 If ARTICLE is nil, then the article on the current line will be
7735 ;; The mark might be a string.
7736 (when (stringp mark)
7737 (setq mark (aref mark 0)))
7738 ;; If no mark is given, then we check auto-expiring.
7739 (and (not no-expire)
7740 gnus-newsgroup-auto-expire
7742 (and (gnus-characterp mark)
7743 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7744 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7745 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7746 (= mark gnus-duplicate-mark))))
7747 (setq mark gnus-expirable-mark))
7748 (let* ((mark (or mark gnus-del-mark))
7749 (article (or article (gnus-summary-article-number)))
7750 (old-mark (gnus-summary-article-mark article)))
7751 ;; Allow the backend to change the mark.
7752 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7753 (if (eq mark old-mark)
7756 (error "No article on current line"))
7757 (if (not (if (or (= mark gnus-unread-mark)
7758 (= mark gnus-ticked-mark)
7759 (= mark gnus-dormant-mark))
7760 (gnus-mark-article-as-unread article mark)
7761 (gnus-mark-article-as-read article mark)))
7763 ;; See whether the article is to be put in the cache.
7765 (not (= mark gnus-canceled-mark))
7766 (vectorp (gnus-summary-article-header article))
7768 (gnus-cache-possibly-enter-article
7769 gnus-newsgroup-name article
7770 (gnus-summary-article-header article)
7771 (= mark gnus-ticked-mark)
7772 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7774 (when (gnus-summary-goto-subject article nil t)
7775 (let ((buffer-read-only nil))
7776 (gnus-summary-show-thread)
7778 (gnus-summary-update-mark mark 'unread)
7781 (defun gnus-summary-update-secondary-mark (article)
7782 "Update the secondary (read, process, cache) mark."
7783 (gnus-summary-update-mark
7784 (cond ((memq article gnus-newsgroup-processable)
7786 ((memq article gnus-newsgroup-cached)
7788 ((memq article gnus-newsgroup-replied)
7790 ((memq article gnus-newsgroup-saved)
7792 (t gnus-unread-mark))
7794 (when (gnus-visual-p 'summary-highlight 'highlight)
7795 (gnus-run-hooks 'gnus-summary-update-hook))
7798 (defun gnus-summary-update-mark (mark type)
7799 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7800 (buffer-read-only nil))
7801 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7802 (when (looking-at "\r")
7805 (<= (+ forward (point)) (point-max)))
7806 ;; Go to the right position on the line.
7807 (goto-char (+ forward (point)))
7808 ;; Replace the old mark with the new mark.
7809 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7810 ;; Optionally update the marks by some user rule.
7811 (when (eq type 'unread)
7813 (gnus-data-find (gnus-summary-article-number)) mark)
7814 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7816 (defun gnus-mark-article-as-read (article &optional mark)
7817 "Enter ARTICLE in the pertinent lists and remove it from others."
7818 ;; Make the article expirable.
7819 (let ((mark (or mark gnus-del-mark)))
7820 (if (= mark gnus-expirable-mark)
7821 (push article gnus-newsgroup-expirable)
7822 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7823 ;; Remove from unread and marked lists.
7824 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7825 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7826 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7827 (push (cons article mark) gnus-newsgroup-reads)
7828 ;; Possibly remove from cache, if that is used.
7829 (when gnus-use-cache
7830 (gnus-cache-enter-remove-article article))
7833 (defun gnus-mark-article-as-unread (article &optional mark)
7834 "Enter ARTICLE in the pertinent lists and remove it from others."
7835 (let ((mark (or mark gnus-ticked-mark)))
7838 (gnus-error 1 "Can't mark negative article numbers")
7840 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7841 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7842 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7843 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7845 ;; Unsuppress duplicates?
7846 (when gnus-suppress-duplicates
7847 (gnus-dup-unsuppress-article article))
7849 (cond ((= mark gnus-ticked-mark)
7850 (push article gnus-newsgroup-marked))
7851 ((= mark gnus-dormant-mark)
7852 (push article gnus-newsgroup-dormant))
7854 (push article gnus-newsgroup-unreads)))
7855 (gnus-pull article gnus-newsgroup-reads)
7858 (defalias 'gnus-summary-mark-as-unread-forward
7859 'gnus-summary-tick-article-forward)
7860 (make-obsolete 'gnus-summary-mark-as-unread-forward
7861 'gnus-summary-tick-article-forward)
7862 (defun gnus-summary-tick-article-forward (n)
7863 "Tick N articles forwards.
7864 If N is negative, tick backwards instead.
7865 The difference between N and the number of articles ticked is returned."
7867 (gnus-summary-mark-forward n gnus-ticked-mark))
7869 (defalias 'gnus-summary-mark-as-unread-backward
7870 'gnus-summary-tick-article-backward)
7871 (make-obsolete 'gnus-summary-mark-as-unread-backward
7872 'gnus-summary-tick-article-backward)
7873 (defun gnus-summary-tick-article-backward (n)
7874 "Tick N articles backwards.
7875 The difference between N and the number of articles ticked is returned."
7877 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7879 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7880 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7881 (defun gnus-summary-tick-article (&optional article clear-mark)
7882 "Mark current article as unread.
7883 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7884 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7886 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7889 (defun gnus-summary-mark-as-read-forward (n)
7890 "Mark N articles as read forwards.
7891 If N is negative, mark backwards instead.
7892 The difference between N and the actual number of articles marked is
7895 (gnus-summary-mark-forward n gnus-del-mark t))
7897 (defun gnus-summary-mark-as-read-backward (n)
7898 "Mark the N articles as read backwards.
7899 The difference between N and the actual number of articles marked is
7902 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7904 (defun gnus-summary-mark-as-read (&optional article mark)
7905 "Mark current article as read.
7906 ARTICLE specifies the article to be marked as read.
7907 MARK specifies a string to be inserted at the beginning of the line."
7908 (gnus-summary-mark-article article mark))
7910 (defun gnus-summary-clear-mark-forward (n)
7911 "Clear marks from N articles forward.
7912 If N is negative, clear backward instead.
7913 The difference between N and the number of marks cleared is returned."
7915 (gnus-summary-mark-forward n gnus-unread-mark))
7917 (defun gnus-summary-clear-mark-backward (n)
7918 "Clear marks from N articles backward.
7919 The difference between N and the number of marks cleared is returned."
7921 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7923 (defun gnus-summary-mark-unread-as-read ()
7924 "Intended to be used by `gnus-summary-mark-article-hook'."
7925 (when (memq gnus-current-article gnus-newsgroup-unreads)
7926 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7928 (defun gnus-summary-mark-read-and-unread-as-read ()
7929 "Intended to be used by `gnus-summary-mark-article-hook'."
7930 (let ((mark (gnus-summary-article-mark)))
7931 (when (or (gnus-unread-mark-p mark)
7932 (gnus-read-mark-p mark))
7933 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7935 (defun gnus-summary-mark-region-as-read (point mark all)
7936 "Mark all unread articles between point and mark as read.
7937 If given a prefix, mark all articles between point and mark as read,
7938 even ticked and dormant ones."
7939 (interactive "r\nP")
7948 (memq (setq article (gnus-summary-article-number))
7949 gnus-newsgroup-unreads))
7950 (gnus-summary-mark-article article gnus-del-mark))
7952 (gnus-summary-find-next))))))
7954 (defun gnus-summary-mark-below (score mark)
7955 "Mark articles with score less than SCORE with MARK."
7956 (interactive "P\ncMark: ")
7957 (setq score (if score
7958 (prefix-numeric-value score)
7959 (or gnus-summary-default-score 0)))
7961 (set-buffer gnus-summary-buffer)
7962 (goto-char (point-min))
7965 (and (< (gnus-summary-article-score) score)
7966 (gnus-summary-mark-article nil mark))
7967 (gnus-summary-find-next)))))
7969 (defun gnus-summary-kill-below (&optional score)
7970 "Mark articles with score below SCORE as read."
7972 (gnus-summary-mark-below score gnus-killed-mark))
7974 (defun gnus-summary-clear-above (&optional score)
7975 "Clear all marks from articles with score above SCORE."
7977 (gnus-summary-mark-above score gnus-unread-mark))
7979 (defun gnus-summary-tick-above (&optional score)
7980 "Tick all articles with score above SCORE."
7982 (gnus-summary-mark-above score gnus-ticked-mark))
7984 (defun gnus-summary-mark-above (score mark)
7985 "Mark articles with score over SCORE with MARK."
7986 (interactive "P\ncMark: ")
7987 (setq score (if score
7988 (prefix-numeric-value score)
7989 (or gnus-summary-default-score 0)))
7991 (set-buffer gnus-summary-buffer)
7992 (goto-char (point-min))
7994 (when (> (gnus-summary-article-score) score)
7995 (gnus-summary-mark-article nil mark))
7997 (gnus-summary-find-next)))))
7999 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8000 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8001 (defun gnus-summary-limit-include-expunged (&optional no-error)
8002 "Display all the hidden articles that were expunged for low scores."
8004 (let ((buffer-read-only nil))
8005 (let ((scored gnus-newsgroup-scored)
8008 (unless (gnus-summary-goto-subject (caar scored))
8009 (and (setq h (gnus-summary-article-header (caar scored)))
8010 (< (cdar scored) gnus-summary-expunge-below)
8012 (setq scored (cdr scored)))
8014 (when (not no-error)
8015 (error "No expunged articles hidden"))
8016 (goto-char (point-min))
8017 (gnus-summary-prepare-unthreaded (nreverse headers))
8018 (goto-char (point-min))
8019 (gnus-summary-position-point)
8022 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8023 "Mark all unread articles in this newsgroup as read.
8024 If prefix argument ALL is non-nil, ticked and dormant articles will
8025 also be marked as read.
8026 If QUIETLY is non-nil, no questions will be asked.
8027 If TO-HERE is non-nil, it should be a point in the buffer. All
8028 articles before this point will be marked as read.
8029 Note that this function will only catch up the unread article
8030 in the current summary buffer limitation.
8031 The number of articles marked as read is returned."
8036 (not gnus-interactive-catchup) ;Without confirmation?
8040 "Mark absolutely all articles as read? "
8041 "Mark all unread articles as read? ")))
8043 (not gnus-newsgroup-adaptive)
8044 (not gnus-newsgroup-auto-expire)
8045 (not gnus-suppress-duplicates)
8046 (or (not gnus-use-cache)
8047 (eq gnus-use-cache 'passive)))
8050 (setq gnus-newsgroup-marked nil
8051 gnus-newsgroup-dormant nil))
8052 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8053 ;; We actually mark all articles as canceled, which we
8054 ;; have to do when using auto-expiry or adaptive scoring.
8055 (gnus-summary-show-all-threads)
8056 (when (gnus-summary-first-subject (not all) t)
8058 (if to-here (< (point) to-here) t)
8059 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8060 (gnus-summary-find-next (not all) nil nil t))))
8061 (gnus-set-mode-line 'summary))
8063 (gnus-summary-position-point)))
8065 (defun gnus-summary-catchup-to-here (&optional all)
8066 "Mark all unticked articles before the current one as read.
8067 If ALL is non-nil, also mark ticked and dormant articles as read."
8070 (gnus-save-hidden-threads
8071 (let ((beg (point)))
8072 ;; We check that there are unread articles.
8073 (when (or all (gnus-summary-find-prev))
8074 (gnus-summary-catchup all t beg)))))
8075 (gnus-summary-position-point))
8077 (defun gnus-summary-catchup-all (&optional quietly)
8078 "Mark all articles in this newsgroup as read."
8080 (gnus-summary-catchup t quietly))
8082 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8083 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8084 If prefix argument ALL is non-nil, all articles are marked as read."
8086 (when (gnus-summary-catchup all quietly nil 'fast)
8087 ;; Select next newsgroup or exit.
8088 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8089 (eq gnus-auto-select-next 'quietly))
8090 (gnus-summary-next-group nil)
8091 (gnus-summary-exit))))
8093 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8094 "Mark all articles in this newsgroup as read, and then exit."
8096 (gnus-summary-catchup-and-exit t quietly))
8098 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8099 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8100 "Mark all articles in this group as read and select the next group.
8101 If given a prefix, mark all articles, unread as well as ticked, as
8105 (gnus-summary-catchup all))
8106 (gnus-summary-next-article t nil nil t))
8108 ;; Thread-based commands.
8110 (defun gnus-summary-articles-in-thread (&optional article)
8111 "Return a list of all articles in the current thread.
8112 If ARTICLE is non-nil, return all articles in the thread that starts
8114 (let* ((article (or article (gnus-summary-article-number)))
8115 (data (gnus-data-find-list article))
8116 (top-level (gnus-data-level (car data)))
8118 (cond ((null gnus-thread-operation-ignore-subject)
8119 (gnus-simplify-subject-re
8120 (mail-header-subject (gnus-data-header (car data)))))
8121 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8122 (gnus-simplify-subject-fuzzy
8123 (mail-header-subject (gnus-data-header (car data)))))
8125 (end-point (save-excursion
8126 (if (gnus-summary-go-to-next-thread)
8127 (point) (point-max))))
8130 (< (gnus-data-pos (car data)) end-point))
8131 (when (or (not top-subject)
8132 (string= top-subject
8133 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8134 (gnus-simplify-subject-fuzzy
8135 (mail-header-subject
8136 (gnus-data-header (car data))))
8137 (gnus-simplify-subject-re
8138 (mail-header-subject
8139 (gnus-data-header (car data)))))))
8140 (push (gnus-data-number (car data)) articles))
8141 (unless (and (setq data (cdr data))
8142 (> (gnus-data-level (car data)) top-level))
8144 ;; Return the list of articles.
8145 (nreverse articles)))
8147 (defun gnus-summary-rethread-current ()
8148 "Rethread the thread the current article is part of."
8150 (let* ((gnus-show-threads t)
8151 (article (gnus-summary-article-number))
8152 (id (mail-header-id (gnus-summary-article-header)))
8153 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8155 (error "No article on the current line"))
8156 (gnus-rebuild-thread id)
8157 (gnus-summary-goto-subject article)))
8159 (defun gnus-summary-reparent-thread ()
8160 "Make the current article child of the marked (or previous) article.
8162 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8163 is non-nil or the Subject: of both articles are the same."
8165 (unless (not (gnus-group-read-only-p))
8166 (error "The current newsgroup does not support article editing"))
8167 (unless (<= (length gnus-newsgroup-processable) 1)
8168 (error "No more than one article may be marked"))
8169 (save-window-excursion
8170 (let ((gnus-article-buffer " *reparent*")
8171 (current-article (gnus-summary-article-number))
8172 ;; First grab the marked article, otherwise one line up.
8173 (parent-article (if (not (null gnus-newsgroup-processable))
8174 (car gnus-newsgroup-processable)
8176 (if (eq (forward-line -1) 0)
8177 (gnus-summary-article-number)
8178 (error "Beginning of summary buffer"))))))
8179 (unless (not (eq current-article parent-article))
8180 (error "An article may not be self-referential"))
8181 (let ((message-id (mail-header-id
8182 (gnus-summary-article-header parent-article))))
8183 (unless (and message-id (not (equal message-id "")))
8184 (error "No message-id in desired parent"))
8185 ;; We don't want the article to be marked as read.
8186 (let (gnus-mark-article-hook)
8187 (gnus-summary-select-article t t nil current-article))
8188 (set-buffer gnus-original-article-buffer)
8189 (let ((buf (format "%s" (buffer-string))))
8192 (goto-char (point-min))
8193 (if (re-search-forward "^References: " nil t)
8195 (re-search-forward "^[^ \t]" nil t)
8198 (insert " " message-id))
8199 (insert "References: " message-id "\n"))
8200 (unless (gnus-request-replace-article
8201 current-article (car gnus-article-current)
8203 (error "Couldn't replace article"))))
8204 (set-buffer gnus-summary-buffer)
8205 (gnus-summary-unmark-all-processable)
8206 (gnus-summary-update-article current-article)
8207 (gnus-summary-rethread-current)
8208 (gnus-message 3 "Article %d is now the child of article %d"
8209 current-article parent-article)))))
8211 (defun gnus-summary-toggle-threads (&optional arg)
8212 "Toggle showing conversation threads.
8213 If ARG is positive number, turn showing conversation threads on."
8215 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8216 (setq gnus-show-threads
8217 (if (null arg) (not gnus-show-threads)
8218 (> (prefix-numeric-value arg) 0)))
8219 (gnus-summary-prepare)
8220 (gnus-summary-goto-subject current)
8221 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8222 (gnus-summary-position-point)))
8224 (defun gnus-summary-show-all-threads ()
8228 (let ((buffer-read-only nil))
8229 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8230 (gnus-summary-position-point))
8232 (defun gnus-summary-show-thread ()
8233 "Show thread subtrees.
8234 Returns nil if no thread was there to be shown."
8236 (let ((buffer-read-only nil)
8238 ;; first goto end then to beg, to have point at beg after let
8239 (end (progn (end-of-line) (point)))
8240 (beg (progn (beginning-of-line) (point))))
8242 ;; Any hidden lines here?
8243 (search-forward "\r" end t)
8244 (subst-char-in-region beg end ?\^M ?\n t)
8246 (gnus-summary-position-point))))
8248 (defun gnus-summary-hide-all-threads ()
8249 "Hide all thread subtrees."
8252 (goto-char (point-min))
8253 (gnus-summary-hide-thread)
8254 (while (zerop (gnus-summary-next-thread 1 t))
8255 (gnus-summary-hide-thread)))
8256 (gnus-summary-position-point))
8258 (defun gnus-summary-hide-thread ()
8259 "Hide thread subtrees.
8260 Returns nil if no threads were there to be hidden."
8262 (let ((buffer-read-only nil)
8264 (article (gnus-summary-article-number)))
8266 ;; Go forward until either the buffer ends or the subthread
8268 (when (and (not (eobp))
8269 (or (zerop (gnus-summary-next-thread 1 t))
8270 (goto-char (point-max))))
8272 (if (and (> (point) start)
8273 (search-backward "\n" start t))
8275 (subst-char-in-region start (point) ?\n ?\^M)
8276 (gnus-summary-goto-subject article))
8279 ;;(gnus-summary-position-point)
8282 (defun gnus-summary-go-to-next-thread (&optional previous)
8283 "Go to the same level (or less) next thread.
8284 If PREVIOUS is non-nil, go to previous thread instead.
8285 Return the article number moved to, or nil if moving was impossible."
8286 (let ((level (gnus-summary-thread-level))
8287 (way (if previous -1 1))
8290 (while (and (not (eobp))
8291 (< level (gnus-summary-thread-level)))
8299 (gnus-summary-article-number)
8302 (defun gnus-summary-next-thread (n &optional silent)
8303 "Go to the same level next N'th thread.
8304 If N is negative, search backward instead.
8305 Returns the difference between N and the number of skips actually
8308 If SILENT, don't output messages."
8310 (let ((backward (< n 0))
8313 (gnus-summary-go-to-next-thread backward))
8316 (gnus-summary-position-point))
8317 (when (and (not silent) (/= 0 n))
8318 (gnus-message 7 "No more threads"))
8321 (defun gnus-summary-prev-thread (n)
8322 "Go to the same level previous N'th thread.
8323 Returns the difference between N and the number of skips actually
8326 (gnus-summary-next-thread (- n)))
8328 (defun gnus-summary-go-down-thread ()
8329 "Go down one level in the current thread."
8330 (let ((children (gnus-summary-article-children)))
8332 (gnus-summary-goto-subject (car children)))))
8334 (defun gnus-summary-go-up-thread ()
8335 "Go up one level in the current thread."
8336 (let ((parent (gnus-summary-article-parent)))
8338 (gnus-summary-goto-subject parent))))
8340 (defun gnus-summary-down-thread (n)
8341 "Go down thread N steps.
8342 If N is negative, go up instead.
8343 Returns the difference between N and how many steps down that were
8349 (if up (gnus-summary-go-up-thread)
8350 (gnus-summary-go-down-thread)))
8352 (gnus-summary-position-point)
8354 (gnus-message 7 "Can't go further"))
8357 (defun gnus-summary-up-thread (n)
8358 "Go up thread N steps.
8359 If N is negative, go up instead.
8360 Returns the difference between N and how many steps down that were
8363 (gnus-summary-down-thread (- n)))
8365 (defun gnus-summary-top-thread ()
8366 "Go to the top of the thread."
8368 (while (gnus-summary-go-up-thread))
8369 (gnus-summary-article-number))
8371 (defun gnus-summary-kill-thread (&optional unmark)
8372 "Mark articles under current thread as read.
8373 If the prefix argument is positive, remove any kinds of marks.
8374 If the prefix argument is negative, tick articles instead."
8377 (setq unmark (prefix-numeric-value unmark)))
8378 (let ((articles (gnus-summary-articles-in-thread)))
8380 ;; Expand the thread.
8381 (gnus-summary-show-thread)
8382 ;; Mark all the articles.
8384 (gnus-summary-goto-subject (car articles))
8385 (cond ((null unmark)
8386 (gnus-summary-mark-article-as-read gnus-killed-mark))
8388 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8390 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8391 (setq articles (cdr articles))))
8392 ;; Hide killed subtrees.
8394 gnus-thread-hide-killed
8395 (gnus-summary-hide-thread))
8396 ;; If marked as read, go to next unread subject.
8398 ;; Go to next unread subject.
8399 (gnus-summary-next-subject 1 t)))
8400 (gnus-set-mode-line 'summary))
8402 ;; Summary sorting commands
8404 (defun gnus-summary-sort-by-number (&optional reverse)
8405 "Sort the summary buffer by article number.
8406 Argument REVERSE means reverse order."
8408 (gnus-summary-sort 'number reverse))
8410 (defun gnus-summary-sort-by-author (&optional reverse)
8411 "Sort the summary buffer by author name alphabetically.
8412 If case-fold-search is non-nil, case of letters is ignored.
8413 Argument REVERSE means reverse order."
8415 (gnus-summary-sort 'author reverse))
8417 (defun gnus-summary-sort-by-subject (&optional reverse)
8418 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8419 If case-fold-search is non-nil, case of letters is ignored.
8420 Argument REVERSE means reverse order."
8422 (gnus-summary-sort 'subject reverse))
8424 (defun gnus-summary-sort-by-date (&optional reverse)
8425 "Sort the summary buffer by date.
8426 Argument REVERSE means reverse order."
8428 (gnus-summary-sort 'date reverse))
8430 (defun gnus-summary-sort-by-score (&optional reverse)
8431 "Sort the summary buffer by score.
8432 Argument REVERSE means reverse order."
8434 (gnus-summary-sort 'score reverse))
8436 (defun gnus-summary-sort-by-lines (&optional reverse)
8437 "Sort the summary buffer by article length.
8438 Argument REVERSE means reverse order."
8440 (gnus-summary-sort 'lines reverse))
8442 (defun gnus-summary-sort (predicate reverse)
8443 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8444 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8445 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8446 (gnus-thread-sort-functions
8452 (gnus-article-sort-functions
8457 (,article t2 t1)))))
8459 (gnus-summary-prepare-hook nil))
8460 ;; We do the sorting by regenerating the threads.
8461 (gnus-summary-prepare)
8462 ;; Hide subthreads if needed.
8463 (when (and gnus-show-threads gnus-thread-hide-subtree)
8464 (gnus-summary-hide-all-threads))))
8466 ;; Summary saving commands.
8468 (defun gnus-summary-save-article (&optional n not-saved)
8469 "Save the current article using the default saver function.
8470 If N is a positive number, save the N next articles.
8471 If N is a negative number, save the N previous articles.
8472 If N is nil and any articles have been marked with the process mark,
8473 save those articles instead.
8474 The variable `gnus-default-article-saver' specifies the saver function."
8476 (let* ((articles (gnus-summary-work-articles n))
8477 (save-buffer (save-excursion
8478 (nnheader-set-temp-buffer " *Gnus Save*")))
8479 (num (length articles))
8480 header article file)
8482 (setq header (gnus-summary-article-header
8483 (setq article (pop articles))))
8484 (if (not (vectorp header))
8485 ;; This is a pseudo-article.
8486 (if (assq 'name header)
8487 (gnus-copy-file (cdr (assq 'name header)))
8488 (gnus-message 1 "Article %d is unsaveable" article))
8489 ;; This is a real article.
8490 (save-window-excursion
8491 (gnus-summary-select-article t nil nil article))
8493 (set-buffer save-buffer)
8495 (insert-buffer-substring gnus-original-article-buffer))
8496 (setq file (gnus-article-save save-buffer file num))
8497 (gnus-summary-remove-process-mark article)
8499 (gnus-summary-set-saved-mark article))))
8500 (gnus-kill-buffer save-buffer)
8501 (gnus-summary-position-point)
8502 (gnus-set-mode-line 'summary)
8505 (defun gnus-summary-pipe-output (&optional arg)
8506 "Pipe the current article to a subprocess.
8507 If N is a positive number, pipe the N next articles.
8508 If N is a negative number, pipe the N previous articles.
8509 If N is nil and any articles have been marked with the process mark,
8510 pipe those articles instead."
8512 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8513 (gnus-summary-save-article arg t))
8514 (gnus-configure-windows 'pipe))
8516 (defun gnus-summary-save-article-mail (&optional arg)
8517 "Append the current article to an mail file.
8518 If N is a positive number, save the N next articles.
8519 If N is a negative number, save the N previous articles.
8520 If N is nil and any articles have been marked with the process mark,
8521 save those articles instead."
8523 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8524 (gnus-summary-save-article arg)))
8526 (defun gnus-summary-save-article-rmail (&optional arg)
8527 "Append the current article to an rmail file.
8528 If N is a positive number, save the N next articles.
8529 If N is a negative number, save the N previous articles.
8530 If N is nil and any articles have been marked with the process mark,
8531 save those articles instead."
8533 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8534 (gnus-summary-save-article arg)))
8536 (defun gnus-summary-save-article-file (&optional arg)
8537 "Append the current article to a file.
8538 If N is a positive number, save the N next articles.
8539 If N is a negative number, save the N previous articles.
8540 If N is nil and any articles have been marked with the process mark,
8541 save those articles instead."
8543 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8544 (gnus-summary-save-article arg)))
8546 (defun gnus-summary-write-article-file (&optional arg)
8547 "Write the current article to a file, deleting the previous file.
8548 If N is a positive number, save the N next articles.
8549 If N is a negative number, save the N previous articles.
8550 If N is nil and any articles have been marked with the process mark,
8551 save those articles instead."
8553 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8554 (gnus-summary-save-article arg)))
8556 (defun gnus-summary-save-article-body-file (&optional arg)
8557 "Append the current article body to a file.
8558 If N is a positive number, save the N next articles.
8559 If N is a negative number, save the N previous articles.
8560 If N is nil and any articles have been marked with the process mark,
8561 save those articles instead."
8563 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8564 (gnus-summary-save-article arg)))
8566 (defun gnus-summary-pipe-message (program)
8567 "Pipe the current article through PROGRAM."
8568 (interactive "sProgram: ")
8569 (gnus-summary-select-article)
8570 (let ((mail-header-separator ""))
8571 (gnus-eval-in-buffer-window gnus-article-buffer
8574 (let ((start (window-start))
8576 (message-pipe-buffer-body program)
8577 (set-window-start (get-buffer-window (current-buffer)) start))))))
8579 (defun gnus-get-split-value (methods)
8580 "Return a value based on the split METHODS."
8581 (let (split-name method result match)
8584 (set-buffer gnus-original-article-buffer)
8586 (nnheader-narrow-to-headers)
8588 (goto-char (point-min))
8589 (setq method (pop methods))
8590 (setq match (car method))
8593 ;; Regular expression.
8595 (re-search-forward match nil t)))
8596 ((gnus-functionp match)
8600 (setq result (funcall match gnus-newsgroup-name))))
8605 (setq result (eval match)))))
8606 (setq split-name (append (cdr method) split-name))
8607 (cond ((stringp result)
8608 (push (expand-file-name
8609 result gnus-article-save-directory)
8612 (setq split-name (append result split-name)))))))))
8615 (defun gnus-valid-move-group-p (group)
8620 (car (gnus-find-method-for-group
8621 (symbol-name group))))
8622 gnus-valid-select-methods))))
8624 (defun gnus-read-move-group-name (prompt default articles prefix)
8625 "Read a group name."
8626 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8627 (minibuffer-confirm-incomplete nil) ; XEmacs
8631 (if (> (length articles) 1)
8632 (format "these %d articles" (length articles))
8637 (gnus-completing-read default prom
8639 'gnus-valid-move-group-p
8641 'gnus-group-history))
8642 ((= 1 (length split-name))
8643 (gnus-completing-read (car split-name) prom
8645 'gnus-valid-move-group-p
8647 'gnus-group-history))
8649 (gnus-completing-read nil prom
8650 (mapcar (lambda (el) (list el))
8651 (nreverse split-name))
8653 'gnus-group-history)))))
8655 (if (or (string= to-newsgroup "")
8656 (string= to-newsgroup prefix))
8657 (setq to-newsgroup default))
8658 (unless to-newsgroup
8659 (error "No group name entered"))
8660 (or (gnus-active to-newsgroup)
8661 (gnus-activate-group to-newsgroup)
8662 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8664 (or (and (gnus-request-create-group
8665 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8666 (gnus-activate-group to-newsgroup nil nil
8667 (gnus-group-name-to-method
8669 (error "Couldn't create group %s" to-newsgroup)))
8670 (error "No such group: %s" to-newsgroup)))
8673 ;; Summary extract commands
8675 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8676 (let ((buffer-read-only nil)
8677 (article (gnus-summary-article-number))
8679 (unless (gnus-summary-goto-subject article)
8680 (error "No such article: %d" article))
8681 (gnus-summary-position-point)
8682 ;; If all commands are to be bunched up on one line, we collect
8684 (unless gnus-view-pseudos-separately
8685 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8688 (setq action (cdr (assq 'action (car ps))))
8689 (setq files (list (cdr (assq 'name (car ps)))))
8690 (while (and ps (cdr ps)
8691 (string= (or action "1")
8692 (or (cdr (assq 'action (cadr ps))) "2")))
8693 (push (cdr (assq 'name (cadr ps))) files)
8694 (setcdr ps (cddr ps)))
8696 (when (not (string-match "%s" action))
8699 (when (assq 'execute (car ps))
8700 (setcdr (assq 'execute (car ps))
8701 (funcall (if (string-match "%s" action)
8708 (gnus-quote-arg-for-sh-or-csh f)))
8710 (setq ps (cdr ps)))))
8711 (if (and gnus-view-pseudos (not not-view))
8713 (when (assq 'execute (car pslist))
8714 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8715 (eq gnus-view-pseudos 'not-confirm)))
8716 (setq pslist (cdr pslist)))
8719 (setq after-article (or (cdr (assq 'article (car pslist)))
8720 (gnus-summary-article-number)))
8721 (gnus-summary-goto-subject after-article)
8724 (insert " " (file-name-nondirectory
8725 (cdr (assq 'name (car pslist))))
8726 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8728 (forward-line -1) ; back to `b'
8729 (gnus-add-text-properties
8730 b (1- e) (list 'gnus-number gnus-reffed-article-number
8731 gnus-mouse-face-prop gnus-mouse-face))
8733 after-article gnus-reffed-article-number
8734 gnus-unread-mark b (car pslist) 0 (- e b))
8735 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8736 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8737 (setq pslist (cdr pslist)))))))
8739 (defun gnus-pseudos< (p1 p2)
8740 (let ((c1 (cdr (assq 'action p1)))
8741 (c2 (cdr (assq 'action p2))))
8742 (and c1 c2 (string< c1 c2))))
8744 (defun gnus-request-pseudo-article (props)
8745 (cond ((assq 'execute props)
8746 (gnus-execute-command (cdr (assq 'execute props)))))
8747 (let ((gnus-current-article (gnus-summary-article-number)))
8748 (gnus-run-hooks 'gnus-mark-article-hook)))
8750 (defun gnus-execute-command (command &optional automatic)
8752 (gnus-article-setup-buffer)
8753 (set-buffer gnus-article-buffer)
8754 (setq buffer-read-only nil)
8755 (let ((command (if automatic command
8756 (read-string "Command: " (cons command 0)))))
8758 (insert "$ " command "\n\n")
8759 (if gnus-view-pseudo-asynchronously
8760 (start-process "gnus-execute" (current-buffer) shell-file-name
8761 shell-command-switch command)
8762 (call-process shell-file-name nil t nil
8763 shell-command-switch command)))))
8765 ;; Summary kill commands.
8767 (defun gnus-summary-edit-global-kill (article)
8768 "Edit the \"global\" kill file."
8769 (interactive (list (gnus-summary-article-number)))
8770 (gnus-group-edit-global-kill article))
8772 (defun gnus-summary-edit-local-kill ()
8773 "Edit a local kill file applied to the current newsgroup."
8775 (setq gnus-current-headers (gnus-summary-article-header))
8776 (gnus-group-edit-local-kill
8777 (gnus-summary-article-number) gnus-newsgroup-name))
8781 (defun gnus-read-header (id &optional header)
8782 "Read the headers of article ID and enter them into the Gnus system."
8783 (let ((group gnus-newsgroup-name)
8784 (gnus-override-method
8785 (and (gnus-news-group-p gnus-newsgroup-name)
8786 gnus-refer-article-method))
8788 ;; First we check to see whether the header in question is already
8791 ;; This is a Message-ID.
8792 (setq header (or header (gnus-id-to-header id)))
8793 ;; This is an article number.
8794 (setq header (or header (gnus-summary-article-header id))))
8796 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8797 ;; We have found the header.
8799 ;; If this is a sparse article, we have to nix out its
8800 ;; previous entry in the thread hashtb.
8802 (gnus-summary-article-sparse-p (mail-header-number header)))
8803 (let* ((parent (gnus-parent-id (mail-header-references header)))
8804 (thread (and parent (gnus-id-to-thread parent))))
8806 (delq (assq header thread) thread))))
8807 ;; We have to really fetch the header to this article.
8809 (set-buffer nntp-server-buffer)
8810 (when (setq where (gnus-request-head id group))
8811 (nnheader-fold-continuation-lines)
8812 (goto-char (point-max))
8814 (goto-char (point-min))
8818 ((cdr where) (cdr where))
8819 (header (mail-header-number header))
8820 (t gnus-reffed-article-number))
8822 (insert " Article retrieved.\n"))
8824 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8825 () ; Malformed head.
8826 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8827 (when (and (stringp id)
8828 (not (string= (gnus-group-real-name group)
8830 ;; If we fetched by Message-ID and the article came
8831 ;; from a different group, we fudge some bogus article
8832 ;; numbers for this article.
8833 (mail-header-set-number header gnus-reffed-article-number))
8835 (set-buffer gnus-summary-buffer)
8836 (decf gnus-reffed-article-number)
8837 (gnus-remove-header (mail-header-number header))
8838 (push header gnus-newsgroup-headers)
8839 (setq gnus-current-headers header)
8840 (push (mail-header-number header) gnus-newsgroup-limit)))
8843 (defun gnus-remove-header (number)
8844 "Remove header NUMBER from `gnus-newsgroup-headers'."
8845 (if (and gnus-newsgroup-headers
8846 (= number (mail-header-number (car gnus-newsgroup-headers))))
8847 (pop gnus-newsgroup-headers)
8848 (let ((headers gnus-newsgroup-headers))
8849 (while (and (cdr headers)
8850 (not (= number (mail-header-number (cadr headers)))))
8853 (setcdr headers (cddr headers))))))
8856 ;;; summary highlights
8859 (defun gnus-highlight-selected-summary ()
8860 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8861 ;; Highlight selected article in summary buffer
8862 (when gnus-summary-selected-face
8864 (let* ((beg (progn (beginning-of-line) (point)))
8865 (end (progn (end-of-line) (point)))
8866 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8867 (from (if (get-text-property beg gnus-mouse-face-prop)
8869 (or (next-single-property-change
8870 beg gnus-mouse-face-prop nil end)
8875 (or (next-single-property-change
8876 from gnus-mouse-face-prop nil end)
8878 ;; If no mouse-face prop on line we will have to = from = end,
8879 ;; so we highlight the entire line instead.
8880 (when (= (+ to 2) from)
8883 (if gnus-newsgroup-selected-overlay
8884 ;; Move old overlay.
8886 gnus-newsgroup-selected-overlay from to (current-buffer))
8887 ;; Create new overlay.
8889 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8890 'face gnus-summary-selected-face))))))
8892 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8893 (defun gnus-summary-highlight-line ()
8894 "Highlight current line according to `gnus-summary-highlight'."
8895 (let* ((list gnus-summary-highlight)
8897 (end (progn (end-of-line) (point)))
8898 ;; now find out where the line starts and leave point there.
8899 (beg (progn (beginning-of-line) (point)))
8900 (article (gnus-summary-article-number))
8901 (score (or (cdr (assq (or article gnus-current-article)
8902 gnus-newsgroup-scored))
8903 gnus-summary-default-score 0))
8904 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8905 (inhibit-read-only t))
8906 ;; Eval the cars of the lists until we find a match.
8907 (let ((default gnus-summary-default-score))
8909 (not (eval (caar list))))
8910 (setq list (cdr list))))
8911 (let ((face (cdar list)))
8912 (unless (eq face (get-text-property beg 'face))
8913 (gnus-put-text-property-excluding-characters-with-faces
8915 (setq face (if (boundp face) (symbol-value face) face)))
8916 (when gnus-summary-highlight-line-function
8917 (funcall gnus-summary-highlight-line-function article face))))
8920 (defun gnus-update-read-articles (group unread &optional compute)
8921 "Update the list of read articles in GROUP."
8922 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8923 (entry (gnus-gethash group gnus-newsrc-hashtb))
8924 (info (nth 2 entry))
8926 (unread (sort (copy-sequence unread) '<))
8928 (if (or (not info) (not active))
8929 ;; There is no info on this group if it was, in fact,
8930 ;; killed. Gnus stores no information on killed groups, so
8931 ;; there's nothing to be done.
8932 ;; One could store the information somewhere temporarily,
8933 ;; perhaps... Hmmm...
8935 ;; Remove any negative articles numbers.
8936 (while (and unread (< (car unread) 0))
8937 (setq unread (cdr unread)))
8938 ;; Remove any expired article numbers
8939 (while (and unread (< (car unread) (car active)))
8940 (setq unread (cdr unread)))
8941 ;; Compute the ranges of read articles by looking at the list of
8944 (when (/= (car unread) prev)
8945 (push (if (= prev (1- (car unread))) prev
8946 (cons prev (1- (car unread))))
8948 (setq prev (1+ (car unread)))
8949 (setq unread (cdr unread)))
8950 (when (<= prev (cdr active))
8951 (push (cons prev (cdr active)) read))
8952 (setq read (if (> (length read) 1) (nreverse read) read))
8956 (set-buffer gnus-group-buffer)
8959 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8960 (gnus-info-set-read ',info ',(gnus-info-read info))
8961 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8962 (gnus-group-update-group ,group t))))
8963 ;; Enter this list into the group info.
8964 (gnus-info-set-read info read)
8965 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8966 (gnus-get-unread-articles-in-group info (gnus-active group))
8969 (defun gnus-offer-save-summaries ()
8970 "Offer to save all active summary buffers."
8972 (let ((buflist (buffer-list))
8974 ;; Go through all buffers and find all summaries.
8976 (and (setq bufname (buffer-name (car buflist)))
8977 (string-match "Summary" bufname)
8979 (set-buffer bufname)
8980 ;; We check that this is, indeed, a summary buffer.
8981 (and (eq major-mode 'gnus-summary-mode)
8982 ;; Also make sure this isn't bogus.
8983 gnus-newsgroup-prepared
8984 ;; Also make sure that this isn't a dead summary buffer.
8985 (not gnus-dead-summary-mode)))
8986 (push bufname buffers))
8987 (setq buflist (cdr buflist)))
8988 ;; Go through all these summary buffers and offer to save them.
8991 "Update summary buffer %s? "
8993 (switch-to-buffer buf)
8994 (gnus-summary-exit))
8998 ;;; @ for mime-partial
9001 (defun gnus-request-partial-message ()
9003 (let ((number (gnus-summary-article-number))
9004 (group gnus-newsgroup-name)
9005 (mother gnus-article-buffer))
9006 (set-buffer (get-buffer-create " *Partial Article*"))
9008 (setq mime-preview-buffer mother)
9009 (gnus-request-article-this-buffer number group)
9013 (autoload 'mime-combine-message/partial-pieces-automatically
9015 "Internal method to combine message/partial messages automatically.")
9018 'action '((type . message)(subtype . partial)
9019 (major-mode . gnus-original-article-mode)
9020 (method . mime-combine-message/partial-pieces-automatically)
9021 (summary-buffer-exp . gnus-summary-buffer)
9022 (request-partial-message-method . gnus-request-partial-message)
9033 (run-hooks 'gnus-sum-load-hook)
9035 ;;; gnus-sum.el ends here