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 ;; Avoid byte-compile warnings.
42 (defvar gnus-article-decoded-p)
43 (defvar gnus-decode-encoded-word-function)
46 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
47 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
49 (defcustom gnus-kill-summary-on-exit t
50 "*If non-nil, kill the summary buffer when you exit from it.
51 If nil, the summary will become a \"*Dead Summary*\" buffer, and
52 it will be killed sometime later."
53 :group 'gnus-summary-exit
56 (defcustom gnus-fetch-old-headers nil
57 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
58 If an unread article in the group refers to an older, already read (or
59 just marked as read) article, the old article will not normally be
60 displayed in the Summary buffer. If this variable is non-nil, Gnus
61 will attempt to grab the headers to the old articles, and thereby
62 build complete threads. If it has the value `some', only enough
63 headers to connect otherwise loose threads will be displayed. This
64 variable can also be a number. In that case, no more than that number
65 of old headers will be fetched. If it has the value `invisible', all
66 old headers will be fetched, but none will be displayed.
68 The server has to support NOV for any of this to work."
70 :type '(choice (const :tag "off" nil)
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-refer-thread-limit 200
76 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
77 If t, fetch all the available old headers."
80 (sexp :menu-tag "other" t)))
82 (defcustom gnus-summary-make-false-root 'adopt
83 "*nil means that Gnus won't gather loose threads.
84 If the root of a thread has expired or been read in a previous
85 session, the information necessary to build a complete thread has been
86 lost. Instead of having many small sub-threads from this original thread
87 scattered all over the summary buffer, Gnus can gather them.
89 If non-nil, Gnus will try to gather all loose sub-threads from an
90 original thread into one large thread.
92 If this variable is non-nil, it should be one of `none', `adopt',
95 If this variable is `none', Gnus will not make a false root, but just
96 present the sub-threads after another.
97 If this variable is `dummy', Gnus will create a dummy root that will
98 have all the sub-threads as children.
99 If this variable is `adopt', Gnus will make one of the \"children\"
100 the parent and mark all the step-children as such.
101 If this variable is `empty', the \"children\" are printed with empty
102 subject fields. (Or rather, they will be printed with a string
103 given by the `gnus-summary-same-subject' variable.)"
105 :type '(choice (const :tag "off" nil)
111 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
112 "*A regexp to match subjects to be excluded from loose thread gathering.
113 As loose thread gathering is done on subjects only, that means that
114 there can be many false gatherings performed. By rooting out certain
115 common subjects, gathering might become saner."
119 (defcustom gnus-summary-gather-subject-limit nil
120 "*Maximum length of subject comparisons when gathering loose threads.
121 Use nil to compare full subjects. Setting this variable to a low
122 number will help gather threads that have been corrupted by
123 newsreaders chopping off subject lines, but it might also mean that
124 unrelated articles that have subject that happen to begin with the
125 same few characters will be incorrectly gathered.
127 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
130 :type '(choice (const :tag "off" nil)
132 (sexp :menu-tag "on" t)))
134 (defcustom gnus-simplify-subject-functions nil
135 "List of functions taking a string argument that simplify subjects.
136 The functions are applied recursively.
138 Useful functions to put in this list include: `gnus-simplify-subject-re',
139 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
141 :type '(repeat function))
143 (defcustom gnus-simplify-ignored-prefixes nil
144 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
146 :type '(choice (const :tag "off" nil)
149 (defcustom gnus-build-sparse-threads nil
150 "*If non-nil, fill in the gaps in threads.
151 If `some', only fill in the gaps that are needed to tie loose threads
152 together. If `more', fill in all leaf nodes that Gnus can find. If
153 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
155 :type '(choice (const :tag "off" nil)
158 (sexp :menu-tag "all" t)))
160 (defcustom gnus-summary-thread-gathering-function
161 'gnus-gather-threads-by-subject
162 "*Function used for gathering loose threads.
163 There are two pre-defined functions: `gnus-gather-threads-by-subject',
164 which only takes Subjects into consideration; and
165 `gnus-gather-threads-by-references', which compared the References
166 headers of the articles to find matches."
168 :type '(radio (function-item gnus-gather-threads-by-subject)
169 (function-item gnus-gather-threads-by-references)
170 (function :tag "other")))
172 (defcustom gnus-summary-same-subject ""
173 "*String indicating that the current article has the same subject as the previous.
174 This variable will only be used if the value of
175 `gnus-summary-make-false-root' is `empty'."
176 :group 'gnus-summary-format
179 (defcustom gnus-summary-goto-unread t
180 "*If t, marking commands will go to the next unread article.
181 If `never', commands that usually go to the next unread article, will
182 go to the next article, whether it is read or not.
183 If nil, only the marking commands will go to the next (un)read article."
184 :group 'gnus-summary-marks
185 :link '(custom-manual "(gnus)Setting Marks")
186 :type '(choice (const :tag "off" nil)
188 (sexp :menu-tag "on" t)))
190 (defcustom gnus-summary-default-score 0
191 "*Default article score level.
192 All scores generated by the score files will be added to this score.
193 If this variable is nil, scoring will be disabled."
194 :group 'gnus-score-default
195 :type '(choice (const :tag "disable")
198 (defcustom gnus-summary-zcore-fuzz 0
199 "*Fuzziness factor for the zcore in the summary buffer.
200 Articles with scores closer than this to `gnus-summary-default-score'
202 :group 'gnus-summary-format
205 (defcustom gnus-simplify-subject-fuzzy-regexp nil
206 "*Strings to be removed when doing fuzzy matches.
207 This can either be a regular expression or list of regular expressions
208 that will be removed from subject strings if fuzzy subject
209 simplification is selected."
211 :type '(repeat regexp))
213 (defcustom gnus-show-threads t
214 "*If non-nil, display threads in summary mode."
218 (defcustom gnus-thread-hide-subtree nil
219 "*If non-nil, hide all threads initially.
220 If threads are hidden, you have to run the command
221 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
222 to expose hidden threads."
226 (defcustom gnus-thread-hide-killed t
227 "*If non-nil, hide killed threads automatically."
231 (defcustom gnus-thread-ignore-subject t
232 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
233 If nil, articles that have different subjects from their parents will
234 start separate threads."
238 (defcustom gnus-thread-operation-ignore-subject t
239 "*If non-nil, subjects will be ignored when doing thread commands.
240 This affects commands like `gnus-summary-kill-thread' and
241 `gnus-summary-lower-thread'.
243 If this variable is nil, articles in the same thread with different
244 subjects will not be included in the operation in question. If this
245 variable is `fuzzy', only articles that have subjects that are fuzzily
246 equal will be included."
248 :type '(choice (const :tag "off" nil)
252 (defcustom gnus-thread-indent-level 4
253 "*Number that says how much each sub-thread should be indented."
257 (defcustom gnus-auto-extend-newsgroup t
258 "*If non-nil, extend newsgroup forward and backward when requested."
259 :group 'gnus-summary-choose
262 (defcustom gnus-auto-select-first t
263 "*If nil, don't select the first unread article when entering a group.
264 If this variable is `best', select the highest-scored unread article
265 in the group. If t, select the first unread article.
267 This variable can also be a function to place point on a likely
268 subject line. Useful values include `gnus-summary-first-unread-subject',
269 `gnus-summary-first-unread-article' and
270 `gnus-summary-best-unread-article'.
272 If you want to prevent automatic selection of the first unread article
273 in some newsgroups, set the variable to nil in
274 `gnus-select-group-hook'."
275 :group 'gnus-group-select
276 :type '(choice (const :tag "none" nil)
278 (sexp :menu-tag "first" t)
279 (function-item gnus-summary-first-unread-subject)
280 (function-item gnus-summary-first-unread-article)
281 (function-item gnus-summary-best-unread-article)))
283 (defcustom gnus-auto-select-next t
284 "*If non-nil, offer to go to the next group from the end of the previous.
285 If the value is t and the next newsgroup is empty, Gnus will exit
286 summary mode and go back to group mode. If the value is neither nil
287 nor t, Gnus will select the following unread newsgroup. In
288 particular, if the value is the symbol `quietly', the next unread
289 newsgroup will be selected without any confirmation, and if it is
290 `almost-quietly', the next group will be selected without any
291 confirmation if you are located on the last article in the group.
292 Finally, if this variable is `slightly-quietly', the `Z n' command
293 will go to the next group without confirmation."
294 :group 'gnus-summary-maneuvering
295 :type '(choice (const :tag "off" nil)
297 (const almost-quietly)
298 (const slightly-quietly)
299 (sexp :menu-tag "on" t)))
301 (defcustom gnus-auto-select-same nil
302 "*If non-nil, select the next article with the same subject.
303 If there are no more articles with the same subject, go to
304 the first unread article."
305 :group 'gnus-summary-maneuvering
308 (defcustom gnus-summary-check-current nil
309 "*If non-nil, consider the current article when moving.
310 The \"unread\" movement commands will stay on the same line if the
311 current article is unread."
312 :group 'gnus-summary-maneuvering
315 (defcustom gnus-auto-center-summary t
316 "*If non-nil, always center the current summary buffer.
317 In particular, if `vertical' do only vertical recentering. If non-nil
318 and non-`vertical', do both horizontal and vertical recentering."
319 :group 'gnus-summary-maneuvering
320 :type '(choice (const :tag "none" nil)
322 (integer :tag "height")
323 (sexp :menu-tag "both" t)))
325 (defcustom gnus-show-all-headers nil
326 "*If non-nil, don't hide any headers."
327 :group 'gnus-article-hiding
328 :group 'gnus-article-headers
331 (defcustom gnus-summary-ignore-duplicates nil
332 "*If non-nil, ignore articles with identical Message-ID headers."
336 (defcustom gnus-single-article-buffer t
337 "*If non-nil, display all articles in the same buffer.
338 If nil, each group will get its own article buffer."
339 :group 'gnus-article-various
342 (defcustom gnus-break-pages t
343 "*If non-nil, do page breaking on articles.
344 The page delimiter is specified by the `gnus-page-delimiter'
346 :group 'gnus-article-various
349 (defcustom gnus-show-mime t
350 "*If non-nil, do mime processing of articles.
351 The articles will simply be fed to the function given by
352 `gnus-article-display-method-for-mime'."
353 :group 'gnus-article-mime
356 (defcustom gnus-move-split-methods nil
357 "*Variable used to suggest where articles are to be moved to.
358 It uses the same syntax as the `gnus-split-methods' variable."
359 :group 'gnus-summary-mail
360 :type '(repeat (choice (list :value (fun) function)
361 (cons :value ("" "") regexp (repeat string))
364 (defcustom gnus-unread-mark ?
365 "*Mark used for unread articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-ticked-mark ?!
370 "*Mark used for ticked articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-dormant-mark ??
375 "*Mark used for dormant articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-del-mark ?r
380 "*Mark used for del'd articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-read-mark ?R
385 "*Mark used for read articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-expirable-mark ?E
390 "*Mark used for expirable articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-killed-mark ?K
395 "*Mark used for killed articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-souped-mark ?F
400 "*Mark used for killed articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-kill-file-mark ?X
405 "*Mark used for articles killed by kill files."
406 :group 'gnus-summary-marks
409 (defcustom gnus-low-score-mark ?Y
410 "*Mark used for articles with a low score."
411 :group 'gnus-summary-marks
414 (defcustom gnus-catchup-mark ?C
415 "*Mark used for articles that are caught up."
416 :group 'gnus-summary-marks
419 (defcustom gnus-replied-mark ?A
420 "*Mark used for articles that have been replied to."
421 :group 'gnus-summary-marks
424 (defcustom gnus-cached-mark ?*
425 "*Mark used for articles that are in the cache."
426 :group 'gnus-summary-marks
429 (defcustom gnus-saved-mark ?S
430 "*Mark used for articles that have been saved to."
431 :group 'gnus-summary-marks
434 (defcustom gnus-ancient-mark ?O
435 "*Mark used for ancient articles."
436 :group 'gnus-summary-marks
439 (defcustom gnus-sparse-mark ?Q
440 "*Mark used for sparsely reffed articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-canceled-mark ?G
445 "*Mark used for canceled articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-duplicate-mark ?M
450 "*Mark used for duplicate articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-undownloaded-mark ?@
455 "*Mark used for articles that weren't downloaded."
456 :group 'gnus-summary-marks
459 (defcustom gnus-downloadable-mark ?%
460 "*Mark used for articles that are to be downloaded."
461 :group 'gnus-summary-marks
464 (defcustom gnus-unsendable-mark ?=
465 "*Mark used for articles that won't be sent."
466 :group 'gnus-summary-marks
469 (defcustom gnus-score-over-mark ?+
470 "*Score mark used for articles with high scores."
471 :group 'gnus-summary-marks
474 (defcustom gnus-score-below-mark ?-
475 "*Score mark used for articles with low scores."
476 :group 'gnus-summary-marks
479 (defcustom gnus-empty-thread-mark ?
480 "*There is no thread under the article."
481 :group 'gnus-summary-marks
484 (defcustom gnus-not-empty-thread-mark ?=
485 "*There is a thread under the article."
486 :group 'gnus-summary-marks
489 (defcustom gnus-view-pseudo-asynchronously nil
490 "*If non-nil, Gnus will view pseudo-articles asynchronously."
491 :group 'gnus-extract-view
494 (defcustom gnus-view-pseudos nil
495 "*If `automatic', pseudo-articles will be viewed automatically.
496 If `not-confirm', pseudos will be viewed automatically, and the user
497 will not be asked to confirm the command."
498 :group 'gnus-extract-view
499 :type '(choice (const :tag "off" nil)
501 (const not-confirm)))
503 (defcustom gnus-view-pseudos-separately t
504 "*If non-nil, one pseudo-article will be created for each file to be viewed.
505 If nil, all files that use the same viewing command will be given as a
506 list of parameters to that command."
507 :group 'gnus-extract-view
510 (defcustom gnus-insert-pseudo-articles t
511 "*If non-nil, insert pseudo-articles when decoding articles."
512 :group 'gnus-extract-view
515 (defcustom gnus-summary-dummy-line-format
517 "*The format specification for the dummy roots in the summary buffer.
518 It works along the same lines as a normal formatting string,
519 with some simple extensions.
522 :group 'gnus-threading
525 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
526 "*The format specification for the summary mode line.
527 It works along the same lines as a normal formatting string,
528 with some simple extensions:
531 %p Unprefixed group name
532 %A Current article number
533 %z Current article score
535 %U Number of unread articles in the group
536 %e Number of unselected articles in the group
537 %Z A string with unread/unselected article counts
538 %g Shortish group name
539 %S Subject of the current article
541 %s Current score file name
542 %d Number of dormant articles
543 %r Number of articles that have been marked as read in this session
544 %E Number of articles expunged by the score files"
545 :group 'gnus-summary-format
548 (defcustom gnus-summary-mark-below 0
549 "*Mark all articles with a score below this variable as read.
550 This variable is local to each summary buffer and usually set by the
552 :group 'gnus-score-default
555 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
556 "*List of functions used for sorting articles in the summary buffer.
557 This variable is only used when not using a threaded display."
558 :group 'gnus-summary-sort
559 :type '(repeat (choice (function-item gnus-article-sort-by-number)
560 (function-item gnus-article-sort-by-author)
561 (function-item gnus-article-sort-by-subject)
562 (function-item gnus-article-sort-by-date)
563 (function-item gnus-article-sort-by-score)
564 (function :tag "other"))))
566 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
567 "*List of functions used for sorting threads in the summary buffer.
568 By default, threads are sorted by article number.
570 Each function takes two threads and return non-nil if the first thread
571 should be sorted before the other. If you use more than one function,
572 the primary sort function should be the last. You should probably
573 always include `gnus-thread-sort-by-number' in the list of sorting
574 functions -- preferably first.
576 Ready-made functions include `gnus-thread-sort-by-number',
577 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
578 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
579 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
580 :group 'gnus-summary-sort
581 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
582 (function-item gnus-thread-sort-by-author)
583 (function-item gnus-thread-sort-by-subject)
584 (function-item gnus-thread-sort-by-date)
585 (function-item gnus-thread-sort-by-score)
586 (function-item gnus-thread-sort-by-total-score)
587 (function :tag "other"))))
589 (defcustom gnus-thread-score-function '+
590 "*Function used for calculating the total score of a thread.
592 The function is called with the scores of the article and each
593 subthread and should then return the score of the thread.
595 Some functions you can use are `+', `max', or `min'."
596 :group 'gnus-summary-sort
599 (defcustom gnus-summary-expunge-below nil
600 "All articles that have a score less than this variable will be expunged.
601 This variable is local to the summary buffers."
602 :group 'gnus-score-default
603 :type '(choice (const :tag "off" nil)
606 (defcustom gnus-thread-expunge-below nil
607 "All threads that have a total score less than this variable will be expunged.
608 See `gnus-thread-score-function' for en explanation of what a
611 This variable is local to the summary buffers."
612 :group 'gnus-treading
613 :group 'gnus-score-default
614 :type '(choice (const :tag "off" nil)
617 (defcustom gnus-summary-mode-hook nil
618 "*A hook for Gnus summary mode.
619 This hook is run before any variables are set in the summary buffer."
620 :group 'gnus-summary-various
623 (defcustom gnus-summary-menu-hook nil
624 "*Hook run after the creation of the summary mode menu."
625 :group 'gnus-summary-visual
628 (defcustom gnus-summary-exit-hook nil
629 "*A hook called on exit from the summary buffer.
630 It will be called with point in the group buffer."
631 :group 'gnus-summary-exit
634 (defcustom gnus-summary-prepare-hook nil
635 "*A hook called after the summary buffer has been generated.
636 If you want to modify the summary buffer, you can use this hook."
637 :group 'gnus-summary-various
640 (defcustom gnus-summary-prepared-hook nil
641 "*A hook called as the last thing after the summary buffer has been generated."
642 :group 'gnus-summary-various
645 (defcustom gnus-summary-generate-hook nil
646 "*A hook run just before generating the summary buffer.
647 This hook is commonly used to customize threading variables and the
649 :group 'gnus-summary-various
652 (defcustom gnus-select-group-hook nil
653 "*A hook called when a newsgroup is selected.
655 If you'd like to simplify subjects like the
656 `gnus-summary-next-same-subject' command does, you can use the
659 (setq gnus-select-group-hook
662 (mapcar (lambda (header)
663 (mail-header-set-subject
665 (gnus-simplify-subject
666 (mail-header-subject header) 're-only)))
667 gnus-newsgroup-headers))))"
668 :group 'gnus-group-select
671 (defcustom gnus-select-article-hook nil
672 "*A hook called when an article is selected."
673 :group 'gnus-summary-choose
676 (defcustom gnus-visual-mark-article-hook
677 (list 'gnus-highlight-selected-summary)
678 "*Hook run after selecting an article in the summary buffer.
679 It is meant to be used for highlighting the article in some way. It
680 is not run if `gnus-visual' is nil."
681 :group 'gnus-summary-visual
684 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
685 "*A hook called before parsing the headers."
689 (defcustom gnus-exit-group-hook nil
690 "*A hook called when exiting (not quitting) summary mode."
694 (defcustom gnus-summary-update-hook
695 (list 'gnus-summary-highlight-line)
696 "*A hook called when a summary line is changed.
697 The hook will not be called if `gnus-visual' is nil.
699 The default function `gnus-summary-highlight-line' will
700 highlight the line according to the `gnus-summary-highlight'
702 :group 'gnus-summary-visual
705 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
706 "*A hook called when an article is selected for the first time.
707 The hook is intended to mark an article as read (or unread)
708 automatically when it is selected."
709 :group 'gnus-summary-choose
712 (defcustom gnus-group-no-more-groups-hook nil
713 "*A hook run when returning to group mode having no more (unread) groups."
714 :group 'gnus-group-select
717 (defcustom gnus-ps-print-hook nil
718 "*A hook run before ps-printing something from Gnus."
722 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
723 "Face used for highlighting the current article in the summary buffer."
724 :group 'gnus-summary-visual
727 (defcustom gnus-summary-highlight
728 '(((= mark gnus-canceled-mark)
729 . gnus-summary-cancelled-face)
730 ((and (> score default)
731 (or (= mark gnus-dormant-mark)
732 (= mark gnus-ticked-mark)))
733 . gnus-summary-high-ticked-face)
734 ((and (< score default)
735 (or (= mark gnus-dormant-mark)
736 (= mark gnus-ticked-mark)))
737 . gnus-summary-low-ticked-face)
738 ((or (= mark gnus-dormant-mark)
739 (= mark gnus-ticked-mark))
740 . gnus-summary-normal-ticked-face)
741 ((and (> score default) (= mark gnus-ancient-mark))
742 . gnus-summary-high-ancient-face)
743 ((and (< score default) (= mark gnus-ancient-mark))
744 . gnus-summary-low-ancient-face)
745 ((= mark gnus-ancient-mark)
746 . gnus-summary-normal-ancient-face)
747 ((and (> score default) (= mark gnus-unread-mark))
748 . gnus-summary-high-unread-face)
749 ((and (< score default) (= mark gnus-unread-mark))
750 . gnus-summary-low-unread-face)
751 ((= mark gnus-unread-mark)
752 . gnus-summary-normal-unread-face)
753 ((and (> score default) (memq mark (list gnus-downloadable-mark
754 gnus-undownloaded-mark)))
755 . gnus-summary-high-unread-face)
756 ((and (< score default) (memq mark (list gnus-downloadable-mark
757 gnus-undownloaded-mark)))
758 . gnus-summary-low-unread-face)
759 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
760 . gnus-summary-normal-unread-face)
762 . gnus-summary-high-read-face)
764 . gnus-summary-low-read-face)
766 . gnus-summary-normal-read-face))
767 "*Controls the highlighting of summary buffer lines.
769 A list of (FORM . FACE) pairs. When deciding how a a particular
770 summary line should be displayed, each form is evaluated. The content
771 of the face field after the first true form is used. You can change
772 how those summary lines are displayed, by editing the face field.
774 You can use the following variables in the FORM field.
776 score: The articles score
777 default: The default article score.
778 below: The score below which articles are automatically marked as read.
779 mark: The articles mark."
780 :group 'gnus-summary-visual
781 :type '(repeat (cons (sexp :tag "Form" nil)
784 (defcustom gnus-alter-header-function nil
785 "Function called to allow alteration of article header structures.
786 The function is called with one parameter, the article header vector,
787 which it may alter in any way.")
789 (defcustom gnus-extra-headers nil
790 "*Extra headers to parse."
792 :type '(repeat symbol))
794 (defcustom gnus-ignored-from-addresses
795 (and user-mail-address (regexp-quote user-mail-address))
796 "*Regexp of From headers that may be suppressed in favor of To headers."
800 ;;; Internal variables
802 (defvar gnus-scores-exclude-files nil)
803 (defvar gnus-page-broken nil)
805 (defvar gnus-original-article nil)
806 (defvar gnus-article-internal-prepare-hook nil)
807 (defvar gnus-newsgroup-process-stack nil)
809 (defvar gnus-thread-indent-array nil)
810 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
812 ;; Avoid highlighting in kill files.
813 (defvar gnus-summary-inhibit-highlight nil)
814 (defvar gnus-newsgroup-selected-overlay nil)
815 (defvar gnus-inhibit-limiting nil)
816 (defvar gnus-newsgroup-adaptive-score-file nil)
817 (defvar gnus-current-score-file nil)
818 (defvar gnus-current-move-group nil)
819 (defvar gnus-current-copy-group nil)
820 (defvar gnus-current-crosspost-group nil)
822 (defvar gnus-newsgroup-dependencies nil)
823 (defvar gnus-newsgroup-adaptive nil)
824 (defvar gnus-summary-display-article-function nil)
825 (defvar gnus-summary-highlight-line-function nil
826 "Function called after highlighting a summary line.")
828 (defvar gnus-summary-line-format-alist
829 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
830 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
831 (?s gnus-tmp-subject-or-nil ?s)
832 (?n gnus-tmp-name ?s)
833 (?A (std11-address-string
834 (car (mime-read-field 'From gnus-tmp-header))) ?s)
835 (?a (or (std11-full-name-string
836 (car (mime-read-field 'From gnus-tmp-header)))
838 (?F gnus-tmp-from ?s)
839 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
840 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
841 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
842 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
843 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
844 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
845 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
846 (?L gnus-tmp-lines ?d)
847 (?I gnus-tmp-indentation ?s)
848 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
849 (?R gnus-tmp-replied ?c)
850 (?\[ gnus-tmp-opening-bracket ?c)
851 (?\] gnus-tmp-closing-bracket ?c)
852 (?\> (make-string gnus-tmp-level ? ) ?s)
853 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
854 (?i gnus-tmp-score ?d)
855 (?z gnus-tmp-score-char ?c)
856 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
857 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
858 (?U gnus-tmp-unread ?c)
859 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
860 (?t (gnus-summary-number-of-articles-in-thread
861 (and (boundp 'thread) (car thread)) gnus-tmp-level)
863 (?e (gnus-summary-number-of-articles-in-thread
864 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
866 (?u gnus-tmp-user-defined ?s)
867 (?P (gnus-pick-line-number) ?d))
868 "An alist of format specifications that can appear in summary lines,
869 and what variables they correspond with, along with the type of the
870 variable (string, integer, character, etc).")
872 (defvar gnus-summary-dummy-line-format-alist
873 `((?S gnus-tmp-subject ?s)
874 (?N gnus-tmp-number ?d)
875 (?u gnus-tmp-user-defined ?s)))
877 (defvar gnus-summary-mode-line-format-alist
878 `((?G gnus-tmp-group-name ?s)
879 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
880 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
881 (?A gnus-tmp-article-number ?d)
882 (?Z gnus-tmp-unread-and-unselected ?s)
884 (?U gnus-tmp-unread-and-unticked ?d)
885 (?S gnus-tmp-subject ?s)
886 (?e gnus-tmp-unselected ?d)
887 (?u gnus-tmp-user-defined ?s)
888 (?d (length gnus-newsgroup-dormant) ?d)
889 (?t (length gnus-newsgroup-marked) ?d)
890 (?r (length gnus-newsgroup-reads) ?d)
891 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
892 (?E gnus-newsgroup-expunged-tally ?d)
893 (?s (gnus-current-score-file-nondirectory) ?s)))
895 (defvar gnus-last-search-regexp nil
896 "Default regexp for article search command.")
898 (defvar gnus-last-shell-command nil
899 "Default shell command on article.")
901 (defvar gnus-newsgroup-begin nil)
902 (defvar gnus-newsgroup-end nil)
903 (defvar gnus-newsgroup-last-rmail nil)
904 (defvar gnus-newsgroup-last-mail nil)
905 (defvar gnus-newsgroup-last-folder nil)
906 (defvar gnus-newsgroup-last-file nil)
907 (defvar gnus-newsgroup-auto-expire nil)
908 (defvar gnus-newsgroup-active nil)
910 (defvar gnus-newsgroup-data nil)
911 (defvar gnus-newsgroup-data-reverse nil)
912 (defvar gnus-newsgroup-limit nil)
913 (defvar gnus-newsgroup-limits nil)
915 (defvar gnus-newsgroup-unreads nil
916 "List of unread articles in the current newsgroup.")
918 (defvar gnus-newsgroup-unselected nil
919 "List of unselected unread articles in the current newsgroup.")
921 (defvar gnus-newsgroup-reads nil
922 "Alist of read articles and article marks in the current newsgroup.")
924 (defvar gnus-newsgroup-expunged-tally nil)
926 (defvar gnus-newsgroup-marked nil
927 "List of ticked articles in the current newsgroup (a subset of unread art).")
929 (defvar gnus-newsgroup-killed nil
930 "List of ranges of articles that have been through the scoring process.")
932 (defvar gnus-newsgroup-cached nil
933 "List of articles that come from the article cache.")
935 (defvar gnus-newsgroup-saved nil
936 "List of articles that have been saved.")
938 (defvar gnus-newsgroup-kill-headers nil)
940 (defvar gnus-newsgroup-replied nil
941 "List of articles that have been replied to in the current newsgroup.")
943 (defvar gnus-newsgroup-expirable nil
944 "List of articles in the current newsgroup that can be expired.")
946 (defvar gnus-newsgroup-processable nil
947 "List of articles in the current newsgroup that can be processed.")
949 (defvar gnus-newsgroup-downloadable nil
950 "List of articles in the current newsgroup that can be processed.")
952 (defvar gnus-newsgroup-undownloaded nil
953 "List of articles in the current newsgroup that haven't been downloaded..")
955 (defvar gnus-newsgroup-unsendable nil
956 "List of articles in the current newsgroup that won't be sent.")
958 (defvar gnus-newsgroup-bookmarks nil
959 "List of articles in the current newsgroup that have bookmarks.")
961 (defvar gnus-newsgroup-dormant nil
962 "List of dormant articles in the current newsgroup.")
964 (defvar gnus-newsgroup-scored nil
965 "List of scored articles in the current newsgroup.")
967 (defvar gnus-newsgroup-headers nil
968 "List of article headers in the current newsgroup.")
970 (defvar gnus-newsgroup-threads nil)
972 (defvar gnus-newsgroup-prepared nil
973 "Whether the current group has been prepared properly.")
975 (defvar gnus-newsgroup-ancient nil
976 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
978 (defvar gnus-newsgroup-sparse nil)
980 (defvar gnus-current-article nil)
981 (defvar gnus-article-current nil)
982 (defvar gnus-current-headers nil)
983 (defvar gnus-have-all-headers nil)
984 (defvar gnus-last-article nil)
985 (defvar gnus-newsgroup-history nil)
987 (defconst gnus-summary-local-variables
988 '(gnus-newsgroup-name
989 gnus-newsgroup-begin gnus-newsgroup-end
990 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
991 gnus-newsgroup-last-folder gnus-newsgroup-last-file
992 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
993 gnus-newsgroup-unselected gnus-newsgroup-marked
994 gnus-newsgroup-reads gnus-newsgroup-saved
995 gnus-newsgroup-replied gnus-newsgroup-expirable
996 gnus-newsgroup-processable gnus-newsgroup-killed
997 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
998 gnus-newsgroup-unsendable
999 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1000 gnus-newsgroup-headers gnus-newsgroup-threads
1001 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1002 gnus-current-article gnus-current-headers gnus-have-all-headers
1003 gnus-last-article gnus-article-internal-prepare-hook
1004 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1005 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1006 gnus-thread-expunge-below
1007 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1008 (gnus-summary-mark-below . global)
1009 gnus-newsgroup-active gnus-scores-exclude-files
1010 gnus-newsgroup-history gnus-newsgroup-ancient
1011 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1012 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1013 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1014 (gnus-newsgroup-expunged-tally . 0)
1015 gnus-cache-removable-articles gnus-newsgroup-cached
1016 gnus-newsgroup-data gnus-newsgroup-data-reverse
1017 gnus-newsgroup-limit gnus-newsgroup-limits)
1018 "Variables that are buffer-local to the summary buffers.")
1020 ;; Byte-compiler warning.
1021 (defvar gnus-article-mode-map)
1023 ;; Subject simplification.
1025 (defun gnus-simplify-whitespace (str)
1026 "Remove excessive whitespace."
1029 (while (string-match "[ \t][ \t]+" mystr)
1030 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1032 (substring mystr (match-end 0)))))
1034 (when (string-match "^[ \t]+" mystr)
1035 (setq mystr (substring mystr (match-end 0))))
1037 (when (string-match "[ \t]+$" mystr)
1038 (setq mystr (substring mystr 0 (match-beginning 0))))
1041 (defsubst gnus-simplify-subject-re (subject)
1042 "Remove \"Re:\" from subject lines."
1043 (if (string-match "^[Rr][Ee]: *" subject)
1044 (substring subject (match-end 0))
1047 (defun gnus-simplify-subject (subject &optional re-only)
1048 "Remove `Re:' and words in parentheses.
1049 If RE-ONLY is non-nil, strip leading `Re:'s only."
1050 (let ((case-fold-search t)) ;Ignore case.
1051 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1052 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1053 (setq subject (substring subject (match-end 0))))
1054 ;; Remove uninteresting prefixes.
1055 (when (and (not re-only)
1056 gnus-simplify-ignored-prefixes
1057 (string-match gnus-simplify-ignored-prefixes subject))
1058 (setq subject (substring subject (match-end 0))))
1059 ;; Remove words in parentheses from end.
1061 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1062 (setq subject (substring subject 0 (match-beginning 0)))))
1063 ;; Return subject string.
1066 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1068 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1069 (goto-char (point-min))
1070 (while (re-search-forward regexp nil t)
1071 (replace-match (or newtext ""))))
1073 (defun gnus-simplify-buffer-fuzzy ()
1074 "Simplify string in the buffer fuzzily.
1075 The string in the accessible portion of the current buffer is simplified.
1076 It is assumed to be a single-line subject.
1077 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1078 matter is removed. Additional things can be deleted by setting
1079 gnus-simplify-subject-fuzzy-regexp."
1080 (let ((case-fold-search t)
1082 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1084 (while (not (eq modified-tick (buffer-modified-tick)))
1085 (setq modified-tick (buffer-modified-tick))
1087 ((listp gnus-simplify-subject-fuzzy-regexp)
1088 (mapcar 'gnus-simplify-buffer-fuzzy-step
1089 gnus-simplify-subject-fuzzy-regexp))
1090 (gnus-simplify-subject-fuzzy-regexp
1091 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1092 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1093 (gnus-simplify-buffer-fuzzy-step
1094 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1095 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1097 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1098 (gnus-simplify-buffer-fuzzy-step " +" " ")
1099 (gnus-simplify-buffer-fuzzy-step " $")
1100 (gnus-simplify-buffer-fuzzy-step "^ +")))
1102 (defun gnus-simplify-subject-fuzzy (subject)
1103 "Simplify a subject string fuzzily.
1104 See `gnus-simplify-buffer-fuzzy' for details."
1106 (gnus-set-work-buffer)
1107 (let ((case-fold-search t))
1108 ;; Remove uninteresting prefixes.
1109 (when (and gnus-simplify-ignored-prefixes
1110 (string-match gnus-simplify-ignored-prefixes subject))
1111 (setq subject (substring subject (match-end 0))))
1113 (inline (gnus-simplify-buffer-fuzzy))
1116 (defsubst gnus-simplify-subject-fully (subject)
1117 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1119 (gnus-simplify-subject-functions
1120 (gnus-map-function gnus-simplify-subject-functions subject))
1121 ((null gnus-summary-gather-subject-limit)
1122 (gnus-simplify-subject-re subject))
1123 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1124 (gnus-simplify-subject-fuzzy subject))
1125 ((numberp gnus-summary-gather-subject-limit)
1126 (gnus-limit-string (gnus-simplify-subject-re subject)
1127 gnus-summary-gather-subject-limit))
1131 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1132 "Check whether two subjects are equal.
1133 If optional argument simple-first is t, first argument is already
1136 ((null simple-first)
1137 (equal (gnus-simplify-subject-fully s1)
1138 (gnus-simplify-subject-fully s2)))
1141 (gnus-simplify-subject-fully s2)))))
1143 (defun gnus-summary-bubble-group ()
1144 "Increase the score of the current group.
1145 This is a handy function to add to `gnus-summary-exit-hook' to
1146 increase the score of each group you read."
1147 (gnus-group-add-score gnus-newsgroup-name))
1151 ;;; Gnus summary mode
1154 (put 'gnus-summary-mode 'mode-class 'special)
1157 ;; Non-orthogonal keys
1159 (gnus-define-keys gnus-summary-mode-map
1160 " " gnus-summary-next-page
1161 "\177" gnus-summary-prev-page
1162 [delete] gnus-summary-prev-page
1163 [backspace] gnus-summary-prev-page
1164 "\r" gnus-summary-scroll-up
1165 "\M-\r" gnus-summary-scroll-down
1166 "n" gnus-summary-next-unread-article
1167 "p" gnus-summary-prev-unread-article
1168 "N" gnus-summary-next-article
1169 "P" gnus-summary-prev-article
1170 "\M-\C-n" gnus-summary-next-same-subject
1171 "\M-\C-p" gnus-summary-prev-same-subject
1172 "\M-n" gnus-summary-next-unread-subject
1173 "\M-p" gnus-summary-prev-unread-subject
1174 "." gnus-summary-first-unread-article
1175 "," gnus-summary-best-unread-article
1176 "\M-s" gnus-summary-search-article-forward
1177 "\M-r" gnus-summary-search-article-backward
1178 "<" gnus-summary-beginning-of-article
1179 ">" gnus-summary-end-of-article
1180 "j" gnus-summary-goto-article
1181 "^" gnus-summary-refer-parent-article
1182 "\M-^" gnus-summary-refer-article
1183 "u" gnus-summary-tick-article-forward
1184 "!" gnus-summary-tick-article-forward
1185 "U" gnus-summary-tick-article-backward
1186 "d" gnus-summary-mark-as-read-forward
1187 "D" gnus-summary-mark-as-read-backward
1188 "E" gnus-summary-mark-as-expirable
1189 "\M-u" gnus-summary-clear-mark-forward
1190 "\M-U" gnus-summary-clear-mark-backward
1191 "k" gnus-summary-kill-same-subject-and-select
1192 "\C-k" gnus-summary-kill-same-subject
1193 "\M-\C-k" gnus-summary-kill-thread
1194 "\M-\C-l" gnus-summary-lower-thread
1195 "e" gnus-summary-edit-article
1196 "#" gnus-summary-mark-as-processable
1197 "\M-#" gnus-summary-unmark-as-processable
1198 "\M-\C-t" gnus-summary-toggle-threads
1199 "\M-\C-s" gnus-summary-show-thread
1200 "\M-\C-h" gnus-summary-hide-thread
1201 "\M-\C-f" gnus-summary-next-thread
1202 "\M-\C-b" gnus-summary-prev-thread
1203 "\M-\C-u" gnus-summary-up-thread
1204 "\M-\C-d" gnus-summary-down-thread
1205 "&" gnus-summary-execute-command
1206 "c" gnus-summary-catchup-and-exit
1207 "\C-w" gnus-summary-mark-region-as-read
1208 "\C-t" gnus-summary-toggle-truncation
1209 "?" gnus-summary-mark-as-dormant
1210 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1211 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1212 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1213 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1214 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1215 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1216 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1217 "=" gnus-summary-expand-window
1218 "\C-x\C-s" gnus-summary-reselect-current-group
1219 "\M-g" gnus-summary-rescan-group
1220 "w" gnus-summary-stop-page-breaking
1221 "\C-c\C-r" gnus-summary-caesar-message
1222 "\M-t" gnus-summary-toggle-mime
1223 "f" gnus-summary-followup
1224 "F" gnus-summary-followup-with-original
1225 "C" gnus-summary-cancel-article
1226 "r" gnus-summary-reply
1227 "R" gnus-summary-reply-with-original
1228 "\C-c\C-f" gnus-summary-mail-forward
1229 "o" gnus-summary-save-article
1230 "\C-o" gnus-summary-save-article-mail
1231 "|" gnus-summary-pipe-output
1232 "\M-k" gnus-summary-edit-local-kill
1233 "\M-K" gnus-summary-edit-global-kill
1235 "\C-c\C-d" gnus-summary-describe-group
1236 "q" gnus-summary-exit
1237 "Q" gnus-summary-exit-no-update
1238 "\C-c\C-i" gnus-info-find-node
1239 gnus-mouse-2 gnus-mouse-pick-article
1240 "m" gnus-summary-mail-other-window
1241 "a" gnus-summary-post-news
1242 "x" gnus-summary-limit-to-unread
1243 "s" gnus-summary-isearch-article
1244 "t" gnus-article-hide-headers
1245 "g" gnus-summary-show-article
1246 "l" gnus-summary-goto-last-article
1247 "v" gnus-summary-preview-mime-message
1248 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1249 "\C-d" gnus-summary-enter-digest-group
1250 "\M-\C-d" gnus-summary-read-document
1251 "\M-\C-e" gnus-summary-edit-parameters
1253 "*" gnus-cache-enter-article
1254 "\M-*" gnus-cache-remove-article
1255 "\M-&" gnus-summary-universal-argument
1256 "\C-l" gnus-recenter
1257 "I" gnus-summary-increase-score
1258 "L" gnus-summary-lower-score
1259 "\M-i" gnus-symbolic-argument
1260 "h" gnus-summary-select-article-buffer
1262 "V" gnus-summary-score-map
1263 "X" gnus-uu-extract-map
1264 "S" gnus-summary-send-map)
1266 ;; Sort of orthogonal keymap
1267 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1268 "t" gnus-summary-tick-article-forward
1269 "!" gnus-summary-tick-article-forward
1270 "d" gnus-summary-mark-as-read-forward
1271 "r" gnus-summary-mark-as-read-forward
1272 "c" gnus-summary-clear-mark-forward
1273 " " gnus-summary-clear-mark-forward
1274 "e" gnus-summary-mark-as-expirable
1275 "x" gnus-summary-mark-as-expirable
1276 "?" gnus-summary-mark-as-dormant
1277 "b" gnus-summary-set-bookmark
1278 "B" gnus-summary-remove-bookmark
1279 "#" gnus-summary-mark-as-processable
1280 "\M-#" gnus-summary-unmark-as-processable
1281 "S" gnus-summary-limit-include-expunged
1282 "C" gnus-summary-catchup
1283 "H" gnus-summary-catchup-to-here
1284 "\C-c" gnus-summary-catchup-all
1285 "k" gnus-summary-kill-same-subject-and-select
1286 "K" gnus-summary-kill-same-subject
1287 "P" gnus-uu-mark-map)
1289 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1290 "c" gnus-summary-clear-above
1291 "u" gnus-summary-tick-above
1292 "m" gnus-summary-mark-above
1293 "k" gnus-summary-kill-below)
1295 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1296 "/" gnus-summary-limit-to-subject
1297 "n" gnus-summary-limit-to-articles
1298 "w" gnus-summary-pop-limit
1299 "s" gnus-summary-limit-to-subject
1300 "a" gnus-summary-limit-to-author
1301 "u" gnus-summary-limit-to-unread
1302 "m" gnus-summary-limit-to-marks
1303 "v" gnus-summary-limit-to-score
1304 "*" gnus-summary-limit-include-cached
1305 "D" gnus-summary-limit-include-dormant
1306 "T" gnus-summary-limit-include-thread
1307 "d" gnus-summary-limit-exclude-dormant
1308 "t" gnus-summary-limit-to-age
1309 "E" gnus-summary-limit-include-expunged
1310 "c" gnus-summary-limit-exclude-childless-dormant
1311 "C" gnus-summary-limit-mark-excluded-as-read)
1313 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1314 "n" gnus-summary-next-unread-article
1315 "p" gnus-summary-prev-unread-article
1316 "N" gnus-summary-next-article
1317 "P" gnus-summary-prev-article
1318 "\C-n" gnus-summary-next-same-subject
1319 "\C-p" gnus-summary-prev-same-subject
1320 "\M-n" gnus-summary-next-unread-subject
1321 "\M-p" gnus-summary-prev-unread-subject
1322 "f" gnus-summary-first-unread-article
1323 "b" gnus-summary-best-unread-article
1324 "j" gnus-summary-goto-article
1325 "g" gnus-summary-goto-subject
1326 "l" gnus-summary-goto-last-article
1327 "o" gnus-summary-pop-article)
1329 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1330 "k" gnus-summary-kill-thread
1331 "l" gnus-summary-lower-thread
1332 "i" gnus-summary-raise-thread
1333 "T" gnus-summary-toggle-threads
1334 "t" gnus-summary-rethread-current
1335 "^" gnus-summary-reparent-thread
1336 "s" gnus-summary-show-thread
1337 "S" gnus-summary-show-all-threads
1338 "h" gnus-summary-hide-thread
1339 "H" gnus-summary-hide-all-threads
1340 "n" gnus-summary-next-thread
1341 "p" gnus-summary-prev-thread
1342 "u" gnus-summary-up-thread
1343 "o" gnus-summary-top-thread
1344 "d" gnus-summary-down-thread
1345 "#" gnus-uu-mark-thread
1346 "\M-#" gnus-uu-unmark-thread)
1348 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1349 "g" gnus-summary-prepare
1350 "c" gnus-summary-insert-cached-articles)
1352 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1353 "c" gnus-summary-catchup-and-exit
1354 "C" gnus-summary-catchup-all-and-exit
1355 "E" gnus-summary-exit-no-update
1356 "Q" gnus-summary-exit
1357 "Z" gnus-summary-exit
1358 "n" gnus-summary-catchup-and-goto-next-group
1359 "R" gnus-summary-reselect-current-group
1360 "G" gnus-summary-rescan-group
1361 "N" gnus-summary-next-group
1362 "s" gnus-summary-save-newsrc
1363 "P" gnus-summary-prev-group)
1365 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1366 " " gnus-summary-next-page
1367 "n" gnus-summary-next-page
1368 "\177" gnus-summary-prev-page
1369 [delete] gnus-summary-prev-page
1370 "p" gnus-summary-prev-page
1371 "\r" gnus-summary-scroll-up
1372 "\M-\r" gnus-summary-scroll-down
1373 "<" gnus-summary-beginning-of-article
1374 ">" gnus-summary-end-of-article
1375 "b" gnus-summary-beginning-of-article
1376 "e" gnus-summary-end-of-article
1377 "^" gnus-summary-refer-parent-article
1378 "r" gnus-summary-refer-parent-article
1379 "R" gnus-summary-refer-references
1380 "T" gnus-summary-refer-thread
1381 "g" gnus-summary-show-article
1382 "s" gnus-summary-isearch-article
1383 "P" gnus-summary-print-article)
1385 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1386 "b" gnus-article-add-buttons
1387 "B" gnus-article-add-buttons-to-head
1388 "o" gnus-article-treat-overstrike
1389 "e" gnus-article-emphasize
1390 "w" gnus-article-fill-cited-article
1391 "c" gnus-article-remove-cr
1392 "f" gnus-article-display-x-face
1393 "l" gnus-summary-stop-page-breaking
1394 "r" gnus-summary-caesar-message
1395 "t" gnus-article-hide-headers
1396 "v" gnus-summary-verbose-headers
1397 "m" gnus-summary-toggle-mime
1398 "h" gnus-article-treat-html
1399 "d" gnus-article-treat-dumbquotes)
1401 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1402 "a" gnus-article-hide
1403 "h" gnus-article-hide-headers
1404 "b" gnus-article-hide-boring-headers
1405 "s" gnus-article-hide-signature
1406 "c" gnus-article-hide-citation
1407 "C" gnus-article-hide-citation-in-followups
1408 "p" gnus-article-hide-pgp
1409 "P" gnus-article-hide-pem
1410 "\C-c" gnus-article-hide-citation-maybe)
1412 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1413 "a" gnus-article-highlight
1414 "h" gnus-article-highlight-headers
1415 "c" gnus-article-highlight-citation
1416 "s" gnus-article-highlight-signature)
1418 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1419 "z" gnus-article-date-ut
1420 "u" gnus-article-date-ut
1421 "l" gnus-article-date-local
1422 "e" gnus-article-date-lapsed
1423 "o" gnus-article-date-original
1424 "i" gnus-article-date-iso8601
1425 "s" gnus-article-date-user)
1427 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1428 "t" gnus-article-remove-trailing-blank-lines
1429 "l" gnus-article-strip-leading-blank-lines
1430 "m" gnus-article-strip-multiple-blank-lines
1431 "a" gnus-article-strip-blank-lines
1432 "A" gnus-article-strip-all-blank-lines
1433 "s" gnus-article-strip-leading-space)
1435 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1437 "f" gnus-summary-fetch-faq
1438 "d" gnus-summary-describe-group
1439 "h" gnus-summary-describe-briefly
1440 "i" gnus-info-find-node)
1442 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1443 "e" gnus-summary-expire-articles
1444 "\M-\C-e" gnus-summary-expire-articles-now
1445 "\177" gnus-summary-delete-article
1446 [delete] gnus-summary-delete-article
1447 "m" gnus-summary-move-article
1448 "r" gnus-summary-respool-article
1449 "w" gnus-summary-edit-article
1450 "c" gnus-summary-copy-article
1451 "B" gnus-summary-crosspost-article
1452 "q" gnus-summary-respool-query
1453 "t" gnus-summary-respool-trace
1454 "i" gnus-summary-import-article
1455 "p" gnus-summary-article-posted-p)
1457 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1458 "o" gnus-summary-save-article
1459 "m" gnus-summary-save-article-mail
1460 "F" gnus-summary-write-article-file
1461 "r" gnus-summary-save-article-rmail
1462 "f" gnus-summary-save-article-file
1463 "b" gnus-summary-save-article-body-file
1464 "h" gnus-summary-save-article-folder
1465 "v" gnus-summary-save-article-vm
1466 "p" gnus-summary-pipe-output
1467 "s" gnus-soup-add-article))
1469 (defun gnus-summary-make-menu-bar ()
1470 (gnus-turn-off-edit-menu 'summary)
1472 (unless (boundp 'gnus-summary-misc-menu)
1475 gnus-summary-kill-menu gnus-summary-mode-map ""
1480 ["Enter score..." gnus-summary-score-entry t]
1481 ["Customize" gnus-score-customize t])
1482 (gnus-make-score-map 'increase)
1483 (gnus-make-score-map 'lower)
1485 ["Kill below" gnus-summary-kill-below t]
1486 ["Mark above" gnus-summary-mark-above t]
1487 ["Tick above" gnus-summary-tick-above t]
1488 ["Clear above" gnus-summary-clear-above t])
1489 ["Current score" gnus-summary-current-score t]
1490 ["Set score" gnus-summary-set-score t]
1491 ["Switch current score file..." gnus-score-change-score-file t]
1492 ["Set mark below..." gnus-score-set-mark-below t]
1493 ["Set expunge below..." gnus-score-set-expunge-below t]
1494 ["Edit current score file" gnus-score-edit-current-scores t]
1495 ["Edit score file" gnus-score-edit-file t]
1496 ["Trace score" gnus-score-find-trace t]
1497 ["Find words" gnus-score-find-favourite-words t]
1498 ["Rescore buffer" gnus-summary-rescore t]
1499 ["Increase score..." gnus-summary-increase-score t]
1500 ["Lower score..." gnus-summary-lower-score t]))))
1502 ;; Define both the Article menu in the summary buffer and the equivalent
1503 ;; Commands menu in the article buffer here for consistency.
1506 ["All" gnus-article-hide t]
1507 ["Headers" gnus-article-hide-headers t]
1508 ["Signature" gnus-article-hide-signature t]
1509 ["Citation" gnus-article-hide-citation t]
1510 ["PGP" gnus-article-hide-pgp t]
1511 ["Boring headers" gnus-article-hide-boring-headers t])
1513 ["All" gnus-article-highlight t]
1514 ["Headers" gnus-article-highlight-headers t]
1515 ["Signature" gnus-article-highlight-signature t]
1516 ["Citation" gnus-article-highlight-citation t])
1518 ["Local" gnus-article-date-local t]
1519 ["ISO8601" gnus-article-date-iso8601 t]
1520 ["UT" gnus-article-date-ut t]
1521 ["Original" gnus-article-date-original t]
1522 ["Lapsed" gnus-article-date-lapsed t]
1523 ["User-defined" gnus-article-date-user t])
1526 ["Leading" gnus-article-strip-leading-blank-lines t]
1527 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1528 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1529 ["All of the above" gnus-article-strip-blank-lines t]
1530 ["All" gnus-article-strip-all-blank-lines t]
1531 ["Leading space" gnus-article-strip-leading-space t])
1532 ["Overstrike" gnus-article-treat-overstrike t]
1533 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1534 ["Emphasis" gnus-article-emphasize t]
1535 ["Word wrap" gnus-article-fill-cited-article t]
1536 ["CR" gnus-article-remove-cr t]
1537 ["Show X-Face" gnus-article-display-x-face t]
1538 ["UnHTMLize" gnus-article-treat-html t]
1539 ["Rot 13" gnus-summary-caesar-message t]
1540 ["Unix pipe" gnus-summary-pipe-message t]
1541 ["Add buttons" gnus-article-add-buttons t]
1542 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1543 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1544 ["Toggle MIME" gnus-summary-toggle-mime t]
1545 ["Verbose header" gnus-summary-verbose-headers t]
1546 ["Toggle header" gnus-summary-toggle-header t])
1548 ["Save in default format" gnus-summary-save-article t]
1549 ["Save in file" gnus-summary-save-article-file t]
1550 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1551 ["Save in MH folder" gnus-summary-save-article-folder t]
1552 ["Save in VM folder" gnus-summary-save-article-vm t]
1553 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1554 ["Save body in file" gnus-summary-save-article-body-file t]
1555 ["Pipe through a filter" gnus-summary-pipe-output t]
1556 ["Add to SOUP packet" gnus-soup-add-article t]
1557 ["Print" gnus-summary-print-article t])
1559 ["Respool article..." gnus-summary-respool-article t]
1560 ["Move article..." gnus-summary-move-article
1561 (gnus-check-backend-function
1562 'request-move-article gnus-newsgroup-name)]
1563 ["Copy article..." gnus-summary-copy-article t]
1564 ["Crosspost article..." gnus-summary-crosspost-article
1565 (gnus-check-backend-function
1566 'request-replace-article gnus-newsgroup-name)]
1567 ["Import file..." gnus-summary-import-article t]
1568 ["Check if posted" gnus-summary-article-posted-p t]
1569 ["Edit article" gnus-summary-edit-article
1570 (not (gnus-group-read-only-p))]
1571 ["Delete article" gnus-summary-delete-article
1572 (gnus-check-backend-function
1573 'request-expire-articles gnus-newsgroup-name)]
1574 ["Query respool" gnus-summary-respool-query t]
1575 ["Trace respool" gnus-summary-respool-trace t]
1576 ["Delete expirable articles" gnus-summary-expire-articles-now
1577 (gnus-check-backend-function
1578 'request-expire-articles gnus-newsgroup-name)])
1580 ["Uudecode" gnus-uu-decode-uu t]
1581 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1582 ["Unshar" gnus-uu-decode-unshar t]
1583 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1584 ["Save" gnus-uu-decode-save t]
1585 ["Binhex" gnus-uu-decode-binhex t]
1586 ["Postscript" gnus-uu-decode-postscript t])
1588 ["Enter article" gnus-cache-enter-article t]
1589 ["Remove article" gnus-cache-remove-article t])
1590 ["Select article buffer" gnus-summary-select-article-buffer t]
1591 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1592 ["Isearch article..." gnus-summary-isearch-article t]
1593 ["Beginning of the article" gnus-summary-beginning-of-article t]
1594 ["End of the article" gnus-summary-end-of-article t]
1595 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1596 ["Fetch referenced articles" gnus-summary-refer-references t]
1597 ["Fetch current thread" gnus-summary-refer-thread t]
1598 ["Fetch article with id..." gnus-summary-refer-article t]
1599 ["Redisplay" gnus-summary-show-article t])))
1601 gnus-summary-article-menu gnus-summary-mode-map ""
1602 (cons "Article" innards))
1605 gnus-article-commands-menu gnus-article-mode-map ""
1606 (cons "Commands" innards)))
1609 gnus-summary-thread-menu gnus-summary-mode-map ""
1611 ["Toggle threading" gnus-summary-toggle-threads t]
1612 ["Hide threads" gnus-summary-hide-all-threads t]
1613 ["Show threads" gnus-summary-show-all-threads t]
1614 ["Hide thread" gnus-summary-hide-thread t]
1615 ["Show thread" gnus-summary-show-thread t]
1616 ["Go to next thread" gnus-summary-next-thread t]
1617 ["Go to previous thread" gnus-summary-prev-thread t]
1618 ["Go down thread" gnus-summary-down-thread t]
1619 ["Go up thread" gnus-summary-up-thread t]
1620 ["Top of thread" gnus-summary-top-thread t]
1621 ["Mark thread as read" gnus-summary-kill-thread t]
1622 ["Lower thread score" gnus-summary-lower-thread t]
1623 ["Raise thread score" gnus-summary-raise-thread t]
1624 ["Rethread current" gnus-summary-rethread-current t]
1628 gnus-summary-post-menu gnus-summary-mode-map ""
1630 ["Post an article" gnus-summary-post-news t]
1631 ["Followup" gnus-summary-followup t]
1632 ["Followup and yank" gnus-summary-followup-with-original t]
1633 ["Supersede article" gnus-summary-supersede-article t]
1634 ["Cancel article" gnus-summary-cancel-article t]
1635 ["Reply" gnus-summary-reply t]
1636 ["Reply and yank" gnus-summary-reply-with-original t]
1637 ["Wide reply" gnus-summary-wide-reply t]
1638 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1639 ["Mail forward" gnus-summary-mail-forward t]
1640 ["Post forward" gnus-summary-post-forward t]
1641 ["Digest and mail" gnus-summary-mail-digest t]
1642 ["Digest and post" gnus-summary-post-digest t]
1643 ["Resend message" gnus-summary-resend-message t]
1644 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1645 ["Send a mail" gnus-summary-mail-other-window t]
1646 ["Uuencode and post" gnus-uu-post-news t]
1647 ["Followup via news" gnus-summary-followup-to-mail t]
1648 ["Followup via news and yank"
1649 gnus-summary-followup-to-mail-with-original t]
1651 ;;["Send" gnus-summary-send-draft t]
1652 ;;["Send bounced" gnus-resend-bounced-mail t])
1656 gnus-summary-misc-menu gnus-summary-mode-map ""
1659 ["Mark as read" gnus-summary-mark-as-read-forward t]
1660 ["Mark same subject and select"
1661 gnus-summary-kill-same-subject-and-select t]
1662 ["Mark same subject" gnus-summary-kill-same-subject t]
1663 ["Catchup" gnus-summary-catchup t]
1664 ["Catchup all" gnus-summary-catchup-all t]
1665 ["Catchup to here" gnus-summary-catchup-to-here t]
1666 ["Catchup region" gnus-summary-mark-region-as-read t]
1667 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1669 ["Tick" gnus-summary-tick-article-forward t]
1670 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1671 ["Remove marks" gnus-summary-clear-mark-forward t]
1672 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1673 ["Set bookmark" gnus-summary-set-bookmark t]
1674 ["Remove bookmark" gnus-summary-remove-bookmark t])
1676 ["Marks..." gnus-summary-limit-to-marks t]
1677 ["Subject..." gnus-summary-limit-to-subject t]
1678 ["Author..." gnus-summary-limit-to-author t]
1679 ["Age..." gnus-summary-limit-to-age t]
1680 ["Score" gnus-summary-limit-to-score t]
1681 ["Unread" gnus-summary-limit-to-unread t]
1682 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1683 ["Articles" gnus-summary-limit-to-articles t]
1684 ["Pop limit" gnus-summary-pop-limit t]
1685 ["Show dormant" gnus-summary-limit-include-dormant t]
1686 ["Hide childless dormant"
1687 gnus-summary-limit-exclude-childless-dormant t]
1688 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1689 ["Show expunged" gnus-summary-show-all-expunged t])
1691 ["Set mark" gnus-summary-mark-as-processable t]
1692 ["Remove mark" gnus-summary-unmark-as-processable t]
1693 ["Remove all marks" gnus-summary-unmark-all-processable t]
1694 ["Mark above" gnus-uu-mark-over t]
1695 ["Mark series" gnus-uu-mark-series t]
1696 ["Mark region" gnus-uu-mark-region t]
1697 ["Unmark region" gnus-uu-unmark-region t]
1698 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1699 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1700 ["Mark all" gnus-uu-mark-all t]
1701 ["Mark buffer" gnus-uu-mark-buffer t]
1702 ["Mark sparse" gnus-uu-mark-sparse t]
1703 ["Mark thread" gnus-uu-mark-thread t]
1704 ["Unmark thread" gnus-uu-unmark-thread t]
1705 ("Process Mark Sets"
1706 ["Kill" gnus-summary-kill-process-mark t]
1707 ["Yank" gnus-summary-yank-process-mark
1708 gnus-newsgroup-process-stack]
1709 ["Save" gnus-summary-save-process-mark t]))
1711 ["Page forward" gnus-summary-next-page t]
1712 ["Page backward" gnus-summary-prev-page t]
1713 ["Line forward" gnus-summary-scroll-up t])
1715 ["Next unread article" gnus-summary-next-unread-article t]
1716 ["Previous unread article" gnus-summary-prev-unread-article t]
1717 ["Next article" gnus-summary-next-article t]
1718 ["Previous article" gnus-summary-prev-article t]
1719 ["Next unread subject" gnus-summary-next-unread-subject t]
1720 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1721 ["Next article same subject" gnus-summary-next-same-subject t]
1722 ["Previous article same subject" gnus-summary-prev-same-subject t]
1723 ["First unread article" gnus-summary-first-unread-article t]
1724 ["Best unread article" gnus-summary-best-unread-article t]
1725 ["Go to subject number..." gnus-summary-goto-subject t]
1726 ["Go to article number..." gnus-summary-goto-article t]
1727 ["Go to the last article" gnus-summary-goto-last-article t]
1728 ["Pop article off history" gnus-summary-pop-article t])
1730 ["Sort by number" gnus-summary-sort-by-number t]
1731 ["Sort by author" gnus-summary-sort-by-author t]
1732 ["Sort by subject" gnus-summary-sort-by-subject t]
1733 ["Sort by date" gnus-summary-sort-by-date t]
1734 ["Sort by score" gnus-summary-sort-by-score t]
1735 ["Sort by lines" gnus-summary-sort-by-lines t])
1737 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1738 ["Describe group" gnus-summary-describe-group t]
1739 ["Read manual" gnus-info-find-node t])
1741 ["Pick and read" gnus-pick-mode t]
1742 ["Binary" gnus-binary-mode t])
1744 ["Regenerate" gnus-summary-prepare t]
1745 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1746 ["Toggle threading" gnus-summary-toggle-threads t])
1747 ["Filter articles..." gnus-summary-execute-command t]
1748 ["Run command on subjects..." gnus-summary-universal-argument t]
1749 ["Search articles forward..." gnus-summary-search-article-forward t]
1750 ["Search articles backward..." gnus-summary-search-article-backward t]
1751 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1752 ["Expand window" gnus-summary-expand-window t]
1753 ["Expire expirable articles" gnus-summary-expire-articles
1754 (gnus-check-backend-function
1755 'request-expire-articles gnus-newsgroup-name)]
1756 ["Edit local kill file" gnus-summary-edit-local-kill t]
1757 ["Edit main kill file" gnus-summary-edit-global-kill t]
1758 ["Edit group parameters" gnus-summary-edit-parameters t]
1759 ["Send a bug report" gnus-bug t]
1761 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1762 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1763 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1764 ["Exit group" gnus-summary-exit t]
1765 ["Exit group without updating" gnus-summary-exit-no-update t]
1766 ["Exit and goto next group" gnus-summary-next-group t]
1767 ["Exit and goto prev group" gnus-summary-prev-group t]
1768 ["Reselect group" gnus-summary-reselect-current-group t]
1769 ["Rescan group" gnus-summary-rescan-group t]
1770 ["Update dribble" gnus-summary-save-newsrc t])))
1772 (gnus-run-hooks 'gnus-summary-menu-hook)))
1774 (defun gnus-score-set-default (var value)
1775 "A version of set that updates the GNU Emacs menu-bar."
1777 ;; It is the message that forces the active status to be updated.
1780 (defun gnus-make-score-map (type)
1781 "Make a summary score map of type TYPE."
1784 (let ((headers '(("author" "from" string)
1785 ("subject" "subject" string)
1786 ("article body" "body" string)
1787 ("article head" "head" string)
1788 ("xref" "xref" string)
1789 ("extra header" "extra" string)
1790 ("lines" "lines" number)
1791 ("followups to author" "followup" string)))
1792 (types '((number ("less than" <)
1795 (string ("substring" s)
1799 (perms '(("temporary" (current-time-string))
1807 (if (eq type 'lower)
1812 (setq header (car headers))
1818 (let ((ts (cdr (assoc (nth 2 header) types)))
1834 'gnus-summary-score-entry
1836 (if (or (string= (nth 1 header)
1838 (string= (nth 1 header)
1841 (list 'gnus-summary-header
1843 (list 'quote (nth 1 (car ts)))
1844 (list 'gnus-score-default nil)
1850 (list (nreverse outp))))
1853 (list (nreverse outt))))
1855 (setq headers (cdr headers)))
1856 (list (nreverse outh))))))))
1860 (defun gnus-summary-mode (&optional group)
1861 "Major mode for reading articles.
1863 All normal editing commands are switched off.
1864 \\<gnus-summary-mode-map>
1865 Each line in this buffer represents one article. To read an
1866 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1867 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1870 You can also post articles and send mail from this buffer. To
1871 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1872 of an article, type `\\[gnus-summary-reply]'.
1874 There are approx. one gazillion commands you can execute in this
1875 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1877 The following commands are available:
1879 \\{gnus-summary-mode-map}"
1881 (when (gnus-visual-p 'summary-menu 'menu)
1882 (gnus-summary-make-menu-bar))
1883 (kill-all-local-variables)
1884 (gnus-summary-make-local-variables)
1885 (gnus-make-thread-indent-array)
1886 (gnus-simplify-mode-line)
1887 (setq major-mode 'gnus-summary-mode)
1888 (setq mode-name "Summary")
1889 (make-local-variable 'minor-mode-alist)
1890 (use-local-map gnus-summary-mode-map)
1891 (buffer-disable-undo)
1892 (setq buffer-read-only t) ;Disable modification
1893 (setq truncate-lines t)
1894 (setq selective-display t)
1895 (setq selective-display-ellipses t) ;Display `...'
1896 (gnus-summary-set-display-table)
1897 (gnus-set-default-directory)
1898 (setq gnus-newsgroup-name group)
1899 (make-local-variable 'gnus-summary-line-format)
1900 (make-local-variable 'gnus-summary-line-format-spec)
1901 (make-local-variable 'gnus-summary-dummy-line-format)
1902 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1903 (make-local-variable 'gnus-summary-mark-positions)
1904 (make-local-hook 'post-command-hook)
1905 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1906 (make-local-hook 'pre-command-hook)
1907 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1908 (gnus-run-hooks 'gnus-summary-mode-hook)
1909 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1910 (gnus-update-summary-mark-positions))
1912 (defun gnus-summary-make-local-variables ()
1913 "Make all the local summary buffer variables."
1914 (let ((locals gnus-summary-local-variables)
1916 (while (setq local (pop locals))
1919 (if (eq (cdr local) 'global)
1920 ;; Copy the global value of the variable.
1921 (setq global (symbol-value (car local)))
1922 ;; Use the value from the list.
1923 (setq global (eval (cdr local))))
1924 (make-local-variable (car local))
1925 (set (car local) global))
1926 ;; Simple nil-valued local variable.
1927 (make-local-variable local)
1930 (defun gnus-summary-clear-local-variables ()
1931 (let ((locals gnus-summary-local-variables))
1933 (if (consp (car locals))
1934 (and (vectorp (caar locals))
1935 (set (caar locals) nil))
1936 (and (vectorp (car locals))
1937 (set (car locals) nil)))
1938 (setq locals (cdr locals)))))
1940 ;; Summary data functions.
1942 (defmacro gnus-data-number (data)
1945 (defmacro gnus-data-set-number (data number)
1946 `(setcar ,data ,number))
1948 (defmacro gnus-data-mark (data)
1951 (defmacro gnus-data-set-mark (data mark)
1952 `(setcar (nthcdr 1 ,data) ,mark))
1954 (defmacro gnus-data-pos (data)
1957 (defmacro gnus-data-set-pos (data pos)
1958 `(setcar (nthcdr 2 ,data) ,pos))
1960 (defmacro gnus-data-header (data)
1963 (defmacro gnus-data-set-header (data header)
1964 `(setf (nth 3 ,data) ,header))
1966 (defmacro gnus-data-level (data)
1969 (defmacro gnus-data-unread-p (data)
1970 `(= (nth 1 ,data) gnus-unread-mark))
1972 (defmacro gnus-data-read-p (data)
1973 `(/= (nth 1 ,data) gnus-unread-mark))
1975 (defmacro gnus-data-pseudo-p (data)
1976 `(consp (nth 3 ,data)))
1978 (defmacro gnus-data-find (number)
1979 `(assq ,number gnus-newsgroup-data))
1981 (defmacro gnus-data-find-list (number &optional data)
1982 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1983 (memq (assq ,number bdata)
1986 (defmacro gnus-data-make (number mark pos header level)
1987 `(list ,number ,mark ,pos ,header ,level))
1989 (defun gnus-data-enter (after-article number mark pos header level offset)
1990 (let ((data (gnus-data-find-list after-article)))
1992 (error "No such article: %d" after-article))
1993 (setcdr data (cons (gnus-data-make number mark pos header level)
1995 (setq gnus-newsgroup-data-reverse nil)
1996 (gnus-data-update-list (cddr data) offset)))
1998 (defun gnus-data-enter-list (after-article list &optional offset)
2000 (let ((data (and after-article (gnus-data-find-list after-article)))
2004 (let ((odata gnus-newsgroup-data))
2005 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2007 (gnus-data-update-list odata offset)))
2008 ;; Find the last element in the list to be spliced into the main
2011 (setq list (cdr list)))
2014 (setcdr list gnus-newsgroup-data)
2015 (setq gnus-newsgroup-data ilist)
2017 (gnus-data-update-list (cdr list) offset)))
2018 (setcdr list (cdr data))
2021 (gnus-data-update-list (cdr list) offset))))
2022 (setq gnus-newsgroup-data-reverse nil))))
2024 (defun gnus-data-remove (article &optional offset)
2025 (let ((data gnus-newsgroup-data))
2026 (if (= (gnus-data-number (car data)) article)
2028 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2029 gnus-newsgroup-data-reverse nil)
2031 (gnus-data-update-list gnus-newsgroup-data offset)))
2033 (when (= (gnus-data-number (cadr data)) article)
2034 (setcdr data (cddr data))
2036 (gnus-data-update-list (cdr data) offset))
2038 gnus-newsgroup-data-reverse nil))
2039 (setq data (cdr data))))))
2041 (defmacro gnus-data-list (backward)
2043 (or gnus-newsgroup-data-reverse
2044 (setq gnus-newsgroup-data-reverse
2045 (reverse gnus-newsgroup-data)))
2046 gnus-newsgroup-data))
2048 (defun gnus-data-update-list (data offset)
2049 "Add OFFSET to the POS of all data entries in DATA."
2050 (setq gnus-newsgroup-data-reverse nil)
2052 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2053 (setq data (cdr data))))
2055 (defun gnus-summary-article-pseudo-p (article)
2056 "Say whether this article is a pseudo article or not."
2057 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2059 (defmacro gnus-summary-article-sparse-p (article)
2060 "Say whether this article is a sparse article or not."
2061 `(memq ,article gnus-newsgroup-sparse))
2063 (defmacro gnus-summary-article-ancient-p (article)
2064 "Say whether this article is a sparse article or not."
2065 `(memq ,article gnus-newsgroup-ancient))
2067 (defun gnus-article-parent-p (number)
2068 "Say whether this article is a parent or not."
2069 (let ((data (gnus-data-find-list number)))
2070 (and (cdr data) ; There has to be an article after...
2071 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2072 (gnus-data-level (nth 1 data))))))
2074 (defun gnus-article-children (number)
2075 "Return a list of all children to NUMBER."
2076 (let* ((data (gnus-data-find-list number))
2077 (level (gnus-data-level (car data)))
2079 (setq data (cdr data))
2081 (= (gnus-data-level (car data)) (1+ level)))
2082 (push (gnus-data-number (car data)) children)
2083 (setq data (cdr data)))
2086 (defmacro gnus-summary-skip-intangible ()
2087 "If the current article is intangible, then jump to a different article."
2088 '(let ((to (get-text-property (point) 'gnus-intangible)))
2089 (and to (gnus-summary-goto-subject to))))
2091 (defmacro gnus-summary-article-intangible-p ()
2092 "Say whether this article is intangible or not."
2093 '(get-text-property (point) 'gnus-intangible))
2095 (defun gnus-article-read-p (article)
2096 "Say whether ARTICLE is read or not."
2097 (not (or (memq article gnus-newsgroup-marked)
2098 (memq article gnus-newsgroup-unreads)
2099 (memq article gnus-newsgroup-unselected)
2100 (memq article gnus-newsgroup-dormant))))
2102 ;; Some summary mode macros.
2104 (defmacro gnus-summary-article-number ()
2105 "The article number of the article on the current line.
2106 If there isn's an article number here, then we return the current
2109 (gnus-summary-skip-intangible)
2110 (or (get-text-property (point) 'gnus-number)
2111 (gnus-summary-last-subject))))
2113 (defmacro gnus-summary-article-header (&optional number)
2114 "Return the header of article NUMBER."
2115 `(gnus-data-header (gnus-data-find
2116 ,(or number '(gnus-summary-article-number)))))
2118 (defmacro gnus-summary-thread-level (&optional number)
2119 "Return the level of thread that starts with article NUMBER."
2120 `(if (and (eq gnus-summary-make-false-root 'dummy)
2121 (get-text-property (point) 'gnus-intangible))
2123 (gnus-data-level (gnus-data-find
2124 ,(or number '(gnus-summary-article-number))))))
2126 (defmacro gnus-summary-article-mark (&optional number)
2127 "Return the mark of article NUMBER."
2128 `(gnus-data-mark (gnus-data-find
2129 ,(or number '(gnus-summary-article-number)))))
2131 (defmacro gnus-summary-article-pos (&optional number)
2132 "Return the position of the line of article NUMBER."
2133 `(gnus-data-pos (gnus-data-find
2134 ,(or number '(gnus-summary-article-number)))))
2136 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2137 (defmacro gnus-summary-article-subject (&optional number)
2138 "Return current subject string or nil if nothing."
2141 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2142 '(gnus-data-header (assq (gnus-summary-article-number)
2143 gnus-newsgroup-data)))))
2146 (mail-header-subject headers))))
2148 (defmacro gnus-summary-article-score (&optional number)
2149 "Return current article score."
2150 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2151 gnus-newsgroup-scored))
2152 gnus-summary-default-score 0))
2154 (defun gnus-summary-article-children (&optional number)
2155 "Return a list of article numbers that are children of article NUMBER."
2156 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2157 (level (gnus-data-level (car data)))
2159 (while (and (setq data (cdr data))
2160 (> (setq l (gnus-data-level (car data))) level))
2161 (and (= (1+ level) l)
2162 (push (gnus-data-number (car data))
2164 (nreverse children)))
2166 (defun gnus-summary-article-parent (&optional number)
2167 "Return the article number of the parent of article NUMBER."
2168 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2169 (gnus-data-list t)))
2170 (level (gnus-data-level (car data))))
2172 () ; This is a root.
2173 ;; We search until we find an article with a level less than
2174 ;; this one. That function has to be the parent.
2175 (while (and (setq data (cdr data))
2176 (not (< (gnus-data-level (car data)) level))))
2177 (and data (gnus-data-number (car data))))))
2179 (defun gnus-unread-mark-p (mark)
2180 "Say whether MARK is the unread mark."
2181 (= mark gnus-unread-mark))
2183 (defun gnus-read-mark-p (mark)
2184 "Say whether MARK is one of the marks that mark as read.
2185 This is all marks except unread, ticked, dormant, and expirable."
2186 (not (or (= mark gnus-unread-mark)
2187 (= mark gnus-ticked-mark)
2188 (= mark gnus-dormant-mark)
2189 (= mark gnus-expirable-mark))))
2191 (defmacro gnus-article-mark (number)
2192 "Return the MARK of article NUMBER.
2193 This macro should only be used when computing the mark the \"first\"
2194 time; i.e., when generating the summary lines. After that,
2195 `gnus-summary-article-mark' should be used to examine the
2198 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2199 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2200 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2201 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2202 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2203 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2204 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2205 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2206 gnus-ancient-mark))))
2208 ;; Saving hidden threads.
2210 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2211 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2213 (defmacro gnus-save-hidden-threads (&rest forms)
2214 "Save hidden threads, eval FORMS, and restore the hidden threads."
2215 (let ((config (make-symbol "config")))
2216 `(let ((,config (gnus-hidden-threads-configuration)))
2220 (gnus-restore-hidden-threads-configuration ,config)))))
2222 (defun gnus-data-compute-positions ()
2223 "Compute the positions of all articles."
2224 (setq gnus-newsgroup-data-reverse nil)
2225 (let ((data gnus-newsgroup-data))
2227 (gnus-save-hidden-threads
2228 (gnus-summary-show-all-threads)
2229 (goto-char (point-min))
2231 (while (get-text-property (point) 'gnus-intangible)
2233 (gnus-data-set-pos (car data) (+ (point) 3))
2234 (setq data (cdr data))
2235 (forward-line 1))))))
2237 (defun gnus-hidden-threads-configuration ()
2238 "Return the current hidden threads configuration."
2241 (goto-char (point-min))
2242 (while (search-forward "\r" nil t)
2243 (push (1- (point)) config))
2246 (defun gnus-restore-hidden-threads-configuration (config)
2247 "Restore hidden threads configuration from CONFIG."
2248 (let (point buffer-read-only)
2249 (while (setq point (pop config))
2250 (when (and (< point (point-max))
2252 (eq (char-after) ?\n))
2253 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2255 ;; Various summary mode internalish functions.
2257 (defun gnus-mouse-pick-article (e)
2260 (gnus-summary-next-page nil t))
2262 (defun gnus-summary-set-display-table ()
2263 ;; Change the display table. Odd characters have a tendency to mess
2264 ;; up nicely formatted displays - we make all possible glyphs
2265 ;; display only a single character.
2267 ;; We start from the standard display table, if any.
2268 (let ((table (or (copy-sequence standard-display-table)
2269 (make-display-table)))
2271 ;; Nix out all the control chars...
2272 (while (>= (setq i (1- i)) 0)
2273 (aset table i [??]))
2274 ;; ... but not newline and cr, of course. (cr is necessary for the
2275 ;; selective display).
2276 (aset table ?\n nil)
2277 (aset table ?\r nil)
2278 ;; We keep TAB as well.
2279 (aset table ?\t nil)
2280 ;; We nix out any glyphs over 126 that are not set already.
2282 (while (>= (setq i (1- i)) 127)
2283 ;; Only modify if the entry is nil.
2284 (unless (aref table i)
2285 (aset table i [??]))))
2286 (setq buffer-display-table table)))
2288 (defun gnus-summary-setup-buffer (group)
2289 "Initialize summary buffer."
2290 (let ((buffer (concat "*Summary " group "*")))
2291 (if (get-buffer buffer)
2294 (setq gnus-summary-buffer (current-buffer))
2295 (not gnus-newsgroup-prepared))
2296 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2297 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2298 (gnus-summary-mode group)
2300 (gnus-carpal-setup-buffer 'summary))
2301 (unless gnus-single-article-buffer
2302 (make-local-variable 'gnus-article-buffer)
2303 (make-local-variable 'gnus-article-current)
2304 (make-local-variable 'gnus-original-article-buffer))
2305 (setq gnus-newsgroup-name group)
2308 (defun gnus-set-global-variables ()
2309 ;; Set the global equivalents of the summary buffer-local variables
2310 ;; to the latest values they had. These reflect the summary buffer
2311 ;; that was in action when the last article was fetched.
2312 (when (eq major-mode 'gnus-summary-mode)
2313 (setq gnus-summary-buffer (current-buffer))
2314 (let ((name gnus-newsgroup-name)
2315 (marked gnus-newsgroup-marked)
2316 (unread gnus-newsgroup-unreads)
2317 (headers gnus-current-headers)
2318 (data gnus-newsgroup-data)
2319 (summary gnus-summary-buffer)
2320 (article-buffer gnus-article-buffer)
2321 (original gnus-original-article-buffer)
2322 (gac gnus-article-current)
2323 (reffed gnus-reffed-article-number)
2324 (score-file gnus-current-score-file))
2326 (set-buffer gnus-group-buffer)
2327 (setq gnus-newsgroup-name name
2328 gnus-newsgroup-marked marked
2329 gnus-newsgroup-unreads unread
2330 gnus-current-headers headers
2331 gnus-newsgroup-data data
2332 gnus-article-current gac
2333 gnus-summary-buffer summary
2334 gnus-article-buffer article-buffer
2335 gnus-original-article-buffer original
2336 gnus-reffed-article-number reffed
2337 gnus-current-score-file score-file)
2338 ;; The article buffer also has local variables.
2339 (when (gnus-buffer-live-p gnus-article-buffer)
2340 (set-buffer gnus-article-buffer)
2341 (setq gnus-summary-buffer summary))))))
2343 (defun gnus-summary-article-unread-p (article)
2344 "Say whether ARTICLE is unread or not."
2345 (memq article gnus-newsgroup-unreads))
2347 (defun gnus-summary-first-article-p (&optional article)
2348 "Return whether ARTICLE is the first article in the buffer."
2349 (if (not (setq article (or article (gnus-summary-article-number))))
2351 (eq article (caar gnus-newsgroup-data))))
2353 (defun gnus-summary-last-article-p (&optional article)
2354 "Return whether ARTICLE is the last article in the buffer."
2355 (if (not (setq article (or article (gnus-summary-article-number))))
2356 t ; All non-existent numbers are the last article. :-)
2357 (not (cdr (gnus-data-find-list article)))))
2359 (defun gnus-make-thread-indent-array ()
2361 (unless (and gnus-thread-indent-array
2362 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2363 (setq gnus-thread-indent-array (make-vector 201 "")
2364 gnus-thread-indent-array-level gnus-thread-indent-level)
2366 (aset gnus-thread-indent-array n
2367 (make-string (* n gnus-thread-indent-level) ? ))
2370 (defun gnus-update-summary-mark-positions ()
2371 "Compute where the summary marks are to go."
2373 (when (gnus-buffer-exists-p gnus-summary-buffer)
2374 (set-buffer gnus-summary-buffer))
2375 (let ((gnus-replied-mark 129)
2376 (gnus-score-below-mark 130)
2377 (gnus-score-over-mark 130)
2378 (gnus-download-mark 131)
2379 (spec gnus-summary-line-format-spec)
2382 (gnus-set-work-buffer)
2383 (let ((gnus-summary-line-format-spec spec)
2384 (gnus-newsgroup-downloadable '((0 . t))))
2385 (gnus-summary-insert-line
2386 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2387 0 nil 128 t nil "" nil 1)
2388 (goto-char (point-min))
2389 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2391 (goto-char (point-min))
2392 (push (cons 'replied (and (search-forward "\201" nil t)
2395 (goto-char (point-min))
2396 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2398 (goto-char (point-min))
2399 (push (cons 'download
2400 (and (search-forward "\203" nil t) (- (point) 2)))
2402 (setq gnus-summary-mark-positions pos))))
2404 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2405 "Insert a dummy root in the summary buffer."
2407 (gnus-add-text-properties
2408 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2409 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2411 (defun gnus-summary-from-or-to-or-newsgroups (header)
2412 (let ((to (cdr (assq 'To (mail-header-extra header))))
2413 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header)))))
2416 gnus-ignored-from-addresses
2417 (string-match gnus-ignored-from-addresses
2418 (mail-header-from header)))
2420 (or (car (funcall gnus-extract-address-components
2422 gnus-decode-encoded-word-function to)))
2423 (funcall gnus-decode-encoded-word-function to))))
2425 gnus-ignored-from-addresses
2426 (string-match gnus-ignored-from-addresses
2427 (mail-header-from header)))
2428 (concat "=> " newsgroups))
2430 (or (car (funcall gnus-extract-address-components
2431 (mail-header-from header)))
2432 (mail-header-from header))))))
2434 (defun gnus-summary-insert-line (gnus-tmp-header
2435 gnus-tmp-level gnus-tmp-current
2436 gnus-tmp-unread gnus-tmp-replied
2437 gnus-tmp-expirable gnus-tmp-subject-or-nil
2438 &optional gnus-tmp-dummy gnus-tmp-score
2440 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2441 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2442 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2443 (gnus-tmp-score-char
2444 (if (or (null gnus-summary-default-score)
2445 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2446 gnus-summary-zcore-fuzz))
2448 (if (< gnus-tmp-score gnus-summary-default-score)
2449 gnus-score-below-mark gnus-score-over-mark)))
2451 (cond (gnus-tmp-process gnus-process-mark)
2452 ((memq gnus-tmp-current gnus-newsgroup-cached)
2454 (gnus-tmp-replied gnus-replied-mark)
2455 ((memq gnus-tmp-current gnus-newsgroup-saved)
2457 (t gnus-unread-mark)))
2458 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2461 ((string-match "<[^>]+> *$" gnus-tmp-from)
2462 (let ((beg (match-beginning 0)))
2463 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2464 (substring gnus-tmp-from (1+ (match-beginning 0))
2465 (1- (match-end 0))))
2466 (substring gnus-tmp-from 0 beg))))
2467 ((string-match "(.+)" gnus-tmp-from)
2468 (substring gnus-tmp-from
2469 (1+ (match-beginning 0)) (1- (match-end 0))))
2471 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2472 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2473 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2474 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2475 (buffer-read-only nil))
2476 (when (string= gnus-tmp-name "")
2477 (setq gnus-tmp-name gnus-tmp-from))
2478 (unless (numberp gnus-tmp-lines)
2479 (setq gnus-tmp-lines 0))
2480 (gnus-put-text-property-excluding-characters-with-faces
2482 (progn (eval gnus-summary-line-format-spec) (point))
2483 'gnus-number gnus-tmp-number)
2484 (when (gnus-visual-p 'summary-highlight 'highlight)
2486 (gnus-run-hooks 'gnus-summary-update-hook)
2489 (defun gnus-summary-update-line (&optional dont-update)
2490 ;; Update summary line after change.
2491 (when (and gnus-summary-default-score
2492 (not gnus-summary-inhibit-highlight))
2493 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2494 (article (gnus-summary-article-number))
2495 (score (gnus-summary-article-score article)))
2497 (if (and gnus-summary-mark-below
2498 (< (gnus-summary-article-score)
2499 gnus-summary-mark-below))
2500 ;; This article has a low score, so we mark it as read.
2501 (when (memq article gnus-newsgroup-unreads)
2502 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2503 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2504 ;; This article was previously marked as read on account
2505 ;; of a low score, but now it has risen, so we mark it as
2507 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2508 (gnus-summary-update-mark
2509 (if (or (null gnus-summary-default-score)
2510 (<= (abs (- score gnus-summary-default-score))
2511 gnus-summary-zcore-fuzz))
2513 (if (< score gnus-summary-default-score)
2514 gnus-score-below-mark gnus-score-over-mark))
2516 ;; Do visual highlighting.
2517 (when (gnus-visual-p 'summary-highlight 'highlight)
2518 (gnus-run-hooks 'gnus-summary-update-hook)))))
2520 (defvar gnus-tmp-new-adopts nil)
2522 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2523 "Return the number of articles in THREAD.
2524 This may be 0 in some cases -- if none of the articles in
2525 the thread are to be displayed."
2527 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2529 ((not (listp thread))
2531 ((and (consp thread) (cdr thread))
2534 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2537 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2540 (when (and level (zerop level) gnus-tmp-new-adopts)
2543 'gnus-summary-number-of-articles-in-thread
2544 gnus-tmp-new-adopts))))
2546 (if (> number 1) gnus-not-empty-thread-mark
2547 gnus-empty-thread-mark)
2550 (defun gnus-summary-set-local-parameters (group)
2551 "Go through the local params of GROUP and set all variable specs in that list."
2552 (let ((params (gnus-group-find-parameter group))
2555 (setq elem (car params)
2556 params (cdr params))
2557 (and (consp elem) ; Has to be a cons.
2558 (consp (cdr elem)) ; The cdr has to be a list.
2559 (symbolp (car elem)) ; Has to be a symbol in there.
2560 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2561 (ignore-errors ; So we set it.
2562 (make-local-variable (car elem))
2563 (set (car elem) (eval (nth 1 elem))))))))
2565 (defun gnus-summary-read-group (group &optional show-all no-article
2566 kill-buffer no-display backward
2568 "Start reading news in newsgroup GROUP.
2569 If SHOW-ALL is non-nil, already read articles are also listed.
2570 If NO-ARTICLE is non-nil, no article is selected initially.
2571 If NO-DISPLAY, don't generate a summary buffer."
2575 (let ((gnus-auto-select-next nil))
2576 (or (gnus-summary-read-group-1
2577 group show-all no-article
2578 kill-buffer no-display
2581 select-articles nil)))))
2582 (eq gnus-auto-select-next 'quietly))
2583 (set-buffer gnus-group-buffer)
2584 ;; The entry function called above goes to the next
2585 ;; group automatically, so we go two groups back
2586 ;; if we are searching for the previous group.
2588 (gnus-group-prev-unread-group 2))
2589 (if (not (equal group (gnus-group-group-name)))
2590 (setq group (gnus-group-group-name))
2594 (defun gnus-summary-read-group-1 (group show-all no-article
2595 kill-buffer no-display
2596 &optional select-articles)
2597 ;; Killed foreign groups can't be entered.
2598 (when (and (not (gnus-group-native-p group))
2599 (not (gnus-gethash group gnus-newsrc-hashtb)))
2600 (error "Dead non-native groups can't be entered"))
2601 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2602 (let* ((new-group (gnus-summary-setup-buffer group))
2603 (quit-config (gnus-group-quit-config group))
2604 (did-select (and new-group (gnus-select-newsgroup
2605 group show-all select-articles))))
2607 ;; This summary buffer exists already, so we just select it.
2609 (gnus-set-global-variables)
2611 (gnus-kill-or-deaden-summary kill-buffer))
2612 (gnus-configure-windows 'summary 'force)
2613 (gnus-set-mode-line 'summary)
2614 (gnus-summary-position-point)
2617 ;; We couldn't select this group.
2619 (when (and (eq major-mode 'gnus-summary-mode)
2620 (not (equal (current-buffer) kill-buffer)))
2621 (kill-buffer (current-buffer))
2622 (if (not quit-config)
2624 ;; Update the info -- marks might need to be removed,
2626 (gnus-summary-update-info)
2627 (set-buffer gnus-group-buffer)
2628 (gnus-group-jump-to-group group)
2629 (gnus-group-next-unread-group 1))
2630 (gnus-handle-ephemeral-exit quit-config)))
2631 (gnus-message 3 "Can't select group")
2633 ;; The user did a `C-g' while prompting for number of articles,
2634 ;; so we exit this group.
2635 ((eq did-select 'quit)
2636 (and (eq major-mode 'gnus-summary-mode)
2637 (not (equal (current-buffer) kill-buffer))
2638 (kill-buffer (current-buffer)))
2640 (gnus-kill-or-deaden-summary kill-buffer))
2641 (if (not quit-config)
2643 (set-buffer gnus-group-buffer)
2644 (gnus-group-jump-to-group group)
2645 (gnus-group-next-unread-group 1)
2646 (gnus-configure-windows 'group 'force))
2647 (gnus-handle-ephemeral-exit quit-config))
2648 ;; Finally signal the quit.
2650 ;; The group was successfully selected.
2652 (gnus-set-global-variables)
2653 ;; Save the active value in effect when the group was entered.
2654 (setq gnus-newsgroup-active
2656 (gnus-active gnus-newsgroup-name)))
2657 ;; You can change the summary buffer in some way with this hook.
2658 (gnus-run-hooks 'gnus-select-group-hook)
2659 ;; Set any local variables in the group parameters.
2660 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2661 (gnus-update-format-specifications
2662 nil 'summary 'summary-mode 'summary-dummy)
2663 ;; Do score processing.
2664 (when gnus-use-scoring
2665 (gnus-possibly-score-headers))
2666 ;; Check whether to fill in the gaps in the threads.
2667 (when gnus-build-sparse-threads
2668 (gnus-build-sparse-threads))
2669 ;; Find the initial limit.
2670 (if gnus-show-threads
2672 (let ((gnus-newsgroup-dormant nil))
2673 (gnus-summary-initial-limit show-all))
2674 (gnus-summary-initial-limit show-all))
2675 (setq gnus-newsgroup-limit
2677 (lambda (header) (mail-header-number header))
2678 gnus-newsgroup-headers)))
2679 ;; Generate the summary buffer.
2681 (gnus-summary-prepare))
2682 (when gnus-use-trees
2683 (gnus-tree-open group)
2684 (setq gnus-summary-highlight-line-function
2685 'gnus-tree-highlight-article))
2686 ;; If the summary buffer is empty, but there are some low-scored
2687 ;; articles or some excluded dormants, we include these in the
2689 (when (and (zerop (buffer-size))
2691 (cond (gnus-newsgroup-dormant
2692 (gnus-summary-limit-include-dormant))
2693 ((and gnus-newsgroup-scored show-all)
2694 (gnus-summary-limit-include-expunged t))))
2695 ;; Function `gnus-apply-kill-file' must be called in this hook.
2696 (gnus-run-hooks 'gnus-apply-kill-hook)
2697 (if (and (zerop (buffer-size))
2700 ;; This newsgroup is empty.
2701 (gnus-summary-catchup-and-exit nil t)
2702 (gnus-message 6 "No unread news")
2704 (gnus-kill-or-deaden-summary kill-buffer))
2705 ;; Return nil from this function.
2707 ;; Hide conversation thread subtrees. We cannot do this in
2708 ;; gnus-summary-prepare-hook since kill processing may not
2709 ;; work with hidden articles.
2710 (and gnus-show-threads
2711 gnus-thread-hide-subtree
2712 (gnus-summary-hide-all-threads))
2714 (gnus-kill-or-deaden-summary kill-buffer))
2715 ;; Show first unread article if requested.
2716 (if (and (not no-article)
2718 gnus-newsgroup-unreads
2719 gnus-auto-select-first)
2721 (gnus-configure-windows 'summary)
2723 ((eq gnus-auto-select-first 'best)
2724 (gnus-summary-best-unread-article))
2725 ((eq gnus-auto-select-first t)
2726 (gnus-summary-first-unread-article))
2727 ((gnus-functionp gnus-auto-select-first)
2728 (funcall gnus-auto-select-first))))
2729 ;; Don't select any articles, just move point to the first
2730 ;; article in the group.
2731 (goto-char (point-min))
2732 (gnus-summary-position-point)
2733 (gnus-configure-windows 'summary 'force)
2734 (gnus-set-mode-line 'summary))
2735 (when (get-buffer-window gnus-group-buffer t)
2736 ;; Gotta use windows, because recenter does weird stuff if
2737 ;; the current buffer ain't the displayed window.
2738 (let ((owin (selected-window)))
2739 (select-window (get-buffer-window gnus-group-buffer t))
2740 (when (gnus-group-goto-group group)
2742 (select-window owin)))
2743 ;; Mark this buffer as "prepared".
2744 (setq gnus-newsgroup-prepared t)
2745 (gnus-run-hooks 'gnus-summary-prepared-hook)
2748 (defun gnus-summary-prepare ()
2749 "Generate the summary buffer."
2751 (let ((buffer-read-only nil))
2753 (setq gnus-newsgroup-data nil
2754 gnus-newsgroup-data-reverse nil)
2755 (gnus-run-hooks 'gnus-summary-generate-hook)
2756 ;; Generate the buffer, either with threads or without.
2757 (when gnus-newsgroup-headers
2758 (gnus-summary-prepare-threads
2759 (if gnus-show-threads
2760 (gnus-sort-gathered-threads
2761 (funcall gnus-summary-thread-gathering-function
2763 (gnus-cut-threads (gnus-make-threads)))))
2764 ;; Unthreaded display.
2765 (gnus-sort-articles gnus-newsgroup-headers))))
2766 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2767 ;; Call hooks for modifying summary buffer.
2768 (goto-char (point-min))
2769 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2771 (defsubst gnus-general-simplify-subject (subject)
2772 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2775 ;; Truncate the subject.
2776 (gnus-simplify-subject-functions
2777 (gnus-map-function gnus-simplify-subject-functions subject))
2778 ((numberp gnus-summary-gather-subject-limit)
2779 (setq subject (gnus-simplify-subject-re subject))
2780 (if (> (length subject) gnus-summary-gather-subject-limit)
2781 (substring subject 0 gnus-summary-gather-subject-limit)
2783 ;; Fuzzily simplify it.
2784 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2785 (gnus-simplify-subject-fuzzy subject))
2786 ;; Just remove the leading "Re:".
2788 (gnus-simplify-subject-re subject))))
2790 (if (and gnus-summary-gather-exclude-subject
2791 (string-match gnus-summary-gather-exclude-subject subject))
2792 nil ; This article shouldn't be gathered
2795 (defun gnus-summary-simplify-subject-query ()
2796 "Query where the respool algorithm would put this article."
2798 (gnus-summary-select-article)
2799 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2801 (defun gnus-gather-threads-by-subject (threads)
2802 "Gather threads by looking at Subject headers."
2803 (if (not gnus-summary-make-false-root)
2805 (let ((hashtb (gnus-make-hashtable 1024))
2808 subject hthread whole-subject)
2810 (setq subject (gnus-general-simplify-subject
2811 (setq whole-subject (mail-header-subject
2814 (if (setq hthread (gnus-gethash subject hashtb))
2816 ;; We enter a dummy root into the thread, if we
2817 ;; haven't done that already.
2818 (unless (stringp (caar hthread))
2819 (setcar hthread (list whole-subject (car hthread))))
2820 ;; We add this new gathered thread to this gathered
2822 (setcdr (car hthread)
2823 (nconc (cdar hthread) (list (car threads))))
2824 ;; Remove it from the list of threads.
2825 (setcdr prev (cdr threads))
2826 (setq threads prev))
2827 ;; Enter this thread into the hash table.
2828 (gnus-sethash subject threads hashtb)))
2830 (setq threads (cdr threads)))
2833 (defun gnus-gather-threads-by-references (threads)
2834 "Gather threads by looking at References headers."
2835 (let ((idhashtb (gnus-make-hashtable 1024))
2836 (thhashtb (gnus-make-hashtable 1024))
2839 ids references id gthread gid entered ref)
2841 (when (setq references (mail-header-references (caar threads)))
2842 (setq id (mail-header-id (caar threads))
2843 ids (gnus-split-references references)
2845 (while (setq ref (pop ids))
2846 (setq ids (delete ref ids))
2847 (if (not (setq gid (gnus-gethash ref idhashtb)))
2849 (gnus-sethash ref id idhashtb)
2850 (gnus-sethash id threads thhashtb))
2851 (setq gthread (gnus-gethash gid thhashtb))
2853 ;; We enter a dummy root into the thread, if we
2854 ;; haven't done that already.
2855 (unless (stringp (caar gthread))
2856 (setcar gthread (list (mail-header-subject (caar gthread))
2858 ;; We add this new gathered thread to this gathered
2860 (setcdr (car gthread)
2861 (nconc (cdar gthread) (list (car threads)))))
2862 ;; Add it into the thread hash table.
2863 (gnus-sethash id gthread thhashtb)
2865 ;; Remove it from the list of threads.
2866 (setcdr prev (cdr threads))
2867 (setq threads prev))))
2869 (setq threads (cdr threads)))
2872 (defun gnus-sort-gathered-threads (threads)
2873 "Sort subtreads inside each gathered thread by article number."
2874 (let ((result threads))
2876 (when (stringp (caar threads))
2877 (setcdr (car threads)
2878 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2879 (setq threads (cdr threads)))
2882 (defun gnus-thread-loop-p (root thread)
2883 "Say whether ROOT is in THREAD."
2884 (let ((stack (list thread))
2887 (while (setq thread (pop stack))
2888 (setq th (cdr thread))
2890 (not (eq (caar th) root)))
2893 ;; We have found a loop.
2895 (setcdr thread (delq (car th) (cdr thread)))
2896 (if (boundp (setq ref-dep (intern "none"
2897 gnus-newsgroup-dependencies)))
2898 (setcdr (symbol-value ref-dep)
2899 (nconc (cdr (symbol-value ref-dep))
2901 (set ref-dep (list nil (car th))))
2904 ;; Push all the subthreads onto the stack.
2905 (push (cdr thread) stack)))
2908 (defun gnus-make-threads ()
2909 "Go through the dependency hashtb and find the roots. Return all threads."
2911 (while (catch 'infloop
2914 ;; Deal with self-referencing References loops.
2915 (when (and (car (symbol-value refs))
2922 (car (symbol-value refs)) thread))
2923 (cdr (symbol-value refs)))))))
2926 (unless (car (symbol-value refs))
2927 ;; These threads do not refer back to any other articles,
2928 ;; so they're roots.
2929 (setq threads (append (cdr (symbol-value refs)) threads))))
2930 gnus-newsgroup-dependencies)))
2933 ;; Build the thread tree.
2934 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2935 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2937 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2938 if it was already present.
2940 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2941 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2942 Message-IDs will be renamed be renamed to a unique Message-ID before
2945 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2946 (let* ((id (mail-header-id header))
2947 (id-dep (and id (intern id dependencies)))
2948 ref ref-dep ref-header)
2949 ;; Enter this `header' in the `dependencies' table.
2953 ;; The first two cases do the normal part: enter a new `header'
2954 ;; in the `dependencies' table.
2955 ((not (boundp id-dep))
2956 (set id-dep (list header)))
2957 ((null (car (symbol-value id-dep)))
2958 (setcar (symbol-value id-dep) header))
2960 ;; From here the `header' was already present in the
2961 ;; `dependencies' table.
2963 ;; Overrides an existing entry;
2964 ;; just set the header part of the entry.
2965 (setcar (symbol-value id-dep) header))
2967 ;; Renames the existing `header' to a unique Message-ID.
2968 ((not gnus-summary-ignore-duplicates)
2969 ;; An article with this Message-ID has already been seen.
2970 ;; We rename the Message-ID.
2971 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2973 (mail-header-set-id header id))
2975 ;; The last case ignores an existing entry, except it adds any
2976 ;; additional Xrefs (in case the two articles came from different
2978 ;; Also sets `header' to `nil' meaning that the `dependencies'
2979 ;; table was *not* modified.
2981 (mail-header-set-xref
2982 (car (symbol-value id-dep))
2983 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2985 (or (mail-header-xref header) "")))
2989 ;; First check if that we are not creating a References loop.
2990 (setq ref (gnus-parent-id (mail-header-references header)))
2992 (setq ref-dep (intern-soft ref dependencies))
2994 (setq ref-header (car (symbol-value ref-dep))))
2995 (if (string= id ref)
2996 ;; Yuk! This is a reference loop. Make the article be a
2999 (mail-header-set-references (car (symbol-value id-dep)) "none")
3001 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3002 (setq ref (gnus-parent-id (mail-header-references header)))
3003 (setq ref-dep (intern (or ref "none") dependencies))
3004 (if (boundp ref-dep)
3005 (setcdr (symbol-value ref-dep)
3006 (nconc (cdr (symbol-value ref-dep))
3007 (list (symbol-value id-dep))))
3008 (set ref-dep (list nil (symbol-value id-dep)))))
3011 (defun gnus-build-sparse-threads ()
3012 (let ((headers gnus-newsgroup-headers)
3013 (gnus-summary-ignore-duplicates t)
3014 header references generation relations
3015 subject child end new-child date)
3016 ;; First we create an alist of generations/relations, where
3017 ;; generations is how much we trust the relation, and the relation
3019 (gnus-message 7 "Making sparse threads...")
3021 (nnheader-set-temp-buffer " *gnus sparse threads*")
3022 (while (setq header (pop headers))
3023 (when (and (setq references (mail-header-references header))
3024 (not (string= references "")))
3026 (setq child (mail-header-id header)
3027 subject (mail-header-subject header)
3028 date (mail-header-date header)
3030 (while (search-backward ">" nil t)
3031 (setq end (1+ (point)))
3032 (when (search-backward "<" nil t)
3033 (setq new-child (buffer-substring (point) end))
3034 (push (list (incf generation)
3035 child (setq child new-child)
3039 (push (list (1+ generation) child nil subject) relations))
3041 (kill-buffer (current-buffer)))
3042 ;; Sort over trustworthiness.
3045 (when (gnus-dependencies-add-header
3046 (make-full-mail-header
3047 gnus-reffed-article-number
3048 (nth 3 relation) "" (or (nth 4 relation) "")
3050 (or (nth 2 relation) "") 0 0 "")
3051 gnus-newsgroup-dependencies nil)
3052 (push gnus-reffed-article-number gnus-newsgroup-limit)
3053 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3054 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3055 gnus-newsgroup-reads)
3056 (decf gnus-reffed-article-number)))
3057 (sort relations 'car-less-than-car))
3058 (gnus-message 7 "Making sparse threads...done")))
3060 (defun gnus-build-old-threads ()
3061 ;; Look at all the articles that refer back to old articles, and
3062 ;; fetch the headers for the articles that aren't there. This will
3063 ;; build complete threads - if the roots haven't been expired by the
3068 (when (not (car (symbol-value refs)))
3069 (setq heads (cdr (symbol-value refs)))
3071 (if (memq (mail-header-number (caar heads))
3072 gnus-newsgroup-dormant)
3073 (setq heads (cdr heads))
3074 (setq id (symbol-name refs))
3075 (while (and (setq id (gnus-build-get-header id))
3076 (not (car (gnus-id-to-thread id)))))
3077 (setq heads nil)))))
3078 gnus-newsgroup-dependencies)))
3080 (defmacro gnus-nov-read-integer ()
3082 (if (eq (char-after) ?\t)
3084 (let ((num (ignore-errors (read buffer))))
3085 (if (numberp num) num 0)))
3087 (search-forward "\t" eol 'move))))
3089 (defmacro gnus-nov-skip-field ()
3090 '(search-forward "\t" eol 'move))
3092 (defmacro gnus-nov-field ()
3093 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3095 (defmacro gnus-nov-parse-extra ()
3097 (while (not (memq (char-after) '(?\n nil)))
3098 (setq string (gnus-nov-field))
3099 (when (string-match "^\\([^ :]+\\): " string)
3100 (push (cons (intern (match-string 1 string))
3101 (substring string (match-end 0)))
3105 ;; This function has to be called with point after the article number
3106 ;; on the beginning of the line.
3107 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3108 (let ((eol (gnus-point-at-eol))
3109 (buffer (current-buffer))
3112 ;; overview: [num subject from date id refs chars lines misc]
3115 (narrow-to-region (point) eol)
3120 (make-full-mail-header
3122 (gnus-nov-field) ; subject
3123 (gnus-nov-field) ; from
3124 (gnus-nov-field) ; date
3125 (or (gnus-nov-field)
3126 (nnheader-generate-fake-message-id)) ; id
3127 (gnus-nov-field) ; refs
3128 (gnus-nov-read-integer) ; chars
3129 (gnus-nov-read-integer) ; lines
3130 (unless (eq (char-after) ?\n)
3131 (gnus-nov-field)) ; misc
3132 (gnus-nov-parse-extra)))) ; extra
3136 (when gnus-alter-header-function
3137 (funcall gnus-alter-header-function header))
3138 (gnus-dependencies-add-header header dependencies force-new)))
3140 (defun gnus-build-get-header (id)
3141 ;; Look through the buffer of NOV lines and find the header to
3142 ;; ID. Enter this line into the dependencies hash table, and return
3143 ;; the id of the parent article (if any).
3144 (let ((deps gnus-newsgroup-dependencies)
3148 (set-buffer nntp-server-buffer)
3149 (let ((case-fold-search nil))
3150 (goto-char (point-min))
3151 (while (and (not found)
3152 (search-forward id nil t))
3154 (setq found (looking-at
3155 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3156 (regexp-quote id))))
3157 (or found (beginning-of-line 2)))
3161 (setq header (gnus-nov-parse-line
3162 (read (current-buffer)) deps))
3163 (gnus-parent-id (mail-header-references header))))))
3165 (let ((number (mail-header-number header)))
3166 (push number gnus-newsgroup-limit)
3167 (push header gnus-newsgroup-headers)
3168 (if (memq number gnus-newsgroup-unselected)
3170 (push number gnus-newsgroup-unreads)
3171 (setq gnus-newsgroup-unselected
3172 (delq number gnus-newsgroup-unselected)))
3173 (push number gnus-newsgroup-ancient)))))))
3175 (defun gnus-build-all-threads ()
3176 "Read all the headers."
3177 (let ((gnus-summary-ignore-duplicates t)
3178 (dependencies gnus-newsgroup-dependencies)
3181 (set-buffer nntp-server-buffer)
3182 (let ((case-fold-search nil))
3183 (goto-char (point-min))
3186 (setq article (read (current-buffer))
3187 header (gnus-nov-parse-line
3188 article dependencies)))
3191 (set-buffer gnus-summary-buffer)
3192 (push header gnus-newsgroup-headers)
3193 (if (memq (setq article (mail-header-number header))
3194 gnus-newsgroup-unselected)
3196 (push article gnus-newsgroup-unreads)
3197 (setq gnus-newsgroup-unselected
3198 (delq article gnus-newsgroup-unselected)))
3199 (push article gnus-newsgroup-ancient)))
3200 (forward-line 1)))))))
3202 (defun gnus-summary-update-article-line (article header)
3203 "Update the line for ARTICLE using HEADERS."
3204 (let* ((id (mail-header-id header))
3205 (thread (gnus-id-to-thread id)))
3207 (error "Article in no thread"))
3208 ;; Update the thread.
3209 (setcar thread header)
3210 (gnus-summary-goto-subject article)
3211 (let* ((datal (gnus-data-find-list article))
3213 (length (when (cdr datal)
3214 (- (gnus-data-pos data)
3215 (gnus-data-pos (cadr datal)))))
3216 (buffer-read-only nil)
3217 (level (gnus-summary-thread-level)))
3219 (gnus-summary-insert-line
3220 header level nil (gnus-article-mark article)
3221 (memq article gnus-newsgroup-replied)
3222 (memq article gnus-newsgroup-expirable)
3223 ;; Only insert the Subject string when it's different
3224 ;; from the previous Subject string.
3225 (if (gnus-subject-equal
3227 (mail-header-subject
3230 (gnus-data-find-list
3232 (gnus-data-list t)))))
3233 ;; Error on the side of excessive subjects.
3235 (mail-header-subject header))
3237 (mail-header-subject header))
3238 nil (cdr (assq article gnus-newsgroup-scored))
3239 (memq article gnus-newsgroup-processable))
3241 (gnus-data-update-list
3242 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3244 (defun gnus-summary-update-article (article &optional iheader)
3245 "Update ARTICLE in the summary buffer."
3246 (set-buffer gnus-summary-buffer)
3247 (let* ((header (gnus-summary-article-header article))
3248 (id (mail-header-id header))
3249 (data (gnus-data-find article))
3250 (thread (gnus-id-to-thread id))
3251 (references (mail-header-references header))
3255 (when (and references
3256 (not (equal "" references)))
3259 (buffer-read-only nil)
3265 (delq thread parent)))
3266 (if (gnus-summary-insert-subject id header)
3267 ;; Set the (possibly) new article number in the data structure.
3268 (gnus-data-set-number data (gnus-id-to-article id))
3272 (defun gnus-rebuild-thread (id &optional line)
3273 "Rebuild the thread containing ID.
3274 If LINE, insert the rebuilt thread starting on line LINE."
3275 (let ((buffer-read-only nil)
3276 old-pos current thread data)
3277 (if (not gnus-show-threads)
3278 (setq thread (list (car (gnus-id-to-thread id))))
3279 ;; Get the thread this article is part of.
3280 (setq thread (gnus-remove-thread id)))
3281 (setq old-pos (gnus-point-at-bol))
3282 (setq current (save-excursion
3283 (and (zerop (forward-line -1))
3284 (gnus-summary-article-number))))
3285 ;; If this is a gathered thread, we have to go some re-gathering.
3286 (when (stringp (car thread))
3287 (let ((subject (car thread))
3289 (setq thread (cdr thread))
3291 (unless (memq (setq thr (gnus-id-to-thread
3293 (mail-header-id (caar thread)))))
3296 (setq thread (cdr thread)))
3297 ;; We now have all (unique) roots.
3298 (if (= (length roots) 1)
3299 ;; All the loose roots are now one solid root.
3300 (setq thread (car roots))
3301 (setq thread (cons subject (gnus-sort-threads roots))))))
3303 ;; We then insert this thread into the summary buffer.
3305 (goto-char (point-min))
3306 (forward-line (1- line)))
3307 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3308 (if gnus-show-threads
3309 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3310 (gnus-summary-prepare-unthreaded thread))
3311 (setq data (nreverse gnus-newsgroup-data))
3312 (setq threads gnus-newsgroup-threads))
3313 ;; We splice the new data into the data structure.
3314 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3315 ;;!!! then we want to insert at the beginning of the buffer.
3316 ;;!!! That happens to be true with Gnus now, but that may
3317 ;;!!! change in the future. Perhaps.
3318 (gnus-data-enter-list
3319 (if line nil current) data (- (point) old-pos))
3320 (setq gnus-newsgroup-threads
3321 (nconc threads gnus-newsgroup-threads))
3322 (gnus-data-compute-positions))))
3324 (defun gnus-number-to-header (number)
3325 "Return the header for article NUMBER."
3326 (let ((headers gnus-newsgroup-headers))
3328 (not (= number (mail-header-number (car headers)))))
3333 (defun gnus-parent-headers (in-headers &optional generation)
3334 "Return the headers of the GENERATIONeth parent of HEADERS."
3336 (setq generation 1))
3338 (headers in-headers)
3341 (not (zerop generation))
3342 (setq references (mail-header-references headers)))
3343 (setq headers (if (and references
3344 (setq parent (gnus-parent-id references)))
3345 (car (gnus-id-to-thread parent))
3348 (and (not (eq headers in-headers))
3351 (defun gnus-id-to-thread (id)
3352 "Return the (sub-)thread where ID appears."
3353 (gnus-gethash id gnus-newsgroup-dependencies))
3355 (defun gnus-id-to-article (id)
3356 "Return the article number of ID."
3357 (let ((thread (gnus-id-to-thread id)))
3360 (mail-header-number (car thread)))))
3362 (defun gnus-id-to-header (id)
3363 "Return the article headers of ID."
3364 (car (gnus-id-to-thread id)))
3366 (defun gnus-article-displayed-root-p (article)
3367 "Say whether ARTICLE is a root(ish) article."
3368 (let ((level (gnus-summary-thread-level article))
3369 (refs (mail-header-references (gnus-summary-article-header article)))
3375 ((null (gnus-parent-id refs)) t)
3377 (null (setq particle (gnus-id-to-article
3378 (gnus-parent-id refs))))
3379 (null (gnus-summary-thread-level particle)))))))
3381 (defun gnus-root-id (id)
3382 "Return the id of the root of the thread where ID appears."
3384 (while (and id (setq prev (car (gnus-id-to-thread id))))
3386 id (gnus-parent-id (mail-header-references prev))))
3389 (defun gnus-articles-in-thread (thread)
3390 "Return the list of articles in THREAD."
3391 (cons (mail-header-number (car thread))
3392 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3394 (defun gnus-remove-thread (id &optional dont-remove)
3395 "Remove the thread that has ID in it."
3396 (let (headers thread last-id)
3397 ;; First go up in this thread until we find the root.
3398 (setq last-id (gnus-root-id id)
3399 headers (message-flatten-list (gnus-id-to-thread last-id)))
3400 ;; We have now found the real root of this thread. It might have
3401 ;; been gathered into some loose thread, so we have to search
3402 ;; through the threads to find the thread we wanted.
3403 (let ((threads gnus-newsgroup-threads)
3406 (setq sub (car threads))
3407 (if (stringp (car sub))
3408 ;; This is a gathered thread, so we look at the roots
3409 ;; below it to find whether this article is in this
3412 (setq sub (cdr sub))
3414 (when (member (caar sub) headers)
3415 (setq thread (car threads)
3418 (setq sub (cdr sub))))
3419 ;; It's an ordinary thread, so we check it.
3420 (when (eq (car sub) (car headers))
3423 (setq threads (cdr threads)))
3424 ;; If this article is in no thread, then it's a root.
3427 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3428 (setq thread (gnus-id-to-thread last-id)))
3431 thread ; We return this thread.
3433 (if (stringp (car thread))
3435 ;; If we use dummy roots, then we have to remove the
3436 ;; dummy root as well.
3437 (when (eq gnus-summary-make-false-root 'dummy)
3438 ;; We go to the dummy root by going to
3439 ;; the first sub-"thread", and then one line up.
3440 (gnus-summary-goto-article
3441 (mail-header-number (caadr thread)))
3444 (gnus-data-compute-positions))
3445 (setq thread (cdr thread))
3447 (gnus-remove-thread-1 (car thread))
3448 (setq thread (cdr thread))))
3449 (gnus-summary-show-all-threads)
3450 (gnus-remove-thread-1 thread))))))))
3452 (defun gnus-remove-thread-1 (thread)
3453 "Remove the thread THREAD recursively."
3454 (let ((number (mail-header-number (pop thread)))
3456 (setq thread (reverse thread))
3458 (gnus-remove-thread-1 (pop thread)))
3459 (when (setq d (gnus-data-find number))
3460 (goto-char (gnus-data-pos d))
3463 (- (gnus-point-at-bol)
3465 (1+ (gnus-point-at-eol))
3466 (gnus-delete-line)))))))
3468 (defun gnus-sort-threads (threads)
3470 (if (not gnus-thread-sort-functions)
3472 (gnus-message 8 "Sorting threads...")
3474 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3475 (gnus-message 8 "Sorting threads...done"))))
3477 (defun gnus-sort-articles (articles)
3479 (when gnus-article-sort-functions
3480 (gnus-message 7 "Sorting articles...")
3482 (setq gnus-newsgroup-headers
3483 (sort articles (gnus-make-sort-function
3484 gnus-article-sort-functions)))
3485 (gnus-message 7 "Sorting articles...done"))))
3487 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3488 (defmacro gnus-thread-header (thread)
3489 ;; Return header of first article in THREAD.
3490 ;; Note that THREAD must never, ever be anything else than a variable -
3491 ;; using some other form will lead to serious barfage.
3492 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3493 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3494 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3497 (defsubst gnus-article-sort-by-number (h1 h2)
3498 "Sort articles by article number."
3499 (< (mail-header-number h1)
3500 (mail-header-number h2)))
3502 (defun gnus-thread-sort-by-number (h1 h2)
3503 "Sort threads by root article number."
3504 (gnus-article-sort-by-number
3505 (gnus-thread-header h1) (gnus-thread-header h2)))
3507 (defsubst gnus-article-sort-by-lines (h1 h2)
3508 "Sort articles by article Lines header."
3509 (< (mail-header-lines h1)
3510 (mail-header-lines h2)))
3512 (defun gnus-thread-sort-by-lines (h1 h2)
3513 "Sort threads by root article Lines header."
3514 (gnus-article-sort-by-lines
3515 (gnus-thread-header h1) (gnus-thread-header h2)))
3517 (defsubst gnus-article-sort-by-author (h1 h2)
3518 "Sort articles by root author."
3520 (let ((addr (mime-read-field 'From h1)))
3521 (or (std11-full-name-string addr)
3522 (std11-address-string addr)
3524 (let ((addr (mime-read-field 'From h2)))
3525 (or (std11-full-name-string addr)
3526 (std11-address-string addr)
3530 (defun gnus-thread-sort-by-author (h1 h2)
3531 "Sort threads by root author."
3532 (gnus-article-sort-by-author
3533 (gnus-thread-header h1) (gnus-thread-header h2)))
3535 (defsubst gnus-article-sort-by-subject (h1 h2)
3536 "Sort articles by root subject."
3538 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3539 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3541 (defun gnus-thread-sort-by-subject (h1 h2)
3542 "Sort threads by root subject."
3543 (gnus-article-sort-by-subject
3544 (gnus-thread-header h1) (gnus-thread-header h2)))
3546 (defsubst gnus-article-sort-by-date (h1 h2)
3547 "Sort articles by root article date."
3549 (gnus-date-get-time (mail-header-date h1))
3550 (gnus-date-get-time (mail-header-date h2))))
3552 (defun gnus-thread-sort-by-date (h1 h2)
3553 "Sort threads by root article date."
3554 (gnus-article-sort-by-date
3555 (gnus-thread-header h1) (gnus-thread-header h2)))
3557 (defsubst gnus-article-sort-by-score (h1 h2)
3558 "Sort articles by root article score.
3559 Unscored articles will be counted as having a score of zero."
3560 (> (or (cdr (assq (mail-header-number h1)
3561 gnus-newsgroup-scored))
3562 gnus-summary-default-score 0)
3563 (or (cdr (assq (mail-header-number h2)
3564 gnus-newsgroup-scored))
3565 gnus-summary-default-score 0)))
3567 (defun gnus-thread-sort-by-score (h1 h2)
3568 "Sort threads by root article score."
3569 (gnus-article-sort-by-score
3570 (gnus-thread-header h1) (gnus-thread-header h2)))
3572 (defun gnus-thread-sort-by-total-score (h1 h2)
3573 "Sort threads by the sum of all scores in the thread.
3574 Unscored articles will be counted as having a score of zero."
3575 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3577 (defun gnus-thread-total-score (thread)
3578 ;; This function find the total score of THREAD.
3579 (cond ((null thread)
3582 (if (stringp (car thread))
3583 (apply gnus-thread-score-function 0
3584 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3585 (gnus-thread-total-score-1 thread)))
3587 (gnus-thread-total-score-1 (list thread)))))
3589 (defun gnus-thread-total-score-1 (root)
3590 ;; This function find the total score of the thread below ROOT.
3591 (setq root (car root))
3592 (apply gnus-thread-score-function
3594 (mapcar 'gnus-thread-total-score
3595 (cdr (gnus-id-to-thread (mail-header-id root))))
3596 (when (> (mail-header-number root) 0)
3597 (list (or (cdr (assq (mail-header-number root)
3598 gnus-newsgroup-scored))
3599 gnus-summary-default-score 0))))
3600 (list gnus-summary-default-score)
3603 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3604 (defvar gnus-tmp-prev-subject nil)
3605 (defvar gnus-tmp-false-parent nil)
3606 (defvar gnus-tmp-root-expunged nil)
3607 (defvar gnus-tmp-dummy-line nil)
3609 (defvar gnus-tmp-header)
3610 (defun gnus-extra-header (type &optional header)
3611 "Return the extra header of TYPE."
3612 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3615 (defun gnus-summary-prepare-threads (threads)
3616 "Prepare summary buffer from THREADS and indentation LEVEL.
3617 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3618 or a straight list of headers."
3619 (gnus-message 7 "Generating summary...")
3621 (setq gnus-newsgroup-threads threads)
3624 (let ((gnus-tmp-level 0)
3625 (default-score (or gnus-summary-default-score 0))
3626 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3627 thread number subject stack state gnus-tmp-gathered beg-match
3628 new-roots gnus-tmp-new-adopts thread-end
3629 gnus-tmp-header gnus-tmp-unread
3630 gnus-tmp-replied gnus-tmp-subject-or-nil
3631 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3632 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3633 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3635 (setq gnus-tmp-prev-subject nil)
3637 (if (vectorp (car threads))
3638 ;; If this is a straight (sic) list of headers, then a
3639 ;; threaded summary display isn't required, so we just create
3640 ;; an unthreaded one.
3641 (gnus-summary-prepare-unthreaded threads)
3643 ;; Do the threaded display.
3645 (while (or threads stack gnus-tmp-new-adopts new-roots)
3647 (if (and (= gnus-tmp-level 0)
3650 (not gnus-tmp-false-parent)
3651 (or gnus-tmp-new-adopts new-roots))
3652 (if gnus-tmp-new-adopts
3653 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3654 thread (list (car gnus-tmp-new-adopts))
3655 gnus-tmp-header (caar thread)
3656 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3658 (setq thread (list (car new-roots))
3659 gnus-tmp-header (caar thread)
3660 new-roots (cdr new-roots))))
3663 ;; If there are some threads, we do them before the
3664 ;; threads on the stack.
3665 (setq thread threads
3666 gnus-tmp-header (caar thread))
3667 ;; There were no current threads, so we pop something off
3669 (setq state (car stack)
3670 gnus-tmp-level (car state)
3673 gnus-tmp-header (caar thread))))
3675 (setq gnus-tmp-false-parent nil)
3676 (setq gnus-tmp-root-expunged nil)
3677 (setq thread-end nil)
3679 (if (stringp gnus-tmp-header)
3680 ;; The header is a dummy root.
3682 ((eq gnus-summary-make-false-root 'adopt)
3683 ;; We let the first article adopt the rest.
3684 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3686 (setq gnus-tmp-gathered
3688 (lambda (h) (mail-header-number (car h)))
3691 (setq thread (cons (list (caar thread)
3694 (setq gnus-tmp-level -1
3695 gnus-tmp-false-parent t))
3696 ((eq gnus-summary-make-false-root 'empty)
3697 ;; We print adopted articles with empty subject fields.
3698 (setq gnus-tmp-gathered
3700 (lambda (h) (mail-header-number (car h)))
3703 (setq gnus-tmp-level -1))
3704 ((eq gnus-summary-make-false-root 'dummy)
3705 ;; We remember that we probably want to output a dummy
3707 (setq gnus-tmp-dummy-line gnus-tmp-header)
3708 (setq gnus-tmp-prev-subject gnus-tmp-header))
3710 ;; We do not make a root for the gathered
3711 ;; sub-threads at all.
3712 (setq gnus-tmp-level -1)))
3714 (setq number (mail-header-number gnus-tmp-header)
3715 subject (mail-header-subject gnus-tmp-header))
3718 ;; If the thread has changed subject, we might want to make
3719 ;; this subthread into a root.
3720 ((and (null gnus-thread-ignore-subject)
3721 (not (zerop gnus-tmp-level))
3722 gnus-tmp-prev-subject
3724 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3725 (setq new-roots (nconc new-roots (list (car thread)))
3727 gnus-tmp-header nil))
3728 ;; If the article lies outside the current limit,
3729 ;; then we do not display it.
3730 ((not (memq number gnus-newsgroup-limit))
3731 (setq gnus-tmp-gathered
3733 (lambda (h) (mail-header-number (car h)))
3736 (setq gnus-tmp-new-adopts (if (cdar thread)
3737 (append gnus-tmp-new-adopts
3739 gnus-tmp-new-adopts)
3741 gnus-tmp-header nil)
3742 (when (zerop gnus-tmp-level)
3743 (setq gnus-tmp-root-expunged t)))
3744 ;; Perhaps this article is to be marked as read?
3745 ((and gnus-summary-mark-below
3746 (< (or (cdr (assq number gnus-newsgroup-scored))
3748 gnus-summary-mark-below)
3749 ;; Don't touch sparse articles.
3750 (not (gnus-summary-article-sparse-p number))
3751 (not (gnus-summary-article-ancient-p number)))
3752 (setq gnus-newsgroup-unreads
3753 (delq number gnus-newsgroup-unreads))
3754 (if gnus-newsgroup-auto-expire
3755 (push number gnus-newsgroup-expirable)
3756 (push (cons number gnus-low-score-mark)
3757 gnus-newsgroup-reads))))
3759 (when gnus-tmp-header
3760 ;; We may have an old dummy line to output before this
3762 (when (and gnus-tmp-dummy-line
3765 (mail-header-subject gnus-tmp-header)))
3766 (gnus-summary-insert-dummy-line
3767 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3768 (setq gnus-tmp-dummy-line nil))
3770 ;; Compute the mark.
3771 (setq gnus-tmp-unread (gnus-article-mark number))
3773 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3774 gnus-tmp-header gnus-tmp-level)
3775 gnus-newsgroup-data)
3777 ;; Actually insert the line.
3779 gnus-tmp-subject-or-nil
3781 ((and gnus-thread-ignore-subject
3782 gnus-tmp-prev-subject
3783 (not (inline (gnus-subject-equal
3784 gnus-tmp-prev-subject subject))))
3786 ((zerop gnus-tmp-level)
3787 (if (and (eq gnus-summary-make-false-root 'empty)
3788 (memq number gnus-tmp-gathered)
3789 gnus-tmp-prev-subject
3790 (inline (gnus-subject-equal
3791 gnus-tmp-prev-subject subject)))
3792 gnus-summary-same-subject
3794 (t gnus-summary-same-subject)))
3795 (if (and (eq gnus-summary-make-false-root 'adopt)
3796 (= gnus-tmp-level 1)
3797 (memq number gnus-tmp-gathered))
3798 (setq gnus-tmp-opening-bracket ?\<
3799 gnus-tmp-closing-bracket ?\>)
3800 (setq gnus-tmp-opening-bracket ?\[
3801 gnus-tmp-closing-bracket ?\]))
3803 gnus-tmp-indentation
3804 (aref gnus-thread-indent-array gnus-tmp-level)
3805 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3806 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3807 gnus-summary-default-score 0)
3809 (if (or (null gnus-summary-default-score)
3810 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3811 gnus-summary-zcore-fuzz))
3813 (if (< gnus-tmp-score gnus-summary-default-score)
3814 gnus-score-below-mark gnus-score-over-mark))
3816 (cond ((memq number gnus-newsgroup-processable)
3818 ((memq number gnus-newsgroup-cached)
3820 ((memq number gnus-newsgroup-replied)
3822 ((memq number gnus-newsgroup-saved)
3824 (t gnus-unread-mark))
3825 gnus-tmp-from (mail-header-from gnus-tmp-header)
3828 ((string-match "<[^>]+> *$" gnus-tmp-from)
3829 (setq beg-match (match-beginning 0))
3830 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3831 (substring gnus-tmp-from (1+ (match-beginning 0))
3832 (1- (match-end 0))))
3833 (substring gnus-tmp-from 0 beg-match)))
3834 ((string-match "(.+)" gnus-tmp-from)
3835 (substring gnus-tmp-from
3836 (1+ (match-beginning 0)) (1- (match-end 0))))
3838 (when (string= gnus-tmp-name "")
3839 (setq gnus-tmp-name gnus-tmp-from))
3840 (unless (numberp gnus-tmp-lines)
3841 (setq gnus-tmp-lines 0))
3842 (gnus-put-text-property
3844 (progn (eval gnus-summary-line-format-spec) (point))
3845 'gnus-number number)
3848 (gnus-run-hooks 'gnus-summary-update-hook)
3851 (setq gnus-tmp-prev-subject subject)))
3853 (when (nth 1 thread)
3854 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3855 (incf gnus-tmp-level)
3856 (setq threads (if thread-end nil (cdar thread)))
3858 (setq gnus-tmp-level 0)))))
3859 (gnus-message 7 "Generating summary...done"))
3861 (defun gnus-summary-prepare-unthreaded (headers)
3862 "Generate an unthreaded summary buffer based on HEADERS."
3863 (let (header number mark)
3868 ;; We may have to root out some bad articles...
3869 (when (memq (setq number (mail-header-number
3870 (setq header (pop headers))))
3871 gnus-newsgroup-limit)
3872 ;; Mark article as read when it has a low score.
3873 (when (and gnus-summary-mark-below
3874 (< (or (cdr (assq number gnus-newsgroup-scored))
3875 gnus-summary-default-score 0)
3876 gnus-summary-mark-below)
3877 (not (gnus-summary-article-ancient-p number)))
3878 (setq gnus-newsgroup-unreads
3879 (delq number gnus-newsgroup-unreads))
3880 (if gnus-newsgroup-auto-expire
3881 (push number gnus-newsgroup-expirable)
3882 (push (cons number gnus-low-score-mark)
3883 gnus-newsgroup-reads)))
3885 (setq mark (gnus-article-mark number))
3886 (push (gnus-data-make number mark (1+ (point)) header 0)
3887 gnus-newsgroup-data)
3888 (gnus-summary-insert-line
3890 mark (memq number gnus-newsgroup-replied)
3891 (memq number gnus-newsgroup-expirable)
3892 (mail-header-subject header) nil
3893 (cdr (assq number gnus-newsgroup-scored))
3894 (memq number gnus-newsgroup-processable))))))
3896 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3897 "Select newsgroup GROUP.
3898 If READ-ALL is non-nil, all articles in the group are selected.
3899 If SELECT-ARTICLES, only select those articles from GROUP."
3900 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3901 ;;!!! Dirty hack; should be removed.
3902 (gnus-summary-ignore-duplicates
3903 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3905 gnus-summary-ignore-duplicates))
3906 (info (nth 2 entry))
3907 articles fetched-articles cached)
3909 (unless (gnus-check-server
3910 (setq gnus-current-select-method
3911 (gnus-find-method-for-group group)))
3912 (error "Couldn't open server"))
3914 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3915 (gnus-activate-group group) ; Or we can activate it...
3916 (progn ; Or we bug out.
3917 (when (equal major-mode 'gnus-summary-mode)
3918 (kill-buffer (current-buffer)))
3919 (error "Couldn't request group %s: %s"
3920 group (gnus-status-message group))))
3922 (unless (gnus-request-group group t)
3923 (when (equal major-mode 'gnus-summary-mode)
3924 (kill-buffer (current-buffer)))
3925 (error "Couldn't request group %s: %s"
3926 group (gnus-status-message group)))
3928 (setq gnus-newsgroup-name group)
3929 (setq gnus-newsgroup-unselected nil)
3930 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3932 ;; Adjust and set lists of article marks.
3934 (gnus-adjust-marked-articles info))
3936 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3937 (when (gnus-virtual-group-p group)
3938 (setq cached gnus-newsgroup-cached))
3940 (setq gnus-newsgroup-unreads
3941 (gnus-set-difference
3942 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3943 gnus-newsgroup-dormant))
3945 (setq gnus-newsgroup-processable nil)
3947 (gnus-update-read-articles group gnus-newsgroup-unreads)
3949 (if (setq articles select-articles)
3950 (setq gnus-newsgroup-unselected
3951 (gnus-sorted-intersection
3952 gnus-newsgroup-unreads
3953 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3954 (setq articles (gnus-articles-to-read group read-all)))
3958 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3960 ((eq articles 0) nil)
3962 ;; Init the dependencies hash table.
3963 (setq gnus-newsgroup-dependencies
3964 (gnus-make-hashtable (length articles)))
3965 (gnus-set-global-variables)
3966 ;; Retrieve the headers and read them in.
3967 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3968 (setq gnus-newsgroup-headers
3970 (setq gnus-headers-retrieved-by
3971 (gnus-retrieve-headers
3972 articles gnus-newsgroup-name
3973 ;; We might want to fetch old headers, but
3974 ;; not if there is only 1 article.
3976 (not (eq gnus-fetch-old-headers 'some))
3977 (not (numberp gnus-fetch-old-headers)))
3978 (> (length articles) 1))
3979 gnus-fetch-old-headers))))
3980 (gnus-get-newsgroup-headers-xover
3981 articles nil nil gnus-newsgroup-name t)
3982 (gnus-get-newsgroup-headers)))
3983 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3985 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3987 (setq gnus-newsgroup-cached cached))
3989 ;; Suppress duplicates?
3990 (when gnus-suppress-duplicates
3991 (gnus-dup-suppress-articles))
3993 ;; Set the initial limit.
3994 (setq gnus-newsgroup-limit (copy-sequence articles))
3995 ;; Remove canceled articles from the list of unread articles.
3996 (setq gnus-newsgroup-unreads
3997 (gnus-set-sorted-intersection
3998 gnus-newsgroup-unreads
3999 (setq fetched-articles
4000 (mapcar (lambda (headers) (mail-header-number headers))
4001 gnus-newsgroup-headers))))
4002 ;; Removed marked articles that do not exist.
4003 (gnus-update-missing-marks
4004 (gnus-sorted-complement fetched-articles articles))
4005 ;; We might want to build some more threads first.
4006 (when (and gnus-fetch-old-headers
4007 (eq gnus-headers-retrieved-by 'nov))
4008 (if (eq gnus-fetch-old-headers 'invisible)
4009 (gnus-build-all-threads)
4010 (gnus-build-old-threads)))
4011 ;; Let the Gnus agent mark articles as read.
4013 (gnus-agent-get-undownloaded-list))
4014 ;; Check whether auto-expire is to be done in this group.
4015 (setq gnus-newsgroup-auto-expire
4016 (gnus-group-auto-expirable-p group))
4017 ;; Set up the article buffer now, if necessary.
4018 (unless gnus-single-article-buffer
4019 (gnus-article-setup-buffer))
4020 ;; First and last article in this newsgroup.
4021 (when gnus-newsgroup-headers
4022 (setq gnus-newsgroup-begin
4023 (mail-header-number (car gnus-newsgroup-headers))
4026 (gnus-last-element gnus-newsgroup-headers))))
4027 ;; GROUP is successfully selected.
4028 (or gnus-newsgroup-headers t)))))
4030 (defun gnus-articles-to-read (group &optional read-all)
4031 ;; Find out what articles the user wants to read.
4033 ;; Select all articles if `read-all' is non-nil, or if there
4034 ;; are no unread articles.
4036 (and (zerop (length gnus-newsgroup-marked))
4037 (zerop (length gnus-newsgroup-unreads)))
4038 (eq (gnus-group-find-parameter group 'display)
4040 (gnus-uncompress-range (gnus-active group))
4041 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4042 (copy-sequence gnus-newsgroup-unreads))
4044 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4045 (scored (length scored-list))
4046 (number (length articles))
4047 (marked (+ (length gnus-newsgroup-marked)
4048 (length gnus-newsgroup-dormant)))
4056 ((and (or (<= scored marked) (= scored number))
4057 (numberp gnus-large-newsgroup)
4058 (> number gnus-large-newsgroup))
4062 "How many articles from %s (default %d): "
4063 (gnus-limit-string gnus-newsgroup-name 35)
4065 (if (string-match "^[ \t]*$" input) number input)))
4066 ((and (> scored marked) (< scored number)
4067 (> (- scored number) 20))
4070 (format "%s %s (%d scored, %d total): "
4071 "How many articles from"
4072 group scored number))))
4073 (if (string-match "^[ \t]*$" input)
4077 (setq select (if (stringp select) (string-to-number select) select))
4078 (if (or (null select) (zerop select))
4080 (if (and (not (zerop scored)) (<= (abs select) scored))
4082 (setq articles (sort scored-list '<))
4083 (setq number (length articles)))
4084 (setq articles (copy-sequence articles)))
4086 (when (< (abs select) number)
4088 ;; Select the N oldest articles.
4089 (setcdr (nthcdr (1- (abs select)) articles) nil)
4090 ;; Select the N most recent articles.
4091 (setq articles (nthcdr (- number select) articles))))
4092 (setq gnus-newsgroup-unselected
4093 (gnus-sorted-intersection
4094 gnus-newsgroup-unreads
4095 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4098 (defun gnus-killed-articles (killed articles)
4101 (when (inline (gnus-member-of-range (car articles) killed))
4102 (push (car articles) out))
4103 (setq articles (cdr articles)))
4106 (defun gnus-uncompress-marks (marks)
4107 "Uncompress the mark ranges in MARKS."
4108 (let ((uncompressed '(score bookmark))
4111 (if (memq (caar marks) uncompressed)
4112 (push (car marks) out)
4113 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4114 (setq marks (cdr marks)))
4117 (defun gnus-adjust-marked-articles (info)
4118 "Set all article lists and remove all marks that are no longer legal."
4119 (let* ((marked-lists (gnus-info-marks info))
4120 (active (gnus-active (gnus-info-group info)))
4123 (types gnus-article-mark-lists)
4124 (uncompressed '(score bookmark killed))
4125 marks var articles article mark)
4128 (setq marks (pop marked-lists))
4129 (set (setq var (intern (format "gnus-newsgroup-%s"
4130 (car (rassq (setq mark (car marks))
4132 (if (memq (car marks) uncompressed) (cdr marks)
4133 (gnus-uncompress-range (cdr marks))))
4135 (setq articles (symbol-value var))
4137 ;; All articles have to be subsets of the active articles.
4139 ;; Adjust "simple" lists.
4140 ((memq mark '(tick dormant expire reply save))
4142 (when (or (< (setq article (pop articles)) min) (> article max))
4143 (set var (delq article (symbol-value var))))))
4145 ((memq mark uncompressed)
4146 (when (not (listp (cdr (symbol-value var))))
4147 (set var (list (symbol-value var))))
4148 (when (not (listp (cdr articles)))
4149 (setq articles (list articles)))
4151 (when (or (not (consp (setq article (pop articles))))
4152 (< (car article) min)
4153 (> (car article) max))
4154 (set var (delq article (symbol-value var))))))))))
4156 (defun gnus-update-missing-marks (missing)
4157 "Go through the list of MISSING articles and remove them from the mark lists."
4159 (let ((types gnus-article-mark-lists)
4161 ;; Go through all types.
4163 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4164 (when (symbol-value var)
4165 ;; This list has articles. So we delete all missing articles
4169 (set var (delq (pop m) (symbol-value var)))))))))
4171 (defun gnus-update-marks ()
4172 "Enter the various lists of marked articles into the newsgroup info list."
4173 (let ((types gnus-article-mark-lists)
4174 (info (gnus-get-info gnus-newsgroup-name))
4175 (uncompressed '(score bookmark killed))
4176 type list newmarked symbol delta-marks)
4178 ;; Add all marks lists that are non-nil to the list of marks lists.
4179 (while (setq type (pop types))
4180 (when (setq list (symbol-value
4182 (intern (format "gnus-newsgroup-%s"
4185 ;; Get rid of the entries of the articles that have the
4187 (when (and (eq (cdr type) 'score)
4191 (prev (cons nil list))
4194 (if (or (not (consp (car arts)))
4195 (= (cdar arts) gnus-summary-default-score))
4196 (setcdr prev (cdr arts))
4198 (setq arts (cdr arts)))
4199 (setq list (cdr all))))
4201 (push (cons (cdr type)
4202 (if (memq (cdr type) uncompressed) list
4203 (gnus-compress-sequence
4204 (set symbol (sort list '<)) t)))
4207 ;; Enter these new marks into the info of the group.
4209 (setcar (nthcdr 3 info) newmarked)
4210 ;; Add the marks lists to the end of the info.
4212 (setcdr (nthcdr 2 info) (list newmarked))))
4214 ;; Cut off the end of the info if there's nothing else there.
4218 (when (nthcdr (decf i) info)
4219 (setcdr (nthcdr i info) nil)))))))
4221 (defun gnus-set-mode-line (where)
4222 "This function sets the mode line of the article or summary buffers.
4223 If WHERE is `summary', the summary mode line format will be used."
4224 ;; Is this mode line one we keep updated?
4225 (when (and (memq where gnus-updated-mode-lines)
4227 (intern (format "gnus-%s-mode-line-format-spec" where))))
4230 ;; We evaluate this in the summary buffer since these
4231 ;; variables are buffer-local to that buffer.
4232 (set-buffer gnus-summary-buffer)
4233 ;; We bind all these variables that are used in the `eval' form
4235 (let* ((mformat (symbol-value
4237 (format "gnus-%s-mode-line-format-spec" where))))
4238 (gnus-tmp-group-name gnus-newsgroup-name)
4239 (gnus-tmp-article-number (or gnus-current-article 0))
4240 (gnus-tmp-unread gnus-newsgroup-unreads)
4241 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4242 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4243 (gnus-tmp-unread-and-unselected
4244 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4245 (zerop gnus-tmp-unselected))
4247 ((zerop gnus-tmp-unselected)
4248 (format "{%d more}" gnus-tmp-unread-and-unticked))
4249 (t (format "{%d(+%d) more}"
4250 gnus-tmp-unread-and-unticked
4251 gnus-tmp-unselected))))
4253 (if (and gnus-current-headers
4254 (vectorp gnus-current-headers))
4255 (gnus-mode-string-quote
4256 (mail-header-subject gnus-current-headers))
4258 bufname-length max-len
4259 gnus-tmp-header);; passed as argument to any user-format-funcs
4260 (setq mode-string (eval mformat))
4261 (setq bufname-length (if (string-match "%b" mode-string)
4264 (if (eq where 'summary)
4266 (get-buffer gnus-article-buffer))))
4269 (setq max-len (max 4 (if gnus-mode-non-string-length
4271 gnus-mode-non-string-length
4273 (length mode-string))))
4274 ;; We might have to chop a bit of the string off...
4275 (when (> (length mode-string) max-len)
4277 (concat (gnus-truncate-string mode-string (- max-len 3))
4279 ;; Pad the mode string a bit.
4280 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4281 ;; Update the mode line.
4282 (setq mode-line-buffer-identification
4283 (gnus-mode-line-buffer-identification (list mode-string)))
4284 (set-buffer-modified-p t))))
4286 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4287 "Go through the HEADERS list and add all Xrefs to a hash table.
4288 The resulting hash table is returned, or nil if no Xrefs were found."
4289 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4290 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4291 (xref-hashtb (gnus-make-hashtable))
4292 start group entry number xrefs header)
4294 (setq header (pop headers))
4295 (when (and (setq xrefs (mail-header-xref header))
4296 (not (memq (setq number (mail-header-number header))
4299 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4300 (setq start (match-end 0))
4301 (setq group (if prefix
4302 (concat prefix (substring xrefs (match-beginning 1)
4304 (substring xrefs (match-beginning 1) (match-end 1))))
4306 (string-to-int (substring xrefs (match-beginning 2)
4308 (if (setq entry (gnus-gethash group xref-hashtb))
4309 (setcdr entry (cons number (cdr entry)))
4310 (gnus-sethash group (cons number nil) xref-hashtb)))))
4311 (and start xref-hashtb)))
4313 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4314 "Look through all the headers and mark the Xrefs as read."
4315 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4316 name entry info xref-hashtb idlist method nth4)
4318 (set-buffer gnus-group-buffer)
4319 (when (setq xref-hashtb
4320 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4323 (unless (string= from-newsgroup (setq name (symbol-name group)))
4324 (setq idlist (symbol-value group))
4325 ;; Dead groups are not updated.
4327 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4329 (when (stringp (setq nth4 (gnus-info-method info)))
4330 (setq nth4 (gnus-server-to-method nth4))))
4331 ;; Only do the xrefs if the group has the same
4332 ;; select method as the group we have just read.
4333 (or (gnus-methods-equal-p
4334 nth4 (gnus-find-method-for-group from-newsgroup))
4336 (equal nth4 (setq method (gnus-find-method-for-group
4338 (and (equal (car nth4) (car method))
4339 (equal (nth 1 nth4) (nth 1 method))))
4340 gnus-use-cross-reference
4341 (or (not (eq gnus-use-cross-reference t))
4343 ;; Only do cross-references on subscribed
4344 ;; groups, if that is what is wanted.
4345 (<= (gnus-info-level info) gnus-level-subscribed))
4346 (gnus-group-make-articles-read name idlist))))
4349 (defun gnus-compute-read-articles (group articles)
4350 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4351 (info (nth 2 entry))
4352 (active (gnus-active group))
4355 ;; First peel off all illegal article numbers.
4357 (let ((ids articles)
4359 (while (setq id (pop ids))
4360 (when (and first (> id (cdr active)))
4361 ;; We'll end up in this situation in one particular
4362 ;; obscure situation. If you re-scan a group and get
4363 ;; a new article that is cross-posted to a different
4364 ;; group that has not been re-scanned, you might get
4365 ;; crossposted article that has a higher number than
4366 ;; Gnus believes possible. So we re-activate this
4367 ;; group as well. This might mean doing the
4368 ;; crossposting thingy will *increase* the number
4369 ;; of articles in some groups. Tsk, tsk.
4370 (setq active (or (gnus-activate-group group) active)))
4371 (when (or (> id (cdr active))
4372 (< id (car active)))
4373 (setq articles (delq id articles))))))
4374 ;; If the read list is nil, we init it.
4376 (null (gnus-info-read info))
4378 (setq ninfo (cons 1 (1- (car active))))
4379 (setq ninfo (gnus-info-read info)))
4380 ;; Then we add the read articles to the range.
4382 ninfo (setq articles (sort articles '<))))))
4384 (defun gnus-group-make-articles-read (group articles)
4385 "Update the info of GROUP to say that ARTICLES are read."
4387 (entry (gnus-gethash group gnus-newsrc-hashtb))
4388 (info (nth 2 entry))
4389 (active (gnus-active group))
4392 (setq range (gnus-compute-read-articles group articles))
4394 (set-buffer gnus-group-buffer)
4397 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4398 (gnus-info-set-read ',info ',(gnus-info-read info))
4399 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4400 (gnus-group-update-group ,group t))))
4401 ;; Add the read articles to the range.
4402 (gnus-info-set-read info range)
4403 ;; Then we have to re-compute how many unread
4404 ;; articles there are in this group.
4408 (setq num (- (1+ (cdr active)) (car active))))
4409 ((not (listp (cdr range)))
4410 (setq num (- (cdr active) (- (1+ (cdr range))
4414 (if (numberp (car range))
4416 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4417 (setq range (cdr range)))
4418 (setq num (- (cdr active) num))))
4419 ;; Update the number of unread articles.
4421 ;; Update the group buffer.
4422 (gnus-group-update-group group t)))))
4424 (defun gnus-methods-equal-p (m1 m2)
4425 (let ((m1 (or m1 gnus-select-method))
4426 (m2 (or m2 gnus-select-method)))
4428 (and (eq (car m1) (car m2))
4429 (or (not (memq 'address (assoc (symbol-name (car m1))
4430 gnus-valid-select-methods)))
4431 (equal (nth 1 m1) (nth 1 m2)))))))
4433 (defvar gnus-newsgroup-none-id 0)
4435 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4436 (let ((cur nntp-server-buffer)
4439 (save-excursion (set-buffer gnus-summary-buffer)
4440 gnus-newsgroup-dependencies)))
4443 (set-buffer nntp-server-buffer)
4444 ;; Translate all TAB characters into SPACE characters.
4445 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4446 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4447 (gnus-run-hooks 'gnus-parse-headers-hook)
4448 (let ((case-fold-search t)
4449 in-reply-to header p lines chars ctype)
4450 (goto-char (point-min))
4451 ;; Search to the beginning of the next header. Error messages
4452 ;; do not begin with 2 or 3.
4453 (while (re-search-forward "^[23][0-9]+ " nil t)
4456 ;; This implementation of this function, with nine
4457 ;; search-forwards instead of the one re-search-forward and
4458 ;; a case (which basically was the old function) is actually
4459 ;; about twice as fast, even though it looks messier. You
4460 ;; can't have everything, I guess. Speed and elegance
4461 ;; doesn't always go hand in hand.
4464 (make-full-mail-header
4470 (narrow-to-region (point)
4471 (or (and (search-forward "\n.\n" nil t)
4477 (if (search-forward "\nsubject: " nil t)
4478 (buffer-substring (match-end 0) (std11-field-end))
4483 (if (search-forward "\nfrom: " nil t)
4484 (buffer-substring (match-end 0) (std11-field-end))
4489 (if (search-forward "\ndate: " nil t)
4490 (buffer-substring (match-end 0) (std11-field-end))
4495 (setq id (if (re-search-forward
4496 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4497 ;; We do it this way to make sure the Message-ID
4498 ;; is (somewhat) syntactically valid.
4499 (buffer-substring (match-beginning 1)
4501 ;; If there was no message-id, we just fake one
4502 ;; to make subsequent routines simpler.
4503 (nnheader-generate-fake-message-id))))
4507 (if (search-forward "\nreferences: " nil t)
4511 (buffer-substring (match-end 0) (std11-field-end))
4516 (search-backward ">" end t)
4519 (search-backward "<" end t)
4521 ;; Get the references from the in-reply-to header if there
4522 ;; were no references and the in-reply-to header looks
4524 (if (and (search-forward "\nin-reply-to: " nil t)
4526 (buffer-substring (match-end 0)
4528 (string-match "<[^>]+>" in-reply-to))
4530 (setq ref (substring in-reply-to (match-beginning 0)
4532 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4533 (setq ref2 (substring in-reply-to (match-beginning 0)
4535 (when (> (length ref2) (length ref))
4542 (if (search-forward "\nchars: " nil t)
4543 (if (numberp (setq chars (ignore-errors (read cur))))
4549 (if (search-forward "\nlines: " nil t)
4550 (if (numberp (setq lines (ignore-errors (read cur))))
4556 (and (search-forward "\nxref: " nil t)
4557 (buffer-substring (match-end 0) (std11-field-end))))
4559 (when gnus-extra-headers
4560 (let ((extra gnus-extra-headers)
4564 (when (search-forward
4565 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4566 (push (cons (car extra)
4567 (buffer-substring (match-end 0)
4573 (if (and (search-forward "\ncontent-type: " nil t)
4575 (buffer-substring (match-end 0) (std11-field-end))))
4576 (mime-entity-set-content-type-internal
4577 header (mime-parse-Content-Type ctype)))
4578 (when (equal id ref)
4581 (when gnus-alter-header-function
4582 (funcall gnus-alter-header-function header)
4583 (setq id (mail-header-id header)
4584 ref (gnus-parent-id (mail-header-references header))))
4587 (gnus-dependencies-add-header
4588 header dependencies force-new))
4589 (push header headers))
4590 (goto-char (point-max))
4592 (nreverse headers)))))
4594 ;; Goes through the xover lines and returns a list of vectors
4595 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4596 force-new dependencies
4597 group also-fetch-heads)
4598 "Parse the news overview data in the server buffer, and return a
4599 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4600 ;; Get the Xref when the users reads the articles since most/some
4601 ;; NNTP servers do not include Xrefs when using XOVER.
4602 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4603 (let ((cur nntp-server-buffer)
4604 (dependencies (or dependencies gnus-newsgroup-dependencies))
4605 number headers header)
4607 (set-buffer nntp-server-buffer)
4608 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4609 ;; Allow the user to mangle the headers before parsing them.
4610 (gnus-run-hooks 'gnus-parse-headers-hook)
4611 (goto-char (point-min))
4614 (while (and sequence (not (eobp)))
4615 (setq number (read cur))
4616 (while (and sequence
4617 (< (car sequence) number))
4618 (setq sequence (cdr sequence)))
4620 (eq number (car sequence))
4622 (setq sequence (cdr sequence))
4623 (setq header (inline
4624 (gnus-nov-parse-line
4625 number dependencies force-new))))
4626 (push header headers))
4629 (gnus-error 4 "Strange nov line (%d)"
4630 (count-lines (point-min) (point)))))
4632 ;; A common bug in inn is that if you have posted an article and
4633 ;; then retrieves the active file, it will answer correctly --
4634 ;; the new article is included. However, a NOV entry for the
4635 ;; article may not have been generated yet, so this may fail.
4636 ;; We work around this problem by retrieving the last few
4637 ;; headers using HEAD.
4638 (if (or (not also-fetch-heads)
4640 ;; We (probably) got all the headers.
4642 (let ((gnus-nov-is-evil t))
4645 (when (gnus-retrieve-headers sequence group)
4646 (gnus-get-newsgroup-headers))))))))
4648 (defun gnus-article-get-xrefs ()
4649 "Fill in the Xref value in `gnus-current-headers', if necessary.
4650 This is meant to be called in `gnus-article-internal-prepare-hook'."
4651 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4652 gnus-current-headers)))
4653 (or (not gnus-use-cross-reference)
4655 (and (mail-header-xref headers)
4656 (not (string= (mail-header-xref headers) "")))
4657 (let ((case-fold-search t)
4660 (nnheader-narrow-to-headers)
4661 (goto-char (point-min))
4662 (when (or (and (eq (downcase (char-after)) ?x)
4663 (looking-at "Xref:"))
4664 (search-forward "\nXref:" nil t))
4665 (goto-char (1+ (match-end 0)))
4666 (setq xref (buffer-substring (point)
4667 (progn (end-of-line) (point))))
4668 (mail-header-set-xref headers xref)))))))
4670 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4671 "Find article ID and insert the summary line for that article.
4672 OLD-HEADER can either be a header or a line number to insert
4673 the subject line on."
4674 (let* ((line (and (numberp old-header) old-header))
4675 (old-header (and (vectorp old-header) old-header))
4676 (header (cond ((and old-header use-old-header)
4679 (gnus-number-to-header id))
4680 (gnus-number-to-header id))
4682 (gnus-read-header id))))
4683 (number (and (numberp id) id))
4686 ;; Rebuild the thread that this article is part of and go to the
4687 ;; article we have fetched.
4688 (when (and (not gnus-show-threads)
4691 (setq d (gnus-data-find (mail-header-number old-header))))
4692 (goto-char (gnus-data-pos d))
4695 (- (gnus-point-at-bol)
4697 (1+ (gnus-point-at-eol))
4698 (gnus-delete-line))))))
4700 (mail-header-set-number header (mail-header-number old-header)))
4701 (setq gnus-newsgroup-sparse
4702 (delq (setq number (mail-header-number header))
4703 gnus-newsgroup-sparse))
4704 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4705 (push number gnus-newsgroup-limit)
4706 (gnus-rebuild-thread (mail-header-id header) line)
4707 (gnus-summary-goto-subject number nil t))
4708 (when (and (numberp number)
4710 ;; We have to update the boundaries even if we can't fetch the
4711 ;; article if ID is a number -- so that the next `P' or `N'
4712 ;; command will fetch the previous (or next) article even
4713 ;; if the one we tried to fetch this time has been canceled.
4714 (when (> number gnus-newsgroup-end)
4715 (setq gnus-newsgroup-end number))
4716 (when (< number gnus-newsgroup-begin)
4717 (setq gnus-newsgroup-begin number))
4718 (setq gnus-newsgroup-unselected
4719 (delq number gnus-newsgroup-unselected)))
4720 ;; Report back a success?
4721 (and header (mail-header-number header))))
4723 ;;; Process/prefix in the summary buffer
4725 (defun gnus-summary-work-articles (n)
4726 "Return a list of articles to be worked upon.
4727 The prefix argument, the list of process marked articles, and the
4728 current article will be taken into consideration."
4730 (set-buffer gnus-summary-buffer)
4733 ;; A numerical prefix has been given.
4734 (setq n (prefix-numeric-value n))
4735 (let ((backward (< n 0))
4736 (n (abs (prefix-numeric-value n)))
4741 (push (setq article (gnus-summary-article-number))
4744 (gnus-summary-find-prev nil article)
4745 (gnus-summary-find-next nil article)))
4747 (nreverse articles)))
4748 ((and (gnus-region-active-p) (mark))
4749 (message "region active")
4750 ;; Work on the region between point and mark.
4751 (let ((max (max (point) (mark)))
4754 (goto-char (min (point) (mark)))
4757 (push (setq article (gnus-summary-article-number)) articles)
4758 (gnus-summary-find-next nil article)
4760 (nreverse articles))))
4761 (gnus-newsgroup-processable
4762 ;; There are process-marked articles present.
4763 ;; Save current state.
4764 (gnus-summary-save-process-mark)
4766 (reverse gnus-newsgroup-processable))
4768 ;; Just return the current article.
4769 (list (gnus-summary-article-number))))))
4771 (defmacro gnus-summary-iterate (arg &rest forms)
4772 "Iterate over the process/prefixed articles and do FORMS.
4773 ARG is the interactive prefix given to the command. FORMS will be
4774 executed with point over the summary line of the articles."
4775 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4776 `(let ((,articles (gnus-summary-work-articles ,arg)))
4778 (gnus-summary-goto-subject (car ,articles))
4781 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4782 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4784 (defun gnus-summary-save-process-mark ()
4785 "Push the current set of process marked articles on the stack."
4787 (push (copy-sequence gnus-newsgroup-processable)
4788 gnus-newsgroup-process-stack))
4790 (defun gnus-summary-kill-process-mark ()
4791 "Push the current set of process marked articles on the stack and unmark."
4793 (gnus-summary-save-process-mark)
4794 (gnus-summary-unmark-all-processable))
4796 (defun gnus-summary-yank-process-mark ()
4797 "Pop the last process mark state off the stack and restore it."
4799 (unless gnus-newsgroup-process-stack
4800 (error "Empty mark stack"))
4801 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4803 (defun gnus-summary-process-mark-set (set)
4804 "Make SET into the current process marked articles."
4805 (gnus-summary-unmark-all-processable)
4807 (gnus-summary-set-process-mark (pop set))))
4809 ;;; Searching and stuff
4811 (defun gnus-summary-search-group (&optional backward use-level)
4812 "Search for next unread newsgroup.
4813 If optional argument BACKWARD is non-nil, search backward instead."
4815 (set-buffer gnus-group-buffer)
4816 (when (gnus-group-search-forward
4817 backward nil (if use-level (gnus-group-group-level) nil))
4818 (gnus-group-group-name))))
4820 (defun gnus-summary-best-group (&optional exclude-group)
4821 "Find the name of the best unread group.
4822 If EXCLUDE-GROUP, do not go to this group."
4824 (set-buffer gnus-group-buffer)
4826 (gnus-group-best-unread-group exclude-group))))
4828 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4829 (if backward (gnus-summary-find-prev)
4830 (let* ((dummy (gnus-summary-article-intangible-p))
4831 (article (or article (gnus-summary-article-number)))
4832 (arts (gnus-data-find-list article))
4834 (when (and (not dummy)
4835 (or (not gnus-summary-check-current)
4837 (not (gnus-data-unread-p (car arts)))))
4838 (setq arts (cdr arts)))
4843 (when (or (and undownloaded
4844 (eq gnus-undownloaded-mark
4845 (gnus-data-mark (car arts))))
4846 (gnus-data-unread-p (car arts)))
4847 (setq result (car arts)
4849 (setq arts (cdr arts)))
4852 (goto-char (gnus-data-pos result))
4853 (gnus-data-number result)))))
4855 (defun gnus-summary-find-prev (&optional unread article)
4856 (let* ((eobp (eobp))
4857 (article (or article (gnus-summary-article-number)))
4858 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4860 (when (and (not eobp)
4861 (or (not gnus-summary-check-current)
4863 (not (gnus-data-unread-p (car arts)))))
4864 (setq arts (cdr arts)))
4869 (when (gnus-data-unread-p (car arts))
4870 (setq result (car arts)
4872 (setq arts (cdr arts)))
4875 (goto-char (gnus-data-pos result))
4876 (gnus-data-number result))))
4878 (defun gnus-summary-find-subject (subject &optional unread backward article)
4879 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4880 (article (or article (gnus-summary-article-number)))
4881 (articles (gnus-data-list backward))
4882 (arts (gnus-data-find-list article articles))
4884 (when (or (not gnus-summary-check-current)
4886 (not (gnus-data-unread-p (car arts))))
4887 (setq arts (cdr arts)))
4889 (and (or (not unread)
4890 (gnus-data-unread-p (car arts)))
4891 (vectorp (gnus-data-header (car arts)))
4893 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4894 (setq result (car arts)
4896 (setq arts (cdr arts)))
4898 (goto-char (gnus-data-pos result))
4899 (gnus-data-number result))))
4901 (defun gnus-summary-search-forward (&optional unread subject backward)
4902 "Search forward for an article.
4903 If UNREAD, look for unread articles. If SUBJECT, look for
4904 articles with that subject. If BACKWARD, search backward instead."
4905 (cond (subject (gnus-summary-find-subject subject unread backward))
4906 (backward (gnus-summary-find-prev unread))
4907 (t (gnus-summary-find-next unread))))
4909 (defun gnus-recenter (&optional n)
4910 "Center point in window and redisplay frame.
4911 Also do horizontal recentering."
4913 (when (and gnus-auto-center-summary
4914 (not (eq gnus-auto-center-summary 'vertical)))
4915 (gnus-horizontal-recenter))
4918 (defun gnus-summary-recenter ()
4919 "Center point in the summary window.
4920 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4921 displayed, no centering will be performed."
4922 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4923 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4924 (let* ((top (cond ((< (window-height) 4) 0)
4925 ((< (window-height) 7) 1)
4926 (t (if (numberp gnus-auto-center-summary)
4927 gnus-auto-center-summary
4929 (height (1- (window-height)))
4930 (bottom (save-excursion (goto-char (point-max))
4931 (forward-line (- height))
4933 (window (get-buffer-window (current-buffer))))
4934 ;; The user has to want it.
4935 (when gnus-auto-center-summary
4936 (when (get-buffer-window gnus-article-buffer)
4937 ;; Only do recentering when the article buffer is displayed,
4938 ;; Set the window start to either `bottom', which is the biggest
4939 ;; possible valid number, or the second line from the top,
4940 ;; whichever is the least.
4942 window (min bottom (save-excursion
4943 (forward-line (- top)) (point)))))
4944 ;; Do horizontal recentering while we're at it.
4945 (when (and (get-buffer-window (current-buffer) t)
4946 (not (eq gnus-auto-center-summary 'vertical)))
4947 (let ((selected (selected-window)))
4948 (select-window (get-buffer-window (current-buffer) t))
4949 (gnus-summary-position-point)
4950 (gnus-horizontal-recenter)
4951 (select-window selected))))))
4953 (defun gnus-summary-jump-to-group (newsgroup)
4954 "Move point to NEWSGROUP in group mode buffer."
4955 ;; Keep update point of group mode buffer if visible.
4956 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4957 (save-window-excursion
4958 ;; Take care of tree window mode.
4959 (when (get-buffer-window gnus-group-buffer)
4960 (pop-to-buffer gnus-group-buffer))
4961 (gnus-group-jump-to-group newsgroup))
4963 ;; Take care of tree window mode.
4964 (if (get-buffer-window gnus-group-buffer)
4965 (pop-to-buffer gnus-group-buffer)
4966 (set-buffer gnus-group-buffer))
4967 (gnus-group-jump-to-group newsgroup))))
4969 ;; This function returns a list of article numbers based on the
4970 ;; difference between the ranges of read articles in this group and
4971 ;; the range of active articles.
4972 (defun gnus-list-of-unread-articles (group)
4973 (let* ((read (gnus-info-read (gnus-get-info group)))
4974 (active (or (gnus-active group) (gnus-activate-group group)))
4977 ;; If none are read, then all are unread.
4979 (setq first (car active))
4980 ;; If the range of read articles is a single range, then the
4981 ;; first unread article is the article after the last read
4982 ;; article. Sounds logical, doesn't it?
4983 (if (not (listp (cdr read)))
4984 (setq first (max (car active) (1+ (cdr read))))
4985 ;; `read' is a list of ranges.
4986 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4989 (setq first (car active)))
4992 (while (< first nlast)
4994 (setq first (1+ first))))
4995 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4996 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4997 (setq read (cdr read)))))
4998 ;; And add the last unread articles.
4999 (while (<= first last)
5001 (setq first (1+ first)))
5002 ;; Return the list of unread articles.
5003 (delq 0 (nreverse unread))))
5005 (defun gnus-list-of-read-articles (group)
5006 "Return a list of unread, unticked and non-dormant articles."
5007 (let* ((info (gnus-get-info group))
5008 (marked (gnus-info-marks info))
5009 (active (gnus-active group)))
5011 (gnus-set-difference
5012 (gnus-sorted-complement
5013 (gnus-uncompress-range active)
5014 (gnus-list-of-unread-articles group))
5016 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5017 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5019 ;; Various summary commands
5021 (defun gnus-summary-select-article-buffer ()
5022 "Reconfigure windows to show article buffer."
5024 (if (not (gnus-buffer-live-p gnus-article-buffer))
5025 (error "There is no article buffer for this summary buffer")
5026 (gnus-configure-windows 'article)
5027 (select-window (get-buffer-window gnus-article-buffer))))
5029 (defun gnus-summary-universal-argument (arg)
5030 "Perform any operation on all articles that are process/prefixed."
5032 (let ((articles (gnus-summary-work-articles arg))
5039 (substitute-command-keys
5040 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5043 (gnus-error 1 "Undefined key")
5046 (gnus-summary-goto-subject (setq article (pop articles)))
5047 (let (gnus-newsgroup-processable)
5048 (command-execute func))
5049 (gnus-summary-remove-process-mark article)))))
5050 (gnus-summary-position-point))
5052 (defun gnus-summary-toggle-truncation (&optional arg)
5053 "Toggle truncation of summary lines.
5054 With arg, turn line truncation on iff arg is positive."
5056 (setq truncate-lines
5057 (if (null arg) (not truncate-lines)
5058 (> (prefix-numeric-value arg) 0)))
5061 (defun gnus-summary-reselect-current-group (&optional all rescan)
5062 "Exit and then reselect the current newsgroup.
5063 The prefix argument ALL means to select all articles."
5065 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5066 (error "Ephemeral groups can't be reselected"))
5067 (let ((current-subject (gnus-summary-article-number))
5068 (group gnus-newsgroup-name))
5069 (setq gnus-newsgroup-begin nil)
5071 ;; We have to adjust the point of group mode buffer because
5072 ;; point was moved to the next unread newsgroup by exiting.
5073 (gnus-summary-jump-to-group group)
5076 (gnus-group-get-new-news-this-group 1)))
5077 (gnus-group-read-group all t)
5078 (gnus-summary-goto-subject current-subject nil t)))
5080 (defun gnus-summary-rescan-group (&optional all)
5081 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5083 (gnus-summary-reselect-current-group all t))
5085 (defun gnus-summary-update-info (&optional non-destructive)
5087 (let ((group gnus-newsgroup-name))
5089 (when gnus-newsgroup-kill-headers
5090 (setq gnus-newsgroup-killed
5091 (gnus-compress-sequence
5093 (gnus-set-sorted-intersection
5094 (gnus-uncompress-range gnus-newsgroup-killed)
5095 (setq gnus-newsgroup-unselected
5096 (sort gnus-newsgroup-unselected '<)))
5097 (setq gnus-newsgroup-unreads
5098 (sort gnus-newsgroup-unreads '<)))
5100 (unless (listp (cdr gnus-newsgroup-killed))
5101 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5102 (let ((headers gnus-newsgroup-headers))
5103 ;; Set the new ranges of read articles.
5105 (set-buffer gnus-group-buffer)
5106 (gnus-undo-force-boundary))
5107 (gnus-update-read-articles
5108 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5109 ;; Set the current article marks.
5110 (let ((gnus-newsgroup-scored
5111 (if (and (not gnus-save-score)
5112 (not non-destructive))
5114 gnus-newsgroup-scored)))
5116 (gnus-update-marks)))
5117 ;; Do the cross-ref thing.
5118 (when gnus-use-cross-reference
5119 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5120 ;; Do not switch windows but change the buffer to work.
5121 (set-buffer gnus-group-buffer)
5122 (unless (gnus-ephemeral-group-p group)
5123 (gnus-group-update-group group)))))))
5125 (defun gnus-summary-save-newsrc (&optional force)
5126 "Save the current number of read/marked articles in the dribble buffer.
5127 The dribble buffer will then be saved.
5128 If FORCE (the prefix), also save the .newsrc file(s)."
5130 (gnus-summary-update-info t)
5132 (gnus-save-newsrc-file)
5133 (gnus-dribble-save)))
5135 (defun gnus-summary-exit (&optional temporary)
5136 "Exit reading current newsgroup, and then return to group selection mode.
5137 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5139 (gnus-set-global-variables)
5140 (gnus-kill-save-kill-buffer)
5141 (gnus-async-halt-prefetch)
5142 (let* ((group gnus-newsgroup-name)
5143 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5146 (buf (current-buffer)))
5147 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5148 ;; If we have several article buffers, we kill them at exit.
5149 (unless gnus-single-article-buffer
5150 (gnus-kill-buffer gnus-original-article-buffer)
5151 (setq gnus-article-current nil))
5152 (when gnus-use-cache
5153 (gnus-cache-possibly-remove-articles)
5154 (gnus-cache-save-buffers))
5155 (gnus-async-prefetch-remove-group group)
5156 (when gnus-suppress-duplicates
5157 (gnus-dup-enter-articles))
5158 (when gnus-use-trees
5159 (gnus-tree-close group))
5160 ;; Remove entries for this group.
5161 (nnmail-purge-split-history (gnus-group-real-name group))
5162 ;; Make all changes in this group permanent.
5164 (gnus-run-hooks 'gnus-exit-group-hook)
5165 (gnus-summary-update-info)
5166 ;; Do adaptive scoring, and possibly save score files.
5167 (when gnus-newsgroup-adaptive
5168 (gnus-score-adaptive))
5169 (when gnus-use-scoring
5171 (gnus-close-group group)
5172 ;; Make sure where we were, and go to next newsgroup.
5173 (set-buffer gnus-group-buffer)
5175 (gnus-group-jump-to-group group))
5176 (gnus-run-hooks 'gnus-summary-exit-hook)
5177 (unless (or quit-config
5178 ;; If this group has disappeared from the summary
5179 ;; buffer, don't skip forwards.
5180 (not (string= group (gnus-group-group-name))))
5181 (gnus-group-next-unread-group 1))
5182 (setq group-point (point))
5185 ;; If we have several article buffers, we kill them at exit.
5186 (unless gnus-single-article-buffer
5187 (gnus-kill-buffer gnus-article-buffer)
5188 (gnus-kill-buffer gnus-original-article-buffer)
5189 (setq gnus-article-current nil))
5191 (if (not gnus-kill-summary-on-exit)
5192 (gnus-deaden-summary)
5193 ;; We set all buffer-local variables to nil. It is unclear why
5194 ;; this is needed, but if we don't, buffer-local variables are
5195 ;; not garbage-collected, it seems. This would the lead to en
5196 ;; ever-growing Emacs.
5197 (gnus-summary-clear-local-variables)
5198 (when (get-buffer gnus-article-buffer)
5199 (bury-buffer gnus-article-buffer))
5200 ;; We clear the global counterparts of the buffer-local
5201 ;; variables as well, just to be on the safe side.
5202 (set-buffer gnus-group-buffer)
5203 (gnus-summary-clear-local-variables)
5204 ;; Return to group mode buffer.
5205 (when (eq mode 'gnus-summary-mode)
5206 (gnus-kill-buffer buf)))
5207 (setq gnus-current-select-method gnus-select-method)
5208 (pop-to-buffer gnus-group-buffer)
5209 (if (not quit-config)
5211 (goto-char group-point)
5212 (gnus-configure-windows 'group 'force))
5213 (gnus-handle-ephemeral-exit quit-config))
5214 ;; Clear the current group name.
5216 (setq gnus-newsgroup-name nil)))))
5218 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5219 (defun gnus-summary-exit-no-update (&optional no-questions)
5220 "Quit reading current newsgroup without updating read article info."
5222 (let* ((group gnus-newsgroup-name)
5223 (quit-config (gnus-group-quit-config group)))
5224 (when (or no-questions
5226 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5227 (gnus-async-halt-prefetch)
5228 (gnus-run-hooks (delq 'gnus-summary-expire-articles
5229 (copy-list gnus-summary-prepare-exit-hook)))
5230 ;; If we have several article buffers, we kill them at exit.
5231 (unless gnus-single-article-buffer
5232 (gnus-kill-buffer gnus-article-buffer)
5233 (gnus-kill-buffer gnus-original-article-buffer)
5234 (setq gnus-article-current nil))
5235 (if (not gnus-kill-summary-on-exit)
5236 (gnus-deaden-summary)
5237 (gnus-close-group group)
5238 (gnus-summary-clear-local-variables)
5239 (set-buffer gnus-group-buffer)
5240 (gnus-summary-clear-local-variables)
5241 (when (get-buffer gnus-summary-buffer)
5242 (kill-buffer gnus-summary-buffer)))
5243 (unless gnus-single-article-buffer
5244 (setq gnus-article-current nil))
5245 (when gnus-use-trees
5246 (gnus-tree-close group))
5247 (gnus-async-prefetch-remove-group group)
5248 (when (get-buffer gnus-article-buffer)
5249 (bury-buffer gnus-article-buffer))
5250 ;; Return to the group buffer.
5251 (gnus-configure-windows 'group 'force)
5252 ;; Clear the current group name.
5253 (setq gnus-newsgroup-name nil)
5254 (when (equal (gnus-group-group-name) group)
5255 (gnus-group-next-unread-group 1))
5257 (gnus-handle-ephemeral-exit quit-config)))))
5259 (defun gnus-handle-ephemeral-exit (quit-config)
5260 "Handle movement when leaving an ephemeral group.
5261 The state which existed when entering the ephemeral is reset."
5262 (if (not (buffer-name (car quit-config)))
5263 (gnus-configure-windows 'group 'force)
5264 (set-buffer (car quit-config))
5265 (cond ((eq major-mode 'gnus-summary-mode)
5266 (gnus-set-global-variables))
5267 ((eq major-mode 'gnus-article-mode)
5269 ;; The `gnus-summary-buffer' variable may point
5270 ;; to the old summary buffer when using a single
5272 (unless (gnus-buffer-live-p gnus-summary-buffer)
5273 (set-buffer gnus-group-buffer))
5274 (set-buffer gnus-summary-buffer)
5275 (gnus-set-global-variables))))
5276 (if (or (eq (cdr quit-config) 'article)
5277 (eq (cdr quit-config) 'pick))
5279 ;; The current article may be from the ephemeral group
5280 ;; thus it is best that we reload this article
5281 (gnus-summary-show-article)
5282 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5283 (gnus-configure-windows 'pick 'force)
5284 (gnus-configure-windows (cdr quit-config) 'force)))
5285 (gnus-configure-windows (cdr quit-config) 'force))
5286 (when (eq major-mode 'gnus-summary-mode)
5287 (gnus-summary-next-subject 1 nil t)
5288 (gnus-summary-recenter)
5289 (gnus-summary-position-point))))
5291 (defun gnus-summary-preview-mime-message (arg)
5292 "MIME decode and play this message."
5295 (let ((gnus-break-pages nil)
5297 (gnus-summary-select-article t t)
5299 (select-window (get-buffer-window gnus-article-buffer))
5304 (defvar gnus-dead-summary-mode-map nil)
5306 (unless gnus-dead-summary-mode-map
5307 (setq gnus-dead-summary-mode-map (make-keymap))
5308 (suppress-keymap gnus-dead-summary-mode-map)
5309 (substitute-key-definition
5310 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5311 (let ((keys '("\C-d" "\r" "\177" [delete])))
5313 (define-key gnus-dead-summary-mode-map
5314 (pop keys) 'gnus-summary-wake-up-the-dead))))
5316 (defvar gnus-dead-summary-mode nil
5317 "Minor mode for Gnus summary buffers.")
5319 (defun gnus-dead-summary-mode (&optional arg)
5320 "Minor mode for Gnus summary buffers."
5322 (when (eq major-mode 'gnus-summary-mode)
5323 (make-local-variable 'gnus-dead-summary-mode)
5324 (setq gnus-dead-summary-mode
5325 (if (null arg) (not gnus-dead-summary-mode)
5326 (> (prefix-numeric-value arg) 0)))
5327 (when gnus-dead-summary-mode
5328 (gnus-add-minor-mode
5329 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5331 (defun gnus-deaden-summary ()
5332 "Make the current summary buffer into a dead summary buffer."
5333 ;; Kill any previous dead summary buffer.
5334 (when (and gnus-dead-summary
5335 (buffer-name gnus-dead-summary))
5337 (set-buffer gnus-dead-summary)
5338 (when gnus-dead-summary-mode
5339 (kill-buffer (current-buffer)))))
5340 ;; Make this the current dead summary.
5341 (setq gnus-dead-summary (current-buffer))
5342 (gnus-dead-summary-mode 1)
5343 (let ((name (buffer-name)))
5344 (when (string-match "Summary" name)
5346 (concat (substring name 0 (match-beginning 0)) "Dead "
5347 (substring name (match-beginning 0)))
5350 (defun gnus-kill-or-deaden-summary (buffer)
5351 "Kill or deaden the summary BUFFER."
5353 (when (and (buffer-name buffer)
5354 (not gnus-single-article-buffer))
5357 (gnus-kill-buffer gnus-article-buffer)
5358 (gnus-kill-buffer gnus-original-article-buffer)))
5359 (cond (gnus-kill-summary-on-exit
5360 (when (and gnus-use-trees
5361 (gnus-buffer-exists-p buffer))
5364 (gnus-tree-close gnus-newsgroup-name)))
5365 (gnus-kill-buffer buffer))
5366 ((gnus-buffer-exists-p buffer)
5369 (gnus-deaden-summary))))))
5371 (defun gnus-summary-wake-up-the-dead (&rest args)
5372 "Wake up the dead summary buffer."
5374 (gnus-dead-summary-mode -1)
5375 (let ((name (buffer-name)))
5376 (when (string-match "Dead " name)
5378 (concat (substring name 0 (match-beginning 0))
5379 (substring name (match-end 0)))
5381 (gnus-message 3 "This dead summary is now alive again"))
5383 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5384 (defun gnus-summary-fetch-faq (&optional faq-dir)
5385 "Fetch the FAQ for the current group.
5386 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5390 (when current-prefix-arg
5392 "Faq dir: " (and (listp gnus-group-faq-directory)
5393 (mapcar (lambda (file) (list file))
5394 gnus-group-faq-directory))))))
5395 (let (gnus-faq-buffer)
5396 (when (setq gnus-faq-buffer
5397 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5398 (gnus-configure-windows 'summary-faq))))
5400 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5401 (defun gnus-summary-describe-group (&optional force)
5402 "Describe the current newsgroup."
5404 (gnus-group-describe-group force gnus-newsgroup-name))
5406 (defun gnus-summary-describe-briefly ()
5407 "Describe summary mode commands briefly."
5410 (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")))
5412 ;; Walking around group mode buffer from summary mode.
5414 (defun gnus-summary-next-group (&optional no-article target-group backward)
5415 "Exit current newsgroup and then select next unread newsgroup.
5416 If prefix argument NO-ARTICLE is non-nil, no article is selected
5417 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5418 previous group instead."
5420 ;; Stop pre-fetching.
5421 (gnus-async-halt-prefetch)
5422 (let ((current-group gnus-newsgroup-name)
5423 (current-buffer (current-buffer))
5425 ;; First we semi-exit this group to update Xrefs and all variables.
5426 ;; We can't do a real exit, because the window conf must remain
5427 ;; the same in case the user is prompted for info, and we don't
5428 ;; want the window conf to change before that...
5429 (gnus-summary-exit t)
5430 (while (not entered)
5431 ;; Then we find what group we are supposed to enter.
5432 (set-buffer gnus-group-buffer)
5433 (gnus-group-jump-to-group current-group)
5436 (if (eq gnus-keep-same-level 'best)
5437 (gnus-summary-best-group gnus-newsgroup-name)
5438 (gnus-summary-search-group backward gnus-keep-same-level))))
5439 (if (not target-group)
5440 ;; There are no further groups, so we return to the group
5443 (gnus-message 5 "Returning to the group buffer")
5445 (when (gnus-buffer-live-p current-buffer)
5446 (set-buffer current-buffer)
5447 (gnus-summary-exit))
5448 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5449 ;; We try to enter the target group.
5450 (gnus-group-jump-to-group target-group)
5451 (let ((unreads (gnus-group-group-unread)))
5452 (if (and (or (eq t unreads)
5453 (and unreads (not (zerop unreads))))
5454 (gnus-summary-read-group
5455 target-group nil no-article
5456 (and (buffer-name current-buffer) current-buffer)
5459 (setq current-group target-group
5460 target-group nil)))))))
5462 (defun gnus-summary-prev-group (&optional no-article)
5463 "Exit current newsgroup and then select previous unread newsgroup.
5464 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5466 (gnus-summary-next-group no-article nil t))
5468 ;; Walking around summary lines.
5470 (defun gnus-summary-first-subject (&optional unread undownloaded)
5471 "Go to the first unread subject.
5472 If UNREAD is non-nil, go to the first unread article.
5473 Returns the article selected or nil if there are no unread articles."
5478 ((null gnus-newsgroup-data)
5479 (gnus-message 3 "No articles in the group")
5481 ;; Pick the first article.
5483 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5484 (gnus-data-number (car gnus-newsgroup-data)))
5485 ;; No unread articles.
5486 ((null gnus-newsgroup-unreads)
5487 (gnus-message 3 "No more unread articles")
5489 ;; Find the first unread article.
5491 (let ((data gnus-newsgroup-data))
5493 (and (not (and undownloaded
5494 (eq gnus-undownloaded-mark
5495 (gnus-data-mark (car data)))))
5496 (not (gnus-data-unread-p (car data)))))
5497 (setq data (cdr data)))
5499 (goto-char (gnus-data-pos (car data)))
5500 (gnus-data-number (car data))))))
5501 (gnus-summary-position-point)))
5503 (defun gnus-summary-next-subject (n &optional unread dont-display)
5504 "Go to next N'th summary line.
5505 If N is negative, go to the previous N'th subject line.
5506 If UNREAD is non-nil, only unread articles are selected.
5507 The difference between N and the actual number of steps taken is
5510 (let ((backward (< n 0))
5514 (gnus-summary-find-prev unread)
5515 (gnus-summary-find-next unread)))
5516 (gnus-summary-show-thread)
5519 (gnus-message 7 "No more%s articles"
5520 (if unread " unread" "")))
5521 (unless dont-display
5522 (gnus-summary-recenter)
5523 (gnus-summary-position-point))
5526 (defun gnus-summary-next-unread-subject (n)
5527 "Go to next N'th unread summary line."
5529 (gnus-summary-next-subject n t))
5531 (defun gnus-summary-prev-subject (n &optional unread)
5532 "Go to previous N'th summary line.
5533 If optional argument UNREAD is non-nil, only unread article is selected."
5535 (gnus-summary-next-subject (- n) unread))
5537 (defun gnus-summary-prev-unread-subject (n)
5538 "Go to previous N'th unread summary line."
5540 (gnus-summary-next-subject (- n) t))
5542 (defun gnus-summary-goto-subject (article &optional force silent)
5543 "Go the subject line of ARTICLE.
5544 If FORCE, also allow jumping to articles not currently shown."
5545 (interactive "nArticle number: ")
5547 (data (gnus-data-find article)))
5548 ;; We read in the article if we have to.
5551 (gnus-summary-insert-subject
5553 (if (or (numberp force) (vectorp force)) force)
5555 (setq data (gnus-data-find article)))
5560 (gnus-message 3 "Can't find article %d" article))
5562 (goto-char (gnus-data-pos data))
5563 (gnus-summary-position-point)
5566 ;; Walking around summary lines with displaying articles.
5568 (defun gnus-summary-expand-window (&optional arg)
5569 "Make the summary buffer take up the entire Emacs frame.
5570 Given a prefix, will force an `article' buffer configuration."
5573 (gnus-configure-windows 'article 'force)
5574 (gnus-configure-windows 'summary 'force)))
5576 (defun gnus-summary-display-article (article &optional all-header)
5577 "Display ARTICLE in article buffer."
5578 (gnus-set-global-variables)
5582 (if gnus-summary-display-article-function
5583 (funcall gnus-summary-display-article-function article all-header)
5584 (gnus-article-prepare article all-header))
5585 (gnus-run-hooks 'gnus-select-article-hook)
5586 (when (and gnus-current-article
5587 (not (zerop gnus-current-article)))
5588 (gnus-summary-goto-subject gnus-current-article))
5589 (gnus-summary-recenter)
5590 (when (and gnus-use-trees gnus-show-threads)
5591 (gnus-possibly-generate-tree article)
5592 (gnus-highlight-selected-tree article))
5593 ;; Successfully display article.
5594 (gnus-article-set-window-start
5595 (cdr (assq article gnus-newsgroup-bookmarks))))))
5597 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5598 "Select the current article.
5599 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5600 non-nil, the article will be re-fetched even if it already present in
5601 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5603 ;; Make sure we are in the summary buffer to work around bbdb bug.
5604 (unless (eq major-mode 'gnus-summary-mode)
5605 (set-buffer gnus-summary-buffer))
5606 (let ((article (or article (gnus-summary-article-number)))
5607 (all-headers (not (not all-headers))) ;Must be T or NIL.
5608 gnus-summary-display-article-function
5611 (gnus-summary-article-pseudo-p article)
5612 (error "This is a pseudo-article"))
5615 (set-buffer gnus-summary-buffer)
5616 (if (or (and gnus-single-article-buffer
5617 (or (null gnus-current-article)
5618 (null gnus-article-current)
5619 (null (get-buffer gnus-article-buffer))
5620 (not (eq article (cdr gnus-article-current)))
5621 (not (equal (car gnus-article-current)
5622 gnus-newsgroup-name))))
5623 (and (not gnus-single-article-buffer)
5624 (or (null gnus-current-article)
5625 (not (eq gnus-current-article article))))
5627 ;; The requested article is different from the current article.
5629 (gnus-summary-display-article article all-headers)
5631 (when (or all-headers gnus-show-all-headers)
5632 (gnus-article-show-all-headers))
5635 (gnus-article-set-window-start
5636 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5638 (defun gnus-summary-set-current-mark (&optional current-mark)
5639 "Obsolete function."
5642 (defun gnus-summary-next-article (&optional unread subject backward push)
5643 "Select the next article.
5644 If UNREAD, only unread articles are selected.
5645 If SUBJECT, only articles with SUBJECT are selected.
5646 If BACKWARD, the previous article is selected instead of the next."
5649 ;; Is there such an article?
5650 ((and (gnus-summary-search-forward unread subject backward)
5651 (or (gnus-summary-display-article (gnus-summary-article-number))
5652 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5653 (gnus-summary-position-point))
5654 ;; If not, we try the first unread, if that is wanted.
5656 gnus-auto-select-same
5657 (gnus-summary-first-unread-article))
5658 (gnus-summary-position-point)
5659 (gnus-message 6 "Wrapped"))
5660 ;; Try to get next/previous article not displayed in this group.
5661 ((and gnus-auto-extend-newsgroup
5662 (not unread) (not subject))
5663 (gnus-summary-goto-article
5664 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5665 nil (count-lines (point-min) (point))))
5666 ;; Go to next/previous group.
5668 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5669 (gnus-summary-jump-to-group gnus-newsgroup-name))
5670 (let ((cmd last-command-char)
5673 (set-buffer gnus-group-buffer)
5676 (if (eq gnus-keep-same-level 'best)
5677 (gnus-summary-best-group gnus-newsgroup-name)
5678 (gnus-summary-search-group backward gnus-keep-same-level))))
5679 ;; For some reason, the group window gets selected. We change
5681 (select-window (get-buffer-window (current-buffer)))
5682 ;; Select next unread newsgroup automagically.
5684 ((or (not gnus-auto-select-next)
5686 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5687 ((or (eq gnus-auto-select-next 'quietly)
5688 (and (eq gnus-auto-select-next 'slightly-quietly)
5690 (and (eq gnus-auto-select-next 'almost-quietly)
5691 (gnus-summary-last-article-p)))
5693 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5695 (gnus-message 7 "No more%s articles (%s)..."
5696 (if unread " unread" "")
5697 (if group (concat "selecting " group)
5699 (gnus-summary-next-group nil group backward)))
5701 (when (gnus-key-press-event-p last-input-event)
5702 (gnus-summary-walk-group-buffer
5703 gnus-newsgroup-name cmd unread backward point))))))))
5705 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5706 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5707 (?\C-p (gnus-group-prev-unread-group 1))))
5708 (cursor-in-echo-area t)
5709 keve key group ended)
5711 (set-buffer gnus-group-buffer)
5714 (if (eq gnus-keep-same-level 'best)
5715 (gnus-summary-best-group gnus-newsgroup-name)
5716 (gnus-summary-search-group backward gnus-keep-same-level))))
5719 5 "No more%s articles%s" (if unread " unread" "")
5721 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5722 (format " (Type %s for %s [%s])"
5723 (single-key-description cmd) group
5724 (car (gnus-gethash group gnus-newsrc-hashtb)))
5725 (format " (Type %s to exit %s)"
5726 (single-key-description cmd)
5727 gnus-newsgroup-name)))
5728 ;; Confirm auto selection.
5729 (setq key (car (setq keve (gnus-read-event-char))))
5732 ((assq key keystrokes)
5733 (let ((obuf (current-buffer)))
5734 (switch-to-buffer gnus-group-buffer)
5736 (gnus-group-jump-to-group group))
5737 (eval (cadr (assq key keystrokes)))
5738 (setq group (gnus-group-group-name))
5739 (switch-to-buffer obuf))
5743 (gnus-ephemeral-group-p gnus-newsgroup-name))
5745 (gnus-summary-next-group nil group backward)))
5747 (push (cdr keve) unread-command-events))))))
5749 (defun gnus-summary-next-unread-article ()
5750 "Select unread article after current one."
5752 (gnus-summary-next-article
5753 (or (not (eq gnus-summary-goto-unread 'never))
5754 (gnus-summary-last-article-p (gnus-summary-article-number)))
5755 (and gnus-auto-select-same
5756 (gnus-summary-article-subject))))
5758 (defun gnus-summary-prev-article (&optional unread subject)
5759 "Select the article after the current one.
5760 If UNREAD is non-nil, only unread articles are selected."
5762 (gnus-summary-next-article unread subject t))
5764 (defun gnus-summary-prev-unread-article ()
5765 "Select unread article before current one."
5767 (gnus-summary-prev-article
5768 (or (not (eq gnus-summary-goto-unread 'never))
5769 (gnus-summary-first-article-p (gnus-summary-article-number)))
5770 (and gnus-auto-select-same
5771 (gnus-summary-article-subject))))
5773 (defun gnus-summary-next-page (&optional lines circular)
5774 "Show next page of the selected article.
5775 If at the end of the current article, select the next article.
5776 LINES says how many lines should be scrolled up.
5778 If CIRCULAR is non-nil, go to the start of the article instead of
5779 selecting the next article when reaching the end of the current
5782 (setq gnus-summary-buffer (current-buffer))
5783 (gnus-set-global-variables)
5784 (let ((article (gnus-summary-article-number))
5785 (article-window (get-buffer-window gnus-article-buffer t))
5787 ;; If the buffer is empty, we have no article.
5789 (error "No article to select"))
5790 (gnus-configure-windows 'article)
5791 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5792 (if (and (eq gnus-summary-goto-unread 'never)
5793 (not (gnus-summary-last-article-p article)))
5794 (gnus-summary-next-article)
5795 (gnus-summary-next-unread-article))
5796 (if (or (null gnus-current-article)
5797 (null gnus-article-current)
5798 (/= article (cdr gnus-article-current))
5799 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5800 ;; Selected subject is different from current article's.
5801 (gnus-summary-display-article article)
5802 (when article-window
5803 (gnus-eval-in-buffer-window gnus-article-buffer
5804 (setq endp (gnus-article-next-page lines)))
5807 (gnus-summary-beginning-of-article))
5809 (gnus-message 3 "End of message"))
5811 (if (and (eq gnus-summary-goto-unread 'never)
5812 (not (gnus-summary-last-article-p article)))
5813 (gnus-summary-next-article)
5814 (gnus-summary-next-unread-article))))))))
5815 (gnus-summary-recenter)
5816 (gnus-summary-position-point)))
5818 (defun gnus-summary-prev-page (&optional lines move)
5819 "Show previous page of selected article.
5820 Argument LINES specifies lines to be scrolled down.
5821 If MOVE, move to the previous unread article if point is at
5822 the beginning of the buffer."
5824 (let ((article (gnus-summary-article-number))
5825 (article-window (get-buffer-window gnus-article-buffer t))
5827 (gnus-configure-windows 'article)
5828 (if (or (null gnus-current-article)
5829 (null gnus-article-current)
5830 (/= article (cdr gnus-article-current))
5831 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5832 ;; Selected subject is different from current article's.
5833 (gnus-summary-display-article article)
5834 (gnus-summary-recenter)
5835 (when article-window
5836 (gnus-eval-in-buffer-window gnus-article-buffer
5837 (setq endp (gnus-article-prev-page lines)))
5838 (when (and move endp)
5840 (gnus-message 3 "Beginning of message"))
5842 (if (and (eq gnus-summary-goto-unread 'never)
5843 (not (gnus-summary-first-article-p article)))
5844 (gnus-summary-prev-article)
5845 (gnus-summary-prev-unread-article))))))))
5846 (gnus-summary-position-point))
5848 (defun gnus-summary-prev-page-or-article (&optional lines)
5849 "Show previous page of selected article.
5850 Argument LINES specifies lines to be scrolled down.
5851 If at the beginning of the article, go to the next article."
5853 (gnus-summary-prev-page lines t))
5855 (defun gnus-summary-scroll-up (lines)
5856 "Scroll up (or down) one line current article.
5857 Argument LINES specifies lines to be scrolled up (or down if negative)."
5859 (gnus-configure-windows 'article)
5860 (gnus-summary-show-thread)
5861 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5862 (gnus-eval-in-buffer-window gnus-article-buffer
5864 (when (gnus-article-next-page lines)
5865 (gnus-message 3 "End of message")))
5867 (gnus-article-prev-page (- lines))))))
5868 (gnus-summary-recenter)
5869 (gnus-summary-position-point))
5871 (defun gnus-summary-scroll-down (lines)
5872 "Scroll down (or up) one line current article.
5873 Argument LINES specifies lines to be scrolled down (or up if negative)."
5875 (gnus-summary-scroll-up (- lines)))
5877 (defun gnus-summary-next-same-subject ()
5878 "Select next article which has the same subject as current one."
5880 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5882 (defun gnus-summary-prev-same-subject ()
5883 "Select previous article which has the same subject as current one."
5885 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5887 (defun gnus-summary-next-unread-same-subject ()
5888 "Select next unread article which has the same subject as current one."
5890 (gnus-summary-next-article t (gnus-summary-article-subject)))
5892 (defun gnus-summary-prev-unread-same-subject ()
5893 "Select previous unread article which has the same subject as current one."
5895 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5897 (defun gnus-summary-first-unread-article ()
5898 "Select the first unread article.
5899 Return nil if there are no unread articles."
5902 (when (gnus-summary-first-subject t)
5903 (gnus-summary-show-thread)
5904 (gnus-summary-first-subject t)
5905 (gnus-summary-display-article (gnus-summary-article-number)))
5906 (gnus-summary-position-point)))
5908 (defun gnus-summary-first-unread-subject ()
5909 "Place the point on the subject line of the first unread article.
5910 Return nil if there are no unread articles."
5913 (when (gnus-summary-first-subject t)
5914 (gnus-summary-show-thread)
5915 (gnus-summary-first-subject t))
5916 (gnus-summary-position-point)))
5918 (defun gnus-summary-first-article ()
5919 "Select the first article.
5920 Return nil if there are no articles."
5923 (when (gnus-summary-first-subject)
5924 (gnus-summary-show-thread)
5925 (gnus-summary-first-subject)
5926 (gnus-summary-display-article (gnus-summary-article-number)))
5927 (gnus-summary-position-point)))
5929 (defun gnus-summary-best-unread-article ()
5930 "Select the unread article with the highest score."
5932 (let ((best -1000000)
5933 (data gnus-newsgroup-data)
5936 (and (gnus-data-unread-p (car data))
5938 (gnus-summary-article-score (gnus-data-number (car data))))
5941 article (gnus-data-number (car data))))
5942 (setq data (cdr data)))
5945 (gnus-summary-goto-article article)
5946 (error "No unread articles"))
5947 (gnus-summary-position-point))))
5949 (defun gnus-summary-last-subject ()
5950 "Go to the last displayed subject line in the group."
5951 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5953 (gnus-summary-goto-subject article))))
5955 (defun gnus-summary-goto-article (article &optional all-headers force)
5956 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5957 If ALL-HEADERS is non-nil, no header lines are hidden.
5958 If FORCE, go to the article even if it isn't displayed. If FORCE
5959 is a number, it is the line the article is to be displayed on."
5963 "Article number or Message-ID: "
5964 (mapcar (lambda (number) (list (int-to-string number)))
5965 gnus-newsgroup-limit))
5969 (if (and (stringp article)
5970 (string-match "@" article))
5971 (gnus-summary-refer-article article)
5972 (when (stringp article)
5973 (setq article (string-to-number article)))
5974 (if (gnus-summary-goto-subject article force)
5975 (gnus-summary-display-article article all-headers)
5976 (gnus-message 4 "Couldn't go to article %s" article) nil))
5977 (gnus-summary-position-point)))
5979 (defun gnus-summary-goto-last-article ()
5980 "Go to the previously read article."
5983 (when gnus-last-article
5984 (gnus-summary-goto-article gnus-last-article nil t))
5985 (gnus-summary-position-point)))
5987 (defun gnus-summary-pop-article (number)
5988 "Pop one article off the history and go to the previous.
5989 NUMBER articles will be popped off."
5992 (setq gnus-newsgroup-history
5993 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5995 (gnus-summary-goto-article (car to) nil t)
5996 (error "Article history empty")))
5997 (gnus-summary-position-point))
5999 ;; Summary commands and functions for limiting the summary buffer.
6001 (defun gnus-summary-limit-to-articles (n)
6002 "Limit the summary buffer to the next N articles.
6003 If not given a prefix, use the process marked articles instead."
6006 (let ((articles (gnus-summary-work-articles n)))
6007 (setq gnus-newsgroup-processable nil)
6008 (gnus-summary-limit articles))
6009 (gnus-summary-position-point)))
6011 (defun gnus-summary-pop-limit (&optional total)
6012 "Restore the previous limit.
6013 If given a prefix, remove all limits."
6016 (setq gnus-newsgroup-limits
6017 (list (mapcar (lambda (h) (mail-header-number h))
6018 gnus-newsgroup-headers))))
6019 (unless gnus-newsgroup-limits
6020 (error "No limit to pop"))
6022 (gnus-summary-limit nil 'pop)
6023 (gnus-summary-position-point)))
6025 (defun gnus-summary-limit-to-subject (subject &optional header)
6026 "Limit the summary buffer to articles that have subjects that match a regexp."
6027 (interactive "sLimit to subject (regexp): ")
6029 (setq header "subject"))
6030 (when (not (equal "" subject))
6032 (let ((articles (gnus-summary-find-matching
6033 (or header "subject") subject 'all)))
6035 (error "Found no matches for \"%s\"" subject))
6036 (gnus-summary-limit articles))
6037 (gnus-summary-position-point))))
6039 (defun gnus-summary-limit-to-author (from)
6040 "Limit the summary buffer to articles that have authors that match a regexp."
6041 (interactive "sLimit to author (regexp): ")
6042 (gnus-summary-limit-to-subject from "from"))
6044 (defun gnus-summary-limit-to-age (age &optional younger-p)
6045 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6046 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6047 articles that are younger than AGE days."
6048 (interactive "nTime in days: \nP")
6050 (let ((data gnus-newsgroup-data)
6051 (cutoff (days-to-time age))
6052 articles d date is-younger)
6053 (while (setq d (pop data))
6054 (when (and (vectorp (gnus-data-header d))
6055 (setq date (mail-header-date (gnus-data-header d))))
6056 (setq is-younger (time-less-p
6057 (time-since (date-to-time date))
6062 (push (gnus-data-number d) articles))))
6063 (gnus-summary-limit (nreverse articles)))
6064 (gnus-summary-position-point)))
6066 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6068 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6070 (defun gnus-summary-limit-to-unread (&optional all)
6071 "Limit the summary buffer to articles that are not marked as read.
6072 If ALL is non-nil, limit strictly to unread articles."
6075 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6076 (gnus-summary-limit-to-marks
6077 ;; Concat all the marks that say that an article is read and have
6079 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6080 gnus-killed-mark gnus-kill-file-mark
6081 gnus-low-score-mark gnus-expirable-mark
6082 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6083 gnus-duplicate-mark gnus-souped-mark)
6086 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6087 (make-obsolete 'gnus-summary-delete-marked-with
6088 'gnus-summary-limit-exlude-marks)
6090 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6091 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6092 If REVERSE, limit the summary buffer to articles that are marked
6093 with MARKS. MARKS can either be a string of marks or a list of marks.
6094 Returns how many articles were removed."
6095 (interactive "sMarks: ")
6096 (gnus-summary-limit-to-marks marks t))
6098 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6099 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6100 If REVERSE (the prefix), limit the summary buffer to articles that are
6101 not marked with MARKS. MARKS can either be a string of marks or a
6103 Returns how many articles were removed."
6104 (interactive "sMarks: \nP")
6106 (let ((data gnus-newsgroup-data)
6107 (marks (if (listp marks) marks
6108 (append marks nil))) ; Transform to list.
6111 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6112 (memq (gnus-data-mark (car data)) marks))
6113 (push (gnus-data-number (car data)) articles))
6114 (setq data (cdr data)))
6115 (gnus-summary-limit articles))
6116 (gnus-summary-position-point)))
6118 (defun gnus-summary-limit-to-score (&optional score)
6119 "Limit to articles with score at or above SCORE."
6121 (setq score (if score
6122 (prefix-numeric-value score)
6123 (or gnus-summary-default-score 0)))
6124 (let ((data gnus-newsgroup-data)
6127 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6129 (push (gnus-data-number (car data)) articles))
6130 (setq data (cdr data)))
6132 (gnus-summary-limit articles)
6133 (gnus-summary-position-point))))
6135 (defun gnus-summary-limit-include-thread (id)
6136 "Display all the hidden articles that in the current thread."
6137 (interactive (list (mail-header-id (gnus-summary-article-header))))
6138 (let ((articles (gnus-articles-in-thread
6139 (gnus-id-to-thread (gnus-root-id id)))))
6141 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6142 (gnus-summary-position-point))))
6144 (defun gnus-summary-limit-include-dormant ()
6145 "Display all the hidden articles that are marked as dormant.
6146 Note that this command only works on a subset of the articles currently
6147 fetched for this group."
6149 (unless gnus-newsgroup-dormant
6150 (error "There are no dormant articles in this group"))
6152 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6153 (gnus-summary-position-point)))
6155 (defun gnus-summary-limit-exclude-dormant ()
6156 "Hide all dormant articles."
6159 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6160 (gnus-summary-position-point)))
6162 (defun gnus-summary-limit-exclude-childless-dormant ()
6163 "Hide all dormant articles that have no children."
6165 (let ((data (gnus-data-list t))
6166 articles d children)
6167 ;; Find all articles that are either not dormant or have
6169 (while (setq d (pop data))
6170 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6172 (gnus-article-children (gnus-data-number d)))
6175 (when (memq (car children) articles)
6180 (push (gnus-data-number d) articles)))
6183 (gnus-summary-limit articles)
6184 (gnus-summary-position-point))))
6186 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6187 "Mark all unread excluded articles as read.
6188 If ALL, mark even excluded ticked and dormants as read."
6190 (let ((articles (gnus-sorted-complement
6192 (mapcar (lambda (h) (mail-header-number h))
6193 gnus-newsgroup-headers)
6195 (sort gnus-newsgroup-limit '<)))
6197 (setq gnus-newsgroup-unreads
6198 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6200 (setq gnus-newsgroup-dormant nil
6201 gnus-newsgroup-marked nil
6202 gnus-newsgroup-reads
6204 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6205 gnus-newsgroup-reads))
6206 (while (setq article (pop articles))
6207 (unless (or (memq article gnus-newsgroup-dormant)
6208 (memq article gnus-newsgroup-marked))
6209 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6211 (defun gnus-summary-limit (articles &optional pop)
6213 ;; We pop the previous limit off the stack and use that.
6214 (setq articles (car gnus-newsgroup-limits)
6215 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6216 ;; We use the new limit, so we push the old limit on the stack.
6217 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6219 (setq gnus-newsgroup-limit articles)
6220 (let ((total (length gnus-newsgroup-data))
6221 (data (gnus-data-find-list (gnus-summary-article-number)))
6222 (gnus-summary-mark-below nil) ; Inhibit this.
6224 ;; This will do all the work of generating the new summary buffer
6225 ;; according to the new limit.
6226 (gnus-summary-prepare)
6227 ;; Hide any threads, possibly.
6228 (and gnus-show-threads
6229 gnus-thread-hide-subtree
6230 (gnus-summary-hide-all-threads))
6231 ;; Try to return to the article you were at, or one in the
6234 ;; We try to find some article after the current one.
6236 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6239 (setq data (cdr data))))
6241 ;; If there is no data, that means that we were after the last
6242 ;; article. The same goes when we can't find any articles
6243 ;; after the current one.
6244 (goto-char (point-max))
6245 (gnus-summary-find-prev))
6246 (gnus-set-mode-line 'summary)
6247 ;; We return how many articles were removed from the summary
6248 ;; buffer as a result of the new limit.
6249 (- total (length gnus-newsgroup-data))))
6251 (defsubst gnus-invisible-cut-children (threads)
6254 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6259 (defsubst gnus-cut-thread (thread)
6260 "Go forwards in the thread until we find an article that we want to display."
6261 (when (or (eq gnus-fetch-old-headers 'some)
6262 (eq gnus-fetch-old-headers 'invisible)
6263 (eq gnus-build-sparse-threads 'some)
6264 (eq gnus-build-sparse-threads 'more))
6265 ;; Deal with old-fetched headers and sparse threads.
6269 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6270 (gnus-summary-article-ancient-p
6271 (mail-header-number (car thread))))
6272 (if (or (<= (length (cdr thread)) 1)
6273 (eq gnus-fetch-old-headers 'invisible))
6274 (setq gnus-newsgroup-limit
6275 (delq (mail-header-number (car thread))
6276 gnus-newsgroup-limit)
6277 thread (cadr thread))
6278 (when (gnus-invisible-cut-children (cdr thread))
6279 (let ((th (cdr thread)))
6281 (if (memq (mail-header-number (caar th))
6282 gnus-newsgroup-limit)
6283 (setq thread (car th)
6285 (setq th (cdr th))))))))))
6288 (defun gnus-cut-threads (threads)
6289 "Cut off all uninteresting articles from the beginning of threads."
6290 (when (or (eq gnus-fetch-old-headers 'some)
6291 (eq gnus-fetch-old-headers 'invisible)
6292 (eq gnus-build-sparse-threads 'some)
6293 (eq gnus-build-sparse-threads 'more))
6296 (setcar th (gnus-cut-thread (car th)))
6297 (setq th (cdr th)))))
6298 ;; Remove nixed out threads.
6301 (defun gnus-summary-initial-limit (&optional show-if-empty)
6302 "Figure out what the initial limit is supposed to be on group entry.
6303 This entails weeding out unwanted dormants, low-scored articles,
6304 fetch-old-headers verbiage, and so on."
6305 ;; Most groups have nothing to remove.
6306 (if (or gnus-inhibit-limiting
6307 (and (null gnus-newsgroup-dormant)
6308 (not (eq gnus-fetch-old-headers 'some))
6309 (not (eq gnus-fetch-old-headers 'invisible))
6310 (null gnus-summary-expunge-below)
6311 (not (eq gnus-build-sparse-threads 'some))
6312 (not (eq gnus-build-sparse-threads 'more))
6313 (null gnus-thread-expunge-below)
6314 (not gnus-use-nocem)))
6316 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6317 (setq gnus-newsgroup-limit nil)
6320 (unless (car (symbol-value node))
6321 ;; These threads have no parents -- they are roots.
6322 (let ((nodes (cdr (symbol-value node)))
6325 (if (and gnus-thread-expunge-below
6326 (< (gnus-thread-total-score (car nodes))
6327 gnus-thread-expunge-below))
6328 (gnus-expunge-thread (pop nodes))
6329 (setq thread (pop nodes))
6330 (gnus-summary-limit-children thread))))))
6331 gnus-newsgroup-dependencies)
6332 ;; If this limitation resulted in an empty group, we might
6333 ;; pop the previous limit and use it instead.
6334 (when (and (not gnus-newsgroup-limit)
6336 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6337 gnus-newsgroup-limit))
6339 (defun gnus-summary-limit-children (thread)
6340 "Return 1 if this subthread is visible and 0 if it is not."
6341 ;; First we get the number of visible children to this thread. This
6342 ;; is done by recursing down the thread using this function, so this
6343 ;; will really go down to a leaf article first, before slowly
6344 ;; working its way up towards the root.
6348 (apply '+ (mapcar 'gnus-summary-limit-children
6351 (number (mail-header-number (car thread)))
6354 (not (memq number gnus-newsgroup-marked))
6356 ;; If this article is dormant and has absolutely no visible
6357 ;; children, then this article isn't visible.
6358 (and (memq number gnus-newsgroup-dormant)
6360 ;; If this is "fetch-old-headered" and there is no
6361 ;; visible children, then we don't want this article.
6362 (and (eq gnus-fetch-old-headers 'some)
6363 (gnus-summary-article-ancient-p number)
6365 ;; If this is "fetch-old-headered" and `invisible', then
6366 ;; we don't want this article.
6367 (and (eq gnus-fetch-old-headers 'invisible)
6368 (gnus-summary-article-ancient-p number))
6369 ;; If this is a sparsely inserted article with no children,
6370 ;; we don't want it.
6371 (and (eq gnus-build-sparse-threads 'some)
6372 (gnus-summary-article-sparse-p number)
6374 ;; If we use expunging, and this article is really
6375 ;; low-scored, then we don't want this article.
6376 (when (and gnus-summary-expunge-below
6378 (or (cdr (assq number gnus-newsgroup-scored))
6379 gnus-summary-default-score))
6380 gnus-summary-expunge-below))
6381 ;; We increase the expunge-tally here, but that has
6382 ;; nothing to do with the limits, really.
6383 (incf gnus-newsgroup-expunged-tally)
6384 ;; We also mark as read here, if that's wanted.
6385 (when (and gnus-summary-mark-below
6386 (< score gnus-summary-mark-below))
6387 (setq gnus-newsgroup-unreads
6388 (delq number gnus-newsgroup-unreads))
6389 (if gnus-newsgroup-auto-expire
6390 (push number gnus-newsgroup-expirable)
6391 (push (cons number gnus-low-score-mark)
6392 gnus-newsgroup-reads)))
6394 ;; Check NoCeM things.
6395 (if (and gnus-use-nocem
6396 (gnus-nocem-unwanted-article-p
6397 (mail-header-id (car thread))))
6399 (setq gnus-newsgroup-unreads
6400 (delq number gnus-newsgroup-unreads))
6402 ;; Nope, invisible article.
6404 ;; Ok, this article is to be visible, so we add it to the limit
6406 (push number gnus-newsgroup-limit)
6409 (defun gnus-expunge-thread (thread)
6410 "Mark all articles in THREAD as read."
6411 (let* ((number (mail-header-number (car thread))))
6412 (incf gnus-newsgroup-expunged-tally)
6413 ;; We also mark as read here, if that's wanted.
6414 (setq gnus-newsgroup-unreads
6415 (delq number gnus-newsgroup-unreads))
6416 (if gnus-newsgroup-auto-expire
6417 (push number gnus-newsgroup-expirable)
6418 (push (cons number gnus-low-score-mark)
6419 gnus-newsgroup-reads)))
6420 ;; Go recursively through all subthreads.
6421 (mapcar 'gnus-expunge-thread (cdr thread)))
6423 ;; Summary article oriented commands
6425 (defun gnus-summary-refer-parent-article (n)
6426 "Refer parent article N times.
6427 If N is negative, go to ancestor -N instead.
6428 The difference between N and the number of articles fetched is returned."
6432 (when (not (natnump n))
6437 (setq header (gnus-summary-article-header))
6438 (if (and (eq (mail-header-number header)
6439 (cdr gnus-article-current))
6440 (equal gnus-newsgroup-name
6441 (car gnus-article-current)))
6442 ;; If we try to find the parent of the currently
6443 ;; displayed article, then we take a look at the actual
6444 ;; References header, since this is slightly more
6445 ;; reliable than the References field we got from the
6448 (set-buffer gnus-original-article-buffer)
6449 (nnheader-narrow-to-headers)
6450 (unless (setq ref (message-fetch-field "references"))
6451 (setq ref (message-fetch-field "in-reply-to")))
6454 ;; It's not the current article, so we take a bet on
6455 ;; the value we got from the server.
6456 (mail-header-references header)))
6458 (not (equal ref "")))
6459 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6460 (gnus-message 1 "Couldn't find parent"))
6461 (gnus-message 1 "No references in article %d"
6462 (gnus-summary-article-number))
6465 (gnus-summary-position-point)
6468 (defun gnus-summary-refer-references ()
6469 "Fetch all articles mentioned in the References header.
6470 Return the number of articles fetched."
6472 (let ((ref (mail-header-references (gnus-summary-article-header)))
6473 (current (gnus-summary-article-number))
6477 (error "No References in the current article")
6478 ;; For each Message-ID in the References header...
6479 (while (string-match "<[^>]*>" ref)
6481 ;; ... fetch that article.
6482 (gnus-summary-refer-article
6483 (prog1 (match-string 0 ref)
6484 (setq ref (substring ref (match-end 0))))))
6485 (gnus-summary-goto-subject current)
6486 (gnus-summary-position-point)
6489 (defun gnus-summary-refer-thread (&optional limit)
6490 "Fetch all articles in the current thread.
6491 If LIMIT (the numerical prefix), fetch that many old headers instead
6492 of what's specified by the `gnus-refer-thread-limit' variable."
6494 (let ((id (mail-header-id (gnus-summary-article-header)))
6495 (limit (if limit (prefix-numeric-value limit)
6496 gnus-refer-thread-limit)))
6497 ;; We want to fetch LIMIT *old* headers, but we also have to
6498 ;; re-fetch all the headers in the current buffer, because many of
6499 ;; them may be undisplayed. So we adjust LIMIT.
6500 (when (numberp limit)
6501 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6502 (unless (eq gnus-fetch-old-headers 'invisible)
6503 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6504 ;; Retrieve the headers and read them in.
6505 (if (eq (gnus-retrieve-headers
6506 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6508 (gnus-build-all-threads)
6509 (error "Can't fetch thread from backends that don't support NOV"))
6510 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6511 (gnus-summary-limit-include-thread id)))
6513 (defun gnus-summary-refer-article (message-id &optional arg)
6514 "Fetch an article specified by MESSAGE-ID.
6515 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6516 or `gnus-select-method', no matter what backend the article comes from."
6517 (interactive "sMessage-ID: \nP")
6518 (when (and (stringp message-id)
6519 (not (zerop (length message-id))))
6520 ;; Construct the correct Message-ID if necessary.
6521 ;; Suggested by tale@pawl.rpi.edu.
6522 (unless (string-match "^<" message-id)
6523 (setq message-id (concat "<" message-id)))
6524 (unless (string-match ">$" message-id)
6525 (setq message-id (concat message-id ">")))
6526 (let* ((header (gnus-id-to-header message-id))
6528 (gnus-summary-article-sparse-p
6529 (mail-header-number header))
6530 (memq (mail-header-number header)
6531 gnus-newsgroup-limit))))
6533 ;; If the article is present in the buffer we just go to it.
6535 (or (not (gnus-summary-article-sparse-p
6536 (mail-header-number header)))
6539 (gnus-summary-goto-article
6540 (mail-header-number header) nil t)
6542 (gnus-summary-update-article (mail-header-number header)))))
6544 ;; We fetch the article
6545 (let ((gnus-override-method
6546 (cond ((gnus-news-group-p gnus-newsgroup-name)
6547 gnus-refer-article-method)
6549 (or gnus-refer-article-method gnus-select-method))
6552 ;; Start the special refer-article method, if necessary.
6553 (when (and gnus-refer-article-method
6554 (gnus-news-group-p gnus-newsgroup-name))
6555 (gnus-check-server gnus-refer-article-method))
6556 ;; Fetch the header, and display the article.
6557 (if (setq number (gnus-summary-insert-subject message-id))
6558 (gnus-summary-select-article nil nil nil number)
6559 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6561 (defun gnus-summary-edit-parameters ()
6562 "Edit the group parameters of the current group."
6564 (gnus-group-edit-group gnus-newsgroup-name 'params))
6566 (defun gnus-summary-enter-digest-group (&optional force)
6567 "Enter an nndoc group based on the current article.
6568 If FORCE, force a digest interpretation. If not, try
6569 to guess what the document format is."
6571 (let ((conf gnus-current-window-configuration))
6573 (gnus-summary-select-article))
6574 (setq gnus-current-window-configuration conf)
6575 (let* ((name (format "%s-%d"
6576 (gnus-group-prefixed-name
6577 gnus-newsgroup-name (list 'nndoc ""))
6579 (set-buffer gnus-summary-buffer)
6580 gnus-current-article)))
6581 (ogroup gnus-newsgroup-name)
6582 (params (append (gnus-info-params (gnus-get-info ogroup))
6583 (list (cons 'to-group ogroup))
6584 (list (cons 'save-article-group ogroup))))
6585 (case-fold-search t)
6586 (buf (current-buffer))
6589 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6590 (insert-buffer-substring gnus-original-article-buffer)
6591 ;; Remove lines that may lead nndoc to misinterpret the
6594 (goto-char (point-min))
6595 (or (search-forward "\n\n" nil t) (point)))
6596 (goto-char (point-min))
6597 (delete-matching-lines "^\\(Path\\):\\|^From ")
6600 (if (gnus-group-read-ephemeral-group
6601 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6603 ,(if force 'digest 'guess))) t)
6604 ;; Make all postings to this group go to the parent group.
6605 (nconc (gnus-info-params (gnus-get-info name))
6607 ;; Couldn't select this doc group.
6608 (switch-to-buffer buf)
6609 (gnus-set-global-variables)
6610 (gnus-configure-windows 'summary)
6611 (gnus-message 3 "Article couldn't be entered?"))
6612 (kill-buffer dig)))))
6614 (defun gnus-summary-read-document (n)
6615 "Open a new group based on the current article(s).
6616 This will allow you to read digests and other similar
6617 documents as newsgroups.
6618 Obeys the standard process/prefix convention."
6620 (let* ((articles (gnus-summary-work-articles n))
6621 (ogroup gnus-newsgroup-name)
6622 (params (append (gnus-info-params (gnus-get-info ogroup))
6623 (list (cons 'to-group ogroup))))
6624 article group egroup groups vgroup)
6625 (while (setq article (pop articles))
6626 (setq group (format "%s-%d" gnus-newsgroup-name article))
6627 (gnus-summary-remove-process-mark article)
6628 (when (gnus-summary-display-article article)
6631 (insert-buffer-substring gnus-original-article-buffer)
6632 ;; Remove some headers that may lead nndoc to make
6634 (message-narrow-to-head)
6635 (goto-char (point-min))
6636 (delete-matching-lines "^\\(Path\\):\\|^From ")
6639 (gnus-group-read-ephemeral-group
6640 group `(nndoc ,group (nndoc-address ,(current-buffer))
6641 (nndoc-article-type guess))
6644 ;; Make all postings to this group go to the parent group.
6645 (nconc (gnus-info-params (gnus-get-info egroup))
6647 (push egroup groups))
6648 ;; Couldn't select this doc group.
6649 (gnus-error 3 "Article couldn't be entered"))))))
6650 ;; Now we have selected all the documents.
6653 (error "None of the articles could be interpreted as documents"))
6654 ((gnus-group-read-ephemeral-group
6655 (setq vgroup (format
6656 "nnvirtual:%s-%s" gnus-newsgroup-name
6657 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6658 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6660 (cons (current-buffer) 'summary)))
6662 (error "Couldn't select virtual nndoc group")))))
6664 (defun gnus-summary-isearch-article (&optional regexp-p)
6665 "Do incremental search forward on the current article.
6666 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6668 (gnus-summary-select-article)
6669 (gnus-configure-windows 'article)
6670 (gnus-eval-in-buffer-window gnus-article-buffer
6673 (isearch-forward regexp-p))))
6675 (defun gnus-summary-search-article-forward (regexp &optional backward)
6676 "Search for an article containing REGEXP forward.
6677 If BACKWARD, search backward instead."
6680 (format "Search article %s (regexp%s): "
6681 (if current-prefix-arg "backward" "forward")
6682 (if gnus-last-search-regexp
6683 (concat ", default " gnus-last-search-regexp)
6685 current-prefix-arg))
6686 (if (string-equal regexp "")
6687 (setq regexp (or gnus-last-search-regexp ""))
6688 (setq gnus-last-search-regexp regexp))
6689 (if (gnus-summary-search-article regexp backward)
6690 (gnus-summary-show-thread)
6691 (error "Search failed: \"%s\"" regexp)))
6693 (defun gnus-summary-search-article-backward (regexp)
6694 "Search for an article containing REGEXP backward."
6697 (format "Search article backward (regexp%s): "
6698 (if gnus-last-search-regexp
6699 (concat ", default " gnus-last-search-regexp)
6701 (gnus-summary-search-article-forward regexp 'backward))
6703 (defun gnus-summary-search-article (regexp &optional backward)
6704 "Search for an article containing REGEXP.
6705 Optional argument BACKWARD means do search for backward.
6706 `gnus-select-article-hook' is not called during the search."
6707 ;; We have to require this here to make sure that the following
6708 ;; dynamic binding isn't shadowed by autoloading.
6709 (require 'gnus-async)
6711 (let ((gnus-select-article-hook nil) ;Disable hook.
6712 (gnus-article-display-hook nil)
6713 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6714 (gnus-use-article-prefetch nil)
6715 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6716 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6717 (sum (current-buffer))
6720 (gnus-save-hidden-threads
6721 (gnus-summary-select-article)
6722 (set-buffer gnus-article-buffer)
6726 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6728 (re-search-backward regexp nil t)
6729 (re-search-forward regexp nil t))
6730 ;; We found the regexp.
6735 (get-buffer-window (current-buffer))
6739 (setq point (point)))
6740 ;; We didn't find it, so we go to the next article.
6743 (while (eq found 'not)
6744 (if (not (if backward (gnus-summary-find-prev)
6745 (gnus-summary-find-next)))
6746 ;; No more articles.
6748 ;; Select the next article and adjust point.
6749 (unless (gnus-summary-article-sparse-p
6750 (gnus-summary-article-number))
6752 (gnus-summary-select-article)
6753 (set-buffer gnus-article-buffer)
6755 (goto-char (if backward (point-max) (point-min))))))))
6756 (gnus-message 7 ""))
6757 ;; Return whether we found the regexp.
6758 (when (eq found 'found)
6760 (gnus-summary-show-thread)
6761 (gnus-summary-goto-subject gnus-current-article)
6762 (gnus-summary-position-point)
6765 (defun gnus-summary-find-matching (header regexp &optional backward unread
6767 "Return a list of all articles that match REGEXP on HEADER.
6768 The search stars on the current article and goes forwards unless
6769 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6770 If UNREAD is non-nil, only unread articles will
6771 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6772 in the comparisons."
6773 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6774 (gnus-data-find-list
6775 (gnus-summary-article-number) (gnus-data-list backward))))
6776 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6777 (case-fold-search (not not-case-fold))
6779 (unless (fboundp (intern (concat "mail-header-" header)))
6780 (error "%s is not a valid header" header))
6783 (and (or (not unread) ; We want all articles...
6784 (gnus-data-unread-p d)) ; Or just unreads.
6785 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6786 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6787 (push (gnus-data-number d) articles)) ; Success!
6788 (setq data (cdr data)))
6789 (nreverse articles)))
6791 (defun gnus-summary-execute-command (header regexp command &optional backward)
6792 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6793 If HEADER is an empty string (or nil), the match is done on the entire
6794 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6796 (list (let ((completion-ignore-case t))
6799 (mapcar (lambda (string) (list string))
6800 '("Number" "Subject" "From" "Lines" "Date"
6801 "Message-ID" "Xref" "References" "Body"))
6802 nil 'require-match))
6803 (read-string "Regexp: ")
6804 (read-key-sequence "Command: ")
6805 current-prefix-arg))
6806 (when (equal header "Body")
6808 ;; Hidden thread subtrees must be searched as well.
6809 (gnus-summary-show-all-threads)
6810 ;; We don't want to change current point nor window configuration.
6812 (save-window-excursion
6813 (gnus-message 6 "Executing %s..." (key-description command))
6814 ;; We'd like to execute COMMAND interactively so as to give arguments.
6815 (gnus-execute header regexp
6816 `(call-interactively ',(key-binding command))
6818 (gnus-message 6 "Executing %s...done" (key-description command)))))
6820 (defun gnus-summary-beginning-of-article ()
6821 "Scroll the article back to the beginning."
6823 (gnus-summary-select-article)
6824 (gnus-configure-windows 'article)
6825 (gnus-eval-in-buffer-window gnus-article-buffer
6827 (goto-char (point-min))
6828 (when gnus-page-broken
6829 (gnus-narrow-to-page))))
6831 (defun gnus-summary-end-of-article ()
6832 "Scroll to the end of the article."
6834 (gnus-summary-select-article)
6835 (gnus-configure-windows 'article)
6836 (gnus-eval-in-buffer-window gnus-article-buffer
6838 (goto-char (point-max))
6840 (when gnus-page-broken
6841 (gnus-narrow-to-page))))
6843 (defun gnus-summary-print-article (&optional filename n)
6844 "Generate and print a PostScript image of the N next (mail) articles.
6846 If N is negative, print the N previous articles. If N is nil and articles
6847 have been marked with the process mark, print these instead.
6849 If the optional second argument FILENAME is nil, send the image to the
6850 printer. If FILENAME is a string, save the PostScript image in a file with
6851 that name. If FILENAME is a number, prompt the user for the name of the file
6853 (interactive (list (ps-print-preprint current-prefix-arg)
6854 current-prefix-arg))
6855 (dolist (article (gnus-summary-work-articles n))
6856 (gnus-summary-select-article nil nil 'pseudo article)
6857 (gnus-eval-in-buffer-window gnus-article-buffer
6858 (let ((buffer (generate-new-buffer " *print*")))
6861 (copy-to-buffer buffer (point-min) (point-max))
6863 (gnus-article-delete-invisible-text)
6864 (let ((ps-left-header
6867 (mail-header-subject gnus-current-headers) ")")
6869 (mail-header-from gnus-current-headers) ")")))
6872 "/pagenumberstring load"
6874 (mail-header-date gnus-current-headers) ")"))))
6875 (gnus-run-hooks 'gnus-ps-print-hook)
6877 (ps-print-buffer-with-faces filename))))
6878 (kill-buffer buffer))))))
6880 (defun gnus-summary-show-article (&optional arg)
6881 "Force re-fetching of the current article.
6882 If ARG (the prefix) is non-nil, show the raw article without any
6883 article massaging functions being run."
6886 ;; Select the article the normal way.
6887 (gnus-summary-select-article nil 'force)
6888 ;; Bind the article treatment functions to nil.
6889 (let ((gnus-have-all-headers t)
6890 gnus-article-display-hook
6891 gnus-article-prepare-hook
6892 gnus-article-decode-hook
6896 (gnus-summary-select-article nil 'force)))
6897 (gnus-summary-goto-subject gnus-current-article)
6898 (gnus-summary-position-point))
6900 (defun gnus-summary-verbose-headers (&optional arg)
6901 "Toggle permanent full header display.
6902 If ARG is a positive number, turn header display on.
6903 If ARG is a negative number, turn header display off."
6905 (setq gnus-show-all-headers
6906 (cond ((or (not (numberp arg))
6908 (not gnus-show-all-headers))
6911 (gnus-summary-show-article))
6913 (defun gnus-summary-toggle-header (&optional arg)
6914 "Show the headers if they are hidden, or hide them if they are shown.
6915 If ARG is a positive number, show the entire header.
6916 If ARG is a negative number, hide the unwanted header lines."
6919 (set-buffer gnus-article-buffer)
6920 (let* ((buffer-read-only nil)
6921 (inhibit-point-motion-hooks t)
6922 (hidden (text-property-any
6923 (goto-char (point-min)) (search-forward "\n\n")
6926 (goto-char (point-min))
6927 (when (search-forward "\n\n" nil t)
6928 (delete-region (point-min) (1- (point))))
6929 (goto-char (point-min))
6931 (set-buffer gnus-original-article-buffer)
6932 (goto-char (point-min))
6933 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6934 (insert-buffer-substring gnus-original-article-buffer 1 e)
6935 (let ((article-inhibit-hiding t))
6936 (gnus-run-hooks 'gnus-article-display-hook))
6937 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6938 (gnus-article-hide-headers)))))
6940 (defun gnus-summary-show-all-headers ()
6941 "Make all header lines visible."
6943 (gnus-article-show-all-headers))
6945 (defun gnus-summary-toggle-mime (&optional arg)
6946 "Toggle MIME processing.
6947 If ARG is a positive number, turn MIME processing on."
6949 (setq gnus-show-mime
6950 (if (null arg) (not gnus-show-mime)
6951 (> (prefix-numeric-value arg) 0)))
6952 (gnus-summary-select-article t 'force))
6954 (defun gnus-summary-caesar-message (&optional arg)
6955 "Caesar rotate the current article by 13.
6956 The numerical prefix specifies how many places to rotate each letter
6959 (gnus-summary-select-article)
6960 (let ((mail-header-separator ""))
6961 (gnus-eval-in-buffer-window gnus-article-buffer
6964 (let ((start (window-start))
6966 (message-caesar-buffer-body arg)
6967 (set-window-start (get-buffer-window (current-buffer)) start))))))
6969 (defun gnus-summary-stop-page-breaking ()
6970 "Stop page breaking in the current article."
6972 (gnus-summary-select-article)
6973 (gnus-eval-in-buffer-window gnus-article-buffer
6975 (when (gnus-visual-p 'page-marker)
6976 (let ((buffer-read-only nil))
6977 (gnus-remove-text-with-property 'gnus-prev)
6978 (gnus-remove-text-with-property 'gnus-next))
6979 (setq gnus-page-broken nil))))
6981 (defun gnus-summary-move-article (&optional n to-newsgroup
6982 select-method action)
6983 "Move the current article to a different newsgroup.
6984 If N is a positive number, move the N next articles.
6985 If N is a negative number, move the N previous articles.
6986 If N is nil and any articles have been marked with the process mark,
6987 move those articles instead.
6988 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6989 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6990 re-spool using this method.
6992 For this function to work, both the current newsgroup and the
6993 newsgroup that you want to move to have to support the `request-move'
6994 and `request-accept' functions."
6997 (setq action 'move))
6998 ;; Disable marking as read.
6999 (let (gnus-mark-article-hook)
7000 (save-window-excursion
7001 (gnus-summary-select-article)))
7002 ;; Check whether the source group supports the required functions.
7003 (cond ((and (eq action 'move)
7004 (not (gnus-check-backend-function
7005 'request-move-article gnus-newsgroup-name)))
7006 (error "The current group does not support article moving"))
7007 ((and (eq action 'crosspost)
7008 (not (gnus-check-backend-function
7009 'request-replace-article gnus-newsgroup-name)))
7010 (error "The current group does not support article editing")))
7011 (let ((articles (gnus-summary-work-articles n))
7012 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7013 (names '((move "Move" "Moving")
7014 (copy "Copy" "Copying")
7015 (crosspost "Crosspost" "Crossposting")))
7016 (copy-buf (save-excursion
7017 (nnheader-set-temp-buffer " *copy article*")))
7018 art-group to-method new-xref article to-groups)
7019 (unless (assq action names)
7020 (error "Unknown action %s" action))
7021 ;; Read the newsgroup name.
7022 (when (and (not to-newsgroup)
7023 (not select-method))
7025 (gnus-read-move-group-name
7026 (cadr (assq action names))
7027 (symbol-value (intern (format "gnus-current-%s-group" action)))
7029 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7030 (setq to-method (or select-method
7031 (gnus-group-name-to-method to-newsgroup)))
7032 ;; Check the method we are to move this article to...
7033 (unless (gnus-check-backend-function
7034 'request-accept-article (car to-method))
7035 (error "%s does not support article copying" (car to-method)))
7036 (unless (gnus-check-server to-method)
7037 (error "Can't open server %s" (car to-method)))
7038 (gnus-message 6 "%s to %s: %s..."
7039 (caddr (assq action names))
7040 (or (car select-method) to-newsgroup) articles)
7042 (setq article (pop articles))
7046 ;; Move the article.
7048 ;; Remove this article from future suppression.
7049 (gnus-dup-unsuppress-article article)
7050 (gnus-request-move-article
7051 article ; Article to move
7052 gnus-newsgroup-name ; From newsgroup
7053 (nth 1 (gnus-find-method-for-group
7054 gnus-newsgroup-name)) ; Server
7055 (list 'gnus-request-accept-article
7056 to-newsgroup (list 'quote select-method)
7057 (not articles) t) ; Accept form
7058 (not articles))) ; Only save nov last time
7059 ;; Copy the article.
7062 (set-buffer copy-buf)
7063 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7064 (gnus-request-accept-article
7065 to-newsgroup select-method (not articles) t))))
7066 ;; Crosspost the article.
7067 ((eq action 'crosspost)
7068 (let ((xref (message-tokenize-header
7069 (mail-header-xref (gnus-summary-article-header article))
7071 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7074 (setq xref (list (system-name))))
7077 (mapconcat 'identity
7078 (delete "Xref:" (delete new-xref xref))
7082 (set-buffer copy-buf)
7083 ;; First put the article in the destination group.
7084 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7085 (when (consp (setq art-group
7086 (gnus-request-accept-article
7087 to-newsgroup select-method (not articles))))
7088 (setq new-xref (concat new-xref " " (car art-group)
7089 ":" (cdr art-group)))
7090 ;; Now we have the new Xrefs header, so we insert
7091 ;; it and replace the new article.
7092 (nnheader-replace-header "Xref" new-xref)
7093 (gnus-request-replace-article
7094 (cdr art-group) to-newsgroup (current-buffer))
7098 (gnus-message 1 "Couldn't %s article %s"
7099 (cadr (assq action names)) article))
7100 ((and (eq art-group 'junk)
7102 (gnus-summary-mark-article article gnus-canceled-mark)
7103 (gnus-message 4 "Deleted article %s" article))
7105 (let* ((pto-group (gnus-group-prefixed-name
7106 (car art-group) to-method))
7108 (gnus-gethash pto-group gnus-newsrc-hashtb))
7109 (info (nth 2 entry))
7110 (to-group (gnus-info-group info)))
7111 ;; Update the group that has been moved to.
7113 (memq action '(move copy)))
7114 (unless (member to-group to-groups)
7115 (push to-group to-groups))
7117 (unless (memq article gnus-newsgroup-unreads)
7119 info (gnus-add-to-range (gnus-info-read info)
7120 (list (cdr art-group)))))
7122 ;; Copy any marks over to the new group.
7123 (let ((marks gnus-article-mark-lists)
7124 (to-article (cdr art-group)))
7126 ;; See whether the article is to be put in the cache.
7127 (when gnus-use-cache
7128 (gnus-cache-possibly-enter-article
7130 (let ((header (copy-sequence
7131 (gnus-summary-article-header article))))
7132 (mail-header-set-number header to-article)
7134 (memq article gnus-newsgroup-marked)
7135 (memq article gnus-newsgroup-dormant)
7136 (memq article gnus-newsgroup-unreads)))
7138 (when (and (equal to-group gnus-newsgroup-name)
7139 (not (memq article gnus-newsgroup-unreads)))
7140 ;; Mark this article as read in this group.
7141 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7142 (setcdr (gnus-active to-group) to-article)
7143 (setcdr gnus-newsgroup-active to-article))
7146 (when (memq article (symbol-value
7147 (intern (format "gnus-newsgroup-%s"
7149 ;; If the other group is the same as this group,
7150 ;; then we have to add the mark to the list.
7151 (when (equal to-group gnus-newsgroup-name)
7152 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7155 (intern (format "gnus-newsgroup-%s"
7157 ;; Copy the marks to other group.
7158 (gnus-add-marked-articles
7159 to-group (cdar marks) (list to-article) info))
7160 (setq marks (cdr marks)))
7163 (concat "(gnus-group-set-info '"
7164 (gnus-prin1-to-string (gnus-get-info to-group))
7167 ;; Update the Xref header in this article to point to
7168 ;; the new crossposted article we have just created.
7169 (when (eq action 'crosspost)
7171 (set-buffer copy-buf)
7172 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7173 (nnheader-replace-header "Xref" new-xref)
7174 (gnus-request-replace-article
7175 article gnus-newsgroup-name (current-buffer)))))
7177 ;;;!!!Why is this necessary?
7178 (set-buffer gnus-summary-buffer)
7180 (gnus-summary-goto-subject article)
7181 (when (eq action 'move)
7182 (gnus-summary-mark-article article gnus-canceled-mark))))
7183 (gnus-summary-remove-process-mark article))
7184 ;; Re-activate all groups that have been moved to.
7187 (set-buffer gnus-group-buffer)
7188 (when (gnus-group-goto-group (car to-groups) t)
7189 (gnus-group-get-new-news-this-group 1 t))
7192 (gnus-kill-buffer copy-buf)
7193 (gnus-summary-position-point)
7194 (gnus-set-mode-line 'summary)))
7196 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7197 "Move the current article to a different newsgroup.
7198 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7199 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7200 re-spool using this method."
7202 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7204 (defun gnus-summary-crosspost-article (&optional n)
7205 "Crosspost the current article to some other group."
7207 (gnus-summary-move-article n nil nil 'crosspost))
7209 (defcustom gnus-summary-respool-default-method nil
7210 "Default method for respooling an article.
7211 If nil, use to the current newsgroup method."
7212 :type '(choice (gnus-select-method :value (nnml ""))
7214 :group 'gnus-summary-mail)
7216 (defun gnus-summary-respool-article (&optional n method)
7217 "Respool the current article.
7218 The article will be squeezed through the mail spooling process again,
7219 which means that it will be put in some mail newsgroup or other
7220 depending on `nnmail-split-methods'.
7221 If N is a positive number, respool the N next articles.
7222 If N is a negative number, respool the N previous articles.
7223 If N is nil and any articles have been marked with the process mark,
7224 respool those articles instead.
7226 Respooling can be done both from mail groups and \"real\" newsgroups.
7227 In the former case, the articles in question will be moved from the
7228 current group into whatever groups they are destined to. In the
7229 latter case, they will be copied into the relevant groups."
7231 (list current-prefix-arg
7232 (let* ((methods (gnus-methods-using 'respool))
7234 (symbol-name (or gnus-summary-respool-default-method
7235 (car (gnus-find-method-for-group
7236 gnus-newsgroup-name)))))
7238 (gnus-completing-read
7239 methname "What backend do you want to use when respooling?"
7240 methods nil t nil 'gnus-mail-method-history))
7243 ((zerop (length (setq ms (gnus-servers-using-backend
7245 (list (intern method) ""))
7249 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7250 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7253 (error "No method given for respooling"))
7254 (if (assoc (symbol-name
7255 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7256 (gnus-methods-using 'respool))
7257 (gnus-summary-move-article n nil method)
7258 (gnus-summary-copy-article n nil method)))
7260 (defun gnus-summary-import-article (file)
7261 "Import an arbitrary file into a mail newsgroup."
7262 (interactive "fImport file: ")
7263 (let ((group gnus-newsgroup-name)
7264 (now (current-time))
7266 (unless (gnus-check-backend-function 'request-accept-article group)
7267 (error "%s does not support article importing" group))
7268 (or (file-readable-p file)
7269 (not (file-regular-p file))
7270 (error "Can't read %s" file))
7272 (set-buffer (gnus-get-buffer-create " *import file*"))
7274 (nnheader-insert-file-contents file)
7275 (goto-char (point-min))
7276 (unless (nnheader-article-p)
7277 ;; This doesn't look like an article, so we fudge some headers.
7278 (setq atts (file-attributes file)
7279 lines (count-lines (point-min) (point-max)))
7280 (insert "From: " (read-string "From: ") "\n"
7281 "Subject: " (read-string "Subject: ") "\n"
7282 "Date: " (message-make-date (nth 5 atts))
7284 "Message-ID: " (message-make-message-id) "\n"
7285 "Lines: " (int-to-string lines) "\n"
7286 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7287 (gnus-request-accept-article group nil t)
7288 (kill-buffer (current-buffer)))))
7290 (defun gnus-summary-article-posted-p ()
7291 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7292 This will be the case if the article has both been mailed and posted."
7294 (let ((id (mail-header-references (gnus-summary-article-header)))
7295 (gnus-override-method
7296 (or gnus-refer-article-method gnus-select-method)))
7297 (if (gnus-request-head id "")
7298 (gnus-message 2 "The current message was found on %s"
7299 gnus-override-method)
7300 (gnus-message 2 "The current message couldn't be found on %s"
7301 gnus-override-method)
7304 (defun gnus-summary-expire-articles (&optional now)
7305 "Expire all articles that are marked as expirable in the current group."
7307 (when (gnus-check-backend-function
7308 'request-expire-articles gnus-newsgroup-name)
7309 ;; This backend supports expiry.
7310 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7311 (expirable (if total
7313 ;; We need to update the info for
7314 ;; this group for `gnus-list-of-read-articles'
7315 ;; to give us the right answer.
7316 (gnus-run-hooks 'gnus-exit-group-hook)
7317 (gnus-summary-update-info)
7318 (gnus-list-of-read-articles gnus-newsgroup-name))
7319 (setq gnus-newsgroup-expirable
7320 (sort gnus-newsgroup-expirable '<))))
7321 (expiry-wait (if now 'immediate
7322 (gnus-group-find-parameter
7323 gnus-newsgroup-name 'expiry-wait)))
7326 ;; There are expirable articles in this group, so we run them
7327 ;; through the expiry process.
7328 (gnus-message 6 "Expiring articles...")
7329 ;; The list of articles that weren't expired is returned.
7332 (let ((nnmail-expiry-wait-function nil)
7333 (nnmail-expiry-wait expiry-wait))
7334 (setq es (gnus-request-expire-articles
7335 expirable gnus-newsgroup-name)))
7336 (setq es (gnus-request-expire-articles
7337 expirable gnus-newsgroup-name))))
7339 (setq gnus-newsgroup-expirable es))
7340 ;; We go through the old list of expirable, and mark all
7341 ;; really expired articles as nonexistent.
7342 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7343 (let ((gnus-use-cache nil))
7345 (unless (memq (car expirable) es)
7346 (when (gnus-data-find (car expirable))
7347 (gnus-summary-mark-article
7348 (car expirable) gnus-canceled-mark)))
7349 (setq expirable (cdr expirable)))))
7350 (gnus-message 6 "Expiring articles...done")))))
7352 (defun gnus-summary-expire-articles-now ()
7353 "Expunge all expirable articles in the current group.
7354 This means that *all* articles that are marked as expirable will be
7355 deleted forever, right now."
7357 (or gnus-expert-user
7359 "Are you really, really, really sure you want to delete all these messages? ")
7361 (gnus-summary-expire-articles t))
7363 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7364 (defun gnus-summary-delete-article (&optional n)
7365 "Delete the N next (mail) articles.
7366 This command actually deletes articles. This is not a marking
7367 command. The article will disappear forever from your life, never to
7369 If N is negative, delete backwards.
7370 If N is nil and articles have been marked with the process mark,
7371 delete these instead."
7373 (unless (gnus-check-backend-function 'request-expire-articles
7374 gnus-newsgroup-name)
7375 (error "The current newsgroup does not support article deletion"))
7376 ;; Compute the list of articles to delete.
7377 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7379 (if (and gnus-novice-user
7380 (not (gnus-yes-or-no-p
7381 (format "Do you really want to delete %s forever? "
7382 (if (> (length articles) 1)
7383 (format "these %s articles" (length articles))
7386 ;; Delete the articles.
7387 (setq not-deleted (gnus-request-expire-articles
7388 articles gnus-newsgroup-name 'force))
7390 (gnus-summary-remove-process-mark (car articles))
7391 ;; The backend might not have been able to delete the article
7393 (unless (memq (car articles) not-deleted)
7394 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7395 (setq articles (cdr articles)))
7397 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7398 (gnus-summary-position-point)
7399 (gnus-set-mode-line 'summary)
7402 (defun gnus-summary-edit-article (&optional force)
7403 "Edit the current article.
7404 This will have permanent effect only in mail groups.
7405 If FORCE is non-nil, allow editing of articles even in read-only
7409 (set-buffer gnus-summary-buffer)
7410 (gnus-set-global-variables)
7411 (when (and (not force)
7412 (gnus-group-read-only-p))
7413 (error "The current newsgroup does not support article editing"))
7414 ;; Select article if needed.
7415 (unless (eq (gnus-summary-article-number)
7416 gnus-current-article)
7417 (gnus-summary-select-article t))
7418 (gnus-article-date-original)
7419 (gnus-article-edit-article
7420 `(lambda (no-highlight)
7421 (gnus-summary-edit-article-done
7422 ,(or (mail-header-references gnus-current-headers) "")
7423 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7425 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7427 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7429 "Make edits to the current article permanent."
7431 ;; Replace the article.
7432 (let ((buf (current-buffer)))
7435 (if (and (not read-only)
7436 (not (gnus-request-replace-article
7437 (cdr gnus-article-current) (car gnus-article-current)
7439 (error "Couldn't replace article")
7440 ;; Update the summary buffer.
7442 (equal (message-tokenize-header references " ")
7443 (message-tokenize-header
7444 (or (message-fetch-field "references") "") " ")))
7445 ;; We only have to update this line.
7448 (message-narrow-to-head)
7449 (let ((head (buffer-string))
7452 (insert (format "211 %d Article retrieved.\n"
7453 (cdr gnus-article-current)))
7456 (let ((nntp-server-buffer (current-buffer)))
7457 (setq header (car (gnus-get-newsgroup-headers
7459 (set-buffer gnus-summary-buffer)
7460 gnus-newsgroup-dependencies)
7463 (set-buffer gnus-summary-buffer)
7464 (gnus-data-set-header
7465 (gnus-data-find (cdr gnus-article-current))
7467 (gnus-summary-update-article-line
7468 (cdr gnus-article-current) header))))))
7470 (set-buffer (or buffer gnus-summary-buffer))
7471 (gnus-summary-update-article (cdr gnus-article-current)))
7472 ;; Prettify the article buffer again.
7473 (unless no-highlight
7475 (set-buffer gnus-article-buffer)
7476 (gnus-run-hooks 'gnus-article-display-hook)
7477 (set-buffer gnus-original-article-buffer)
7478 (gnus-request-article
7479 (cdr gnus-article-current)
7480 (car gnus-article-current) (current-buffer))))
7481 ;; Prettify the summary buffer line.
7482 (when (gnus-visual-p 'summary-highlight 'highlight)
7483 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7485 (defun gnus-summary-edit-wash (key)
7486 "Perform editing command KEY in the article buffer."
7490 (message "%s" (concat (this-command-keys) "- "))
7493 (gnus-summary-edit-article)
7494 (execute-kbd-macro (concat (this-command-keys) key))
7495 (gnus-article-edit-done))
7499 (defun gnus-summary-respool-query (&optional silent trace)
7500 "Query where the respool algorithm would put this article."
7502 (let (gnus-mark-article-hook)
7503 (gnus-summary-select-article)
7505 (set-buffer gnus-original-article-buffer)
7507 (message-narrow-to-head)
7508 (let ((groups (nnmail-article-group 'identity trace)))
7511 (message "This message would go to %s"
7512 (mapconcat 'car groups ", "))
7513 (message "This message would go to no groups"))
7516 (defun gnus-summary-respool-trace ()
7517 "Trace where the respool algorithm would put this article.
7518 Display a buffer showing all fancy splitting patterns which matched."
7520 (gnus-summary-respool-query nil t))
7522 ;; Summary marking commands.
7524 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7525 "Mark articles which has the same subject as read, and then select the next.
7526 If UNMARK is positive, remove any kind of mark.
7527 If UNMARK is negative, tick articles."
7530 (setq unmark (prefix-numeric-value unmark)))
7532 (gnus-summary-mark-same-subject
7533 (gnus-summary-article-subject) unmark)))
7534 ;; Select next unread article. If auto-select-same mode, should
7535 ;; select the first unread article.
7536 (gnus-summary-next-article t (and gnus-auto-select-same
7537 (gnus-summary-article-subject)))
7538 (gnus-message 7 "%d article%s marked as %s"
7539 count (if (= count 1) " is" "s are")
7540 (if unmark "unread" "read"))))
7542 (defun gnus-summary-kill-same-subject (&optional unmark)
7543 "Mark articles which has the same subject as read.
7544 If UNMARK is positive, remove any kind of mark.
7545 If UNMARK is negative, tick articles."
7548 (setq unmark (prefix-numeric-value unmark)))
7550 (gnus-summary-mark-same-subject
7551 (gnus-summary-article-subject) unmark)))
7552 ;; If marked as read, go to next unread subject.
7554 ;; Go to next unread subject.
7555 (gnus-summary-next-subject 1 t))
7556 (gnus-message 7 "%d articles are marked as %s"
7557 count (if unmark "unread" "read"))))
7559 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7560 "Mark articles with same SUBJECT as read, and return marked number.
7561 If optional argument UNMARK is positive, remove any kinds of marks.
7562 If optional argument UNMARK is negative, mark articles as unread instead."
7566 ((null unmark) ; Mark as read.
7569 (gnus-summary-mark-article-as-read gnus-killed-mark)
7570 (gnus-summary-show-thread) t)
7571 (gnus-summary-find-subject subject))
7572 (setq count (1+ count))))
7573 ((> unmark 0) ; Tick.
7576 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7577 (gnus-summary-show-thread) t)
7578 (gnus-summary-find-subject subject))
7579 (setq count (1+ count))))
7580 (t ; Mark as unread.
7583 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7584 (gnus-summary-show-thread) t)
7585 (gnus-summary-find-subject subject))
7586 (setq count (1+ count)))))
7587 (gnus-set-mode-line 'summary)
7588 ;; Return the number of marked articles.
7591 (defun gnus-summary-mark-as-processable (n &optional unmark)
7592 "Set the process mark on the next N articles.
7593 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7594 the process mark instead. The difference between N and the actual
7595 number of articles marked is returned."
7597 (let ((backward (< n 0))
7602 (gnus-summary-remove-process-mark
7603 (gnus-summary-article-number))
7604 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7605 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7608 (gnus-message 7 "No more articles"))
7609 (gnus-summary-recenter)
7610 (gnus-summary-position-point)
7613 (defun gnus-summary-unmark-as-processable (n)
7614 "Remove the process mark from the next N articles.
7615 If N is negative, unmark backward instead. The difference between N and
7616 the actual number of articles unmarked is returned."
7618 (gnus-summary-mark-as-processable n t))
7620 (defun gnus-summary-unmark-all-processable ()
7621 "Remove the process mark from all articles."
7624 (while gnus-newsgroup-processable
7625 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7626 (gnus-summary-position-point))
7628 (defun gnus-summary-mark-as-expirable (n)
7629 "Mark N articles forward as expirable.
7630 If N is negative, mark backward instead. The difference between N and
7631 the actual number of articles marked is returned."
7633 (gnus-summary-mark-forward n gnus-expirable-mark))
7635 (defun gnus-summary-mark-article-as-replied (article)
7636 "Mark ARTICLE replied and update the summary line."
7637 (push article gnus-newsgroup-replied)
7638 (let ((buffer-read-only nil))
7639 (when (gnus-summary-goto-subject article nil t)
7640 (gnus-summary-update-secondary-mark article))))
7642 (defun gnus-summary-set-bookmark (article)
7643 "Set a bookmark in current article."
7644 (interactive (list (gnus-summary-article-number)))
7645 (when (or (not (get-buffer gnus-article-buffer))
7646 (not gnus-current-article)
7647 (not gnus-article-current)
7648 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7649 (error "No current article selected"))
7650 ;; Remove old bookmark, if one exists.
7651 (let ((old (assq article gnus-newsgroup-bookmarks)))
7653 (setq gnus-newsgroup-bookmarks
7654 (delq old gnus-newsgroup-bookmarks))))
7655 ;; Set the new bookmark, which is on the form
7656 ;; (article-number . line-number-in-body).
7660 (set-buffer gnus-article-buffer)
7664 (goto-char (point-min))
7665 (search-forward "\n\n" nil t)
7668 gnus-newsgroup-bookmarks)
7669 (gnus-message 6 "A bookmark has been added to the current article."))
7671 (defun gnus-summary-remove-bookmark (article)
7672 "Remove the bookmark from the current article."
7673 (interactive (list (gnus-summary-article-number)))
7674 ;; Remove old bookmark, if one exists.
7675 (let ((old (assq article gnus-newsgroup-bookmarks)))
7678 (setq gnus-newsgroup-bookmarks
7679 (delq old gnus-newsgroup-bookmarks))
7680 (gnus-message 6 "Removed bookmark."))
7681 (gnus-message 6 "No bookmark in current article."))))
7683 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7684 (defun gnus-summary-mark-as-dormant (n)
7685 "Mark N articles forward as dormant.
7686 If N is negative, mark backward instead. The difference between N and
7687 the actual number of articles marked is returned."
7689 (gnus-summary-mark-forward n gnus-dormant-mark))
7691 (defun gnus-summary-set-process-mark (article)
7692 "Set the process mark on ARTICLE and update the summary line."
7693 (setq gnus-newsgroup-processable
7695 (delq article gnus-newsgroup-processable)))
7696 (when (gnus-summary-goto-subject article)
7697 (gnus-summary-show-thread)
7698 (gnus-summary-goto-subject article)
7699 (gnus-summary-update-secondary-mark article)))
7701 (defun gnus-summary-remove-process-mark (article)
7702 "Remove the process mark from ARTICLE and update the summary line."
7703 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7704 (when (gnus-summary-goto-subject article)
7705 (gnus-summary-show-thread)
7706 (gnus-summary-goto-subject article)
7707 (gnus-summary-update-secondary-mark article)))
7709 (defun gnus-summary-set-saved-mark (article)
7710 "Set the process mark on ARTICLE and update the summary line."
7711 (push article gnus-newsgroup-saved)
7712 (when (gnus-summary-goto-subject article)
7713 (gnus-summary-update-secondary-mark article)))
7715 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7716 "Mark N articles as read forwards.
7717 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7718 The difference between N and the actual number of articles marked is
7721 (gnus-summary-show-thread)
7722 (let ((backward (< n 0))
7723 (gnus-summary-goto-unread
7724 (and gnus-summary-goto-unread
7725 (not (eq gnus-summary-goto-unread 'never))
7726 (not (memq mark (list gnus-unread-mark
7727 gnus-ticked-mark gnus-dormant-mark)))))
7729 (mark (or mark gnus-del-mark)))
7731 (gnus-summary-mark-article nil mark no-expire)
7732 (zerop (gnus-summary-next-subject
7734 (and gnus-summary-goto-unread
7735 (not (eq gnus-summary-goto-unread 'never)))
7739 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7740 (gnus-summary-recenter)
7741 (gnus-summary-position-point)
7742 (gnus-set-mode-line 'summary)
7745 (defun gnus-summary-mark-article-as-read (mark)
7746 "Mark the current article quickly as read with MARK."
7747 (let ((article (gnus-summary-article-number)))
7748 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7749 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7750 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7751 (push (cons article mark) gnus-newsgroup-reads)
7752 ;; Possibly remove from cache, if that is used.
7753 (when gnus-use-cache
7754 (gnus-cache-enter-remove-article article))
7755 ;; Allow the backend to change the mark.
7756 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7757 ;; Check for auto-expiry.
7758 (when (and gnus-newsgroup-auto-expire
7759 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7760 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7761 (= mark gnus-ancient-mark)
7762 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7763 (= mark gnus-duplicate-mark)))
7764 (setq mark gnus-expirable-mark)
7765 ;; Let the backend know about the mark change.
7766 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7767 (push article gnus-newsgroup-expirable))
7768 ;; Set the mark in the buffer.
7769 (gnus-summary-update-mark mark 'unread)
7772 (defun gnus-summary-mark-article-as-unread (mark)
7773 "Mark the current article quickly as unread with MARK."
7774 (let* ((article (gnus-summary-article-number))
7775 (old-mark (gnus-summary-article-mark article)))
7776 ;; Allow the backend to change the mark.
7777 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7778 (if (eq mark old-mark)
7782 (gnus-error 1 "Can't mark negative article numbers")
7784 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7785 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7786 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7787 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7788 (cond ((= mark gnus-ticked-mark)
7789 (push article gnus-newsgroup-marked))
7790 ((= mark gnus-dormant-mark)
7791 (push article gnus-newsgroup-dormant))
7793 (push article gnus-newsgroup-unreads)))
7794 (gnus-pull article gnus-newsgroup-reads)
7796 ;; See whether the article is to be put in the cache.
7798 (vectorp (gnus-summary-article-header article))
7800 (gnus-cache-possibly-enter-article
7801 gnus-newsgroup-name article
7802 (gnus-summary-article-header article)
7803 (= mark gnus-ticked-mark)
7804 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7807 (gnus-summary-update-mark mark 'unread)
7810 (defun gnus-summary-mark-article (&optional article mark no-expire)
7811 "Mark ARTICLE with MARK. MARK can be any character.
7812 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7813 `??' (dormant) and `?E' (expirable).
7814 If MARK is nil, then the default character `?D' is used.
7815 If ARTICLE is nil, then the article on the current line will be
7817 ;; The mark might be a string.
7818 (when (stringp mark)
7819 (setq mark (aref mark 0)))
7820 ;; If no mark is given, then we check auto-expiring.
7821 (and (not no-expire)
7822 gnus-newsgroup-auto-expire
7824 (and (gnus-characterp mark)
7825 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7826 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7827 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7828 (= mark gnus-duplicate-mark))))
7829 (setq mark gnus-expirable-mark))
7830 (let* ((mark (or mark gnus-del-mark))
7831 (article (or article (gnus-summary-article-number)))
7832 (old-mark (gnus-summary-article-mark article)))
7833 ;; Allow the backend to change the mark.
7834 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7835 (if (eq mark old-mark)
7838 (error "No article on current line"))
7839 (if (not (if (or (= mark gnus-unread-mark)
7840 (= mark gnus-ticked-mark)
7841 (= mark gnus-dormant-mark))
7842 (gnus-mark-article-as-unread article mark)
7843 (gnus-mark-article-as-read article mark)))
7845 ;; See whether the article is to be put in the cache.
7847 (not (= mark gnus-canceled-mark))
7848 (vectorp (gnus-summary-article-header article))
7850 (gnus-cache-possibly-enter-article
7851 gnus-newsgroup-name article
7852 (gnus-summary-article-header article)
7853 (= mark gnus-ticked-mark)
7854 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7856 (when (gnus-summary-goto-subject article nil t)
7857 (let ((buffer-read-only nil))
7858 (gnus-summary-show-thread)
7860 (gnus-summary-update-mark mark 'unread)
7863 (defun gnus-summary-update-secondary-mark (article)
7864 "Update the secondary (read, process, cache) mark."
7865 (gnus-summary-update-mark
7866 (cond ((memq article gnus-newsgroup-processable)
7868 ((memq article gnus-newsgroup-cached)
7870 ((memq article gnus-newsgroup-replied)
7872 ((memq article gnus-newsgroup-saved)
7874 (t gnus-unread-mark))
7876 (when (gnus-visual-p 'summary-highlight 'highlight)
7877 (gnus-run-hooks 'gnus-summary-update-hook))
7880 (defun gnus-summary-update-mark (mark type)
7881 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7882 (buffer-read-only nil))
7883 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7885 (when (looking-at "\r")
7887 (when (<= (+ forward (point)) (point-max))
7888 ;; Go to the right position on the line.
7889 (goto-char (+ forward (point)))
7890 ;; Replace the old mark with the new mark.
7891 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
7892 ;; Optionally update the marks by some user rule.
7893 (when (eq type 'unread)
7895 (gnus-data-find (gnus-summary-article-number)) mark)
7896 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
7898 (defun gnus-mark-article-as-read (article &optional mark)
7899 "Enter ARTICLE in the pertinent lists and remove it from others."
7900 ;; Make the article expirable.
7901 (let ((mark (or mark gnus-del-mark)))
7902 (if (= mark gnus-expirable-mark)
7903 (push article gnus-newsgroup-expirable)
7904 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7905 ;; Remove from unread and marked lists.
7906 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7907 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7908 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7909 (push (cons article mark) gnus-newsgroup-reads)
7910 ;; Possibly remove from cache, if that is used.
7911 (when gnus-use-cache
7912 (gnus-cache-enter-remove-article article))
7915 (defun gnus-mark-article-as-unread (article &optional mark)
7916 "Enter ARTICLE in the pertinent lists and remove it from others."
7917 (let ((mark (or mark gnus-ticked-mark)))
7920 (gnus-error 1 "Can't mark negative article numbers")
7922 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7923 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7924 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7925 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7927 ;; Unsuppress duplicates?
7928 (when gnus-suppress-duplicates
7929 (gnus-dup-unsuppress-article article))
7931 (cond ((= mark gnus-ticked-mark)
7932 (push article gnus-newsgroup-marked))
7933 ((= mark gnus-dormant-mark)
7934 (push article gnus-newsgroup-dormant))
7936 (push article gnus-newsgroup-unreads)))
7937 (gnus-pull article gnus-newsgroup-reads)
7940 (defalias 'gnus-summary-mark-as-unread-forward
7941 'gnus-summary-tick-article-forward)
7942 (make-obsolete 'gnus-summary-mark-as-unread-forward
7943 'gnus-summary-tick-article-forward)
7944 (defun gnus-summary-tick-article-forward (n)
7945 "Tick N articles forwards.
7946 If N is negative, tick backwards instead.
7947 The difference between N and the number of articles ticked is returned."
7949 (gnus-summary-mark-forward n gnus-ticked-mark))
7951 (defalias 'gnus-summary-mark-as-unread-backward
7952 'gnus-summary-tick-article-backward)
7953 (make-obsolete 'gnus-summary-mark-as-unread-backward
7954 'gnus-summary-tick-article-backward)
7955 (defun gnus-summary-tick-article-backward (n)
7956 "Tick N articles backwards.
7957 The difference between N and the number of articles ticked is returned."
7959 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7961 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7962 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7963 (defun gnus-summary-tick-article (&optional article clear-mark)
7964 "Mark current article as unread.
7965 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7966 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7968 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7971 (defun gnus-summary-mark-as-read-forward (n)
7972 "Mark N articles as read forwards.
7973 If N is negative, mark backwards instead.
7974 The difference between N and the actual number of articles marked is
7977 (gnus-summary-mark-forward n gnus-del-mark t))
7979 (defun gnus-summary-mark-as-read-backward (n)
7980 "Mark the N articles as read backwards.
7981 The difference between N and the actual number of articles marked is
7984 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7986 (defun gnus-summary-mark-as-read (&optional article mark)
7987 "Mark current article as read.
7988 ARTICLE specifies the article to be marked as read.
7989 MARK specifies a string to be inserted at the beginning of the line."
7990 (gnus-summary-mark-article article mark))
7992 (defun gnus-summary-clear-mark-forward (n)
7993 "Clear marks from N articles forward.
7994 If N is negative, clear backward instead.
7995 The difference between N and the number of marks cleared is returned."
7997 (gnus-summary-mark-forward n gnus-unread-mark))
7999 (defun gnus-summary-clear-mark-backward (n)
8000 "Clear marks from N articles backward.
8001 The difference between N and the number of marks cleared is returned."
8003 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8005 (defun gnus-summary-mark-unread-as-read ()
8006 "Intended to be used by `gnus-summary-mark-article-hook'."
8007 (when (memq gnus-current-article gnus-newsgroup-unreads)
8008 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8010 (defun gnus-summary-mark-read-and-unread-as-read ()
8011 "Intended to be used by `gnus-summary-mark-article-hook'."
8012 (let ((mark (gnus-summary-article-mark)))
8013 (when (or (gnus-unread-mark-p mark)
8014 (gnus-read-mark-p mark))
8015 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8017 (defun gnus-summary-mark-region-as-read (point mark all)
8018 "Mark all unread articles between point and mark as read.
8019 If given a prefix, mark all articles between point and mark as read,
8020 even ticked and dormant ones."
8021 (interactive "r\nP")
8030 (memq (setq article (gnus-summary-article-number))
8031 gnus-newsgroup-unreads))
8032 (gnus-summary-mark-article article gnus-del-mark))
8034 (gnus-summary-find-next))))))
8036 (defun gnus-summary-mark-below (score mark)
8037 "Mark articles with score less than SCORE with MARK."
8038 (interactive "P\ncMark: ")
8039 (setq score (if score
8040 (prefix-numeric-value score)
8041 (or gnus-summary-default-score 0)))
8043 (set-buffer gnus-summary-buffer)
8044 (goto-char (point-min))
8047 (and (< (gnus-summary-article-score) score)
8048 (gnus-summary-mark-article nil mark))
8049 (gnus-summary-find-next)))))
8051 (defun gnus-summary-kill-below (&optional score)
8052 "Mark articles with score below SCORE as read."
8054 (gnus-summary-mark-below score gnus-killed-mark))
8056 (defun gnus-summary-clear-above (&optional score)
8057 "Clear all marks from articles with score above SCORE."
8059 (gnus-summary-mark-above score gnus-unread-mark))
8061 (defun gnus-summary-tick-above (&optional score)
8062 "Tick all articles with score above SCORE."
8064 (gnus-summary-mark-above score gnus-ticked-mark))
8066 (defun gnus-summary-mark-above (score mark)
8067 "Mark articles with score over SCORE with MARK."
8068 (interactive "P\ncMark: ")
8069 (setq score (if score
8070 (prefix-numeric-value score)
8071 (or gnus-summary-default-score 0)))
8073 (set-buffer gnus-summary-buffer)
8074 (goto-char (point-min))
8076 (when (> (gnus-summary-article-score) score)
8077 (gnus-summary-mark-article nil mark))
8079 (gnus-summary-find-next)))))
8081 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8082 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8083 (defun gnus-summary-limit-include-expunged (&optional no-error)
8084 "Display all the hidden articles that were expunged for low scores."
8086 (let ((buffer-read-only nil))
8087 (let ((scored gnus-newsgroup-scored)
8090 (unless (gnus-summary-goto-subject (caar scored))
8091 (and (setq h (gnus-summary-article-header (caar scored)))
8092 (< (cdar scored) gnus-summary-expunge-below)
8094 (setq scored (cdr scored)))
8096 (when (not no-error)
8097 (error "No expunged articles hidden"))
8098 (goto-char (point-min))
8099 (gnus-summary-prepare-unthreaded (nreverse headers))
8100 (goto-char (point-min))
8101 (gnus-summary-position-point)
8104 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8105 "Mark all unread articles in this newsgroup as read.
8106 If prefix argument ALL is non-nil, ticked and dormant articles will
8107 also be marked as read.
8108 If QUIETLY is non-nil, no questions will be asked.
8109 If TO-HERE is non-nil, it should be a point in the buffer. All
8110 articles before this point will be marked as read.
8111 Note that this function will only catch up the unread article
8112 in the current summary buffer limitation.
8113 The number of articles marked as read is returned."
8118 (not gnus-interactive-catchup) ;Without confirmation?
8122 "Mark absolutely all articles as read? "
8123 "Mark all unread articles as read? ")))
8125 (not gnus-newsgroup-adaptive)
8126 (not gnus-newsgroup-auto-expire)
8127 (not gnus-suppress-duplicates)
8128 (or (not gnus-use-cache)
8129 (eq gnus-use-cache 'passive)))
8132 (setq gnus-newsgroup-marked nil
8133 gnus-newsgroup-dormant nil))
8134 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8135 ;; We actually mark all articles as canceled, which we
8136 ;; have to do when using auto-expiry or adaptive scoring.
8137 (gnus-summary-show-all-threads)
8138 (when (gnus-summary-first-subject (not all) t)
8140 (if to-here (< (point) to-here) t)
8141 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8142 (gnus-summary-find-next (not all) nil nil t))))
8143 (gnus-set-mode-line 'summary))
8145 (gnus-summary-position-point)))
8147 (defun gnus-summary-catchup-to-here (&optional all)
8148 "Mark all unticked articles before the current one as read.
8149 If ALL is non-nil, also mark ticked and dormant articles as read."
8152 (gnus-save-hidden-threads
8153 (let ((beg (point)))
8154 ;; We check that there are unread articles.
8155 (when (or all (gnus-summary-find-prev))
8156 (gnus-summary-catchup all t beg)))))
8157 (gnus-summary-position-point))
8159 (defun gnus-summary-catchup-all (&optional quietly)
8160 "Mark all articles in this newsgroup as read."
8162 (gnus-summary-catchup t quietly))
8164 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8165 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8166 If prefix argument ALL is non-nil, all articles are marked as read."
8168 (when (gnus-summary-catchup all quietly nil 'fast)
8169 ;; Select next newsgroup or exit.
8170 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8171 (eq gnus-auto-select-next 'quietly))
8172 (gnus-summary-next-group nil)
8173 (gnus-summary-exit))))
8175 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8176 "Mark all articles in this newsgroup as read, and then exit."
8178 (gnus-summary-catchup-and-exit t quietly))
8180 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8181 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8182 "Mark all articles in this group as read and select the next group.
8183 If given a prefix, mark all articles, unread as well as ticked, as
8187 (gnus-summary-catchup all))
8188 (gnus-summary-next-article t nil nil t))
8190 ;; Thread-based commands.
8192 (defun gnus-summary-articles-in-thread (&optional article)
8193 "Return a list of all articles in the current thread.
8194 If ARTICLE is non-nil, return all articles in the thread that starts
8196 (let* ((article (or article (gnus-summary-article-number)))
8197 (data (gnus-data-find-list article))
8198 (top-level (gnus-data-level (car data)))
8200 (cond ((null gnus-thread-operation-ignore-subject)
8201 (gnus-simplify-subject-re
8202 (mail-header-subject (gnus-data-header (car data)))))
8203 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8204 (gnus-simplify-subject-fuzzy
8205 (mail-header-subject (gnus-data-header (car data)))))
8207 (end-point (save-excursion
8208 (if (gnus-summary-go-to-next-thread)
8209 (point) (point-max))))
8212 (< (gnus-data-pos (car data)) end-point))
8213 (when (or (not top-subject)
8214 (string= top-subject
8215 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8216 (gnus-simplify-subject-fuzzy
8217 (mail-header-subject
8218 (gnus-data-header (car data))))
8219 (gnus-simplify-subject-re
8220 (mail-header-subject
8221 (gnus-data-header (car data)))))))
8222 (push (gnus-data-number (car data)) articles))
8223 (unless (and (setq data (cdr data))
8224 (> (gnus-data-level (car data)) top-level))
8226 ;; Return the list of articles.
8227 (nreverse articles)))
8229 (defun gnus-summary-rethread-current ()
8230 "Rethread the thread the current article is part of."
8232 (let* ((gnus-show-threads t)
8233 (article (gnus-summary-article-number))
8234 (id (mail-header-id (gnus-summary-article-header)))
8235 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8237 (error "No article on the current line"))
8238 (gnus-rebuild-thread id)
8239 (gnus-summary-goto-subject article)))
8241 (defun gnus-summary-reparent-thread ()
8242 "Make the current article child of the marked (or previous) article.
8244 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8245 is non-nil or the Subject: of both articles are the same."
8247 (unless (not (gnus-group-read-only-p))
8248 (error "The current newsgroup does not support article editing"))
8249 (unless (<= (length gnus-newsgroup-processable) 1)
8250 (error "No more than one article may be marked"))
8251 (save-window-excursion
8252 (let ((gnus-article-buffer " *reparent*")
8253 (current-article (gnus-summary-article-number))
8254 ;; First grab the marked article, otherwise one line up.
8255 (parent-article (if (not (null gnus-newsgroup-processable))
8256 (car gnus-newsgroup-processable)
8258 (if (eq (forward-line -1) 0)
8259 (gnus-summary-article-number)
8260 (error "Beginning of summary buffer"))))))
8261 (unless (not (eq current-article parent-article))
8262 (error "An article may not be self-referential"))
8263 (let ((message-id (mail-header-id
8264 (gnus-summary-article-header parent-article))))
8265 (unless (and message-id (not (equal message-id "")))
8266 (error "No message-id in desired parent"))
8267 ;; We don't want the article to be marked as read.
8268 (let (gnus-mark-article-hook)
8269 (gnus-summary-select-article t t nil current-article))
8270 (set-buffer gnus-original-article-buffer)
8271 (let ((buf (format "%s" (buffer-string))))
8274 (goto-char (point-min))
8275 (if (re-search-forward "^References: " nil t)
8277 (re-search-forward "^[^ \t]" nil t)
8280 (insert " " message-id))
8281 (insert "References: " message-id "\n"))
8282 (unless (gnus-request-replace-article
8283 current-article (car gnus-article-current)
8285 (error "Couldn't replace article"))))
8286 (set-buffer gnus-summary-buffer)
8287 (gnus-summary-unmark-all-processable)
8288 (gnus-summary-update-article current-article)
8289 (gnus-summary-rethread-current)
8290 (gnus-message 3 "Article %d is now the child of article %d"
8291 current-article parent-article)))))
8293 (defun gnus-summary-toggle-threads (&optional arg)
8294 "Toggle showing conversation threads.
8295 If ARG is positive number, turn showing conversation threads on."
8297 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8298 (setq gnus-show-threads
8299 (if (null arg) (not gnus-show-threads)
8300 (> (prefix-numeric-value arg) 0)))
8301 (gnus-summary-prepare)
8302 (gnus-summary-goto-subject current)
8303 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8304 (gnus-summary-position-point)))
8306 (defun gnus-summary-show-all-threads ()
8310 (let ((buffer-read-only nil))
8311 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8312 (gnus-summary-position-point))
8314 (defun gnus-summary-show-thread ()
8315 "Show thread subtrees.
8316 Returns nil if no thread was there to be shown."
8318 (let ((buffer-read-only nil)
8320 ;; first goto end then to beg, to have point at beg after let
8321 (end (progn (end-of-line) (point)))
8322 (beg (progn (beginning-of-line) (point))))
8324 ;; Any hidden lines here?
8325 (search-forward "\r" end t)
8326 (subst-char-in-region beg end ?\^M ?\n t)
8328 (gnus-summary-position-point))))
8330 (defun gnus-summary-hide-all-threads ()
8331 "Hide all thread subtrees."
8334 (goto-char (point-min))
8335 (gnus-summary-hide-thread)
8336 (while (zerop (gnus-summary-next-thread 1 t))
8337 (gnus-summary-hide-thread)))
8338 (gnus-summary-position-point))
8340 (defun gnus-summary-hide-thread ()
8341 "Hide thread subtrees.
8342 Returns nil if no threads were there to be hidden."
8344 (let ((buffer-read-only nil)
8346 (article (gnus-summary-article-number)))
8348 ;; Go forward until either the buffer ends or the subthread
8350 (when (and (not (eobp))
8351 (or (zerop (gnus-summary-next-thread 1 t))
8352 (goto-char (point-max))))
8354 (if (and (> (point) start)
8355 (search-backward "\n" start t))
8357 (subst-char-in-region start (point) ?\n ?\^M)
8358 (gnus-summary-goto-subject article))
8361 ;;(gnus-summary-position-point)
8364 (defun gnus-summary-go-to-next-thread (&optional previous)
8365 "Go to the same level (or less) next thread.
8366 If PREVIOUS is non-nil, go to previous thread instead.
8367 Return the article number moved to, or nil if moving was impossible."
8368 (let ((level (gnus-summary-thread-level))
8369 (way (if previous -1 1))
8372 (while (and (not (eobp))
8373 (< level (gnus-summary-thread-level)))
8381 (gnus-summary-article-number)
8384 (defun gnus-summary-next-thread (n &optional silent)
8385 "Go to the same level next N'th thread.
8386 If N is negative, search backward instead.
8387 Returns the difference between N and the number of skips actually
8390 If SILENT, don't output messages."
8392 (let ((backward (< n 0))
8395 (gnus-summary-go-to-next-thread backward))
8398 (gnus-summary-position-point))
8399 (when (and (not silent) (/= 0 n))
8400 (gnus-message 7 "No more threads"))
8403 (defun gnus-summary-prev-thread (n)
8404 "Go to the same level previous N'th thread.
8405 Returns the difference between N and the number of skips actually
8408 (gnus-summary-next-thread (- n)))
8410 (defun gnus-summary-go-down-thread ()
8411 "Go down one level in the current thread."
8412 (let ((children (gnus-summary-article-children)))
8414 (gnus-summary-goto-subject (car children)))))
8416 (defun gnus-summary-go-up-thread ()
8417 "Go up one level in the current thread."
8418 (let ((parent (gnus-summary-article-parent)))
8420 (gnus-summary-goto-subject parent))))
8422 (defun gnus-summary-down-thread (n)
8423 "Go down thread N steps.
8424 If N is negative, go up instead.
8425 Returns the difference between N and how many steps down that were
8431 (if up (gnus-summary-go-up-thread)
8432 (gnus-summary-go-down-thread)))
8434 (gnus-summary-position-point)
8436 (gnus-message 7 "Can't go further"))
8439 (defun gnus-summary-up-thread (n)
8440 "Go up thread N steps.
8441 If N is negative, go up instead.
8442 Returns the difference between N and how many steps down that were
8445 (gnus-summary-down-thread (- n)))
8447 (defun gnus-summary-top-thread ()
8448 "Go to the top of the thread."
8450 (while (gnus-summary-go-up-thread))
8451 (gnus-summary-article-number))
8453 (defun gnus-summary-kill-thread (&optional unmark)
8454 "Mark articles under current thread as read.
8455 If the prefix argument is positive, remove any kinds of marks.
8456 If the prefix argument is negative, tick articles instead."
8459 (setq unmark (prefix-numeric-value unmark)))
8460 (let ((articles (gnus-summary-articles-in-thread)))
8462 ;; Expand the thread.
8463 (gnus-summary-show-thread)
8464 ;; Mark all the articles.
8466 (gnus-summary-goto-subject (car articles))
8467 (cond ((null unmark)
8468 (gnus-summary-mark-article-as-read gnus-killed-mark))
8470 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8472 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8473 (setq articles (cdr articles))))
8474 ;; Hide killed subtrees.
8476 gnus-thread-hide-killed
8477 (gnus-summary-hide-thread))
8478 ;; If marked as read, go to next unread subject.
8480 ;; Go to next unread subject.
8481 (gnus-summary-next-subject 1 t)))
8482 (gnus-set-mode-line 'summary))
8484 ;; Summary sorting commands
8486 (defun gnus-summary-sort-by-number (&optional reverse)
8487 "Sort the summary buffer by article number.
8488 Argument REVERSE means reverse order."
8490 (gnus-summary-sort 'number reverse))
8492 (defun gnus-summary-sort-by-author (&optional reverse)
8493 "Sort the summary buffer by author name alphabetically.
8494 If case-fold-search is non-nil, case of letters is ignored.
8495 Argument REVERSE means reverse order."
8497 (gnus-summary-sort 'author reverse))
8499 (defun gnus-summary-sort-by-subject (&optional reverse)
8500 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8501 If case-fold-search is non-nil, case of letters is ignored.
8502 Argument REVERSE means reverse order."
8504 (gnus-summary-sort 'subject reverse))
8506 (defun gnus-summary-sort-by-date (&optional reverse)
8507 "Sort the summary buffer by date.
8508 Argument REVERSE means reverse order."
8510 (gnus-summary-sort 'date reverse))
8512 (defun gnus-summary-sort-by-score (&optional reverse)
8513 "Sort the summary buffer by score.
8514 Argument REVERSE means reverse order."
8516 (gnus-summary-sort 'score reverse))
8518 (defun gnus-summary-sort-by-lines (&optional reverse)
8519 "Sort the summary buffer by article length.
8520 Argument REVERSE means reverse order."
8522 (gnus-summary-sort 'lines reverse))
8524 (defun gnus-summary-sort (predicate reverse)
8525 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8526 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8527 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8528 (gnus-thread-sort-functions
8534 (gnus-article-sort-functions
8539 (,article t2 t1)))))
8541 (gnus-summary-prepare-hook nil))
8542 ;; We do the sorting by regenerating the threads.
8543 (gnus-summary-prepare)
8544 ;; Hide subthreads if needed.
8545 (when (and gnus-show-threads gnus-thread-hide-subtree)
8546 (gnus-summary-hide-all-threads))))
8548 ;; Summary saving commands.
8550 (defun gnus-summary-save-article (&optional n not-saved)
8551 "Save the current article using the default saver function.
8552 If N is a positive number, save the N next articles.
8553 If N is a negative number, save the N previous articles.
8554 If N is nil and any articles have been marked with the process mark,
8555 save those articles instead.
8556 The variable `gnus-default-article-saver' specifies the saver function."
8558 (let* ((articles (gnus-summary-work-articles n))
8559 (save-buffer (save-excursion
8560 (nnheader-set-temp-buffer " *Gnus Save*")))
8561 (num (length articles))
8562 header article file)
8564 (setq header (gnus-summary-article-header
8565 (setq article (pop articles))))
8566 (if (not (vectorp header))
8567 ;; This is a pseudo-article.
8568 (if (assq 'name header)
8569 (gnus-copy-file (cdr (assq 'name header)))
8570 (gnus-message 1 "Article %d is unsaveable" article))
8571 ;; This is a real article.
8572 (save-window-excursion
8573 (gnus-summary-select-article t nil nil article))
8575 (set-buffer save-buffer)
8577 (insert-buffer-substring gnus-original-article-buffer))
8578 (setq file (gnus-article-save save-buffer file num))
8579 (gnus-summary-remove-process-mark article)
8581 (gnus-summary-set-saved-mark article))))
8582 (gnus-kill-buffer save-buffer)
8583 (gnus-summary-position-point)
8584 (gnus-set-mode-line 'summary)
8587 (defun gnus-summary-pipe-output (&optional arg)
8588 "Pipe the current article to a subprocess.
8589 If N is a positive number, pipe the N next articles.
8590 If N is a negative number, pipe the N previous articles.
8591 If N is nil and any articles have been marked with the process mark,
8592 pipe those articles instead."
8594 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8595 (gnus-summary-save-article arg t))
8596 (gnus-configure-windows 'pipe))
8598 (defun gnus-summary-save-article-mail (&optional arg)
8599 "Append the current article to an mail file.
8600 If N is a positive number, save the N next articles.
8601 If N is a negative number, save the N previous articles.
8602 If N is nil and any articles have been marked with the process mark,
8603 save those articles instead."
8605 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8606 (gnus-summary-save-article arg)))
8608 (defun gnus-summary-save-article-rmail (&optional arg)
8609 "Append the current article to an rmail file.
8610 If N is a positive number, save the N next articles.
8611 If N is a negative number, save the N previous articles.
8612 If N is nil and any articles have been marked with the process mark,
8613 save those articles instead."
8615 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8616 (gnus-summary-save-article arg)))
8618 (defun gnus-summary-save-article-file (&optional arg)
8619 "Append the current article to a file.
8620 If N is a positive number, save the N next articles.
8621 If N is a negative number, save the N previous articles.
8622 If N is nil and any articles have been marked with the process mark,
8623 save those articles instead."
8625 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8626 (gnus-summary-save-article arg)))
8628 (defun gnus-summary-write-article-file (&optional arg)
8629 "Write the current article to a file, deleting the previous file.
8630 If N is a positive number, save the N next articles.
8631 If N is a negative number, save the N previous articles.
8632 If N is nil and any articles have been marked with the process mark,
8633 save those articles instead."
8635 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8636 (gnus-summary-save-article arg)))
8638 (defun gnus-summary-save-article-body-file (&optional arg)
8639 "Append the current article body to a file.
8640 If N is a positive number, save the N next articles.
8641 If N is a negative number, save the N previous articles.
8642 If N is nil and any articles have been marked with the process mark,
8643 save those articles instead."
8645 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8646 (gnus-summary-save-article arg)))
8648 (defun gnus-summary-pipe-message (program)
8649 "Pipe the current article through PROGRAM."
8650 (interactive "sProgram: ")
8651 (gnus-summary-select-article)
8652 (let ((mail-header-separator ""))
8653 (gnus-eval-in-buffer-window gnus-article-buffer
8656 (let ((start (window-start))
8658 (message-pipe-buffer-body program)
8659 (set-window-start (get-buffer-window (current-buffer)) start))))))
8661 (defun gnus-get-split-value (methods)
8662 "Return a value based on the split METHODS."
8663 (let (split-name method result match)
8666 (set-buffer gnus-original-article-buffer)
8668 (nnheader-narrow-to-headers)
8670 (goto-char (point-min))
8671 (setq method (pop methods))
8672 (setq match (car method))
8675 ;; Regular expression.
8677 (re-search-forward match nil t)))
8678 ((gnus-functionp match)
8682 (setq result (funcall match gnus-newsgroup-name))))
8687 (setq result (eval match)))))
8688 (setq split-name (append (cdr method) split-name))
8689 (cond ((stringp result)
8690 (push (expand-file-name
8691 result gnus-article-save-directory)
8694 (setq split-name (append result split-name)))))))))
8697 (defun gnus-valid-move-group-p (group)
8700 (symbol-value group)
8703 (car (gnus-find-method-for-group
8704 (symbol-name group))))
8705 gnus-valid-select-methods))))
8707 (defun gnus-read-move-group-name (prompt default articles prefix)
8708 "Read a group name."
8709 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8710 (minibuffer-confirm-incomplete nil) ; XEmacs
8714 (if (> (length articles) 1)
8715 (format "these %d articles" (length articles))
8720 (gnus-completing-read default prom
8722 'gnus-valid-move-group-p
8724 'gnus-group-history))
8725 ((= 1 (length split-name))
8726 (gnus-completing-read (car split-name) prom
8728 'gnus-valid-move-group-p
8730 'gnus-group-history))
8732 (gnus-completing-read nil prom
8733 (mapcar (lambda (el) (list el))
8734 (nreverse split-name))
8736 'gnus-group-history)))))
8738 (if (or (string= to-newsgroup "")
8739 (string= to-newsgroup prefix))
8740 (setq to-newsgroup default))
8741 (unless to-newsgroup
8742 (error "No group name entered"))
8743 (or (gnus-active to-newsgroup)
8744 (gnus-activate-group to-newsgroup)
8745 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8747 (or (and (gnus-request-create-group
8748 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8749 (gnus-activate-group to-newsgroup nil nil
8750 (gnus-group-name-to-method
8752 (error "Couldn't create group %s" to-newsgroup)))
8753 (error "No such group: %s" to-newsgroup)))
8756 ;; Summary extract commands
8758 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8759 (let ((buffer-read-only nil)
8760 (article (gnus-summary-article-number))
8762 (unless (gnus-summary-goto-subject article)
8763 (error "No such article: %d" article))
8764 (gnus-summary-position-point)
8765 ;; If all commands are to be bunched up on one line, we collect
8767 (unless gnus-view-pseudos-separately
8768 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8771 (setq action (cdr (assq 'action (car ps))))
8772 (setq files (list (cdr (assq 'name (car ps)))))
8773 (while (and ps (cdr ps)
8774 (string= (or action "1")
8775 (or (cdr (assq 'action (cadr ps))) "2")))
8776 (push (cdr (assq 'name (cadr ps))) files)
8777 (setcdr ps (cddr ps)))
8779 (when (not (string-match "%s" action))
8782 (when (assq 'execute (car ps))
8783 (setcdr (assq 'execute (car ps))
8784 (funcall (if (string-match "%s" action)
8791 (gnus-quote-arg-for-sh-or-csh f)))
8793 (setq ps (cdr ps)))))
8794 (if (and gnus-view-pseudos (not not-view))
8796 (when (assq 'execute (car pslist))
8797 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8798 (eq gnus-view-pseudos 'not-confirm)))
8799 (setq pslist (cdr pslist)))
8802 (setq after-article (or (cdr (assq 'article (car pslist)))
8803 (gnus-summary-article-number)))
8804 (gnus-summary-goto-subject after-article)
8807 (insert " " (file-name-nondirectory
8808 (cdr (assq 'name (car pslist))))
8809 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8811 (forward-line -1) ; back to `b'
8812 (gnus-add-text-properties
8813 b (1- e) (list 'gnus-number gnus-reffed-article-number
8814 gnus-mouse-face-prop gnus-mouse-face))
8816 after-article gnus-reffed-article-number
8817 gnus-unread-mark b (car pslist) 0 (- e b))
8818 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8819 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8820 (setq pslist (cdr pslist)))))))
8822 (defun gnus-pseudos< (p1 p2)
8823 (let ((c1 (cdr (assq 'action p1)))
8824 (c2 (cdr (assq 'action p2))))
8825 (and c1 c2 (string< c1 c2))))
8827 (defun gnus-request-pseudo-article (props)
8828 (cond ((assq 'execute props)
8829 (gnus-execute-command (cdr (assq 'execute props)))))
8830 (let ((gnus-current-article (gnus-summary-article-number)))
8831 (gnus-run-hooks 'gnus-mark-article-hook)))
8833 (defun gnus-execute-command (command &optional automatic)
8835 (gnus-article-setup-buffer)
8836 (set-buffer gnus-article-buffer)
8837 (setq buffer-read-only nil)
8838 (let ((command (if automatic command
8839 (read-string "Command: " (cons command 0)))))
8841 (insert "$ " command "\n\n")
8842 (if gnus-view-pseudo-asynchronously
8843 (start-process "gnus-execute" (current-buffer) shell-file-name
8844 shell-command-switch command)
8845 (call-process shell-file-name nil t nil
8846 shell-command-switch command)))))
8848 ;; Summary kill commands.
8850 (defun gnus-summary-edit-global-kill (article)
8851 "Edit the \"global\" kill file."
8852 (interactive (list (gnus-summary-article-number)))
8853 (gnus-group-edit-global-kill article))
8855 (defun gnus-summary-edit-local-kill ()
8856 "Edit a local kill file applied to the current newsgroup."
8858 (setq gnus-current-headers (gnus-summary-article-header))
8859 (gnus-group-edit-local-kill
8860 (gnus-summary-article-number) gnus-newsgroup-name))
8864 (defun gnus-read-header (id &optional header)
8865 "Read the headers of article ID and enter them into the Gnus system."
8866 (let ((group gnus-newsgroup-name)
8867 (gnus-override-method
8868 (and (gnus-news-group-p gnus-newsgroup-name)
8869 gnus-refer-article-method))
8871 ;; First we check to see whether the header in question is already
8874 ;; This is a Message-ID.
8875 (setq header (or header (gnus-id-to-header id)))
8876 ;; This is an article number.
8877 (setq header (or header (gnus-summary-article-header id))))
8879 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8880 ;; We have found the header.
8882 ;; If this is a sparse article, we have to nix out its
8883 ;; previous entry in the thread hashtb.
8885 (gnus-summary-article-sparse-p (mail-header-number header)))
8886 (let* ((parent (gnus-parent-id (mail-header-references header)))
8887 (thread (and parent (gnus-id-to-thread parent))))
8889 (delq (assq header thread) thread))))
8890 ;; We have to really fetch the header to this article.
8892 (set-buffer nntp-server-buffer)
8893 (when (setq where (gnus-request-head id group))
8894 (nnheader-fold-continuation-lines)
8895 (goto-char (point-max))
8897 (goto-char (point-min))
8901 ((cdr where) (cdr where))
8902 (header (mail-header-number header))
8903 (t gnus-reffed-article-number))
8905 (insert " Article retrieved.\n"))
8907 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8908 () ; Malformed head.
8909 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8910 (when (and (stringp id)
8911 (not (string= (gnus-group-real-name group)
8913 ;; If we fetched by Message-ID and the article came
8914 ;; from a different group, we fudge some bogus article
8915 ;; numbers for this article.
8916 (mail-header-set-number header gnus-reffed-article-number))
8918 (set-buffer gnus-summary-buffer)
8919 (decf gnus-reffed-article-number)
8920 (gnus-remove-header (mail-header-number header))
8921 (push header gnus-newsgroup-headers)
8922 (setq gnus-current-headers header)
8923 (push (mail-header-number header) gnus-newsgroup-limit)))
8926 (defun gnus-remove-header (number)
8927 "Remove header NUMBER from `gnus-newsgroup-headers'."
8928 (if (and gnus-newsgroup-headers
8929 (= number (mail-header-number (car gnus-newsgroup-headers))))
8930 (pop gnus-newsgroup-headers)
8931 (let ((headers gnus-newsgroup-headers))
8932 (while (and (cdr headers)
8933 (not (= number (mail-header-number (cadr headers)))))
8936 (setcdr headers (cddr headers))))))
8939 ;;; summary highlights
8942 (defun gnus-highlight-selected-summary ()
8943 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8944 ;; Highlight selected article in summary buffer
8945 (when gnus-summary-selected-face
8947 (let* ((beg (progn (beginning-of-line) (point)))
8948 (end (progn (end-of-line) (point)))
8949 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8950 (from (if (get-text-property beg gnus-mouse-face-prop)
8952 (or (next-single-property-change
8953 beg gnus-mouse-face-prop nil end)
8958 (or (next-single-property-change
8959 from gnus-mouse-face-prop nil end)
8961 ;; If no mouse-face prop on line we will have to = from = end,
8962 ;; so we highlight the entire line instead.
8963 (when (= (+ to 2) from)
8966 (if gnus-newsgroup-selected-overlay
8967 ;; Move old overlay.
8969 gnus-newsgroup-selected-overlay from to (current-buffer))
8970 ;; Create new overlay.
8972 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8973 'face gnus-summary-selected-face))))))
8975 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8976 (defun gnus-summary-highlight-line ()
8977 "Highlight current line according to `gnus-summary-highlight'."
8978 (let* ((list gnus-summary-highlight)
8980 (end (progn (end-of-line) (point)))
8981 ;; now find out where the line starts and leave point there.
8982 (beg (progn (beginning-of-line) (point)))
8983 (article (gnus-summary-article-number))
8984 (score (or (cdr (assq (or article gnus-current-article)
8985 gnus-newsgroup-scored))
8986 gnus-summary-default-score 0))
8987 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8988 (inhibit-read-only t))
8989 ;; Eval the cars of the lists until we find a match.
8990 (let ((default gnus-summary-default-score))
8992 (not (eval (caar list))))
8993 (setq list (cdr list))))
8994 (let ((face (cdar list)))
8995 (unless (eq face (get-text-property beg 'face))
8996 (gnus-put-text-property-excluding-characters-with-faces
8998 (setq face (if (boundp face) (symbol-value face) face)))
8999 (when gnus-summary-highlight-line-function
9000 (funcall gnus-summary-highlight-line-function article face))))
9003 (defun gnus-update-read-articles (group unread &optional compute)
9004 "Update the list of read articles in GROUP."
9005 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9006 (entry (gnus-gethash group gnus-newsrc-hashtb))
9007 (info (nth 2 entry))
9009 (unread (sort (copy-sequence unread) '<))
9011 (if (or (not info) (not active))
9012 ;; There is no info on this group if it was, in fact,
9013 ;; killed. Gnus stores no information on killed groups, so
9014 ;; there's nothing to be done.
9015 ;; One could store the information somewhere temporarily,
9016 ;; perhaps... Hmmm...
9018 ;; Remove any negative articles numbers.
9019 (while (and unread (< (car unread) 0))
9020 (setq unread (cdr unread)))
9021 ;; Remove any expired article numbers
9022 (while (and unread (< (car unread) (car active)))
9023 (setq unread (cdr unread)))
9024 ;; Compute the ranges of read articles by looking at the list of
9027 (when (/= (car unread) prev)
9028 (push (if (= prev (1- (car unread))) prev
9029 (cons prev (1- (car unread))))
9031 (setq prev (1+ (car unread)))
9032 (setq unread (cdr unread)))
9033 (when (<= prev (cdr active))
9034 (push (cons prev (cdr active)) read))
9035 (setq read (if (> (length read) 1) (nreverse read) read))
9039 (set-buffer gnus-group-buffer)
9042 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9043 (gnus-info-set-read ',info ',(gnus-info-read info))
9044 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9045 (gnus-group-update-group ,group t))))
9046 ;; Enter this list into the group info.
9047 (gnus-info-set-read info read)
9048 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9049 (gnus-get-unread-articles-in-group info (gnus-active group))
9052 (defun gnus-offer-save-summaries ()
9053 "Offer to save all active summary buffers."
9055 (let ((buflist (buffer-list))
9057 ;; Go through all buffers and find all summaries.
9059 (and (setq bufname (buffer-name (car buflist)))
9060 (string-match "Summary" bufname)
9062 (set-buffer bufname)
9063 ;; We check that this is, indeed, a summary buffer.
9064 (and (eq major-mode 'gnus-summary-mode)
9065 ;; Also make sure this isn't bogus.
9066 gnus-newsgroup-prepared
9067 ;; Also make sure that this isn't a dead summary buffer.
9068 (not gnus-dead-summary-mode)))
9069 (push bufname buffers))
9070 (setq buflist (cdr buflist)))
9071 ;; Go through all these summary buffers and offer to save them.
9074 "Update summary buffer %s? "
9076 (switch-to-buffer buf)
9077 (gnus-summary-exit))
9081 ;;; @ for mime-partial
9084 (defun gnus-request-partial-message ()
9086 (let ((number (gnus-summary-article-number))
9087 (group gnus-newsgroup-name)
9088 (mother gnus-article-buffer))
9089 (set-buffer (get-buffer-create " *Partial Article*"))
9091 (setq mime-preview-buffer mother)
9092 (gnus-request-article-this-buffer number group)
9096 (autoload 'mime-combine-message/partial-pieces-automatically
9098 "Internal method to combine message/partial messages automatically.")
9101 'action '((type . message)(subtype . partial)
9102 (major-mode . gnus-original-article-mode)
9103 (method . mime-combine-message/partial-pieces-automatically)
9104 (summary-buffer-exp . gnus-summary-buffer)
9105 (request-partial-message-method . gnus-request-partial-message)
9116 (run-hooks 'gnus-sum-load-hook)
9118 ;;; gnus-sum.el ends here