1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 (or (string< "1" eword-decode-version)
41 (error "Please install latest SEMI."))
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
46 (defcustom gnus-kill-summary-on-exit t
47 "*If non-nil, kill the summary buffer when you exit from it.
48 If nil, the summary will become a \"*Dead Summary*\" buffer, and
49 it will be killed sometime later."
50 :group 'gnus-summary-exit
53 (defcustom gnus-fetch-old-headers nil
54 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
55 If an unread article in the group refers to an older, already read (or
56 just marked as read) article, the old article will not normally be
57 displayed in the Summary buffer. If this variable is non-nil, Gnus
58 will attempt to grab the headers to the old articles, and thereby
59 build complete threads. If it has the value `some', only enough
60 headers to connect otherwise loose threads will be displayed. This
61 variable can also be a number. In that case, no more than that number
62 of old headers will be fetched. If it has the value `invisible', all
63 old headers will be fetched, but none will be displayed.
65 The server has to support NOV for any of this to work."
67 :type '(choice (const :tag "off" nil)
70 (sexp :menu-tag "other" t)))
72 (defcustom gnus-refer-thread-limit 200
73 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
74 If t, fetch all the available old headers."
77 (sexp :menu-tag "other" t)))
79 (defcustom gnus-summary-make-false-root 'adopt
80 "*nil means that Gnus won't gather loose threads.
81 If the root of a thread has expired or been read in a previous
82 session, the information necessary to build a complete thread has been
83 lost. Instead of having many small sub-threads from this original thread
84 scattered all over the summary buffer, Gnus can gather them.
86 If non-nil, Gnus will try to gather all loose sub-threads from an
87 original thread into one large thread.
89 If this variable is non-nil, it should be one of `none', `adopt',
92 If this variable is `none', Gnus will not make a false root, but just
93 present the sub-threads after another.
94 If this variable is `dummy', Gnus will create a dummy root that will
95 have all the sub-threads as children.
96 If this variable is `adopt', Gnus will make one of the \"children\"
97 the parent and mark all the step-children as such.
98 If this variable is `empty', the \"children\" are printed with empty
99 subject fields. (Or rather, they will be printed with a string
100 given by the `gnus-summary-same-subject' variable.)"
102 :type '(choice (const :tag "off" nil)
108 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
109 "*A regexp to match subjects to be excluded from loose thread gathering.
110 As loose thread gathering is done on subjects only, that means that
111 there can be many false gatherings performed. By rooting out certain
112 common subjects, gathering might become saner."
116 (defcustom gnus-summary-gather-subject-limit nil
117 "*Maximum length of subject comparisons when gathering loose threads.
118 Use nil to compare full subjects. Setting this variable to a low
119 number will help gather threads that have been corrupted by
120 newsreaders chopping off subject lines, but it might also mean that
121 unrelated articles that have subject that happen to begin with the
122 same few characters will be incorrectly gathered.
124 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
127 :type '(choice (const :tag "off" nil)
129 (sexp :menu-tag "on" t)))
131 (defcustom gnus-simplify-subject-functions nil
132 "List of functions taking a string argument that simplify subjects.
133 The functions are applied recursively.
135 Useful functions to put in this list include: `gnus-simplify-subject-re',
136 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
138 :type '(repeat function))
140 (defcustom gnus-simplify-ignored-prefixes nil
141 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
143 :type '(choice (const :tag "off" nil)
146 (defcustom gnus-build-sparse-threads nil
147 "*If non-nil, fill in the gaps in threads.
148 If `some', only fill in the gaps that are needed to tie loose threads
149 together. If `more', fill in all leaf nodes that Gnus can find. If
150 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
152 :type '(choice (const :tag "off" nil)
155 (sexp :menu-tag "all" t)))
157 (defcustom gnus-summary-thread-gathering-function
158 'gnus-gather-threads-by-subject
159 "*Function used for gathering loose threads.
160 There are two pre-defined functions: `gnus-gather-threads-by-subject',
161 which only takes Subjects into consideration; and
162 `gnus-gather-threads-by-references', which compared the References
163 headers of the articles to find matches."
165 :type '(radio (function-item gnus-gather-threads-by-subject)
166 (function-item gnus-gather-threads-by-references)
167 (function :tag "other")))
169 (defcustom gnus-summary-same-subject ""
170 "*String indicating that the current article has the same subject as the previous.
171 This variable will only be used if the value of
172 `gnus-summary-make-false-root' is `empty'."
173 :group 'gnus-summary-format
176 (defcustom gnus-summary-goto-unread t
177 "*If t, marking commands will go to the next unread article.
178 If `never', commands that usually go to the next unread article, will
179 go to the next article, whether it is read or not.
180 If nil, only the marking commands will go to the next (un)read article."
181 :group 'gnus-summary-marks
182 :link '(custom-manual "(gnus)Setting Marks")
183 :type '(choice (const :tag "off" nil)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-summary-default-score 0
188 "*Default article score level.
189 All scores generated by the score files will be added to this score.
190 If this variable is nil, scoring will be disabled."
191 :group 'gnus-score-default
192 :type '(choice (const :tag "disable")
195 (defcustom gnus-summary-zcore-fuzz 0
196 "*Fuzziness factor for the zcore in the summary buffer.
197 Articles with scores closer than this to `gnus-summary-default-score'
199 :group 'gnus-summary-format
202 (defcustom gnus-simplify-subject-fuzzy-regexp nil
203 "*Strings to be removed when doing fuzzy matches.
204 This can either be a regular expression or list of regular expressions
205 that will be removed from subject strings if fuzzy subject
206 simplification is selected."
208 :type '(repeat regexp))
210 (defcustom gnus-show-threads t
211 "*If non-nil, display threads in summary mode."
215 (defcustom gnus-thread-hide-subtree nil
216 "*If non-nil, hide all threads initially.
217 If threads are hidden, you have to run the command
218 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
219 to expose hidden threads."
223 (defcustom gnus-thread-hide-killed t
224 "*If non-nil, hide killed threads automatically."
228 (defcustom gnus-thread-ignore-subject nil
229 "*If non-nil, ignore subjects and do all threading based on the Reference header.
230 If nil, which is the default, articles that have different subjects
231 from their parents will start separate threads."
235 (defcustom gnus-thread-operation-ignore-subject t
236 "*If non-nil, subjects will be ignored when doing thread commands.
237 This affects commands like `gnus-summary-kill-thread' and
238 `gnus-summary-lower-thread'.
240 If this variable is nil, articles in the same thread with different
241 subjects will not be included in the operation in question. If this
242 variable is `fuzzy', only articles that have subjects that are fuzzily
243 equal will be included."
245 :type '(choice (const :tag "off" nil)
249 (defcustom gnus-thread-indent-level 4
250 "*Number that says how much each sub-thread should be indented."
254 (defcustom gnus-auto-extend-newsgroup t
255 "*If non-nil, extend newsgroup forward and backward when requested."
256 :group 'gnus-summary-choose
259 (defcustom gnus-auto-select-first t
260 "*If nil, don't select the first unread article when entering a group.
261 If this variable is `best', select the highest-scored unread article
262 in the group. If neither nil nor `best', select the first unread
265 If you want to prevent automatic selection of the first unread article
266 in some newsgroups, set the variable to nil in
267 `gnus-select-group-hook'."
268 :group 'gnus-group-select
269 :type '(choice (const :tag "none" nil)
271 (sexp :menu-tag "first" t)))
273 (defcustom gnus-auto-select-next t
274 "*If non-nil, offer to go to the next group from the end of the previous.
275 If the value is t and the next newsgroup is empty, Gnus will exit
276 summary mode and go back to group mode. If the value is neither nil
277 nor t, Gnus will select the following unread newsgroup. In
278 particular, if the value is the symbol `quietly', the next unread
279 newsgroup will be selected without any confirmation, and if it is
280 `almost-quietly', the next group will be selected without any
281 confirmation if you are located on the last article in the group.
282 Finally, if this variable is `slightly-quietly', the `Z n' command
283 will go to the next group without confirmation."
284 :group 'gnus-summary-maneuvering
285 :type '(choice (const :tag "off" nil)
287 (const almost-quietly)
288 (const slightly-quietly)
289 (sexp :menu-tag "on" t)))
291 (defcustom gnus-auto-select-same nil
292 "*If non-nil, select the next article with the same subject."
293 :group 'gnus-summary-maneuvering
296 (defcustom gnus-summary-check-current nil
297 "*If non-nil, consider the current article when moving.
298 The \"unread\" movement commands will stay on the same line if the
299 current article is unread."
300 :group 'gnus-summary-maneuvering
303 (defcustom gnus-auto-center-summary t
304 "*If non-nil, always center the current summary buffer.
305 In particular, if `vertical' do only vertical recentering. If non-nil
306 and non-`vertical', do both horizontal and vertical recentering."
307 :group 'gnus-summary-maneuvering
308 :type '(choice (const :tag "none" nil)
310 (sexp :menu-tag "both" t)))
312 (defcustom gnus-show-all-headers nil
313 "*If non-nil, don't hide any headers."
314 :group 'gnus-article-hiding
315 :group 'gnus-article-headers
318 (defcustom gnus-summary-ignore-duplicates nil
319 "*If non-nil, ignore articles with identical Message-ID headers."
323 (defcustom gnus-single-article-buffer t
324 "*If non-nil, display all articles in the same buffer.
325 If nil, each group will get its own article buffer."
326 :group 'gnus-article-various
329 (defcustom gnus-break-pages t
330 "*If non-nil, do page breaking on articles.
331 The page delimiter is specified by the `gnus-page-delimiter'
333 :group 'gnus-article-various
336 (defcustom gnus-show-mime t
337 "*If non-nil, do mime processing of articles.
338 The articles will simply be fed to the function given by
339 `gnus-show-mime-method'."
340 :group 'gnus-article-mime
343 (defcustom gnus-move-split-methods nil
344 "*Variable used to suggest where articles are to be moved to.
345 It uses the same syntax as the `gnus-split-methods' variable."
346 :group 'gnus-summary-mail
347 :type '(repeat (choice (list :value (fun) function)
348 (cons :value ("" "") regexp (repeat string))
351 (defcustom gnus-unread-mark ?
352 "*Mark used for unread articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-ticked-mark ?!
357 "*Mark used for ticked articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-dormant-mark ??
362 "*Mark used for dormant articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-del-mark ?r
367 "*Mark used for del'd articles."
368 :group 'gnus-summary-marks
371 (defcustom gnus-read-mark ?R
372 "*Mark used for read articles."
373 :group 'gnus-summary-marks
376 (defcustom gnus-expirable-mark ?E
377 "*Mark used for expirable articles."
378 :group 'gnus-summary-marks
381 (defcustom gnus-killed-mark ?K
382 "*Mark used for killed articles."
383 :group 'gnus-summary-marks
386 (defcustom gnus-souped-mark ?F
387 "*Mark used for killed articles."
388 :group 'gnus-summary-marks
391 (defcustom gnus-kill-file-mark ?X
392 "*Mark used for articles killed by kill files."
393 :group 'gnus-summary-marks
396 (defcustom gnus-low-score-mark ?Y
397 "*Mark used for articles with a low score."
398 :group 'gnus-summary-marks
401 (defcustom gnus-catchup-mark ?C
402 "*Mark used for articles that are caught up."
403 :group 'gnus-summary-marks
406 (defcustom gnus-replied-mark ?A
407 "*Mark used for articles that have been replied to."
408 :group 'gnus-summary-marks
411 (defcustom gnus-cached-mark ?*
412 "*Mark used for articles that are in the cache."
413 :group 'gnus-summary-marks
416 (defcustom gnus-saved-mark ?S
417 "*Mark used for articles that have been saved to."
418 :group 'gnus-summary-marks
421 (defcustom gnus-ancient-mark ?O
422 "*Mark used for ancient articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-sparse-mark ?Q
427 "*Mark used for sparsely reffed articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-canceled-mark ?G
432 "*Mark used for canceled articles."
433 :group 'gnus-summary-marks
436 (defcustom gnus-duplicate-mark ?M
437 "*Mark used for duplicate articles."
438 :group 'gnus-summary-marks
441 (defcustom gnus-undownloaded-mark ?@
442 "*Mark used for articles that weren't downloaded."
443 :group 'gnus-summary-marks
446 (defcustom gnus-downloadable-mark ?%
447 "*Mark used for articles that are to be downloaded."
448 :group 'gnus-summary-marks
451 (defcustom gnus-unsendable-mark ?=
452 "*Mark used for articles that won't be sent."
453 :group 'gnus-summary-marks
456 (defcustom gnus-score-over-mark ?+
457 "*Score mark used for articles with high scores."
458 :group 'gnus-summary-marks
461 (defcustom gnus-score-below-mark ?-
462 "*Score mark used for articles with low scores."
463 :group 'gnus-summary-marks
466 (defcustom gnus-empty-thread-mark ?
467 "*There is no thread under the article."
468 :group 'gnus-summary-marks
471 (defcustom gnus-not-empty-thread-mark ?=
472 "*There is a thread under the article."
473 :group 'gnus-summary-marks
476 (defcustom gnus-view-pseudo-asynchronously nil
477 "*If non-nil, Gnus will view pseudo-articles asynchronously."
478 :group 'gnus-extract-view
481 (defcustom gnus-view-pseudos nil
482 "*If `automatic', pseudo-articles will be viewed automatically.
483 If `not-confirm', pseudos will be viewed automatically, and the user
484 will not be asked to confirm the command."
485 :group 'gnus-extract-view
486 :type '(choice (const :tag "off" nil)
488 (const not-confirm)))
490 (defcustom gnus-view-pseudos-separately t
491 "*If non-nil, one pseudo-article will be created for each file to be viewed.
492 If nil, all files that use the same viewing command will be given as a
493 list of parameters to that command."
494 :group 'gnus-extract-view
497 (defcustom gnus-insert-pseudo-articles t
498 "*If non-nil, insert pseudo-articles when decoding articles."
499 :group 'gnus-extract-view
502 (defcustom gnus-summary-dummy-line-format
504 "*The format specification for the dummy roots in the summary buffer.
505 It works along the same lines as a normal formatting string,
506 with some simple extensions.
509 :group 'gnus-threading
512 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
513 "*The format specification for the summary mode line.
514 It works along the same lines as a normal formatting string,
515 with some simple extensions:
518 %p Unprefixed group name
519 %A Current article number
521 %U Number of unread articles in the group
522 %e Number of unselected articles in the group
523 %Z A string with unread/unselected article counts
524 %g Shortish group name
525 %S Subject of the current article
527 %s Current score file name
528 %d Number of dormant articles
529 %r Number of articles that have been marked as read in this session
530 %E Number of articles expunged by the score files"
531 :group 'gnus-summary-format
534 (defcustom gnus-summary-mark-below 0
535 "*Mark all articles with a score below this variable as read.
536 This variable is local to each summary buffer and usually set by the
538 :group 'gnus-score-default
541 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
542 "*List of functions used for sorting articles in the summary buffer.
543 This variable is only used when not using a threaded display."
544 :group 'gnus-summary-sort
545 :type '(repeat (choice (function-item gnus-article-sort-by-number)
546 (function-item gnus-article-sort-by-author)
547 (function-item gnus-article-sort-by-subject)
548 (function-item gnus-article-sort-by-date)
549 (function-item gnus-article-sort-by-score)
550 (function :tag "other"))))
552 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
553 "*List of functions used for sorting threads in the summary buffer.
554 By default, threads are sorted by article number.
556 Each function takes two threads and return non-nil if the first thread
557 should be sorted before the other. If you use more than one function,
558 the primary sort function should be the last. You should probably
559 always include `gnus-thread-sort-by-number' in the list of sorting
560 functions -- preferably first.
562 Ready-made functions include `gnus-thread-sort-by-number',
563 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
564 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
565 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
566 :group 'gnus-summary-sort
567 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
568 (function-item gnus-thread-sort-by-author)
569 (function-item gnus-thread-sort-by-subject)
570 (function-item gnus-thread-sort-by-date)
571 (function-item gnus-thread-sort-by-score)
572 (function-item gnus-thread-sort-by-total-score)
573 (function :tag "other"))))
575 (defcustom gnus-thread-score-function '+
576 "*Function used for calculating the total score of a thread.
578 The function is called with the scores of the article and each
579 subthread and should then return the score of the thread.
581 Some functions you can use are `+', `max', or `min'."
582 :group 'gnus-summary-sort
585 (defcustom gnus-summary-expunge-below nil
586 "All articles that have a score less than this variable will be expunged.
587 This variable is local to the summary buffers."
588 :group 'gnus-score-default
589 :type '(choice (const :tag "off" nil)
592 (defcustom gnus-thread-expunge-below nil
593 "All threads that have a total score less than this variable will be expunged.
594 See `gnus-thread-score-function' for en explanation of what a
597 This variable is local to the summary buffers."
598 :group 'gnus-treading
599 :group 'gnus-score-default
600 :type '(choice (const :tag "off" nil)
603 (defcustom gnus-summary-mode-hook nil
604 "*A hook for Gnus summary mode.
605 This hook is run before any variables are set in the summary buffer."
606 :group 'gnus-summary-various
609 (defcustom gnus-summary-menu-hook nil
610 "*Hook run after the creation of the summary mode menu."
611 :group 'gnus-summary-visual
614 (defcustom gnus-summary-exit-hook nil
615 "*A hook called on exit from the summary buffer.
616 It will be called with point in the group buffer."
617 :group 'gnus-summary-exit
620 (defcustom gnus-summary-prepare-hook nil
621 "*A hook called after the summary buffer has been generated.
622 If you want to modify the summary buffer, you can use this hook."
623 :group 'gnus-summary-various
626 (defcustom gnus-summary-prepared-hook nil
627 "*A hook called as the last thing after the summary buffer has been generated."
628 :group 'gnus-summary-various
631 (defcustom gnus-summary-generate-hook nil
632 "*A hook run just before generating the summary buffer.
633 This hook is commonly used to customize threading variables and the
635 :group 'gnus-summary-various
638 (defcustom gnus-select-group-hook nil
639 "*A hook called when a newsgroup is selected.
641 If you'd like to simplify subjects like the
642 `gnus-summary-next-same-subject' command does, you can use the
645 (setq gnus-select-group-hook
648 (mapcar (lambda (header)
649 (mail-header-set-subject
651 (gnus-simplify-subject
652 (mail-header-subject header) 're-only)))
653 gnus-newsgroup-headers))))"
654 :group 'gnus-group-select
657 (defcustom gnus-select-article-hook nil
658 "*A hook called when an article is selected."
659 :group 'gnus-summary-choose
662 (defcustom gnus-visual-mark-article-hook
663 (list 'gnus-highlight-selected-summary)
664 "*Hook run after selecting an article in the summary buffer.
665 It is meant to be used for highlighting the article in some way. It
666 is not run if `gnus-visual' is nil."
667 :group 'gnus-summary-visual
670 (defcustom gnus-structured-field-decoder
671 #'eword-decode-and-unfold-structured-field
672 "Function to decode non-ASCII characters in structured field for summary."
676 (defcustom gnus-unstructured-field-decoder
679 (eword-decode-unstructured-field-body
680 (std11-unfold-string string) 'must-unfold)
682 "Function to decode non-ASCII characters in unstructured field for summary."
686 (defcustom gnus-parse-headers-hook
687 '(gnus-set-summary-default-charset)
688 "*A hook called before parsing the headers."
692 (defcustom gnus-exit-group-hook nil
693 "*A hook called when exiting (not quitting) summary mode."
697 (defcustom gnus-summary-update-hook
698 (list 'gnus-summary-highlight-line)
699 "*A hook called when a summary line is changed.
700 The hook will not be called if `gnus-visual' is nil.
702 The default function `gnus-summary-highlight-line' will
703 highlight the line according to the `gnus-summary-highlight'
705 :group 'gnus-summary-visual
708 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
709 "*A hook called when an article is selected for the first time.
710 The hook is intended to mark an article as read (or unread)
711 automatically when it is selected."
712 :group 'gnus-summary-choose
715 (defcustom gnus-group-no-more-groups-hook nil
716 "*A hook run when returning to group mode having no more (unread) groups."
717 :group 'gnus-group-select
720 (defcustom gnus-ps-print-hook nil
721 "*A hook run before ps-printing something from Gnus."
725 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
726 "Face used for highlighting the current article in the summary buffer."
727 :group 'gnus-summary-visual
730 (defcustom gnus-summary-highlight
731 '(((= mark gnus-canceled-mark)
732 . gnus-summary-cancelled-face)
733 ((and (> score default)
734 (or (= mark gnus-dormant-mark)
735 (= mark gnus-ticked-mark)))
736 . gnus-summary-high-ticked-face)
737 ((and (< score default)
738 (or (= mark gnus-dormant-mark)
739 (= mark gnus-ticked-mark)))
740 . gnus-summary-low-ticked-face)
741 ((or (= mark gnus-dormant-mark)
742 (= mark gnus-ticked-mark))
743 . gnus-summary-normal-ticked-face)
744 ((and (> score default) (= mark gnus-ancient-mark))
745 . gnus-summary-high-ancient-face)
746 ((and (< score default) (= mark gnus-ancient-mark))
747 . gnus-summary-low-ancient-face)
748 ((= mark gnus-ancient-mark)
749 . gnus-summary-normal-ancient-face)
750 ((and (> score default) (= mark gnus-unread-mark))
751 . gnus-summary-high-unread-face)
752 ((and (< score default) (= mark gnus-unread-mark))
753 . gnus-summary-low-unread-face)
754 ((= mark gnus-unread-mark)
755 . gnus-summary-normal-unread-face)
756 ((and (> score default) (memq mark (list gnus-downloadable-mark
757 gnus-undownloaded-mark)))
758 . gnus-summary-high-unread-face)
759 ((and (< score default) (memq mark (list gnus-downloadable-mark
760 gnus-undownloaded-mark)))
761 . gnus-summary-low-unread-face)
762 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
763 . gnus-summary-normal-unread-face)
765 . gnus-summary-high-read-face)
767 . gnus-summary-low-read-face)
769 . gnus-summary-normal-read-face))
770 "*Controls the highlighting of summary buffer lines.
772 A list of (FORM . FACE) pairs. When deciding how a a particular
773 summary line should be displayed, each form is evaluated. The content
774 of the face field after the first true form is used. You can change
775 how those summary lines are displayed, by editing the face field.
777 You can use the following variables in the FORM field.
779 score: The articles score
780 default: The default article score.
781 below: The score below which articles are automatically marked as read.
782 mark: The articles mark."
783 :group 'gnus-summary-visual
784 :type '(repeat (cons (sexp :tag "Form" nil)
787 (defcustom gnus-alter-header-function nil
788 "Function called to allow alteration of article header structures.
789 The function is called with one parameter, the article header vector,
790 which it may alter in any way.")
792 ;;; Internal variables
794 (defvar gnus-scores-exclude-files nil)
795 (defvar gnus-page-broken nil)
797 (defvar gnus-original-article nil)
798 (defvar gnus-article-internal-prepare-hook nil)
799 (defvar gnus-newsgroup-process-stack nil)
801 (defvar gnus-thread-indent-array nil)
802 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
804 ;; Avoid highlighting in kill files.
805 (defvar gnus-summary-inhibit-highlight nil)
806 (defvar gnus-newsgroup-selected-overlay nil)
807 (defvar gnus-inhibit-limiting nil)
808 (defvar gnus-newsgroup-adaptive-score-file nil)
809 (defvar gnus-current-score-file nil)
810 (defvar gnus-current-move-group nil)
811 (defvar gnus-current-copy-group nil)
812 (defvar gnus-current-crosspost-group nil)
814 (defvar gnus-newsgroup-dependencies nil)
815 (defvar gnus-newsgroup-adaptive nil)
816 (defvar gnus-summary-display-article-function nil)
817 (defvar gnus-summary-highlight-line-function nil
818 "Function called after highlighting a summary line.")
820 (defvar gnus-summary-line-format-alist
821 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
822 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
823 (?s gnus-tmp-subject-or-nil ?s)
824 (?n gnus-tmp-name ?s)
825 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
827 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
829 (?F gnus-tmp-from ?s)
830 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
831 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
832 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
833 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
834 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
835 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
836 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
837 (?L gnus-tmp-lines ?d)
838 (?I gnus-tmp-indentation ?s)
839 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
840 (?R gnus-tmp-replied ?c)
841 (?\[ gnus-tmp-opening-bracket ?c)
842 (?\] gnus-tmp-closing-bracket ?c)
843 (?\> (make-string gnus-tmp-level ? ) ?s)
844 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
845 (?i gnus-tmp-score ?d)
846 (?z gnus-tmp-score-char ?c)
847 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
848 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
849 (?U gnus-tmp-unread ?c)
850 (?t (gnus-summary-number-of-articles-in-thread
851 (and (boundp 'thread) (car thread)) gnus-tmp-level)
853 (?e (gnus-summary-number-of-articles-in-thread
854 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
856 (?u gnus-tmp-user-defined ?s)
857 (?P (gnus-pick-line-number) ?d))
858 "An alist of format specifications that can appear in summary lines,
859 and what variables they correspond with, along with the type of the
860 variable (string, integer, character, etc).")
862 (defvar gnus-summary-dummy-line-format-alist
863 `((?S gnus-tmp-subject ?s)
864 (?N gnus-tmp-number ?d)
865 (?u gnus-tmp-user-defined ?s)))
867 (defvar gnus-summary-mode-line-format-alist
868 `((?G gnus-tmp-group-name ?s)
869 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
870 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
871 (?A gnus-tmp-article-number ?d)
872 (?Z gnus-tmp-unread-and-unselected ?s)
874 (?U gnus-tmp-unread-and-unticked ?d)
875 (?S gnus-tmp-subject ?s)
876 (?e gnus-tmp-unselected ?d)
877 (?u gnus-tmp-user-defined ?s)
878 (?d (length gnus-newsgroup-dormant) ?d)
879 (?t (length gnus-newsgroup-marked) ?d)
880 (?r (length gnus-newsgroup-reads) ?d)
881 (?E gnus-newsgroup-expunged-tally ?d)
882 (?s (gnus-current-score-file-nondirectory) ?s)))
884 (defvar gnus-last-search-regexp nil
885 "Default regexp for article search command.")
887 (defvar gnus-last-shell-command nil
888 "Default shell command on article.")
890 (defvar gnus-newsgroup-begin nil)
891 (defvar gnus-newsgroup-end nil)
892 (defvar gnus-newsgroup-last-rmail nil)
893 (defvar gnus-newsgroup-last-mail nil)
894 (defvar gnus-newsgroup-last-folder nil)
895 (defvar gnus-newsgroup-last-file nil)
896 (defvar gnus-newsgroup-auto-expire nil)
897 (defvar gnus-newsgroup-active nil)
899 (defvar gnus-newsgroup-data nil)
900 (defvar gnus-newsgroup-data-reverse nil)
901 (defvar gnus-newsgroup-limit nil)
902 (defvar gnus-newsgroup-limits nil)
904 (defvar gnus-newsgroup-unreads nil
905 "List of unread articles in the current newsgroup.")
907 (defvar gnus-newsgroup-unselected nil
908 "List of unselected unread articles in the current newsgroup.")
910 (defvar gnus-newsgroup-reads nil
911 "Alist of read articles and article marks in the current newsgroup.")
913 (defvar gnus-newsgroup-expunged-tally nil)
915 (defvar gnus-newsgroup-marked nil
916 "List of ticked articles in the current newsgroup (a subset of unread art).")
918 (defvar gnus-newsgroup-killed nil
919 "List of ranges of articles that have been through the scoring process.")
921 (defvar gnus-newsgroup-cached nil
922 "List of articles that come from the article cache.")
924 (defvar gnus-newsgroup-saved nil
925 "List of articles that have been saved.")
927 (defvar gnus-newsgroup-kill-headers nil)
929 (defvar gnus-newsgroup-replied nil
930 "List of articles that have been replied to in the current newsgroup.")
932 (defvar gnus-newsgroup-expirable nil
933 "List of articles in the current newsgroup that can be expired.")
935 (defvar gnus-newsgroup-processable nil
936 "List of articles in the current newsgroup that can be processed.")
938 (defvar gnus-newsgroup-downloadable nil
939 "List of articles in the current newsgroup that can be processed.")
941 (defvar gnus-newsgroup-undownloaded nil
942 "List of articles in the current newsgroup that haven't been downloaded..")
944 (defvar gnus-newsgroup-unsendable nil
945 "List of articles in the current newsgroup that won't be sent.")
947 (defvar gnus-newsgroup-bookmarks nil
948 "List of articles in the current newsgroup that have bookmarks.")
950 (defvar gnus-newsgroup-dormant nil
951 "List of dormant articles in the current newsgroup.")
953 (defvar gnus-newsgroup-scored nil
954 "List of scored articles in the current newsgroup.")
956 (defvar gnus-newsgroup-headers nil
957 "List of article headers in the current newsgroup.")
959 (defvar gnus-newsgroup-threads nil)
961 (defvar gnus-newsgroup-prepared nil
962 "Whether the current group has been prepared properly.")
964 (defvar gnus-newsgroup-ancient nil
965 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
967 (defvar gnus-newsgroup-sparse nil)
969 (defvar gnus-current-article nil)
970 (defvar gnus-article-current nil)
971 (defvar gnus-current-headers nil)
972 (defvar gnus-have-all-headers nil)
973 (defvar gnus-last-article nil)
974 (defvar gnus-newsgroup-history nil)
976 (defconst gnus-summary-local-variables
977 '(gnus-newsgroup-name
978 gnus-newsgroup-begin gnus-newsgroup-end
979 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
980 gnus-newsgroup-last-folder gnus-newsgroup-last-file
981 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
982 gnus-newsgroup-unselected gnus-newsgroup-marked
983 gnus-newsgroup-reads gnus-newsgroup-saved
984 gnus-newsgroup-replied gnus-newsgroup-expirable
985 gnus-newsgroup-processable gnus-newsgroup-killed
986 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
987 gnus-newsgroup-unsendable
988 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
989 gnus-newsgroup-headers gnus-newsgroup-threads
990 gnus-newsgroup-prepared gnus-summary-highlight-line-function
991 gnus-current-article gnus-current-headers gnus-have-all-headers
992 gnus-last-article gnus-article-internal-prepare-hook
993 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
994 gnus-newsgroup-scored gnus-newsgroup-kill-headers
995 gnus-thread-expunge-below
996 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
997 (gnus-summary-mark-below . global)
998 gnus-newsgroup-active gnus-scores-exclude-files
999 gnus-newsgroup-history gnus-newsgroup-ancient
1000 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1001 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1002 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1003 (gnus-newsgroup-expunged-tally . 0)
1004 gnus-cache-removable-articles gnus-newsgroup-cached
1005 gnus-newsgroup-data gnus-newsgroup-data-reverse
1006 gnus-newsgroup-limit gnus-newsgroup-limits)
1007 "Variables that are buffer-local to the summary buffers.")
1009 ;; Byte-compiler warning.
1010 (defvar gnus-article-mode-map)
1012 ;; Subject simplification.
1014 (defun gnus-simplify-whitespace (str)
1015 "Remove excessive whitespace."
1018 (while (string-match "[ \t][ \t]+" mystr)
1019 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1021 (substring mystr (match-end 0)))))
1023 (when (string-match "^[ \t]+" mystr)
1024 (setq mystr (substring mystr (match-end 0))))
1026 (when (string-match "[ \t]+$" mystr)
1027 (setq mystr (substring mystr 0 (match-beginning 0))))
1030 (defsubst gnus-simplify-subject-re (subject)
1031 "Remove \"Re:\" from subject lines."
1032 (if (string-match "^[Rr][Ee]: *" subject)
1033 (substring subject (match-end 0))
1036 (defun gnus-simplify-subject (subject &optional re-only)
1037 "Remove `Re:' and words in parentheses.
1038 If RE-ONLY is non-nil, strip leading `Re:'s only."
1039 (let ((case-fold-search t)) ;Ignore case.
1040 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1041 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1042 (setq subject (substring subject (match-end 0))))
1043 ;; Remove uninteresting prefixes.
1044 (when (and (not re-only)
1045 gnus-simplify-ignored-prefixes
1046 (string-match gnus-simplify-ignored-prefixes subject))
1047 (setq subject (substring subject (match-end 0))))
1048 ;; Remove words in parentheses from end.
1050 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1051 (setq subject (substring subject 0 (match-beginning 0)))))
1052 ;; Return subject string.
1055 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1057 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1058 (goto-char (point-min))
1059 (while (re-search-forward regexp nil t)
1060 (replace-match (or newtext ""))))
1062 (defun gnus-simplify-buffer-fuzzy ()
1063 "Simplify string in the buffer fuzzily.
1064 The string in the accessible portion of the current buffer is simplified.
1065 It is assumed to be a single-line subject.
1066 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1067 matter is removed. Additional things can be deleted by setting
1068 gnus-simplify-subject-fuzzy-regexp."
1069 (let ((case-fold-search t)
1071 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1073 (while (not (eq modified-tick (buffer-modified-tick)))
1074 (setq modified-tick (buffer-modified-tick))
1076 ((listp gnus-simplify-subject-fuzzy-regexp)
1077 (mapcar 'gnus-simplify-buffer-fuzzy-step
1078 gnus-simplify-subject-fuzzy-regexp))
1079 (gnus-simplify-subject-fuzzy-regexp
1080 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1081 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1082 (gnus-simplify-buffer-fuzzy-step
1083 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1084 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1086 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1087 (gnus-simplify-buffer-fuzzy-step " +" " ")
1088 (gnus-simplify-buffer-fuzzy-step " $")
1089 (gnus-simplify-buffer-fuzzy-step "^ +")))
1091 (defun gnus-simplify-subject-fuzzy (subject)
1092 "Simplify a subject string fuzzily.
1093 See `gnus-simplify-buffer-fuzzy' for details."
1095 (gnus-set-work-buffer)
1096 (let ((case-fold-search t))
1097 ;; Remove uninteresting prefixes.
1098 (when (and gnus-simplify-ignored-prefixes
1099 (string-match gnus-simplify-ignored-prefixes subject))
1100 (setq subject (substring subject (match-end 0))))
1102 (inline (gnus-simplify-buffer-fuzzy))
1105 (defsubst gnus-simplify-subject-fully (subject)
1106 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1108 (gnus-simplify-subject-functions
1109 (gnus-map-function gnus-simplify-subject-functions subject))
1110 ((null gnus-summary-gather-subject-limit)
1111 (gnus-simplify-subject-re subject))
1112 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1113 (gnus-simplify-subject-fuzzy subject))
1114 ((numberp gnus-summary-gather-subject-limit)
1115 (gnus-limit-string (gnus-simplify-subject-re subject)
1116 gnus-summary-gather-subject-limit))
1120 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1121 "Check whether two subjects are equal.
1122 If optional argument simple-first is t, first argument is already
1125 ((null simple-first)
1126 (equal (gnus-simplify-subject-fully s1)
1127 (gnus-simplify-subject-fully s2)))
1130 (gnus-simplify-subject-fully s2)))))
1132 (defun gnus-summary-bubble-group ()
1133 "Increase the score of the current group.
1134 This is a handy function to add to `gnus-summary-exit-hook' to
1135 increase the score of each group you read."
1136 (gnus-group-add-score gnus-newsgroup-name))
1140 ;;; Gnus summary mode
1143 (put 'gnus-summary-mode 'mode-class 'special)
1146 ;; Non-orthogonal keys
1148 (gnus-define-keys gnus-summary-mode-map
1149 " " gnus-summary-next-page
1150 "\177" gnus-summary-prev-page
1151 [delete] gnus-summary-prev-page
1152 [backspace] gnus-summary-prev-page
1153 "\r" gnus-summary-scroll-up
1154 "\e\r" gnus-summary-scroll-down
1155 "n" gnus-summary-next-unread-article
1156 "p" gnus-summary-prev-unread-article
1157 "N" gnus-summary-next-article
1158 "P" gnus-summary-prev-article
1159 "\M-\C-n" gnus-summary-next-same-subject
1160 "\M-\C-p" gnus-summary-prev-same-subject
1161 "\M-n" gnus-summary-next-unread-subject
1162 "\M-p" gnus-summary-prev-unread-subject
1163 "." gnus-summary-first-unread-article
1164 "," gnus-summary-best-unread-article
1165 "\M-s" gnus-summary-search-article-forward
1166 "\M-r" gnus-summary-search-article-backward
1167 "<" gnus-summary-beginning-of-article
1168 ">" gnus-summary-end-of-article
1169 "j" gnus-summary-goto-article
1170 "^" gnus-summary-refer-parent-article
1171 "\M-^" gnus-summary-refer-article
1172 "u" gnus-summary-tick-article-forward
1173 "!" gnus-summary-tick-article-forward
1174 "U" gnus-summary-tick-article-backward
1175 "d" gnus-summary-mark-as-read-forward
1176 "D" gnus-summary-mark-as-read-backward
1177 "E" gnus-summary-mark-as-expirable
1178 "\M-u" gnus-summary-clear-mark-forward
1179 "\M-U" gnus-summary-clear-mark-backward
1180 "k" gnus-summary-kill-same-subject-and-select
1181 "\C-k" gnus-summary-kill-same-subject
1182 "\M-\C-k" gnus-summary-kill-thread
1183 "\M-\C-l" gnus-summary-lower-thread
1184 "e" gnus-summary-edit-article
1185 "#" gnus-summary-mark-as-processable
1186 "\M-#" gnus-summary-unmark-as-processable
1187 "\M-\C-t" gnus-summary-toggle-threads
1188 "\M-\C-s" gnus-summary-show-thread
1189 "\M-\C-h" gnus-summary-hide-thread
1190 "\M-\C-f" gnus-summary-next-thread
1191 "\M-\C-b" gnus-summary-prev-thread
1192 "\M-\C-u" gnus-summary-up-thread
1193 "\M-\C-d" gnus-summary-down-thread
1194 "&" gnus-summary-execute-command
1195 "c" gnus-summary-catchup-and-exit
1196 "\C-w" gnus-summary-mark-region-as-read
1197 "\C-t" gnus-summary-toggle-truncation
1198 "?" gnus-summary-mark-as-dormant
1199 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1200 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1201 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1202 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1203 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1204 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1205 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1206 "=" gnus-summary-expand-window
1207 "\C-x\C-s" gnus-summary-reselect-current-group
1208 "\M-g" gnus-summary-rescan-group
1209 "w" gnus-summary-stop-page-breaking
1210 "\C-c\C-r" gnus-summary-caesar-message
1211 "\M-t" gnus-summary-toggle-mime
1212 "f" gnus-summary-followup
1213 "F" gnus-summary-followup-with-original
1214 "C" gnus-summary-cancel-article
1215 "r" gnus-summary-reply
1216 "R" gnus-summary-reply-with-original
1217 "\C-c\C-f" gnus-summary-mail-forward
1218 "o" gnus-summary-save-article
1219 "\C-o" gnus-summary-save-article-mail
1220 "|" gnus-summary-pipe-output
1221 "\M-k" gnus-summary-edit-local-kill
1222 "\M-K" gnus-summary-edit-global-kill
1224 "\C-c\C-d" gnus-summary-describe-group
1225 "q" gnus-summary-exit
1226 "Q" gnus-summary-exit-no-update
1227 "\C-c\C-i" gnus-info-find-node
1228 gnus-mouse-2 gnus-mouse-pick-article
1229 "m" gnus-summary-mail-other-window
1230 "a" gnus-summary-post-news
1231 "x" gnus-summary-limit-to-unread
1232 "s" gnus-summary-isearch-article
1233 "t" gnus-article-hide-headers
1234 "g" gnus-summary-show-article
1235 "l" gnus-summary-goto-last-article
1236 "v" gnus-summary-preview-mime-message
1237 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1238 "\C-d" gnus-summary-enter-digest-group
1239 "\M-\C-d" gnus-summary-read-document
1240 "\M-\C-e" gnus-summary-edit-parameters
1242 "*" gnus-cache-enter-article
1243 "\M-*" gnus-cache-remove-article
1244 "\M-&" gnus-summary-universal-argument
1245 "\C-l" gnus-recenter
1246 "I" gnus-summary-increase-score
1247 "L" gnus-summary-lower-score
1248 "\M-i" gnus-symbolic-argument
1249 "h" gnus-summary-select-article-buffer
1251 "V" gnus-summary-score-map
1252 "X" gnus-uu-extract-map
1253 "S" gnus-summary-send-map)
1255 ;; Sort of orthogonal keymap
1256 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1257 "t" gnus-summary-tick-article-forward
1258 "!" gnus-summary-tick-article-forward
1259 "d" gnus-summary-mark-as-read-forward
1260 "r" gnus-summary-mark-as-read-forward
1261 "c" gnus-summary-clear-mark-forward
1262 " " gnus-summary-clear-mark-forward
1263 "e" gnus-summary-mark-as-expirable
1264 "x" gnus-summary-mark-as-expirable
1265 "?" gnus-summary-mark-as-dormant
1266 "b" gnus-summary-set-bookmark
1267 "B" gnus-summary-remove-bookmark
1268 "#" gnus-summary-mark-as-processable
1269 "\M-#" gnus-summary-unmark-as-processable
1270 "S" gnus-summary-limit-include-expunged
1271 "C" gnus-summary-catchup
1272 "H" gnus-summary-catchup-to-here
1273 "\C-c" gnus-summary-catchup-all
1274 "k" gnus-summary-kill-same-subject-and-select
1275 "K" gnus-summary-kill-same-subject
1276 "P" gnus-uu-mark-map)
1278 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1279 "c" gnus-summary-clear-above
1280 "u" gnus-summary-tick-above
1281 "m" gnus-summary-mark-above
1282 "k" gnus-summary-kill-below)
1284 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1285 "/" gnus-summary-limit-to-subject
1286 "n" gnus-summary-limit-to-articles
1287 "w" gnus-summary-pop-limit
1288 "s" gnus-summary-limit-to-subject
1289 "a" gnus-summary-limit-to-author
1290 "u" gnus-summary-limit-to-unread
1291 "m" gnus-summary-limit-to-marks
1292 "v" gnus-summary-limit-to-score
1293 "*" gnus-summary-limit-include-cached
1294 "D" gnus-summary-limit-include-dormant
1295 "T" gnus-summary-limit-include-thread
1296 "d" gnus-summary-limit-exclude-dormant
1297 "t" gnus-summary-limit-to-age
1298 "E" gnus-summary-limit-include-expunged
1299 "c" gnus-summary-limit-exclude-childless-dormant
1300 "C" gnus-summary-limit-mark-excluded-as-read)
1302 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1303 "n" gnus-summary-next-unread-article
1304 "p" gnus-summary-prev-unread-article
1305 "N" gnus-summary-next-article
1306 "P" gnus-summary-prev-article
1307 "\C-n" gnus-summary-next-same-subject
1308 "\C-p" gnus-summary-prev-same-subject
1309 "\M-n" gnus-summary-next-unread-subject
1310 "\M-p" gnus-summary-prev-unread-subject
1311 "f" gnus-summary-first-unread-article
1312 "b" gnus-summary-best-unread-article
1313 "j" gnus-summary-goto-article
1314 "g" gnus-summary-goto-subject
1315 "l" gnus-summary-goto-last-article
1316 "o" gnus-summary-pop-article)
1318 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1319 "k" gnus-summary-kill-thread
1320 "l" gnus-summary-lower-thread
1321 "i" gnus-summary-raise-thread
1322 "T" gnus-summary-toggle-threads
1323 "t" gnus-summary-rethread-current
1324 "^" gnus-summary-reparent-thread
1325 "s" gnus-summary-show-thread
1326 "S" gnus-summary-show-all-threads
1327 "h" gnus-summary-hide-thread
1328 "H" gnus-summary-hide-all-threads
1329 "n" gnus-summary-next-thread
1330 "p" gnus-summary-prev-thread
1331 "u" gnus-summary-up-thread
1332 "o" gnus-summary-top-thread
1333 "d" gnus-summary-down-thread
1334 "#" gnus-uu-mark-thread
1335 "\M-#" gnus-uu-unmark-thread)
1337 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1338 "g" gnus-summary-prepare
1339 "c" gnus-summary-insert-cached-articles)
1341 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1342 "c" gnus-summary-catchup-and-exit
1343 "C" gnus-summary-catchup-all-and-exit
1344 "E" gnus-summary-exit-no-update
1345 "Q" gnus-summary-exit
1346 "Z" gnus-summary-exit
1347 "n" gnus-summary-catchup-and-goto-next-group
1348 "R" gnus-summary-reselect-current-group
1349 "G" gnus-summary-rescan-group
1350 "N" gnus-summary-next-group
1351 "s" gnus-summary-save-newsrc
1352 "P" gnus-summary-prev-group)
1354 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1355 " " gnus-summary-next-page
1356 "n" gnus-summary-next-page
1357 "\177" gnus-summary-prev-page
1358 [delete] gnus-summary-prev-page
1359 "p" gnus-summary-prev-page
1360 "\r" gnus-summary-scroll-up
1361 "<" gnus-summary-beginning-of-article
1362 ">" gnus-summary-end-of-article
1363 "b" gnus-summary-beginning-of-article
1364 "e" gnus-summary-end-of-article
1365 "^" gnus-summary-refer-parent-article
1366 "r" gnus-summary-refer-parent-article
1367 "R" gnus-summary-refer-references
1368 "T" gnus-summary-refer-thread
1369 "g" gnus-summary-show-article
1370 "s" gnus-summary-isearch-article
1371 "P" gnus-summary-print-article)
1373 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1374 "b" gnus-article-add-buttons
1375 "B" gnus-article-add-buttons-to-head
1376 "o" gnus-article-treat-overstrike
1377 "e" gnus-article-emphasize
1378 "w" gnus-article-fill-cited-article
1379 "c" gnus-article-remove-cr
1380 "f" gnus-article-display-x-face
1381 "l" gnus-summary-stop-page-breaking
1382 "r" gnus-summary-caesar-message
1383 "t" gnus-article-hide-headers
1384 "v" gnus-summary-verbose-headers
1385 "m" gnus-summary-toggle-mime
1386 "h" gnus-article-treat-html
1387 "d" gnus-article-treat-dumbquotes)
1389 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1390 "a" gnus-article-hide
1391 "h" gnus-article-hide-headers
1392 "b" gnus-article-hide-boring-headers
1393 "s" gnus-article-hide-signature
1394 "c" gnus-article-hide-citation
1395 "p" gnus-article-hide-pgp
1396 "P" gnus-article-hide-pem
1397 "\C-c" gnus-article-hide-citation-maybe)
1399 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1400 "a" gnus-article-highlight
1401 "h" gnus-article-highlight-headers
1402 "c" gnus-article-highlight-citation
1403 "s" gnus-article-highlight-signature)
1405 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1406 "z" gnus-article-date-ut
1407 "u" gnus-article-date-ut
1408 "l" gnus-article-date-local
1409 "e" gnus-article-date-lapsed
1410 "o" gnus-article-date-original
1411 "i" gnus-article-date-iso8601
1412 "s" gnus-article-date-user)
1414 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1415 "t" gnus-article-remove-trailing-blank-lines
1416 "l" gnus-article-strip-leading-blank-lines
1417 "m" gnus-article-strip-multiple-blank-lines
1418 "a" gnus-article-strip-blank-lines
1419 "A" gnus-article-strip-all-blank-lines
1420 "s" gnus-article-strip-leading-space)
1422 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1424 "f" gnus-summary-fetch-faq
1425 "d" gnus-summary-describe-group
1426 "h" gnus-summary-describe-briefly
1427 "i" gnus-info-find-node)
1429 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1430 "e" gnus-summary-expire-articles
1431 "\M-\C-e" gnus-summary-expire-articles-now
1432 "\177" gnus-summary-delete-article
1433 [delete] gnus-summary-delete-article
1434 "m" gnus-summary-move-article
1435 "r" gnus-summary-respool-article
1436 "w" gnus-summary-edit-article
1437 "c" gnus-summary-copy-article
1438 "B" gnus-summary-crosspost-article
1439 "q" gnus-summary-respool-query
1440 "i" gnus-summary-import-article
1441 "p" gnus-summary-article-posted-p)
1443 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1444 "o" gnus-summary-save-article
1445 "m" gnus-summary-save-article-mail
1446 "F" gnus-summary-write-article-file
1447 "r" gnus-summary-save-article-rmail
1448 "f" gnus-summary-save-article-file
1449 "b" gnus-summary-save-article-body-file
1450 "h" gnus-summary-save-article-folder
1451 "v" gnus-summary-save-article-vm
1452 "p" gnus-summary-pipe-output
1453 "s" gnus-soup-add-article))
1455 (defun gnus-summary-make-menu-bar ()
1456 (gnus-turn-off-edit-menu 'summary)
1458 (unless (boundp 'gnus-summary-misc-menu)
1461 gnus-summary-kill-menu gnus-summary-mode-map ""
1466 ["Enter score..." gnus-summary-score-entry t]
1467 ["Customize" gnus-score-customize t])
1468 (gnus-make-score-map 'increase)
1469 (gnus-make-score-map 'lower)
1471 ["Kill below" gnus-summary-kill-below t]
1472 ["Mark above" gnus-summary-mark-above t]
1473 ["Tick above" gnus-summary-tick-above t]
1474 ["Clear above" gnus-summary-clear-above t])
1475 ["Current score" gnus-summary-current-score t]
1476 ["Set score" gnus-summary-set-score t]
1477 ["Switch current score file..." gnus-score-change-score-file t]
1478 ["Set mark below..." gnus-score-set-mark-below t]
1479 ["Set expunge below..." gnus-score-set-expunge-below t]
1480 ["Edit current score file" gnus-score-edit-current-scores t]
1481 ["Edit score file" gnus-score-edit-file t]
1482 ["Trace score" gnus-score-find-trace t]
1483 ["Find words" gnus-score-find-favourite-words t]
1484 ["Rescore buffer" gnus-summary-rescore t]
1485 ["Increase score..." gnus-summary-increase-score t]
1486 ["Lower score..." gnus-summary-lower-score t]))))
1489 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1491 :selected (null gnus-score-default-header)]
1492 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1494 :selected (eq gnus-score-default-header 'a)]
1495 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1497 :selected (eq gnus-score-default-header 's)]
1499 (gnus-score-set-default 'gnus-score-default-header 'b)
1501 :selected (eq gnus-score-default-header 'b )]
1503 (gnus-score-set-default 'gnus-score-default-header 'h)
1505 :selected (eq gnus-score-default-header 'h )]
1506 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1508 :selected (eq gnus-score-default-header 'i )]
1509 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1511 :selected (eq gnus-score-default-header 't )]
1513 (gnus-score-set-default 'gnus-score-default-header 'x)
1515 :selected (eq gnus-score-default-header 'x )]
1516 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1518 :selected (eq gnus-score-default-header 'l )]
1519 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1521 :selected (eq gnus-score-default-header 'd )]
1522 ["Followups to author"
1523 (gnus-score-set-default 'gnus-score-default-header 'f)
1525 :selected (eq gnus-score-default-header 'f )])
1527 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1529 :selected (null gnus-score-default-type)]
1530 ;; The `:active' key is commented out in the following,
1531 ;; because the GNU Emacs hack to support radio buttons use
1532 ;; active to indicate which button is selected.
1533 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1535 ;; :active (not (memq gnus-score-default-header '(l d)))
1536 :selected (eq gnus-score-default-type 's)]
1537 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1539 ;; :active (not (memq gnus-score-default-header '(l d)))
1540 :selected (eq gnus-score-default-type 'r)]
1541 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1543 ;; :active (not (memq gnus-score-default-header '(l d)))
1544 :selected (eq gnus-score-default-type 'e)]
1545 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1547 ;; :active (not (memq gnus-score-default-header '(l d)))
1548 :selected (eq gnus-score-default-type 'f)]
1549 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1551 ;; :active (eq (gnus-score-default-header 'd))
1552 :selected (eq gnus-score-default-type 'b)]
1553 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1555 ;; :active (eq (gnus-score-default-header 'd))
1556 :selected (eq gnus-score-default-type 'n)]
1557 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1559 ;; :active (eq (gnus-score-default-header 'd))
1560 :selected (eq gnus-score-default-type 'a)]
1562 (gnus-score-set-default 'gnus-score-default-type '<)
1564 ;; :active (eq (gnus-score-default-header 'l))
1565 :selected (eq gnus-score-default-type '<)]
1567 (gnus-score-set-default 'gnus-score-default-type '=)
1569 ;; :active (eq (gnus-score-default-header 'l))
1570 :selected (eq gnus-score-default-type '=)]
1571 ["Greater than number"
1572 (gnus-score-set-default 'gnus-score-default-type '>)
1574 ;; :active (eq (gnus-score-default-header 'l))
1575 :selected (eq gnus-score-default-type '>)])
1576 ["Default fold" gnus-score-default-fold-toggle
1578 :selected gnus-score-default-fold]
1580 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1582 :selected (null gnus-score-default-duration)]
1584 (gnus-score-set-default 'gnus-score-default-duration 'p)
1586 :selected (eq gnus-score-default-duration 'p)]
1588 (gnus-score-set-default 'gnus-score-default-duration 't)
1590 :selected (eq gnus-score-default-duration 't)]
1592 (gnus-score-set-default 'gnus-score-default-duration 'i)
1594 :selected (eq gnus-score-default-duration 'i)]))
1597 gnus-summary-article-menu gnus-summary-mode-map ""
1600 ["All" gnus-article-hide t]
1601 ["Headers" gnus-article-hide-headers t]
1602 ["Signature" gnus-article-hide-signature t]
1603 ["Citation" gnus-article-hide-citation t]
1604 ["PGP" gnus-article-hide-pgp t]
1605 ["Boring headers" gnus-article-hide-boring-headers t])
1607 ["All" gnus-article-highlight t]
1608 ["Headers" gnus-article-highlight-headers t]
1609 ["Signature" gnus-article-highlight-signature t]
1610 ["Citation" gnus-article-highlight-citation t])
1612 ["Local" gnus-article-date-local t]
1613 ["ISO8601" gnus-article-date-iso8601 t]
1614 ["UT" gnus-article-date-ut t]
1615 ["Original" gnus-article-date-original t]
1616 ["Lapsed" gnus-article-date-lapsed t]
1617 ["User-defined" gnus-article-date-user t])
1620 ["Leading" gnus-article-strip-leading-blank-lines t]
1621 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1622 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1623 ["All of the above" gnus-article-strip-blank-lines t]
1624 ["All" gnus-article-strip-all-blank-lines t]
1625 ["Leading space" gnus-article-strip-leading-space t])
1626 ["Overstrike" gnus-article-treat-overstrike t]
1627 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1628 ["Emphasis" gnus-article-emphasize t]
1629 ["Word wrap" gnus-article-fill-cited-article t]
1630 ["CR" gnus-article-remove-cr t]
1631 ["Show X-Face" gnus-article-display-x-face t]
1632 ["UnHTMLize" gnus-article-treat-html t]
1633 ["Rot 13" gnus-summary-caesar-message t]
1634 ["Unix pipe" gnus-summary-pipe-message t]
1635 ["Add buttons" gnus-article-add-buttons t]
1636 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1637 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1638 ["Toggle MIME" gnus-summary-toggle-mime t]
1639 ["Verbose header" gnus-summary-verbose-headers t]
1640 ["Toggle header" gnus-summary-toggle-header t])
1642 ["Save in default format" gnus-summary-save-article t]
1643 ["Save in file" gnus-summary-save-article-file t]
1644 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1645 ["Save in MH folder" gnus-summary-save-article-folder t]
1646 ["Save in VM folder" gnus-summary-save-article-vm t]
1647 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1648 ["Save body in file" gnus-summary-save-article-body-file t]
1649 ["Pipe through a filter" gnus-summary-pipe-output t]
1650 ["Add to SOUP packet" gnus-soup-add-article t]
1651 ["Print" gnus-summary-print-article t])
1653 ["Respool article..." gnus-summary-respool-article t]
1654 ["Move article..." gnus-summary-move-article
1655 (gnus-check-backend-function
1656 'request-move-article gnus-newsgroup-name)]
1657 ["Copy article..." gnus-summary-copy-article t]
1658 ["Crosspost article..." gnus-summary-crosspost-article
1659 (gnus-check-backend-function
1660 'request-replace-article gnus-newsgroup-name)]
1661 ["Import file..." gnus-summary-import-article t]
1662 ["Check if posted" gnus-summary-article-posted-p t]
1663 ["Edit article" gnus-summary-edit-article
1664 (not (gnus-group-read-only-p))]
1665 ["Delete article" gnus-summary-delete-article
1666 (gnus-check-backend-function
1667 'request-expire-articles gnus-newsgroup-name)]
1668 ["Query respool" gnus-summary-respool-query t]
1669 ["Delete expirable articles" gnus-summary-expire-articles-now
1670 (gnus-check-backend-function
1671 'request-expire-articles gnus-newsgroup-name)])
1673 ["Uudecode" gnus-uu-decode-uu t]
1674 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1675 ["Unshar" gnus-uu-decode-unshar t]
1676 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1677 ["Save" gnus-uu-decode-save t]
1678 ["Binhex" gnus-uu-decode-binhex t]
1679 ["Postscript" gnus-uu-decode-postscript t])
1681 ["Enter article" gnus-cache-enter-article t]
1682 ["Remove article" gnus-cache-remove-article t])
1683 ["Select article buffer" gnus-summary-select-article-buffer t]
1684 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1685 ["Isearch article..." gnus-summary-isearch-article t]
1686 ["Beginning of the article" gnus-summary-beginning-of-article t]
1687 ["End of the article" gnus-summary-end-of-article t]
1688 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1689 ["Fetch referenced articles" gnus-summary-refer-references t]
1690 ["Fetch current thread" gnus-summary-refer-thread t]
1691 ["Fetch article with id..." gnus-summary-refer-article t]
1692 ["Redisplay" gnus-summary-show-article t]))
1695 gnus-summary-thread-menu gnus-summary-mode-map ""
1697 ["Toggle threading" gnus-summary-toggle-threads t]
1698 ["Hide threads" gnus-summary-hide-all-threads t]
1699 ["Show threads" gnus-summary-show-all-threads t]
1700 ["Hide thread" gnus-summary-hide-thread t]
1701 ["Show thread" gnus-summary-show-thread t]
1702 ["Go to next thread" gnus-summary-next-thread t]
1703 ["Go to previous thread" gnus-summary-prev-thread t]
1704 ["Go down thread" gnus-summary-down-thread t]
1705 ["Go up thread" gnus-summary-up-thread t]
1706 ["Top of thread" gnus-summary-top-thread t]
1707 ["Mark thread as read" gnus-summary-kill-thread t]
1708 ["Lower thread score" gnus-summary-lower-thread t]
1709 ["Raise thread score" gnus-summary-raise-thread t]
1710 ["Rethread current" gnus-summary-rethread-current t]
1714 gnus-summary-post-menu gnus-summary-mode-map ""
1716 ["Post an article" gnus-summary-post-news t]
1717 ["Followup" gnus-summary-followup t]
1718 ["Followup and yank" gnus-summary-followup-with-original t]
1719 ["Supersede article" gnus-summary-supersede-article t]
1720 ["Cancel article" gnus-summary-cancel-article t]
1721 ["Reply" gnus-summary-reply t]
1722 ["Reply and yank" gnus-summary-reply-with-original t]
1723 ["Wide reply" gnus-summary-wide-reply t]
1724 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1725 ["Mail forward" gnus-summary-mail-forward t]
1726 ["Post forward" gnus-summary-post-forward t]
1727 ["Digest and mail" gnus-uu-digest-mail-forward t]
1728 ["Digest and post" gnus-uu-digest-post-forward t]
1729 ["Resend message" gnus-summary-resend-message t]
1730 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1731 ["Send a mail" gnus-summary-mail-other-window t]
1732 ["Uuencode and post" gnus-uu-post-news t]
1733 ["Followup via news" gnus-summary-followup-to-mail t]
1734 ["Followup via news and yank"
1735 gnus-summary-followup-to-mail-with-original t]
1737 ;;["Send" gnus-summary-send-draft t]
1738 ;;["Send bounced" gnus-resend-bounced-mail t])
1742 gnus-summary-misc-menu gnus-summary-mode-map ""
1745 ["Mark as read" gnus-summary-mark-as-read-forward t]
1746 ["Mark same subject and select"
1747 gnus-summary-kill-same-subject-and-select t]
1748 ["Mark same subject" gnus-summary-kill-same-subject t]
1749 ["Catchup" gnus-summary-catchup t]
1750 ["Catchup all" gnus-summary-catchup-all t]
1751 ["Catchup to here" gnus-summary-catchup-to-here t]
1752 ["Catchup region" gnus-summary-mark-region-as-read t]
1753 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1755 ["Tick" gnus-summary-tick-article-forward t]
1756 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1757 ["Remove marks" gnus-summary-clear-mark-forward t]
1758 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1759 ["Set bookmark" gnus-summary-set-bookmark t]
1760 ["Remove bookmark" gnus-summary-remove-bookmark t])
1762 ["Marks..." gnus-summary-limit-to-marks t]
1763 ["Subject..." gnus-summary-limit-to-subject t]
1764 ["Author..." gnus-summary-limit-to-author t]
1765 ["Age..." gnus-summary-limit-to-age t]
1766 ["Score" gnus-summary-limit-to-score t]
1767 ["Unread" gnus-summary-limit-to-unread t]
1768 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1769 ["Articles" gnus-summary-limit-to-articles t]
1770 ["Pop limit" gnus-summary-pop-limit t]
1771 ["Show dormant" gnus-summary-limit-include-dormant t]
1772 ["Hide childless dormant"
1773 gnus-summary-limit-exclude-childless-dormant t]
1774 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1775 ["Show expunged" gnus-summary-show-all-expunged t])
1777 ["Set mark" gnus-summary-mark-as-processable t]
1778 ["Remove mark" gnus-summary-unmark-as-processable t]
1779 ["Remove all marks" gnus-summary-unmark-all-processable t]
1780 ["Mark above" gnus-uu-mark-over t]
1781 ["Mark series" gnus-uu-mark-series t]
1782 ["Mark region" gnus-uu-mark-region t]
1783 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1784 ["Mark all" gnus-uu-mark-all t]
1785 ["Mark buffer" gnus-uu-mark-buffer t]
1786 ["Mark sparse" gnus-uu-mark-sparse t]
1787 ["Mark thread" gnus-uu-mark-thread t]
1788 ["Unmark thread" gnus-uu-unmark-thread t]
1789 ("Process Mark Sets"
1790 ["Kill" gnus-summary-kill-process-mark t]
1791 ["Yank" gnus-summary-yank-process-mark
1792 gnus-newsgroup-process-stack]
1793 ["Save" gnus-summary-save-process-mark t]))
1795 ["Page forward" gnus-summary-next-page t]
1796 ["Page backward" gnus-summary-prev-page t]
1797 ["Line forward" gnus-summary-scroll-up t])
1799 ["Next unread article" gnus-summary-next-unread-article t]
1800 ["Previous unread article" gnus-summary-prev-unread-article t]
1801 ["Next article" gnus-summary-next-article t]
1802 ["Previous article" gnus-summary-prev-article t]
1803 ["Next unread subject" gnus-summary-next-unread-subject t]
1804 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1805 ["Next article same subject" gnus-summary-next-same-subject t]
1806 ["Previous article same subject" gnus-summary-prev-same-subject t]
1807 ["First unread article" gnus-summary-first-unread-article t]
1808 ["Best unread article" gnus-summary-best-unread-article t]
1809 ["Go to subject number..." gnus-summary-goto-subject t]
1810 ["Go to article number..." gnus-summary-goto-article t]
1811 ["Go to the last article" gnus-summary-goto-last-article t]
1812 ["Pop article off history" gnus-summary-pop-article t])
1814 ["Sort by number" gnus-summary-sort-by-number t]
1815 ["Sort by author" gnus-summary-sort-by-author t]
1816 ["Sort by subject" gnus-summary-sort-by-subject t]
1817 ["Sort by date" gnus-summary-sort-by-date t]
1818 ["Sort by score" gnus-summary-sort-by-score t]
1819 ["Sort by lines" gnus-summary-sort-by-lines t])
1821 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1822 ["Describe group" gnus-summary-describe-group t]
1823 ["Read manual" gnus-info-find-node t])
1825 ["Pick and read" gnus-pick-mode t]
1826 ["Binary" gnus-binary-mode t])
1828 ["Regenerate" gnus-summary-prepare t]
1829 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1830 ["Toggle threading" gnus-summary-toggle-threads t])
1831 ["Filter articles..." gnus-summary-execute-command t]
1832 ["Run command on subjects..." gnus-summary-universal-argument t]
1833 ["Search articles forward..." gnus-summary-search-article-forward t]
1834 ["Search articles backward..." gnus-summary-search-article-backward t]
1835 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1836 ["Expand window" gnus-summary-expand-window t]
1837 ["Expire expirable articles" gnus-summary-expire-articles
1838 (gnus-check-backend-function
1839 'request-expire-articles gnus-newsgroup-name)]
1840 ["Edit local kill file" gnus-summary-edit-local-kill t]
1841 ["Edit main kill file" gnus-summary-edit-global-kill t]
1842 ["Edit group parameters" gnus-summary-edit-parameters t]
1844 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1845 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1846 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1847 ["Exit group" gnus-summary-exit t]
1848 ["Exit group without updating" gnus-summary-exit-no-update t]
1849 ["Exit and goto next group" gnus-summary-next-group t]
1850 ["Exit and goto prev group" gnus-summary-prev-group t]
1851 ["Reselect group" gnus-summary-reselect-current-group t]
1852 ["Rescan group" gnus-summary-rescan-group t]
1853 ["Update dribble" gnus-summary-save-newsrc t])))
1855 (gnus-run-hooks 'gnus-summary-menu-hook)))
1857 (defun gnus-score-set-default (var value)
1858 "A version of set that updates the GNU Emacs menu-bar."
1860 ;; It is the message that forces the active status to be updated.
1863 (defun gnus-make-score-map (type)
1864 "Make a summary score map of type TYPE."
1867 (let ((headers '(("author" "from" string)
1868 ("subject" "subject" string)
1869 ("article body" "body" string)
1870 ("article head" "head" string)
1871 ("xref" "xref" string)
1872 ("lines" "lines" number)
1873 ("followups to author" "followup" string)))
1874 (types '((number ("less than" <)
1877 (string ("substring" s)
1881 (perms '(("temporary" (current-time-string))
1889 (if (eq type 'lower)
1894 (setq header (car headers))
1900 (let ((ts (cdr (assoc (nth 2 header) types)))
1916 'gnus-summary-score-entry
1918 (if (or (string= (nth 1 header)
1920 (string= (nth 1 header)
1923 (list 'gnus-summary-header
1925 (list 'quote (nth 1 (car ts)))
1926 (list 'gnus-score-default nil)
1932 (list (nreverse outp))))
1935 (list (nreverse outt))))
1937 (setq headers (cdr headers)))
1938 (list (nreverse outh))))))))
1942 (defun gnus-summary-mode (&optional group)
1943 "Major mode for reading articles.
1945 All normal editing commands are switched off.
1946 \\<gnus-summary-mode-map>
1947 Each line in this buffer represents one article. To read an
1948 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1949 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1952 You can also post articles and send mail from this buffer. To
1953 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1954 of an article, type `\\[gnus-summary-reply]'.
1956 There are approx. one gazillion commands you can execute in this
1957 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1959 The following commands are available:
1961 \\{gnus-summary-mode-map}"
1963 (when (gnus-visual-p 'summary-menu 'menu)
1964 (gnus-summary-make-menu-bar))
1965 (kill-all-local-variables)
1966 (gnus-summary-make-local-variables)
1967 (gnus-make-thread-indent-array)
1968 (gnus-simplify-mode-line)
1969 (setq major-mode 'gnus-summary-mode)
1970 (setq mode-name "Summary")
1971 (make-local-variable 'minor-mode-alist)
1972 (use-local-map gnus-summary-mode-map)
1973 (buffer-disable-undo (current-buffer))
1974 (setq buffer-read-only t) ;Disable modification
1975 (setq truncate-lines t)
1976 (setq selective-display t)
1977 (setq selective-display-ellipses t) ;Display `...'
1978 (gnus-summary-set-display-table)
1979 (gnus-set-default-directory)
1980 (setq gnus-newsgroup-name group)
1981 (make-local-variable 'gnus-summary-line-format)
1982 (make-local-variable 'gnus-summary-line-format-spec)
1983 (make-local-variable 'gnus-summary-dummy-line-format)
1984 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1985 (make-local-variable 'gnus-summary-mark-positions)
1986 (make-local-hook 'post-command-hook)
1987 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1988 (make-local-hook 'pre-command-hook)
1989 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1990 (gnus-run-hooks 'gnus-summary-mode-hook)
1991 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1992 (gnus-update-summary-mark-positions))
1994 (defun gnus-summary-make-local-variables ()
1995 "Make all the local summary buffer variables."
1996 (let ((locals gnus-summary-local-variables)
1998 (while (setq local (pop locals))
2001 (if (eq (cdr local) 'global)
2002 ;; Copy the global value of the variable.
2003 (setq global (symbol-value (car local)))
2004 ;; Use the value from the list.
2005 (setq global (eval (cdr local))))
2006 (make-local-variable (car local))
2007 (set (car local) global))
2008 ;; Simple nil-valued local variable.
2009 (make-local-variable local)
2012 (defun gnus-summary-clear-local-variables ()
2013 (let ((locals gnus-summary-local-variables))
2015 (if (consp (car locals))
2016 (and (vectorp (caar locals))
2017 (set (caar locals) nil))
2018 (and (vectorp (car locals))
2019 (set (car locals) nil)))
2020 (setq locals (cdr locals)))))
2022 ;; Summary data functions.
2024 (defmacro gnus-data-number (data)
2027 (defmacro gnus-data-set-number (data number)
2028 `(setcar ,data ,number))
2030 (defmacro gnus-data-mark (data)
2033 (defmacro gnus-data-set-mark (data mark)
2034 `(setcar (nthcdr 1 ,data) ,mark))
2036 (defmacro gnus-data-pos (data)
2039 (defmacro gnus-data-set-pos (data pos)
2040 `(setcar (nthcdr 2 ,data) ,pos))
2042 (defmacro gnus-data-header (data)
2045 (defmacro gnus-data-set-header (data header)
2046 `(setf (nth 3 ,data) ,header))
2048 (defmacro gnus-data-level (data)
2051 (defmacro gnus-data-unread-p (data)
2052 `(= (nth 1 ,data) gnus-unread-mark))
2054 (defmacro gnus-data-read-p (data)
2055 `(/= (nth 1 ,data) gnus-unread-mark))
2057 (defmacro gnus-data-pseudo-p (data)
2058 `(consp (nth 3 ,data)))
2060 (defmacro gnus-data-find (number)
2061 `(assq ,number gnus-newsgroup-data))
2063 (defmacro gnus-data-find-list (number &optional data)
2064 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2065 (memq (assq ,number bdata)
2068 (defmacro gnus-data-make (number mark pos header level)
2069 `(list ,number ,mark ,pos ,header ,level))
2071 (defun gnus-data-enter (after-article number mark pos header level offset)
2072 (let ((data (gnus-data-find-list after-article)))
2074 (error "No such article: %d" after-article))
2075 (setcdr data (cons (gnus-data-make number mark pos header level)
2077 (setq gnus-newsgroup-data-reverse nil)
2078 (gnus-data-update-list (cddr data) offset)))
2080 (defun gnus-data-enter-list (after-article list &optional offset)
2082 (let ((data (and after-article (gnus-data-find-list after-article)))
2084 (or data (not after-article) (error "No such article: %d" after-article))
2085 ;; Find the last element in the list to be spliced into the main
2088 (setq list (cdr list)))
2091 (setcdr list gnus-newsgroup-data)
2092 (setq gnus-newsgroup-data ilist)
2094 (gnus-data-update-list (cdr list) offset)))
2095 (setcdr list (cdr data))
2098 (gnus-data-update-list (cdr list) offset)))
2099 (setq gnus-newsgroup-data-reverse nil))))
2101 (defun gnus-data-remove (article &optional offset)
2102 (let ((data gnus-newsgroup-data))
2103 (if (= (gnus-data-number (car data)) article)
2105 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2106 gnus-newsgroup-data-reverse nil)
2108 (gnus-data-update-list gnus-newsgroup-data offset)))
2110 (when (= (gnus-data-number (cadr data)) article)
2111 (setcdr data (cddr data))
2113 (gnus-data-update-list (cdr data) offset))
2115 gnus-newsgroup-data-reverse nil))
2116 (setq data (cdr data))))))
2118 (defmacro gnus-data-list (backward)
2120 (or gnus-newsgroup-data-reverse
2121 (setq gnus-newsgroup-data-reverse
2122 (reverse gnus-newsgroup-data)))
2123 gnus-newsgroup-data))
2125 (defun gnus-data-update-list (data offset)
2126 "Add OFFSET to the POS of all data entries in DATA."
2128 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2129 (setq data (cdr data))))
2131 (defun gnus-data-compute-positions ()
2132 "Compute the positions of all articles."
2133 (let ((data gnus-newsgroup-data)
2136 (when (setq pos (text-property-any
2137 (point-min) (point-max)
2138 'gnus-number (gnus-data-number (car data))))
2139 (gnus-data-set-pos (car data) (+ pos 3)))
2140 (setq data (cdr data)))))
2142 (defun gnus-summary-article-pseudo-p (article)
2143 "Say whether this article is a pseudo article or not."
2144 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2146 (defmacro gnus-summary-article-sparse-p (article)
2147 "Say whether this article is a sparse article or not."
2148 `(memq ,article gnus-newsgroup-sparse))
2150 (defmacro gnus-summary-article-ancient-p (article)
2151 "Say whether this article is a sparse article or not."
2152 `(memq ,article gnus-newsgroup-ancient))
2154 (defun gnus-article-parent-p (number)
2155 "Say whether this article is a parent or not."
2156 (let ((data (gnus-data-find-list number)))
2157 (and (cdr data) ; There has to be an article after...
2158 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2159 (gnus-data-level (nth 1 data))))))
2161 (defun gnus-article-children (number)
2162 "Return a list of all children to NUMBER."
2163 (let* ((data (gnus-data-find-list number))
2164 (level (gnus-data-level (car data)))
2166 (setq data (cdr data))
2168 (= (gnus-data-level (car data)) (1+ level)))
2169 (push (gnus-data-number (car data)) children)
2170 (setq data (cdr data)))
2173 (defmacro gnus-summary-skip-intangible ()
2174 "If the current article is intangible, then jump to a different article."
2175 '(let ((to (get-text-property (point) 'gnus-intangible)))
2176 (and to (gnus-summary-goto-subject to))))
2178 (defmacro gnus-summary-article-intangible-p ()
2179 "Say whether this article is intangible or not."
2180 '(get-text-property (point) 'gnus-intangible))
2182 (defun gnus-article-read-p (article)
2183 "Say whether ARTICLE is read or not."
2184 (not (or (memq article gnus-newsgroup-marked)
2185 (memq article gnus-newsgroup-unreads)
2186 (memq article gnus-newsgroup-unselected)
2187 (memq article gnus-newsgroup-dormant))))
2189 ;; Some summary mode macros.
2191 (defmacro gnus-summary-article-number ()
2192 "The article number of the article on the current line.
2193 If there isn's an article number here, then we return the current
2196 (gnus-summary-skip-intangible)
2197 (or (get-text-property (point) 'gnus-number)
2198 (gnus-summary-last-subject))))
2200 (defmacro gnus-summary-article-header (&optional number)
2201 "Return the header of article NUMBER."
2202 `(gnus-data-header (gnus-data-find
2203 ,(or number '(gnus-summary-article-number)))))
2205 (defmacro gnus-summary-thread-level (&optional number)
2206 "Return the level of thread that starts with article NUMBER."
2207 `(if (and (eq gnus-summary-make-false-root 'dummy)
2208 (get-text-property (point) 'gnus-intangible))
2210 (gnus-data-level (gnus-data-find
2211 ,(or number '(gnus-summary-article-number))))))
2213 (defmacro gnus-summary-article-mark (&optional number)
2214 "Return the mark of article NUMBER."
2215 `(gnus-data-mark (gnus-data-find
2216 ,(or number '(gnus-summary-article-number)))))
2218 (defmacro gnus-summary-article-pos (&optional number)
2219 "Return the position of the line of article NUMBER."
2220 `(gnus-data-pos (gnus-data-find
2221 ,(or number '(gnus-summary-article-number)))))
2223 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2224 (defmacro gnus-summary-article-subject (&optional number)
2225 "Return current subject string or nil if nothing."
2228 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2229 '(gnus-data-header (assq (gnus-summary-article-number)
2230 gnus-newsgroup-data)))))
2233 (mail-header-subject headers))))
2235 (defmacro gnus-summary-article-score (&optional number)
2236 "Return current article score."
2237 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2238 gnus-newsgroup-scored))
2239 gnus-summary-default-score 0))
2241 (defun gnus-summary-article-children (&optional number)
2242 "Return a list of article numbers that are children of article NUMBER."
2243 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2244 (level (gnus-data-level (car data)))
2246 (while (and (setq data (cdr data))
2247 (> (setq l (gnus-data-level (car data))) level))
2248 (and (= (1+ level) l)
2249 (push (gnus-data-number (car data))
2251 (nreverse children)))
2253 (defun gnus-summary-article-parent (&optional number)
2254 "Return the article number of the parent of article NUMBER."
2255 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2256 (gnus-data-list t)))
2257 (level (gnus-data-level (car data))))
2259 () ; This is a root.
2260 ;; We search until we find an article with a level less than
2261 ;; this one. That function has to be the parent.
2262 (while (and (setq data (cdr data))
2263 (not (< (gnus-data-level (car data)) level))))
2264 (and data (gnus-data-number (car data))))))
2266 (defun gnus-unread-mark-p (mark)
2267 "Say whether MARK is the unread mark."
2268 (= mark gnus-unread-mark))
2270 (defun gnus-read-mark-p (mark)
2271 "Say whether MARK is one of the marks that mark as read.
2272 This is all marks except unread, ticked, dormant, and expirable."
2273 (not (or (= mark gnus-unread-mark)
2274 (= mark gnus-ticked-mark)
2275 (= mark gnus-dormant-mark)
2276 (= mark gnus-expirable-mark))))
2278 (defmacro gnus-article-mark (number)
2279 "Return the MARK of article NUMBER.
2280 This macro should only be used when computing the mark the \"first\"
2281 time; i.e., when generating the summary lines. After that,
2282 `gnus-summary-article-mark' should be used to examine the
2285 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2286 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2287 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2288 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2289 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2290 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2291 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2292 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2293 gnus-ancient-mark))))
2295 ;; Saving hidden threads.
2297 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2298 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2300 (defmacro gnus-save-hidden-threads (&rest forms)
2301 "Save hidden threads, eval FORMS, and restore the hidden threads."
2302 (let ((config (make-symbol "config")))
2303 `(let ((,config (gnus-hidden-threads-configuration)))
2307 (gnus-restore-hidden-threads-configuration ,config)))))
2309 (defun gnus-hidden-threads-configuration ()
2310 "Return the current hidden threads configuration."
2313 (goto-char (point-min))
2314 (while (search-forward "\r" nil t)
2315 (push (1- (point)) config))
2318 (defun gnus-restore-hidden-threads-configuration (config)
2319 "Restore hidden threads configuration from CONFIG."
2320 (let (point buffer-read-only)
2321 (while (setq point (pop config))
2322 (when (and (< point (point-max))
2324 (= (following-char) ?\n))
2325 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2327 ;; Various summary mode internalish functions.
2329 (defun gnus-mouse-pick-article (e)
2332 (gnus-summary-next-page nil t))
2334 (defun gnus-summary-set-display-table ()
2335 ;; Change the display table. Odd characters have a tendency to mess
2336 ;; up nicely formatted displays - we make all possible glyphs
2337 ;; display only a single character.
2339 ;; We start from the standard display table, if any.
2340 (let ((table (or (copy-sequence standard-display-table)
2341 (make-display-table)))
2343 ;; Nix out all the control chars...
2344 (while (>= (setq i (1- i)) 0)
2345 (aset table i [??]))
2346 ;; ... but not newline and cr, of course. (cr is necessary for the
2347 ;; selective display).
2348 (aset table ?\n nil)
2349 (aset table ?\r nil)
2350 ;; We keep TAB as well.
2351 (aset table ?\t nil)
2352 ;; We nix out any glyphs over 126 that are not set already.
2354 (while (>= (setq i (1- i)) 127)
2355 ;; Only modify if the entry is nil.
2356 (unless (aref table i)
2357 (aset table i [??]))))
2358 (setq buffer-display-table table)))
2360 (defun gnus-summary-setup-buffer (group)
2361 "Initialize summary buffer."
2362 (let ((buffer (concat "*Summary " group "*")))
2363 (if (get-buffer buffer)
2366 (setq gnus-summary-buffer (current-buffer))
2367 (not gnus-newsgroup-prepared))
2368 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2369 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2370 (gnus-add-current-to-buffer-list)
2371 (gnus-summary-mode group)
2373 (gnus-carpal-setup-buffer 'summary))
2374 (unless gnus-single-article-buffer
2375 (make-local-variable 'gnus-article-buffer)
2376 (make-local-variable 'gnus-article-current)
2377 (make-local-variable 'gnus-original-article-buffer))
2378 (setq gnus-newsgroup-name group)
2381 (defun gnus-set-global-variables ()
2382 ;; Set the global equivalents of the summary buffer-local variables
2383 ;; to the latest values they had. These reflect the summary buffer
2384 ;; that was in action when the last article was fetched.
2385 (when (eq major-mode 'gnus-summary-mode)
2386 (setq gnus-summary-buffer (current-buffer))
2387 (let ((name gnus-newsgroup-name)
2388 (marked gnus-newsgroup-marked)
2389 (unread gnus-newsgroup-unreads)
2390 (headers gnus-current-headers)
2391 (data gnus-newsgroup-data)
2392 (summary gnus-summary-buffer)
2393 (article-buffer gnus-article-buffer)
2394 (original gnus-original-article-buffer)
2395 (gac gnus-article-current)
2396 (reffed gnus-reffed-article-number)
2397 (score-file gnus-current-score-file))
2399 (set-buffer gnus-group-buffer)
2400 (setq gnus-newsgroup-name name
2401 gnus-newsgroup-marked marked
2402 gnus-newsgroup-unreads unread
2403 gnus-current-headers headers
2404 gnus-newsgroup-data data
2405 gnus-article-current gac
2406 gnus-summary-buffer summary
2407 gnus-article-buffer article-buffer
2408 gnus-original-article-buffer original
2409 gnus-reffed-article-number reffed
2410 gnus-current-score-file score-file)
2411 ;; The article buffer also has local variables.
2412 (when (gnus-buffer-live-p gnus-article-buffer)
2413 (set-buffer gnus-article-buffer)
2414 (setq gnus-summary-buffer summary))))))
2416 (defun gnus-summary-article-unread-p (article)
2417 "Say whether ARTICLE is unread or not."
2418 (memq article gnus-newsgroup-unreads))
2420 (defun gnus-summary-first-article-p (&optional article)
2421 "Return whether ARTICLE is the first article in the buffer."
2422 (if (not (setq article (or article (gnus-summary-article-number))))
2424 (eq article (caar gnus-newsgroup-data))))
2426 (defun gnus-summary-last-article-p (&optional article)
2427 "Return whether ARTICLE is the last article in the buffer."
2428 (if (not (setq article (or article (gnus-summary-article-number))))
2429 t ; All non-existent numbers are the last article. :-)
2430 (not (cdr (gnus-data-find-list article)))))
2432 (defun gnus-make-thread-indent-array ()
2434 (unless (and gnus-thread-indent-array
2435 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2436 (setq gnus-thread-indent-array (make-vector 201 "")
2437 gnus-thread-indent-array-level gnus-thread-indent-level)
2439 (aset gnus-thread-indent-array n
2440 (make-string (* n gnus-thread-indent-level) ? ))
2443 (defun gnus-update-summary-mark-positions ()
2444 "Compute where the summary marks are to go."
2446 (when (and gnus-summary-buffer
2447 (get-buffer gnus-summary-buffer)
2448 (buffer-name (get-buffer gnus-summary-buffer)))
2449 (set-buffer gnus-summary-buffer))
2450 (let ((gnus-replied-mark 129)
2451 (gnus-score-below-mark 130)
2452 (gnus-score-over-mark 130)
2453 (gnus-download-mark 131)
2454 (spec gnus-summary-line-format-spec)
2455 thread gnus-visual pos)
2457 (gnus-set-work-buffer)
2458 (let ((gnus-summary-line-format-spec spec)
2459 (gnus-newsgroup-downloadable '((0 . t))))
2460 (gnus-summary-insert-line
2461 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2462 (goto-char (point-min))
2463 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2465 (goto-char (point-min))
2466 (push (cons 'replied (and (search-forward "\201" nil t)
2469 (goto-char (point-min))
2470 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2472 (goto-char (point-min))
2473 (push (cons 'download
2474 (and (search-forward "\203" nil t) (- (point) 2)))
2476 (setq gnus-summary-mark-positions pos))))
2478 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2479 "Insert a dummy root in the summary buffer."
2481 (gnus-add-text-properties
2482 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2483 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2485 (defun gnus-summary-insert-line (gnus-tmp-header
2486 gnus-tmp-level gnus-tmp-current
2487 gnus-tmp-unread gnus-tmp-replied
2488 gnus-tmp-expirable gnus-tmp-subject-or-nil
2489 &optional gnus-tmp-dummy gnus-tmp-score
2491 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2492 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2493 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2494 (gnus-tmp-score-char
2495 (if (or (null gnus-summary-default-score)
2496 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2497 gnus-summary-zcore-fuzz))
2499 (if (< gnus-tmp-score gnus-summary-default-score)
2500 gnus-score-below-mark gnus-score-over-mark)))
2502 (cond (gnus-tmp-process gnus-process-mark)
2503 ((memq gnus-tmp-current gnus-newsgroup-cached)
2505 (gnus-tmp-replied gnus-replied-mark)
2506 ((memq gnus-tmp-current gnus-newsgroup-saved)
2508 (t gnus-unread-mark)))
2509 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2512 ((string-match "<[^>]+> *$" gnus-tmp-from)
2513 (let ((beg (match-beginning 0)))
2514 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2515 (substring gnus-tmp-from (1+ (match-beginning 0))
2516 (1- (match-end 0))))
2517 (substring gnus-tmp-from 0 beg))))
2518 ((string-match "(.+)" gnus-tmp-from)
2519 (substring gnus-tmp-from
2520 (1+ (match-beginning 0)) (1- (match-end 0))))
2522 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2523 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2524 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2525 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2526 (buffer-read-only nil))
2527 (when (string= gnus-tmp-name "")
2528 (setq gnus-tmp-name gnus-tmp-from))
2529 (unless (numberp gnus-tmp-lines)
2530 (setq gnus-tmp-lines 0))
2531 (gnus-put-text-property
2533 (progn (eval gnus-summary-line-format-spec) (point))
2534 'gnus-number gnus-tmp-number)
2535 (when (gnus-visual-p 'summary-highlight 'highlight)
2537 (gnus-run-hooks 'gnus-summary-update-hook)
2540 (defun gnus-summary-update-line (&optional dont-update)
2541 ;; Update summary line after change.
2542 (when (and gnus-summary-default-score
2543 (not gnus-summary-inhibit-highlight))
2544 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2545 (article (gnus-summary-article-number))
2546 (score (gnus-summary-article-score article)))
2548 (if (and gnus-summary-mark-below
2549 (< (gnus-summary-article-score)
2550 gnus-summary-mark-below))
2551 ;; This article has a low score, so we mark it as read.
2552 (when (memq article gnus-newsgroup-unreads)
2553 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2554 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2555 ;; This article was previously marked as read on account
2556 ;; of a low score, but now it has risen, so we mark it as
2558 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2559 (gnus-summary-update-mark
2560 (if (or (null gnus-summary-default-score)
2561 (<= (abs (- score gnus-summary-default-score))
2562 gnus-summary-zcore-fuzz))
2564 (if (< score gnus-summary-default-score)
2565 gnus-score-below-mark gnus-score-over-mark))
2567 ;; Do visual highlighting.
2568 (when (gnus-visual-p 'summary-highlight 'highlight)
2569 (gnus-run-hooks 'gnus-summary-update-hook)))))
2571 (defvar gnus-tmp-new-adopts nil)
2573 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2574 "Return the number of articles in THREAD.
2575 This may be 0 in some cases -- if none of the articles in
2576 the thread are to be displayed."
2578 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2580 ((not (listp thread))
2582 ((and (consp thread) (cdr thread))
2585 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2588 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2591 (when (and level (zerop level) gnus-tmp-new-adopts)
2594 'gnus-summary-number-of-articles-in-thread
2595 gnus-tmp-new-adopts))))
2597 (if (> number 1) gnus-not-empty-thread-mark
2598 gnus-empty-thread-mark)
2601 (defun gnus-summary-set-local-parameters (group)
2602 "Go through the local params of GROUP and set all variable specs in that list."
2603 (let ((params (gnus-group-find-parameter group))
2606 (setq elem (car params)
2607 params (cdr params))
2608 (and (consp elem) ; Has to be a cons.
2609 (consp (cdr elem)) ; The cdr has to be a list.
2610 (symbolp (car elem)) ; Has to be a symbol in there.
2611 (not (memq (car elem)
2612 '(quit-config to-address to-list to-group)))
2613 (ignore-errors ; So we set it.
2614 (make-local-variable (car elem))
2615 (set (car elem) (eval (nth 1 elem))))))))
2617 (defun gnus-summary-read-group (group &optional show-all no-article
2618 kill-buffer no-display backward)
2619 "Start reading news in newsgroup GROUP.
2620 If SHOW-ALL is non-nil, already read articles are also listed.
2621 If NO-ARTICLE is non-nil, no article is selected initially.
2622 If NO-DISPLAY, don't generate a summary buffer."
2626 (let ((gnus-auto-select-next nil))
2627 (or (gnus-summary-read-group-1
2628 group show-all no-article
2629 kill-buffer no-display)
2630 (setq show-all nil)))))
2631 (eq gnus-auto-select-next 'quietly))
2632 (set-buffer gnus-group-buffer)
2633 ;; The entry function called above goes to the next
2634 ;; group automatically, so we go two groups back
2635 ;; if we are searching for the previous group.
2637 (gnus-group-prev-unread-group 2))
2638 (if (not (equal group (gnus-group-group-name)))
2639 (setq group (gnus-group-group-name))
2643 (defun gnus-summary-read-group-1 (group show-all no-article
2644 kill-buffer no-display)
2645 ;; Killed foreign groups can't be entered.
2646 (when (and (not (gnus-group-native-p group))
2647 (not (gnus-gethash group gnus-newsrc-hashtb)))
2648 (error "Dead non-native groups can't be entered"))
2649 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2650 (let* ((new-group (gnus-summary-setup-buffer group))
2651 (quit-config (gnus-group-quit-config group))
2652 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2654 ;; This summary buffer exists already, so we just select it.
2656 (gnus-set-global-variables)
2658 (gnus-kill-or-deaden-summary kill-buffer))
2659 (gnus-configure-windows 'summary 'force)
2660 (gnus-set-mode-line 'summary)
2661 (gnus-summary-position-point)
2664 ;; We couldn't select this group.
2666 (when (and (eq major-mode 'gnus-summary-mode)
2667 (not (equal (current-buffer) kill-buffer)))
2668 (kill-buffer (current-buffer))
2669 (if (not quit-config)
2671 ;; Update the info -- marks might need to be removed,
2673 (gnus-summary-update-info)
2674 (set-buffer gnus-group-buffer)
2675 (gnus-group-jump-to-group group)
2676 (gnus-group-next-unread-group 1))
2677 (gnus-handle-ephemeral-exit quit-config)))
2678 (gnus-message 3 "Can't select group")
2680 ;; The user did a `C-g' while prompting for number of articles,
2681 ;; so we exit this group.
2682 ((eq did-select 'quit)
2683 (and (eq major-mode 'gnus-summary-mode)
2684 (not (equal (current-buffer) kill-buffer))
2685 (kill-buffer (current-buffer)))
2687 (gnus-kill-or-deaden-summary kill-buffer))
2688 (if (not quit-config)
2690 (set-buffer gnus-group-buffer)
2691 (gnus-group-jump-to-group group)
2692 (gnus-group-next-unread-group 1)
2693 (gnus-configure-windows 'group 'force))
2694 (gnus-handle-ephemeral-exit quit-config))
2695 ;; Finally signal the quit.
2697 ;; The group was successfully selected.
2699 (gnus-set-global-variables)
2700 ;; Save the active value in effect when the group was entered.
2701 (setq gnus-newsgroup-active
2703 (gnus-active gnus-newsgroup-name)))
2704 ;; You can change the summary buffer in some way with this hook.
2705 (gnus-run-hooks 'gnus-select-group-hook)
2706 ;; Set any local variables in the group parameters.
2707 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2708 (gnus-update-format-specifications
2709 nil 'summary 'summary-mode 'summary-dummy)
2710 ;; Do score processing.
2711 (when gnus-use-scoring
2712 (gnus-possibly-score-headers))
2713 ;; Check whether to fill in the gaps in the threads.
2714 (when gnus-build-sparse-threads
2715 (gnus-build-sparse-threads))
2716 ;; Find the initial limit.
2717 (if gnus-show-threads
2719 (let ((gnus-newsgroup-dormant nil))
2720 (gnus-summary-initial-limit show-all))
2721 (gnus-summary-initial-limit show-all))
2722 (setq gnus-newsgroup-limit
2724 (lambda (header) (mail-header-number header))
2725 gnus-newsgroup-headers)))
2726 ;; Generate the summary buffer.
2728 (gnus-summary-prepare))
2729 (when gnus-use-trees
2730 (gnus-tree-open group)
2731 (setq gnus-summary-highlight-line-function
2732 'gnus-tree-highlight-article))
2733 ;; If the summary buffer is empty, but there are some low-scored
2734 ;; articles or some excluded dormants, we include these in the
2736 (when (and (zerop (buffer-size))
2738 (cond (gnus-newsgroup-dormant
2739 (gnus-summary-limit-include-dormant))
2740 ((and gnus-newsgroup-scored show-all)
2741 (gnus-summary-limit-include-expunged t))))
2742 ;; Function `gnus-apply-kill-file' must be called in this hook.
2743 (gnus-run-hooks 'gnus-apply-kill-hook)
2744 (if (and (zerop (buffer-size))
2747 ;; This newsgroup is empty.
2748 (gnus-summary-catchup-and-exit nil t)
2749 (gnus-message 6 "No unread news")
2751 (gnus-kill-or-deaden-summary kill-buffer))
2752 ;; Return nil from this function.
2754 ;; Hide conversation thread subtrees. We cannot do this in
2755 ;; gnus-summary-prepare-hook since kill processing may not
2756 ;; work with hidden articles.
2757 (and gnus-show-threads
2758 gnus-thread-hide-subtree
2759 (gnus-summary-hide-all-threads))
2761 (gnus-kill-or-deaden-summary kill-buffer))
2762 ;; Show first unread article if requested.
2763 (if (and (not no-article)
2765 gnus-newsgroup-unreads
2766 gnus-auto-select-first)
2767 (unless (if (eq gnus-auto-select-first 'best)
2768 (gnus-summary-best-unread-article)
2769 (gnus-summary-first-unread-article))
2770 (gnus-configure-windows 'summary))
2771 ;; Don't select any articles, just move point to the first
2772 ;; article in the group.
2773 (goto-char (point-min))
2774 (gnus-summary-position-point)
2775 (gnus-configure-windows 'summary 'force)
2776 (gnus-set-mode-line 'summary))
2777 (when (get-buffer-window gnus-group-buffer t)
2778 ;; Gotta use windows, because recenter does weird stuff if
2779 ;; the current buffer ain't the displayed window.
2780 (let ((owin (selected-window)))
2781 (select-window (get-buffer-window gnus-group-buffer t))
2782 (when (gnus-group-goto-group group)
2784 (select-window owin)))
2785 ;; Mark this buffer as "prepared".
2786 (setq gnus-newsgroup-prepared t)
2787 (gnus-run-hooks 'gnus-summary-prepared-hook)
2790 (defun gnus-summary-prepare ()
2791 "Generate the summary buffer."
2793 (let ((buffer-read-only nil))
2795 (setq gnus-newsgroup-data nil
2796 gnus-newsgroup-data-reverse nil)
2797 (gnus-run-hooks 'gnus-summary-generate-hook)
2798 ;; Generate the buffer, either with threads or without.
2799 (when gnus-newsgroup-headers
2800 (gnus-summary-prepare-threads
2801 (if gnus-show-threads
2802 (gnus-sort-gathered-threads
2803 (funcall gnus-summary-thread-gathering-function
2805 (gnus-cut-threads (gnus-make-threads)))))
2806 ;; Unthreaded display.
2807 (gnus-sort-articles gnus-newsgroup-headers))))
2808 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2809 ;; Call hooks for modifying summary buffer.
2810 (goto-char (point-min))
2811 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2813 (defsubst gnus-general-simplify-subject (subject)
2814 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2817 ;; Truncate the subject.
2818 (gnus-simplify-subject-functions
2819 (gnus-map-function gnus-simplify-subject-functions subject))
2820 ((numberp gnus-summary-gather-subject-limit)
2821 (setq subject (gnus-simplify-subject-re subject))
2822 (if (> (length subject) gnus-summary-gather-subject-limit)
2823 (substring subject 0 gnus-summary-gather-subject-limit)
2825 ;; Fuzzily simplify it.
2826 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2827 (gnus-simplify-subject-fuzzy subject))
2828 ;; Just remove the leading "Re:".
2830 (gnus-simplify-subject-re subject))))
2832 (if (and gnus-summary-gather-exclude-subject
2833 (string-match gnus-summary-gather-exclude-subject subject))
2834 nil ; This article shouldn't be gathered
2837 (defun gnus-summary-simplify-subject-query ()
2838 "Query where the respool algorithm would put this article."
2840 (gnus-summary-select-article)
2841 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2843 (defun gnus-gather-threads-by-subject (threads)
2844 "Gather threads by looking at Subject headers."
2845 (if (not gnus-summary-make-false-root)
2847 (let ((hashtb (gnus-make-hashtable 1024))
2850 subject hthread whole-subject)
2852 (setq subject (gnus-general-simplify-subject
2853 (setq whole-subject (mail-header-subject
2856 (if (setq hthread (gnus-gethash subject hashtb))
2858 ;; We enter a dummy root into the thread, if we
2859 ;; haven't done that already.
2860 (unless (stringp (caar hthread))
2861 (setcar hthread (list whole-subject (car hthread))))
2862 ;; We add this new gathered thread to this gathered
2864 (setcdr (car hthread)
2865 (nconc (cdar hthread) (list (car threads))))
2866 ;; Remove it from the list of threads.
2867 (setcdr prev (cdr threads))
2868 (setq threads prev))
2869 ;; Enter this thread into the hash table.
2870 (gnus-sethash subject threads hashtb)))
2872 (setq threads (cdr threads)))
2875 (defun gnus-gather-threads-by-references (threads)
2876 "Gather threads by looking at References headers."
2877 (let ((idhashtb (gnus-make-hashtable 1024))
2878 (thhashtb (gnus-make-hashtable 1024))
2881 ids references id gthread gid entered ref)
2883 (when (setq references (mail-header-references (caar threads)))
2884 (setq id (mail-header-id (caar threads))
2885 ids (gnus-split-references references)
2887 (while (setq ref (pop ids))
2888 (setq ids (delete ref ids))
2889 (if (not (setq gid (gnus-gethash ref idhashtb)))
2891 (gnus-sethash ref id idhashtb)
2892 (gnus-sethash id threads thhashtb))
2893 (setq gthread (gnus-gethash gid thhashtb))
2895 ;; We enter a dummy root into the thread, if we
2896 ;; haven't done that already.
2897 (unless (stringp (caar gthread))
2898 (setcar gthread (list (mail-header-subject (caar gthread))
2900 ;; We add this new gathered thread to this gathered
2902 (setcdr (car gthread)
2903 (nconc (cdar gthread) (list (car threads)))))
2904 ;; Add it into the thread hash table.
2905 (gnus-sethash id gthread thhashtb)
2907 ;; Remove it from the list of threads.
2908 (setcdr prev (cdr threads))
2909 (setq threads prev))))
2911 (setq threads (cdr threads)))
2914 (defun gnus-sort-gathered-threads (threads)
2915 "Sort subtreads inside each gathered thread by article number."
2916 (let ((result threads))
2918 (when (stringp (caar threads))
2919 (setcdr (car threads)
2920 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2921 (setq threads (cdr threads)))
2924 (defun gnus-thread-loop-p (root thread)
2925 "Say whether ROOT is in THREAD."
2926 (let ((stack (list thread))
2929 (while (setq thread (pop stack))
2930 (setq th (cdr thread))
2932 (not (eq (caar th) root)))
2935 ;; We have found a loop.
2937 (setcdr thread (delq (car th) (cdr thread)))
2938 (if (boundp (setq ref-dep (intern "none"
2939 gnus-newsgroup-dependencies)))
2940 (setcdr (symbol-value ref-dep)
2941 (nconc (cdr (symbol-value ref-dep))
2943 (set ref-dep (list nil (car th))))
2946 ;; Push all the subthreads onto the stack.
2947 (push (cdr thread) stack)))
2950 (defun gnus-make-threads ()
2951 "Go through the dependency hashtb and find the roots. Return all threads."
2953 (while (catch 'infloop
2956 ;; Deal with self-referencing References loops.
2957 (when (and (car (symbol-value refs))
2964 (car (symbol-value refs)) thread))
2965 (cdr (symbol-value refs)))))))
2968 (unless (car (symbol-value refs))
2969 ;; These threads do not refer back to any other articles,
2970 ;; so they're roots.
2971 (setq threads (append (cdr (symbol-value refs)) threads))))
2972 gnus-newsgroup-dependencies)))
2975 (defun gnus-build-sparse-threads ()
2976 (let ((headers gnus-newsgroup-headers)
2977 (deps gnus-newsgroup-dependencies)
2978 header references generation relations
2979 cthread subject child end pthread relation new-child)
2980 ;; First we create an alist of generations/relations, where
2981 ;; generations is how much we trust the relation, and the relation
2983 (gnus-message 7 "Making sparse threads...")
2985 (nnheader-set-temp-buffer " *gnus sparse threads*")
2986 (while (setq header (pop headers))
2987 (when (and (setq references (mail-header-references header))
2988 (not (string= references "")))
2990 (setq child (mail-header-id header)
2991 subject (mail-header-subject header))
2993 (while (search-backward ">" nil t)
2994 (setq end (1+ (point)))
2995 (when (search-backward "<" nil t)
2996 (unless (string= (setq new-child (buffer-substring (point) end))
2998 (push (list (incf generation)
2999 child (setq child new-child)
3002 (push (list (1+ generation) child nil subject) relations)
3004 (kill-buffer (current-buffer)))
3005 ;; Sort over trustworthiness.
3006 (setq relations (sort relations 'car-less-than-car))
3007 (while (setq relation (pop relations))
3008 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
3009 (unless (car (symbol-value cthread))
3010 ;; Make this article the parent of these threads.
3011 (setcar (symbol-value cthread)
3012 (vector gnus-reffed-article-number
3016 (or (caddr relation) "") 0 0 "")))
3017 (set cthread (list (vector gnus-reffed-article-number
3019 "" "" (cadr relation)
3020 (or (caddr relation) "") 0 0 ""))))
3021 (push gnus-reffed-article-number gnus-newsgroup-limit)
3022 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3023 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3024 gnus-newsgroup-reads)
3025 (decf gnus-reffed-article-number)
3026 ;; Make this new thread the child of its parent.
3027 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
3028 (setcdr (symbol-value pthread)
3029 (nconc (cdr (symbol-value pthread))
3030 (list (symbol-value cthread))))
3031 (set pthread (list nil (symbol-value cthread))))))
3032 (gnus-message 7 "Making sparse threads...done")))
3034 (defun gnus-build-old-threads ()
3035 ;; Look at all the articles that refer back to old articles, and
3036 ;; fetch the headers for the articles that aren't there. This will
3037 ;; build complete threads - if the roots haven't been expired by the
3042 (when (not (car (symbol-value refs)))
3043 (setq heads (cdr (symbol-value refs)))
3045 (if (memq (mail-header-number (caar heads))
3046 gnus-newsgroup-dormant)
3047 (setq heads (cdr heads))
3048 (setq id (symbol-name refs))
3049 (while (and (setq id (gnus-build-get-header id))
3050 (not (car (gnus-gethash
3051 id gnus-newsgroup-dependencies)))))
3052 (setq heads nil)))))
3053 gnus-newsgroup-dependencies)))
3055 (defun gnus-build-get-header (id)
3056 ;; Look through the buffer of NOV lines and find the header to
3057 ;; ID. Enter this line into the dependencies hash table, and return
3058 ;; the id of the parent article (if any).
3059 (let ((deps gnus-newsgroup-dependencies)
3063 (set-buffer nntp-server-buffer)
3064 (let ((case-fold-search nil))
3065 (goto-char (point-min))
3066 (while (and (not found)
3067 (search-forward id nil t))
3069 (setq found (looking-at
3070 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3071 (regexp-quote id))))
3072 (or found (beginning-of-line 2)))
3076 (setq header (gnus-nov-parse-line
3077 (read (current-buffer)) deps))
3078 (gnus-parent-id (mail-header-references header))))))
3080 (let ((number (mail-header-number header)))
3081 (push number gnus-newsgroup-limit)
3082 (push header gnus-newsgroup-headers)
3083 (if (memq number gnus-newsgroup-unselected)
3085 (push number gnus-newsgroup-unreads)
3086 (setq gnus-newsgroup-unselected
3087 (delq number gnus-newsgroup-unselected)))
3088 (push number gnus-newsgroup-ancient)))))))
3090 (defun gnus-build-all-threads ()
3091 "Read all the headers."
3092 (let ((deps gnus-newsgroup-dependencies)
3093 (gnus-summary-ignore-duplicates t)
3094 found header article)
3096 (set-buffer nntp-server-buffer)
3097 (let ((case-fold-search nil))
3098 (goto-char (point-min))
3101 (setq article (read (current-buffer)))
3102 (setq header (gnus-nov-parse-line article deps)))
3104 (push header gnus-newsgroup-headers)
3105 (if (memq (setq article (mail-header-number header))
3106 gnus-newsgroup-unselected)
3108 (push article gnus-newsgroup-unreads)
3109 (setq gnus-newsgroup-unselected
3110 (delq article gnus-newsgroup-unselected)))
3111 (push article gnus-newsgroup-ancient))
3112 (forward-line 1)))))))
3114 (defun gnus-summary-update-article-line (article header)
3115 "Update the line for ARTICLE using HEADERS."
3116 (let* ((id (mail-header-id header))
3117 (thread (gnus-id-to-thread id)))
3119 (error "Article in no thread"))
3120 ;; Update the thread.
3121 (setcar thread header)
3122 (gnus-summary-goto-subject article)
3123 (let* ((datal (gnus-data-find-list article))
3125 (length (when (cdr datal)
3126 (- (gnus-data-pos data)
3127 (gnus-data-pos (cadr datal)))))
3128 (buffer-read-only nil)
3129 (level (gnus-summary-thread-level)))
3131 (gnus-summary-insert-line
3132 header level nil (gnus-article-mark article)
3133 (memq article gnus-newsgroup-replied)
3134 (memq article gnus-newsgroup-expirable)
3135 ;; Only insert the Subject string when it's different
3136 ;; from the previous Subject string.
3137 (if (gnus-subject-equal
3139 (mail-header-subject
3142 (gnus-data-find-list
3144 (gnus-data-list t)))))
3145 ;; Error on the side of excessive subjects.
3147 (mail-header-subject header))
3149 (mail-header-subject header))
3150 nil (cdr (assq article gnus-newsgroup-scored))
3151 (memq article gnus-newsgroup-processable))
3153 (gnus-data-update-list
3154 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3156 (defun gnus-summary-update-article (article &optional iheader)
3157 "Update ARTICLE in the summary buffer."
3158 (set-buffer gnus-summary-buffer)
3159 (let* ((header (or iheader (gnus-summary-article-header article)))
3160 (id (mail-header-id header))
3161 (data (gnus-data-find article))
3162 (thread (gnus-id-to-thread id))
3163 (references (mail-header-references header))
3167 (when (and references
3168 (not (equal "" references)))
3171 (buffer-read-only nil)
3173 (number (mail-header-number header))
3176 ;; !!! Should this be in or not?
3178 (setcar thread nil))
3180 (delq thread parent))
3181 (if (gnus-summary-insert-subject id header iheader)
3182 ;; Set the (possibly) new article number in the data structure.
3183 (gnus-data-set-number data (gnus-id-to-article id))
3187 (defun gnus-rebuild-thread (id)
3188 "Rebuild the thread containing ID."
3189 (let ((buffer-read-only nil)
3190 old-pos current thread data)
3191 (if (not gnus-show-threads)
3192 (setq thread (list (car (gnus-id-to-thread id))))
3193 ;; Get the thread this article is part of.
3194 (setq thread (gnus-remove-thread id)))
3195 (setq old-pos (gnus-point-at-bol))
3196 (setq current (save-excursion
3197 (and (zerop (forward-line -1))
3198 (gnus-summary-article-number))))
3199 ;; If this is a gathered thread, we have to go some re-gathering.
3200 (when (stringp (car thread))
3201 (let ((subject (car thread))
3203 (setq thread (cdr thread))
3205 (unless (memq (setq thr (gnus-id-to-thread
3207 (mail-header-id (caar thread)))))
3210 (setq thread (cdr thread)))
3211 ;; We now have all (unique) roots.
3212 (if (= (length roots) 1)
3213 ;; All the loose roots are now one solid root.
3214 (setq thread (car roots))
3215 (setq thread (cons subject (gnus-sort-threads roots))))))
3217 ;; We then insert this thread into the summary buffer.
3218 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3219 (if gnus-show-threads
3220 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3221 (gnus-summary-prepare-unthreaded thread))
3222 (setq data (nreverse gnus-newsgroup-data))
3223 (setq threads gnus-newsgroup-threads))
3224 ;; We splice the new data into the data structure.
3225 (gnus-data-enter-list current data (- (point) old-pos))
3226 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3228 (defun gnus-number-to-header (number)
3229 "Return the header for article NUMBER."
3230 (let ((headers gnus-newsgroup-headers))
3232 (not (= number (mail-header-number (car headers)))))
3237 (defun gnus-parent-headers (headers &optional generation)
3238 "Return the headers of the GENERATIONeth parent of HEADERS."
3240 (setq generation 1))
3243 (while (and parent headers (not (zerop generation)))
3244 (setq references (mail-header-references headers))
3245 (when (and references
3246 (setq parent (gnus-parent-id references))
3247 (setq headers (car (gnus-id-to-thread parent))))
3251 (defun gnus-id-to-thread (id)
3252 "Return the (sub-)thread where ID appears."
3253 (gnus-gethash id gnus-newsgroup-dependencies))
3255 (defun gnus-id-to-article (id)
3256 "Return the article number of ID."
3257 (let ((thread (gnus-id-to-thread id)))
3260 (mail-header-number (car thread)))))
3262 (defun gnus-id-to-header (id)
3263 "Return the article headers of ID."
3264 (car (gnus-id-to-thread id)))
3266 (defun gnus-article-displayed-root-p (article)
3267 "Say whether ARTICLE is a root(ish) article."
3268 (let ((level (gnus-summary-thread-level article))
3269 (refs (mail-header-references (gnus-summary-article-header article)))
3275 ((null (gnus-parent-id refs)) t)
3277 (null (setq particle (gnus-id-to-article
3278 (gnus-parent-id refs))))
3279 (null (gnus-summary-thread-level particle)))))))
3281 (defun gnus-root-id (id)
3282 "Return the id of the root of the thread where ID appears."
3284 (while (and id (setq prev (car (gnus-gethash
3285 id gnus-newsgroup-dependencies))))
3287 id (gnus-parent-id (mail-header-references prev))))
3290 (defun gnus-articles-in-thread (thread)
3291 "Return the list of articles in THREAD."
3292 (cons (mail-header-number (car thread))
3293 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3295 (defun gnus-remove-thread (id &optional dont-remove)
3296 "Remove the thread that has ID in it."
3297 (let ((dep gnus-newsgroup-dependencies)
3298 headers thread last-id)
3299 ;; First go up in this thread until we find the root.
3300 (setq last-id (gnus-root-id id))
3301 (setq headers (list (car (gnus-id-to-thread last-id))
3302 (caadr (gnus-id-to-thread last-id))))
3303 ;; We have now found the real root of this thread. It might have
3304 ;; been gathered into some loose thread, so we have to search
3305 ;; through the threads to find the thread we wanted.
3306 (let ((threads gnus-newsgroup-threads)
3309 (setq sub (car threads))
3310 (if (stringp (car sub))
3311 ;; This is a gathered thread, so we look at the roots
3312 ;; below it to find whether this article is in this
3315 (setq sub (cdr sub))
3317 (when (member (caar sub) headers)
3318 (setq thread (car threads)
3321 (setq sub (cdr sub))))
3322 ;; It's an ordinary thread, so we check it.
3323 (when (eq (car sub) (car headers))
3326 (setq threads (cdr threads)))
3327 ;; If this article is in no thread, then it's a root.
3330 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3331 (setq thread (gnus-gethash last-id dep)))
3334 thread ; We return this thread.
3336 (if (stringp (car thread))
3338 ;; If we use dummy roots, then we have to remove the
3339 ;; dummy root as well.
3340 (when (eq gnus-summary-make-false-root 'dummy)
3342 (gnus-data-compute-positions))
3343 (setq thread (cdr thread))
3345 (gnus-remove-thread-1 (car thread))
3346 (setq thread (cdr thread))))
3347 (gnus-remove-thread-1 thread))))))))
3349 (defun gnus-remove-thread-1 (thread)
3350 "Remove the thread THREAD recursively."
3351 (let ((number (mail-header-number (pop thread)))
3353 (setq thread (reverse thread))
3355 (gnus-remove-thread-1 (pop thread)))
3356 (when (setq d (gnus-data-find number))
3357 (goto-char (gnus-data-pos d))
3360 (- (gnus-point-at-bol)
3362 (1+ (gnus-point-at-eol))
3363 (gnus-delete-line)))))))
3365 (defun gnus-sort-threads (threads)
3367 (if (not gnus-thread-sort-functions)
3369 (gnus-message 7 "Sorting threads...")
3371 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3372 (gnus-message 7 "Sorting threads...done"))))
3374 (defun gnus-sort-articles (articles)
3376 (when gnus-article-sort-functions
3377 (gnus-message 7 "Sorting articles...")
3379 (setq gnus-newsgroup-headers
3380 (sort articles (gnus-make-sort-function
3381 gnus-article-sort-functions)))
3382 (gnus-message 7 "Sorting articles...done"))))
3384 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3385 (defmacro gnus-thread-header (thread)
3386 ;; Return header of first article in THREAD.
3387 ;; Note that THREAD must never, ever be anything else than a variable -
3388 ;; using some other form will lead to serious barfage.
3389 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3390 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3391 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3394 (defsubst gnus-article-sort-by-number (h1 h2)
3395 "Sort articles by article number."
3396 (< (mail-header-number h1)
3397 (mail-header-number h2)))
3399 (defun gnus-thread-sort-by-number (h1 h2)
3400 "Sort threads by root article number."
3401 (gnus-article-sort-by-number
3402 (gnus-thread-header h1) (gnus-thread-header h2)))
3404 (defsubst gnus-article-sort-by-lines (h1 h2)
3405 "Sort articles by article Lines header."
3406 (< (mail-header-lines h1)
3407 (mail-header-lines h2)))
3409 (defun gnus-thread-sort-by-lines (h1 h2)
3410 "Sort threads by root article Lines header."
3411 (gnus-article-sort-by-lines
3412 (gnus-thread-header h1) (gnus-thread-header h2)))
3414 (defsubst gnus-article-sort-by-author (h1 h2)
3415 "Sort articles by root author."
3417 (let ((extract (funcall
3418 gnus-extract-address-components
3419 (mail-header-from h1))))
3420 (or (car extract) (cadr extract) ""))
3421 (let ((extract (funcall
3422 gnus-extract-address-components
3423 (mail-header-from h2))))
3424 (or (car extract) (cadr extract) ""))))
3426 (defun gnus-thread-sort-by-author (h1 h2)
3427 "Sort threads by root author."
3428 (gnus-article-sort-by-author
3429 (gnus-thread-header h1) (gnus-thread-header h2)))
3431 (defsubst gnus-article-sort-by-subject (h1 h2)
3432 "Sort articles by root subject."
3434 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3435 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3437 (defun gnus-thread-sort-by-subject (h1 h2)
3438 "Sort threads by root subject."
3439 (gnus-article-sort-by-subject
3440 (gnus-thread-header h1) (gnus-thread-header h2)))
3442 (defsubst gnus-article-sort-by-date (h1 h2)
3443 "Sort articles by root article date."
3445 (gnus-date-get-time (mail-header-date h1))
3446 (gnus-date-get-time (mail-header-date h2))))
3448 (defun gnus-thread-sort-by-date (h1 h2)
3449 "Sort threads by root article date."
3450 (gnus-article-sort-by-date
3451 (gnus-thread-header h1) (gnus-thread-header h2)))
3453 (defsubst gnus-article-sort-by-score (h1 h2)
3454 "Sort articles by root article score.
3455 Unscored articles will be counted as having a score of zero."
3456 (> (or (cdr (assq (mail-header-number h1)
3457 gnus-newsgroup-scored))
3458 gnus-summary-default-score 0)
3459 (or (cdr (assq (mail-header-number h2)
3460 gnus-newsgroup-scored))
3461 gnus-summary-default-score 0)))
3463 (defun gnus-thread-sort-by-score (h1 h2)
3464 "Sort threads by root article score."
3465 (gnus-article-sort-by-score
3466 (gnus-thread-header h1) (gnus-thread-header h2)))
3468 (defun gnus-thread-sort-by-total-score (h1 h2)
3469 "Sort threads by the sum of all scores in the thread.
3470 Unscored articles will be counted as having a score of zero."
3471 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3473 (defun gnus-thread-total-score (thread)
3474 ;; This function find the total score of THREAD.
3475 (cond ((null thread)
3478 (if (stringp (car thread))
3479 (apply gnus-thread-score-function 0
3480 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3481 (gnus-thread-total-score-1 thread)))
3483 (gnus-thread-total-score-1 (list thread)))))
3485 (defun gnus-thread-total-score-1 (root)
3486 ;; This function find the total score of the thread below ROOT.
3487 (setq root (car root))
3488 (apply gnus-thread-score-function
3490 (mapcar 'gnus-thread-total-score
3491 (cdr (gnus-gethash (mail-header-id root)
3492 gnus-newsgroup-dependencies)))
3493 (when (> (mail-header-number root) 0)
3494 (list (or (cdr (assq (mail-header-number root)
3495 gnus-newsgroup-scored))
3496 gnus-summary-default-score 0))))
3497 (list gnus-summary-default-score)
3500 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3501 (defvar gnus-tmp-prev-subject nil)
3502 (defvar gnus-tmp-false-parent nil)
3503 (defvar gnus-tmp-root-expunged nil)
3504 (defvar gnus-tmp-dummy-line nil)
3506 (defun gnus-summary-prepare-threads (threads)
3507 "Prepare summary buffer from THREADS and indentation LEVEL.
3508 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3509 or a straight list of headers."
3510 (gnus-message 7 "Generating summary...")
3512 (setq gnus-newsgroup-threads threads)
3515 (let ((gnus-tmp-level 0)
3516 (default-score (or gnus-summary-default-score 0))
3517 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3518 thread number subject stack state gnus-tmp-gathered beg-match
3519 new-roots gnus-tmp-new-adopts thread-end
3520 gnus-tmp-header gnus-tmp-unread
3521 gnus-tmp-replied gnus-tmp-subject-or-nil
3522 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3523 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3524 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3526 (setq gnus-tmp-prev-subject nil)
3528 (if (vectorp (car threads))
3529 ;; If this is a straight (sic) list of headers, then a
3530 ;; threaded summary display isn't required, so we just create
3531 ;; an unthreaded one.
3532 (gnus-summary-prepare-unthreaded threads)
3534 ;; Do the threaded display.
3536 (while (or threads stack gnus-tmp-new-adopts new-roots)
3538 (if (and (= gnus-tmp-level 0)
3539 (not (setq gnus-tmp-dummy-line nil))
3542 (not gnus-tmp-false-parent)
3543 (or gnus-tmp-new-adopts new-roots))
3544 (if gnus-tmp-new-adopts
3545 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3546 thread (list (car gnus-tmp-new-adopts))
3547 gnus-tmp-header (caar thread)
3548 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3550 (setq thread (list (car new-roots))
3551 gnus-tmp-header (caar thread)
3552 new-roots (cdr new-roots))))
3555 ;; If there are some threads, we do them before the
3556 ;; threads on the stack.
3557 (setq thread threads
3558 gnus-tmp-header (caar thread))
3559 ;; There were no current threads, so we pop something off
3561 (setq state (car stack)
3562 gnus-tmp-level (car state)
3565 gnus-tmp-header (caar thread))))
3567 (setq gnus-tmp-false-parent nil)
3568 (setq gnus-tmp-root-expunged nil)
3569 (setq thread-end nil)
3571 (if (stringp gnus-tmp-header)
3572 ;; The header is a dummy root.
3574 ((eq gnus-summary-make-false-root 'adopt)
3575 ;; We let the first article adopt the rest.
3576 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3578 (setq gnus-tmp-gathered
3580 (lambda (h) (mail-header-number (car h)))
3583 (setq thread (cons (list (caar thread)
3586 (setq gnus-tmp-level -1
3587 gnus-tmp-false-parent t))
3588 ((eq gnus-summary-make-false-root 'empty)
3589 ;; We print adopted articles with empty subject fields.
3590 (setq gnus-tmp-gathered
3592 (lambda (h) (mail-header-number (car h)))
3595 (setq gnus-tmp-level -1))
3596 ((eq gnus-summary-make-false-root 'dummy)
3597 ;; We remember that we probably want to output a dummy
3599 (setq gnus-tmp-dummy-line gnus-tmp-header)
3600 (setq gnus-tmp-prev-subject gnus-tmp-header))
3602 ;; We do not make a root for the gathered
3603 ;; sub-threads at all.
3604 (setq gnus-tmp-level -1)))
3606 (setq number (mail-header-number gnus-tmp-header)
3607 subject (mail-header-subject gnus-tmp-header))
3610 ;; If the thread has changed subject, we might want to make
3611 ;; this subthread into a root.
3612 ((and (null gnus-thread-ignore-subject)
3613 (not (zerop gnus-tmp-level))
3614 gnus-tmp-prev-subject
3616 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3617 (setq new-roots (nconc new-roots (list (car thread)))
3619 gnus-tmp-header nil))
3620 ;; If the article lies outside the current limit,
3621 ;; then we do not display it.
3622 ((not (memq number gnus-newsgroup-limit))
3623 (setq gnus-tmp-gathered
3625 (lambda (h) (mail-header-number (car h)))
3628 (setq gnus-tmp-new-adopts (if (cdar thread)
3629 (append gnus-tmp-new-adopts
3631 gnus-tmp-new-adopts)
3633 gnus-tmp-header nil)
3634 (when (zerop gnus-tmp-level)
3635 (setq gnus-tmp-root-expunged t)))
3636 ;; Perhaps this article is to be marked as read?
3637 ((and gnus-summary-mark-below
3638 (< (or (cdr (assq number gnus-newsgroup-scored))
3640 gnus-summary-mark-below)
3641 ;; Don't touch sparse articles.
3642 (not (gnus-summary-article-sparse-p number))
3643 (not (gnus-summary-article-ancient-p number)))
3644 (setq gnus-newsgroup-unreads
3645 (delq number gnus-newsgroup-unreads))
3646 (if gnus-newsgroup-auto-expire
3647 (push number gnus-newsgroup-expirable)
3648 (push (cons number gnus-low-score-mark)
3649 gnus-newsgroup-reads))))
3651 (when gnus-tmp-header
3652 ;; We may have an old dummy line to output before this
3654 (when gnus-tmp-dummy-line
3655 (gnus-summary-insert-dummy-line
3656 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3657 (setq gnus-tmp-dummy-line nil))
3659 ;; Compute the mark.
3660 (setq gnus-tmp-unread (gnus-article-mark number))
3662 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3663 gnus-tmp-header gnus-tmp-level)
3664 gnus-newsgroup-data)
3666 ;; Actually insert the line.
3668 gnus-tmp-subject-or-nil
3670 ((and gnus-thread-ignore-subject
3671 gnus-tmp-prev-subject
3672 (not (inline (gnus-subject-equal
3673 gnus-tmp-prev-subject subject))))
3675 ((zerop gnus-tmp-level)
3676 (if (and (eq gnus-summary-make-false-root 'empty)
3677 (memq number gnus-tmp-gathered)
3678 gnus-tmp-prev-subject
3679 (inline (gnus-subject-equal
3680 gnus-tmp-prev-subject subject)))
3681 gnus-summary-same-subject
3683 (t gnus-summary-same-subject)))
3684 (if (and (eq gnus-summary-make-false-root 'adopt)
3685 (= gnus-tmp-level 1)
3686 (memq number gnus-tmp-gathered))
3687 (setq gnus-tmp-opening-bracket ?\<
3688 gnus-tmp-closing-bracket ?\>)
3689 (setq gnus-tmp-opening-bracket ?\[
3690 gnus-tmp-closing-bracket ?\]))
3692 gnus-tmp-indentation
3693 (aref gnus-thread-indent-array gnus-tmp-level)
3694 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3695 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3696 gnus-summary-default-score 0)
3698 (if (or (null gnus-summary-default-score)
3699 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3700 gnus-summary-zcore-fuzz))
3702 (if (< gnus-tmp-score gnus-summary-default-score)
3703 gnus-score-below-mark gnus-score-over-mark))
3705 (cond ((memq number gnus-newsgroup-processable)
3707 ((memq number gnus-newsgroup-cached)
3709 ((memq number gnus-newsgroup-replied)
3711 ((memq number gnus-newsgroup-saved)
3713 (t gnus-unread-mark))
3714 gnus-tmp-from (mail-header-from gnus-tmp-header)
3717 ((string-match "<[^>]+> *$" gnus-tmp-from)
3718 (setq beg-match (match-beginning 0))
3719 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3720 (substring gnus-tmp-from (1+ (match-beginning 0))
3721 (1- (match-end 0))))
3722 (substring gnus-tmp-from 0 beg-match)))
3723 ((string-match "(.+)" gnus-tmp-from)
3724 (substring gnus-tmp-from
3725 (1+ (match-beginning 0)) (1- (match-end 0))))
3727 (when (string= gnus-tmp-name "")
3728 (setq gnus-tmp-name gnus-tmp-from))
3729 (unless (numberp gnus-tmp-lines)
3730 (setq gnus-tmp-lines 0))
3731 (gnus-put-text-property
3733 (progn (eval gnus-summary-line-format-spec) (point))
3734 'gnus-number number)
3737 (gnus-run-hooks 'gnus-summary-update-hook)
3740 (setq gnus-tmp-prev-subject subject)))
3742 (when (nth 1 thread)
3743 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3744 (incf gnus-tmp-level)
3745 (setq threads (if thread-end nil (cdar thread)))
3747 (setq gnus-tmp-level 0)))))
3748 (gnus-message 7 "Generating summary...done"))
3750 (defun gnus-summary-prepare-unthreaded (headers)
3751 "Generate an unthreaded summary buffer based on HEADERS."
3752 (let (header number mark)
3757 ;; We may have to root out some bad articles...
3758 (when (memq (setq number (mail-header-number
3759 (setq header (pop headers))))
3760 gnus-newsgroup-limit)
3761 ;; Mark article as read when it has a low score.
3762 (when (and gnus-summary-mark-below
3763 (< (or (cdr (assq number gnus-newsgroup-scored))
3764 gnus-summary-default-score 0)
3765 gnus-summary-mark-below)
3766 (not (gnus-summary-article-ancient-p number)))
3767 (setq gnus-newsgroup-unreads
3768 (delq number gnus-newsgroup-unreads))
3769 (if gnus-newsgroup-auto-expire
3770 (push number gnus-newsgroup-expirable)
3771 (push (cons number gnus-low-score-mark)
3772 gnus-newsgroup-reads)))
3774 (setq mark (gnus-article-mark number))
3775 (push (gnus-data-make number mark (1+ (point)) header 0)
3776 gnus-newsgroup-data)
3777 (gnus-summary-insert-line
3779 mark (memq number gnus-newsgroup-replied)
3780 (memq number gnus-newsgroup-expirable)
3781 (mail-header-subject header) nil
3782 (cdr (assq number gnus-newsgroup-scored))
3783 (memq number gnus-newsgroup-processable))))))
3785 (defun gnus-select-newsgroup (group &optional read-all)
3786 "Select newsgroup GROUP.
3787 If READ-ALL is non-nil, all articles in the group are selected."
3788 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3789 ;;!!! Dirty hack; should be removed.
3790 (gnus-summary-ignore-duplicates
3791 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3793 gnus-summary-ignore-duplicates))
3794 (info (nth 2 entry))
3795 articles fetched-articles cached)
3797 (unless (gnus-check-server
3798 (setq gnus-current-select-method
3799 (gnus-find-method-for-group group)))
3800 (error "Couldn't open server"))
3802 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3803 (gnus-activate-group group) ; Or we can activate it...
3804 (progn ; Or we bug out.
3805 (when (equal major-mode 'gnus-summary-mode)
3806 (kill-buffer (current-buffer)))
3807 (error "Couldn't request group %s: %s"
3808 group (gnus-status-message group))))
3810 (unless (gnus-request-group group t)
3811 (when (equal major-mode 'gnus-summary-mode)
3812 (kill-buffer (current-buffer)))
3813 (error "Couldn't request group %s: %s"
3814 group (gnus-status-message group)))
3816 (setq gnus-newsgroup-name group)
3817 (setq gnus-newsgroup-unselected nil)
3818 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3820 ;; Adjust and set lists of article marks.
3822 (gnus-adjust-marked-articles info))
3824 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3825 (when (gnus-virtual-group-p group)
3826 (setq cached gnus-newsgroup-cached))
3828 (setq gnus-newsgroup-unreads
3829 (gnus-set-difference
3830 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3831 gnus-newsgroup-dormant))
3833 (setq gnus-newsgroup-processable nil)
3835 (gnus-update-read-articles group gnus-newsgroup-unreads)
3836 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3837 (gnus-group-update-group group))
3839 (setq articles (gnus-articles-to-read group read-all))
3843 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3845 ((eq articles 0) nil)
3847 ;; Init the dependencies hash table.
3848 (setq gnus-newsgroup-dependencies
3849 (gnus-make-hashtable (length articles)))
3850 ;; Retrieve the headers and read them in.
3851 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3852 (setq gnus-newsgroup-headers
3854 (setq gnus-headers-retrieved-by
3855 (gnus-retrieve-headers
3856 articles gnus-newsgroup-name
3857 ;; We might want to fetch old headers, but
3858 ;; not if there is only 1 article.
3859 (and gnus-fetch-old-headers
3861 (not (eq gnus-fetch-old-headers 'some))
3862 (not (numberp gnus-fetch-old-headers)))
3863 (> (length articles) 1))))))
3864 (gnus-get-newsgroup-headers-xover
3865 articles nil nil gnus-newsgroup-name t)
3866 (gnus-get-newsgroup-headers)))
3867 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3869 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3871 (setq gnus-newsgroup-cached cached))
3873 ;; Suppress duplicates?
3874 (when gnus-suppress-duplicates
3875 (gnus-dup-suppress-articles))
3877 ;; Set the initial limit.
3878 (setq gnus-newsgroup-limit (copy-sequence articles))
3879 ;; Remove canceled articles from the list of unread articles.
3880 (setq gnus-newsgroup-unreads
3881 (gnus-set-sorted-intersection
3882 gnus-newsgroup-unreads
3883 (setq fetched-articles
3884 (mapcar (lambda (headers) (mail-header-number headers))
3885 gnus-newsgroup-headers))))
3886 ;; Removed marked articles that do not exist.
3887 (gnus-update-missing-marks
3888 (gnus-sorted-complement fetched-articles articles))
3889 ;; Let the Gnus agent mark articles as read.
3891 (gnus-agent-get-undownloaded-list))
3892 ;; We might want to build some more threads first.
3893 (when (and gnus-fetch-old-headers
3894 (eq gnus-headers-retrieved-by 'nov))
3895 (if (eq gnus-fetch-old-headers 'invisible)
3896 (gnus-build-all-threads)
3897 (gnus-build-old-threads)))
3898 ;; Check whether auto-expire is to be done in this group.
3899 (setq gnus-newsgroup-auto-expire
3900 (gnus-group-auto-expirable-p group))
3901 ;; Set up the article buffer now, if necessary.
3902 (unless gnus-single-article-buffer
3903 (gnus-article-setup-buffer))
3904 ;; First and last article in this newsgroup.
3905 (when gnus-newsgroup-headers
3906 (setq gnus-newsgroup-begin
3907 (mail-header-number (car gnus-newsgroup-headers))
3910 (gnus-last-element gnus-newsgroup-headers))))
3911 ;; GROUP is successfully selected.
3912 (or gnus-newsgroup-headers t)))))
3914 (defun gnus-articles-to-read (group &optional read-all)
3915 ;; Find out what articles the user wants to read.
3917 ;; Select all articles if `read-all' is non-nil, or if there
3918 ;; are no unread articles.
3920 (and (zerop (length gnus-newsgroup-marked))
3921 (zerop (length gnus-newsgroup-unreads)))
3922 (eq (gnus-group-find-parameter group 'display)
3924 (gnus-uncompress-range (gnus-active group))
3925 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3926 (copy-sequence gnus-newsgroup-unreads))
3928 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3929 (scored (length scored-list))
3930 (number (length articles))
3931 (marked (+ (length gnus-newsgroup-marked)
3932 (length gnus-newsgroup-dormant)))
3940 ((and (or (<= scored marked) (= scored number))
3941 (numberp gnus-large-newsgroup)
3942 (> number gnus-large-newsgroup))
3946 "How many articles from %s (default %d): "
3947 (gnus-limit-string gnus-newsgroup-name 35)
3949 (if (string-match "^[ \t]*$" input) number input)))
3950 ((and (> scored marked) (< scored number)
3951 (> (- scored number) 20))
3954 (format "%s %s (%d scored, %d total): "
3955 "How many articles from"
3956 group scored number))))
3957 (if (string-match "^[ \t]*$" input)
3961 (setq select (if (stringp select) (string-to-number select) select))
3962 (if (or (null select) (zerop select))
3964 (if (and (not (zerop scored)) (<= (abs select) scored))
3966 (setq articles (sort scored-list '<))
3967 (setq number (length articles)))
3968 (setq articles (copy-sequence articles)))
3970 (when (< (abs select) number)
3972 ;; Select the N oldest articles.
3973 (setcdr (nthcdr (1- (abs select)) articles) nil)
3974 ;; Select the N most recent articles.
3975 (setq articles (nthcdr (- number select) articles))))
3976 (setq gnus-newsgroup-unselected
3977 (gnus-sorted-intersection
3978 gnus-newsgroup-unreads
3979 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3982 (defun gnus-killed-articles (killed articles)
3985 (when (inline (gnus-member-of-range (car articles) killed))
3986 (push (car articles) out))
3987 (setq articles (cdr articles)))
3990 (defun gnus-uncompress-marks (marks)
3991 "Uncompress the mark ranges in MARKS."
3992 (let ((uncompressed '(score bookmark))
3995 (if (memq (caar marks) uncompressed)
3996 (push (car marks) out)
3997 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3998 (setq marks (cdr marks)))
4001 (defun gnus-adjust-marked-articles (info)
4002 "Set all article lists and remove all marks that are no longer legal."
4003 (let* ((marked-lists (gnus-info-marks info))
4004 (active (gnus-active (gnus-info-group info)))
4007 (types gnus-article-mark-lists)
4008 (uncompressed '(score bookmark killed))
4009 marks var articles article mark)
4012 (setq marks (pop marked-lists))
4013 (set (setq var (intern (format "gnus-newsgroup-%s"
4014 (car (rassq (setq mark (car marks))
4016 (if (memq (car marks) uncompressed) (cdr marks)
4017 (gnus-uncompress-range (cdr marks))))
4019 (setq articles (symbol-value var))
4021 ;; All articles have to be subsets of the active articles.
4023 ;; Adjust "simple" lists.
4024 ((memq mark '(tick dormant expire reply save))
4026 (when (or (< (setq article (pop articles)) min) (> article max))
4027 (set var (delq article (symbol-value var))))))
4029 ((memq mark uncompressed)
4030 (when (not (listp (cdr (symbol-value var))))
4031 (set var (list (symbol-value var))))
4032 (when (not (listp (cdr articles)))
4033 (setq articles (list articles)))
4035 (when (or (not (consp (setq article (pop articles))))
4036 (< (car article) min)
4037 (> (car article) max))
4038 (set var (delq article (symbol-value var))))))))))
4040 (defun gnus-update-missing-marks (missing)
4041 "Go through the list of MISSING articles and remove them from the mark lists."
4043 (let ((types gnus-article-mark-lists)
4045 ;; Go through all types.
4047 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4048 (when (symbol-value var)
4049 ;; This list has articles. So we delete all missing articles
4053 (set var (delq (pop m) (symbol-value var)))))))))
4055 (defun gnus-update-marks ()
4056 "Enter the various lists of marked articles into the newsgroup info list."
4057 (let ((types gnus-article-mark-lists)
4058 (info (gnus-get-info gnus-newsgroup-name))
4059 (uncompressed '(score bookmark killed))
4060 type list newmarked symbol)
4062 ;; Add all marks lists that are non-nil to the list of marks lists.
4063 (while (setq type (pop types))
4064 (when (setq list (symbol-value
4066 (intern (format "gnus-newsgroup-%s"
4069 ;; Get rid of the entries of the articles that have the
4071 (when (and (eq (cdr type) 'score)
4075 (prev (cons nil list))
4078 (if (or (not (consp (car arts)))
4079 (= (cdar arts) gnus-summary-default-score))
4080 (setcdr prev (cdr arts))
4082 (setq arts (cdr arts)))
4083 (setq list (cdr all))))
4085 (push (cons (cdr type)
4086 (if (memq (cdr type) uncompressed) list
4087 (gnus-compress-sequence
4088 (set symbol (sort list '<)) t)))
4091 ;; Enter these new marks into the info of the group.
4093 (setcar (nthcdr 3 info) newmarked)
4094 ;; Add the marks lists to the end of the info.
4096 (setcdr (nthcdr 2 info) (list newmarked))))
4098 ;; Cut off the end of the info if there's nothing else there.
4102 (when (nthcdr (decf i) info)
4103 (setcdr (nthcdr i info) nil)))))))
4105 (defun gnus-set-mode-line (where)
4106 "This function sets the mode line of the article or summary buffers.
4107 If WHERE is `summary', the summary mode line format will be used."
4108 ;; Is this mode line one we keep updated?
4109 (when (memq where gnus-updated-mode-lines)
4112 ;; We evaluate this in the summary buffer since these
4113 ;; variables are buffer-local to that buffer.
4114 (set-buffer gnus-summary-buffer)
4115 ;; We bind all these variables that are used in the `eval' form
4117 (let* ((mformat (symbol-value
4119 (format "gnus-%s-mode-line-format-spec" where))))
4120 (gnus-tmp-group-name gnus-newsgroup-name)
4121 (gnus-tmp-article-number (or gnus-current-article 0))
4122 (gnus-tmp-unread gnus-newsgroup-unreads)
4123 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4124 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4125 (gnus-tmp-unread-and-unselected
4126 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4127 (zerop gnus-tmp-unselected))
4129 ((zerop gnus-tmp-unselected)
4130 (format "{%d more}" gnus-tmp-unread-and-unticked))
4131 (t (format "{%d(+%d) more}"
4132 gnus-tmp-unread-and-unticked
4133 gnus-tmp-unselected))))
4135 (if (and gnus-current-headers
4136 (vectorp gnus-current-headers))
4137 (gnus-mode-string-quote
4138 (mail-header-subject gnus-current-headers))
4140 bufname-length max-len
4141 gnus-tmp-header);; passed as argument to any user-format-funcs
4142 (setq mode-string (eval mformat))
4143 (setq bufname-length (if (string-match "%b" mode-string)
4146 (if (eq where 'summary)
4148 (get-buffer gnus-article-buffer))))
4151 (setq max-len (max 4 (if gnus-mode-non-string-length
4153 gnus-mode-non-string-length
4155 (length mode-string))))
4156 ;; We might have to chop a bit of the string off...
4157 (when (> (length mode-string) max-len)
4159 (concat (gnus-truncate-string mode-string (- max-len 3))
4161 ;; Pad the mode string a bit.
4162 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4163 ;; Update the mode line.
4164 (setq mode-line-buffer-identification
4165 (gnus-mode-line-buffer-identification (list mode-string)))
4166 (set-buffer-modified-p t))))
4168 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4169 "Go through the HEADERS list and add all Xrefs to a hash table.
4170 The resulting hash table is returned, or nil if no Xrefs were found."
4171 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4172 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4173 (xref-hashtb (gnus-make-hashtable))
4174 start group entry number xrefs header)
4176 (setq header (pop headers))
4177 (when (and (setq xrefs (mail-header-xref header))
4178 (not (memq (setq number (mail-header-number header))
4181 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4182 (setq start (match-end 0))
4183 (setq group (if prefix
4184 (concat prefix (substring xrefs (match-beginning 1)
4186 (substring xrefs (match-beginning 1) (match-end 1))))
4188 (string-to-int (substring xrefs (match-beginning 2)
4190 (if (setq entry (gnus-gethash group xref-hashtb))
4191 (setcdr entry (cons number (cdr entry)))
4192 (gnus-sethash group (cons number nil) xref-hashtb)))))
4193 (and start xref-hashtb)))
4195 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4196 "Look through all the headers and mark the Xrefs as read."
4197 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4198 name entry info xref-hashtb idlist method nth4)
4200 (set-buffer gnus-group-buffer)
4201 (when (setq xref-hashtb
4202 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4205 (unless (string= from-newsgroup (setq name (symbol-name group)))
4206 (setq idlist (symbol-value group))
4207 ;; Dead groups are not updated.
4209 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4211 (when (stringp (setq nth4 (gnus-info-method info)))
4212 (setq nth4 (gnus-server-to-method nth4))))
4213 ;; Only do the xrefs if the group has the same
4214 ;; select method as the group we have just read.
4215 (or (gnus-methods-equal-p
4216 nth4 (gnus-find-method-for-group from-newsgroup))
4218 (equal nth4 (setq method (gnus-find-method-for-group
4220 (and (equal (car nth4) (car method))
4221 (equal (nth 1 nth4) (nth 1 method))))
4222 gnus-use-cross-reference
4223 (or (not (eq gnus-use-cross-reference t))
4225 ;; Only do cross-references on subscribed
4226 ;; groups, if that is what is wanted.
4227 (<= (gnus-info-level info) gnus-level-subscribed))
4228 (gnus-group-make-articles-read name idlist))))
4231 (defun gnus-compute-read-articles (group articles)
4232 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4233 (info (nth 2 entry))
4234 (active (gnus-active group))
4237 ;; First peel off all illegal article numbers.
4239 (let ((ids articles)
4241 (while (setq id (pop ids))
4242 (when (and first (> id (cdr active)))
4243 ;; We'll end up in this situation in one particular
4244 ;; obscure situation. If you re-scan a group and get
4245 ;; a new article that is cross-posted to a different
4246 ;; group that has not been re-scanned, you might get
4247 ;; crossposted article that has a higher number than
4248 ;; Gnus believes possible. So we re-activate this
4249 ;; group as well. This might mean doing the
4250 ;; crossposting thingy will *increase* the number
4251 ;; of articles in some groups. Tsk, tsk.
4252 (setq active (or (gnus-activate-group group) active)))
4253 (when (or (> id (cdr active))
4254 (< id (car active)))
4255 (setq articles (delq id articles))))))
4256 ;; If the read list is nil, we init it.
4258 (null (gnus-info-read info))
4260 (setq ninfo (cons 1 (1- (car active))))
4261 (setq ninfo (gnus-info-read info)))
4262 ;; Then we add the read articles to the range.
4264 ninfo (setq articles (sort articles '<))))))
4266 (defun gnus-group-make-articles-read (group articles)
4267 "Update the info of GROUP to say that ARTICLES are read."
4269 (entry (gnus-gethash group gnus-newsrc-hashtb))
4270 (info (nth 2 entry))
4271 (active (gnus-active group))
4274 (setq range (gnus-compute-read-articles group articles))
4276 (set-buffer gnus-group-buffer)
4279 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4280 (gnus-info-set-read ',info ',(gnus-info-read info))
4281 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4282 (gnus-group-update-group ,group t))))
4283 ;; Add the read articles to the range.
4284 (gnus-info-set-read info range)
4285 ;; Then we have to re-compute how many unread
4286 ;; articles there are in this group.
4290 (setq num (- (1+ (cdr active)) (car active))))
4291 ((not (listp (cdr range)))
4292 (setq num (- (cdr active) (- (1+ (cdr range))
4296 (if (numberp (car range))
4298 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4299 (setq range (cdr range)))
4300 (setq num (- (cdr active) num))))
4301 ;; Update the number of unread articles.
4303 ;; Update the group buffer.
4304 (gnus-group-update-group group t)))))
4306 (defun gnus-methods-equal-p (m1 m2)
4307 (let ((m1 (or m1 gnus-select-method))
4308 (m2 (or m2 gnus-select-method)))
4310 (and (eq (car m1) (car m2))
4311 (or (not (memq 'address (assoc (symbol-name (car m1))
4312 gnus-valid-select-methods)))
4313 (equal (nth 1 m1) (nth 1 m2)))))))
4315 (defvar gnus-newsgroup-none-id 0)
4317 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4318 (let ((cur nntp-server-buffer)
4321 (save-excursion (set-buffer gnus-summary-buffer)
4322 gnus-newsgroup-dependencies)))
4323 headers id id-dep ref-dep end ref)
4325 (set-buffer nntp-server-buffer)
4326 ;; Translate all TAB characters into SPACE characters.
4327 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4328 (gnus-run-hooks 'gnus-parse-headers-hook)
4329 (let ((case-fold-search t)
4330 in-reply-to header p lines)
4331 (goto-char (point-min))
4332 ;; Search to the beginning of the next header. Error messages
4333 ;; do not begin with 2 or 3.
4334 (while (re-search-forward "^[23][0-9]+ " nil t)
4337 ;; This implementation of this function, with nine
4338 ;; search-forwards instead of the one re-search-forward and
4339 ;; a case (which basically was the old function) is actually
4340 ;; about twice as fast, even though it looks messier. You
4341 ;; can't have everything, I guess. Speed and elegance
4342 ;; doesn't always go hand in hand.
4351 (narrow-to-region (point)
4352 (or (and (search-forward "\n.\n" nil t)
4358 (if (search-forward "\nsubject: " nil t)
4360 gnus-unstructured-field-decoder (nnheader-header-value))
4365 (if (search-forward "\nfrom: " nil t)
4367 gnus-structured-field-decoder (nnheader-header-value))
4372 (if (search-forward "\ndate: " nil t)
4373 (nnheader-header-value) ""))
4377 (setq id (if (re-search-forward
4378 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4379 ;; We do it this way to make sure the Message-ID
4380 ;; is (somewhat) syntactically valid.
4381 (buffer-substring (match-beginning 1)
4383 ;; If there was no message-id, we just fake one
4384 ;; to make subsequent routines simpler.
4385 (nnheader-generate-fake-message-id))))
4389 (if (search-forward "\nreferences: " nil t)
4393 (nnheader-header-value)
4398 (search-backward ">" end t)
4401 (search-backward "<" end t)
4403 ;; Get the references from the in-reply-to header if there
4404 ;; were no references and the in-reply-to header looks
4406 (if (and (search-forward "\nin-reply-to: " nil t)
4407 (setq in-reply-to (nnheader-header-value))
4408 (string-match "<[^>]+>" in-reply-to))
4410 (setq ref (substring in-reply-to (match-beginning 0)
4412 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4413 (setq ref2 (substring in-reply-to (match-beginning 0)
4415 (when (> (length ref2) (length ref))
4423 (if (search-forward "\nlines: " nil t)
4424 (if (numberp (setq lines (ignore-errors (read cur))))
4430 (and (search-forward "\nxref: " nil t)
4431 (nnheader-header-value)))))
4432 (when (equal id ref)
4435 (when gnus-alter-header-function
4436 (funcall gnus-alter-header-function header)
4437 (setq id (mail-header-id header)
4438 ref (gnus-parent-id (mail-header-references header))))
4440 ;; We do the threading while we read the headers. The
4441 ;; message-id and the last reference are both entered into
4442 ;; the same hash table. Some tippy-toeing around has to be
4443 ;; done in case an article has arrived before the article
4444 ;; which it refers to.
4445 (if (boundp (setq id-dep (intern id dependencies)))
4446 (if (and (car (symbol-value id-dep))
4448 ;; An article with this Message-ID has already been seen.
4449 (if gnus-summary-ignore-duplicates
4450 ;; We ignore this one, except we add
4451 ;; any additional Xrefs (in case the two articles
4452 ;; came from different servers).
4454 (mail-header-set-xref
4455 (car (symbol-value id-dep))
4456 (concat (or (mail-header-xref
4457 (car (symbol-value id-dep)))
4459 (or (mail-header-xref header) "")))
4461 ;; We rename the Message-ID.
4463 (setq id-dep (intern (setq id (nnmail-message-id))
4466 (mail-header-set-id header id))
4467 (setcar (symbol-value id-dep) header))
4468 (set id-dep (list header)))
4470 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4471 (setcdr (symbol-value ref-dep)
4472 (nconc (cdr (symbol-value ref-dep))
4473 (list (symbol-value id-dep))))
4474 (set ref-dep (list nil (symbol-value id-dep))))
4475 (push header headers))
4476 (goto-char (point-max))
4478 (nreverse headers)))))
4480 ;; The following macros and functions were written by Felix Lee
4481 ;; <flee@cse.psu.edu>.
4483 (defmacro gnus-nov-read-integer ()
4485 (if (= (following-char) ?\t)
4487 (let ((num (ignore-errors (read buffer))))
4488 (if (numberp num) num 0)))
4490 (search-forward "\t" eol 'move))))
4492 (defmacro gnus-nov-skip-field ()
4493 '(search-forward "\t" eol 'move))
4495 (defmacro gnus-nov-field ()
4496 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4498 ;; (defvar gnus-nov-none-counter 0)
4500 ;; This function has to be called with point after the article number
4501 ;; on the beginning of the line.
4502 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4503 (let ((eol (gnus-point-at-eol))
4504 (buffer (current-buffer))
4505 header ref id id-dep ref-dep)
4507 ;; overview: [num subject from date id refs chars lines misc]
4510 (narrow-to-region (point) eol)
4518 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4520 gnus-structured-field-decoder (gnus-nov-field)) ; from
4521 (gnus-nov-field) ; date
4522 (setq id (or (gnus-nov-field)
4523 (nnheader-generate-fake-message-id))) ; id
4525 (let ((beg (point)))
4526 (search-forward "\t" eol)
4527 (if (search-backward ">" beg t)
4531 (or (search-backward "<" beg t) beg)))
4534 (gnus-nov-field)) ; refs
4535 (gnus-nov-read-integer) ; chars
4536 (gnus-nov-read-integer) ; lines
4537 (if (= (following-char) ?\n)
4539 (gnus-nov-field))))) ; misc
4543 (when gnus-alter-header-function
4544 (funcall gnus-alter-header-function header)
4545 (setq id (mail-header-id header)
4546 ref (gnus-parent-id (mail-header-references header))))
4548 ;; We build the thread tree.
4549 (when (equal id ref)
4550 ;; This article refers back to itself. Naughty, naughty.
4552 (if (boundp (setq id-dep (intern id dependencies)))
4553 (if (and (car (symbol-value id-dep))
4555 ;; An article with this Message-ID has already been seen.
4556 (if gnus-summary-ignore-duplicates
4557 ;; We ignore this one, except we add any additional
4558 ;; Xrefs (in case the two articles came from different
4561 (mail-header-set-xref
4562 (car (symbol-value id-dep))
4563 (concat (or (mail-header-xref
4564 (car (symbol-value id-dep)))
4566 (or (mail-header-xref header) "")))
4568 ;; We rename the Message-ID.
4570 (setq id-dep (intern (setq id (nnmail-message-id))
4573 (mail-header-set-id header id))
4574 (setcar (symbol-value id-dep) header))
4575 (set id-dep (list header)))
4577 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4578 (setcdr (symbol-value ref-dep)
4579 (nconc (cdr (symbol-value ref-dep))
4580 (list (symbol-value id-dep))))
4581 (set ref-dep (list nil (symbol-value id-dep)))))
4584 ;; Goes through the xover lines and returns a list of vectors
4585 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4586 force-new dependencies
4587 group also-fetch-heads)
4588 "Parse the news overview data in the server buffer, and return a
4589 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4590 ;; Get the Xref when the users reads the articles since most/some
4591 ;; NNTP servers do not include Xrefs when using XOVER.
4592 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4593 (let ((cur nntp-server-buffer)
4594 (dependencies (or dependencies gnus-newsgroup-dependencies))
4595 number headers header)
4597 (set-buffer nntp-server-buffer)
4598 ;; Allow the user to mangle the headers before parsing them.
4599 (gnus-run-hooks 'gnus-parse-headers-hook)
4600 (goto-char (point-min))
4603 (while (and sequence (not (eobp)))
4604 (setq number (read cur))
4605 (while (and sequence
4606 (< (car sequence) number))
4607 (setq sequence (cdr sequence)))
4609 (eq number (car sequence))
4611 (setq sequence (cdr sequence))
4612 (setq header (inline
4613 (gnus-nov-parse-line
4614 number dependencies force-new))))
4615 (push header headers))
4618 (gnus-error 4 "Strange nov line (%d)"
4619 (count-lines (point-min) (point)))))
4621 ;; A common bug in inn is that if you have posted an article and
4622 ;; then retrieves the active file, it will answer correctly --
4623 ;; the new article is included. However, a NOV entry for the
4624 ;; article may not have been generated yet, so this may fail.
4625 ;; We work around this problem by retrieving the last few
4626 ;; headers using HEAD.
4627 (if (or (not also-fetch-heads)
4629 ;; We (probably) got all the headers.
4631 (let ((gnus-nov-is-evil t))
4634 (when (gnus-retrieve-headers sequence group)
4635 (gnus-get-newsgroup-headers))))))))
4637 (defun gnus-article-get-xrefs ()
4638 "Fill in the Xref value in `gnus-current-headers', if necessary.
4639 This is meant to be called in `gnus-article-internal-prepare-hook'."
4640 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4641 gnus-current-headers)))
4642 (or (not gnus-use-cross-reference)
4644 (and (mail-header-xref headers)
4645 (not (string= (mail-header-xref headers) "")))
4646 (let ((case-fold-search t)
4649 (nnheader-narrow-to-headers)
4650 (goto-char (point-min))
4651 (when (or (and (eq (downcase (following-char)) ?x)
4652 (looking-at "Xref:"))
4653 (search-forward "\nXref:" nil t))
4654 (goto-char (1+ (match-end 0)))
4655 (setq xref (buffer-substring (point)
4656 (progn (end-of-line) (point))))
4657 (mail-header-set-xref headers xref)))))))
4659 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4660 "Find article ID and insert the summary line for that article."
4661 (let ((header (cond ((and old-header use-old-header)
4664 (gnus-number-to-header id))
4665 (gnus-number-to-header id))
4667 (gnus-read-header id))))
4668 (number (and (numberp id) id))
4671 ;; Rebuild the thread that this article is part of and go to the
4672 ;; article we have fetched.
4673 (when (and (not gnus-show-threads)
4676 (setq d (gnus-data-find (mail-header-number old-header))))
4677 (goto-char (gnus-data-pos d))
4680 (- (gnus-point-at-bol)
4682 (1+ (gnus-point-at-eol))
4683 (gnus-delete-line))))))
4685 (mail-header-set-number header (mail-header-number old-header)))
4686 (setq gnus-newsgroup-sparse
4687 (delq (setq number (mail-header-number header))
4688 gnus-newsgroup-sparse))
4689 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4690 (push number gnus-newsgroup-limit)
4691 (gnus-rebuild-thread (mail-header-id header))
4692 (gnus-summary-goto-subject number nil t))
4693 (when (and (numberp number)
4695 ;; We have to update the boundaries even if we can't fetch the
4696 ;; article if ID is a number -- so that the next `P' or `N'
4697 ;; command will fetch the previous (or next) article even
4698 ;; if the one we tried to fetch this time has been canceled.
4699 (when (> number gnus-newsgroup-end)
4700 (setq gnus-newsgroup-end number))
4701 (when (< number gnus-newsgroup-begin)
4702 (setq gnus-newsgroup-begin number))
4703 (setq gnus-newsgroup-unselected
4704 (delq number gnus-newsgroup-unselected)))
4705 ;; Report back a success?
4706 (and header (mail-header-number header))))
4708 ;;; Process/prefix in the summary buffer
4710 (defun gnus-summary-work-articles (n)
4711 "Return a list of articles to be worked upon. The prefix argument,
4712 the list of process marked articles, and the current article will be
4713 taken into consideration."
4715 (set-buffer gnus-summary-buffer)
4718 ;; A numerical prefix has been given.
4719 (setq n (prefix-numeric-value n))
4720 (let ((backward (< n 0))
4721 (n (abs (prefix-numeric-value n)))
4726 (push (setq article (gnus-summary-article-number))
4729 (gnus-summary-find-prev nil article)
4730 (gnus-summary-find-next nil article)))
4732 (nreverse articles)))
4733 ((and (gnus-region-active-p) (mark))
4734 (message "region active")
4735 ;; Work on the region between point and mark.
4736 (let ((max (max (point) (mark)))
4739 (goto-char (min (point) (mark)))
4742 (push (setq article (gnus-summary-article-number)) articles)
4743 (gnus-summary-find-next nil article)
4745 (nreverse articles))))
4746 (gnus-newsgroup-processable
4747 ;; There are process-marked articles present.
4748 ;; Save current state.
4749 (gnus-summary-save-process-mark)
4751 (reverse gnus-newsgroup-processable))
4753 ;; Just return the current article.
4754 (list (gnus-summary-article-number))))))
4756 (defun gnus-summary-save-process-mark ()
4757 "Push the current set of process marked articles on the stack."
4759 (push (copy-sequence gnus-newsgroup-processable)
4760 gnus-newsgroup-process-stack))
4762 (defun gnus-summary-kill-process-mark ()
4763 "Push the current set of process marked articles on the stack and unmark."
4765 (gnus-summary-save-process-mark)
4766 (gnus-summary-unmark-all-processable))
4768 (defun gnus-summary-yank-process-mark ()
4769 "Pop the last process mark state off the stack and restore it."
4771 (unless gnus-newsgroup-process-stack
4772 (error "Empty mark stack"))
4773 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4775 (defun gnus-summary-process-mark-set (set)
4776 "Make SET into the current process marked articles."
4777 (gnus-summary-unmark-all-processable)
4779 (gnus-summary-set-process-mark (pop set))))
4781 ;;; Searching and stuff
4783 (defun gnus-summary-search-group (&optional backward use-level)
4784 "Search for next unread newsgroup.
4785 If optional argument BACKWARD is non-nil, search backward instead."
4787 (set-buffer gnus-group-buffer)
4788 (when (gnus-group-search-forward
4789 backward nil (if use-level (gnus-group-group-level) nil))
4790 (gnus-group-group-name))))
4792 (defun gnus-summary-best-group (&optional exclude-group)
4793 "Find the name of the best unread group.
4794 If EXCLUDE-GROUP, do not go to this group."
4796 (set-buffer gnus-group-buffer)
4798 (gnus-group-best-unread-group exclude-group))))
4800 (defun gnus-summary-find-next (&optional unread article backward)
4801 (if backward (gnus-summary-find-prev)
4802 (let* ((dummy (gnus-summary-article-intangible-p))
4803 (article (or article (gnus-summary-article-number)))
4804 (arts (gnus-data-find-list article))
4806 (when (and (not dummy)
4807 (or (not gnus-summary-check-current)
4809 (not (gnus-data-unread-p (car arts)))))
4810 (setq arts (cdr arts)))
4815 (when (gnus-data-unread-p (car arts))
4816 (setq result (car arts)
4818 (setq arts (cdr arts)))
4821 (goto-char (gnus-data-pos result))
4822 (gnus-data-number result)))))
4824 (defun gnus-summary-find-prev (&optional unread article)
4825 (let* ((eobp (eobp))
4826 (article (or article (gnus-summary-article-number)))
4827 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4829 (when (and (not eobp)
4830 (or (not gnus-summary-check-current)
4832 (not (gnus-data-unread-p (car arts)))))
4833 (setq arts (cdr arts)))
4838 (when (gnus-data-unread-p (car arts))
4839 (setq result (car arts)
4841 (setq arts (cdr arts)))
4844 (goto-char (gnus-data-pos result))
4845 (gnus-data-number result))))
4847 (defun gnus-summary-find-subject (subject &optional unread backward article)
4848 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4849 (article (or article (gnus-summary-article-number)))
4850 (articles (gnus-data-list backward))
4851 (arts (gnus-data-find-list article articles))
4853 (when (or (not gnus-summary-check-current)
4855 (not (gnus-data-unread-p (car arts))))
4856 (setq arts (cdr arts)))
4858 (and (or (not unread)
4859 (gnus-data-unread-p (car arts)))
4860 (vectorp (gnus-data-header (car arts)))
4862 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4863 (setq result (car arts)
4865 (setq arts (cdr arts)))
4867 (goto-char (gnus-data-pos result))
4868 (gnus-data-number result))))
4870 (defun gnus-summary-search-forward (&optional unread subject backward)
4871 "Search forward for an article.
4872 If UNREAD, look for unread articles. If SUBJECT, look for
4873 articles with that subject. If BACKWARD, search backward instead."
4874 (cond (subject (gnus-summary-find-subject subject unread backward))
4875 (backward (gnus-summary-find-prev unread))
4876 (t (gnus-summary-find-next unread))))
4878 (defun gnus-recenter (&optional n)
4879 "Center point in window and redisplay frame.
4880 Also do horizontal recentering."
4882 (when (and gnus-auto-center-summary
4883 (not (eq gnus-auto-center-summary 'vertical)))
4884 (gnus-horizontal-recenter))
4887 (defun gnus-summary-recenter ()
4888 "Center point in the summary window.
4889 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4890 displayed, no centering will be performed."
4891 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4892 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4893 (let* ((top (cond ((< (window-height) 4) 0)
4894 ((< (window-height) 7) 1)
4896 (height (1- (window-height)))
4897 (bottom (save-excursion (goto-char (point-max))
4898 (forward-line (- height))
4900 (window (get-buffer-window (current-buffer))))
4901 ;; The user has to want it.
4902 (when gnus-auto-center-summary
4903 (when (get-buffer-window gnus-article-buffer)
4904 ;; Only do recentering when the article buffer is displayed,
4905 ;; Set the window start to either `bottom', which is the biggest
4906 ;; possible valid number, or the second line from the top,
4907 ;; whichever is the least.
4909 window (min bottom (save-excursion
4910 (forward-line (- top)) (point)))))
4911 ;; Do horizontal recentering while we're at it.
4912 (when (and (get-buffer-window (current-buffer) t)
4913 (not (eq gnus-auto-center-summary 'vertical)))
4914 (let ((selected (selected-window)))
4915 (select-window (get-buffer-window (current-buffer) t))
4916 (gnus-summary-position-point)
4917 (gnus-horizontal-recenter)
4918 (select-window selected))))))
4920 (defun gnus-summary-jump-to-group (newsgroup)
4921 "Move point to NEWSGROUP in group mode buffer."
4922 ;; Keep update point of group mode buffer if visible.
4923 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4924 (save-window-excursion
4925 ;; Take care of tree window mode.
4926 (when (get-buffer-window gnus-group-buffer)
4927 (pop-to-buffer gnus-group-buffer))
4928 (gnus-group-jump-to-group newsgroup))
4930 ;; Take care of tree window mode.
4931 (if (get-buffer-window gnus-group-buffer)
4932 (pop-to-buffer gnus-group-buffer)
4933 (set-buffer gnus-group-buffer))
4934 (gnus-group-jump-to-group newsgroup))))
4936 ;; This function returns a list of article numbers based on the
4937 ;; difference between the ranges of read articles in this group and
4938 ;; the range of active articles.
4939 (defun gnus-list-of-unread-articles (group)
4940 (let* ((read (gnus-info-read (gnus-get-info group)))
4941 (active (or (gnus-active group) (gnus-activate-group group)))
4944 ;; If none are read, then all are unread.
4946 (setq first (car active))
4947 ;; If the range of read articles is a single range, then the
4948 ;; first unread article is the article after the last read
4949 ;; article. Sounds logical, doesn't it?
4950 (if (not (listp (cdr read)))
4951 (setq first (1+ (cdr read)))
4952 ;; `read' is a list of ranges.
4953 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4959 (while (< first nlast)
4961 (setq first (1+ first))))
4962 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4963 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4964 (setq read (cdr read)))))
4965 ;; And add the last unread articles.
4966 (while (<= first last)
4968 (setq first (1+ first)))
4969 ;; Return the list of unread articles.
4970 (delq 0 (nreverse unread))))
4972 (defun gnus-list-of-read-articles (group)
4973 "Return a list of unread, unticked and non-dormant articles."
4974 (let* ((info (gnus-get-info group))
4975 (marked (gnus-info-marks info))
4976 (active (gnus-active group)))
4978 (gnus-set-difference
4979 (gnus-sorted-complement
4980 (gnus-uncompress-range active)
4981 (gnus-list-of-unread-articles group))
4983 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4984 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4986 ;; Various summary commands
4988 (defun gnus-summary-select-article-buffer ()
4989 "Reconfigure windows to show article buffer."
4991 (if (not (gnus-buffer-live-p gnus-article-buffer))
4992 (error "There is no article buffer for this summary buffer")
4993 (gnus-configure-windows 'article)
4994 (select-window (get-buffer-window gnus-article-buffer))))
4996 (defun gnus-summary-universal-argument (arg)
4997 "Perform any operation on all articles that are process/prefixed."
4999 (let ((articles (gnus-summary-work-articles arg))
5006 (substitute-command-keys
5007 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5010 (gnus-error 1 "Undefined key")
5013 (gnus-summary-goto-subject (setq article (pop articles)))
5014 (let (gnus-newsgroup-processable)
5015 (command-execute func))
5016 (gnus-summary-remove-process-mark article)))))
5017 (gnus-summary-position-point))
5019 (defun gnus-summary-toggle-truncation (&optional arg)
5020 "Toggle truncation of summary lines.
5021 With arg, turn line truncation on iff arg is positive."
5023 (setq truncate-lines
5024 (if (null arg) (not truncate-lines)
5025 (> (prefix-numeric-value arg) 0)))
5028 (defun gnus-summary-reselect-current-group (&optional all rescan)
5029 "Exit and then reselect the current newsgroup.
5030 The prefix argument ALL means to select all articles."
5032 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5033 (error "Ephemeral groups can't be reselected"))
5034 (let ((current-subject (gnus-summary-article-number))
5035 (group gnus-newsgroup-name))
5036 (setq gnus-newsgroup-begin nil)
5038 ;; We have to adjust the point of group mode buffer because
5039 ;; point was moved to the next unread newsgroup by exiting.
5040 (gnus-summary-jump-to-group group)
5043 (gnus-group-get-new-news-this-group 1)))
5044 (gnus-group-read-group all t)
5045 (gnus-summary-goto-subject current-subject nil t)))
5047 (defun gnus-summary-rescan-group (&optional all)
5048 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5050 (gnus-summary-reselect-current-group all t))
5052 (defun gnus-summary-update-info (&optional non-destructive)
5054 (let ((group gnus-newsgroup-name))
5056 (when gnus-newsgroup-kill-headers
5057 (setq gnus-newsgroup-killed
5058 (gnus-compress-sequence
5060 (gnus-set-sorted-intersection
5061 (gnus-uncompress-range gnus-newsgroup-killed)
5062 (setq gnus-newsgroup-unselected
5063 (sort gnus-newsgroup-unselected '<)))
5064 (setq gnus-newsgroup-unreads
5065 (sort gnus-newsgroup-unreads '<)))
5067 (unless (listp (cdr gnus-newsgroup-killed))
5068 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5069 (let ((headers gnus-newsgroup-headers))
5070 (when (and (not gnus-save-score)
5071 (not non-destructive))
5072 (setq gnus-newsgroup-scored nil))
5073 ;; Set the new ranges of read articles.
5075 (set-buffer gnus-group-buffer)
5076 (gnus-undo-force-boundary))
5077 (gnus-update-read-articles
5078 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5079 ;; Set the current article marks.
5081 ;; Do the cross-ref thing.
5082 (when gnus-use-cross-reference
5083 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5084 ;; Do not switch windows but change the buffer to work.
5085 (set-buffer gnus-group-buffer)
5086 (unless (gnus-ephemeral-group-p group)
5087 (gnus-group-update-group group)))))))
5089 (defun gnus-summary-save-newsrc (&optional force)
5090 "Save the current number of read/marked articles in the dribble buffer.
5091 The dribble buffer will then be saved.
5092 If FORCE (the prefix), also save the .newsrc file(s)."
5094 (gnus-summary-update-info t)
5096 (gnus-save-newsrc-file)
5097 (gnus-dribble-save)))
5099 (defun gnus-summary-exit (&optional temporary)
5100 "Exit reading current newsgroup, and then return to group selection mode.
5101 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5103 (gnus-set-global-variables)
5104 (gnus-kill-save-kill-buffer)
5105 (gnus-async-halt-prefetch)
5106 (let* ((group gnus-newsgroup-name)
5107 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5110 (buf (current-buffer)))
5111 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5112 ;; If we have several article buffers, we kill them at exit.
5113 (unless gnus-single-article-buffer
5114 (gnus-kill-buffer gnus-original-article-buffer)
5115 (setq gnus-article-current nil))
5116 (when gnus-use-cache
5117 (gnus-cache-possibly-remove-articles)
5118 (gnus-cache-save-buffers))
5119 (gnus-async-prefetch-remove-group group)
5120 (when gnus-suppress-duplicates
5121 (gnus-dup-enter-articles))
5122 (when gnus-use-trees
5123 (gnus-tree-close group))
5124 ;; Remove entries for this group.
5125 (nnmail-purge-split-history (gnus-group-real-name group))
5126 ;; Make all changes in this group permanent.
5128 (gnus-run-hooks 'gnus-exit-group-hook)
5129 (gnus-summary-update-info)
5130 ;; Do adaptive scoring, and possibly save score files.
5131 (when gnus-newsgroup-adaptive
5132 (gnus-score-adaptive))
5133 (when gnus-use-scoring
5135 (gnus-close-group group)
5136 ;; Make sure where we were, and go to next newsgroup.
5137 (set-buffer gnus-group-buffer)
5139 (gnus-group-jump-to-group group))
5140 (gnus-run-hooks 'gnus-summary-exit-hook)
5141 (unless (or quit-config
5142 ;; If this group has disappeared from the summary
5143 ;; buffer, don't skip forwards.
5144 (not (string= group (gnus-group-group-name))))
5145 (gnus-group-next-unread-group 1))
5146 (setq group-point (point))
5149 ;; If we have several article buffers, we kill them at exit.
5150 (unless gnus-single-article-buffer
5151 (gnus-kill-buffer gnus-article-buffer)
5152 (gnus-kill-buffer gnus-original-article-buffer)
5153 (setq gnus-article-current nil))
5155 (if (not gnus-kill-summary-on-exit)
5156 (gnus-deaden-summary)
5157 ;; We set all buffer-local variables to nil. It is unclear why
5158 ;; this is needed, but if we don't, buffer-local variables are
5159 ;; not garbage-collected, it seems. This would the lead to en
5160 ;; ever-growing Emacs.
5161 (gnus-summary-clear-local-variables)
5162 (when (get-buffer gnus-article-buffer)
5163 (bury-buffer gnus-article-buffer))
5164 ;; We clear the global counterparts of the buffer-local
5165 ;; variables as well, just to be on the safe side.
5166 (set-buffer gnus-group-buffer)
5167 (gnus-summary-clear-local-variables)
5168 ;; Return to group mode buffer.
5169 (when (eq mode 'gnus-summary-mode)
5170 (gnus-kill-buffer buf)))
5171 (setq gnus-current-select-method gnus-select-method)
5172 (pop-to-buffer gnus-group-buffer)
5173 ;; Clear the current group name.
5174 (if (not quit-config)
5176 (goto-char group-point)
5177 (gnus-configure-windows 'group 'force))
5178 (gnus-handle-ephemeral-exit quit-config))
5180 (setq gnus-newsgroup-name nil)))))
5182 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5183 (defun gnus-summary-exit-no-update (&optional no-questions)
5184 "Quit reading current newsgroup without updating read article info."
5186 (let* ((group gnus-newsgroup-name)
5187 (quit-config (gnus-group-quit-config group)))
5188 (when (or no-questions
5190 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5191 (gnus-async-halt-prefetch)
5192 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5193 ;; If we have several article buffers, we kill them at exit.
5194 (unless gnus-single-article-buffer
5195 (gnus-kill-buffer gnus-article-buffer)
5196 (gnus-kill-buffer gnus-original-article-buffer)
5197 (setq gnus-article-current nil))
5198 (if (not gnus-kill-summary-on-exit)
5199 (gnus-deaden-summary)
5200 (gnus-close-group group)
5201 (gnus-summary-clear-local-variables)
5202 (set-buffer gnus-group-buffer)
5203 (gnus-summary-clear-local-variables)
5204 (when (get-buffer gnus-summary-buffer)
5205 (kill-buffer gnus-summary-buffer)))
5206 (unless gnus-single-article-buffer
5207 (setq gnus-article-current nil))
5208 (when gnus-use-trees
5209 (gnus-tree-close group))
5210 (gnus-async-prefetch-remove-group group)
5211 (when (get-buffer gnus-article-buffer)
5212 (bury-buffer gnus-article-buffer))
5213 ;; Return to the group buffer.
5214 (gnus-configure-windows 'group 'force)
5215 ;; Clear the current group name.
5216 (setq gnus-newsgroup-name nil)
5217 (when (equal (gnus-group-group-name) group)
5218 (gnus-group-next-unread-group 1))
5220 (gnus-handle-ephemeral-exit quit-config)))))
5222 (defun gnus-handle-ephemeral-exit (quit-config)
5223 "Handle movement when leaving an ephemeral group. The state
5224 which existed when entering the ephemeral is reset."
5225 (if (not (buffer-name (car quit-config)))
5226 (gnus-configure-windows 'group 'force)
5227 (set-buffer (car quit-config))
5228 (cond ((eq major-mode 'gnus-summary-mode)
5229 (gnus-set-global-variables))
5230 ((eq major-mode 'gnus-article-mode)
5232 ;; The `gnus-summary-buffer' variable may point
5233 ;; to the old summary buffer when using a single
5235 (unless (gnus-buffer-live-p gnus-summary-buffer)
5236 (set-buffer gnus-group-buffer))
5237 (set-buffer gnus-summary-buffer)
5238 (gnus-set-global-variables))))
5239 (if (or (eq (cdr quit-config) 'article)
5240 (eq (cdr quit-config) 'pick))
5242 ;; The current article may be from the ephemeral group
5243 ;; thus it is best that we reload this article
5244 (gnus-summary-show-article)
5245 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5246 (gnus-configure-windows 'pick 'force)
5247 (gnus-configure-windows (cdr quit-config) 'force)))
5248 (gnus-configure-windows (cdr quit-config) 'force))
5249 (when (eq major-mode 'gnus-summary-mode)
5250 (gnus-summary-next-subject 1 nil t)
5251 (gnus-summary-recenter)
5252 (gnus-summary-position-point))))
5254 (defun gnus-summary-preview-mime-message (arg)
5255 "MIME decode and play this message."
5257 (let ((gnus-break-pages nil))
5258 (gnus-summary-select-article t t)
5260 (pop-to-buffer gnus-original-article-buffer t)
5261 (let (buffer-read-only)
5262 (if (text-property-any (point-min) (point-max) 'invisible t)
5263 (remove-text-properties (point-min) (point-max)
5264 gnus-hidden-properties)
5266 (mime-view-mode nil nil nil gnus-original-article-buffer
5267 gnus-article-buffer)
5270 (defun gnus-summary-scroll-down ()
5271 "Scroll down one line current article."
5273 (gnus-summary-scroll-up -1)
5278 (defvar gnus-dead-summary-mode-map nil)
5280 (unless gnus-dead-summary-mode-map
5281 (setq gnus-dead-summary-mode-map (make-keymap))
5282 (suppress-keymap gnus-dead-summary-mode-map)
5283 (substitute-key-definition
5284 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5285 (let ((keys '("\C-d" "\r" "\177" [delete])))
5287 (define-key gnus-dead-summary-mode-map
5288 (pop keys) 'gnus-summary-wake-up-the-dead))))
5290 (defvar gnus-dead-summary-mode nil
5291 "Minor mode for Gnus summary buffers.")
5293 (defun gnus-dead-summary-mode (&optional arg)
5294 "Minor mode for Gnus summary buffers."
5296 (when (eq major-mode 'gnus-summary-mode)
5297 (make-local-variable 'gnus-dead-summary-mode)
5298 (setq gnus-dead-summary-mode
5299 (if (null arg) (not gnus-dead-summary-mode)
5300 (> (prefix-numeric-value arg) 0)))
5301 (when gnus-dead-summary-mode
5302 (gnus-add-minor-mode
5303 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5305 (defun gnus-deaden-summary ()
5306 "Make the current summary buffer into a dead summary buffer."
5307 ;; Kill any previous dead summary buffer.
5308 (when (and gnus-dead-summary
5309 (buffer-name gnus-dead-summary))
5311 (set-buffer gnus-dead-summary)
5312 (when gnus-dead-summary-mode
5313 (kill-buffer (current-buffer)))))
5314 ;; Make this the current dead summary.
5315 (setq gnus-dead-summary (current-buffer))
5316 (gnus-dead-summary-mode 1)
5317 (let ((name (buffer-name)))
5318 (when (string-match "Summary" name)
5320 (concat (substring name 0 (match-beginning 0)) "Dead "
5321 (substring name (match-beginning 0)))
5324 (defun gnus-kill-or-deaden-summary (buffer)
5325 "Kill or deaden the summary BUFFER."
5327 (when (and (buffer-name buffer)
5328 (not gnus-single-article-buffer))
5331 (gnus-kill-buffer gnus-article-buffer)
5332 (gnus-kill-buffer gnus-original-article-buffer)))
5333 (cond (gnus-kill-summary-on-exit
5334 (when (and gnus-use-trees
5335 (and (get-buffer buffer)
5336 (buffer-name (get-buffer buffer))))
5338 (set-buffer (get-buffer buffer))
5339 (gnus-tree-close gnus-newsgroup-name)))
5340 (gnus-kill-buffer buffer))
5341 ((and (get-buffer buffer)
5342 (buffer-name (get-buffer buffer)))
5345 (gnus-deaden-summary))))))
5347 (defun gnus-summary-wake-up-the-dead (&rest args)
5348 "Wake up the dead summary buffer."
5350 (gnus-dead-summary-mode -1)
5351 (let ((name (buffer-name)))
5352 (when (string-match "Dead " name)
5354 (concat (substring name 0 (match-beginning 0))
5355 (substring name (match-end 0)))
5357 (gnus-message 3 "This dead summary is now alive again"))
5359 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5360 (defun gnus-summary-fetch-faq (&optional faq-dir)
5361 "Fetch the FAQ for the current group.
5362 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5366 (when current-prefix-arg
5368 "Faq dir: " (and (listp gnus-group-faq-directory)
5369 (mapcar (lambda (file) (list file))
5370 gnus-group-faq-directory))))))
5371 (let (gnus-faq-buffer)
5372 (when (setq gnus-faq-buffer
5373 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5374 (gnus-configure-windows 'summary-faq))))
5376 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5377 (defun gnus-summary-describe-group (&optional force)
5378 "Describe the current newsgroup."
5380 (gnus-group-describe-group force gnus-newsgroup-name))
5382 (defun gnus-summary-describe-briefly ()
5383 "Describe summary mode commands briefly."
5386 (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")))
5388 ;; Walking around group mode buffer from summary mode.
5390 (defun gnus-summary-next-group (&optional no-article target-group backward)
5391 "Exit current newsgroup and then select next unread newsgroup.
5392 If prefix argument NO-ARTICLE is non-nil, no article is selected
5393 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5394 previous group instead."
5396 ;; Stop pre-fetching.
5397 (gnus-async-halt-prefetch)
5398 (let ((current-group gnus-newsgroup-name)
5399 (current-buffer (current-buffer))
5401 ;; First we semi-exit this group to update Xrefs and all variables.
5402 ;; We can't do a real exit, because the window conf must remain
5403 ;; the same in case the user is prompted for info, and we don't
5404 ;; want the window conf to change before that...
5405 (gnus-summary-exit t)
5406 (while (not entered)
5407 ;; Then we find what group we are supposed to enter.
5408 (set-buffer gnus-group-buffer)
5409 (gnus-group-jump-to-group current-group)
5412 (if (eq gnus-keep-same-level 'best)
5413 (gnus-summary-best-group gnus-newsgroup-name)
5414 (gnus-summary-search-group backward gnus-keep-same-level))))
5415 (if (not target-group)
5416 ;; There are no further groups, so we return to the group
5419 (gnus-message 5 "Returning to the group buffer")
5421 (when (gnus-buffer-live-p current-buffer)
5422 (set-buffer current-buffer)
5423 (gnus-summary-exit))
5424 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5425 ;; We try to enter the target group.
5426 (gnus-group-jump-to-group target-group)
5427 (let ((unreads (gnus-group-group-unread)))
5428 (if (and (or (eq t unreads)
5429 (and unreads (not (zerop unreads))))
5430 (gnus-summary-read-group
5431 target-group nil no-article
5432 (and (buffer-name current-buffer) current-buffer)
5435 (setq current-group target-group
5436 target-group nil)))))))
5438 (defun gnus-summary-prev-group (&optional no-article)
5439 "Exit current newsgroup and then select previous unread newsgroup.
5440 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5442 (gnus-summary-next-group no-article nil t))
5444 ;; Walking around summary lines.
5446 (defun gnus-summary-first-subject (&optional unread)
5447 "Go to the first unread subject.
5448 If UNREAD is non-nil, go to the first unread article.
5449 Returns the article selected or nil if there are no unread articles."
5454 ((null gnus-newsgroup-data)
5455 (gnus-message 3 "No articles in the group")
5457 ;; Pick the first article.
5459 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5460 (gnus-data-number (car gnus-newsgroup-data)))
5461 ;; No unread articles.
5462 ((null gnus-newsgroup-unreads)
5463 (gnus-message 3 "No more unread articles")
5465 ;; Find the first unread article.
5467 (let ((data gnus-newsgroup-data))
5469 (not (gnus-data-unread-p (car data))))
5470 (setq data (cdr data)))
5472 (goto-char (gnus-data-pos (car data)))
5473 (gnus-data-number (car data))))))
5474 (gnus-summary-position-point)))
5476 (defun gnus-summary-next-subject (n &optional unread dont-display)
5477 "Go to next N'th summary line.
5478 If N is negative, go to the previous N'th subject line.
5479 If UNREAD is non-nil, only unread articles are selected.
5480 The difference between N and the actual number of steps taken is
5483 (let ((backward (< n 0))
5487 (gnus-summary-find-prev unread)
5488 (gnus-summary-find-next unread)))
5491 (gnus-message 7 "No more%s articles"
5492 (if unread " unread" "")))
5493 (unless dont-display
5494 (gnus-summary-recenter)
5495 (gnus-summary-position-point))
5498 (defun gnus-summary-next-unread-subject (n)
5499 "Go to next N'th unread summary line."
5501 (gnus-summary-next-subject n t))
5503 (defun gnus-summary-prev-subject (n &optional unread)
5504 "Go to previous N'th summary line.
5505 If optional argument UNREAD is non-nil, only unread article is selected."
5507 (gnus-summary-next-subject (- n) unread))
5509 (defun gnus-summary-prev-unread-subject (n)
5510 "Go to previous N'th unread summary line."
5512 (gnus-summary-next-subject (- n) t))
5514 (defun gnus-summary-goto-subject (article &optional force silent)
5515 "Go the subject line of ARTICLE.
5516 If FORCE, also allow jumping to articles not currently shown."
5517 (interactive "nArticle number: ")
5519 (data (gnus-data-find article)))
5520 ;; We read in the article if we have to.
5523 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5524 (setq data (gnus-data-find article)))
5529 (gnus-message 3 "Can't find article %d" article))
5531 (goto-char (gnus-data-pos data))
5534 ;; Walking around summary lines with displaying articles.
5536 (defun gnus-summary-expand-window (&optional arg)
5537 "Make the summary buffer take up the entire Emacs frame.
5538 Given a prefix, will force an `article' buffer configuration."
5541 (gnus-configure-windows 'article 'force)
5542 (gnus-configure-windows 'summary 'force)))
5544 (defun gnus-summary-display-article (article &optional all-header)
5545 "Display ARTICLE in article buffer."
5546 (gnus-set-global-variables)
5550 (if gnus-summary-display-article-function
5551 (funcall gnus-summary-display-article-function article all-header)
5552 (gnus-article-prepare article all-header))
5553 (gnus-run-hooks 'gnus-select-article-hook)
5554 (when (and gnus-current-article
5555 (not (zerop gnus-current-article)))
5556 (gnus-summary-goto-subject gnus-current-article))
5557 (gnus-summary-recenter)
5558 (when (and gnus-use-trees gnus-show-threads)
5559 (gnus-possibly-generate-tree article)
5560 (gnus-highlight-selected-tree article))
5561 ;; Successfully display article.
5562 (gnus-article-set-window-start
5563 (cdr (assq article gnus-newsgroup-bookmarks))))))
5565 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5566 "Select the current article.
5567 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5568 non-nil, the article will be re-fetched even if it already present in
5569 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5571 ;; Make sure we are in the summary buffer to work around bbdb bug.
5572 (unless (eq major-mode 'gnus-summary-mode)
5573 (set-buffer gnus-summary-buffer))
5574 (let ((article (or article (gnus-summary-article-number)))
5575 (all-headers (not (not all-headers))) ;Must be T or NIL.
5576 gnus-summary-display-article-function
5579 (gnus-summary-article-pseudo-p article)
5580 (error "This is a pseudo-article"))
5583 (set-buffer gnus-summary-buffer)
5584 (if (or (and gnus-single-article-buffer
5585 (or (null gnus-current-article)
5586 (null gnus-article-current)
5587 (null (get-buffer gnus-article-buffer))
5588 (not (eq article (cdr gnus-article-current)))
5589 (not (equal (car gnus-article-current)
5590 gnus-newsgroup-name))))
5591 (and (not gnus-single-article-buffer)
5592 (or (null gnus-current-article)
5593 (not (eq gnus-current-article article))))
5595 ;; The requested article is different from the current article.
5597 (gnus-summary-display-article article all-headers)
5599 (when (or all-headers gnus-show-all-headers)
5600 (gnus-article-show-all-headers))
5603 (gnus-article-set-window-start
5604 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5606 (defun gnus-summary-set-current-mark (&optional current-mark)
5607 "Obsolete function."
5610 (defun gnus-summary-next-article (&optional unread subject backward push)
5611 "Select the next article.
5612 If UNREAD, only unread articles are selected.
5613 If SUBJECT, only articles with SUBJECT are selected.
5614 If BACKWARD, the previous article is selected instead of the next."
5617 ;; Is there such an article?
5618 ((and (gnus-summary-search-forward unread subject backward)
5619 (or (gnus-summary-display-article (gnus-summary-article-number))
5620 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5621 (gnus-summary-position-point))
5622 ;; If not, we try the first unread, if that is wanted.
5624 gnus-auto-select-same
5625 (gnus-summary-first-unread-article))
5626 (gnus-summary-position-point)
5627 (gnus-message 6 "Wrapped"))
5628 ;; Try to get next/previous article not displayed in this group.
5629 ((and gnus-auto-extend-newsgroup
5630 (not unread) (not subject))
5631 (gnus-summary-goto-article
5632 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5634 ;; Go to next/previous group.
5636 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5637 (gnus-summary-jump-to-group gnus-newsgroup-name))
5638 (let ((cmd last-command-char)
5641 (set-buffer gnus-group-buffer)
5644 (if (eq gnus-keep-same-level 'best)
5645 (gnus-summary-best-group gnus-newsgroup-name)
5646 (gnus-summary-search-group backward gnus-keep-same-level))))
5647 ;; For some reason, the group window gets selected. We change
5649 (select-window (get-buffer-window (current-buffer)))
5650 ;; Select next unread newsgroup automagically.
5652 ((or (not gnus-auto-select-next)
5654 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5655 ((or (eq gnus-auto-select-next 'quietly)
5656 (and (eq gnus-auto-select-next 'slightly-quietly)
5658 (and (eq gnus-auto-select-next 'almost-quietly)
5659 (gnus-summary-last-article-p)))
5661 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5663 (gnus-message 7 "No more%s articles (%s)..."
5664 (if unread " unread" "")
5665 (if group (concat "selecting " group)
5667 (gnus-summary-next-group nil group backward)))
5669 (when (gnus-key-press-event-p last-input-event)
5670 (gnus-summary-walk-group-buffer
5671 gnus-newsgroup-name cmd unread backward point))))))))
5673 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5674 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5675 (?\C-p (gnus-group-prev-unread-group 1))))
5676 (cursor-in-echo-area t)
5677 keve key group ended)
5679 (set-buffer gnus-group-buffer)
5682 (if (eq gnus-keep-same-level 'best)
5683 (gnus-summary-best-group gnus-newsgroup-name)
5684 (gnus-summary-search-group backward gnus-keep-same-level))))
5687 5 "No more%s articles%s" (if unread " unread" "")
5689 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5690 (format " (Type %s for %s [%s])"
5691 (single-key-description cmd) group
5692 (car (gnus-gethash group gnus-newsrc-hashtb)))
5693 (format " (Type %s to exit %s)"
5694 (single-key-description cmd)
5695 gnus-newsgroup-name)))
5696 ;; Confirm auto selection.
5697 (setq key (car (setq keve (gnus-read-event-char))))
5700 ((assq key keystrokes)
5701 (let ((obuf (current-buffer)))
5702 (switch-to-buffer gnus-group-buffer)
5704 (gnus-group-jump-to-group group))
5705 (eval (cadr (assq key keystrokes)))
5706 (setq group (gnus-group-group-name))
5707 (switch-to-buffer obuf))
5711 (gnus-ephemeral-group-p gnus-newsgroup-name))
5713 (gnus-summary-next-group nil group backward)))
5715 (push (cdr keve) unread-command-events))))))
5717 (defun gnus-summary-next-unread-article ()
5718 "Select unread article after current one."
5720 (gnus-summary-next-article
5721 (or (not (eq gnus-summary-goto-unread 'never))
5722 (gnus-summary-last-article-p (gnus-summary-article-number)))
5723 (and gnus-auto-select-same
5724 (gnus-summary-article-subject))))
5726 (defun gnus-summary-prev-article (&optional unread subject)
5727 "Select the article after the current one.
5728 If UNREAD is non-nil, only unread articles are selected."
5730 (gnus-summary-next-article unread subject t))
5732 (defun gnus-summary-prev-unread-article ()
5733 "Select unread article before current one."
5735 (gnus-summary-prev-article
5736 (or (not (eq gnus-summary-goto-unread 'never))
5737 (gnus-summary-first-article-p (gnus-summary-article-number)))
5738 (and gnus-auto-select-same
5739 (gnus-summary-article-subject))))
5741 (defun gnus-summary-next-page (&optional lines circular)
5742 "Show next page of the selected article.
5743 If at the end of the current article, select the next article.
5744 LINES says how many lines should be scrolled up.
5746 If CIRCULAR is non-nil, go to the start of the article instead of
5747 selecting the next article when reaching the end of the current
5750 (setq gnus-summary-buffer (current-buffer))
5751 (gnus-set-global-variables)
5752 (let ((article (gnus-summary-article-number))
5753 (article-window (get-buffer-window gnus-article-buffer t))
5755 (gnus-configure-windows 'article)
5756 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5757 (if (and (eq gnus-summary-goto-unread 'never)
5758 (not (gnus-summary-last-article-p article)))
5759 (gnus-summary-next-article)
5760 (gnus-summary-next-unread-article))
5761 (if (or (null gnus-current-article)
5762 (null gnus-article-current)
5763 (/= article (cdr gnus-article-current))
5764 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5765 ;; Selected subject is different from current article's.
5766 (gnus-summary-display-article article)
5767 (when article-window
5768 (gnus-eval-in-buffer-window gnus-article-buffer
5769 (setq endp (gnus-article-next-page lines)))
5772 (gnus-summary-beginning-of-article))
5774 (gnus-message 3 "End of message"))
5776 (if (and (eq gnus-summary-goto-unread 'never)
5777 (not (gnus-summary-last-article-p article)))
5778 (gnus-summary-next-article)
5779 (gnus-summary-next-unread-article))))))))
5780 (gnus-summary-recenter)
5781 (gnus-summary-position-point)))
5783 (defun gnus-summary-prev-page (&optional lines move)
5784 "Show previous page of selected article.
5785 Argument LINES specifies lines to be scrolled down.
5786 If MOVE, move to the previous unread article if point is at
5787 the beginning of the buffer."
5789 (let ((article (gnus-summary-article-number))
5790 (article-window (get-buffer-window gnus-article-buffer t))
5792 (gnus-configure-windows 'article)
5793 (if (or (null gnus-current-article)
5794 (null gnus-article-current)
5795 (/= article (cdr gnus-article-current))
5796 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5797 ;; Selected subject is different from current article's.
5798 (gnus-summary-display-article article)
5799 (gnus-summary-recenter)
5800 (when article-window
5801 (gnus-eval-in-buffer-window gnus-article-buffer
5802 (setq endp (gnus-article-prev-page lines)))
5803 (when (and move endp)
5805 (gnus-message 3 "Beginning of message"))
5807 (if (and (eq gnus-summary-goto-unread 'never)
5808 (not (gnus-summary-first-article-p article)))
5809 (gnus-summary-prev-article)
5810 (gnus-summary-prev-unread-article))))))))
5811 (gnus-summary-position-point))
5813 (defun gnus-summary-prev-page-or-article (&optional lines)
5814 "Show previous page of selected article.
5815 Argument LINES specifies lines to be scrolled down.
5816 If at the beginning of the article, go to the next article."
5818 (gnus-summary-prev-page lines t))
5820 (defun gnus-summary-scroll-up (lines)
5821 "Scroll up (or down) one line current article.
5822 Argument LINES specifies lines to be scrolled up (or down if negative)."
5824 (gnus-configure-windows 'article)
5825 (gnus-summary-show-thread)
5826 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5827 (gnus-eval-in-buffer-window gnus-article-buffer
5829 (when (gnus-article-next-page lines)
5830 (gnus-message 3 "End of message")))
5832 (gnus-article-prev-page (- lines))))))
5833 (gnus-summary-recenter)
5834 (gnus-summary-position-point))
5836 (defun gnus-summary-next-same-subject ()
5837 "Select next article which has the same subject as current one."
5839 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5841 (defun gnus-summary-prev-same-subject ()
5842 "Select previous article which has the same subject as current one."
5844 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5846 (defun gnus-summary-next-unread-same-subject ()
5847 "Select next unread article which has the same subject as current one."
5849 (gnus-summary-next-article t (gnus-summary-article-subject)))
5851 (defun gnus-summary-prev-unread-same-subject ()
5852 "Select previous unread article which has the same subject as current one."
5854 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5856 (defun gnus-summary-first-unread-article ()
5857 "Select the first unread article.
5858 Return nil if there are no unread articles."
5861 (when (gnus-summary-first-subject t)
5862 (gnus-summary-show-thread)
5863 (gnus-summary-first-subject t)
5864 (gnus-summary-display-article (gnus-summary-article-number)))
5865 (gnus-summary-position-point)))
5867 (defun gnus-summary-first-article ()
5868 "Select the first article.
5869 Return nil if there are no articles."
5872 (when (gnus-summary-first-subject)
5873 (gnus-summary-show-thread)
5874 (gnus-summary-first-subject)
5875 (gnus-summary-display-article (gnus-summary-article-number)))
5876 (gnus-summary-position-point)))
5878 (defun gnus-summary-best-unread-article ()
5879 "Select the unread article with the highest score."
5881 (let ((best -1000000)
5882 (data gnus-newsgroup-data)
5885 (and (gnus-data-unread-p (car data))
5887 (gnus-summary-article-score (gnus-data-number (car data))))
5890 article (gnus-data-number (car data))))
5891 (setq data (cdr data)))
5894 (gnus-summary-goto-article article)
5895 (error "No unread articles"))
5896 (gnus-summary-position-point))))
5898 (defun gnus-summary-last-subject ()
5899 "Go to the last displayed subject line in the group."
5900 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5902 (gnus-summary-goto-subject article))))
5904 (defun gnus-summary-goto-article (article &optional all-headers force)
5905 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5906 If ALL-HEADERS is non-nil, no header lines are hidden."
5910 "Article number or Message-ID: "
5911 (mapcar (lambda (number) (list (int-to-string number)))
5912 gnus-newsgroup-limit))
5916 (if (and (stringp article)
5917 (string-match "@" article))
5918 (gnus-summary-refer-article article)
5919 (when (stringp article)
5920 (setq article (string-to-number article)))
5921 (if (gnus-summary-goto-subject article force)
5922 (gnus-summary-display-article article all-headers)
5923 (gnus-message 4 "Couldn't go to article %s" article) nil))
5924 (gnus-summary-position-point)))
5926 (defun gnus-summary-goto-last-article ()
5927 "Go to the previously read article."
5930 (when gnus-last-article
5931 (gnus-summary-goto-article gnus-last-article nil t))
5932 (gnus-summary-position-point)))
5934 (defun gnus-summary-pop-article (number)
5935 "Pop one article off the history and go to the previous.
5936 NUMBER articles will be popped off."
5939 (setq gnus-newsgroup-history
5940 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5942 (gnus-summary-goto-article (car to) nil t)
5943 (error "Article history empty")))
5944 (gnus-summary-position-point))
5946 ;; Summary commands and functions for limiting the summary buffer.
5948 (defun gnus-summary-limit-to-articles (n)
5949 "Limit the summary buffer to the next N articles.
5950 If not given a prefix, use the process marked articles instead."
5953 (let ((articles (gnus-summary-work-articles n)))
5954 (setq gnus-newsgroup-processable nil)
5955 (gnus-summary-limit articles))
5956 (gnus-summary-position-point)))
5958 (defun gnus-summary-pop-limit (&optional total)
5959 "Restore the previous limit.
5960 If given a prefix, remove all limits."
5963 (setq gnus-newsgroup-limits
5964 (list (mapcar (lambda (h) (mail-header-number h))
5965 gnus-newsgroup-headers))))
5966 (unless gnus-newsgroup-limits
5967 (error "No limit to pop"))
5969 (gnus-summary-limit nil 'pop)
5970 (gnus-summary-position-point)))
5972 (defun gnus-summary-limit-to-subject (subject &optional header)
5973 "Limit the summary buffer to articles that have subjects that match a regexp."
5974 (interactive "sLimit to subject (regexp): ")
5976 (setq header "subject"))
5977 (when (not (equal "" subject))
5979 (let ((articles (gnus-summary-find-matching
5980 (or header "subject") subject 'all)))
5982 (error "Found no matches for \"%s\"" subject))
5983 (gnus-summary-limit articles))
5984 (gnus-summary-position-point))))
5986 (defun gnus-summary-limit-to-author (from)
5987 "Limit the summary buffer to articles that have authors that match a regexp."
5988 (interactive "sLimit to author (regexp): ")
5989 (gnus-summary-limit-to-subject from "from"))
5991 (defun gnus-summary-limit-to-age (age &optional younger-p)
5992 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5993 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5994 articles that are younger than AGE days."
5995 (interactive "nTime in days: \nP")
5997 (let ((data gnus-newsgroup-data)
5998 (cutoff (nnmail-days-to-time age))
5999 articles d date is-younger)
6000 (while (setq d (pop data))
6001 (when (and (vectorp (gnus-data-header d))
6002 (setq date (mail-header-date (gnus-data-header d))))
6003 (setq is-younger (nnmail-time-less
6004 (nnmail-time-since (nnmail-date-to-time date))
6006 (when (if younger-p is-younger (not is-younger))
6007 (push (gnus-data-number d) articles))))
6008 (gnus-summary-limit (nreverse articles)))
6009 (gnus-summary-position-point)))
6011 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6013 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6015 (defun gnus-summary-limit-to-unread (&optional all)
6016 "Limit the summary buffer to articles that are not marked as read.
6017 If ALL is non-nil, limit strictly to unread articles."
6020 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6021 (gnus-summary-limit-to-marks
6022 ;; Concat all the marks that say that an article is read and have
6024 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6025 gnus-killed-mark gnus-kill-file-mark
6026 gnus-low-score-mark gnus-expirable-mark
6027 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6028 gnus-duplicate-mark gnus-souped-mark)
6031 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6032 (make-obsolete 'gnus-summary-delete-marked-with
6033 'gnus-summary-limit-exlude-marks)
6035 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6036 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6037 If REVERSE, limit the summary buffer to articles that are marked
6038 with MARKS. MARKS can either be a string of marks or a list of marks.
6039 Returns how many articles were removed."
6040 (interactive "sMarks: ")
6041 (gnus-summary-limit-to-marks marks t))
6043 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6044 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6045 If REVERSE (the prefix), limit the summary buffer to articles that are
6046 not marked with MARKS. MARKS can either be a string of marks or a
6048 Returns how many articles were removed."
6049 (interactive "sMarks: \nP")
6051 (let ((data gnus-newsgroup-data)
6052 (marks (if (listp marks) marks
6053 (append marks nil))) ; Transform to list.
6056 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6057 (memq (gnus-data-mark (car data)) marks))
6058 (push (gnus-data-number (car data)) articles))
6059 (setq data (cdr data)))
6060 (gnus-summary-limit articles))
6061 (gnus-summary-position-point)))
6063 (defun gnus-summary-limit-to-score (&optional score)
6064 "Limit to articles with score at or above SCORE."
6066 (setq score (if score
6067 (prefix-numeric-value score)
6068 (or gnus-summary-default-score 0)))
6069 (let ((data gnus-newsgroup-data)
6072 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6074 (push (gnus-data-number (car data)) articles))
6075 (setq data (cdr data)))
6077 (gnus-summary-limit articles)
6078 (gnus-summary-position-point))))
6080 (defun gnus-summary-limit-include-thread (id)
6081 "Display all the hidden articles that in the current thread."
6082 (interactive (list (mail-header-id (gnus-summary-article-header))))
6083 (let ((articles (gnus-articles-in-thread
6084 (gnus-id-to-thread (gnus-root-id id)))))
6086 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6087 (gnus-summary-position-point))))
6089 (defun gnus-summary-limit-include-dormant ()
6090 "Display all the hidden articles that are marked as dormant.
6091 Note that this command only works on a subset of the articles currently
6092 fetched for this group."
6094 (unless gnus-newsgroup-dormant
6095 (error "There are no dormant articles in this group"))
6097 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6098 (gnus-summary-position-point)))
6100 (defun gnus-summary-limit-exclude-dormant ()
6101 "Hide all dormant articles."
6104 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6105 (gnus-summary-position-point)))
6107 (defun gnus-summary-limit-exclude-childless-dormant ()
6108 "Hide all dormant articles that have no children."
6110 (let ((data (gnus-data-list t))
6111 articles d children)
6112 ;; Find all articles that are either not dormant or have
6114 (while (setq d (pop data))
6115 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6117 (gnus-article-children (gnus-data-number d)))
6120 (when (memq (car children) articles)
6125 (push (gnus-data-number d) articles)))
6128 (gnus-summary-limit articles)
6129 (gnus-summary-position-point))))
6131 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6132 "Mark all unread excluded articles as read.
6133 If ALL, mark even excluded ticked and dormants as read."
6135 (let ((articles (gnus-sorted-complement
6137 (mapcar (lambda (h) (mail-header-number h))
6138 gnus-newsgroup-headers)
6140 (sort gnus-newsgroup-limit '<)))
6142 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6144 (setq gnus-newsgroup-dormant nil
6145 gnus-newsgroup-marked nil
6146 gnus-newsgroup-reads
6148 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6149 gnus-newsgroup-reads))
6150 (while (setq article (pop articles))
6151 (unless (or (memq article gnus-newsgroup-dormant)
6152 (memq article gnus-newsgroup-marked))
6153 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6155 (defun gnus-summary-limit (articles &optional pop)
6157 ;; We pop the previous limit off the stack and use that.
6158 (setq articles (car gnus-newsgroup-limits)
6159 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6160 ;; We use the new limit, so we push the old limit on the stack.
6161 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6163 (setq gnus-newsgroup-limit articles)
6164 (let ((total (length gnus-newsgroup-data))
6165 (data (gnus-data-find-list (gnus-summary-article-number)))
6166 (gnus-summary-mark-below nil) ; Inhibit this.
6168 ;; This will do all the work of generating the new summary buffer
6169 ;; according to the new limit.
6170 (gnus-summary-prepare)
6171 ;; Hide any threads, possibly.
6172 (and gnus-show-threads
6173 gnus-thread-hide-subtree
6174 (gnus-summary-hide-all-threads))
6175 ;; Try to return to the article you were at, or one in the
6178 ;; We try to find some article after the current one.
6180 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6183 (setq data (cdr data))))
6185 ;; If there is no data, that means that we were after the last
6186 ;; article. The same goes when we can't find any articles
6187 ;; after the current one.
6188 (goto-char (point-max))
6189 (gnus-summary-find-prev))
6190 ;; We return how many articles were removed from the summary
6191 ;; buffer as a result of the new limit.
6192 (- total (length gnus-newsgroup-data))))
6194 (defsubst gnus-invisible-cut-children (threads)
6197 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6202 (defsubst gnus-cut-thread (thread)
6203 "Go forwards in the thread until we find an article that we want to display."
6204 (when (or (eq gnus-fetch-old-headers 'some)
6205 (eq gnus-fetch-old-headers 'invisible)
6206 (eq gnus-build-sparse-threads 'some)
6207 (eq gnus-build-sparse-threads 'more))
6208 ;; Deal with old-fetched headers and sparse threads.
6212 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6213 (gnus-summary-article-ancient-p
6214 (mail-header-number (car thread))))
6215 (if (or (<= (length (cdr thread)) 1)
6216 (eq gnus-fetch-old-headers 'invisible))
6217 (setq gnus-newsgroup-limit
6218 (delq (mail-header-number (car thread))
6219 gnus-newsgroup-limit)
6220 thread (cadr thread))
6221 (when (gnus-invisible-cut-children (cdr thread))
6222 (let ((th (cdr thread)))
6224 (if (memq (mail-header-number (caar th))
6225 gnus-newsgroup-limit)
6226 (setq thread (car th)
6228 (setq th (cdr th))))))))))
6231 (defun gnus-cut-threads (threads)
6232 "Cut off all uninteresting articles from the beginning of threads."
6233 (when (or (eq gnus-fetch-old-headers 'some)
6234 (eq gnus-fetch-old-headers 'invisible)
6235 (eq gnus-build-sparse-threads 'some)
6236 (eq gnus-build-sparse-threads 'more))
6239 (setcar th (gnus-cut-thread (car th)))
6240 (setq th (cdr th)))))
6241 ;; Remove nixed out threads.
6244 (defun gnus-summary-initial-limit (&optional show-if-empty)
6245 "Figure out what the initial limit is supposed to be on group entry.
6246 This entails weeding out unwanted dormants, low-scored articles,
6247 fetch-old-headers verbiage, and so on."
6248 ;; Most groups have nothing to remove.
6249 (if (or gnus-inhibit-limiting
6250 (and (null gnus-newsgroup-dormant)
6251 (not (eq gnus-fetch-old-headers 'some))
6252 (not (eq gnus-fetch-old-headers 'invisible))
6253 (null gnus-summary-expunge-below)
6254 (not (eq gnus-build-sparse-threads 'some))
6255 (not (eq gnus-build-sparse-threads 'more))
6256 (null gnus-thread-expunge-below)
6257 (not gnus-use-nocem)))
6259 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6260 (setq gnus-newsgroup-limit nil)
6263 (unless (car (symbol-value node))
6264 ;; These threads have no parents -- they are roots.
6265 (let ((nodes (cdr (symbol-value node)))
6268 (if (and gnus-thread-expunge-below
6269 (< (gnus-thread-total-score (car nodes))
6270 gnus-thread-expunge-below))
6271 (gnus-expunge-thread (pop nodes))
6272 (setq thread (pop nodes))
6273 (gnus-summary-limit-children thread))))))
6274 gnus-newsgroup-dependencies)
6275 ;; If this limitation resulted in an empty group, we might
6276 ;; pop the previous limit and use it instead.
6277 (when (and (not gnus-newsgroup-limit)
6279 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6280 gnus-newsgroup-limit))
6282 (defun gnus-summary-limit-children (thread)
6283 "Return 1 if this subthread is visible and 0 if it is not."
6284 ;; First we get the number of visible children to this thread. This
6285 ;; is done by recursing down the thread using this function, so this
6286 ;; will really go down to a leaf article first, before slowly
6287 ;; working its way up towards the root.
6291 (apply '+ (mapcar 'gnus-summary-limit-children
6294 (number (mail-header-number (car thread)))
6297 (not (memq number gnus-newsgroup-marked))
6299 ;; If this article is dormant and has absolutely no visible
6300 ;; children, then this article isn't visible.
6301 (and (memq number gnus-newsgroup-dormant)
6303 ;; If this is "fetch-old-headered" and there is no
6304 ;; visible children, then we don't want this article.
6305 (and (eq gnus-fetch-old-headers 'some)
6306 (gnus-summary-article-ancient-p number)
6308 ;; If this is "fetch-old-headered" and `invisible', then
6309 ;; we don't want this article.
6310 (and (eq gnus-fetch-old-headers 'invisible)
6311 (gnus-summary-article-ancient-p number))
6312 ;; If this is a sparsely inserted article with no children,
6313 ;; we don't want it.
6314 (and (eq gnus-build-sparse-threads 'some)
6315 (gnus-summary-article-sparse-p number)
6317 ;; If we use expunging, and this article is really
6318 ;; low-scored, then we don't want this article.
6319 (when (and gnus-summary-expunge-below
6321 (or (cdr (assq number gnus-newsgroup-scored))
6322 gnus-summary-default-score))
6323 gnus-summary-expunge-below))
6324 ;; We increase the expunge-tally here, but that has
6325 ;; nothing to do with the limits, really.
6326 (incf gnus-newsgroup-expunged-tally)
6327 ;; We also mark as read here, if that's wanted.
6328 (when (and gnus-summary-mark-below
6329 (< score gnus-summary-mark-below))
6330 (setq gnus-newsgroup-unreads
6331 (delq number gnus-newsgroup-unreads))
6332 (if gnus-newsgroup-auto-expire
6333 (push number gnus-newsgroup-expirable)
6334 (push (cons number gnus-low-score-mark)
6335 gnus-newsgroup-reads)))
6337 ;; Check NoCeM things.
6338 (if (and gnus-use-nocem
6339 (gnus-nocem-unwanted-article-p
6340 (mail-header-id (car thread))))
6342 (setq gnus-newsgroup-unreads
6343 (delq number gnus-newsgroup-unreads))
6345 ;; Nope, invisible article.
6347 ;; Ok, this article is to be visible, so we add it to the limit
6349 (push number gnus-newsgroup-limit)
6352 (defun gnus-expunge-thread (thread)
6353 "Mark all articles in THREAD as read."
6354 (let* ((number (mail-header-number (car thread))))
6355 (incf gnus-newsgroup-expunged-tally)
6356 ;; We also mark as read here, if that's wanted.
6357 (setq gnus-newsgroup-unreads
6358 (delq number gnus-newsgroup-unreads))
6359 (if gnus-newsgroup-auto-expire
6360 (push number gnus-newsgroup-expirable)
6361 (push (cons number gnus-low-score-mark)
6362 gnus-newsgroup-reads)))
6363 ;; Go recursively through all subthreads.
6364 (mapcar 'gnus-expunge-thread (cdr thread)))
6366 ;; Summary article oriented commands
6368 (defun gnus-summary-refer-parent-article (n)
6369 "Refer parent article N times.
6370 If N is negative, go to ancestor -N instead.
6371 The difference between N and the number of articles fetched is returned."
6375 (when (not (natnump n))
6380 (setq header (gnus-summary-article-header))
6381 (if (and (eq (mail-header-number header)
6382 (cdr gnus-article-current))
6383 (equal gnus-newsgroup-name
6384 (car gnus-article-current)))
6385 ;; If we try to find the parent of the currently
6386 ;; displayed article, then we take a look at the actual
6387 ;; References header, since this is slightly more
6388 ;; reliable than the References field we got from the
6391 (set-buffer gnus-original-article-buffer)
6392 (nnheader-narrow-to-headers)
6393 (unless (setq ref (message-fetch-field "references"))
6394 (setq ref (message-fetch-field "in-reply-to")))
6397 ;; It's not the current article, so we take a bet on
6398 ;; the value we got from the server.
6399 (mail-header-references header)))
6401 (not (equal ref "")))
6402 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6403 (gnus-message 1 "Couldn't find parent"))
6404 (gnus-message 1 "No references in article %d"
6405 (gnus-summary-article-number))
6408 (gnus-summary-position-point)
6411 (defun gnus-summary-refer-references ()
6412 "Fetch all articles mentioned in the References header.
6413 Return the number of articles fetched."
6415 (let ((ref (mail-header-references (gnus-summary-article-header)))
6416 (current (gnus-summary-article-number))
6420 (error "No References in the current article")
6421 ;; For each Message-ID in the References header...
6422 (while (string-match "<[^>]*>" ref)
6424 ;; ... fetch that article.
6425 (gnus-summary-refer-article
6426 (prog1 (match-string 0 ref)
6427 (setq ref (substring ref (match-end 0))))))
6428 (gnus-summary-goto-subject current)
6429 (gnus-summary-position-point)
6432 (defun gnus-summary-refer-thread (&optional limit)
6433 "Fetch all articles in the current thread.
6434 If LIMIT (the numerical prefix), fetch that many old headers instead
6435 of what's specified by the `gnus-refer-thread-limit' variable."
6437 (let ((id (mail-header-id (gnus-summary-article-header)))
6438 (limit (if limit (prefix-numeric-value limit)
6439 gnus-refer-thread-limit))
6441 ;; We want to fetch LIMIT *old* headers, but we also have to
6442 ;; re-fetch all the headers in the current buffer, because many of
6443 ;; them may be undisplayed. So we adjust LIMIT.
6444 (when (numberp limit)
6445 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6446 (unless (eq gnus-fetch-old-headers 'invisible)
6447 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6448 ;; Retrieve the headers and read them in.
6449 (if (eq (gnus-retrieve-headers
6450 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6452 (gnus-build-all-threads)
6453 (error "Can't fetch thread from backends that don't support NOV"))
6454 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6455 (gnus-summary-limit-include-thread id)))
6457 (defun gnus-summary-refer-article (message-id &optional arg)
6458 "Fetch an article specified by MESSAGE-ID.
6459 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6460 or `gnus-select-method', no matter what backend the article comes from."
6461 (interactive "sMessage-ID: \nP")
6462 (when (and (stringp message-id)
6463 (not (zerop (length message-id))))
6464 ;; Construct the correct Message-ID if necessary.
6465 ;; Suggested by tale@pawl.rpi.edu.
6466 (unless (string-match "^<" message-id)
6467 (setq message-id (concat "<" message-id)))
6468 (unless (string-match ">$" message-id)
6469 (setq message-id (concat message-id ">")))
6470 (let* ((header (gnus-id-to-header message-id))
6472 (gnus-summary-article-sparse-p
6473 (mail-header-number header))
6474 (memq (mail-header-number header)
6475 gnus-newsgroup-limit)))
6478 ;; If the article is present in the buffer we just go to it.
6480 (or (not (gnus-summary-article-sparse-p
6481 (mail-header-number header)))
6484 (gnus-summary-goto-article
6485 (mail-header-number header) nil t)
6487 (gnus-summary-update-article (mail-header-number header)))))
6489 ;; We fetch the article
6490 (let ((gnus-override-method
6491 (cond ((gnus-news-group-p gnus-newsgroup-name)
6492 gnus-refer-article-method)
6494 (or gnus-refer-article-method gnus-select-method))
6497 ;; Start the special refer-article method, if necessary.
6498 (when (and gnus-refer-article-method
6499 (gnus-news-group-p gnus-newsgroup-name))
6500 (gnus-check-server gnus-refer-article-method))
6501 ;; Fetch the header, and display the article.
6502 (if (setq number (gnus-summary-insert-subject message-id))
6503 (gnus-summary-select-article nil nil nil number)
6504 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6506 (defun gnus-summary-edit-parameters ()
6507 "Edit the group parameters of the current group."
6509 (gnus-group-edit-group gnus-newsgroup-name 'params))
6511 (defun gnus-summary-enter-digest-group (&optional force)
6512 "Enter an nndoc group based on the current article.
6513 If FORCE, force a digest interpretation. If not, try
6514 to guess what the document format is."
6516 (let ((conf gnus-current-window-configuration))
6518 (gnus-summary-select-article))
6519 (setq gnus-current-window-configuration conf)
6520 (let* ((name (format "%s-%d"
6521 (gnus-group-prefixed-name
6522 gnus-newsgroup-name (list 'nndoc ""))
6524 (set-buffer gnus-summary-buffer)
6525 gnus-current-article)))
6526 (ogroup gnus-newsgroup-name)
6527 (params (append (gnus-info-params (gnus-get-info ogroup))
6528 (list (cons 'to-group ogroup))
6529 (list (cons 'save-article-group ogroup))))
6530 (case-fold-search t)
6531 (buf (current-buffer))
6534 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6535 (insert-buffer-substring gnus-original-article-buffer)
6536 ;; Remove lines that may lead nndoc to misinterpret the
6539 (goto-char (point-min))
6540 (or (search-forward "\n\n" nil t) (point)))
6541 (goto-char (point-min))
6542 (delete-matching-lines "^\\(Path\\):\\|^From ")
6545 (if (gnus-group-read-ephemeral-group
6546 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6548 ,(if force 'digest 'guess))) t)
6549 ;; Make all postings to this group go to the parent group.
6550 (nconc (gnus-info-params (gnus-get-info name))
6552 ;; Couldn't select this doc group.
6553 (switch-to-buffer buf)
6554 (gnus-set-global-variables)
6555 (gnus-configure-windows 'summary)
6556 (gnus-message 3 "Article couldn't be entered?"))
6557 (kill-buffer dig)))))
6559 (defun gnus-summary-read-document (n)
6560 "Open a new group based on the current article(s).
6561 This will allow you to read digests and other similar
6562 documents as newsgroups.
6563 Obeys the standard process/prefix convention."
6565 (let* ((articles (gnus-summary-work-articles n))
6566 (ogroup gnus-newsgroup-name)
6567 (params (append (gnus-info-params (gnus-get-info ogroup))
6568 (list (cons 'to-group ogroup))))
6569 article group egroup groups vgroup)
6570 (while (setq article (pop articles))
6571 (setq group (format "%s-%d" gnus-newsgroup-name article))
6572 (gnus-summary-remove-process-mark article)
6573 (when (gnus-summary-display-article article)
6575 (nnheader-temp-write nil
6576 (insert-buffer-substring gnus-original-article-buffer)
6577 ;; Remove some headers that may lead nndoc to make
6579 (message-narrow-to-head)
6580 (goto-char (point-min))
6581 (delete-matching-lines "^\\(Path\\):\\|^From ")
6584 (gnus-group-read-ephemeral-group
6585 group `(nndoc ,group (nndoc-address ,(current-buffer))
6586 (nndoc-article-type guess))
6589 ;; Make all postings to this group go to the parent group.
6590 (nconc (gnus-info-params (gnus-get-info egroup))
6592 (push egroup groups))
6593 ;; Couldn't select this doc group.
6594 (gnus-error 3 "Article couldn't be entered"))))))
6595 ;; Now we have selected all the documents.
6598 (error "None of the articles could be interpreted as documents"))
6599 ((gnus-group-read-ephemeral-group
6600 (setq vgroup (format
6601 "nnvirtual:%s-%s" gnus-newsgroup-name
6602 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6603 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6605 (cons (current-buffer) 'summary)))
6607 (error "Couldn't select virtual nndoc group")))))
6609 (defun gnus-summary-isearch-article (&optional regexp-p)
6610 "Do incremental search forward on the current article.
6611 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6613 (gnus-summary-select-article)
6614 (gnus-configure-windows 'article)
6615 (gnus-eval-in-buffer-window gnus-article-buffer
6618 (isearch-forward regexp-p))))
6620 (defun gnus-summary-search-article-forward (regexp &optional backward)
6621 "Search for an article containing REGEXP forward.
6622 If BACKWARD, search backward instead."
6625 (format "Search article %s (regexp%s): "
6626 (if current-prefix-arg "backward" "forward")
6627 (if gnus-last-search-regexp
6628 (concat ", default " gnus-last-search-regexp)
6630 current-prefix-arg))
6631 (if (string-equal regexp "")
6632 (setq regexp (or gnus-last-search-regexp ""))
6633 (setq gnus-last-search-regexp regexp))
6634 (if (gnus-summary-search-article regexp backward)
6635 (gnus-summary-show-thread)
6636 (error "Search failed: \"%s\"" regexp)))
6638 (defun gnus-summary-search-article-backward (regexp)
6639 "Search for an article containing REGEXP backward."
6642 (format "Search article backward (regexp%s): "
6643 (if gnus-last-search-regexp
6644 (concat ", default " gnus-last-search-regexp)
6646 (gnus-summary-search-article-forward regexp 'backward))
6648 (defun gnus-summary-search-article (regexp &optional backward)
6649 "Search for an article containing REGEXP.
6650 Optional argument BACKWARD means do search for backward.
6651 `gnus-select-article-hook' is not called during the search."
6652 ;; We have to require this here to make sure that the following
6653 ;; dynamic binding isn't shadowed by autoloading.
6654 (require 'gnus-async)
6655 (let ((gnus-select-article-hook nil) ;Disable hook.
6656 (gnus-article-display-hook nil)
6657 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6658 (gnus-use-article-prefetch nil)
6659 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6660 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6661 (sum (current-buffer))
6664 (gnus-save-hidden-threads
6665 (gnus-summary-select-article)
6666 (set-buffer gnus-article-buffer)
6670 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6672 (re-search-backward regexp nil t)
6673 (re-search-forward regexp nil t))
6674 ;; We found the regexp.
6679 (get-buffer-window (current-buffer))
6683 (setq point (point)))
6684 ;; We didn't find it, so we go to the next article.
6687 (while (eq found 'not)
6688 (if (not (if backward (gnus-summary-find-prev)
6689 (gnus-summary-find-next)))
6690 ;; No more articles.
6692 ;; Select the next article and adjust point.
6693 (unless (gnus-summary-article-sparse-p
6694 (gnus-summary-article-number))
6696 (gnus-summary-select-article)
6697 (set-buffer gnus-article-buffer)
6699 (goto-char (if backward (point-max) (point-min))))))))
6700 (gnus-message 7 ""))
6701 ;; Return whether we found the regexp.
6702 (when (eq found 'found)
6704 (gnus-summary-show-thread)
6705 (gnus-summary-goto-subject gnus-current-article)
6706 (gnus-summary-position-point)
6709 (defun gnus-summary-find-matching (header regexp &optional backward unread
6711 "Return a list of all articles that match REGEXP on HEADER.
6712 The search stars on the current article and goes forwards unless
6713 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6714 If UNREAD is non-nil, only unread articles will
6715 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6716 in the comparisons."
6717 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6718 (gnus-data-find-list
6719 (gnus-summary-article-number) (gnus-data-list backward))))
6720 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6721 (case-fold-search (not not-case-fold))
6723 (unless (fboundp (intern (concat "mail-header-" header)))
6724 (error "%s is not a valid header" header))
6727 (and (or (not unread) ; We want all articles...
6728 (gnus-data-unread-p d)) ; Or just unreads.
6729 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6730 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6731 (push (gnus-data-number d) articles)) ; Success!
6732 (setq data (cdr data)))
6733 (nreverse articles)))
6735 (defun gnus-summary-execute-command (header regexp command &optional backward)
6736 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6737 If HEADER is an empty string (or nil), the match is done on the entire
6738 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6740 (list (let ((completion-ignore-case t))
6743 (mapcar (lambda (string) (list string))
6744 '("Number" "Subject" "From" "Lines" "Date"
6745 "Message-ID" "Xref" "References" "Body"))
6746 nil 'require-match))
6747 (read-string "Regexp: ")
6748 (read-key-sequence "Command: ")
6749 current-prefix-arg))
6750 (when (equal header "Body")
6752 ;; Hidden thread subtrees must be searched as well.
6753 (gnus-summary-show-all-threads)
6754 ;; We don't want to change current point nor window configuration.
6756 (save-window-excursion
6757 (gnus-message 6 "Executing %s..." (key-description command))
6758 ;; We'd like to execute COMMAND interactively so as to give arguments.
6759 (gnus-execute header regexp
6760 `(call-interactively ',(key-binding command))
6762 (gnus-message 6 "Executing %s...done" (key-description command)))))
6764 (defun gnus-summary-beginning-of-article ()
6765 "Scroll the article back to the beginning."
6767 (gnus-summary-select-article)
6768 (gnus-configure-windows 'article)
6769 (gnus-eval-in-buffer-window gnus-article-buffer
6771 (goto-char (point-min))
6772 (when gnus-page-broken
6773 (gnus-narrow-to-page))))
6775 (defun gnus-summary-end-of-article ()
6776 "Scroll to the end of the article."
6778 (gnus-summary-select-article)
6779 (gnus-configure-windows 'article)
6780 (gnus-eval-in-buffer-window gnus-article-buffer
6782 (goto-char (point-max))
6784 (when gnus-page-broken
6785 (gnus-narrow-to-page))))
6787 (defun gnus-summary-print-article (&optional filename n)
6788 "Generate and print a PostScript image of the N next (mail) articles.
6790 If N is negative, print the N previous articles. If N is nil and articles
6791 have been marked with the process mark, print these instead.
6793 If the optional second argument FILENAME is nil, send the image to the
6794 printer. If FILENAME is a string, save the PostScript image in a file with
6795 that name. If FILENAME is a number, prompt the user for the name of the file
6797 (interactive (list (ps-print-preprint current-prefix-arg)
6798 current-prefix-arg))
6799 (dolist (article (gnus-summary-work-articles n))
6800 (gnus-summary-select-article nil nil 'pseudo article)
6801 (gnus-eval-in-buffer-window gnus-article-buffer
6802 (let ((buffer (generate-new-buffer " *print*")))
6805 (copy-to-buffer buffer (point-min) (point-max))
6807 (gnus-article-delete-invisible-text)
6808 (let ((ps-left-header
6811 (mail-header-subject gnus-current-headers) ")")
6813 (mail-header-from gnus-current-headers) ")")))
6816 "/pagenumberstring load"
6818 (mail-header-date gnus-current-headers) ")"))))
6819 (gnus-run-hooks 'gnus-ps-print-hook)
6820 (ps-print-buffer-with-faces filename)))
6821 (kill-buffer buffer))))))
6823 (defun gnus-summary-show-article (&optional arg)
6824 "Force re-fetching of the current article.
6825 If ARG (the prefix) is non-nil, show the raw article without any
6826 article massaging functions being run."
6829 ;; Select the article the normal way.
6830 (gnus-summary-select-article nil 'force)
6831 ;; Bind the article treatment functions to nil.
6832 (let ((gnus-have-all-headers t)
6833 gnus-article-display-hook
6834 gnus-article-prepare-hook
6838 (gnus-summary-select-article nil 'force)))
6839 (gnus-summary-goto-subject gnus-current-article)
6840 (gnus-summary-position-point))
6842 (defun gnus-summary-verbose-headers (&optional arg)
6843 "Toggle permanent full header display.
6844 If ARG is a positive number, turn header display on.
6845 If ARG is a negative number, turn header display off."
6847 (setq gnus-show-all-headers
6848 (cond ((or (not (numberp arg))
6850 (not gnus-show-all-headers))
6853 (gnus-summary-show-article))
6855 (defun gnus-summary-toggle-header (&optional arg)
6856 "Show the headers if they are hidden, or hide them if they are shown.
6857 If ARG is a positive number, show the entire header.
6858 If ARG is a negative number, hide the unwanted header lines."
6861 (set-buffer gnus-article-buffer)
6862 (let* ((buffer-read-only nil)
6863 (inhibit-point-motion-hooks t)
6864 (hidden (text-property-any
6865 (goto-char (point-min)) (search-forward "\n\n")
6868 (goto-char (point-min))
6869 (when (search-forward "\n\n" nil t)
6870 (delete-region (point-min) (1- (point))))
6871 (goto-char (point-min))
6873 (set-buffer gnus-original-article-buffer)
6874 (goto-char (point-min))
6875 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6876 (insert-buffer-substring gnus-original-article-buffer 1 e)
6877 (let ((article-inhibit-hiding t))
6878 (gnus-run-hooks 'gnus-article-display-hook))
6879 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6880 (gnus-article-hide-headers)))))
6882 (defun gnus-summary-show-all-headers ()
6883 "Make all header lines visible."
6885 (gnus-article-show-all-headers))
6887 (defun gnus-summary-toggle-mime (&optional arg)
6888 "Toggle MIME processing.
6889 If ARG is a positive number, turn MIME processing on."
6891 (setq gnus-show-mime
6892 (if (null arg) (not gnus-show-mime)
6893 (> (prefix-numeric-value arg) 0)))
6894 (gnus-summary-select-article t 'force))
6896 (defun gnus-summary-caesar-message (&optional arg)
6897 "Caesar rotate the current article by 13.
6898 The numerical prefix specifies how many places to rotate each letter
6901 (gnus-summary-select-article)
6902 (let ((mail-header-separator ""))
6903 (gnus-eval-in-buffer-window gnus-article-buffer
6906 (let ((start (window-start))
6908 (message-caesar-buffer-body arg)
6909 (set-window-start (get-buffer-window (current-buffer)) start))))))
6911 (defun gnus-summary-stop-page-breaking ()
6912 "Stop page breaking in the current article."
6914 (gnus-summary-select-article)
6915 (gnus-eval-in-buffer-window gnus-article-buffer
6917 (when (gnus-visual-p 'page-marker)
6918 (let ((buffer-read-only nil))
6919 (gnus-remove-text-with-property 'gnus-prev)
6920 (gnus-remove-text-with-property 'gnus-next))
6921 (setq gnus-page-broken nil))))
6923 (defun gnus-summary-move-article (&optional n to-newsgroup
6924 select-method action)
6925 "Move the current article to a different newsgroup.
6926 If N is a positive number, move the N next articles.
6927 If N is a negative number, move the N previous articles.
6928 If N is nil and any articles have been marked with the process mark,
6929 move those articles instead.
6930 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6931 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6932 re-spool using this method.
6934 For this function to work, both the current newsgroup and the
6935 newsgroup that you want to move to have to support the `request-move'
6936 and `request-accept' functions."
6939 (setq action 'move))
6940 ;; Disable marking as read.
6941 (let (gnus-mark-article-hook)
6942 (save-window-excursion
6943 (gnus-summary-select-article)))
6944 ;; Check whether the source group supports the required functions.
6945 (cond ((and (eq action 'move)
6946 (not (gnus-check-backend-function
6947 'request-move-article gnus-newsgroup-name)))
6948 (error "The current group does not support article moving"))
6949 ((and (eq action 'crosspost)
6950 (not (gnus-check-backend-function
6951 'request-replace-article gnus-newsgroup-name)))
6952 (error "The current group does not support article editing")))
6953 (let ((articles (gnus-summary-work-articles n))
6954 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6955 (names '((move "Move" "Moving")
6956 (copy "Copy" "Copying")
6957 (crosspost "Crosspost" "Crossposting")))
6958 (copy-buf (save-excursion
6959 (nnheader-set-temp-buffer " *copy article*")))
6960 art-group to-method new-xref article to-groups)
6961 (unless (assq action names)
6962 (error "Unknown action %s" action))
6963 ;; Read the newsgroup name.
6964 (when (and (not to-newsgroup)
6965 (not select-method))
6967 (gnus-read-move-group-name
6968 (cadr (assq action names))
6969 (symbol-value (intern (format "gnus-current-%s-group" action)))
6971 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6972 (setq to-method (or select-method
6973 (gnus-group-name-to-method to-newsgroup)))
6974 ;; Check the method we are to move this article to...
6975 (unless (gnus-check-backend-function
6976 'request-accept-article (car to-method))
6977 (error "%s does not support article copying" (car to-method)))
6978 (unless (gnus-check-server to-method)
6979 (error "Can't open server %s" (car to-method)))
6980 (gnus-message 6 "%s to %s: %s..."
6981 (caddr (assq action names))
6982 (or (car select-method) to-newsgroup) articles)
6984 (setq article (pop articles))
6988 ;; Move the article.
6990 ;; Remove this article from future suppression.
6991 (gnus-dup-unsuppress-article article)
6992 (gnus-request-move-article
6993 article ; Article to move
6994 gnus-newsgroup-name ; From newsgroup
6995 (nth 1 (gnus-find-method-for-group
6996 gnus-newsgroup-name)) ; Server
6997 (list 'gnus-request-accept-article
6998 to-newsgroup (list 'quote select-method)
6999 (not articles)) ; Accept form
7000 (not articles))) ; Only save nov last time
7001 ;; Copy the article.
7004 (set-buffer copy-buf)
7005 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7006 (gnus-request-accept-article
7007 to-newsgroup select-method (not articles)))))
7008 ;; Crosspost the article.
7009 ((eq action 'crosspost)
7010 (let ((xref (message-tokenize-header
7011 (mail-header-xref (gnus-summary-article-header article))
7013 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7016 (setq xref (list (system-name))))
7019 (mapconcat 'identity
7020 (delete "Xref:" (delete new-xref xref))
7024 (set-buffer copy-buf)
7025 ;; First put the article in the destination group.
7026 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7027 (when (consp (setq art-group
7028 (gnus-request-accept-article
7029 to-newsgroup select-method (not articles))))
7030 (setq new-xref (concat new-xref " " (car art-group)
7031 ":" (cdr art-group)))
7032 ;; Now we have the new Xrefs header, so we insert
7033 ;; it and replace the new article.
7034 (nnheader-replace-header "Xref" new-xref)
7035 (gnus-request-replace-article
7036 (cdr art-group) to-newsgroup (current-buffer))
7040 (gnus-message 1 "Couldn't %s article %s"
7041 (cadr (assq action names)) article))
7042 ((and (eq art-group 'junk)
7044 (gnus-summary-mark-article article gnus-canceled-mark)
7045 (gnus-message 4 "Deleted article %s" article))
7049 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7051 (gnus-group-prefixed-name
7054 (gnus-find-method-for-group to-newsgroup)))
7055 gnus-newsrc-hashtb)))
7056 (info (nth 2 entry))
7057 (to-group (gnus-info-group info)))
7058 ;; Update the group that has been moved to.
7060 (memq action '(move copy)))
7061 (unless (member to-group to-groups)
7062 (push to-group to-groups))
7064 (unless (memq article gnus-newsgroup-unreads)
7066 info (gnus-add-to-range (gnus-info-read info)
7067 (list (cdr art-group)))))
7069 ;; Copy any marks over to the new group.
7070 (let ((marks gnus-article-mark-lists)
7071 (to-article (cdr art-group)))
7073 ;; See whether the article is to be put in the cache.
7074 (when gnus-use-cache
7075 (gnus-cache-possibly-enter-article
7077 (let ((header (copy-sequence
7078 (gnus-summary-article-header article))))
7079 (mail-header-set-number header to-article)
7081 (memq article gnus-newsgroup-marked)
7082 (memq article gnus-newsgroup-dormant)
7083 (memq article gnus-newsgroup-unreads)))
7085 (when (and (equal to-group gnus-newsgroup-name)
7086 (not (memq article gnus-newsgroup-unreads)))
7087 ;; Mark this article as read in this group.
7088 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7089 (setcdr (gnus-active to-group) to-article)
7090 (setcdr gnus-newsgroup-active to-article))
7093 (when (memq article (symbol-value
7094 (intern (format "gnus-newsgroup-%s"
7096 ;; If the other group is the same as this group,
7097 ;; then we have to add the mark to the list.
7098 (when (equal to-group gnus-newsgroup-name)
7099 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7102 (intern (format "gnus-newsgroup-%s"
7104 ;; Copy the marks to other group.
7105 (gnus-add-marked-articles
7106 to-group (cdar marks) (list to-article) info))
7107 (setq marks (cdr marks)))
7110 (concat "(gnus-group-set-info '"
7111 (gnus-prin1-to-string (gnus-get-info to-group))
7114 ;; Update the Xref header in this article to point to
7115 ;; the new crossposted article we have just created.
7116 (when (eq action 'crosspost)
7118 (set-buffer copy-buf)
7119 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7120 (nnheader-replace-header "Xref" new-xref)
7121 (gnus-request-replace-article
7122 article gnus-newsgroup-name (current-buffer)))))
7124 ;;;!!!Why is this necessary?
7125 (set-buffer gnus-summary-buffer)
7127 (gnus-summary-goto-subject article)
7128 (when (eq action 'move)
7129 (gnus-summary-mark-article article gnus-canceled-mark))))
7130 (gnus-summary-remove-process-mark article))
7131 ;; Re-activate all groups that have been moved to.
7134 (set-buffer gnus-group-buffer)
7135 (when (gnus-group-goto-group (car to-groups) t)
7136 (gnus-group-get-new-news-this-group 1 t))
7139 (gnus-kill-buffer copy-buf)
7140 (gnus-summary-position-point)
7141 (gnus-set-mode-line 'summary)))
7143 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7144 "Move the current article to a different newsgroup.
7145 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7146 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7147 re-spool using this method."
7149 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7151 (defun gnus-summary-crosspost-article (&optional n)
7152 "Crosspost the current article to some other group."
7154 (gnus-summary-move-article n nil nil 'crosspost))
7156 (defcustom gnus-summary-respool-default-method nil
7157 "Default method for respooling an article.
7158 If nil, use to the current newsgroup method."
7159 :type `(choice (gnus-select-method :value (nnml ""))
7161 :group 'gnus-summary-mail)
7163 (defun gnus-summary-respool-article (&optional n method)
7164 "Respool the current article.
7165 The article will be squeezed through the mail spooling process again,
7166 which means that it will be put in some mail newsgroup or other
7167 depending on `nnmail-split-methods'.
7168 If N is a positive number, respool the N next articles.
7169 If N is a negative number, respool the N previous articles.
7170 If N is nil and any articles have been marked with the process mark,
7171 respool those articles instead.
7173 Respooling can be done both from mail groups and \"real\" newsgroups.
7174 In the former case, the articles in question will be moved from the
7175 current group into whatever groups they are destined to. In the
7176 latter case, they will be copied into the relevant groups."
7178 (list current-prefix-arg
7179 (let* ((methods (gnus-methods-using 'respool))
7181 (symbol-name (or gnus-summary-respool-default-method
7182 (car (gnus-find-method-for-group
7183 gnus-newsgroup-name)))))
7185 (gnus-completing-read
7186 methname "What backend do you want to use when respooling?"
7187 methods nil t nil 'gnus-mail-method-history))
7190 ((zerop (length (setq ms (gnus-servers-using-backend
7192 (list (intern method) ""))
7196 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7197 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7200 (error "No method given for respooling"))
7201 (if (assoc (symbol-name
7202 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7203 (gnus-methods-using 'respool))
7204 (gnus-summary-move-article n nil method)
7205 (gnus-summary-copy-article n nil method)))
7207 (defun gnus-summary-import-article (file)
7208 "Import a random file into a mail newsgroup."
7209 (interactive "fImport file: ")
7210 (let ((group gnus-newsgroup-name)
7211 (now (current-time))
7213 (unless (gnus-check-backend-function 'request-accept-article group)
7214 (error "%s does not support article importing" group))
7215 (or (file-readable-p file)
7216 (not (file-regular-p file))
7217 (error "Can't read %s" file))
7219 (set-buffer (get-buffer-create " *import file*"))
7220 (buffer-disable-undo (current-buffer))
7222 (insert-file-contents file)
7223 (goto-char (point-min))
7224 (unless (nnheader-article-p)
7225 ;; This doesn't look like an article, so we fudge some headers.
7226 (setq atts (file-attributes file)
7227 lines (count-lines (point-min) (point-max)))
7228 (insert "From: " (read-string "From: ") "\n"
7229 "Subject: " (read-string "Subject: ") "\n"
7230 "Date: " (timezone-make-date-arpa-standard
7231 (current-time-string (nth 5 atts))
7232 (current-time-zone now)
7233 (current-time-zone now))
7235 "Message-ID: " (message-make-message-id) "\n"
7236 "Lines: " (int-to-string lines) "\n"
7237 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7238 (gnus-request-accept-article group nil t)
7239 (kill-buffer (current-buffer)))))
7241 (defun gnus-summary-article-posted-p ()
7242 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7243 This will be the case if the article has both been mailed and posted."
7245 (let ((id (mail-header-references (gnus-summary-article-header)))
7246 (gnus-override-method
7247 (or gnus-refer-article-method gnus-select-method)))
7248 (if (gnus-request-head id "")
7249 (gnus-message 2 "The current message was found on %s"
7250 gnus-override-method)
7251 (gnus-message 2 "The current message couldn't be found on %s"
7252 gnus-override-method)
7255 (defun gnus-summary-expire-articles (&optional now)
7256 "Expire all articles that are marked as expirable in the current group."
7258 (when (gnus-check-backend-function
7259 'request-expire-articles gnus-newsgroup-name)
7260 ;; This backend supports expiry.
7261 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7262 (expirable (if total
7264 ;; We need to update the info for
7265 ;; this group for `gnus-list-of-read-articles'
7266 ;; to give us the right answer.
7267 (gnus-run-hooks 'gnus-exit-group-hook)
7268 (gnus-summary-update-info)
7269 (gnus-list-of-read-articles gnus-newsgroup-name))
7270 (setq gnus-newsgroup-expirable
7271 (sort gnus-newsgroup-expirable '<))))
7272 (expiry-wait (if now 'immediate
7273 (gnus-group-find-parameter
7274 gnus-newsgroup-name 'expiry-wait)))
7277 ;; There are expirable articles in this group, so we run them
7278 ;; through the expiry process.
7279 (gnus-message 6 "Expiring articles...")
7280 ;; The list of articles that weren't expired is returned.
7283 (let ((nnmail-expiry-wait-function nil)
7284 (nnmail-expiry-wait expiry-wait))
7285 (setq es (gnus-request-expire-articles
7286 expirable gnus-newsgroup-name)))
7287 (setq es (gnus-request-expire-articles
7288 expirable gnus-newsgroup-name))))
7290 (setq gnus-newsgroup-expirable es))
7291 ;; We go through the old list of expirable, and mark all
7292 ;; really expired articles as nonexistent.
7293 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7294 (let ((gnus-use-cache nil))
7296 (unless (memq (car expirable) es)
7297 (when (gnus-data-find (car expirable))
7298 (gnus-summary-mark-article
7299 (car expirable) gnus-canceled-mark)))
7300 (setq expirable (cdr expirable)))))
7301 (gnus-message 6 "Expiring articles...done")))))
7303 (defun gnus-summary-expire-articles-now ()
7304 "Expunge all expirable articles in the current group.
7305 This means that *all* articles that are marked as expirable will be
7306 deleted forever, right now."
7308 (unless gnus-expert-user
7310 "Are you really, really, really sure you want to delete all these messages? ")
7312 (gnus-summary-expire-articles t))
7314 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7315 (defun gnus-summary-delete-article (&optional n)
7316 "Delete the N next (mail) articles.
7317 This command actually deletes articles. This is not a marking
7318 command. The article will disappear forever from your life, never to
7320 If N is negative, delete backwards.
7321 If N is nil and articles have been marked with the process mark,
7322 delete these instead."
7324 (unless (gnus-check-backend-function 'request-expire-articles
7325 gnus-newsgroup-name)
7326 (error "The current newsgroup does not support article deletion"))
7327 ;; Compute the list of articles to delete.
7328 (let ((articles (gnus-summary-work-articles n))
7330 (if (and gnus-novice-user
7331 (not (gnus-yes-or-no-p
7332 (format "Do you really want to delete %s forever? "
7333 (if (> (length articles) 1)
7334 (format "these %s articles" (length articles))
7337 ;; Delete the articles.
7338 (setq not-deleted (gnus-request-expire-articles
7339 articles gnus-newsgroup-name 'force))
7341 (gnus-summary-remove-process-mark (car articles))
7342 ;; The backend might not have been able to delete the article
7344 (unless (memq (car articles) not-deleted)
7345 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7346 (setq articles (cdr articles)))
7348 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7349 (gnus-summary-position-point)
7350 (gnus-set-mode-line 'summary)
7353 (defun gnus-summary-edit-article (&optional force)
7354 "Edit the current article.
7355 This will have permanent effect only in mail groups.
7356 If FORCE is non-nil, allow editing of articles even in read-only
7360 (set-buffer gnus-summary-buffer)
7361 (gnus-set-global-variables)
7362 (when (and (not force)
7363 (gnus-group-read-only-p))
7364 (error "The current newsgroup does not support article editing"))
7365 ;; Select article if needed.
7366 (unless (eq (gnus-summary-article-number)
7367 gnus-current-article)
7368 (gnus-summary-select-article t))
7369 (gnus-article-date-original)
7370 (gnus-article-edit-article
7371 `(lambda (no-highlight)
7372 (gnus-summary-edit-article-done
7373 ,(or (mail-header-references gnus-current-headers) "")
7374 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7376 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7378 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7380 "Make edits to the current article permanent."
7382 ;; Replace the article.
7383 (if (and (not read-only)
7384 (not (gnus-request-replace-article
7385 (cdr gnus-article-current) (car gnus-article-current)
7387 (error "Couldn't replace article")
7388 ;; Update the summary buffer.
7390 (equal (message-tokenize-header references " ")
7391 (message-tokenize-header
7392 (or (message-fetch-field "references") "") " ")))
7393 ;; We only have to update this line.
7396 (message-narrow-to-head)
7397 (let ((head (buffer-string))
7399 (nnheader-temp-write nil
7400 (insert (format "211 %d Article retrieved.\n"
7401 (cdr gnus-article-current)))
7404 (let ((nntp-server-buffer (current-buffer)))
7405 (setq header (car (gnus-get-newsgroup-headers
7407 (set-buffer gnus-summary-buffer)
7408 gnus-newsgroup-dependencies)
7411 (set-buffer gnus-summary-buffer)
7412 (gnus-data-set-header
7413 (gnus-data-find (cdr gnus-article-current))
7415 (gnus-summary-update-article-line
7416 (cdr gnus-article-current) header))))))
7418 (set-buffer (or buffer gnus-summary-buffer))
7419 (gnus-summary-update-article (cdr gnus-article-current)))
7420 ;; Prettify the article buffer again.
7421 (unless no-highlight
7423 (set-buffer gnus-article-buffer)
7424 (gnus-run-hooks 'gnus-article-display-hook)
7425 (set-buffer gnus-original-article-buffer)
7426 (gnus-request-article
7427 (cdr gnus-article-current)
7428 (car gnus-article-current) (current-buffer))))
7429 ;; Prettify the summary buffer line.
7430 (when (gnus-visual-p 'summary-highlight 'highlight)
7431 (gnus-run-hooks 'gnus-visual-mark-article-hook))))
7433 (defun gnus-summary-edit-wash (key)
7434 "Perform editing command in the article buffer."
7438 (message "%s" (concat (this-command-keys) "- "))
7441 (gnus-summary-edit-article)
7442 (execute-kbd-macro (concat (this-command-keys) key))
7443 (gnus-article-edit-done))
7447 (defun gnus-summary-respool-query (&optional silent)
7448 "Query where the respool algorithm would put this article."
7450 (let (gnus-mark-article-hook)
7451 (gnus-summary-select-article)
7453 (set-buffer gnus-original-article-buffer)
7455 (message-narrow-to-head)
7456 (let ((groups (nnmail-article-group 'identity)))
7459 (message "This message would go to %s"
7460 (mapconcat 'car groups ", "))
7461 (message "This message would go to no groups"))
7464 ;; Summary marking commands.
7466 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7467 "Mark articles which has the same subject as read, and then select the next.
7468 If UNMARK is positive, remove any kind of mark.
7469 If UNMARK is negative, tick articles."
7472 (setq unmark (prefix-numeric-value unmark)))
7474 (gnus-summary-mark-same-subject
7475 (gnus-summary-article-subject) unmark)))
7476 ;; Select next unread article. If auto-select-same mode, should
7477 ;; select the first unread article.
7478 (gnus-summary-next-article t (and gnus-auto-select-same
7479 (gnus-summary-article-subject)))
7480 (gnus-message 7 "%d article%s marked as %s"
7481 count (if (= count 1) " is" "s are")
7482 (if unmark "unread" "read"))))
7484 (defun gnus-summary-kill-same-subject (&optional unmark)
7485 "Mark articles which has the same subject as read.
7486 If UNMARK is positive, remove any kind of mark.
7487 If UNMARK is negative, tick articles."
7490 (setq unmark (prefix-numeric-value unmark)))
7492 (gnus-summary-mark-same-subject
7493 (gnus-summary-article-subject) unmark)))
7494 ;; If marked as read, go to next unread subject.
7496 ;; Go to next unread subject.
7497 (gnus-summary-next-subject 1 t))
7498 (gnus-message 7 "%d articles are marked as %s"
7499 count (if unmark "unread" "read"))))
7501 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7502 "Mark articles with same SUBJECT as read, and return marked number.
7503 If optional argument UNMARK is positive, remove any kinds of marks.
7504 If optional argument UNMARK is negative, mark articles as unread instead."
7508 ((null unmark) ; Mark as read.
7511 (gnus-summary-mark-article-as-read gnus-killed-mark)
7512 (gnus-summary-show-thread) t)
7513 (gnus-summary-find-subject subject))
7514 (setq count (1+ count))))
7515 ((> unmark 0) ; Tick.
7518 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7519 (gnus-summary-show-thread) t)
7520 (gnus-summary-find-subject subject))
7521 (setq count (1+ count))))
7522 (t ; Mark as unread.
7525 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7526 (gnus-summary-show-thread) t)
7527 (gnus-summary-find-subject subject))
7528 (setq count (1+ count)))))
7529 (gnus-set-mode-line 'summary)
7530 ;; Return the number of marked articles.
7533 (defun gnus-summary-mark-as-processable (n &optional unmark)
7534 "Set the process mark on the next N articles.
7535 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7536 the process mark instead. The difference between N and the actual
7537 number of articles marked is returned."
7539 (let ((backward (< n 0))
7544 (gnus-summary-remove-process-mark
7545 (gnus-summary-article-number))
7546 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7547 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7550 (gnus-message 7 "No more articles"))
7551 (gnus-summary-recenter)
7552 (gnus-summary-position-point)
7555 (defun gnus-summary-unmark-as-processable (n)
7556 "Remove the process mark from the next N articles.
7557 If N is negative, unmark backward instead. The difference between N and
7558 the actual number of articles unmarked is returned."
7560 (gnus-summary-mark-as-processable n t))
7562 (defun gnus-summary-unmark-all-processable ()
7563 "Remove the process mark from all articles."
7566 (while gnus-newsgroup-processable
7567 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7568 (gnus-summary-position-point))
7570 (defun gnus-summary-mark-as-expirable (n)
7571 "Mark N articles forward as expirable.
7572 If N is negative, mark backward instead. The difference between N and
7573 the actual number of articles marked is returned."
7575 (gnus-summary-mark-forward n gnus-expirable-mark))
7577 (defun gnus-summary-mark-article-as-replied (article)
7578 "Mark ARTICLE replied and update the summary line."
7579 (push article gnus-newsgroup-replied)
7580 (let ((buffer-read-only nil))
7581 (when (gnus-summary-goto-subject article)
7582 (gnus-summary-update-secondary-mark article))))
7584 (defun gnus-summary-set-bookmark (article)
7585 "Set a bookmark in current article."
7586 (interactive (list (gnus-summary-article-number)))
7587 (when (or (not (get-buffer gnus-article-buffer))
7588 (not gnus-current-article)
7589 (not gnus-article-current)
7590 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7591 (error "No current article selected"))
7592 ;; Remove old bookmark, if one exists.
7593 (let ((old (assq article gnus-newsgroup-bookmarks)))
7595 (setq gnus-newsgroup-bookmarks
7596 (delq old gnus-newsgroup-bookmarks))))
7597 ;; Set the new bookmark, which is on the form
7598 ;; (article-number . line-number-in-body).
7602 (set-buffer gnus-article-buffer)
7606 (goto-char (point-min))
7607 (search-forward "\n\n" nil t)
7610 gnus-newsgroup-bookmarks)
7611 (gnus-message 6 "A bookmark has been added to the current article."))
7613 (defun gnus-summary-remove-bookmark (article)
7614 "Remove the bookmark from the current article."
7615 (interactive (list (gnus-summary-article-number)))
7616 ;; Remove old bookmark, if one exists.
7617 (let ((old (assq article gnus-newsgroup-bookmarks)))
7620 (setq gnus-newsgroup-bookmarks
7621 (delq old gnus-newsgroup-bookmarks))
7622 (gnus-message 6 "Removed bookmark."))
7623 (gnus-message 6 "No bookmark in current article."))))
7625 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7626 (defun gnus-summary-mark-as-dormant (n)
7627 "Mark N articles forward as dormant.
7628 If N is negative, mark backward instead. The difference between N and
7629 the actual number of articles marked is returned."
7631 (gnus-summary-mark-forward n gnus-dormant-mark))
7633 (defun gnus-summary-set-process-mark (article)
7634 "Set the process mark on ARTICLE and update the summary line."
7635 (setq gnus-newsgroup-processable
7637 (delq article gnus-newsgroup-processable)))
7638 (when (gnus-summary-goto-subject article)
7639 (gnus-summary-show-thread)
7640 (gnus-summary-update-secondary-mark article)))
7642 (defun gnus-summary-remove-process-mark (article)
7643 "Remove the process mark from ARTICLE and update the summary line."
7644 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7645 (when (gnus-summary-goto-subject article)
7646 (gnus-summary-show-thread)
7647 (gnus-summary-update-secondary-mark article)))
7649 (defun gnus-summary-set-saved-mark (article)
7650 "Set the process mark on ARTICLE and update the summary line."
7651 (push article gnus-newsgroup-saved)
7652 (when (gnus-summary-goto-subject article)
7653 (gnus-summary-update-secondary-mark article)))
7655 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7656 "Mark N articles as read forwards.
7657 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7658 The difference between N and the actual number of articles marked is
7661 (let ((backward (< n 0))
7662 (gnus-summary-goto-unread
7663 (and gnus-summary-goto-unread
7664 (not (eq gnus-summary-goto-unread 'never))
7665 (not (memq mark (list gnus-unread-mark
7666 gnus-ticked-mark gnus-dormant-mark)))))
7668 (mark (or mark gnus-del-mark)))
7670 (gnus-summary-mark-article nil mark no-expire)
7671 (zerop (gnus-summary-next-subject
7673 (and gnus-summary-goto-unread
7674 (not (eq gnus-summary-goto-unread 'never)))
7678 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7679 (gnus-summary-recenter)
7680 (gnus-summary-position-point)
7681 (gnus-set-mode-line 'summary)
7684 (defun gnus-summary-mark-article-as-read (mark)
7685 "Mark the current article quickly as read with MARK."
7686 (let ((article (gnus-summary-article-number)))
7687 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7688 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7689 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7690 (push (cons article mark) gnus-newsgroup-reads)
7691 ;; Possibly remove from cache, if that is used.
7692 (when gnus-use-cache
7693 (gnus-cache-enter-remove-article article))
7694 ;; Allow the backend to change the mark.
7695 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7696 ;; Check for auto-expiry.
7697 (when (and gnus-newsgroup-auto-expire
7698 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7699 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7700 (= mark gnus-ancient-mark)
7701 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7702 (= mark gnus-duplicate-mark)))
7703 (setq mark gnus-expirable-mark)
7704 (push article gnus-newsgroup-expirable))
7705 ;; Set the mark in the buffer.
7706 (gnus-summary-update-mark mark 'unread)
7709 (defun gnus-summary-mark-article-as-unread (mark)
7710 "Mark the current article quickly as unread with MARK."
7711 (let* ((article (gnus-summary-article-number))
7712 (old-mark (gnus-summary-article-mark article)))
7713 (if (eq mark old-mark)
7717 (gnus-error 1 "Can't mark negative article numbers")
7719 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7720 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7721 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7722 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7723 (cond ((= mark gnus-ticked-mark)
7724 (push article gnus-newsgroup-marked))
7725 ((= mark gnus-dormant-mark)
7726 (push article gnus-newsgroup-dormant))
7728 (push article gnus-newsgroup-unreads)))
7729 (setq gnus-newsgroup-reads
7730 (delq (assq article gnus-newsgroup-reads)
7731 gnus-newsgroup-reads))
7733 ;; See whether the article is to be put in the cache.
7735 (vectorp (gnus-summary-article-header article))
7737 (gnus-cache-possibly-enter-article
7738 gnus-newsgroup-name article
7739 (gnus-summary-article-header article)
7740 (= mark gnus-ticked-mark)
7741 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7744 (gnus-summary-update-mark mark 'unread)
7747 (defun gnus-summary-mark-article (&optional article mark no-expire)
7748 "Mark ARTICLE with MARK. MARK can be any character.
7749 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7750 `??' (dormant) and `?E' (expirable).
7751 If MARK is nil, then the default character `?D' is used.
7752 If ARTICLE is nil, then the article on the current line will be
7754 ;; The mark might be a string.
7755 (when (stringp mark)
7756 (setq mark (aref mark 0)))
7757 ;; If no mark is given, then we check auto-expiring.
7758 (and (not no-expire)
7759 gnus-newsgroup-auto-expire
7761 (and (gnus-characterp mark)
7762 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7763 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7764 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7765 (= mark gnus-duplicate-mark))))
7766 (setq mark gnus-expirable-mark))
7767 (let* ((mark (or mark gnus-del-mark))
7768 (article (or article (gnus-summary-article-number)))
7769 (old-mark (gnus-summary-article-mark article)))
7770 (if (eq mark old-mark)
7773 (error "No article on current line"))
7774 (if (not (if (or (= mark gnus-unread-mark)
7775 (= mark gnus-ticked-mark)
7776 (= mark gnus-dormant-mark))
7777 (gnus-mark-article-as-unread article mark)
7778 (gnus-mark-article-as-read article mark)))
7780 ;; See whether the article is to be put in the cache.
7782 (not (= mark gnus-canceled-mark))
7783 (vectorp (gnus-summary-article-header article))
7785 (gnus-cache-possibly-enter-article
7786 gnus-newsgroup-name article
7787 (gnus-summary-article-header article)
7788 (= mark gnus-ticked-mark)
7789 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7791 (when (gnus-summary-goto-subject article nil t)
7792 (let ((buffer-read-only nil))
7793 (gnus-summary-show-thread)
7795 (gnus-summary-update-mark mark 'unread)
7798 (defun gnus-summary-update-secondary-mark (article)
7799 "Update the secondary (read, process, cache) mark."
7800 (gnus-summary-update-mark
7801 (cond ((memq article gnus-newsgroup-processable)
7803 ((memq article gnus-newsgroup-cached)
7805 ((memq article gnus-newsgroup-replied)
7807 ((memq article gnus-newsgroup-saved)
7809 (t gnus-unread-mark))
7811 (when (gnus-visual-p 'summary-highlight 'highlight)
7812 (gnus-run-hooks 'gnus-summary-update-hook))
7815 (defun gnus-summary-update-mark (mark type)
7816 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7817 (buffer-read-only nil))
7818 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7819 (when (looking-at "\r")
7822 (<= (+ forward (point)) (point-max)))
7823 ;; Go to the right position on the line.
7824 (goto-char (+ forward (point)))
7825 ;; Replace the old mark with the new mark.
7826 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7827 ;; Optionally update the marks by some user rule.
7828 (when (eq type 'unread)
7830 (gnus-data-find (gnus-summary-article-number)) mark)
7831 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7833 (defun gnus-mark-article-as-read (article &optional mark)
7834 "Enter ARTICLE in the pertinent lists and remove it from others."
7835 ;; Make the article expirable.
7836 (let ((mark (or mark gnus-del-mark)))
7837 (if (= mark gnus-expirable-mark)
7838 (push article gnus-newsgroup-expirable)
7839 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7840 ;; Remove from unread and marked lists.
7841 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7842 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7843 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7844 (push (cons article mark) gnus-newsgroup-reads)
7845 ;; Possibly remove from cache, if that is used.
7846 (when gnus-use-cache
7847 (gnus-cache-enter-remove-article article))
7850 (defun gnus-mark-article-as-unread (article &optional mark)
7851 "Enter ARTICLE in the pertinent lists and remove it from others."
7852 (let ((mark (or mark gnus-ticked-mark)))
7855 (gnus-error 1 "Can't mark negative article numbers")
7857 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7858 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7859 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7860 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7862 ;; Unsuppress duplicates?
7863 (when gnus-suppress-duplicates
7864 (gnus-dup-unsuppress-article article))
7866 (cond ((= mark gnus-ticked-mark)
7867 (push article gnus-newsgroup-marked))
7868 ((= mark gnus-dormant-mark)
7869 (push article gnus-newsgroup-dormant))
7871 (push article gnus-newsgroup-unreads)))
7872 (setq gnus-newsgroup-reads
7873 (delq (assq article gnus-newsgroup-reads)
7874 gnus-newsgroup-reads))
7877 (defalias 'gnus-summary-mark-as-unread-forward
7878 'gnus-summary-tick-article-forward)
7879 (make-obsolete 'gnus-summary-mark-as-unread-forward
7880 'gnus-summary-tick-article-forward)
7881 (defun gnus-summary-tick-article-forward (n)
7882 "Tick N articles forwards.
7883 If N is negative, tick backwards instead.
7884 The difference between N and the number of articles ticked is returned."
7886 (gnus-summary-mark-forward n gnus-ticked-mark))
7888 (defalias 'gnus-summary-mark-as-unread-backward
7889 'gnus-summary-tick-article-backward)
7890 (make-obsolete 'gnus-summary-mark-as-unread-backward
7891 'gnus-summary-tick-article-backward)
7892 (defun gnus-summary-tick-article-backward (n)
7893 "Tick N articles backwards.
7894 The difference between N and the number of articles ticked is returned."
7896 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7898 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7899 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7900 (defun gnus-summary-tick-article (&optional article clear-mark)
7901 "Mark current article as unread.
7902 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7903 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7905 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7908 (defun gnus-summary-mark-as-read-forward (n)
7909 "Mark N articles as read forwards.
7910 If N is negative, mark backwards instead.
7911 The difference between N and the actual number of articles marked is
7914 (gnus-summary-mark-forward n gnus-del-mark t))
7916 (defun gnus-summary-mark-as-read-backward (n)
7917 "Mark the N articles as read backwards.
7918 The difference between N and the actual number of articles marked is
7921 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7923 (defun gnus-summary-mark-as-read (&optional article mark)
7924 "Mark current article as read.
7925 ARTICLE specifies the article to be marked as read.
7926 MARK specifies a string to be inserted at the beginning of the line."
7927 (gnus-summary-mark-article article mark))
7929 (defun gnus-summary-clear-mark-forward (n)
7930 "Clear marks from N articles forward.
7931 If N is negative, clear backward instead.
7932 The difference between N and the number of marks cleared is returned."
7934 (gnus-summary-mark-forward n gnus-unread-mark))
7936 (defun gnus-summary-clear-mark-backward (n)
7937 "Clear marks from N articles backward.
7938 The difference between N and the number of marks cleared is returned."
7940 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7942 (defun gnus-summary-mark-unread-as-read ()
7943 "Intended to be used by `gnus-summary-mark-article-hook'."
7944 (when (memq gnus-current-article gnus-newsgroup-unreads)
7945 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7947 (defun gnus-summary-mark-read-and-unread-as-read ()
7948 "Intended to be used by `gnus-summary-mark-article-hook'."
7949 (let ((mark (gnus-summary-article-mark)))
7950 (when (or (gnus-unread-mark-p mark)
7951 (gnus-read-mark-p mark))
7952 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7954 (defun gnus-summary-mark-region-as-read (point mark all)
7955 "Mark all unread articles between point and mark as read.
7956 If given a prefix, mark all articles between point and mark as read,
7957 even ticked and dormant ones."
7958 (interactive "r\nP")
7967 (memq (setq article (gnus-summary-article-number))
7968 gnus-newsgroup-unreads))
7969 (gnus-summary-mark-article article gnus-del-mark))
7971 (gnus-summary-find-next))))))
7973 (defun gnus-summary-mark-below (score mark)
7974 "Mark articles with score less than SCORE with MARK."
7975 (interactive "P\ncMark: ")
7976 (setq score (if score
7977 (prefix-numeric-value score)
7978 (or gnus-summary-default-score 0)))
7980 (set-buffer gnus-summary-buffer)
7981 (goto-char (point-min))
7984 (and (< (gnus-summary-article-score) score)
7985 (gnus-summary-mark-article nil mark))
7986 (gnus-summary-find-next)))))
7988 (defun gnus-summary-kill-below (&optional score)
7989 "Mark articles with score below SCORE as read."
7991 (gnus-summary-mark-below score gnus-killed-mark))
7993 (defun gnus-summary-clear-above (&optional score)
7994 "Clear all marks from articles with score above SCORE."
7996 (gnus-summary-mark-above score gnus-unread-mark))
7998 (defun gnus-summary-tick-above (&optional score)
7999 "Tick all articles with score above SCORE."
8001 (gnus-summary-mark-above score gnus-ticked-mark))
8003 (defun gnus-summary-mark-above (score mark)
8004 "Mark articles with score over SCORE with MARK."
8005 (interactive "P\ncMark: ")
8006 (setq score (if score
8007 (prefix-numeric-value score)
8008 (or gnus-summary-default-score 0)))
8010 (set-buffer gnus-summary-buffer)
8011 (goto-char (point-min))
8013 (when (> (gnus-summary-article-score) score)
8014 (gnus-summary-mark-article nil mark))
8016 (gnus-summary-find-next)))))
8018 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8019 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8020 (defun gnus-summary-limit-include-expunged (&optional no-error)
8021 "Display all the hidden articles that were expunged for low scores."
8023 (let ((buffer-read-only nil))
8024 (let ((scored gnus-newsgroup-scored)
8027 (unless (gnus-summary-goto-subject (caar scored))
8028 (and (setq h (gnus-summary-article-header (caar scored)))
8029 (< (cdar scored) gnus-summary-expunge-below)
8031 (setq scored (cdr scored)))
8033 (when (not no-error)
8034 (error "No expunged articles hidden"))
8035 (goto-char (point-min))
8036 (gnus-summary-prepare-unthreaded (nreverse headers))
8037 (goto-char (point-min))
8038 (gnus-summary-position-point)
8041 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8042 "Mark all unread articles in this newsgroup as read.
8043 If prefix argument ALL is non-nil, ticked and dormant articles will
8044 also be marked as read.
8045 If QUIETLY is non-nil, no questions will be asked.
8046 If TO-HERE is non-nil, it should be a point in the buffer. All
8047 articles before this point will be marked as read.
8048 Note that this function will only catch up the unread article
8049 in the current summary buffer limitation.
8050 The number of articles marked as read is returned."
8055 (not gnus-interactive-catchup) ;Without confirmation?
8059 "Mark absolutely all articles as read? "
8060 "Mark all unread articles as read? ")))
8062 (not gnus-newsgroup-adaptive)
8063 (not gnus-newsgroup-auto-expire)
8064 (not gnus-suppress-duplicates)
8065 (or (not gnus-use-cache)
8066 (eq gnus-use-cache 'passive)))
8069 (setq gnus-newsgroup-marked nil
8070 gnus-newsgroup-dormant nil))
8071 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8072 ;; We actually mark all articles as canceled, which we
8073 ;; have to do when using auto-expiry or adaptive scoring.
8074 (gnus-summary-show-all-threads)
8075 (when (gnus-summary-first-subject (not all))
8077 (if to-here (< (point) to-here) t)
8078 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8079 (gnus-summary-find-next (not all)))))
8080 (gnus-set-mode-line 'summary))
8082 (gnus-summary-position-point)))
8084 (defun gnus-summary-catchup-to-here (&optional all)
8085 "Mark all unticked articles before the current one as read.
8086 If ALL is non-nil, also mark ticked and dormant articles as read."
8089 (gnus-save-hidden-threads
8090 (let ((beg (point)))
8091 ;; We check that there are unread articles.
8092 (when (or all (gnus-summary-find-prev))
8093 (gnus-summary-catchup all t beg)))))
8094 (gnus-summary-position-point))
8096 (defun gnus-summary-catchup-all (&optional quietly)
8097 "Mark all articles in this newsgroup as read."
8099 (gnus-summary-catchup t quietly))
8101 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8102 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8103 If prefix argument ALL is non-nil, all articles are marked as read."
8105 (when (gnus-summary-catchup all quietly nil 'fast)
8106 ;; Select next newsgroup or exit.
8107 (if (eq gnus-auto-select-next 'quietly)
8108 (gnus-summary-next-group nil)
8109 (gnus-summary-exit))))
8111 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8112 "Mark all articles in this newsgroup as read, and then exit."
8114 (gnus-summary-catchup-and-exit t quietly))
8116 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8117 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8118 "Mark all articles in this group as read and select the next group.
8119 If given a prefix, mark all articles, unread as well as ticked, as
8123 (gnus-summary-catchup all))
8124 (gnus-summary-next-article t nil nil t))
8126 ;; Thread-based commands.
8128 (defun gnus-summary-articles-in-thread (&optional article)
8129 "Return a list of all articles in the current thread.
8130 If ARTICLE is non-nil, return all articles in the thread that starts
8132 (let* ((article (or article (gnus-summary-article-number)))
8133 (data (gnus-data-find-list article))
8134 (top-level (gnus-data-level (car data)))
8136 (cond ((null gnus-thread-operation-ignore-subject)
8137 (gnus-simplify-subject-re
8138 (mail-header-subject (gnus-data-header (car data)))))
8139 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8140 (gnus-simplify-subject-fuzzy
8141 (mail-header-subject (gnus-data-header (car data)))))
8143 (end-point (save-excursion
8144 (if (gnus-summary-go-to-next-thread)
8145 (point) (point-max))))
8148 (< (gnus-data-pos (car data)) end-point))
8149 (when (or (not top-subject)
8150 (string= top-subject
8151 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8152 (gnus-simplify-subject-fuzzy
8153 (mail-header-subject
8154 (gnus-data-header (car data))))
8155 (gnus-simplify-subject-re
8156 (mail-header-subject
8157 (gnus-data-header (car data)))))))
8158 (push (gnus-data-number (car data)) articles))
8159 (unless (and (setq data (cdr data))
8160 (> (gnus-data-level (car data)) top-level))
8162 ;; Return the list of articles.
8163 (nreverse articles)))
8165 (defun gnus-summary-rethread-current ()
8166 "Rethread the thread the current article is part of."
8168 (let* ((gnus-show-threads t)
8169 (article (gnus-summary-article-number))
8170 (id (mail-header-id (gnus-summary-article-header)))
8171 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8173 (error "No article on the current line"))
8174 (gnus-rebuild-thread id)
8175 (gnus-summary-goto-subject article)))
8177 (defun gnus-summary-reparent-thread ()
8178 "Make the current article child of the marked (or previous) article.
8180 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8181 is non-nil or the Subject: of both articles are the same."
8183 (unless (not (gnus-group-read-only-p))
8184 (error "The current newsgroup does not support article editing"))
8185 (unless (<= (length gnus-newsgroup-processable) 1)
8186 (error "No more than one article may be marked"))
8187 (save-window-excursion
8188 (let ((gnus-article-buffer " *reparent*")
8189 (current-article (gnus-summary-article-number))
8190 ;; First grab the marked article, otherwise one line up.
8191 (parent-article (if (not (null gnus-newsgroup-processable))
8192 (car gnus-newsgroup-processable)
8194 (if (eq (forward-line -1) 0)
8195 (gnus-summary-article-number)
8196 (error "Beginning of summary buffer"))))))
8197 (unless (not (eq current-article parent-article))
8198 (error "An article may not be self-referential"))
8199 (let ((message-id (mail-header-id
8200 (gnus-summary-article-header parent-article))))
8201 (unless (and message-id (not (equal message-id "")))
8202 (error "No message-id in desired parent"))
8203 ;; We don't want the article to be marked as read.
8204 (let (gnus-mark-article-hook)
8205 (gnus-summary-select-article t t nil current-article))
8206 (set-buffer gnus-original-article-buffer)
8207 (let ((buf (format "%s" (buffer-string))))
8208 (nnheader-temp-write nil
8210 (goto-char (point-min))
8211 (if (re-search-forward "^References: " nil t)
8213 (re-search-forward "^[^ \t]" nil t)
8216 (insert " " message-id))
8217 (insert "References: " message-id "\n"))
8218 (unless (gnus-request-replace-article
8219 current-article (car gnus-article-current)
8221 (error "Couldn't replace article"))))
8222 (set-buffer gnus-summary-buffer)
8223 (gnus-summary-unmark-all-processable)
8224 (gnus-summary-update-article current-article)
8225 (gnus-summary-rethread-current)
8226 (gnus-message 3 "Article %d is now the child of article %d"
8227 current-article parent-article)))))
8229 (defun gnus-summary-toggle-threads (&optional arg)
8230 "Toggle showing conversation threads.
8231 If ARG is positive number, turn showing conversation threads on."
8233 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8234 (setq gnus-show-threads
8235 (if (null arg) (not gnus-show-threads)
8236 (> (prefix-numeric-value arg) 0)))
8237 (gnus-summary-prepare)
8238 (gnus-summary-goto-subject current)
8239 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8240 (gnus-summary-position-point)))
8242 (defun gnus-summary-show-all-threads ()
8246 (let ((buffer-read-only nil))
8247 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8248 (gnus-summary-position-point))
8250 (defun gnus-summary-show-thread ()
8251 "Show thread subtrees.
8252 Returns nil if no thread was there to be shown."
8254 (let ((buffer-read-only nil)
8256 ;; first goto end then to beg, to have point at beg after let
8257 (end (progn (end-of-line) (point)))
8258 (beg (progn (beginning-of-line) (point))))
8260 ;; Any hidden lines here?
8261 (search-forward "\r" end t)
8262 (subst-char-in-region beg end ?\^M ?\n t)
8264 (gnus-summary-position-point))))
8266 (defun gnus-summary-hide-all-threads ()
8267 "Hide all thread subtrees."
8270 (goto-char (point-min))
8271 (gnus-summary-hide-thread)
8272 (while (zerop (gnus-summary-next-thread 1 t))
8273 (gnus-summary-hide-thread)))
8274 (gnus-summary-position-point))
8276 (defun gnus-summary-hide-thread ()
8277 "Hide thread subtrees.
8278 Returns nil if no threads were there to be hidden."
8280 (let ((buffer-read-only nil)
8282 (article (gnus-summary-article-number)))
8284 ;; Go forward until either the buffer ends or the subthread
8286 (when (and (not (eobp))
8287 (or (zerop (gnus-summary-next-thread 1 t))
8288 (goto-char (point-max))))
8290 (if (and (> (point) start)
8291 (search-backward "\n" start t))
8293 (subst-char-in-region start (point) ?\n ?\^M)
8294 (gnus-summary-goto-subject article))
8297 ;;(gnus-summary-position-point)
8300 (defun gnus-summary-go-to-next-thread (&optional previous)
8301 "Go to the same level (or less) next thread.
8302 If PREVIOUS is non-nil, go to previous thread instead.
8303 Return the article number moved to, or nil if moving was impossible."
8304 (let ((level (gnus-summary-thread-level))
8305 (way (if previous -1 1))
8308 (while (and (not (eobp))
8309 (< level (gnus-summary-thread-level)))
8317 (gnus-summary-article-number)
8320 (defun gnus-summary-next-thread (n &optional silent)
8321 "Go to the same level next N'th thread.
8322 If N is negative, search backward instead.
8323 Returns the difference between N and the number of skips actually
8326 If SILENT, don't output messages."
8328 (let ((backward (< n 0))
8331 (gnus-summary-go-to-next-thread backward))
8334 (gnus-summary-position-point))
8335 (when (and (not silent) (/= 0 n))
8336 (gnus-message 7 "No more threads"))
8339 (defun gnus-summary-prev-thread (n)
8340 "Go to the same level previous N'th thread.
8341 Returns the difference between N and the number of skips actually
8344 (gnus-summary-next-thread (- n)))
8346 (defun gnus-summary-go-down-thread ()
8347 "Go down one level in the current thread."
8348 (let ((children (gnus-summary-article-children)))
8350 (gnus-summary-goto-subject (car children)))))
8352 (defun gnus-summary-go-up-thread ()
8353 "Go up one level in the current thread."
8354 (let ((parent (gnus-summary-article-parent)))
8356 (gnus-summary-goto-subject parent))))
8358 (defun gnus-summary-down-thread (n)
8359 "Go down thread N steps.
8360 If N is negative, go up instead.
8361 Returns the difference between N and how many steps down that were
8367 (if up (gnus-summary-go-up-thread)
8368 (gnus-summary-go-down-thread)))
8370 (gnus-summary-position-point)
8372 (gnus-message 7 "Can't go further"))
8375 (defun gnus-summary-up-thread (n)
8376 "Go up thread N steps.
8377 If N is negative, go up instead.
8378 Returns the difference between N and how many steps down that were
8381 (gnus-summary-down-thread (- n)))
8383 (defun gnus-summary-top-thread ()
8384 "Go to the top of the thread."
8386 (while (gnus-summary-go-up-thread))
8387 (gnus-summary-article-number))
8389 (defun gnus-summary-kill-thread (&optional unmark)
8390 "Mark articles under current thread as read.
8391 If the prefix argument is positive, remove any kinds of marks.
8392 If the prefix argument is negative, tick articles instead."
8395 (setq unmark (prefix-numeric-value unmark)))
8396 (let ((articles (gnus-summary-articles-in-thread)))
8398 ;; Expand the thread.
8399 (gnus-summary-show-thread)
8400 ;; Mark all the articles.
8402 (gnus-summary-goto-subject (car articles))
8403 (cond ((null unmark)
8404 (gnus-summary-mark-article-as-read gnus-killed-mark))
8406 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8408 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8409 (setq articles (cdr articles))))
8410 ;; Hide killed subtrees.
8412 gnus-thread-hide-killed
8413 (gnus-summary-hide-thread))
8414 ;; If marked as read, go to next unread subject.
8416 ;; Go to next unread subject.
8417 (gnus-summary-next-subject 1 t)))
8418 (gnus-set-mode-line 'summary))
8420 ;; Summary sorting commands
8422 (defun gnus-summary-sort-by-number (&optional reverse)
8423 "Sort the summary buffer by article number.
8424 Argument REVERSE means reverse order."
8426 (gnus-summary-sort 'number reverse))
8428 (defun gnus-summary-sort-by-author (&optional reverse)
8429 "Sort the summary buffer by author name alphabetically.
8430 If case-fold-search is non-nil, case of letters is ignored.
8431 Argument REVERSE means reverse order."
8433 (gnus-summary-sort 'author reverse))
8435 (defun gnus-summary-sort-by-subject (&optional reverse)
8436 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8437 If case-fold-search is non-nil, case of letters is ignored.
8438 Argument REVERSE means reverse order."
8440 (gnus-summary-sort 'subject reverse))
8442 (defun gnus-summary-sort-by-date (&optional reverse)
8443 "Sort the summary buffer by date.
8444 Argument REVERSE means reverse order."
8446 (gnus-summary-sort 'date reverse))
8448 (defun gnus-summary-sort-by-score (&optional reverse)
8449 "Sort the summary buffer by score.
8450 Argument REVERSE means reverse order."
8452 (gnus-summary-sort 'score reverse))
8454 (defun gnus-summary-sort-by-lines (&optional reverse)
8455 "Sort the summary buffer by article length.
8456 Argument REVERSE means reverse order."
8458 (gnus-summary-sort 'lines reverse))
8460 (defun gnus-summary-sort (predicate reverse)
8461 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8462 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8463 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8464 (gnus-thread-sort-functions
8470 (gnus-article-sort-functions
8475 (,article t2 t1)))))
8477 (gnus-summary-prepare-hook nil))
8478 ;; We do the sorting by regenerating the threads.
8479 (gnus-summary-prepare)
8480 ;; Hide subthreads if needed.
8481 (when (and gnus-show-threads gnus-thread-hide-subtree)
8482 (gnus-summary-hide-all-threads))))
8484 ;; Summary saving commands.
8486 (defun gnus-summary-save-article (&optional n not-saved)
8487 "Save the current article using the default saver function.
8488 If N is a positive number, save the N next articles.
8489 If N is a negative number, save the N previous articles.
8490 If N is nil and any articles have been marked with the process mark,
8491 save those articles instead.
8492 The variable `gnus-default-article-saver' specifies the saver function."
8494 (let* ((articles (gnus-summary-work-articles n))
8495 (save-buffer (save-excursion
8496 (nnheader-set-temp-buffer " *Gnus Save*")))
8497 (num (length articles))
8498 header article file)
8500 (setq header (gnus-summary-article-header
8501 (setq article (pop articles))))
8502 (if (not (vectorp header))
8503 ;; This is a pseudo-article.
8504 (if (assq 'name header)
8505 (gnus-copy-file (cdr (assq 'name header)))
8506 (gnus-message 1 "Article %d is unsaveable" article))
8507 ;; This is a real article.
8508 (save-window-excursion
8509 (gnus-summary-select-article t nil nil article))
8511 (set-buffer save-buffer)
8513 (insert-buffer-substring gnus-original-article-buffer))
8514 (setq file (gnus-article-save save-buffer file num))
8515 (gnus-summary-remove-process-mark article)
8517 (gnus-summary-set-saved-mark article))))
8518 (gnus-kill-buffer save-buffer)
8519 (gnus-summary-position-point)
8520 (gnus-set-mode-line 'summary)
8523 (defun gnus-summary-pipe-output (&optional arg)
8524 "Pipe the current article to a subprocess.
8525 If N is a positive number, pipe the N next articles.
8526 If N is a negative number, pipe the N previous articles.
8527 If N is nil and any articles have been marked with the process mark,
8528 pipe those articles instead."
8530 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8531 (gnus-summary-save-article arg t))
8532 (gnus-configure-windows 'pipe))
8534 (defun gnus-summary-save-article-mail (&optional arg)
8535 "Append the current article to an mail file.
8536 If N is a positive number, save the N next articles.
8537 If N is a negative number, save the N previous articles.
8538 If N is nil and any articles have been marked with the process mark,
8539 save those articles instead."
8541 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8542 (gnus-summary-save-article arg)))
8544 (defun gnus-summary-save-article-rmail (&optional arg)
8545 "Append the current article to an rmail file.
8546 If N is a positive number, save the N next articles.
8547 If N is a negative number, save the N previous articles.
8548 If N is nil and any articles have been marked with the process mark,
8549 save those articles instead."
8551 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8552 (gnus-summary-save-article arg)))
8554 (defun gnus-summary-save-article-file (&optional arg)
8555 "Append the current article to a file.
8556 If N is a positive number, save the N next articles.
8557 If N is a negative number, save the N previous articles.
8558 If N is nil and any articles have been marked with the process mark,
8559 save those articles instead."
8561 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8562 (gnus-summary-save-article arg)))
8564 (defun gnus-summary-write-article-file (&optional arg)
8565 "Write the current article to a file, deleting the previous file.
8566 If N is a positive number, save the N next articles.
8567 If N is a negative number, save the N previous articles.
8568 If N is nil and any articles have been marked with the process mark,
8569 save those articles instead."
8571 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8572 (gnus-summary-save-article arg)))
8574 (defun gnus-summary-save-article-body-file (&optional arg)
8575 "Append the current article body to a file.
8576 If N is a positive number, save the N next articles.
8577 If N is a negative number, save the N previous articles.
8578 If N is nil and any articles have been marked with the process mark,
8579 save those articles instead."
8581 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8582 (gnus-summary-save-article arg)))
8584 (defun gnus-summary-pipe-message (program)
8585 "Pipe the current article through PROGRAM."
8586 (interactive "sProgram: ")
8587 (gnus-summary-select-article)
8588 (let ((mail-header-separator "")
8589 (art-buf (get-buffer gnus-article-buffer)))
8590 (gnus-eval-in-buffer-window gnus-article-buffer
8593 (let ((start (window-start))
8595 (message-pipe-buffer-body program)
8596 (set-window-start (get-buffer-window (current-buffer)) start))))))
8598 (defun gnus-get-split-value (methods)
8599 "Return a value based on the split METHODS."
8600 (let (split-name method result match)
8603 (set-buffer gnus-original-article-buffer)
8605 (nnheader-narrow-to-headers)
8607 (goto-char (point-min))
8608 (setq method (pop methods))
8609 (setq match (car method))
8612 ;; Regular expression.
8614 (re-search-forward match nil t)))
8615 ((gnus-functionp match)
8619 (setq result (funcall match gnus-newsgroup-name))))
8624 (setq result (eval match)))))
8625 (setq split-name (append (cdr method) split-name))
8626 (cond ((stringp result)
8627 (push (expand-file-name
8628 result gnus-article-save-directory)
8631 (setq split-name (append result split-name)))))))))
8634 (defun gnus-valid-move-group-p (group)
8639 (car (gnus-find-method-for-group
8640 (symbol-name group))))
8641 gnus-valid-select-methods))))
8643 (defun gnus-read-move-group-name (prompt default articles prefix)
8644 "Read a group name."
8645 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8646 (minibuffer-confirm-incomplete nil) ; XEmacs
8650 (if (> (length articles) 1)
8651 (format "these %d articles" (length articles))
8656 (gnus-completing-read default prom
8658 'gnus-valid-move-group-p
8660 'gnus-group-history))
8661 ((= 1 (length split-name))
8662 (gnus-completing-read (car split-name) prom
8664 'gnus-valid-move-group-p
8666 'gnus-group-history))
8668 (gnus-completing-read nil prom
8669 (mapcar (lambda (el) (list el))
8670 (nreverse split-name))
8672 'gnus-group-history)))))
8674 (if (or (string= to-newsgroup "")
8675 (string= to-newsgroup prefix))
8676 (setq to-newsgroup default))
8677 (unless to-newsgroup
8678 (error "No group name entered"))
8679 (or (gnus-active to-newsgroup)
8680 (gnus-activate-group to-newsgroup)
8681 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8683 (or (and (gnus-request-create-group
8684 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8685 (gnus-activate-group to-newsgroup nil nil
8686 (gnus-group-name-to-method
8688 (error "Couldn't create group %s" to-newsgroup)))
8689 (error "No such group: %s" to-newsgroup)))
8692 ;; Summary extract commands
8694 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8695 (let ((buffer-read-only nil)
8696 (article (gnus-summary-article-number))
8698 (unless (gnus-summary-goto-subject article)
8699 (error "No such article: %d" article))
8700 (gnus-summary-position-point)
8701 ;; If all commands are to be bunched up on one line, we collect
8703 (unless gnus-view-pseudos-separately
8704 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8707 (setq action (cdr (assq 'action (car ps))))
8708 (setq files (list (cdr (assq 'name (car ps)))))
8709 (while (and ps (cdr ps)
8710 (string= (or action "1")
8711 (or (cdr (assq 'action (cadr ps))) "2")))
8712 (push (cdr (assq 'name (cadr ps))) files)
8713 (setcdr ps (cddr ps)))
8715 (when (not (string-match "%s" action))
8718 (when (assq 'execute (car ps))
8719 (setcdr (assq 'execute (car ps))
8720 (funcall (if (string-match "%s" action)
8727 (gnus-quote-arg-for-sh-or-csh f)))
8729 (setq ps (cdr ps)))))
8730 (if (and gnus-view-pseudos (not not-view))
8732 (when (assq 'execute (car pslist))
8733 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8734 (eq gnus-view-pseudos 'not-confirm)))
8735 (setq pslist (cdr pslist)))
8738 (setq after-article (or (cdr (assq 'article (car pslist)))
8739 (gnus-summary-article-number)))
8740 (gnus-summary-goto-subject after-article)
8743 (insert " " (file-name-nondirectory
8744 (cdr (assq 'name (car pslist))))
8745 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8747 (forward-line -1) ; back to `b'
8748 (gnus-add-text-properties
8749 b (1- e) (list 'gnus-number gnus-reffed-article-number
8750 gnus-mouse-face-prop gnus-mouse-face))
8752 after-article gnus-reffed-article-number
8753 gnus-unread-mark b (car pslist) 0 (- e b))
8754 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8755 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8756 (setq pslist (cdr pslist)))))))
8758 (defun gnus-pseudos< (p1 p2)
8759 (let ((c1 (cdr (assq 'action p1)))
8760 (c2 (cdr (assq 'action p2))))
8761 (and c1 c2 (string< c1 c2))))
8763 (defun gnus-request-pseudo-article (props)
8764 (cond ((assq 'execute props)
8765 (gnus-execute-command (cdr (assq 'execute props)))))
8766 (let ((gnus-current-article (gnus-summary-article-number)))
8767 (gnus-run-hooks 'gnus-mark-article-hook)))
8769 (defun gnus-execute-command (command &optional automatic)
8771 (gnus-article-setup-buffer)
8772 (set-buffer gnus-article-buffer)
8773 (setq buffer-read-only nil)
8774 (let ((command (if automatic command
8775 (read-string "Command: " (cons command 0)))))
8777 (insert "$ " command "\n\n")
8778 (if gnus-view-pseudo-asynchronously
8779 (start-process "gnus-execute" (current-buffer) shell-file-name
8780 shell-command-switch command)
8781 (call-process shell-file-name nil t nil
8782 shell-command-switch command)))))
8784 ;; Summary kill commands.
8786 (defun gnus-summary-edit-global-kill (article)
8787 "Edit the \"global\" kill file."
8788 (interactive (list (gnus-summary-article-number)))
8789 (gnus-group-edit-global-kill article))
8791 (defun gnus-summary-edit-local-kill ()
8792 "Edit a local kill file applied to the current newsgroup."
8794 (setq gnus-current-headers (gnus-summary-article-header))
8795 (gnus-group-edit-local-kill
8796 (gnus-summary-article-number) gnus-newsgroup-name))
8800 (defun gnus-read-header (id &optional header)
8801 "Read the headers of article ID and enter them into the Gnus system."
8802 (let ((group gnus-newsgroup-name)
8803 (gnus-override-method
8804 (and (gnus-news-group-p gnus-newsgroup-name)
8805 gnus-refer-article-method))
8807 ;; First we check to see whether the header in question is already
8810 ;; This is a Message-ID.
8811 (setq header (or header (gnus-id-to-header id)))
8812 ;; This is an article number.
8813 (setq header (or header (gnus-summary-article-header id))))
8815 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8816 ;; We have found the header.
8818 ;; If this is a sparse article, we have to nix out its
8819 ;; previous entry in the thread hashtb.
8821 (gnus-summary-article-sparse-p (mail-header-number header)))
8822 (let* ((parent (gnus-parent-id (mail-header-references header)))
8825 (gnus-gethash parent gnus-newsgroup-dependencies))))
8827 (delq (assq header thread) thread))))
8828 ;; We have to really fetch the header to this article.
8830 (set-buffer nntp-server-buffer)
8831 (when (setq where (gnus-request-head id group))
8832 (nnheader-fold-continuation-lines)
8833 (goto-char (point-max))
8835 (goto-char (point-min))
8839 ((cdr where) (cdr where))
8840 (header (mail-header-number header))
8841 (t gnus-reffed-article-number))
8843 (insert " Article retrieved.\n"))
8845 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8846 () ; Malformed head.
8847 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8848 (when (and (stringp id)
8849 (not (string= (gnus-group-real-name group)
8851 ;; If we fetched by Message-ID and the article came
8852 ;; from a different group, we fudge some bogus article
8853 ;; numbers for this article.
8854 (mail-header-set-number header gnus-reffed-article-number))
8856 (set-buffer gnus-summary-buffer)
8857 (decf gnus-reffed-article-number)
8858 (gnus-remove-header (mail-header-number header))
8859 (push header gnus-newsgroup-headers)
8860 (setq gnus-current-headers header)
8861 (push (mail-header-number header) gnus-newsgroup-limit)))
8864 (defun gnus-remove-header (number)
8865 "Remove header NUMBER from `gnus-newsgroup-headers'."
8866 (if (and gnus-newsgroup-headers
8867 (= number (mail-header-number (car gnus-newsgroup-headers))))
8868 (pop gnus-newsgroup-headers)
8869 (let ((headers gnus-newsgroup-headers))
8870 (while (and (cdr headers)
8871 (not (= number (mail-header-number (cadr headers)))))
8874 (setcdr headers (cddr headers))))))
8877 ;;; summary highlights
8880 (defun gnus-highlight-selected-summary ()
8881 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8882 ;; Highlight selected article in summary buffer
8883 (when gnus-summary-selected-face
8885 (let* ((beg (progn (beginning-of-line) (point)))
8886 (end (progn (end-of-line) (point)))
8887 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8888 (from (if (get-text-property beg gnus-mouse-face-prop)
8890 (or (next-single-property-change
8891 beg gnus-mouse-face-prop nil end)
8896 (or (next-single-property-change
8897 from gnus-mouse-face-prop nil end)
8899 ;; If no mouse-face prop on line we will have to = from = end,
8900 ;; so we highlight the entire line instead.
8901 (when (= (+ to 2) from)
8904 (if gnus-newsgroup-selected-overlay
8905 ;; Move old overlay.
8907 gnus-newsgroup-selected-overlay from to (current-buffer))
8908 ;; Create new overlay.
8910 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8911 'face gnus-summary-selected-face))))))
8913 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8914 (defun gnus-summary-highlight-line ()
8915 "Highlight current line according to `gnus-summary-highlight'."
8916 (let* ((list gnus-summary-highlight)
8918 (end (progn (end-of-line) (point)))
8919 ;; now find out where the line starts and leave point there.
8920 (beg (progn (beginning-of-line) (point)))
8921 (article (gnus-summary-article-number))
8922 (score (or (cdr (assq (or article gnus-current-article)
8923 gnus-newsgroup-scored))
8924 gnus-summary-default-score 0))
8925 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8926 (inhibit-read-only t))
8927 ;; Eval the cars of the lists until we find a match.
8928 (let ((default gnus-summary-default-score))
8930 (not (eval (caar list))))
8931 (setq list (cdr list))))
8932 (let ((face (cdar list)))
8933 (unless (eq face (get-text-property beg 'face))
8934 (gnus-put-text-property
8936 (setq face (if (boundp face) (symbol-value face) face)))
8937 (when gnus-summary-highlight-line-function
8938 (funcall gnus-summary-highlight-line-function article face))))
8941 (defun gnus-update-read-articles (group unread &optional compute)
8942 "Update the list of read articles in GROUP."
8943 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8944 (entry (gnus-gethash group gnus-newsrc-hashtb))
8945 (info (nth 2 entry))
8947 (unread (sort (copy-sequence unread) '<))
8949 (if (or (not info) (not active))
8950 ;; There is no info on this group if it was, in fact,
8951 ;; killed. Gnus stores no information on killed groups, so
8952 ;; there's nothing to be done.
8953 ;; One could store the information somewhere temporarily,
8954 ;; perhaps... Hmmm...
8956 ;; Remove any negative articles numbers.
8957 (while (and unread (< (car unread) 0))
8958 (setq unread (cdr unread)))
8959 ;; Remove any expired article numbers
8960 (while (and unread (< (car unread) (car active)))
8961 (setq unread (cdr unread)))
8962 ;; Compute the ranges of read articles by looking at the list of
8965 (when (/= (car unread) prev)
8966 (push (if (= prev (1- (car unread))) prev
8967 (cons prev (1- (car unread))))
8969 (setq prev (1+ (car unread)))
8970 (setq unread (cdr unread)))
8971 (when (<= prev (cdr active))
8972 (push (cons prev (cdr active)) read))
8974 (if (> (length read) 1) (nreverse read) read)
8976 (set-buffer gnus-group-buffer)
8979 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8980 (gnus-info-set-read ',info ',(gnus-info-read info))
8981 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8982 (gnus-group-update-group ,group t))))
8983 ;; Enter this list into the group info.
8985 info (if (> (length read) 1) (nreverse read) read))
8986 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8987 (gnus-get-unread-articles-in-group info (gnus-active group))
8990 (defun gnus-offer-save-summaries ()
8991 "Offer to save all active summary buffers."
8993 (let ((buflist (buffer-list))
8995 ;; Go through all buffers and find all summaries.
8997 (and (setq bufname (buffer-name (car buflist)))
8998 (string-match "Summary" bufname)
9000 (set-buffer bufname)
9001 ;; We check that this is, indeed, a summary buffer.
9002 (and (eq major-mode 'gnus-summary-mode)
9003 ;; Also make sure this isn't bogus.
9004 gnus-newsgroup-prepared
9005 ;; Also make sure that this isn't a dead summary buffer.
9006 (not gnus-dead-summary-mode)))
9007 (push bufname buffers))
9008 (setq buflist (cdr buflist)))
9009 ;; Go through all these summary buffers and offer to save them.
9012 "Update summary buffer %s? "
9014 (switch-to-buffer buf)
9015 (gnus-summary-exit))
9019 ;;; @ for mime-partial
9022 (defun gnus-mime-partial-preview-function ()
9023 (gnus-summary-preview-mime-message (gnus-summary-article-number))
9026 (autoload 'mime-combine-message/partials-automatically
9028 "Internal method to combine message/partial messages automatically.")
9030 (set-atype 'mime-acting-condition
9031 '((type . "message/partial")
9032 (method . mime-combine-message/partials-automatically)
9033 (major-mode . gnus-original-article-mode)
9034 (summary-buffer-exp . gnus-summary-buffer)
9037 (set-alist 'mime-view-partial-message-method-alist
9038 'gnus-original-article-mode
9039 'gnus-mime-partial-preview-function)
9049 (run-hooks 'gnus-sum-load-hook)
9051 ;;; gnus-sum.el ends here