1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (autoload 'gnus-cache-write-active "gnus-cache")
42 (defcustom gnus-kill-summary-on-exit t
43 "*If non-nil, kill the summary buffer when you exit from it.
44 If nil, the summary will become a \"*Dead Summary*\" buffer, and
45 it will be killed sometime later."
46 :group 'gnus-summary-exit
49 (defcustom gnus-fetch-old-headers nil
50 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
51 If an unread article in the group refers to an older, already read (or
52 just marked as read) article, the old article will not normally be
53 displayed in the Summary buffer. If this variable is non-nil, Gnus
54 will attempt to grab the headers to the old articles, and thereby
55 build complete threads. If it has the value `some', only enough
56 headers to connect otherwise loose threads will be displayed. This
57 variable can also be a number. In that case, no more than that number
58 of old headers will be fetched. If it has the value `invisible', all
59 old headers will be fetched, but none will be displayed.
61 The server has to support NOV for any of this to work."
63 :type '(choice (const :tag "off" nil)
66 (sexp :menu-tag "other" t)))
68 (defcustom gnus-refer-thread-limit 200
69 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
70 If t, fetch all the available old headers."
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-summary-make-false-root 'adopt
76 "*nil means that Gnus won't gather loose threads.
77 If the root of a thread has expired or been read in a previous
78 session, the information necessary to build a complete thread has been
79 lost. Instead of having many small sub-threads from this original thread
80 scattered all over the summary buffer, Gnus can gather them.
82 If non-nil, Gnus will try to gather all loose sub-threads from an
83 original thread into one large thread.
85 If this variable is non-nil, it should be one of `none', `adopt',
88 If this variable is `none', Gnus will not make a false root, but just
89 present the sub-threads after another.
90 If this variable is `dummy', Gnus will create a dummy root that will
91 have all the sub-threads as children.
92 If this variable is `adopt', Gnus will make one of the \"children\"
93 the parent and mark all the step-children as such.
94 If this variable is `empty', the \"children\" are printed with empty
95 subject fields. (Or rather, they will be printed with a string
96 given by the `gnus-summary-same-subject' variable.)"
98 :type '(choice (const :tag "off" nil)
104 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
105 "*A regexp to match subjects to be excluded from loose thread gathering.
106 As loose thread gathering is done on subjects only, that means that
107 there can be many false gatherings performed. By rooting out certain
108 common subjects, gathering might become saner."
112 (defcustom gnus-summary-gather-subject-limit nil
113 "*Maximum length of subject comparisons when gathering loose threads.
114 Use nil to compare full subjects. Setting this variable to a low
115 number will help gather threads that have been corrupted by
116 newsreaders chopping off subject lines, but it might also mean that
117 unrelated articles that have subject that happen to begin with the
118 same few characters will be incorrectly gathered.
120 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
123 :type '(choice (const :tag "off" nil)
125 (sexp :menu-tag "on" t)))
127 (defcustom gnus-simplify-subject-functions nil
128 "List of functions taking a string argument that simplify subjects.
129 The functions are applied recursively.
131 Useful functions to put in this list include: `gnus-simplify-subject-re',
132 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
134 :type '(repeat function))
136 (defcustom gnus-simplify-ignored-prefixes nil
137 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
139 :type '(choice (const :tag "off" nil)
142 (defcustom gnus-build-sparse-threads nil
143 "*If non-nil, fill in the gaps in threads.
144 If `some', only fill in the gaps that are needed to tie loose threads
145 together. If `more', fill in all leaf nodes that Gnus can find. If
146 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
148 :type '(choice (const :tag "off" nil)
151 (sexp :menu-tag "all" t)))
153 (defcustom gnus-summary-thread-gathering-function
154 'gnus-gather-threads-by-subject
155 "*Function used for gathering loose threads.
156 There are two pre-defined functions: `gnus-gather-threads-by-subject',
157 which only takes Subjects into consideration; and
158 `gnus-gather-threads-by-references', which compared the References
159 headers of the articles to find matches."
161 :type '(radio (function-item gnus-gather-threads-by-subject)
162 (function-item gnus-gather-threads-by-references)
163 (function :tag "other")))
165 (defcustom gnus-summary-same-subject ""
166 "*String indicating that the current article has the same subject as the previous.
167 This variable will only be used if the value of
168 `gnus-summary-make-false-root' is `empty'."
169 :group 'gnus-summary-format
172 (defcustom gnus-summary-goto-unread t
173 "*If t, many commands will go to the next unread article.
174 This applies to marking commands as well as other commands that
175 \"naturally\" select the next article, like, for instance, `SPC' at
176 the end of an article.
178 If nil, the marking commands do NOT go to the next unread article
179 (they go to the next article instead). If `never', commands that
180 usually go to the next unread article, will go to the next article,
181 whether it is read or not."
182 :group 'gnus-summary-marks
183 :link '(custom-manual "(gnus)Setting Marks")
184 :type '(choice (const :tag "off" nil)
186 (sexp :menu-tag "on" t)))
188 (defcustom gnus-summary-default-score 0
189 "*Default article score level.
190 All scores generated by the score files will be added to this score.
191 If this variable is nil, scoring will be disabled."
192 :group 'gnus-score-default
193 :type '(choice (const :tag "disable")
196 (defcustom gnus-summary-zcore-fuzz 0
197 "*Fuzziness factor for the zcore in the summary buffer.
198 Articles with scores closer than this to `gnus-summary-default-score'
200 :group 'gnus-summary-format
203 (defcustom gnus-simplify-subject-fuzzy-regexp nil
204 "*Strings to be removed when doing fuzzy matches.
205 This can either be a regular expression or list of regular expressions
206 that will be removed from subject strings if fuzzy subject
207 simplification is selected."
209 :type '(repeat regexp))
211 (defcustom gnus-show-threads t
212 "*If non-nil, display threads in summary mode."
216 (defcustom gnus-thread-hide-subtree nil
217 "*If non-nil, hide all threads initially.
218 If threads are hidden, you have to run the command
219 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
220 to expose hidden threads."
224 (defcustom gnus-thread-hide-killed t
225 "*If non-nil, hide killed threads automatically."
229 (defcustom gnus-thread-ignore-subject t
230 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
231 If nil, articles that have different subjects from their parents will
232 start separate threads."
236 (defcustom gnus-thread-operation-ignore-subject t
237 "*If non-nil, subjects will be ignored when doing thread commands.
238 This affects commands like `gnus-summary-kill-thread' and
239 `gnus-summary-lower-thread'.
241 If this variable is nil, articles in the same thread with different
242 subjects will not be included in the operation in question. If this
243 variable is `fuzzy', only articles that have subjects that are fuzzily
244 equal will be included."
246 :type '(choice (const :tag "off" nil)
250 (defcustom gnus-thread-indent-level 4
251 "*Number that says how much each sub-thread should be indented."
255 (defcustom gnus-auto-extend-newsgroup t
256 "*If non-nil, extend newsgroup forward and backward when requested."
257 :group 'gnus-summary-choose
260 (defcustom gnus-auto-select-first t
261 "*If nil, don't select the first unread article when entering a group.
262 If this variable is `best', select the highest-scored unread article
263 in the group. If t, select the first unread article.
265 This variable can also be a function to place point on a likely
266 subject line. Useful values include `gnus-summary-first-unread-subject',
267 `gnus-summary-first-unread-article' and
268 `gnus-summary-best-unread-article'.
270 If you want to prevent automatic selection of the first unread article
271 in some newsgroups, set the variable to nil in
272 `gnus-select-group-hook'."
273 :group 'gnus-group-select
274 :type '(choice (const :tag "none" nil)
276 (sexp :menu-tag "first" t)
277 (function-item gnus-summary-first-unread-subject)
278 (function-item gnus-summary-first-unread-article)
279 (function-item gnus-summary-best-unread-article)))
281 (defcustom gnus-auto-select-next t
282 "*If non-nil, offer to go to the next group from the end of the previous.
283 If the value is t and the next newsgroup is empty, Gnus will exit
284 summary mode and go back to group mode. If the value is neither nil
285 nor t, Gnus will select the following unread newsgroup. In
286 particular, if the value is the symbol `quietly', the next unread
287 newsgroup will be selected without any confirmation, and if it is
288 `almost-quietly', the next group will be selected without any
289 confirmation if you are located on the last article in the group.
290 Finally, if this variable is `slightly-quietly', the `Z n' command
291 will go to the next group without confirmation."
292 :group 'gnus-summary-maneuvering
293 :type '(choice (const :tag "off" nil)
295 (const almost-quietly)
296 (const slightly-quietly)
297 (sexp :menu-tag "on" t)))
299 (defcustom gnus-auto-select-same nil
300 "*If non-nil, select the next article with the same subject.
301 If there are no more articles with the same subject, go to
302 the first unread article."
303 :group 'gnus-summary-maneuvering
306 (defcustom gnus-summary-check-current nil
307 "*If non-nil, consider the current article when moving.
308 The \"unread\" movement commands will stay on the same line if the
309 current article is unread."
310 :group 'gnus-summary-maneuvering
313 (defcustom gnus-auto-center-summary t
314 "*If non-nil, always center the current summary buffer.
315 In particular, if `vertical' do only vertical recentering. If non-nil
316 and non-`vertical', do both horizontal and vertical recentering."
317 :group 'gnus-summary-maneuvering
318 :type '(choice (const :tag "none" nil)
320 (integer :tag "height")
321 (sexp :menu-tag "both" t)))
323 (defcustom gnus-show-all-headers nil
324 "*If non-nil, don't hide any headers."
325 :group 'gnus-article-hiding
326 :group 'gnus-article-headers
329 (defcustom gnus-summary-ignore-duplicates nil
330 "*If non-nil, ignore articles with identical Message-ID headers."
334 (defcustom gnus-single-article-buffer t
335 "*If non-nil, display all articles in the same buffer.
336 If nil, each group will get its own article buffer."
337 :group 'gnus-article-various
340 (defcustom gnus-break-pages t
341 "*If non-nil, do page breaking on articles.
342 The page delimiter is specified by the `gnus-page-delimiter'
344 :group 'gnus-article-various
347 (defcustom gnus-move-split-methods nil
348 "*Variable used to suggest where articles are to be moved to.
349 It uses the same syntax as the `gnus-split-methods' variable."
350 :group 'gnus-summary-mail
351 :type '(repeat (choice (list :value (fun) function)
352 (cons :value ("" "") regexp (repeat string))
355 (defcustom gnus-unread-mark ? ;Whitespace
356 "*Mark used for unread articles."
357 :group 'gnus-summary-marks
360 (defcustom gnus-ticked-mark ?!
361 "*Mark used for ticked articles."
362 :group 'gnus-summary-marks
365 (defcustom gnus-dormant-mark ??
366 "*Mark used for dormant articles."
367 :group 'gnus-summary-marks
370 (defcustom gnus-del-mark ?r
371 "*Mark used for del'd articles."
372 :group 'gnus-summary-marks
375 (defcustom gnus-read-mark ?R
376 "*Mark used for read articles."
377 :group 'gnus-summary-marks
380 (defcustom gnus-expirable-mark ?E
381 "*Mark used for expirable articles."
382 :group 'gnus-summary-marks
385 (defcustom gnus-killed-mark ?K
386 "*Mark used for killed articles."
387 :group 'gnus-summary-marks
390 (defcustom gnus-souped-mark ?F
391 "*Mark used for killed articles."
392 :group 'gnus-summary-marks
395 (defcustom gnus-kill-file-mark ?X
396 "*Mark used for articles killed by kill files."
397 :group 'gnus-summary-marks
400 (defcustom gnus-low-score-mark ?Y
401 "*Mark used for articles with a low score."
402 :group 'gnus-summary-marks
405 (defcustom gnus-catchup-mark ?C
406 "*Mark used for articles that are caught up."
407 :group 'gnus-summary-marks
410 (defcustom gnus-replied-mark ?A
411 "*Mark used for articles that have been replied to."
412 :group 'gnus-summary-marks
415 (defcustom gnus-cached-mark ?*
416 "*Mark used for articles that are in the cache."
417 :group 'gnus-summary-marks
420 (defcustom gnus-saved-mark ?S
421 "*Mark used for articles that have been saved to."
422 :group 'gnus-summary-marks
425 (defcustom gnus-ancient-mark ?O
426 "*Mark used for ancient articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-sparse-mark ?Q
431 "*Mark used for sparsely reffed articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-canceled-mark ?G
436 "*Mark used for canceled articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-duplicate-mark ?M
441 "*Mark used for duplicate articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-undownloaded-mark ?@
446 "*Mark used for articles that weren't downloaded."
447 :group 'gnus-summary-marks
450 (defcustom gnus-downloadable-mark ?%
451 "*Mark used for articles that are to be downloaded."
452 :group 'gnus-summary-marks
455 (defcustom gnus-unsendable-mark ?=
456 "*Mark used for articles that won't be sent."
457 :group 'gnus-summary-marks
460 (defcustom gnus-score-over-mark ?+
461 "*Score mark used for articles with high scores."
462 :group 'gnus-summary-marks
465 (defcustom gnus-score-below-mark ?-
466 "*Score mark used for articles with low scores."
467 :group 'gnus-summary-marks
470 (defcustom gnus-empty-thread-mark ? ;Whitespace
471 "*There is no thread under the article."
472 :group 'gnus-summary-marks
475 (defcustom gnus-not-empty-thread-mark ?=
476 "*There is a thread under the article."
477 :group 'gnus-summary-marks
480 (defcustom gnus-view-pseudo-asynchronously nil
481 "*If non-nil, Gnus will view pseudo-articles asynchronously."
482 :group 'gnus-extract-view
485 (defcustom gnus-auto-expirable-marks
486 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
487 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
488 gnus-souped-mark gnus-duplicate-mark)
489 "*The list of marks converted into expiration if a group is auto-expirable."
491 :type '(repeat character))
493 (defcustom gnus-inhibit-user-auto-expire t
494 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
498 (defcustom gnus-view-pseudos nil
499 "*If `automatic', pseudo-articles will be viewed automatically.
500 If `not-confirm', pseudos will be viewed automatically, and the user
501 will not be asked to confirm the command."
502 :group 'gnus-extract-view
503 :type '(choice (const :tag "off" nil)
505 (const not-confirm)))
507 (defcustom gnus-view-pseudos-separately t
508 "*If non-nil, one pseudo-article will be created for each file to be viewed.
509 If nil, all files that use the same viewing command will be given as a
510 list of parameters to that command."
511 :group 'gnus-extract-view
514 (defcustom gnus-insert-pseudo-articles t
515 "*If non-nil, insert pseudo-articles when decoding articles."
516 :group 'gnus-extract-view
519 (defcustom gnus-summary-dummy-line-format
521 "*The format specification for the dummy roots in the summary buffer.
522 It works along the same lines as a normal formatting string,
523 with some simple extensions.
526 :group 'gnus-threading
529 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
530 "*The format specification for the summary mode line.
531 It works along the same lines as a normal formatting string,
532 with some simple extensions:
535 %p Unprefixed group name
536 %A Current article number
537 %z Current article score
539 %U Number of unread articles in the group
540 %e Number of unselected articles in the group
541 %Z A string with unread/unselected article counts
542 %g Shortish group name
543 %S Subject of the current article
545 %s Current score file name
546 %d Number of dormant articles
547 %r Number of articles that have been marked as read in this session
548 %E Number of articles expunged by the score files"
549 :group 'gnus-summary-format
552 (defcustom gnus-list-identifiers nil
553 "Regexp that matches list identifiers to be removed from subject.
554 This can also be a list of regexps."
555 :group 'gnus-summary-format
556 :group 'gnus-article-hiding
557 :type '(choice (const :tag "none" nil)
559 (repeat :value (".*") regexp)))
561 (defcustom gnus-summary-mark-below 0
562 "*Mark all articles with a score below this variable as read.
563 This variable is local to each summary buffer and usually set by the
565 :group 'gnus-score-default
568 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
569 "*List of functions used for sorting articles in the summary buffer.
570 This variable is only used when not using a threaded display."
571 :group 'gnus-summary-sort
572 :type '(repeat (choice (function-item gnus-article-sort-by-number)
573 (function-item gnus-article-sort-by-author)
574 (function-item gnus-article-sort-by-subject)
575 (function-item gnus-article-sort-by-date)
576 (function-item gnus-article-sort-by-score)
577 (function :tag "other"))))
579 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
580 "*List of functions used for sorting threads in the summary buffer.
581 By default, threads are sorted by article number.
583 Each function takes two threads and return non-nil if the first thread
584 should be sorted before the other. If you use more than one function,
585 the primary sort function should be the last. You should probably
586 always include `gnus-thread-sort-by-number' in the list of sorting
587 functions -- preferably first.
589 Ready-made functions include `gnus-thread-sort-by-number',
590 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
591 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
592 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
593 :group 'gnus-summary-sort
594 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
595 (function-item gnus-thread-sort-by-author)
596 (function-item gnus-thread-sort-by-subject)
597 (function-item gnus-thread-sort-by-date)
598 (function-item gnus-thread-sort-by-score)
599 (function-item gnus-thread-sort-by-total-score)
600 (function :tag "other"))))
602 (defcustom gnus-thread-score-function '+
603 "*Function used for calculating the total score of a thread.
605 The function is called with the scores of the article and each
606 subthread and should then return the score of the thread.
608 Some functions you can use are `+', `max', or `min'."
609 :group 'gnus-summary-sort
612 (defcustom gnus-summary-expunge-below nil
613 "All articles that have a score less than this variable will be expunged.
614 This variable is local to the summary buffers."
615 :group 'gnus-score-default
616 :type '(choice (const :tag "off" nil)
619 (defcustom gnus-thread-expunge-below nil
620 "All threads that have a total score less than this variable will be expunged.
621 See `gnus-thread-score-function' for en explanation of what a
624 This variable is local to the summary buffers."
625 :group 'gnus-threading
626 :group 'gnus-score-default
627 :type '(choice (const :tag "off" nil)
630 (defcustom gnus-summary-mode-hook nil
631 "*A hook for Gnus summary mode.
632 This hook is run before any variables are set in the summary buffer."
633 :group 'gnus-summary-various
636 (defcustom gnus-summary-menu-hook nil
637 "*Hook run after the creation of the summary mode menu."
638 :group 'gnus-summary-visual
641 (defcustom gnus-summary-exit-hook nil
642 "*A hook called on exit from the summary buffer.
643 It will be called with point in the group buffer."
644 :group 'gnus-summary-exit
647 (defcustom gnus-summary-prepare-hook nil
648 "*A hook called after the summary buffer has been generated.
649 If you want to modify the summary buffer, you can use this hook."
650 :group 'gnus-summary-various
653 (defcustom gnus-summary-prepared-hook nil
654 "*A hook called as the last thing after the summary buffer has been generated."
655 :group 'gnus-summary-various
658 (defcustom gnus-summary-generate-hook nil
659 "*A hook run just before generating the summary buffer.
660 This hook is commonly used to customize threading variables and the
662 :group 'gnus-summary-various
665 (defcustom gnus-select-group-hook nil
666 "*A hook called when a newsgroup is selected.
668 If you'd like to simplify subjects like the
669 `gnus-summary-next-same-subject' command does, you can use the
672 (setq gnus-select-group-hook
675 (mapcar (lambda (header)
676 (mail-header-set-subject
678 (gnus-simplify-subject
679 (mail-header-subject header) 're-only)))
680 gnus-newsgroup-headers))))"
681 :group 'gnus-group-select
684 (defcustom gnus-select-article-hook nil
685 "*A hook called when an article is selected."
686 :group 'gnus-summary-choose
689 (defcustom gnus-visual-mark-article-hook
690 (list 'gnus-highlight-selected-summary)
691 "*Hook run after selecting an article in the summary buffer.
692 It is meant to be used for highlighting the article in some way. It
693 is not run if `gnus-visual' is nil."
694 :group 'gnus-summary-visual
697 (defcustom gnus-parse-headers-hook nil
698 "*A hook called before parsing the headers."
702 (defcustom gnus-exit-group-hook nil
703 "*A hook called when exiting summary mode.
704 This hook is not called from the non-updating exit commands like `Q'."
708 (defcustom gnus-summary-update-hook
709 (list 'gnus-summary-highlight-line)
710 "*A hook called when a summary line is changed.
711 The hook will not be called if `gnus-visual' is nil.
713 The default function `gnus-summary-highlight-line' will
714 highlight the line according to the `gnus-summary-highlight'
716 :group 'gnus-summary-visual
719 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
720 "*A hook called when an article is selected for the first time.
721 The hook is intended to mark an article as read (or unread)
722 automatically when it is selected."
723 :group 'gnus-summary-choose
726 (defcustom gnus-group-no-more-groups-hook nil
727 "*A hook run when returning to group mode having no more (unread) groups."
728 :group 'gnus-group-select
731 (defcustom gnus-ps-print-hook nil
732 "*A hook run before ps-printing something from Gnus."
736 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
737 "Face used for highlighting the current article in the summary buffer."
738 :group 'gnus-summary-visual
741 (defcustom gnus-summary-highlight
742 '(((= mark gnus-canceled-mark)
743 . gnus-summary-cancelled-face)
744 ((and (> score default)
745 (or (= mark gnus-dormant-mark)
746 (= mark gnus-ticked-mark)))
747 . gnus-summary-high-ticked-face)
748 ((and (< score default)
749 (or (= mark gnus-dormant-mark)
750 (= mark gnus-ticked-mark)))
751 . gnus-summary-low-ticked-face)
752 ((or (= mark gnus-dormant-mark)
753 (= mark gnus-ticked-mark))
754 . gnus-summary-normal-ticked-face)
755 ((and (> score default) (= mark gnus-ancient-mark))
756 . gnus-summary-high-ancient-face)
757 ((and (< score default) (= mark gnus-ancient-mark))
758 . gnus-summary-low-ancient-face)
759 ((= mark gnus-ancient-mark)
760 . gnus-summary-normal-ancient-face)
761 ((and (> score default) (= mark gnus-unread-mark))
762 . gnus-summary-high-unread-face)
763 ((and (< score default) (= mark gnus-unread-mark))
764 . gnus-summary-low-unread-face)
765 ((= mark gnus-unread-mark)
766 . gnus-summary-normal-unread-face)
767 ((and (> score default) (memq mark (list gnus-downloadable-mark
768 gnus-undownloaded-mark)))
769 . gnus-summary-high-unread-face)
770 ((and (< score default) (memq mark (list gnus-downloadable-mark
771 gnus-undownloaded-mark)))
772 . gnus-summary-low-unread-face)
773 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
774 . gnus-summary-normal-unread-face)
776 . gnus-summary-high-read-face)
778 . gnus-summary-low-read-face)
780 . gnus-summary-normal-read-face))
781 "*Controls the highlighting of summary buffer lines.
783 A list of (FORM . FACE) pairs. When deciding how a a particular
784 summary line should be displayed, each form is evaluated. The content
785 of the face field after the first true form is used. You can change
786 how those summary lines are displayed, by editing the face field.
788 You can use the following variables in the FORM field.
790 score: The articles score
791 default: The default article score.
792 below: The score below which articles are automatically marked as read.
793 mark: The articles mark."
794 :group 'gnus-summary-visual
795 :type '(repeat (cons (sexp :tag "Form" nil)
798 (defcustom gnus-alter-header-function nil
799 "Function called to allow alteration of article header structures.
800 The function is called with one parameter, the article header vector,
801 which it may alter in any way.")
803 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
804 "Variable that says which function should be used to decode a string with encoded words.")
806 (defcustom gnus-extra-headers nil
807 "*Extra headers to parse."
809 :type '(repeat symbol))
811 (defcustom gnus-ignored-from-addresses
812 (and user-mail-address (regexp-quote user-mail-address))
813 "*Regexp of From headers that may be suppressed in favor of To headers."
817 (defcustom gnus-group-charset-alist
818 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
819 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
820 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
821 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
822 ("^relcom\\>" koi8-r)
824 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
825 ("^israel\\>" iso-8859-1)
827 ("^alt.chinese.text.big5\\>" chinese-big5)
828 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
829 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
831 "Alist of regexps (to match group names) and default charsets to be used when reading."
832 :type '(repeat (list (regexp :tag "Group")
833 (symbol :tag "Charset")))
834 :group 'gnus-charset)
836 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
837 "List of charsets that should be ignored.
838 When these charsets are used in the \"charset\" parameter, the
839 default charset will be used instead."
840 :type '(repeat symbol)
841 :group 'gnus-charset)
843 (defcustom gnus-group-ignored-charsets-alist
844 '(("alt\\.chinese\\.text" iso-8859-1))
845 "Alist of regexps (to match group names) and charsets that should be ignored.
846 When these charsets are used in the \"charset\" parameter, the
847 default charset will be used instead."
848 :type '(repeat (cons (regexp :tag "Group")
850 :group 'gnus-charset)
852 (defcustom gnus-group-highlight-words-alist nil
853 "Alist of group regexps and highlight regexps.
854 This variable uses the same syntax as `gnus-emphasis-alist'."
855 :type '(repeat (cons (regexp :tag "Group")
856 (repeat (list (regexp :tag "Highlight regexp")
857 (number :tag "Group for entire word" 0)
858 (number :tag "Group for displayed part" 0)
860 gnus-emphasis-highlight-words)))))
861 :group 'gnus-summary-visual)
863 (defcustom gnus-summary-show-article-charset-alist
865 "Alist of number and charset.
866 The article will be shown with the charset corresponding to the
868 For example: ((1 . cn-gb-2312) (2 . big5))."
869 :type '(repeat (cons (number :tag "Argument" 1)
870 (symbol :tag "Charset")))
871 :group 'gnus-charset)
873 (defcustom gnus-preserve-marks t
874 "Whether marks are preserved when moving, copying and respooling messages."
876 :group 'gnus-summary-marks)
878 (defcustom gnus-alter-articles-to-read-function nil
879 "Function to be called to alter the list of articles to be selected."
881 :group 'gnus-summary)
883 (defcustom gnus-orphan-score nil
884 "*All orphans get this score added. Set in the score file."
885 :group 'gnus-score-default
886 :type '(choice (const nil)
889 (defcustom gnus-summary-save-parts-default-mime "image/.*"
890 "*A regexp to match MIME parts when saving multiple parts of a message
891 with gnus-summary-save-parts (X m). This regexp will be used by default
892 when prompting the user for which type of files to save."
897 ;;; Internal variables
899 (defvar gnus-article-mime-handles nil)
900 (defvar gnus-article-decoded-p nil)
901 (defvar gnus-scores-exclude-files nil)
902 (defvar gnus-page-broken nil)
903 (defvar gnus-inhibit-mime-unbuttonizing nil)
905 (defvar gnus-original-article nil)
906 (defvar gnus-article-internal-prepare-hook nil)
907 (defvar gnus-newsgroup-process-stack nil)
909 (defvar gnus-thread-indent-array nil)
910 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
911 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
912 "Function called to sort the articles within a thread after it has been gathered together.")
914 (defvar gnus-summary-save-parts-type-history nil)
915 (defvar gnus-summary-save-parts-last-directory nil)
917 ;; Avoid highlighting in kill files.
918 (defvar gnus-summary-inhibit-highlight nil)
919 (defvar gnus-newsgroup-selected-overlay nil)
920 (defvar gnus-inhibit-limiting nil)
921 (defvar gnus-newsgroup-adaptive-score-file nil)
922 (defvar gnus-current-score-file nil)
923 (defvar gnus-current-move-group nil)
924 (defvar gnus-current-copy-group nil)
925 (defvar gnus-current-crosspost-group nil)
927 (defvar gnus-newsgroup-dependencies nil)
928 (defvar gnus-newsgroup-adaptive nil)
929 (defvar gnus-summary-display-article-function nil)
930 (defvar gnus-summary-highlight-line-function nil
931 "Function called after highlighting a summary line.")
933 (defvar gnus-summary-line-format-alist
934 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
935 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
936 (?s gnus-tmp-subject-or-nil ?s)
937 (?n gnus-tmp-name ?s)
938 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
940 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
942 (?F gnus-tmp-from ?s)
943 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
944 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
945 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
946 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
947 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
948 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
949 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
950 (?L gnus-tmp-lines ?d)
951 (?I gnus-tmp-indentation ?s)
952 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
953 (?R gnus-tmp-replied ?c)
954 (?\[ gnus-tmp-opening-bracket ?c)
955 (?\] gnus-tmp-closing-bracket ?c)
956 (?\> (make-string gnus-tmp-level ? ) ?s)
957 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
958 (?i gnus-tmp-score ?d)
959 (?z gnus-tmp-score-char ?c)
960 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
961 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
962 (?U gnus-tmp-unread ?c)
963 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
964 (?t (gnus-summary-number-of-articles-in-thread
965 (and (boundp 'thread) (car thread)) gnus-tmp-level)
967 (?e (gnus-summary-number-of-articles-in-thread
968 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
970 (?u gnus-tmp-user-defined ?s)
971 (?P (gnus-pick-line-number) ?d))
972 "An alist of format specifications that can appear in summary lines.
973 These are paired with what variables they correspond with, along with
974 the type of the variable (string, integer, character, etc).")
976 (defvar gnus-summary-dummy-line-format-alist
977 `((?S gnus-tmp-subject ?s)
978 (?N gnus-tmp-number ?d)
979 (?u gnus-tmp-user-defined ?s)))
981 (defvar gnus-summary-mode-line-format-alist
982 `((?G gnus-tmp-group-name ?s)
983 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
984 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
985 (?A gnus-tmp-article-number ?d)
986 (?Z gnus-tmp-unread-and-unselected ?s)
988 (?U gnus-tmp-unread-and-unticked ?d)
989 (?S gnus-tmp-subject ?s)
990 (?e gnus-tmp-unselected ?d)
991 (?u gnus-tmp-user-defined ?s)
992 (?d (length gnus-newsgroup-dormant) ?d)
993 (?t (length gnus-newsgroup-marked) ?d)
994 (?r (length gnus-newsgroup-reads) ?d)
995 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
996 (?E gnus-newsgroup-expunged-tally ?d)
997 (?s (gnus-current-score-file-nondirectory) ?s)))
999 (defvar gnus-last-search-regexp nil
1000 "Default regexp for article search command.")
1002 (defvar gnus-last-shell-command nil
1003 "Default shell command on article.")
1005 (defvar gnus-newsgroup-begin nil)
1006 (defvar gnus-newsgroup-end nil)
1007 (defvar gnus-newsgroup-last-rmail nil)
1008 (defvar gnus-newsgroup-last-mail nil)
1009 (defvar gnus-newsgroup-last-folder nil)
1010 (defvar gnus-newsgroup-last-file nil)
1011 (defvar gnus-newsgroup-auto-expire nil)
1012 (defvar gnus-newsgroup-active nil)
1014 (defvar gnus-newsgroup-data nil)
1015 (defvar gnus-newsgroup-data-reverse nil)
1016 (defvar gnus-newsgroup-limit nil)
1017 (defvar gnus-newsgroup-limits nil)
1019 (defvar gnus-newsgroup-unreads nil
1020 "List of unread articles in the current newsgroup.")
1022 (defvar gnus-newsgroup-unselected nil
1023 "List of unselected unread articles in the current newsgroup.")
1025 (defvar gnus-newsgroup-reads nil
1026 "Alist of read articles and article marks in the current newsgroup.")
1028 (defvar gnus-newsgroup-expunged-tally nil)
1030 (defvar gnus-newsgroup-marked nil
1031 "List of ticked articles in the current newsgroup (a subset of unread art).")
1033 (defvar gnus-newsgroup-killed nil
1034 "List of ranges of articles that have been through the scoring process.")
1036 (defvar gnus-newsgroup-cached nil
1037 "List of articles that come from the article cache.")
1039 (defvar gnus-newsgroup-saved nil
1040 "List of articles that have been saved.")
1042 (defvar gnus-newsgroup-kill-headers nil)
1044 (defvar gnus-newsgroup-replied nil
1045 "List of articles that have been replied to in the current newsgroup.")
1047 (defvar gnus-newsgroup-expirable nil
1048 "List of articles in the current newsgroup that can be expired.")
1050 (defvar gnus-newsgroup-processable nil
1051 "List of articles in the current newsgroup that can be processed.")
1053 (defvar gnus-newsgroup-downloadable nil
1054 "List of articles in the current newsgroup that can be processed.")
1056 (defvar gnus-newsgroup-undownloaded nil
1057 "List of articles in the current newsgroup that haven't been downloaded..")
1059 (defvar gnus-newsgroup-unsendable nil
1060 "List of articles in the current newsgroup that won't be sent.")
1062 (defvar gnus-newsgroup-bookmarks nil
1063 "List of articles in the current newsgroup that have bookmarks.")
1065 (defvar gnus-newsgroup-dormant nil
1066 "List of dormant articles in the current newsgroup.")
1068 (defvar gnus-newsgroup-scored nil
1069 "List of scored articles in the current newsgroup.")
1071 (defvar gnus-newsgroup-headers nil
1072 "List of article headers in the current newsgroup.")
1074 (defvar gnus-newsgroup-threads nil)
1076 (defvar gnus-newsgroup-prepared nil
1077 "Whether the current group has been prepared properly.")
1079 (defvar gnus-newsgroup-ancient nil
1080 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1082 (defvar gnus-newsgroup-sparse nil)
1084 (defvar gnus-current-article nil)
1085 (defvar gnus-article-current nil)
1086 (defvar gnus-current-headers nil)
1087 (defvar gnus-have-all-headers nil)
1088 (defvar gnus-last-article nil)
1089 (defvar gnus-newsgroup-history nil)
1090 (defvar gnus-newsgroup-charset nil)
1091 (defvar gnus-newsgroup-ephemeral-charset nil)
1092 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1094 (defconst gnus-summary-local-variables
1095 '(gnus-newsgroup-name
1096 gnus-newsgroup-begin gnus-newsgroup-end
1097 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1098 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1099 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1100 gnus-newsgroup-unselected gnus-newsgroup-marked
1101 gnus-newsgroup-reads gnus-newsgroup-saved
1102 gnus-newsgroup-replied gnus-newsgroup-expirable
1103 gnus-newsgroup-processable gnus-newsgroup-killed
1104 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1105 gnus-newsgroup-unsendable
1106 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1107 gnus-newsgroup-headers gnus-newsgroup-threads
1108 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1109 gnus-current-article gnus-current-headers gnus-have-all-headers
1110 gnus-last-article gnus-article-internal-prepare-hook
1111 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1112 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1113 gnus-thread-expunge-below
1114 gnus-score-alist gnus-current-score-file
1115 (gnus-summary-expunge-below . global)
1116 (gnus-summary-mark-below . global)
1117 (gnus-orphan-score . global)
1118 gnus-newsgroup-active gnus-scores-exclude-files
1119 gnus-newsgroup-history gnus-newsgroup-ancient
1120 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1121 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1122 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1123 (gnus-newsgroup-expunged-tally . 0)
1124 gnus-cache-removable-articles gnus-newsgroup-cached
1125 gnus-newsgroup-data gnus-newsgroup-data-reverse
1126 gnus-newsgroup-limit gnus-newsgroup-limits
1127 gnus-newsgroup-charset)
1128 "Variables that are buffer-local to the summary buffers.")
1130 ;; Byte-compiler warning.
1131 (defvar gnus-article-mode-map)
1135 (defvar gnus-decode-encoded-word-methods
1136 '(mail-decode-encoded-word-string)
1137 "List of methods used to decode encoded words.
1139 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1140 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1141 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1142 whose names match REGEXP.
1145 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1146 mail-decode-encoded-word-string
1147 (\"chinese\" . rfc1843-decode-string))")
1149 (defvar gnus-decode-encoded-word-methods-cache nil)
1151 (defun gnus-multi-decode-encoded-word-string (string)
1152 "Apply the functions from `gnus-encoded-word-methods' that match."
1153 (unless (and gnus-decode-encoded-word-methods-cache
1154 (eq gnus-newsgroup-name
1155 (car gnus-decode-encoded-word-methods-cache)))
1156 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1159 (nconc gnus-decode-encoded-word-methods-cache (list x))
1160 (if (and gnus-newsgroup-name
1161 (string-match (car x) gnus-newsgroup-name))
1162 (nconc gnus-decode-encoded-word-methods-cache
1164 gnus-decode-encoded-word-methods))
1165 (let ((xlist gnus-decode-encoded-word-methods-cache))
1168 (setq string (funcall (pop xlist) string))))
1171 ;; Subject simplification.
1173 (defun gnus-simplify-whitespace (str)
1174 "Remove excessive whitespace from STR."
1177 (while (string-match "[ \t][ \t]+" mystr)
1178 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1180 (substring mystr (match-end 0)))))
1182 (when (string-match "^[ \t]+" mystr)
1183 (setq mystr (substring mystr (match-end 0))))
1185 (when (string-match "[ \t]+$" mystr)
1186 (setq mystr (substring mystr 0 (match-beginning 0))))
1189 (defsubst gnus-simplify-subject-re (subject)
1190 "Remove \"Re:\" from subject lines."
1191 (if (string-match "^[Rr][Ee]: *" subject)
1192 (substring subject (match-end 0))
1195 (defun gnus-simplify-subject (subject &optional re-only)
1196 "Remove `Re:' and words in parentheses.
1197 If RE-ONLY is non-nil, strip leading `Re:'s only."
1198 (let ((case-fold-search t)) ;Ignore case.
1199 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1200 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1201 (setq subject (substring subject (match-end 0))))
1202 ;; Remove uninteresting prefixes.
1203 (when (and (not re-only)
1204 gnus-simplify-ignored-prefixes
1205 (string-match gnus-simplify-ignored-prefixes subject))
1206 (setq subject (substring subject (match-end 0))))
1207 ;; Remove words in parentheses from end.
1209 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1210 (setq subject (substring subject 0 (match-beginning 0)))))
1211 ;; Return subject string.
1214 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1216 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1217 (goto-char (point-min))
1218 (while (re-search-forward regexp nil t)
1219 (replace-match (or newtext ""))))
1221 (defun gnus-simplify-buffer-fuzzy ()
1222 "Simplify string in the buffer fuzzily.
1223 The string in the accessible portion of the current buffer is simplified.
1224 It is assumed to be a single-line subject.
1225 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1226 matter is removed. Additional things can be deleted by setting
1227 `gnus-simplify-subject-fuzzy-regexp'."
1228 (let ((case-fold-search t)
1230 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1232 (while (not (eq modified-tick (buffer-modified-tick)))
1233 (setq modified-tick (buffer-modified-tick))
1235 ((listp gnus-simplify-subject-fuzzy-regexp)
1236 (mapcar 'gnus-simplify-buffer-fuzzy-step
1237 gnus-simplify-subject-fuzzy-regexp))
1238 (gnus-simplify-subject-fuzzy-regexp
1239 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1240 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1241 (gnus-simplify-buffer-fuzzy-step
1242 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1243 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1245 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1246 (gnus-simplify-buffer-fuzzy-step " +" " ")
1247 (gnus-simplify-buffer-fuzzy-step " $")
1248 (gnus-simplify-buffer-fuzzy-step "^ +")))
1250 (defun gnus-simplify-subject-fuzzy (subject)
1251 "Simplify a subject string fuzzily.
1252 See `gnus-simplify-buffer-fuzzy' for details."
1254 (gnus-set-work-buffer)
1255 (let ((case-fold-search t))
1256 ;; Remove uninteresting prefixes.
1257 (when (and gnus-simplify-ignored-prefixes
1258 (string-match gnus-simplify-ignored-prefixes subject))
1259 (setq subject (substring subject (match-end 0))))
1261 (inline (gnus-simplify-buffer-fuzzy))
1264 (defsubst gnus-simplify-subject-fully (subject)
1265 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1267 (gnus-simplify-subject-functions
1268 (gnus-map-function gnus-simplify-subject-functions subject))
1269 ((null gnus-summary-gather-subject-limit)
1270 (gnus-simplify-subject-re subject))
1271 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1272 (gnus-simplify-subject-fuzzy subject))
1273 ((numberp gnus-summary-gather-subject-limit)
1274 (gnus-limit-string (gnus-simplify-subject-re subject)
1275 gnus-summary-gather-subject-limit))
1279 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1280 "Check whether two subjects are equal.
1281 If optional argument simple-first is t, first argument is already
1284 ((null simple-first)
1285 (equal (gnus-simplify-subject-fully s1)
1286 (gnus-simplify-subject-fully s2)))
1289 (gnus-simplify-subject-fully s2)))))
1291 (defun gnus-summary-bubble-group ()
1292 "Increase the score of the current group.
1293 This is a handy function to add to `gnus-summary-exit-hook' to
1294 increase the score of each group you read."
1295 (gnus-group-add-score gnus-newsgroup-name))
1299 ;;; Gnus summary mode
1302 (put 'gnus-summary-mode 'mode-class 'special)
1305 ;; Non-orthogonal keys
1307 (gnus-define-keys gnus-summary-mode-map
1308 " " gnus-summary-next-page
1309 "\177" gnus-summary-prev-page
1310 [delete] gnus-summary-prev-page
1311 [backspace] gnus-summary-prev-page
1312 "\r" gnus-summary-scroll-up
1313 "\M-\r" gnus-summary-scroll-down
1314 "n" gnus-summary-next-unread-article
1315 "p" gnus-summary-prev-unread-article
1316 "N" gnus-summary-next-article
1317 "P" gnus-summary-prev-article
1318 "\M-\C-n" gnus-summary-next-same-subject
1319 "\M-\C-p" gnus-summary-prev-same-subject
1320 "\M-n" gnus-summary-next-unread-subject
1321 "\M-p" gnus-summary-prev-unread-subject
1322 "." gnus-summary-first-unread-article
1323 "," gnus-summary-best-unread-article
1324 "\M-s" gnus-summary-search-article-forward
1325 "\M-r" gnus-summary-search-article-backward
1326 "<" gnus-summary-beginning-of-article
1327 ">" gnus-summary-end-of-article
1328 "j" gnus-summary-goto-article
1329 "^" gnus-summary-refer-parent-article
1330 "\M-^" gnus-summary-refer-article
1331 "u" gnus-summary-tick-article-forward
1332 "!" gnus-summary-tick-article-forward
1333 "U" gnus-summary-tick-article-backward
1334 "d" gnus-summary-mark-as-read-forward
1335 "D" gnus-summary-mark-as-read-backward
1336 "E" gnus-summary-mark-as-expirable
1337 "\M-u" gnus-summary-clear-mark-forward
1338 "\M-U" gnus-summary-clear-mark-backward
1339 "k" gnus-summary-kill-same-subject-and-select
1340 "\C-k" gnus-summary-kill-same-subject
1341 "\M-\C-k" gnus-summary-kill-thread
1342 "\M-\C-l" gnus-summary-lower-thread
1343 "e" gnus-summary-edit-article
1344 "#" gnus-summary-mark-as-processable
1345 "\M-#" gnus-summary-unmark-as-processable
1346 "\M-\C-t" gnus-summary-toggle-threads
1347 "\M-\C-s" gnus-summary-show-thread
1348 "\M-\C-h" gnus-summary-hide-thread
1349 "\M-\C-f" gnus-summary-next-thread
1350 "\M-\C-b" gnus-summary-prev-thread
1351 [(meta down)] gnus-summary-next-thread
1352 [(meta up)] gnus-summary-prev-thread
1353 "\M-\C-u" gnus-summary-up-thread
1354 "\M-\C-d" gnus-summary-down-thread
1355 "&" gnus-summary-execute-command
1356 "c" gnus-summary-catchup-and-exit
1357 "\C-w" gnus-summary-mark-region-as-read
1358 "\C-t" gnus-summary-toggle-truncation
1359 "?" gnus-summary-mark-as-dormant
1360 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1361 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1362 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1363 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1364 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1365 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1366 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1367 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1368 "=" gnus-summary-expand-window
1369 "\C-x\C-s" gnus-summary-reselect-current-group
1370 "\M-g" gnus-summary-rescan-group
1371 "w" gnus-summary-stop-page-breaking
1372 "\C-c\C-r" gnus-summary-caesar-message
1373 "f" gnus-summary-followup
1374 "F" gnus-summary-followup-with-original
1375 "C" gnus-summary-cancel-article
1376 "r" gnus-summary-reply
1377 "R" gnus-summary-reply-with-original
1378 "\C-c\C-f" gnus-summary-mail-forward
1379 "o" gnus-summary-save-article
1380 "\C-o" gnus-summary-save-article-mail
1381 "|" gnus-summary-pipe-output
1382 "\M-k" gnus-summary-edit-local-kill
1383 "\M-K" gnus-summary-edit-global-kill
1385 "\C-c\C-d" gnus-summary-describe-group
1386 "q" gnus-summary-exit
1387 "Q" gnus-summary-exit-no-update
1388 "\C-c\C-i" gnus-info-find-node
1389 gnus-mouse-2 gnus-mouse-pick-article
1390 "m" gnus-summary-mail-other-window
1391 "a" gnus-summary-post-news
1392 "x" gnus-summary-limit-to-unread
1393 "s" gnus-summary-isearch-article
1394 "t" gnus-summary-toggle-header
1395 "g" gnus-summary-show-article
1396 "l" gnus-summary-goto-last-article
1397 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1398 "\C-d" gnus-summary-enter-digest-group
1399 "\M-\C-d" gnus-summary-read-document
1400 "\M-\C-e" gnus-summary-edit-parameters
1401 "\M-\C-a" gnus-summary-customize-parameters
1403 "*" gnus-cache-enter-article
1404 "\M-*" gnus-cache-remove-article
1405 "\M-&" gnus-summary-universal-argument
1406 "\C-l" gnus-recenter
1407 "I" gnus-summary-increase-score
1408 "L" gnus-summary-lower-score
1409 "\M-i" gnus-symbolic-argument
1410 "h" gnus-summary-select-article-buffer
1412 "b" gnus-article-view-part
1413 "\M-t" gnus-summary-toggle-display-buttonized
1415 "V" gnus-summary-score-map
1416 "X" gnus-uu-extract-map
1417 "S" gnus-summary-send-map)
1419 ;; Sort of orthogonal keymap
1420 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1421 "t" gnus-summary-tick-article-forward
1422 "!" gnus-summary-tick-article-forward
1423 "d" gnus-summary-mark-as-read-forward
1424 "r" gnus-summary-mark-as-read-forward
1425 "c" gnus-summary-clear-mark-forward
1426 " " gnus-summary-clear-mark-forward
1427 "e" gnus-summary-mark-as-expirable
1428 "x" gnus-summary-mark-as-expirable
1429 "?" gnus-summary-mark-as-dormant
1430 "b" gnus-summary-set-bookmark
1431 "B" gnus-summary-remove-bookmark
1432 "#" gnus-summary-mark-as-processable
1433 "\M-#" gnus-summary-unmark-as-processable
1434 "S" gnus-summary-limit-include-expunged
1435 "C" gnus-summary-catchup
1436 "H" gnus-summary-catchup-to-here
1437 "\C-c" gnus-summary-catchup-all
1438 "k" gnus-summary-kill-same-subject-and-select
1439 "K" gnus-summary-kill-same-subject
1440 "P" gnus-uu-mark-map)
1442 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1443 "c" gnus-summary-clear-above
1444 "u" gnus-summary-tick-above
1445 "m" gnus-summary-mark-above
1446 "k" gnus-summary-kill-below)
1448 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1449 "/" gnus-summary-limit-to-subject
1450 "n" gnus-summary-limit-to-articles
1451 "w" gnus-summary-pop-limit
1452 "s" gnus-summary-limit-to-subject
1453 "a" gnus-summary-limit-to-author
1454 "u" gnus-summary-limit-to-unread
1455 "m" gnus-summary-limit-to-marks
1456 "M" gnus-summary-limit-exclude-marks
1457 "v" gnus-summary-limit-to-score
1458 "*" gnus-summary-limit-include-cached
1459 "D" gnus-summary-limit-include-dormant
1460 "T" gnus-summary-limit-include-thread
1461 "d" gnus-summary-limit-exclude-dormant
1462 "t" gnus-summary-limit-to-age
1463 "x" gnus-summary-limit-to-extra
1464 "E" gnus-summary-limit-include-expunged
1465 "c" gnus-summary-limit-exclude-childless-dormant
1466 "C" gnus-summary-limit-mark-excluded-as-read)
1468 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1469 "n" gnus-summary-next-unread-article
1470 "p" gnus-summary-prev-unread-article
1471 "N" gnus-summary-next-article
1472 "P" gnus-summary-prev-article
1473 "\C-n" gnus-summary-next-same-subject
1474 "\C-p" gnus-summary-prev-same-subject
1475 "\M-n" gnus-summary-next-unread-subject
1476 "\M-p" gnus-summary-prev-unread-subject
1477 "f" gnus-summary-first-unread-article
1478 "b" gnus-summary-best-unread-article
1479 "j" gnus-summary-goto-article
1480 "g" gnus-summary-goto-subject
1481 "l" gnus-summary-goto-last-article
1482 "o" gnus-summary-pop-article)
1484 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1485 "k" gnus-summary-kill-thread
1486 "l" gnus-summary-lower-thread
1487 "i" gnus-summary-raise-thread
1488 "T" gnus-summary-toggle-threads
1489 "t" gnus-summary-rethread-current
1490 "^" gnus-summary-reparent-thread
1491 "s" gnus-summary-show-thread
1492 "S" gnus-summary-show-all-threads
1493 "h" gnus-summary-hide-thread
1494 "H" gnus-summary-hide-all-threads
1495 "n" gnus-summary-next-thread
1496 "p" gnus-summary-prev-thread
1497 "u" gnus-summary-up-thread
1498 "o" gnus-summary-top-thread
1499 "d" gnus-summary-down-thread
1500 "#" gnus-uu-mark-thread
1501 "\M-#" gnus-uu-unmark-thread)
1503 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1504 "g" gnus-summary-prepare
1505 "c" gnus-summary-insert-cached-articles)
1507 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1508 "c" gnus-summary-catchup-and-exit
1509 "C" gnus-summary-catchup-all-and-exit
1510 "E" gnus-summary-exit-no-update
1511 "Q" gnus-summary-exit
1512 "Z" gnus-summary-exit
1513 "n" gnus-summary-catchup-and-goto-next-group
1514 "R" gnus-summary-reselect-current-group
1515 "G" gnus-summary-rescan-group
1516 "N" gnus-summary-next-group
1517 "s" gnus-summary-save-newsrc
1518 "P" gnus-summary-prev-group)
1520 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1521 " " gnus-summary-next-page
1522 "n" gnus-summary-next-page
1523 "\177" gnus-summary-prev-page
1524 [delete] gnus-summary-prev-page
1525 "p" gnus-summary-prev-page
1526 "\r" gnus-summary-scroll-up
1527 "\M-\r" gnus-summary-scroll-down
1528 "<" gnus-summary-beginning-of-article
1529 ">" gnus-summary-end-of-article
1530 "b" gnus-summary-beginning-of-article
1531 "e" gnus-summary-end-of-article
1532 "^" gnus-summary-refer-parent-article
1533 "r" gnus-summary-refer-parent-article
1534 "D" gnus-summary-enter-digest-group
1535 "R" gnus-summary-refer-references
1536 "T" gnus-summary-refer-thread
1537 "g" gnus-summary-show-article
1538 "s" gnus-summary-isearch-article
1539 "P" gnus-summary-print-article
1540 "t" gnus-article-babel)
1542 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1543 "b" gnus-article-add-buttons
1544 "B" gnus-article-add-buttons-to-head
1545 "o" gnus-article-treat-overstrike
1546 "e" gnus-article-emphasize
1547 "w" gnus-article-fill-cited-article
1548 "Q" gnus-article-fill-long-lines
1549 "C" gnus-article-capitalize-sentences
1550 "c" gnus-article-remove-cr
1551 "q" gnus-article-de-quoted-unreadable
1552 "6" gnus-article-de-base64-unreadable
1553 "Z" gnus-article-decode-HZ
1554 "h" gnus-article-wash-html
1555 "f" gnus-article-display-x-face
1556 "l" gnus-summary-stop-page-breaking
1557 "r" gnus-summary-caesar-message
1558 "t" gnus-summary-toggle-header
1559 "v" gnus-summary-verbose-headers
1560 "H" gnus-article-strip-headers-in-body
1561 "d" gnus-article-treat-dumbquotes)
1563 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1564 "a" gnus-article-hide
1565 "h" gnus-article-hide-headers
1566 "b" gnus-article-hide-boring-headers
1567 "s" gnus-article-hide-signature
1568 "c" gnus-article-hide-citation
1569 "C" gnus-article-hide-citation-in-followups
1570 "l" gnus-article-hide-list-identifiers
1571 "p" gnus-article-hide-pgp
1572 "B" gnus-article-strip-banner
1573 "P" gnus-article-hide-pem
1574 "\C-c" gnus-article-hide-citation-maybe)
1576 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1577 "a" gnus-article-highlight
1578 "h" gnus-article-highlight-headers
1579 "c" gnus-article-highlight-citation
1580 "s" gnus-article-highlight-signature)
1582 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1583 "w" gnus-article-decode-mime-words
1584 "c" gnus-article-decode-charset
1585 "v" gnus-mime-view-all-parts
1586 "b" gnus-article-view-part)
1588 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1589 "z" gnus-article-date-ut
1590 "u" gnus-article-date-ut
1591 "l" gnus-article-date-local
1592 "e" gnus-article-date-lapsed
1593 "o" gnus-article-date-original
1594 "i" gnus-article-date-iso8601
1595 "s" gnus-article-date-user)
1597 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1598 "t" gnus-article-remove-trailing-blank-lines
1599 "l" gnus-article-strip-leading-blank-lines
1600 "m" gnus-article-strip-multiple-blank-lines
1601 "a" gnus-article-strip-blank-lines
1602 "A" gnus-article-strip-all-blank-lines
1603 "s" gnus-article-strip-leading-space
1604 "e" gnus-article-strip-trailing-space)
1606 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1608 "f" gnus-summary-fetch-faq
1609 "d" gnus-summary-describe-group
1610 "h" gnus-summary-describe-briefly
1611 "i" gnus-info-find-node)
1613 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1614 "e" gnus-summary-expire-articles
1615 "\M-\C-e" gnus-summary-expire-articles-now
1616 "\177" gnus-summary-delete-article
1617 [delete] gnus-summary-delete-article
1618 [backspace] gnus-summary-delete-article
1619 "m" gnus-summary-move-article
1620 "r" gnus-summary-respool-article
1621 "w" gnus-summary-edit-article
1622 "c" gnus-summary-copy-article
1623 "B" gnus-summary-crosspost-article
1624 "q" gnus-summary-respool-query
1625 "t" gnus-summary-respool-trace
1626 "i" gnus-summary-import-article
1627 "p" gnus-summary-article-posted-p)
1629 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1630 "o" gnus-summary-save-article
1631 "m" gnus-summary-save-article-mail
1632 "F" gnus-summary-write-article-file
1633 "r" gnus-summary-save-article-rmail
1634 "f" gnus-summary-save-article-file
1635 "b" gnus-summary-save-article-body-file
1636 "h" gnus-summary-save-article-folder
1637 "v" gnus-summary-save-article-vm
1638 "p" gnus-summary-pipe-output
1639 "s" gnus-soup-add-article)
1641 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1642 "b" gnus-summary-display-buttonized
1643 "m" gnus-summary-repair-multipart
1644 "v" gnus-article-view-part
1645 "o" gnus-article-save-part
1646 "c" gnus-article-copy-part
1647 "e" gnus-article-externalize-part
1648 "i" gnus-article-inline-part
1649 "|" gnus-article-pipe-part))
1651 (defun gnus-summary-make-menu-bar ()
1652 (gnus-turn-off-edit-menu 'summary)
1654 (unless (boundp 'gnus-summary-misc-menu)
1657 gnus-summary-kill-menu gnus-summary-mode-map ""
1662 ["Enter score..." gnus-summary-score-entry t]
1663 ["Customize" gnus-score-customize t])
1664 (gnus-make-score-map 'increase)
1665 (gnus-make-score-map 'lower)
1667 ["Kill below" gnus-summary-kill-below t]
1668 ["Mark above" gnus-summary-mark-above t]
1669 ["Tick above" gnus-summary-tick-above t]
1670 ["Clear above" gnus-summary-clear-above t])
1671 ["Current score" gnus-summary-current-score t]
1672 ["Set score" gnus-summary-set-score t]
1673 ["Switch current score file..." gnus-score-change-score-file t]
1674 ["Set mark below..." gnus-score-set-mark-below t]
1675 ["Set expunge below..." gnus-score-set-expunge-below t]
1676 ["Edit current score file" gnus-score-edit-current-scores t]
1677 ["Edit score file" gnus-score-edit-file t]
1678 ["Trace score" gnus-score-find-trace t]
1679 ["Find words" gnus-score-find-favourite-words t]
1680 ["Rescore buffer" gnus-summary-rescore t]
1681 ["Increase score..." gnus-summary-increase-score t]
1682 ["Lower score..." gnus-summary-lower-score t]))))
1684 ;; Define both the Article menu in the summary buffer and the equivalent
1685 ;; Commands menu in the article buffer here for consistency.
1688 ["All" gnus-article-hide t]
1689 ["Headers" gnus-article-hide-headers t]
1690 ["Signature" gnus-article-hide-signature t]
1691 ["Citation" gnus-article-hide-citation t]
1692 ["List identifiers" gnus-article-hide-list-identifiers t]
1693 ["PGP" gnus-article-hide-pgp t]
1694 ["Banner" gnus-article-strip-banner t]
1695 ["Boring headers" gnus-article-hide-boring-headers t])
1697 ["All" gnus-article-highlight t]
1698 ["Headers" gnus-article-highlight-headers t]
1699 ["Signature" gnus-article-highlight-signature t]
1700 ["Citation" gnus-article-highlight-citation t])
1702 ["Words" gnus-article-decode-mime-words t]
1703 ["Charset" gnus-article-decode-charset t]
1704 ["QP" gnus-article-de-quoted-unreadable t]
1705 ["Base64" gnus-article-de-base64-unreadable t]
1706 ["View all" gnus-mime-view-all-parts t])
1708 ["Local" gnus-article-date-local t]
1709 ["ISO8601" gnus-article-date-iso8601 t]
1710 ["UT" gnus-article-date-ut t]
1711 ["Original" gnus-article-date-original t]
1712 ["Lapsed" gnus-article-date-lapsed t]
1713 ["User-defined" gnus-article-date-user t])
1716 ["Leading" gnus-article-strip-leading-blank-lines t]
1717 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1718 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1719 ["All of the above" gnus-article-strip-blank-lines t]
1720 ["All" gnus-article-strip-all-blank-lines t]
1721 ["Leading space" gnus-article-strip-leading-space t]
1722 ["Trailing space" gnus-article-strip-trailing-space t])
1723 ["Overstrike" gnus-article-treat-overstrike t]
1724 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1725 ["Emphasis" gnus-article-emphasize t]
1726 ["Word wrap" gnus-article-fill-cited-article t]
1727 ["Fill long lines" gnus-article-fill-long-lines t]
1728 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1729 ["CR" gnus-article-remove-cr t]
1730 ["Show X-Face" gnus-article-display-x-face t]
1731 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1732 ["Base64" gnus-article-de-base64-unreadable t]
1733 ["Rot 13" gnus-summary-caesar-message t]
1734 ["Unix pipe" gnus-summary-pipe-message t]
1735 ["Add buttons" gnus-article-add-buttons t]
1736 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1737 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1738 ["Verbose header" gnus-summary-verbose-headers t]
1739 ["Toggle header" gnus-summary-toggle-header t]
1740 ["Html" gnus-article-wash-html t]
1741 ["HZ" gnus-article-decode-HZ t])
1743 ["Save in default format" gnus-summary-save-article t]
1744 ["Save in file" gnus-summary-save-article-file t]
1745 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1746 ["Save in MH folder" gnus-summary-save-article-folder t]
1747 ["Save in VM folder" gnus-summary-save-article-vm t]
1748 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1749 ["Save body in file" gnus-summary-save-article-body-file t]
1750 ["Pipe through a filter" gnus-summary-pipe-output t]
1751 ["Add to SOUP packet" gnus-soup-add-article t]
1752 ["Print" gnus-summary-print-article t])
1754 ["Respool article..." gnus-summary-respool-article t]
1755 ["Move article..." gnus-summary-move-article
1756 (gnus-check-backend-function
1757 'request-move-article gnus-newsgroup-name)]
1758 ["Copy article..." gnus-summary-copy-article t]
1759 ["Crosspost article..." gnus-summary-crosspost-article
1760 (gnus-check-backend-function
1761 'request-replace-article gnus-newsgroup-name)]
1762 ["Import file..." gnus-summary-import-article t]
1763 ["Check if posted" gnus-summary-article-posted-p t]
1764 ["Edit article" gnus-summary-edit-article
1765 (not (gnus-group-read-only-p))]
1766 ["Delete article" gnus-summary-delete-article
1767 (gnus-check-backend-function
1768 'request-expire-articles gnus-newsgroup-name)]
1769 ["Query respool" gnus-summary-respool-query t]
1770 ["Trace respool" gnus-summary-respool-trace t]
1771 ["Delete expirable articles" gnus-summary-expire-articles-now
1772 (gnus-check-backend-function
1773 'request-expire-articles gnus-newsgroup-name)])
1775 ["Uudecode" gnus-uu-decode-uu t]
1776 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1777 ["Unshar" gnus-uu-decode-unshar t]
1778 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1779 ["Save" gnus-uu-decode-save t]
1780 ["Binhex" gnus-uu-decode-binhex t]
1781 ["Postscript" gnus-uu-decode-postscript t])
1783 ["Enter article" gnus-cache-enter-article t]
1784 ["Remove article" gnus-cache-remove-article t])
1785 ["Translate" gnus-article-babel t]
1786 ["Select article buffer" gnus-summary-select-article-buffer t]
1787 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1788 ["Isearch article..." gnus-summary-isearch-article t]
1789 ["Beginning of the article" gnus-summary-beginning-of-article t]
1790 ["End of the article" gnus-summary-end-of-article t]
1791 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1792 ["Fetch referenced articles" gnus-summary-refer-references t]
1793 ["Fetch current thread" gnus-summary-refer-thread t]
1794 ["Fetch article with id..." gnus-summary-refer-article t]
1795 ["Redisplay" gnus-summary-show-article t])))
1797 gnus-summary-article-menu gnus-summary-mode-map ""
1798 (cons "Article" innards))
1801 gnus-article-commands-menu gnus-article-mode-map ""
1802 (cons "Commands" innards)))
1805 gnus-summary-thread-menu gnus-summary-mode-map ""
1807 ["Toggle threading" gnus-summary-toggle-threads t]
1808 ["Hide threads" gnus-summary-hide-all-threads t]
1809 ["Show threads" gnus-summary-show-all-threads t]
1810 ["Hide thread" gnus-summary-hide-thread t]
1811 ["Show thread" gnus-summary-show-thread t]
1812 ["Go to next thread" gnus-summary-next-thread t]
1813 ["Go to previous thread" gnus-summary-prev-thread t]
1814 ["Go down thread" gnus-summary-down-thread t]
1815 ["Go up thread" gnus-summary-up-thread t]
1816 ["Top of thread" gnus-summary-top-thread t]
1817 ["Mark thread as read" gnus-summary-kill-thread t]
1818 ["Lower thread score" gnus-summary-lower-thread t]
1819 ["Raise thread score" gnus-summary-raise-thread t]
1820 ["Rethread current" gnus-summary-rethread-current t]))
1823 gnus-summary-post-menu gnus-summary-mode-map ""
1825 ["Post an article" gnus-summary-post-news t]
1826 ["Followup" gnus-summary-followup t]
1827 ["Followup and yank" gnus-summary-followup-with-original t]
1828 ["Supersede article" gnus-summary-supersede-article t]
1829 ["Cancel article" gnus-summary-cancel-article t]
1830 ["Reply" gnus-summary-reply t]
1831 ["Reply and yank" gnus-summary-reply-with-original t]
1832 ["Wide reply" gnus-summary-wide-reply t]
1833 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1834 ["Mail forward" gnus-summary-mail-forward t]
1835 ["Post forward" gnus-summary-post-forward t]
1836 ["Digest and mail" gnus-uu-digest-mail-forward t]
1837 ["Digest and post" gnus-uu-digest-post-forward t]
1838 ["Resend message" gnus-summary-resend-message t]
1839 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1840 ["Send a mail" gnus-summary-mail-other-window t]
1841 ["Uuencode and post" gnus-uu-post-news t]
1842 ["Followup via news" gnus-summary-followup-to-mail t]
1843 ["Followup via news and yank"
1844 gnus-summary-followup-to-mail-with-original t]
1846 ;;["Send" gnus-summary-send-draft t]
1847 ;;["Send bounced" gnus-resend-bounced-mail t])
1851 gnus-summary-misc-menu gnus-summary-mode-map ""
1854 ["Mark as read" gnus-summary-mark-as-read-forward t]
1855 ["Mark same subject and select"
1856 gnus-summary-kill-same-subject-and-select t]
1857 ["Mark same subject" gnus-summary-kill-same-subject t]
1858 ["Catchup" gnus-summary-catchup t]
1859 ["Catchup all" gnus-summary-catchup-all t]
1860 ["Catchup to here" gnus-summary-catchup-to-here t]
1861 ["Catchup region" gnus-summary-mark-region-as-read t]
1862 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1864 ["Tick" gnus-summary-tick-article-forward t]
1865 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1866 ["Remove marks" gnus-summary-clear-mark-forward t]
1867 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1868 ["Set bookmark" gnus-summary-set-bookmark t]
1869 ["Remove bookmark" gnus-summary-remove-bookmark t])
1871 ["Marks..." gnus-summary-limit-to-marks t]
1872 ["Subject..." gnus-summary-limit-to-subject t]
1873 ["Author..." gnus-summary-limit-to-author t]
1874 ["Age..." gnus-summary-limit-to-age t]
1875 ["Extra..." gnus-summary-limit-to-extra t]
1876 ["Score" gnus-summary-limit-to-score t]
1877 ["Unread" gnus-summary-limit-to-unread t]
1878 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1879 ["Articles" gnus-summary-limit-to-articles t]
1880 ["Pop limit" gnus-summary-pop-limit t]
1881 ["Show dormant" gnus-summary-limit-include-dormant t]
1882 ["Hide childless dormant"
1883 gnus-summary-limit-exclude-childless-dormant t]
1884 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1885 ["Hide marked" gnus-summary-limit-exclude-marks t]
1886 ["Show expunged" gnus-summary-show-all-expunged t])
1888 ["Set mark" gnus-summary-mark-as-processable t]
1889 ["Remove mark" gnus-summary-unmark-as-processable t]
1890 ["Remove all marks" gnus-summary-unmark-all-processable t]
1891 ["Mark above" gnus-uu-mark-over t]
1892 ["Mark series" gnus-uu-mark-series t]
1893 ["Mark region" gnus-uu-mark-region t]
1894 ["Unmark region" gnus-uu-unmark-region t]
1895 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1896 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1897 ["Mark all" gnus-uu-mark-all t]
1898 ["Mark buffer" gnus-uu-mark-buffer t]
1899 ["Mark sparse" gnus-uu-mark-sparse t]
1900 ["Mark thread" gnus-uu-mark-thread t]
1901 ["Unmark thread" gnus-uu-unmark-thread t]
1902 ("Process Mark Sets"
1903 ["Kill" gnus-summary-kill-process-mark t]
1904 ["Yank" gnus-summary-yank-process-mark
1905 gnus-newsgroup-process-stack]
1906 ["Save" gnus-summary-save-process-mark t]))
1908 ["Page forward" gnus-summary-next-page t]
1909 ["Page backward" gnus-summary-prev-page t]
1910 ["Line forward" gnus-summary-scroll-up t])
1912 ["Next unread article" gnus-summary-next-unread-article t]
1913 ["Previous unread article" gnus-summary-prev-unread-article t]
1914 ["Next article" gnus-summary-next-article t]
1915 ["Previous article" gnus-summary-prev-article t]
1916 ["Next unread subject" gnus-summary-next-unread-subject t]
1917 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1918 ["Next article same subject" gnus-summary-next-same-subject t]
1919 ["Previous article same subject" gnus-summary-prev-same-subject t]
1920 ["First unread article" gnus-summary-first-unread-article t]
1921 ["Best unread article" gnus-summary-best-unread-article t]
1922 ["Go to subject number..." gnus-summary-goto-subject t]
1923 ["Go to article number..." gnus-summary-goto-article t]
1924 ["Go to the last article" gnus-summary-goto-last-article t]
1925 ["Pop article off history" gnus-summary-pop-article t])
1927 ["Sort by number" gnus-summary-sort-by-number t]
1928 ["Sort by author" gnus-summary-sort-by-author t]
1929 ["Sort by subject" gnus-summary-sort-by-subject t]
1930 ["Sort by date" gnus-summary-sort-by-date t]
1931 ["Sort by score" gnus-summary-sort-by-score t]
1932 ["Sort by lines" gnus-summary-sort-by-lines t]
1933 ["Sort by characters" gnus-summary-sort-by-chars t])
1935 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1936 ["Describe group" gnus-summary-describe-group t]
1937 ["Read manual" gnus-info-find-node t])
1939 ["Pick and read" gnus-pick-mode t]
1940 ["Binary" gnus-binary-mode t])
1942 ["Regenerate" gnus-summary-prepare t]
1943 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1944 ["Toggle threading" gnus-summary-toggle-threads t])
1945 ["Filter articles..." gnus-summary-execute-command t]
1946 ["Run command on subjects..." gnus-summary-universal-argument t]
1947 ["Search articles forward..." gnus-summary-search-article-forward t]
1948 ["Search articles backward..." gnus-summary-search-article-backward t]
1949 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1950 ["Expand window" gnus-summary-expand-window t]
1951 ["Expire expirable articles" gnus-summary-expire-articles
1952 (gnus-check-backend-function
1953 'request-expire-articles gnus-newsgroup-name)]
1954 ["Edit local kill file" gnus-summary-edit-local-kill t]
1955 ["Edit main kill file" gnus-summary-edit-global-kill t]
1956 ["Edit group parameters" gnus-summary-edit-parameters t]
1957 ["Customize group parameters" gnus-summary-customize-parameters t]
1958 ["Send a bug report" gnus-bug t]
1960 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1961 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1962 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1963 ["Exit group" gnus-summary-exit t]
1964 ["Exit group without updating" gnus-summary-exit-no-update t]
1965 ["Exit and goto next group" gnus-summary-next-group t]
1966 ["Exit and goto prev group" gnus-summary-prev-group t]
1967 ["Reselect group" gnus-summary-reselect-current-group t]
1968 ["Rescan group" gnus-summary-rescan-group t]
1969 ["Update dribble" gnus-summary-save-newsrc t])))
1971 (gnus-run-hooks 'gnus-summary-menu-hook)))
1973 (defun gnus-score-set-default (var value)
1974 "A version of set that updates the GNU Emacs menu-bar."
1976 ;; It is the message that forces the active status to be updated.
1979 (defun gnus-make-score-map (type)
1980 "Make a summary score map of type TYPE."
1983 (let ((headers '(("author" "from" string)
1984 ("subject" "subject" string)
1985 ("article body" "body" string)
1986 ("article head" "head" string)
1987 ("xref" "xref" string)
1988 ("extra header" "extra" string)
1989 ("lines" "lines" number)
1990 ("followups to author" "followup" string)))
1991 (types '((number ("less than" <)
1994 (string ("substring" s)
1998 (perms '(("temporary" (current-time-string))
2006 (if (eq type 'lower)
2011 (setq header (car headers))
2017 (let ((ts (cdr (assoc (nth 2 header) types)))
2033 'gnus-summary-score-entry
2035 (if (or (string= (nth 1 header)
2037 (string= (nth 1 header)
2040 (list 'gnus-summary-header
2042 (list 'quote (nth 1 (car ts)))
2043 (list 'gnus-score-delta-default
2050 (list (nreverse outp))))
2053 (list (nreverse outt))))
2055 (setq headers (cdr headers)))
2056 (list (nreverse outh))))))))
2060 (defun gnus-summary-mode (&optional group)
2061 "Major mode for reading articles.
2063 All normal editing commands are switched off.
2064 \\<gnus-summary-mode-map>
2065 Each line in this buffer represents one article. To read an
2066 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2067 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2070 You can also post articles and send mail from this buffer. To
2071 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2072 of an article, type `\\[gnus-summary-reply]'.
2074 There are approx. one gazillion commands you can execute in this
2075 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2077 The following commands are available:
2079 \\{gnus-summary-mode-map}"
2081 (when (gnus-visual-p 'summary-menu 'menu)
2082 (gnus-summary-make-menu-bar))
2083 (kill-all-local-variables)
2084 (gnus-summary-make-local-variables)
2085 (gnus-make-thread-indent-array)
2086 (gnus-simplify-mode-line)
2087 (setq major-mode 'gnus-summary-mode)
2088 (setq mode-name "Summary")
2089 (make-local-variable 'minor-mode-alist)
2090 (use-local-map gnus-summary-mode-map)
2091 (buffer-disable-undo)
2092 (setq buffer-read-only t) ;Disable modification
2093 (setq truncate-lines t)
2094 (setq selective-display t)
2095 (setq selective-display-ellipses t) ;Display `...'
2096 (gnus-summary-set-display-table)
2097 (gnus-set-default-directory)
2098 (setq gnus-newsgroup-name group)
2099 (make-local-variable 'gnus-summary-line-format)
2100 (make-local-variable 'gnus-summary-line-format-spec)
2101 (make-local-variable 'gnus-summary-dummy-line-format)
2102 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2103 (make-local-variable 'gnus-summary-mark-positions)
2104 (make-local-hook 'pre-command-hook)
2105 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2106 (gnus-run-hooks 'gnus-summary-mode-hook)
2107 (mm-enable-multibyte-mule4)
2108 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2109 (gnus-update-summary-mark-positions))
2111 (defun gnus-summary-make-local-variables ()
2112 "Make all the local summary buffer variables."
2114 (dolist (local gnus-summary-local-variables)
2117 (if (eq (cdr local) 'global)
2118 ;; Copy the global value of the variable.
2119 (setq global (symbol-value (car local)))
2120 ;; Use the value from the list.
2121 (setq global (eval (cdr local))))
2122 (set (make-local-variable (car local)) global))
2123 ;; Simple nil-valued local variable.
2124 (set (make-local-variable local) nil)))))
2126 (defun gnus-summary-clear-local-variables ()
2127 (let ((locals gnus-summary-local-variables))
2129 (if (consp (car locals))
2130 (and (vectorp (caar locals))
2131 (set (caar locals) nil))
2132 (and (vectorp (car locals))
2133 (set (car locals) nil)))
2134 (setq locals (cdr locals)))))
2136 ;; Summary data functions.
2138 (defmacro gnus-data-number (data)
2141 (defmacro gnus-data-set-number (data number)
2142 `(setcar ,data ,number))
2144 (defmacro gnus-data-mark (data)
2147 (defmacro gnus-data-set-mark (data mark)
2148 `(setcar (nthcdr 1 ,data) ,mark))
2150 (defmacro gnus-data-pos (data)
2153 (defmacro gnus-data-set-pos (data pos)
2154 `(setcar (nthcdr 2 ,data) ,pos))
2156 (defmacro gnus-data-header (data)
2159 (defmacro gnus-data-set-header (data header)
2160 `(setf (nth 3 ,data) ,header))
2162 (defmacro gnus-data-level (data)
2165 (defmacro gnus-data-unread-p (data)
2166 `(= (nth 1 ,data) gnus-unread-mark))
2168 (defmacro gnus-data-read-p (data)
2169 `(/= (nth 1 ,data) gnus-unread-mark))
2171 (defmacro gnus-data-pseudo-p (data)
2172 `(consp (nth 3 ,data)))
2174 (defmacro gnus-data-find (number)
2175 `(assq ,number gnus-newsgroup-data))
2177 (defmacro gnus-data-find-list (number &optional data)
2178 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2179 (memq (assq ,number bdata)
2182 (defmacro gnus-data-make (number mark pos header level)
2183 `(list ,number ,mark ,pos ,header ,level))
2185 (defun gnus-data-enter (after-article number mark pos header level offset)
2186 (let ((data (gnus-data-find-list after-article)))
2188 (error "No such article: %d" after-article))
2189 (setcdr data (cons (gnus-data-make number mark pos header level)
2191 (setq gnus-newsgroup-data-reverse nil)
2192 (gnus-data-update-list (cddr data) offset)))
2194 (defun gnus-data-enter-list (after-article list &optional offset)
2196 (let ((data (and after-article (gnus-data-find-list after-article)))
2200 (let ((odata gnus-newsgroup-data))
2201 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2203 (gnus-data-update-list odata offset)))
2204 ;; Find the last element in the list to be spliced into the main
2207 (setq list (cdr list)))
2210 (setcdr list gnus-newsgroup-data)
2211 (setq gnus-newsgroup-data ilist)
2213 (gnus-data-update-list (cdr list) offset)))
2214 (setcdr list (cdr data))
2217 (gnus-data-update-list (cdr list) offset))))
2218 (setq gnus-newsgroup-data-reverse nil))))
2220 (defun gnus-data-remove (article &optional offset)
2221 (let ((data gnus-newsgroup-data))
2222 (if (= (gnus-data-number (car data)) article)
2224 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2225 gnus-newsgroup-data-reverse nil)
2227 (gnus-data-update-list gnus-newsgroup-data offset)))
2229 (when (= (gnus-data-number (cadr data)) article)
2230 (setcdr data (cddr data))
2232 (gnus-data-update-list (cdr data) offset))
2234 gnus-newsgroup-data-reverse nil))
2235 (setq data (cdr data))))))
2237 (defmacro gnus-data-list (backward)
2239 (or gnus-newsgroup-data-reverse
2240 (setq gnus-newsgroup-data-reverse
2241 (reverse gnus-newsgroup-data)))
2242 gnus-newsgroup-data))
2244 (defun gnus-data-update-list (data offset)
2245 "Add OFFSET to the POS of all data entries in DATA."
2246 (setq gnus-newsgroup-data-reverse nil)
2248 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2249 (setq data (cdr data))))
2251 (defun gnus-summary-article-pseudo-p (article)
2252 "Say whether this article is a pseudo article or not."
2253 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2255 (defmacro gnus-summary-article-sparse-p (article)
2256 "Say whether this article is a sparse article or not."
2257 `(memq ,article gnus-newsgroup-sparse))
2259 (defmacro gnus-summary-article-ancient-p (article)
2260 "Say whether this article is a sparse article or not."
2261 `(memq ,article gnus-newsgroup-ancient))
2263 (defun gnus-article-parent-p (number)
2264 "Say whether this article is a parent or not."
2265 (let ((data (gnus-data-find-list number)))
2266 (and (cdr data) ; There has to be an article after...
2267 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2268 (gnus-data-level (nth 1 data))))))
2270 (defun gnus-article-children (number)
2271 "Return a list of all children to NUMBER."
2272 (let* ((data (gnus-data-find-list number))
2273 (level (gnus-data-level (car data)))
2275 (setq data (cdr data))
2277 (= (gnus-data-level (car data)) (1+ level)))
2278 (push (gnus-data-number (car data)) children)
2279 (setq data (cdr data)))
2282 (defmacro gnus-summary-skip-intangible ()
2283 "If the current article is intangible, then jump to a different article."
2284 '(let ((to (get-text-property (point) 'gnus-intangible)))
2285 (and to (gnus-summary-goto-subject to))))
2287 (defmacro gnus-summary-article-intangible-p ()
2288 "Say whether this article is intangible or not."
2289 '(get-text-property (point) 'gnus-intangible))
2291 (defun gnus-article-read-p (article)
2292 "Say whether ARTICLE is read or not."
2293 (not (or (memq article gnus-newsgroup-marked)
2294 (memq article gnus-newsgroup-unreads)
2295 (memq article gnus-newsgroup-unselected)
2296 (memq article gnus-newsgroup-dormant))))
2298 ;; Some summary mode macros.
2300 (defmacro gnus-summary-article-number ()
2301 "The article number of the article on the current line.
2302 If there isn's an article number here, then we return the current
2305 (gnus-summary-skip-intangible)
2306 (or (get-text-property (point) 'gnus-number)
2307 (gnus-summary-last-subject))))
2309 (defmacro gnus-summary-article-header (&optional number)
2310 "Return the header of article NUMBER."
2311 `(gnus-data-header (gnus-data-find
2312 ,(or number '(gnus-summary-article-number)))))
2314 (defmacro gnus-summary-thread-level (&optional number)
2315 "Return the level of thread that starts with article NUMBER."
2316 `(if (and (eq gnus-summary-make-false-root 'dummy)
2317 (get-text-property (point) 'gnus-intangible))
2319 (gnus-data-level (gnus-data-find
2320 ,(or number '(gnus-summary-article-number))))))
2322 (defmacro gnus-summary-article-mark (&optional number)
2323 "Return the mark of article NUMBER."
2324 `(gnus-data-mark (gnus-data-find
2325 ,(or number '(gnus-summary-article-number)))))
2327 (defmacro gnus-summary-article-pos (&optional number)
2328 "Return the position of the line of article NUMBER."
2329 `(gnus-data-pos (gnus-data-find
2330 ,(or number '(gnus-summary-article-number)))))
2332 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2333 (defmacro gnus-summary-article-subject (&optional number)
2334 "Return current subject string or nil if nothing."
2337 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2338 '(gnus-data-header (assq (gnus-summary-article-number)
2339 gnus-newsgroup-data)))))
2342 (mail-header-subject headers))))
2344 (defmacro gnus-summary-article-score (&optional number)
2345 "Return current article score."
2346 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2347 gnus-newsgroup-scored))
2348 gnus-summary-default-score 0))
2350 (defun gnus-summary-article-children (&optional number)
2351 "Return a list of article numbers that are children of article NUMBER."
2352 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2353 (level (gnus-data-level (car data)))
2355 (while (and (setq data (cdr data))
2356 (> (setq l (gnus-data-level (car data))) level))
2357 (and (= (1+ level) l)
2358 (push (gnus-data-number (car data))
2360 (nreverse children)))
2362 (defun gnus-summary-article-parent (&optional number)
2363 "Return the article number of the parent of article NUMBER."
2364 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2365 (gnus-data-list t)))
2366 (level (gnus-data-level (car data))))
2368 () ; This is a root.
2369 ;; We search until we find an article with a level less than
2370 ;; this one. That function has to be the parent.
2371 (while (and (setq data (cdr data))
2372 (not (< (gnus-data-level (car data)) level))))
2373 (and data (gnus-data-number (car data))))))
2375 (defun gnus-unread-mark-p (mark)
2376 "Say whether MARK is the unread mark."
2377 (= mark gnus-unread-mark))
2379 (defun gnus-read-mark-p (mark)
2380 "Say whether MARK is one of the marks that mark as read.
2381 This is all marks except unread, ticked, dormant, and expirable."
2382 (not (or (= mark gnus-unread-mark)
2383 (= mark gnus-ticked-mark)
2384 (= mark gnus-dormant-mark)
2385 (= mark gnus-expirable-mark))))
2387 (defmacro gnus-article-mark (number)
2388 "Return the MARK of article NUMBER.
2389 This macro should only be used when computing the mark the \"first\"
2390 time; i.e., when generating the summary lines. After that,
2391 `gnus-summary-article-mark' should be used to examine the
2394 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2395 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2396 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2397 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2398 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2399 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2400 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2401 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2402 gnus-ancient-mark))))
2404 ;; Saving hidden threads.
2406 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2407 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2409 (defmacro gnus-save-hidden-threads (&rest forms)
2410 "Save hidden threads, eval FORMS, and restore the hidden threads."
2411 (let ((config (make-symbol "config")))
2412 `(let ((,config (gnus-hidden-threads-configuration)))
2416 (gnus-restore-hidden-threads-configuration ,config)))))
2418 (defun gnus-data-compute-positions ()
2419 "Compute the positions of all articles."
2420 (setq gnus-newsgroup-data-reverse nil)
2421 (let ((data gnus-newsgroup-data))
2423 (gnus-save-hidden-threads
2424 (gnus-summary-show-all-threads)
2425 (goto-char (point-min))
2427 (while (get-text-property (point) 'gnus-intangible)
2429 (gnus-data-set-pos (car data) (+ (point) 3))
2430 (setq data (cdr data))
2431 (forward-line 1))))))
2433 (defun gnus-hidden-threads-configuration ()
2434 "Return the current hidden threads configuration."
2437 (goto-char (point-min))
2438 (while (search-forward "\r" nil t)
2439 (push (1- (point)) config))
2442 (defun gnus-restore-hidden-threads-configuration (config)
2443 "Restore hidden threads configuration from CONFIG."
2445 (let (point buffer-read-only)
2446 (while (setq point (pop config))
2447 (when (and (< point (point-max))
2449 (eq (char-after) ?\n))
2450 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2452 ;; Various summary mode internalish functions.
2454 (defun gnus-mouse-pick-article (e)
2457 (gnus-summary-next-page nil t))
2459 (defun gnus-summary-set-display-table ()
2460 "Change the display table.
2461 Odd characters have a tendency to mess
2462 up nicely formatted displays - we make all possible glyphs
2463 display only a single character."
2465 ;; We start from the standard display table, if any.
2466 (let ((table (or (copy-sequence standard-display-table)
2467 (make-display-table)))
2469 ;; Nix out all the control chars...
2470 (while (>= (setq i (1- i)) 0)
2471 (aset table i [??]))
2472 ;; ... but not newline and cr, of course. (cr is necessary for the
2473 ;; selective display).
2474 (aset table ?\n nil)
2475 (aset table ?\r nil)
2476 ;; We keep TAB as well.
2477 (aset table ?\t nil)
2478 ;; We nix out any glyphs over 126 that are not set already.
2480 (while (>= (setq i (1- i)) 127)
2481 ;; Only modify if the entry is nil.
2482 (unless (aref table i)
2483 (aset table i [??]))))
2484 (setq buffer-display-table table)))
2486 (defun gnus-summary-setup-buffer (group)
2487 "Initialize summary buffer."
2488 (let ((buffer (concat "*Summary " group "*")))
2489 (if (get-buffer buffer)
2492 (setq gnus-summary-buffer (current-buffer))
2493 (not gnus-newsgroup-prepared))
2494 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2495 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2496 (gnus-summary-mode group)
2498 (gnus-carpal-setup-buffer 'summary))
2499 (unless gnus-single-article-buffer
2500 (make-local-variable 'gnus-article-buffer)
2501 (make-local-variable 'gnus-article-current)
2502 (make-local-variable 'gnus-original-article-buffer))
2503 (setq gnus-newsgroup-name group)
2506 (defun gnus-set-global-variables ()
2507 "Set the global equivalents of the buffer-local variables.
2508 They are set to the latest values they had. These reflect the summary
2509 buffer that was in action when the last article was fetched."
2510 (when (eq major-mode 'gnus-summary-mode)
2511 (setq gnus-summary-buffer (current-buffer))
2512 (let ((name gnus-newsgroup-name)
2513 (marked gnus-newsgroup-marked)
2514 (unread gnus-newsgroup-unreads)
2515 (headers gnus-current-headers)
2516 (data gnus-newsgroup-data)
2517 (summary gnus-summary-buffer)
2518 (article-buffer gnus-article-buffer)
2519 (original gnus-original-article-buffer)
2520 (gac gnus-article-current)
2521 (reffed gnus-reffed-article-number)
2522 (score-file gnus-current-score-file)
2523 (default-charset gnus-newsgroup-charset))
2525 (set-buffer gnus-group-buffer)
2526 (setq gnus-newsgroup-name name
2527 gnus-newsgroup-marked marked
2528 gnus-newsgroup-unreads unread
2529 gnus-current-headers headers
2530 gnus-newsgroup-data data
2531 gnus-article-current gac
2532 gnus-summary-buffer summary
2533 gnus-article-buffer article-buffer
2534 gnus-original-article-buffer original
2535 gnus-reffed-article-number reffed
2536 gnus-current-score-file score-file
2537 gnus-newsgroup-charset default-charset)
2538 ;; The article buffer also has local variables.
2539 (when (gnus-buffer-live-p gnus-article-buffer)
2540 (set-buffer gnus-article-buffer)
2541 (setq gnus-summary-buffer summary))))))
2543 (defun gnus-summary-article-unread-p (article)
2544 "Say whether ARTICLE is unread or not."
2545 (memq article gnus-newsgroup-unreads))
2547 (defun gnus-summary-first-article-p (&optional article)
2548 "Return whether ARTICLE is the first article in the buffer."
2549 (if (not (setq article (or article (gnus-summary-article-number))))
2551 (eq article (caar gnus-newsgroup-data))))
2553 (defun gnus-summary-last-article-p (&optional article)
2554 "Return whether ARTICLE is the last article in the buffer."
2555 (if (not (setq article (or article (gnus-summary-article-number))))
2556 ;; All non-existent numbers are the last article. :-)
2558 (not (cdr (gnus-data-find-list article)))))
2560 (defun gnus-make-thread-indent-array ()
2562 (unless (and gnus-thread-indent-array
2563 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2564 (setq gnus-thread-indent-array (make-vector 201 "")
2565 gnus-thread-indent-array-level gnus-thread-indent-level)
2567 (aset gnus-thread-indent-array n
2568 (make-string (* n gnus-thread-indent-level) ? ))
2571 (defun gnus-update-summary-mark-positions ()
2572 "Compute where the summary marks are to go."
2574 (when (gnus-buffer-exists-p gnus-summary-buffer)
2575 (set-buffer gnus-summary-buffer))
2576 (let ((gnus-replied-mark 129)
2577 (gnus-score-below-mark 130)
2578 (gnus-score-over-mark 130)
2579 (gnus-download-mark 131)
2580 (spec gnus-summary-line-format-spec)
2583 (gnus-set-work-buffer)
2584 (let ((gnus-summary-line-format-spec spec)
2585 (gnus-newsgroup-downloadable '((0 . t))))
2586 (gnus-summary-insert-line
2587 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2588 (goto-char (point-min))
2589 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2591 (goto-char (point-min))
2592 (push (cons 'replied (and (search-forward "\201" nil t)
2595 (goto-char (point-min))
2596 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2598 (goto-char (point-min))
2599 (push (cons 'download
2600 (and (search-forward "\203" nil t) (- (point) 2)))
2602 (setq gnus-summary-mark-positions pos))))
2604 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2605 "Insert a dummy root in the summary buffer."
2607 (gnus-add-text-properties
2608 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2609 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2611 (defun gnus-summary-from-or-to-or-newsgroups (header)
2612 (let ((to (cdr (assq 'To (mail-header-extra header))))
2613 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2614 (mail-parse-charset gnus-newsgroup-charset)
2615 (mail-parse-ignored-charsets
2616 (save-excursion (set-buffer gnus-summary-buffer)
2617 gnus-newsgroup-ignored-charsets)))
2620 gnus-ignored-from-addresses
2621 (string-match gnus-ignored-from-addresses
2622 (mail-header-from header)))
2624 (or (car (funcall gnus-extract-address-components
2626 gnus-decode-encoded-word-function to)))
2627 (funcall gnus-decode-encoded-word-function to))))
2629 gnus-ignored-from-addresses
2630 (string-match gnus-ignored-from-addresses
2631 (mail-header-from header)))
2632 (concat "=> " newsgroups))
2634 (or (car (funcall gnus-extract-address-components
2635 (mail-header-from header)))
2636 (mail-header-from header))))))
2638 (defun gnus-summary-insert-line (gnus-tmp-header
2639 gnus-tmp-level gnus-tmp-current
2640 gnus-tmp-unread gnus-tmp-replied
2641 gnus-tmp-expirable gnus-tmp-subject-or-nil
2642 &optional gnus-tmp-dummy gnus-tmp-score
2644 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2645 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2646 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2647 (gnus-tmp-score-char
2648 (if (or (null gnus-summary-default-score)
2649 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2650 gnus-summary-zcore-fuzz))
2652 (if (< gnus-tmp-score gnus-summary-default-score)
2653 gnus-score-below-mark gnus-score-over-mark)))
2655 (cond (gnus-tmp-process gnus-process-mark)
2656 ((memq gnus-tmp-current gnus-newsgroup-cached)
2658 (gnus-tmp-replied gnus-replied-mark)
2659 ((memq gnus-tmp-current gnus-newsgroup-saved)
2661 (t gnus-unread-mark)))
2662 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2665 ((string-match "<[^>]+> *$" gnus-tmp-from)
2666 (let ((beg (match-beginning 0)))
2667 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2668 (substring gnus-tmp-from (1+ (match-beginning 0))
2669 (1- (match-end 0))))
2670 (substring gnus-tmp-from 0 beg))))
2671 ((string-match "(.+)" gnus-tmp-from)
2672 (substring gnus-tmp-from
2673 (1+ (match-beginning 0)) (1- (match-end 0))))
2675 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2676 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2677 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2678 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2679 (buffer-read-only nil))
2680 (when (string= gnus-tmp-name "")
2681 (setq gnus-tmp-name gnus-tmp-from))
2682 (unless (numberp gnus-tmp-lines)
2683 (setq gnus-tmp-lines 0))
2684 (gnus-put-text-property
2686 (progn (eval gnus-summary-line-format-spec) (point))
2687 'gnus-number gnus-tmp-number)
2688 (when (gnus-visual-p 'summary-highlight 'highlight)
2690 (gnus-run-hooks 'gnus-summary-update-hook)
2693 (defun gnus-summary-update-line (&optional dont-update)
2694 "Update summary line after change."
2695 (when (and gnus-summary-default-score
2696 (not gnus-summary-inhibit-highlight))
2697 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2698 (article (gnus-summary-article-number))
2699 (score (gnus-summary-article-score article)))
2701 (if (and gnus-summary-mark-below
2702 (< (gnus-summary-article-score)
2703 gnus-summary-mark-below))
2704 ;; This article has a low score, so we mark it as read.
2705 (when (memq article gnus-newsgroup-unreads)
2706 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2707 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2708 ;; This article was previously marked as read on account
2709 ;; of a low score, but now it has risen, so we mark it as
2711 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2712 (gnus-summary-update-mark
2713 (if (or (null gnus-summary-default-score)
2714 (<= (abs (- score gnus-summary-default-score))
2715 gnus-summary-zcore-fuzz))
2717 (if (< score gnus-summary-default-score)
2718 gnus-score-below-mark gnus-score-over-mark))
2720 ;; Do visual highlighting.
2721 (when (gnus-visual-p 'summary-highlight 'highlight)
2722 (gnus-run-hooks 'gnus-summary-update-hook)))))
2724 (defvar gnus-tmp-new-adopts nil)
2726 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2727 "Return the number of articles in THREAD.
2728 This may be 0 in some cases -- if none of the articles in
2729 the thread are to be displayed."
2731 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2733 ((not (listp thread))
2735 ((and (consp thread) (cdr thread))
2738 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2741 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2744 (when (and level (zerop level) gnus-tmp-new-adopts)
2747 'gnus-summary-number-of-articles-in-thread
2748 gnus-tmp-new-adopts))))
2750 (if (> number 1) gnus-not-empty-thread-mark
2751 gnus-empty-thread-mark)
2754 (defun gnus-summary-set-local-parameters (group)
2755 "Go through the local params of GROUP and set all variable specs in that list."
2756 (let ((params (gnus-group-find-parameter group))
2759 (setq elem (car params)
2760 params (cdr params))
2761 (and (consp elem) ; Has to be a cons.
2762 (consp (cdr elem)) ; The cdr has to be a list.
2763 (symbolp (car elem)) ; Has to be a symbol in there.
2764 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2765 (ignore-errors ; So we set it.
2766 (make-local-variable (car elem))
2767 (set (car elem) (eval (nth 1 elem))))))))
2769 (defun gnus-summary-read-group (group &optional show-all no-article
2770 kill-buffer no-display backward
2772 "Start reading news in newsgroup GROUP.
2773 If SHOW-ALL is non-nil, already read articles are also listed.
2774 If NO-ARTICLE is non-nil, no article is selected initially.
2775 If NO-DISPLAY, don't generate a summary buffer."
2779 (let ((gnus-auto-select-next nil))
2780 (or (gnus-summary-read-group-1
2781 group show-all no-article
2782 kill-buffer no-display
2785 select-articles nil)))))
2786 (eq gnus-auto-select-next 'quietly))
2787 (set-buffer gnus-group-buffer)
2788 ;; The entry function called above goes to the next
2789 ;; group automatically, so we go two groups back
2790 ;; if we are searching for the previous group.
2792 (gnus-group-prev-unread-group 2))
2793 (if (not (equal group (gnus-group-group-name)))
2794 (setq group (gnus-group-group-name))
2798 (defun gnus-summary-read-group-1 (group show-all no-article
2799 kill-buffer no-display
2800 &optional select-articles)
2801 ;; Killed foreign groups can't be entered.
2802 (when (and (not (gnus-group-native-p group))
2803 (not (gnus-gethash group gnus-newsrc-hashtb)))
2804 (error "Dead non-native groups can't be entered"))
2805 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2806 (let* ((new-group (gnus-summary-setup-buffer group))
2807 (quit-config (gnus-group-quit-config group))
2808 (did-select (and new-group (gnus-select-newsgroup
2809 group show-all select-articles))))
2811 ;; This summary buffer exists already, so we just select it.
2813 (gnus-set-global-variables)
2815 (gnus-kill-or-deaden-summary kill-buffer))
2816 (gnus-configure-windows 'summary 'force)
2817 (gnus-set-mode-line 'summary)
2818 (gnus-summary-position-point)
2821 ;; We couldn't select this group.
2823 (when (and (eq major-mode 'gnus-summary-mode)
2824 (not (equal (current-buffer) kill-buffer)))
2825 (kill-buffer (current-buffer))
2826 (if (not quit-config)
2828 ;; Update the info -- marks might need to be removed,
2830 (gnus-summary-update-info)
2831 (set-buffer gnus-group-buffer)
2832 (gnus-group-jump-to-group group)
2833 (gnus-group-next-unread-group 1))
2834 (gnus-handle-ephemeral-exit quit-config)))
2835 (gnus-message 3 "Can't select group")
2837 ;; The user did a `C-g' while prompting for number of articles,
2838 ;; so we exit this group.
2839 ((eq did-select 'quit)
2840 (and (eq major-mode 'gnus-summary-mode)
2841 (not (equal (current-buffer) kill-buffer))
2842 (kill-buffer (current-buffer)))
2844 (gnus-kill-or-deaden-summary kill-buffer))
2845 (if (not quit-config)
2847 (set-buffer gnus-group-buffer)
2848 (gnus-group-jump-to-group group)
2849 (gnus-group-next-unread-group 1)
2850 (gnus-configure-windows 'group 'force))
2851 (gnus-handle-ephemeral-exit quit-config))
2852 ;; Finally signal the quit.
2854 ;; The group was successfully selected.
2856 (gnus-set-global-variables)
2857 ;; Save the active value in effect when the group was entered.
2858 (setq gnus-newsgroup-active
2860 (gnus-active gnus-newsgroup-name)))
2861 ;; You can change the summary buffer in some way with this hook.
2862 (gnus-run-hooks 'gnus-select-group-hook)
2863 ;; Set any local variables in the group parameters.
2864 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2865 (gnus-update-format-specifications
2866 nil 'summary 'summary-mode 'summary-dummy)
2867 (gnus-update-summary-mark-positions)
2868 ;; Do score processing.
2869 (when gnus-use-scoring
2870 (gnus-possibly-score-headers))
2871 ;; Check whether to fill in the gaps in the threads.
2872 (when gnus-build-sparse-threads
2873 (gnus-build-sparse-threads))
2874 ;; Find the initial limit.
2875 (if gnus-show-threads
2877 (let ((gnus-newsgroup-dormant nil))
2878 (gnus-summary-initial-limit show-all))
2879 (gnus-summary-initial-limit show-all))
2880 ;; When untreaded, all articles are always shown.
2881 (setq gnus-newsgroup-limit
2883 (lambda (header) (mail-header-number header))
2884 gnus-newsgroup-headers)))
2885 ;; Generate the summary buffer.
2887 (gnus-summary-prepare))
2888 (when gnus-use-trees
2889 (gnus-tree-open group)
2890 (setq gnus-summary-highlight-line-function
2891 'gnus-tree-highlight-article))
2892 ;; If the summary buffer is empty, but there are some low-scored
2893 ;; articles or some excluded dormants, we include these in the
2895 (when (and (zerop (buffer-size))
2897 (cond (gnus-newsgroup-dormant
2898 (gnus-summary-limit-include-dormant))
2899 ((and gnus-newsgroup-scored show-all)
2900 (gnus-summary-limit-include-expunged t))))
2901 ;; Function `gnus-apply-kill-file' must be called in this hook.
2902 (gnus-run-hooks 'gnus-apply-kill-hook)
2903 (if (and (zerop (buffer-size))
2906 ;; This newsgroup is empty.
2907 (gnus-summary-catchup-and-exit nil t)
2908 (gnus-message 6 "No unread news")
2910 (gnus-kill-or-deaden-summary kill-buffer))
2911 ;; Return nil from this function.
2913 ;; Hide conversation thread subtrees. We cannot do this in
2914 ;; gnus-summary-prepare-hook since kill processing may not
2915 ;; work with hidden articles.
2916 (and gnus-show-threads
2917 gnus-thread-hide-subtree
2918 (gnus-summary-hide-all-threads))
2920 (gnus-kill-or-deaden-summary kill-buffer))
2921 ;; Show first unread article if requested.
2922 (if (and (not no-article)
2924 gnus-newsgroup-unreads
2925 gnus-auto-select-first)
2927 (gnus-configure-windows 'summary)
2929 ((eq gnus-auto-select-first 'best)
2930 (gnus-summary-best-unread-article))
2931 ((eq gnus-auto-select-first t)
2932 (gnus-summary-first-unread-article))
2933 ((gnus-functionp gnus-auto-select-first)
2934 (funcall gnus-auto-select-first))))
2935 ;; Don't select any articles, just move point to the first
2936 ;; article in the group.
2937 (goto-char (point-min))
2938 (gnus-summary-position-point)
2939 (gnus-configure-windows 'summary 'force)
2940 (gnus-set-mode-line 'summary))
2941 (when (get-buffer-window gnus-group-buffer t)
2942 ;; Gotta use windows, because recenter does weird stuff if
2943 ;; the current buffer ain't the displayed window.
2944 (let ((owin (selected-window)))
2945 (select-window (get-buffer-window gnus-group-buffer t))
2946 (when (gnus-group-goto-group group)
2948 (select-window owin)))
2949 ;; Mark this buffer as "prepared".
2950 (setq gnus-newsgroup-prepared t)
2951 (gnus-run-hooks 'gnus-summary-prepared-hook)
2954 (defun gnus-summary-prepare ()
2955 "Generate the summary buffer."
2957 (let ((buffer-read-only nil))
2959 (setq gnus-newsgroup-data nil
2960 gnus-newsgroup-data-reverse nil)
2961 (gnus-run-hooks 'gnus-summary-generate-hook)
2962 ;; Generate the buffer, either with threads or without.
2963 (when gnus-newsgroup-headers
2964 (gnus-summary-prepare-threads
2965 (if gnus-show-threads
2966 (gnus-sort-gathered-threads
2967 (funcall gnus-summary-thread-gathering-function
2969 (gnus-cut-threads (gnus-make-threads)))))
2970 ;; Unthreaded display.
2971 (gnus-sort-articles gnus-newsgroup-headers))))
2972 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2973 ;; Call hooks for modifying summary buffer.
2974 (goto-char (point-min))
2975 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2977 (defsubst gnus-general-simplify-subject (subject)
2978 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2981 ;; Truncate the subject.
2982 (gnus-simplify-subject-functions
2983 (gnus-map-function gnus-simplify-subject-functions subject))
2984 ((numberp gnus-summary-gather-subject-limit)
2985 (setq subject (gnus-simplify-subject-re subject))
2986 (if (> (length subject) gnus-summary-gather-subject-limit)
2987 (substring subject 0 gnus-summary-gather-subject-limit)
2989 ;; Fuzzily simplify it.
2990 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2991 (gnus-simplify-subject-fuzzy subject))
2992 ;; Just remove the leading "Re:".
2994 (gnus-simplify-subject-re subject))))
2996 (if (and gnus-summary-gather-exclude-subject
2997 (string-match gnus-summary-gather-exclude-subject subject))
2998 nil ; This article shouldn't be gathered
3001 (defun gnus-summary-simplify-subject-query ()
3002 "Query where the respool algorithm would put this article."
3004 (gnus-summary-select-article)
3005 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3007 (defun gnus-gather-threads-by-subject (threads)
3008 "Gather threads by looking at Subject headers."
3009 (if (not gnus-summary-make-false-root)
3011 (let ((hashtb (gnus-make-hashtable 1024))
3014 subject hthread whole-subject)
3016 (setq subject (gnus-general-simplify-subject
3017 (setq whole-subject (mail-header-subject
3020 (if (setq hthread (gnus-gethash subject hashtb))
3022 ;; We enter a dummy root into the thread, if we
3023 ;; haven't done that already.
3024 (unless (stringp (caar hthread))
3025 (setcar hthread (list whole-subject (car hthread))))
3026 ;; We add this new gathered thread to this gathered
3028 (setcdr (car hthread)
3029 (nconc (cdar hthread) (list (car threads))))
3030 ;; Remove it from the list of threads.
3031 (setcdr prev (cdr threads))
3032 (setq threads prev))
3033 ;; Enter this thread into the hash table.
3034 (gnus-sethash subject threads hashtb)))
3036 (setq threads (cdr threads)))
3039 (defun gnus-gather-threads-by-references (threads)
3040 "Gather threads by looking at References headers."
3041 (let ((idhashtb (gnus-make-hashtable 1024))
3042 (thhashtb (gnus-make-hashtable 1024))
3045 ids references id gthread gid entered ref)
3047 (when (setq references (mail-header-references (caar threads)))
3048 (setq id (mail-header-id (caar threads))
3049 ids (gnus-split-references references)
3051 (while (setq ref (pop ids))
3052 (setq ids (delete ref ids))
3053 (if (not (setq gid (gnus-gethash ref idhashtb)))
3055 (gnus-sethash ref id idhashtb)
3056 (gnus-sethash id threads thhashtb))
3057 (setq gthread (gnus-gethash gid thhashtb))
3059 ;; We enter a dummy root into the thread, if we
3060 ;; haven't done that already.
3061 (unless (stringp (caar gthread))
3062 (setcar gthread (list (mail-header-subject (caar gthread))
3064 ;; We add this new gathered thread to this gathered
3066 (setcdr (car gthread)
3067 (nconc (cdar gthread) (list (car threads)))))
3068 ;; Add it into the thread hash table.
3069 (gnus-sethash id gthread thhashtb)
3071 ;; Remove it from the list of threads.
3072 (setcdr prev (cdr threads))
3073 (setq threads prev))))
3075 (setq threads (cdr threads)))
3078 (defun gnus-sort-gathered-threads (threads)
3079 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3080 (let ((result threads))
3082 (when (stringp (caar threads))
3083 (setcdr (car threads)
3084 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3085 (setq threads (cdr threads)))
3088 (defun gnus-thread-loop-p (root thread)
3089 "Say whether ROOT is in THREAD."
3090 (let ((stack (list thread))
3093 (while (setq thread (pop stack))
3094 (setq th (cdr thread))
3096 (not (eq (caar th) root)))
3099 ;; We have found a loop.
3101 (setcdr thread (delq (car th) (cdr thread)))
3102 (if (boundp (setq ref-dep (intern "none"
3103 gnus-newsgroup-dependencies)))
3104 (setcdr (symbol-value ref-dep)
3105 (nconc (cdr (symbol-value ref-dep))
3107 (set ref-dep (list nil (car th))))
3110 ;; Push all the subthreads onto the stack.
3111 (push (cdr thread) stack)))
3114 (defun gnus-make-threads ()
3115 "Go through the dependency hashtb and find the roots. Return all threads."
3117 (while (catch 'infloop
3120 ;; Deal with self-referencing References loops.
3121 (when (and (car (symbol-value refs))
3128 (car (symbol-value refs)) thread))
3129 (cdr (symbol-value refs)))))))
3132 (unless (car (symbol-value refs))
3133 ;; These threads do not refer back to any other articles,
3134 ;; so they're roots.
3135 (setq threads (append (cdr (symbol-value refs)) threads))))
3136 gnus-newsgroup-dependencies)))
3139 ;; Build the thread tree.
3140 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3141 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3143 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3144 if it was already present.
3146 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3147 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3148 Message-IDs will be renamed be renamed to a unique Message-ID before
3151 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3152 (let* ((id (mail-header-id header))
3153 (id-dep (and id (intern id dependencies)))
3154 ref ref-dep ref-header)
3155 ;; Enter this `header' in the `dependencies' table.
3159 ;; The first two cases do the normal part: enter a new `header'
3160 ;; in the `dependencies' table.
3161 ((not (boundp id-dep))
3162 (set id-dep (list header)))
3163 ((null (car (symbol-value id-dep)))
3164 (setcar (symbol-value id-dep) header))
3166 ;; From here the `header' was already present in the
3167 ;; `dependencies' table.
3169 ;; Overrides an existing entry;
3170 ;; just set the header part of the entry.
3171 (setcar (symbol-value id-dep) header))
3173 ;; Renames the existing `header' to a unique Message-ID.
3174 ((not gnus-summary-ignore-duplicates)
3175 ;; An article with this Message-ID has already been seen.
3176 ;; We rename the Message-ID.
3177 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3179 (mail-header-set-id header id))
3181 ;; The last case ignores an existing entry, except it adds any
3182 ;; additional Xrefs (in case the two articles came from different
3184 ;; Also sets `header' to `nil' meaning that the `dependencies'
3185 ;; table was *not* modified.
3187 (mail-header-set-xref
3188 (car (symbol-value id-dep))
3189 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3191 (or (mail-header-xref header) "")))
3195 ;; First check if that we are not creating a References loop.
3196 (setq ref (gnus-parent-id (mail-header-references header)))
3198 (setq ref-dep (intern-soft ref dependencies))
3200 (setq ref-header (car (symbol-value ref-dep))))
3201 (if (string= id ref)
3202 ;; Yuk! This is a reference loop. Make the article be a
3205 (mail-header-set-references (car (symbol-value id-dep)) "none")
3207 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3208 (setq ref (gnus-parent-id (mail-header-references header)))
3209 (setq ref-dep (intern (or ref "none") dependencies))
3210 (if (boundp ref-dep)
3211 (setcdr (symbol-value ref-dep)
3212 (nconc (cdr (symbol-value ref-dep))
3213 (list (symbol-value id-dep))))
3214 (set ref-dep (list nil (symbol-value id-dep)))))
3217 (defun gnus-build-sparse-threads ()
3218 (let ((headers gnus-newsgroup-headers)
3219 (mail-parse-charset gnus-newsgroup-charset)
3220 (gnus-summary-ignore-duplicates t)
3221 header references generation relations
3222 subject child end new-child date)
3223 ;; First we create an alist of generations/relations, where
3224 ;; generations is how much we trust the relation, and the relation
3226 (gnus-message 7 "Making sparse threads...")
3228 (nnheader-set-temp-buffer " *gnus sparse threads*")
3229 (while (setq header (pop headers))
3230 (when (and (setq references (mail-header-references header))
3231 (not (string= references "")))
3233 (setq child (mail-header-id header)
3234 subject (mail-header-subject header)
3235 date (mail-header-date header)
3237 (while (search-backward ">" nil t)
3238 (setq end (1+ (point)))
3239 (when (search-backward "<" nil t)
3240 (setq new-child (buffer-substring (point) end))
3241 (push (list (incf generation)
3242 child (setq child new-child)
3246 (push (list (1+ generation) child nil subject) relations))
3248 (kill-buffer (current-buffer)))
3249 ;; Sort over trustworthiness.
3252 (when (gnus-dependencies-add-header
3253 (make-full-mail-header
3254 gnus-reffed-article-number
3255 (nth 3 relation) "" (or (nth 4 relation) "")
3257 (or (nth 2 relation) "") 0 0 "")
3258 gnus-newsgroup-dependencies nil)
3259 (push gnus-reffed-article-number gnus-newsgroup-limit)
3260 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3261 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3262 gnus-newsgroup-reads)
3263 (decf gnus-reffed-article-number)))
3264 (sort relations 'car-less-than-car))
3265 (gnus-message 7 "Making sparse threads...done")))
3267 (defun gnus-build-old-threads ()
3268 ;; Look at all the articles that refer back to old articles, and
3269 ;; fetch the headers for the articles that aren't there. This will
3270 ;; build complete threads - if the roots haven't been expired by the
3272 (let ((mail-parse-charset gnus-newsgroup-charset)
3276 (when (not (car (symbol-value refs)))
3277 (setq heads (cdr (symbol-value refs)))
3279 (if (memq (mail-header-number (caar heads))
3280 gnus-newsgroup-dormant)
3281 (setq heads (cdr heads))
3282 (setq id (symbol-name refs))
3283 (while (and (setq id (gnus-build-get-header id))
3284 (not (car (gnus-id-to-thread id)))))
3285 (setq heads nil)))))
3286 gnus-newsgroup-dependencies)))
3288 ;; This function has to be called with point after the article number
3289 ;; on the beginning of the line.
3290 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3291 (let ((eol (gnus-point-at-eol))
3292 (buffer (current-buffer))
3295 ;; overview: [num subject from date id refs chars lines misc]
3298 (narrow-to-region (point) eol)
3303 (make-full-mail-header
3305 (funcall gnus-decode-encoded-word-function
3306 (nnheader-nov-field)) ; subject
3307 (funcall gnus-decode-encoded-word-function
3308 (nnheader-nov-field)) ; from
3309 (nnheader-nov-field) ; date
3310 (nnheader-nov-read-message-id) ; id
3311 (nnheader-nov-field) ; refs
3312 (nnheader-nov-read-integer) ; chars
3313 (nnheader-nov-read-integer) ; lines
3315 (if (looking-at "Xref: ")
3316 (goto-char (match-end 0)))
3317 (nnheader-nov-field)) ; Xref
3318 (nnheader-nov-parse-extra)))) ; extra
3322 (when gnus-alter-header-function
3323 (funcall gnus-alter-header-function header))
3324 (gnus-dependencies-add-header header dependencies force-new)))
3326 (defun gnus-build-get-header (id)
3327 "Look through the buffer of NOV lines and find the header to ID.
3328 Enter this line into the dependencies hash table, and return
3329 the id of the parent article (if any)."
3330 (let ((deps gnus-newsgroup-dependencies)
3334 (set-buffer nntp-server-buffer)
3335 (let ((case-fold-search nil))
3336 (goto-char (point-min))
3337 (while (and (not found)
3338 (search-forward id nil t))
3340 (setq found (looking-at
3341 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3342 (regexp-quote id))))
3343 (or found (beginning-of-line 2)))
3347 (setq header (gnus-nov-parse-line
3348 (read (current-buffer)) deps))
3349 (gnus-parent-id (mail-header-references header))))))
3351 (let ((number (mail-header-number header)))
3352 (push number gnus-newsgroup-limit)
3353 (push header gnus-newsgroup-headers)
3354 (if (memq number gnus-newsgroup-unselected)
3356 (push number gnus-newsgroup-unreads)
3357 (setq gnus-newsgroup-unselected
3358 (delq number gnus-newsgroup-unselected)))
3359 (push number gnus-newsgroup-ancient)))))))
3361 (defun gnus-build-all-threads ()
3362 "Read all the headers."
3363 (let ((gnus-summary-ignore-duplicates t)
3364 (mail-parse-charset gnus-newsgroup-charset)
3365 (dependencies gnus-newsgroup-dependencies)
3368 (set-buffer nntp-server-buffer)
3369 (let ((case-fold-search nil))
3370 (goto-char (point-min))
3373 (setq article (read (current-buffer))
3374 header (gnus-nov-parse-line article dependencies)))
3377 (set-buffer gnus-summary-buffer)
3378 (push header gnus-newsgroup-headers)
3379 (if (memq (setq article (mail-header-number header))
3380 gnus-newsgroup-unselected)
3382 (push article gnus-newsgroup-unreads)
3383 (setq gnus-newsgroup-unselected
3384 (delq article gnus-newsgroup-unselected)))
3385 (push article gnus-newsgroup-ancient)))
3386 (forward-line 1)))))))
3388 (defun gnus-summary-update-article-line (article header)
3389 "Update the line for ARTICLE using HEADERS."
3390 (let* ((id (mail-header-id header))
3391 (thread (gnus-id-to-thread id)))
3393 (error "Article in no thread"))
3394 ;; Update the thread.
3395 (setcar thread header)
3396 (gnus-summary-goto-subject article)
3397 (let* ((datal (gnus-data-find-list article))
3399 (length (when (cdr datal)
3400 (- (gnus-data-pos data)
3401 (gnus-data-pos (cadr datal)))))
3402 (buffer-read-only nil)
3403 (level (gnus-summary-thread-level)))
3405 (gnus-summary-insert-line
3406 header level nil (gnus-article-mark article)
3407 (memq article gnus-newsgroup-replied)
3408 (memq article gnus-newsgroup-expirable)
3409 ;; Only insert the Subject string when it's different
3410 ;; from the previous Subject string.
3415 (mail-header-subject
3418 (gnus-data-find-list
3420 (gnus-data-list t)))))
3421 ;; Error on the side of excessive subjects.
3423 (mail-header-subject header)))
3425 (mail-header-subject header))
3426 nil (cdr (assq article gnus-newsgroup-scored))
3427 (memq article gnus-newsgroup-processable))
3429 (gnus-data-update-list
3430 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3432 (defun gnus-summary-update-article (article &optional iheader)
3433 "Update ARTICLE in the summary buffer."
3434 (set-buffer gnus-summary-buffer)
3435 (let* ((header (gnus-summary-article-header article))
3436 (id (mail-header-id header))
3437 (data (gnus-data-find article))
3438 (thread (gnus-id-to-thread id))
3439 (references (mail-header-references header))
3443 (when (and references
3444 (not (equal "" references)))
3447 (buffer-read-only nil)
3453 (delq thread parent)))
3454 (if (gnus-summary-insert-subject id header)
3455 ;; Set the (possibly) new article number in the data structure.
3456 (gnus-data-set-number data (gnus-id-to-article id))
3460 (defun gnus-rebuild-thread (id &optional line)
3461 "Rebuild the thread containing ID.
3462 If LINE, insert the rebuilt thread starting on line LINE."
3463 (let ((buffer-read-only nil)
3464 old-pos current thread data)
3465 (if (not gnus-show-threads)
3466 (setq thread (list (car (gnus-id-to-thread id))))
3467 ;; Get the thread this article is part of.
3468 (setq thread (gnus-remove-thread id)))
3469 (setq old-pos (gnus-point-at-bol))
3470 (setq current (save-excursion
3471 (and (zerop (forward-line -1))
3472 (gnus-summary-article-number))))
3473 ;; If this is a gathered thread, we have to go some re-gathering.
3474 (when (stringp (car thread))
3475 (let ((subject (car thread))
3477 (setq thread (cdr thread))
3479 (unless (memq (setq thr (gnus-id-to-thread
3481 (mail-header-id (caar thread)))))
3484 (setq thread (cdr thread)))
3485 ;; We now have all (unique) roots.
3486 (if (= (length roots) 1)
3487 ;; All the loose roots are now one solid root.
3488 (setq thread (car roots))
3489 (setq thread (cons subject (gnus-sort-threads roots))))))
3491 ;; We then insert this thread into the summary buffer.
3493 (goto-char (point-min))
3494 (forward-line (1- line)))
3495 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3496 (if gnus-show-threads
3497 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3498 (gnus-summary-prepare-unthreaded thread))
3499 (setq data (nreverse gnus-newsgroup-data))
3500 (setq threads gnus-newsgroup-threads))
3501 ;; We splice the new data into the data structure.
3502 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3503 ;;!!! then we want to insert at the beginning of the buffer.
3504 ;;!!! That happens to be true with Gnus now, but that may
3505 ;;!!! change in the future. Perhaps.
3506 (gnus-data-enter-list
3507 (if line nil current) data (- (point) old-pos))
3508 (setq gnus-newsgroup-threads
3509 (nconc threads gnus-newsgroup-threads))
3510 (gnus-data-compute-positions))))
3512 (defun gnus-number-to-header (number)
3513 "Return the header for article NUMBER."
3514 (let ((headers gnus-newsgroup-headers))
3516 (not (= number (mail-header-number (car headers)))))
3521 (defun gnus-parent-headers (in-headers &optional generation)
3522 "Return the headers of the GENERATIONeth parent of HEADERS."
3524 (setq generation 1))
3526 (headers in-headers)
3529 (not (zerop generation))
3530 (setq references (mail-header-references headers)))
3531 (setq headers (if (and references
3532 (setq parent (gnus-parent-id references)))
3533 (car (gnus-id-to-thread parent))
3536 (and (not (eq headers in-headers))
3539 (defun gnus-id-to-thread (id)
3540 "Return the (sub-)thread where ID appears."
3541 (gnus-gethash id gnus-newsgroup-dependencies))
3543 (defun gnus-id-to-article (id)
3544 "Return the article number of ID."
3545 (let ((thread (gnus-id-to-thread id)))
3548 (mail-header-number (car thread)))))
3550 (defun gnus-id-to-header (id)
3551 "Return the article headers of ID."
3552 (car (gnus-id-to-thread id)))
3554 (defun gnus-article-displayed-root-p (article)
3555 "Say whether ARTICLE is a root(ish) article."
3556 (let ((level (gnus-summary-thread-level article))
3557 (refs (mail-header-references (gnus-summary-article-header article)))
3563 ((null (gnus-parent-id refs)) t)
3565 (null (setq particle (gnus-id-to-article
3566 (gnus-parent-id refs))))
3567 (null (gnus-summary-thread-level particle)))))))
3569 (defun gnus-root-id (id)
3570 "Return the id of the root of the thread where ID appears."
3572 (while (and id (setq prev (car (gnus-id-to-thread id))))
3574 id (gnus-parent-id (mail-header-references prev))))
3577 (defun gnus-articles-in-thread (thread)
3578 "Return the list of articles in THREAD."
3579 (cons (mail-header-number (car thread))
3580 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3582 (defun gnus-remove-thread (id &optional dont-remove)
3583 "Remove the thread that has ID in it."
3584 (let (headers thread last-id)
3585 ;; First go up in this thread until we find the root.
3586 (setq last-id (gnus-root-id id)
3587 headers (message-flatten-list (gnus-id-to-thread last-id)))
3588 ;; We have now found the real root of this thread. It might have
3589 ;; been gathered into some loose thread, so we have to search
3590 ;; through the threads to find the thread we wanted.
3591 (let ((threads gnus-newsgroup-threads)
3594 (setq sub (car threads))
3595 (if (stringp (car sub))
3596 ;; This is a gathered thread, so we look at the roots
3597 ;; below it to find whether this article is in this
3600 (setq sub (cdr sub))
3602 (when (member (caar sub) headers)
3603 (setq thread (car threads)
3606 (setq sub (cdr sub))))
3607 ;; It's an ordinary thread, so we check it.
3608 (when (eq (car sub) (car headers))
3611 (setq threads (cdr threads)))
3612 ;; If this article is in no thread, then it's a root.
3615 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3616 (setq thread (gnus-id-to-thread last-id)))
3619 thread ; We return this thread.
3621 (if (stringp (car thread))
3623 ;; If we use dummy roots, then we have to remove the
3624 ;; dummy root as well.
3625 (when (eq gnus-summary-make-false-root 'dummy)
3626 ;; We go to the dummy root by going to
3627 ;; the first sub-"thread", and then one line up.
3628 (gnus-summary-goto-article
3629 (mail-header-number (caadr thread)))
3632 (gnus-data-compute-positions))
3633 (setq thread (cdr thread))
3635 (gnus-remove-thread-1 (car thread))
3636 (setq thread (cdr thread))))
3637 (gnus-remove-thread-1 thread))))))))
3639 (defun gnus-remove-thread-1 (thread)
3640 "Remove the thread THREAD recursively."
3641 (let ((number (mail-header-number (pop thread)))
3643 (setq thread (reverse thread))
3645 (gnus-remove-thread-1 (pop thread)))
3646 (when (setq d (gnus-data-find number))
3647 (goto-char (gnus-data-pos d))
3648 (gnus-summary-show-thread)
3651 (- (gnus-point-at-bol)
3653 (1+ (gnus-point-at-eol))
3654 (gnus-delete-line)))))))
3656 (defun gnus-sort-threads-1 (threads func)
3657 (sort (mapcar (lambda (thread)
3660 (gnus-sort-threads-1 (cdr thread) func))))
3663 (defun gnus-sort-threads (threads)
3665 (if (not gnus-thread-sort-functions)
3667 (gnus-message 8 "Sorting threads...")
3669 (gnus-sort-threads-1
3671 (gnus-make-sort-function gnus-thread-sort-functions))
3672 (gnus-message 8 "Sorting threads...done"))))
3674 (defun gnus-sort-articles (articles)
3676 (when gnus-article-sort-functions
3677 (gnus-message 7 "Sorting articles...")
3679 (setq gnus-newsgroup-headers
3680 (sort articles (gnus-make-sort-function
3681 gnus-article-sort-functions)))
3682 (gnus-message 7 "Sorting articles...done"))))
3684 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3685 (defmacro gnus-thread-header (thread)
3686 "Return header of first article in THREAD.
3687 Note that THREAD must never, ever be anything else than a variable -
3688 using some other form will lead to serious barfage."
3689 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3690 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3691 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3694 (defsubst gnus-article-sort-by-number (h1 h2)
3695 "Sort articles by article number."
3696 (< (mail-header-number h1)
3697 (mail-header-number h2)))
3699 (defun gnus-thread-sort-by-number (h1 h2)
3700 "Sort threads by root article number."
3701 (gnus-article-sort-by-number
3702 (gnus-thread-header h1) (gnus-thread-header h2)))
3704 (defsubst gnus-article-sort-by-lines (h1 h2)
3705 "Sort articles by article Lines header."
3706 (< (mail-header-lines h1)
3707 (mail-header-lines h2)))
3709 (defun gnus-thread-sort-by-lines (h1 h2)
3710 "Sort threads by root article Lines header."
3711 (gnus-article-sort-by-lines
3712 (gnus-thread-header h1) (gnus-thread-header h2)))
3714 (defsubst gnus-article-sort-by-chars (h1 h2)
3715 "Sort articles by octet length."
3716 (< (mail-header-chars h1)
3717 (mail-header-chars h2)))
3719 (defun gnus-thread-sort-by-chars (h1 h2)
3720 "Sort threads by root article octet length."
3721 (gnus-article-sort-by-chars
3722 (gnus-thread-header h1) (gnus-thread-header h2)))
3724 (defsubst gnus-article-sort-by-author (h1 h2)
3725 "Sort articles by root author."
3727 (let ((extract (funcall
3728 gnus-extract-address-components
3729 (mail-header-from h1))))
3730 (or (car extract) (cadr extract) ""))
3731 (let ((extract (funcall
3732 gnus-extract-address-components
3733 (mail-header-from h2))))
3734 (or (car extract) (cadr extract) ""))))
3736 (defun gnus-thread-sort-by-author (h1 h2)
3737 "Sort threads by root author."
3738 (gnus-article-sort-by-author
3739 (gnus-thread-header h1) (gnus-thread-header h2)))
3741 (defsubst gnus-article-sort-by-subject (h1 h2)
3742 "Sort articles by root subject."
3744 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3745 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3747 (defun gnus-thread-sort-by-subject (h1 h2)
3748 "Sort threads by root subject."
3749 (gnus-article-sort-by-subject
3750 (gnus-thread-header h1) (gnus-thread-header h2)))
3752 (defsubst gnus-article-sort-by-date (h1 h2)
3753 "Sort articles by root article date."
3755 (gnus-date-get-time (mail-header-date h1))
3756 (gnus-date-get-time (mail-header-date h2))))
3758 (defun gnus-thread-sort-by-date (h1 h2)
3759 "Sort threads by root article date."
3760 (gnus-article-sort-by-date
3761 (gnus-thread-header h1) (gnus-thread-header h2)))
3763 (defsubst gnus-article-sort-by-score (h1 h2)
3764 "Sort articles by root article score.
3765 Unscored articles will be counted as having a score of zero."
3766 (> (or (cdr (assq (mail-header-number h1)
3767 gnus-newsgroup-scored))
3768 gnus-summary-default-score 0)
3769 (or (cdr (assq (mail-header-number h2)
3770 gnus-newsgroup-scored))
3771 gnus-summary-default-score 0)))
3773 (defun gnus-thread-sort-by-score (h1 h2)
3774 "Sort threads by root article score."
3775 (gnus-article-sort-by-score
3776 (gnus-thread-header h1) (gnus-thread-header h2)))
3778 (defun gnus-thread-sort-by-total-score (h1 h2)
3779 "Sort threads by the sum of all scores in the thread.
3780 Unscored articles will be counted as having a score of zero."
3781 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3783 (defun gnus-thread-total-score (thread)
3784 ;; This function find the total score of THREAD.
3785 (cond ((null thread)
3788 (if (stringp (car thread))
3789 (apply gnus-thread-score-function 0
3790 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3791 (gnus-thread-total-score-1 thread)))
3793 (gnus-thread-total-score-1 (list thread)))))
3795 (defun gnus-thread-total-score-1 (root)
3796 ;; This function find the total score of the thread below ROOT.
3797 (setq root (car root))
3798 (apply gnus-thread-score-function
3800 (mapcar 'gnus-thread-total-score
3801 (cdr (gnus-id-to-thread (mail-header-id root))))
3802 (when (> (mail-header-number root) 0)
3803 (list (or (cdr (assq (mail-header-number root)
3804 gnus-newsgroup-scored))
3805 gnus-summary-default-score 0))))
3806 (list gnus-summary-default-score)
3809 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3810 (defvar gnus-tmp-prev-subject nil)
3811 (defvar gnus-tmp-false-parent nil)
3812 (defvar gnus-tmp-root-expunged nil)
3813 (defvar gnus-tmp-dummy-line nil)
3815 (defvar gnus-tmp-header)
3816 (defun gnus-extra-header (type &optional header)
3817 "Return the extra header of TYPE."
3818 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3821 (defun gnus-summary-prepare-threads (threads)
3822 "Prepare summary buffer from THREADS and indentation LEVEL.
3823 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3824 or a straight list of headers."
3825 (gnus-message 7 "Generating summary...")
3827 (setq gnus-newsgroup-threads threads)
3830 (let ((gnus-tmp-level 0)
3831 (default-score (or gnus-summary-default-score 0))
3832 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3833 thread number subject stack state gnus-tmp-gathered beg-match
3834 new-roots gnus-tmp-new-adopts thread-end
3835 gnus-tmp-header gnus-tmp-unread
3836 gnus-tmp-replied gnus-tmp-subject-or-nil
3837 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3838 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3839 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3841 (setq gnus-tmp-prev-subject nil)
3843 (if (vectorp (car threads))
3844 ;; If this is a straight (sic) list of headers, then a
3845 ;; threaded summary display isn't required, so we just create
3846 ;; an unthreaded one.
3847 (gnus-summary-prepare-unthreaded threads)
3849 ;; Do the threaded display.
3851 (while (or threads stack gnus-tmp-new-adopts new-roots)
3853 (if (and (= gnus-tmp-level 0)
3856 (not gnus-tmp-false-parent)
3857 (or gnus-tmp-new-adopts new-roots))
3858 (if gnus-tmp-new-adopts
3859 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3860 thread (list (car gnus-tmp-new-adopts))
3861 gnus-tmp-header (caar thread)
3862 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3864 (setq thread (list (car new-roots))
3865 gnus-tmp-header (caar thread)
3866 new-roots (cdr new-roots))))
3869 ;; If there are some threads, we do them before the
3870 ;; threads on the stack.
3871 (setq thread threads
3872 gnus-tmp-header (caar thread))
3873 ;; There were no current threads, so we pop something off
3875 (setq state (car stack)
3876 gnus-tmp-level (car state)
3879 gnus-tmp-header (caar thread))))
3881 (setq gnus-tmp-false-parent nil)
3882 (setq gnus-tmp-root-expunged nil)
3883 (setq thread-end nil)
3885 (if (stringp gnus-tmp-header)
3886 ;; The header is a dummy root.
3888 ((eq gnus-summary-make-false-root 'adopt)
3889 ;; We let the first article adopt the rest.
3890 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3892 (setq gnus-tmp-gathered
3894 (lambda (h) (mail-header-number (car h)))
3897 (setq thread (cons (list (caar thread)
3900 (setq gnus-tmp-level -1
3901 gnus-tmp-false-parent t))
3902 ((eq gnus-summary-make-false-root 'empty)
3903 ;; We print adopted articles with empty subject fields.
3904 (setq gnus-tmp-gathered
3906 (lambda (h) (mail-header-number (car h)))
3909 (setq gnus-tmp-level -1))
3910 ((eq gnus-summary-make-false-root 'dummy)
3911 ;; We remember that we probably want to output a dummy
3913 (setq gnus-tmp-dummy-line gnus-tmp-header)
3914 (setq gnus-tmp-prev-subject gnus-tmp-header))
3916 ;; We do not make a root for the gathered
3917 ;; sub-threads at all.
3918 (setq gnus-tmp-level -1)))
3920 (setq number (mail-header-number gnus-tmp-header)
3921 subject (mail-header-subject gnus-tmp-header))
3924 ;; If the thread has changed subject, we might want to make
3925 ;; this subthread into a root.
3926 ((and (null gnus-thread-ignore-subject)
3927 (not (zerop gnus-tmp-level))
3928 gnus-tmp-prev-subject
3930 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3931 (setq new-roots (nconc new-roots (list (car thread)))
3933 gnus-tmp-header nil))
3934 ;; If the article lies outside the current limit,
3935 ;; then we do not display it.
3936 ((not (memq number gnus-newsgroup-limit))
3937 (setq gnus-tmp-gathered
3939 (lambda (h) (mail-header-number (car h)))
3942 (setq gnus-tmp-new-adopts (if (cdar thread)
3943 (append gnus-tmp-new-adopts
3945 gnus-tmp-new-adopts)
3947 gnus-tmp-header nil)
3948 (when (zerop gnus-tmp-level)
3949 (setq gnus-tmp-root-expunged t)))
3950 ;; Perhaps this article is to be marked as read?
3951 ((and gnus-summary-mark-below
3952 (< (or (cdr (assq number gnus-newsgroup-scored))
3954 gnus-summary-mark-below)
3955 ;; Don't touch sparse articles.
3956 (not (gnus-summary-article-sparse-p number))
3957 (not (gnus-summary-article-ancient-p number)))
3958 (setq gnus-newsgroup-unreads
3959 (delq number gnus-newsgroup-unreads))
3960 (if gnus-newsgroup-auto-expire
3961 (push number gnus-newsgroup-expirable)
3962 (push (cons number gnus-low-score-mark)
3963 gnus-newsgroup-reads))))
3965 (when gnus-tmp-header
3966 ;; We may have an old dummy line to output before this
3968 (when (and gnus-tmp-dummy-line
3971 (mail-header-subject gnus-tmp-header)))
3972 (gnus-summary-insert-dummy-line
3973 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3974 (setq gnus-tmp-dummy-line nil))
3976 ;; Compute the mark.
3977 (setq gnus-tmp-unread (gnus-article-mark number))
3979 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3980 gnus-tmp-header gnus-tmp-level)
3981 gnus-newsgroup-data)
3983 ;; Actually insert the line.
3985 gnus-tmp-subject-or-nil
3987 ((and gnus-thread-ignore-subject
3988 gnus-tmp-prev-subject
3989 (not (inline (gnus-subject-equal
3990 gnus-tmp-prev-subject subject))))
3992 ((zerop gnus-tmp-level)
3993 (if (and (eq gnus-summary-make-false-root 'empty)
3994 (memq number gnus-tmp-gathered)
3995 gnus-tmp-prev-subject
3996 (inline (gnus-subject-equal
3997 gnus-tmp-prev-subject subject)))
3998 gnus-summary-same-subject
4000 (t gnus-summary-same-subject)))
4001 (if (and (eq gnus-summary-make-false-root 'adopt)
4002 (= gnus-tmp-level 1)
4003 (memq number gnus-tmp-gathered))
4004 (setq gnus-tmp-opening-bracket ?\<
4005 gnus-tmp-closing-bracket ?\>)
4006 (setq gnus-tmp-opening-bracket ?\[
4007 gnus-tmp-closing-bracket ?\]))
4009 gnus-tmp-indentation
4010 (aref gnus-thread-indent-array gnus-tmp-level)
4011 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4012 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4013 gnus-summary-default-score 0)
4015 (if (or (null gnus-summary-default-score)
4016 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4017 gnus-summary-zcore-fuzz))
4019 (if (< gnus-tmp-score gnus-summary-default-score)
4020 gnus-score-below-mark gnus-score-over-mark))
4022 (cond ((memq number gnus-newsgroup-processable)
4024 ((memq number gnus-newsgroup-cached)
4026 ((memq number gnus-newsgroup-replied)
4028 ((memq number gnus-newsgroup-saved)
4030 (t gnus-unread-mark))
4031 gnus-tmp-from (mail-header-from gnus-tmp-header)
4034 ((string-match "<[^>]+> *$" gnus-tmp-from)
4035 (setq beg-match (match-beginning 0))
4036 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4037 (substring gnus-tmp-from (1+ (match-beginning 0))
4038 (1- (match-end 0))))
4039 (substring gnus-tmp-from 0 beg-match)))
4040 ((string-match "(.+)" gnus-tmp-from)
4041 (substring gnus-tmp-from
4042 (1+ (match-beginning 0)) (1- (match-end 0))))
4044 (when (string= gnus-tmp-name "")
4045 (setq gnus-tmp-name gnus-tmp-from))
4046 (unless (numberp gnus-tmp-lines)
4047 (setq gnus-tmp-lines 0))
4048 (gnus-put-text-property
4050 (progn (eval gnus-summary-line-format-spec) (point))
4051 'gnus-number number)
4054 (gnus-run-hooks 'gnus-summary-update-hook)
4057 (setq gnus-tmp-prev-subject subject)))
4059 (when (nth 1 thread)
4060 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4061 (incf gnus-tmp-level)
4062 (setq threads (if thread-end nil (cdar thread)))
4064 (setq gnus-tmp-level 0)))))
4065 (gnus-message 7 "Generating summary...done"))
4067 (defun gnus-summary-prepare-unthreaded (headers)
4068 "Generate an unthreaded summary buffer based on HEADERS."
4069 (let (header number mark)
4074 ;; We may have to root out some bad articles...
4075 (when (memq (setq number (mail-header-number
4076 (setq header (pop headers))))
4077 gnus-newsgroup-limit)
4078 ;; Mark article as read when it has a low score.
4079 (when (and gnus-summary-mark-below
4080 (< (or (cdr (assq number gnus-newsgroup-scored))
4081 gnus-summary-default-score 0)
4082 gnus-summary-mark-below)
4083 (not (gnus-summary-article-ancient-p number)))
4084 (setq gnus-newsgroup-unreads
4085 (delq number gnus-newsgroup-unreads))
4086 (if gnus-newsgroup-auto-expire
4087 (push number gnus-newsgroup-expirable)
4088 (push (cons number gnus-low-score-mark)
4089 gnus-newsgroup-reads)))
4091 (setq mark (gnus-article-mark number))
4092 (push (gnus-data-make number mark (1+ (point)) header 0)
4093 gnus-newsgroup-data)
4094 (gnus-summary-insert-line
4096 mark (memq number gnus-newsgroup-replied)
4097 (memq number gnus-newsgroup-expirable)
4098 (mail-header-subject header) nil
4099 (cdr (assq number gnus-newsgroup-scored))
4100 (memq number gnus-newsgroup-processable))))))
4102 (defun gnus-summary-remove-list-identifiers ()
4103 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4104 (let ((regexp (if (stringp gnus-list-identifiers)
4105 gnus-list-identifiers
4106 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4107 (dolist (header gnus-newsgroup-headers)
4108 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4109 " *\\)\\)+\\(Re: +\\)?\\)")
4110 (mail-header-subject header))
4111 (mail-header-set-subject
4112 header (concat (substring (mail-header-subject header)
4113 0 (match-beginning 1))
4115 (match-string 3 (mail-header-subject header))
4116 (match-string 5 (mail-header-subject header)))
4117 (substring (mail-header-subject header)
4118 (match-end 1))))))))
4120 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4121 "Select newsgroup GROUP.
4122 If READ-ALL is non-nil, all articles in the group are selected.
4123 If SELECT-ARTICLES, only select those articles from GROUP."
4124 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4125 ;;!!! Dirty hack; should be removed.
4126 (gnus-summary-ignore-duplicates
4127 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4129 gnus-summary-ignore-duplicates))
4130 (info (nth 2 entry))
4131 articles fetched-articles cached)
4133 (unless (gnus-check-server
4134 (setq gnus-current-select-method
4135 (gnus-find-method-for-group group)))
4136 (error "Couldn't open server"))
4138 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4139 (gnus-activate-group group) ; Or we can activate it...
4140 (progn ; Or we bug out.
4141 (when (equal major-mode 'gnus-summary-mode)
4142 (kill-buffer (current-buffer)))
4143 (error "Couldn't request group %s: %s"
4144 group (gnus-status-message group))))
4146 (unless (gnus-request-group group t)
4147 (when (equal major-mode 'gnus-summary-mode)
4148 (kill-buffer (current-buffer)))
4149 (error "Couldn't request group %s: %s"
4150 group (gnus-status-message group)))
4152 (setq gnus-newsgroup-name group)
4153 (setq gnus-newsgroup-unselected nil)
4154 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4155 (gnus-summary-setup-default-charset)
4157 ;; Adjust and set lists of article marks.
4159 (gnus-adjust-marked-articles info))
4161 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4162 (when (gnus-virtual-group-p group)
4163 (setq cached gnus-newsgroup-cached))
4165 (setq gnus-newsgroup-unreads
4166 (gnus-set-difference
4167 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4168 gnus-newsgroup-dormant))
4170 (setq gnus-newsgroup-processable nil)
4172 (gnus-update-read-articles group gnus-newsgroup-unreads)
4174 (if (setq articles select-articles)
4175 (setq gnus-newsgroup-unselected
4176 (gnus-sorted-intersection
4177 gnus-newsgroup-unreads
4178 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4179 (setq articles (gnus-articles-to-read group read-all)))
4183 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4185 ((eq articles 0) nil)
4187 ;; Init the dependencies hash table.
4188 (setq gnus-newsgroup-dependencies
4189 (gnus-make-hashtable (length articles)))
4190 (gnus-set-global-variables)
4191 ;; Retrieve the headers and read them in.
4192 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4193 (setq gnus-newsgroup-headers
4195 (setq gnus-headers-retrieved-by
4196 (gnus-retrieve-headers
4197 articles gnus-newsgroup-name
4198 ;; We might want to fetch old headers, but
4199 ;; not if there is only 1 article.
4201 (not (eq gnus-fetch-old-headers 'some))
4202 (not (numberp gnus-fetch-old-headers)))
4203 (> (length articles) 1))
4204 gnus-fetch-old-headers))))
4205 (gnus-get-newsgroup-headers-xover
4206 articles nil nil gnus-newsgroup-name t)
4207 (gnus-get-newsgroup-headers)))
4208 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4210 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4212 (setq gnus-newsgroup-cached cached))
4214 ;; Suppress duplicates?
4215 (when gnus-suppress-duplicates
4216 (gnus-dup-suppress-articles))
4218 ;; Set the initial limit.
4219 (setq gnus-newsgroup-limit (copy-sequence articles))
4220 ;; Remove canceled articles from the list of unread articles.
4221 (setq gnus-newsgroup-unreads
4222 (gnus-set-sorted-intersection
4223 gnus-newsgroup-unreads
4224 (setq fetched-articles
4225 (mapcar (lambda (headers) (mail-header-number headers))
4226 gnus-newsgroup-headers))))
4227 ;; Removed marked articles that do not exist.
4228 (gnus-update-missing-marks
4229 (gnus-sorted-complement fetched-articles articles))
4230 ;; We might want to build some more threads first.
4231 (when (and gnus-fetch-old-headers
4232 (eq gnus-headers-retrieved-by 'nov))
4233 (if (eq gnus-fetch-old-headers 'invisible)
4234 (gnus-build-all-threads)
4235 (gnus-build-old-threads)))
4236 ;; Let the Gnus agent mark articles as read.
4238 (gnus-agent-get-undownloaded-list))
4239 ;; Remove list identifiers from subject
4240 (when gnus-list-identifiers
4241 (gnus-summary-remove-list-identifiers))
4242 ;; Check whether auto-expire is to be done in this group.
4243 (setq gnus-newsgroup-auto-expire
4244 (gnus-group-auto-expirable-p group))
4245 ;; Set up the article buffer now, if necessary.
4246 (unless gnus-single-article-buffer
4247 (gnus-article-setup-buffer))
4248 ;; First and last article in this newsgroup.
4249 (when gnus-newsgroup-headers
4250 (setq gnus-newsgroup-begin
4251 (mail-header-number (car gnus-newsgroup-headers))
4254 (gnus-last-element gnus-newsgroup-headers))))
4255 ;; GROUP is successfully selected.
4256 (or gnus-newsgroup-headers t)))))
4258 (defun gnus-articles-to-read (group &optional read-all)
4259 "Find out what articles the user wants to read."
4261 ;; Select all articles if `read-all' is non-nil, or if there
4262 ;; are no unread articles.
4264 (and (zerop (length gnus-newsgroup-marked))
4265 (zerop (length gnus-newsgroup-unreads)))
4266 (eq (gnus-group-find-parameter group 'display)
4269 (gnus-uncompress-range (gnus-active group))
4270 (gnus-cache-articles-in-group group))
4271 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4272 (copy-sequence gnus-newsgroup-unreads))
4274 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4275 (scored (length scored-list))
4276 (number (length articles))
4277 (marked (+ (length gnus-newsgroup-marked)
4278 (length gnus-newsgroup-dormant)))
4286 ((and (or (<= scored marked) (= scored number))
4287 (numberp gnus-large-newsgroup)
4288 (> number gnus-large-newsgroup))
4292 "How many articles from %s (default %d): "
4293 (gnus-limit-string gnus-newsgroup-name 35)
4295 (if (string-match "^[ \t]*$" input) number input)))
4296 ((and (> scored marked) (< scored number)
4297 (> (- scored number) 20))
4300 (format "%s %s (%d scored, %d total): "
4301 "How many articles from"
4302 group scored number))))
4303 (if (string-match "^[ \t]*$" input)
4307 (message "Quit getting the articles to read")
4309 (setq select (if (stringp select) (string-to-number select) select))
4310 (if (or (null select) (zerop select))
4312 (if (and (not (zerop scored)) (<= (abs select) scored))
4314 (setq articles (sort scored-list '<))
4315 (setq number (length articles)))
4316 (setq articles (copy-sequence articles)))
4318 (when (< (abs select) number)
4320 ;; Select the N oldest articles.
4321 (setcdr (nthcdr (1- (abs select)) articles) nil)
4322 ;; Select the N most recent articles.
4323 (setq articles (nthcdr (- number select) articles))))
4324 (setq gnus-newsgroup-unselected
4325 (gnus-sorted-intersection
4326 gnus-newsgroup-unreads
4327 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4328 (when gnus-alter-articles-to-read-function
4329 (setq gnus-newsgroup-unreads
4331 (funcall gnus-alter-articles-to-read-function
4332 gnus-newsgroup-name gnus-newsgroup-unreads)
4336 (defun gnus-killed-articles (killed articles)
4339 (when (inline (gnus-member-of-range (car articles) killed))
4340 (push (car articles) out))
4341 (setq articles (cdr articles)))
4344 (defun gnus-uncompress-marks (marks)
4345 "Uncompress the mark ranges in MARKS."
4346 (let ((uncompressed '(score bookmark))
4349 (if (memq (caar marks) uncompressed)
4350 (push (car marks) out)
4351 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4352 (setq marks (cdr marks)))
4355 (defun gnus-adjust-marked-articles (info)
4356 "Set all article lists and remove all marks that are no longer valid."
4357 (let* ((marked-lists (gnus-info-marks info))
4358 (active (gnus-active (gnus-info-group info)))
4361 (types gnus-article-mark-lists)
4362 (uncompressed '(score bookmark killed))
4363 marks var articles article mark)
4366 (setq marks (pop marked-lists))
4367 (set (setq var (intern (format "gnus-newsgroup-%s"
4368 (car (rassq (setq mark (car marks))
4370 (if (memq (car marks) uncompressed) (cdr marks)
4371 (gnus-uncompress-range (cdr marks))))
4373 (setq articles (symbol-value var))
4375 ;; All articles have to be subsets of the active articles.
4377 ;; Adjust "simple" lists.
4378 ((memq mark '(tick dormant expire reply save))
4380 (when (or (< (setq article (pop articles)) min) (> article max))
4381 (set var (delq article (symbol-value var))))))
4383 ((memq mark uncompressed)
4384 (when (not (listp (cdr (symbol-value var))))
4385 (set var (list (symbol-value var))))
4386 (when (not (listp (cdr articles)))
4387 (setq articles (list articles)))
4389 (when (or (not (consp (setq article (pop articles))))
4390 (< (car article) min)
4391 (> (car article) max))
4392 (set var (delq article (symbol-value var))))))))))
4394 (defun gnus-update-missing-marks (missing)
4395 "Go through the list of MISSING articles and remove them from the mark lists."
4397 (let ((types gnus-article-mark-lists)
4399 ;; Go through all types.
4401 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4402 (when (symbol-value var)
4403 ;; This list has articles. So we delete all missing articles
4407 (set var (delq (pop m) (symbol-value var)))))))))
4409 (defun gnus-update-marks ()
4410 "Enter the various lists of marked articles into the newsgroup info list."
4411 (let ((types gnus-article-mark-lists)
4412 (info (gnus-get-info gnus-newsgroup-name))
4413 (uncompressed '(score bookmark killed))
4414 type list newmarked symbol delta-marks)
4416 ;; Add all marks lists to the list of marks lists.
4417 (while (setq type (pop types))
4418 (setq list (symbol-value
4420 (intern (format "gnus-newsgroup-%s"
4424 ;; Get rid of the entries of the articles that have the
4426 (when (and (eq (cdr type) 'score)
4430 (prev (cons nil list))
4433 (if (or (not (consp (car arts)))
4434 (= (cdar arts) gnus-summary-default-score))
4435 (setcdr prev (cdr arts))
4437 (setq arts (cdr arts)))
4438 (setq list (cdr all)))))
4440 (unless (memq (cdr type) uncompressed)
4441 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4443 (when (gnus-check-backend-function
4444 'request-set-mark gnus-newsgroup-name)
4445 ;; propagate flags to server, with the following exceptions:
4446 ;; uncompressed:s are not proper flags (they are cons cells)
4447 ;; cache is a internal gnus flag
4448 ;; download are local to one gnus installation (well)
4449 ;; unsend are for nndraft groups only
4450 ;; xxx: generality of this? this suits nnimap anyway
4451 (unless (memq (cdr type) (append '(cache download unsend)
4453 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4454 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4455 (add (gnus-remove-from-range
4456 (gnus-copy-sequence list) old)))
4458 (push (list add 'add (list (cdr type))) delta-marks))
4460 (push (list del 'del (list (cdr type))) delta-marks)))))
4463 (push (cons (cdr type) list) newmarked)))
4466 (unless (gnus-check-group gnus-newsgroup-name)
4467 (error "Can't open server for %s" gnus-newsgroup-name))
4468 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4470 ;; Enter these new marks into the info of the group.
4472 (setcar (nthcdr 3 info) newmarked)
4473 ;; Add the marks lists to the end of the info.
4475 (setcdr (nthcdr 2 info) (list newmarked))))
4477 ;; Cut off the end of the info if there's nothing else there.
4481 (when (nthcdr (decf i) info)
4482 (setcdr (nthcdr i info) nil)))))))
4484 (defun gnus-set-mode-line (where)
4485 "Set the mode line of the article or summary buffers.
4486 If WHERE is `summary', the summary mode line format will be used."
4487 ;; Is this mode line one we keep updated?
4488 (when (and (memq where gnus-updated-mode-lines)
4490 (intern (format "gnus-%s-mode-line-format-spec" where))))
4493 ;; We evaluate this in the summary buffer since these
4494 ;; variables are buffer-local to that buffer.
4495 (set-buffer gnus-summary-buffer)
4496 ;; We bind all these variables that are used in the `eval' form
4498 (let* ((mformat (symbol-value
4500 (format "gnus-%s-mode-line-format-spec" where))))
4501 (gnus-tmp-group-name (gnus-group-name-decode
4503 (gnus-group-name-charset
4505 gnus-newsgroup-name)))
4506 (gnus-tmp-article-number (or gnus-current-article 0))
4507 (gnus-tmp-unread gnus-newsgroup-unreads)
4508 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4509 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4510 (gnus-tmp-unread-and-unselected
4511 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4512 (zerop gnus-tmp-unselected))
4514 ((zerop gnus-tmp-unselected)
4515 (format "{%d more}" gnus-tmp-unread-and-unticked))
4516 (t (format "{%d(+%d) more}"
4517 gnus-tmp-unread-and-unticked
4518 gnus-tmp-unselected))))
4520 (if (and gnus-current-headers
4521 (vectorp gnus-current-headers))
4522 (gnus-mode-string-quote
4523 (mail-header-subject gnus-current-headers))
4525 bufname-length max-len
4526 gnus-tmp-header);; passed as argument to any user-format-funcs
4527 (setq mode-string (eval mformat))
4528 (setq bufname-length (if (string-match "%b" mode-string)
4531 (if (eq where 'summary)
4533 (get-buffer gnus-article-buffer))))
4536 (setq max-len (max 4 (if gnus-mode-non-string-length
4538 gnus-mode-non-string-length
4540 (length mode-string))))
4541 ;; We might have to chop a bit of the string off...
4542 (when (> (length mode-string) max-len)
4544 (concat (truncate-string-to-width mode-string (- max-len 3))
4546 ;; Pad the mode string a bit.
4547 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4548 ;; Update the mode line.
4549 (setq mode-line-buffer-identification
4550 (gnus-mode-line-buffer-identification (list mode-string)))
4551 (set-buffer-modified-p t))))
4553 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4554 "Go through the HEADERS list and add all Xrefs to a hash table.
4555 The resulting hash table is returned, or nil if no Xrefs were found."
4556 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4557 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4558 (xref-hashtb (gnus-make-hashtable))
4559 start group entry number xrefs header)
4561 (setq header (pop headers))
4562 (when (and (setq xrefs (mail-header-xref header))
4563 (not (memq (setq number (mail-header-number header))
4566 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4567 (setq start (match-end 0))
4568 (setq group (if prefix
4569 (concat prefix (substring xrefs (match-beginning 1)
4571 (substring xrefs (match-beginning 1) (match-end 1))))
4573 (string-to-int (substring xrefs (match-beginning 2)
4575 (if (setq entry (gnus-gethash group xref-hashtb))
4576 (setcdr entry (cons number (cdr entry)))
4577 (gnus-sethash group (cons number nil) xref-hashtb)))))
4578 (and start xref-hashtb)))
4580 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4581 "Look through all the headers and mark the Xrefs as read."
4582 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4583 name entry info xref-hashtb idlist method nth4)
4585 (set-buffer gnus-group-buffer)
4586 (when (setq xref-hashtb
4587 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4590 (unless (string= from-newsgroup (setq name (symbol-name group)))
4591 (setq idlist (symbol-value group))
4592 ;; Dead groups are not updated.
4594 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4596 (when (stringp (setq nth4 (gnus-info-method info)))
4597 (setq nth4 (gnus-server-to-method nth4))))
4598 ;; Only do the xrefs if the group has the same
4599 ;; select method as the group we have just read.
4600 (or (gnus-methods-equal-p
4601 nth4 (gnus-find-method-for-group from-newsgroup))
4603 (equal nth4 (setq method (gnus-find-method-for-group
4605 (and (equal (car nth4) (car method))
4606 (equal (nth 1 nth4) (nth 1 method))))
4607 gnus-use-cross-reference
4608 (or (not (eq gnus-use-cross-reference t))
4610 ;; Only do cross-references on subscribed
4611 ;; groups, if that is what is wanted.
4612 (<= (gnus-info-level info) gnus-level-subscribed))
4613 (gnus-group-make-articles-read name idlist))))
4616 (defun gnus-compute-read-articles (group articles)
4617 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4618 (info (nth 2 entry))
4619 (active (gnus-active group))
4622 ;; First peel off all invalid article numbers.
4624 (let ((ids articles)
4626 (while (setq id (pop ids))
4627 (when (and first (> id (cdr active)))
4628 ;; We'll end up in this situation in one particular
4629 ;; obscure situation. If you re-scan a group and get
4630 ;; a new article that is cross-posted to a different
4631 ;; group that has not been re-scanned, you might get
4632 ;; crossposted article that has a higher number than
4633 ;; Gnus believes possible. So we re-activate this
4634 ;; group as well. This might mean doing the
4635 ;; crossposting thingy will *increase* the number
4636 ;; of articles in some groups. Tsk, tsk.
4637 (setq active (or (gnus-activate-group group) active)))
4638 (when (or (> id (cdr active))
4639 (< id (car active)))
4640 (setq articles (delq id articles))))))
4641 ;; If the read list is nil, we init it.
4643 (null (gnus-info-read info))
4645 (setq ninfo (cons 1 (1- (car active))))
4646 (setq ninfo (gnus-info-read info)))
4647 ;; Then we add the read articles to the range.
4649 ninfo (setq articles (sort articles '<))))))
4651 (defun gnus-group-make-articles-read (group articles)
4652 "Update the info of GROUP to say that ARTICLES are read."
4654 (entry (gnus-gethash group gnus-newsrc-hashtb))
4655 (info (nth 2 entry))
4656 (active (gnus-active group))
4659 (setq range (gnus-compute-read-articles group articles))
4661 (set-buffer gnus-group-buffer)
4664 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4665 (gnus-info-set-read ',info ',(gnus-info-read info))
4666 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4667 (gnus-group-update-group ,group t))))
4668 ;; Add the read articles to the range.
4669 (gnus-info-set-read info range)
4670 ;; Then we have to re-compute how many unread
4671 ;; articles there are in this group.
4675 (setq num (- (1+ (cdr active)) (car active))))
4676 ((not (listp (cdr range)))
4677 (setq num (- (cdr active) (- (1+ (cdr range))
4681 (if (numberp (car range))
4683 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4684 (setq range (cdr range)))
4685 (setq num (- (cdr active) num))))
4686 ;; Update the number of unread articles.
4688 ;; Update the group buffer.
4689 (gnus-group-update-group group t)))))
4691 (defvar gnus-newsgroup-none-id 0)
4693 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4694 (let ((cur nntp-server-buffer)
4697 (save-excursion (set-buffer gnus-summary-buffer)
4698 gnus-newsgroup-dependencies)))
4700 (mail-parse-charset gnus-newsgroup-charset)
4701 (mail-parse-ignored-charsets
4702 (save-excursion (condition-case nil
4703 (set-buffer gnus-summary-buffer)
4705 gnus-newsgroup-ignored-charsets)))
4707 (set-buffer nntp-server-buffer)
4708 ;; Translate all TAB characters into SPACE characters.
4709 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4710 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4711 (gnus-run-hooks 'gnus-parse-headers-hook)
4712 (let ((case-fold-search t)
4713 in-reply-to header p lines chars)
4714 (goto-char (point-min))
4715 ;; Search to the beginning of the next header. Error messages
4716 ;; do not begin with 2 or 3.
4717 (while (re-search-forward "^[23][0-9]+ " nil t)
4720 ;; This implementation of this function, with nine
4721 ;; search-forwards instead of the one re-search-forward and
4722 ;; a case (which basically was the old function) is actually
4723 ;; about twice as fast, even though it looks messier. You
4724 ;; can't have everything, I guess. Speed and elegance
4725 ;; doesn't always go hand in hand.
4734 (narrow-to-region (point)
4735 (or (and (search-forward "\n.\n" nil t)
4741 (if (search-forward "\nsubject: " nil t)
4742 (funcall gnus-decode-encoded-word-function
4743 (nnheader-header-value))
4748 (if (or (search-forward "\nfrom: " nil t)
4749 (search-forward "\nfrom:" nil t))
4750 (funcall gnus-decode-encoded-word-function
4751 (nnheader-header-value))
4756 (if (search-forward "\ndate: " nil t)
4757 (nnheader-header-value) ""))
4761 (setq id (if (re-search-forward
4762 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4763 ;; We do it this way to make sure the Message-ID
4764 ;; is (somewhat) syntactically valid.
4765 (buffer-substring (match-beginning 1)
4767 ;; If there was no message-id, we just fake one
4768 ;; to make subsequent routines simpler.
4769 (nnheader-generate-fake-message-id))))
4773 (if (search-forward "\nreferences: " nil t)
4777 (nnheader-header-value)
4782 (search-backward ">" end t)
4785 (search-backward "<" end t)
4787 ;; Get the references from the in-reply-to header if there
4788 ;; were no references and the in-reply-to header looks
4790 (if (and (search-forward "\nin-reply-to: " nil t)
4791 (setq in-reply-to (nnheader-header-value))
4792 (string-match "<[^>]+>" in-reply-to))
4794 (setq ref (substring in-reply-to (match-beginning 0)
4796 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4797 (setq ref2 (substring in-reply-to (match-beginning 0)
4799 (when (> (length ref2) (length ref))
4806 (if (search-forward "\nchars: " nil t)
4807 (if (numberp (setq chars (ignore-errors (read cur))))
4813 (if (search-forward "\nlines: " nil t)
4814 (if (numberp (setq lines (ignore-errors (read cur))))
4820 (and (search-forward "\nxref: " nil t)
4821 (nnheader-header-value)))
4823 (when gnus-extra-headers
4824 (let ((extra gnus-extra-headers)
4828 (when (search-forward
4829 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4830 (push (cons (car extra) (nnheader-header-value))
4834 (when (equal id ref)
4837 (when gnus-alter-header-function
4838 (funcall gnus-alter-header-function header)
4839 (setq id (mail-header-id header)
4840 ref (gnus-parent-id (mail-header-references header))))
4843 (gnus-dependencies-add-header
4844 header dependencies force-new))
4845 (push header headers))
4846 (goto-char (point-max))
4848 (nreverse headers)))))
4850 ;; Goes through the xover lines and returns a list of vectors
4851 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4852 force-new dependencies
4853 group also-fetch-heads)
4854 "Parse the news overview data in the server buffer.
4855 Return a list of headers that match SEQUENCE (see
4856 `nntp-retrieve-headers')."
4857 ;; Get the Xref when the users reads the articles since most/some
4858 ;; NNTP servers do not include Xrefs when using XOVER.
4859 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4860 (let ((mail-parse-charset gnus-newsgroup-charset)
4861 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4862 (cur nntp-server-buffer)
4863 (dependencies (or dependencies gnus-newsgroup-dependencies))
4864 number headers header)
4866 (set-buffer nntp-server-buffer)
4867 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4868 ;; Allow the user to mangle the headers before parsing them.
4869 (gnus-run-hooks 'gnus-parse-headers-hook)
4870 (goto-char (point-min))
4873 (while (and sequence (not (eobp)))
4874 (setq number (read cur))
4875 (while (and sequence
4876 (< (car sequence) number))
4877 (setq sequence (cdr sequence)))
4879 (eq number (car sequence))
4881 (setq sequence (cdr sequence))
4882 (setq header (inline
4883 (gnus-nov-parse-line
4884 number dependencies force-new))))
4885 (push header headers))
4888 (gnus-error 4 "Strange nov line (%d)"
4889 (count-lines (point-min) (point)))))
4891 ;; A common bug in inn is that if you have posted an article and
4892 ;; then retrieves the active file, it will answer correctly --
4893 ;; the new article is included. However, a NOV entry for the
4894 ;; article may not have been generated yet, so this may fail.
4895 ;; We work around this problem by retrieving the last few
4896 ;; headers using HEAD.
4897 (if (or (not also-fetch-heads)
4899 ;; We (probably) got all the headers.
4901 (let ((gnus-nov-is-evil t))
4904 (when (gnus-retrieve-headers sequence group)
4905 (gnus-get-newsgroup-headers))))))))
4907 (defun gnus-article-get-xrefs ()
4908 "Fill in the Xref value in `gnus-current-headers', if necessary.
4909 This is meant to be called in `gnus-article-internal-prepare-hook'."
4910 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4911 gnus-current-headers)))
4912 (or (not gnus-use-cross-reference)
4914 (and (mail-header-xref headers)
4915 (not (string= (mail-header-xref headers) "")))
4916 (let ((case-fold-search t)
4919 (nnheader-narrow-to-headers)
4920 (goto-char (point-min))
4921 (when (or (and (not (eobp))
4922 (eq (downcase (char-after)) ?x)
4923 (looking-at "Xref:"))
4924 (search-forward "\nXref:" nil t))
4925 (goto-char (1+ (match-end 0)))
4926 (setq xref (buffer-substring (point)
4927 (progn (end-of-line) (point))))
4928 (mail-header-set-xref headers xref)))))))
4930 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4931 "Find article ID and insert the summary line for that article.
4932 OLD-HEADER can either be a header or a line number to insert
4933 the subject line on."
4934 (let* ((line (and (numberp old-header) old-header))
4935 (old-header (and (vectorp old-header) old-header))
4936 (header (cond ((and old-header use-old-header)
4939 (gnus-number-to-header id))
4940 (gnus-number-to-header id))
4942 (gnus-read-header id))))
4943 (number (and (numberp id) id))
4946 ;; Rebuild the thread that this article is part of and go to the
4947 ;; article we have fetched.
4948 (when (and (not gnus-show-threads)
4951 (setq d (gnus-data-find (mail-header-number old-header))))
4952 (goto-char (gnus-data-pos d))
4955 (- (gnus-point-at-bol)
4957 (1+ (gnus-point-at-eol))
4958 (gnus-delete-line))))))
4960 (mail-header-set-number header (mail-header-number old-header)))
4961 (setq gnus-newsgroup-sparse
4962 (delq (setq number (mail-header-number header))
4963 gnus-newsgroup-sparse))
4964 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4965 (push number gnus-newsgroup-limit)
4966 (gnus-rebuild-thread (mail-header-id header) line)
4967 (gnus-summary-goto-subject number nil t))
4968 (when (and (numberp number)
4970 ;; We have to update the boundaries even if we can't fetch the
4971 ;; article if ID is a number -- so that the next `P' or `N'
4972 ;; command will fetch the previous (or next) article even
4973 ;; if the one we tried to fetch this time has been canceled.
4974 (when (> number gnus-newsgroup-end)
4975 (setq gnus-newsgroup-end number))
4976 (when (< number gnus-newsgroup-begin)
4977 (setq gnus-newsgroup-begin number))
4978 (setq gnus-newsgroup-unselected
4979 (delq number gnus-newsgroup-unselected)))
4980 ;; Report back a success?
4981 (and header (mail-header-number header))))
4983 ;;; Process/prefix in the summary buffer
4985 (defun gnus-summary-work-articles (n)
4986 "Return a list of articles to be worked upon.
4987 The prefix argument, the list of process marked articles, and the
4988 current article will be taken into consideration."
4990 (set-buffer gnus-summary-buffer)
4993 ;; A numerical prefix has been given.
4994 (setq n (prefix-numeric-value n))
4995 (let ((backward (< n 0))
4996 (n (abs (prefix-numeric-value n)))
5001 (push (setq article (gnus-summary-article-number))
5004 (gnus-summary-find-prev nil article)
5005 (gnus-summary-find-next nil article)))
5007 (nreverse articles)))
5008 ((and (gnus-region-active-p) (mark))
5009 (message "region active")
5010 ;; Work on the region between point and mark.
5011 (let ((max (max (point) (mark)))
5014 (goto-char (min (min (point) (mark))))
5017 (push (setq article (gnus-summary-article-number)) articles)
5018 (gnus-summary-find-next nil article)
5020 (nreverse articles))))
5021 (gnus-newsgroup-processable
5022 ;; There are process-marked articles present.
5023 ;; Save current state.
5024 (gnus-summary-save-process-mark)
5026 (reverse gnus-newsgroup-processable))
5028 ;; Just return the current article.
5029 (list (gnus-summary-article-number))))))
5031 (defmacro gnus-summary-iterate (arg &rest forms)
5032 "Iterate over the process/prefixed articles and do FORMS.
5033 ARG is the interactive prefix given to the command. FORMS will be
5034 executed with point over the summary line of the articles."
5035 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5036 `(let ((,articles (gnus-summary-work-articles ,arg)))
5038 (gnus-summary-goto-subject (car ,articles))
5042 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5043 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5045 (defun gnus-summary-save-process-mark ()
5046 "Push the current set of process marked articles on the stack."
5048 (push (copy-sequence gnus-newsgroup-processable)
5049 gnus-newsgroup-process-stack))
5051 (defun gnus-summary-kill-process-mark ()
5052 "Push the current set of process marked articles on the stack and unmark."
5054 (gnus-summary-save-process-mark)
5055 (gnus-summary-unmark-all-processable))
5057 (defun gnus-summary-yank-process-mark ()
5058 "Pop the last process mark state off the stack and restore it."
5060 (unless gnus-newsgroup-process-stack
5061 (error "Empty mark stack"))
5062 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5064 (defun gnus-summary-process-mark-set (set)
5065 "Make SET into the current process marked articles."
5066 (gnus-summary-unmark-all-processable)
5068 (gnus-summary-set-process-mark (pop set))))
5070 ;;; Searching and stuff
5072 (defun gnus-summary-search-group (&optional backward use-level)
5073 "Search for next unread newsgroup.
5074 If optional argument BACKWARD is non-nil, search backward instead."
5076 (set-buffer gnus-group-buffer)
5077 (when (gnus-group-search-forward
5078 backward nil (if use-level (gnus-group-group-level) nil))
5079 (gnus-group-group-name))))
5081 (defun gnus-summary-best-group (&optional exclude-group)
5082 "Find the name of the best unread group.
5083 If EXCLUDE-GROUP, do not go to this group."
5085 (set-buffer gnus-group-buffer)
5087 (gnus-group-best-unread-group exclude-group))))
5089 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5090 (if backward (gnus-summary-find-prev)
5091 (let* ((dummy (gnus-summary-article-intangible-p))
5092 (article (or article (gnus-summary-article-number)))
5093 (arts (gnus-data-find-list article))
5095 (when (and (not dummy)
5096 (or (not gnus-summary-check-current)
5098 (not (gnus-data-unread-p (car arts)))))
5099 (setq arts (cdr arts)))
5104 (when (or (and undownloaded
5105 (eq gnus-undownloaded-mark
5106 (gnus-data-mark (car arts))))
5107 (gnus-data-unread-p (car arts)))
5108 (setq result (car arts)
5110 (setq arts (cdr arts)))
5113 (goto-char (gnus-data-pos result))
5114 (gnus-data-number result)))))
5116 (defun gnus-summary-find-prev (&optional unread article)
5117 (let* ((eobp (eobp))
5118 (article (or article (gnus-summary-article-number)))
5119 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5121 (when (and (not eobp)
5122 (or (not gnus-summary-check-current)
5124 (not (gnus-data-unread-p (car arts)))))
5125 (setq arts (cdr arts)))
5130 (when (gnus-data-unread-p (car arts))
5131 (setq result (car arts)
5133 (setq arts (cdr arts)))
5136 (goto-char (gnus-data-pos result))
5137 (gnus-data-number result))))
5139 (defun gnus-summary-find-subject (subject &optional unread backward article)
5140 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5141 (article (or article (gnus-summary-article-number)))
5142 (articles (gnus-data-list backward))
5143 (arts (gnus-data-find-list article articles))
5145 (when (or (not gnus-summary-check-current)
5147 (not (gnus-data-unread-p (car arts))))
5148 (setq arts (cdr arts)))
5150 (and (or (not unread)
5151 (gnus-data-unread-p (car arts)))
5152 (vectorp (gnus-data-header (car arts)))
5154 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5155 (setq result (car arts)
5157 (setq arts (cdr arts)))
5159 (goto-char (gnus-data-pos result))
5160 (gnus-data-number result))))
5162 (defun gnus-summary-search-forward (&optional unread subject backward)
5163 "Search forward for an article.
5164 If UNREAD, look for unread articles. If SUBJECT, look for
5165 articles with that subject. If BACKWARD, search backward instead."
5166 (cond (subject (gnus-summary-find-subject subject unread backward))
5167 (backward (gnus-summary-find-prev unread))
5168 (t (gnus-summary-find-next unread))))
5170 (defun gnus-recenter (&optional n)
5171 "Center point in window and redisplay frame.
5172 Also do horizontal recentering."
5174 (when (and gnus-auto-center-summary
5175 (not (eq gnus-auto-center-summary 'vertical)))
5176 (gnus-horizontal-recenter))
5179 (defun gnus-summary-recenter ()
5180 "Center point in the summary window.
5181 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5182 displayed, no centering will be performed."
5183 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5184 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5186 (let* ((top (cond ((< (window-height) 4) 0)
5187 ((< (window-height) 7) 1)
5188 (t (if (numberp gnus-auto-center-summary)
5189 gnus-auto-center-summary
5191 (height (1- (window-height)))
5192 (bottom (save-excursion (goto-char (point-max))
5193 (forward-line (- height))
5195 (window (get-buffer-window (current-buffer))))
5196 ;; The user has to want it.
5197 (when gnus-auto-center-summary
5198 (when (get-buffer-window gnus-article-buffer)
5199 ;; Only do recentering when the article buffer is displayed,
5200 ;; Set the window start to either `bottom', which is the biggest
5201 ;; possible valid number, or the second line from the top,
5202 ;; whichever is the least.
5204 window (min bottom (save-excursion
5205 (forward-line (- top)) (point)))
5207 ;; Do horizontal recentering while we're at it.
5208 (when (and (get-buffer-window (current-buffer) t)
5209 (not (eq gnus-auto-center-summary 'vertical)))
5210 (let ((selected (selected-window)))
5211 (select-window (get-buffer-window (current-buffer) t))
5212 (gnus-summary-position-point)
5213 (gnus-horizontal-recenter)
5214 (select-window selected))))))
5216 (defun gnus-summary-jump-to-group (newsgroup)
5217 "Move point to NEWSGROUP in group mode buffer."
5218 ;; Keep update point of group mode buffer if visible.
5219 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5220 (save-window-excursion
5221 ;; Take care of tree window mode.
5222 (when (get-buffer-window gnus-group-buffer)
5223 (pop-to-buffer gnus-group-buffer))
5224 (gnus-group-jump-to-group newsgroup))
5226 ;; Take care of tree window mode.
5227 (if (get-buffer-window gnus-group-buffer)
5228 (pop-to-buffer gnus-group-buffer)
5229 (set-buffer gnus-group-buffer))
5230 (gnus-group-jump-to-group newsgroup))))
5232 ;; This function returns a list of article numbers based on the
5233 ;; difference between the ranges of read articles in this group and
5234 ;; the range of active articles.
5235 (defun gnus-list-of-unread-articles (group)
5236 (let* ((read (gnus-info-read (gnus-get-info group)))
5237 (active (or (gnus-active group) (gnus-activate-group group)))
5240 ;; If none are read, then all are unread.
5242 (setq first (car active))
5243 ;; If the range of read articles is a single range, then the
5244 ;; first unread article is the article after the last read
5245 ;; article. Sounds logical, doesn't it?
5246 (if (and (not (listp (cdr read)))
5247 (or (< (car read) (car active))
5248 (progn (setq read (list read))
5250 (setq first (max (car active) (1+ (cdr read))))
5251 ;; `read' is a list of ranges.
5252 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5255 (setq first (car active)))
5258 (while (< first nlast)
5260 (setq first (1+ first))))
5261 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5262 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5263 (setq read (cdr read)))))
5264 ;; And add the last unread articles.
5265 (while (<= first last)
5267 (setq first (1+ first)))
5268 ;; Return the list of unread articles.
5269 (delq 0 (nreverse unread))))
5271 (defun gnus-list-of-read-articles (group)
5272 "Return a list of unread, unticked and non-dormant articles."
5273 (let* ((info (gnus-get-info group))
5274 (marked (gnus-info-marks info))
5275 (active (gnus-active group)))
5277 (gnus-set-difference
5278 (gnus-sorted-complement
5279 (gnus-uncompress-range active)
5280 (gnus-list-of-unread-articles group))
5282 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5283 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5285 ;; Various summary commands
5287 (defun gnus-summary-select-article-buffer ()
5288 "Reconfigure windows to show article buffer."
5290 (if (not (gnus-buffer-live-p gnus-article-buffer))
5291 (error "There is no article buffer for this summary buffer")
5292 (gnus-configure-windows 'article)
5293 (select-window (get-buffer-window gnus-article-buffer))))
5295 (defun gnus-summary-universal-argument (arg)
5296 "Perform any operation on all articles that are process/prefixed."
5298 (let ((articles (gnus-summary-work-articles arg))
5305 (substitute-command-keys
5306 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5308 (gnus-error 1 "Undefined key")
5311 (gnus-summary-goto-subject (setq article (pop articles)))
5312 (let (gnus-newsgroup-processable)
5313 (command-execute func))
5314 (gnus-summary-remove-process-mark article)))))
5315 (gnus-summary-position-point))
5317 (defun gnus-summary-toggle-truncation (&optional arg)
5318 "Toggle truncation of summary lines.
5319 With arg, turn line truncation on iff arg is positive."
5321 (setq truncate-lines
5322 (if (null arg) (not truncate-lines)
5323 (> (prefix-numeric-value arg) 0)))
5326 (defun gnus-summary-reselect-current-group (&optional all rescan)
5327 "Exit and then reselect the current newsgroup.
5328 The prefix argument ALL means to select all articles."
5330 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5331 (error "Ephemeral groups can't be reselected"))
5332 (let ((current-subject (gnus-summary-article-number))
5333 (group gnus-newsgroup-name))
5334 (setq gnus-newsgroup-begin nil)
5336 ;; We have to adjust the point of group mode buffer because
5337 ;; point was moved to the next unread newsgroup by exiting.
5338 (gnus-summary-jump-to-group group)
5341 (gnus-group-get-new-news-this-group 1)))
5342 (gnus-group-read-group all t)
5343 (gnus-summary-goto-subject current-subject nil t)))
5345 (defun gnus-summary-rescan-group (&optional all)
5346 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5348 (gnus-summary-reselect-current-group all t))
5350 (defun gnus-summary-update-info (&optional non-destructive)
5352 (let ((group gnus-newsgroup-name))
5354 (when gnus-newsgroup-kill-headers
5355 (setq gnus-newsgroup-killed
5356 (gnus-compress-sequence
5358 (gnus-set-sorted-intersection
5359 (gnus-uncompress-range gnus-newsgroup-killed)
5360 (setq gnus-newsgroup-unselected
5361 (sort gnus-newsgroup-unselected '<)))
5362 (setq gnus-newsgroup-unreads
5363 (sort gnus-newsgroup-unreads '<)))
5365 (unless (listp (cdr gnus-newsgroup-killed))
5366 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5367 (let ((headers gnus-newsgroup-headers))
5368 ;; Set the new ranges of read articles.
5370 (set-buffer gnus-group-buffer)
5371 (gnus-undo-force-boundary))
5372 (gnus-update-read-articles
5373 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5374 ;; Set the current article marks.
5375 (let ((gnus-newsgroup-scored
5376 (if (and (not gnus-save-score)
5377 (not non-destructive))
5379 gnus-newsgroup-scored)))
5381 (gnus-update-marks)))
5382 ;; Do the cross-ref thing.
5383 (when gnus-use-cross-reference
5384 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5385 ;; Do not switch windows but change the buffer to work.
5386 (set-buffer gnus-group-buffer)
5387 (unless (gnus-ephemeral-group-p group)
5388 (gnus-group-update-group group)))))))
5390 (defun gnus-summary-save-newsrc (&optional force)
5391 "Save the current number of read/marked articles in the dribble buffer.
5392 The dribble buffer will then be saved.
5393 If FORCE (the prefix), also save the .newsrc file(s)."
5395 (gnus-summary-update-info t)
5397 (gnus-save-newsrc-file)
5398 (gnus-dribble-save)))
5400 (defun gnus-summary-exit (&optional temporary)
5401 "Exit reading current newsgroup, and then return to group selection mode.
5402 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5404 (gnus-set-global-variables)
5405 (when (gnus-buffer-live-p gnus-article-buffer)
5407 (set-buffer gnus-article-buffer)
5408 (mm-destroy-parts gnus-article-mime-handles)
5409 ;; Set it to nil for safety reason.
5410 (setq gnus-article-mime-handle-alist nil)
5411 (setq gnus-article-mime-handles nil)))
5412 (gnus-kill-save-kill-buffer)
5413 (gnus-async-halt-prefetch)
5414 (let* ((group gnus-newsgroup-name)
5415 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5418 (buf (current-buffer)))
5420 ;; Do adaptive scoring, and possibly save score files.
5421 (when gnus-newsgroup-adaptive
5422 (gnus-score-adaptive))
5423 (when gnus-use-scoring
5425 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5426 ;; If we have several article buffers, we kill them at exit.
5427 (unless gnus-single-article-buffer
5428 (gnus-kill-buffer gnus-original-article-buffer)
5429 (setq gnus-article-current nil))
5430 (when gnus-use-cache
5431 (gnus-cache-possibly-remove-articles)
5432 (gnus-cache-save-buffers))
5433 (gnus-async-prefetch-remove-group group)
5434 (when gnus-suppress-duplicates
5435 (gnus-dup-enter-articles))
5436 (when gnus-use-trees
5437 (gnus-tree-close group))
5438 (when gnus-use-cache
5439 (gnus-cache-write-active))
5440 ;; Remove entries for this group.
5441 (nnmail-purge-split-history (gnus-group-real-name group))
5442 ;; Make all changes in this group permanent.
5444 (gnus-run-hooks 'gnus-exit-group-hook)
5445 (gnus-summary-update-info))
5446 (gnus-close-group group)
5447 ;; Make sure where we were, and go to next newsgroup.
5448 (set-buffer gnus-group-buffer)
5450 (gnus-group-jump-to-group group))
5451 (gnus-run-hooks 'gnus-summary-exit-hook)
5452 (unless (or quit-config
5453 ;; If this group has disappeared from the summary
5454 ;; buffer, don't skip forwards.
5455 (not (string= group (gnus-group-group-name))))
5456 (gnus-group-next-unread-group 1))
5457 (setq group-point (point))
5460 ;; If we have several article buffers, we kill them at exit.
5461 (unless gnus-single-article-buffer
5462 (gnus-kill-buffer gnus-article-buffer)
5463 (gnus-kill-buffer gnus-original-article-buffer)
5464 (setq gnus-article-current nil))
5466 (if (not gnus-kill-summary-on-exit)
5467 (gnus-deaden-summary)
5468 ;; We set all buffer-local variables to nil. It is unclear why
5469 ;; this is needed, but if we don't, buffer-local variables are
5470 ;; not garbage-collected, it seems. This would the lead to en
5471 ;; ever-growing Emacs.
5472 (gnus-summary-clear-local-variables)
5473 (when (get-buffer gnus-article-buffer)
5474 (bury-buffer gnus-article-buffer))
5475 ;; We clear the global counterparts of the buffer-local
5476 ;; variables as well, just to be on the safe side.
5477 (set-buffer gnus-group-buffer)
5478 (gnus-summary-clear-local-variables)
5479 ;; Return to group mode buffer.
5480 (when (eq mode 'gnus-summary-mode)
5481 (gnus-kill-buffer buf)))
5482 (setq gnus-current-select-method gnus-select-method)
5483 (pop-to-buffer gnus-group-buffer)
5484 (if (not quit-config)
5486 (goto-char group-point)
5487 (gnus-configure-windows 'group 'force))
5488 (gnus-handle-ephemeral-exit quit-config))
5489 ;; Clear the current group name.
5491 (setq gnus-newsgroup-name nil)))))
5493 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5494 (defun gnus-summary-exit-no-update (&optional no-questions)
5495 "Quit reading current newsgroup without updating read article info."
5497 (let* ((group gnus-newsgroup-name)
5498 (quit-config (gnus-group-quit-config group)))
5499 (when (or no-questions
5501 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5502 (gnus-async-halt-prefetch)
5504 (delq 'gnus-summary-expire-articles
5505 (copy-sequence gnus-summary-prepare-exit-hook)))
5506 (when (gnus-buffer-live-p gnus-article-buffer)
5508 (set-buffer gnus-article-buffer)
5509 (mm-destroy-parts gnus-article-mime-handles)
5510 ;; Set it to nil for safety reason.
5511 (setq gnus-article-mime-handle-alist nil)
5512 (setq gnus-article-mime-handles nil)))
5513 ;; If we have several article buffers, we kill them at exit.
5514 (unless gnus-single-article-buffer
5515 (gnus-kill-buffer gnus-article-buffer)
5516 (gnus-kill-buffer gnus-original-article-buffer)
5517 (setq gnus-article-current nil))
5518 (if (not gnus-kill-summary-on-exit)
5519 (gnus-deaden-summary)
5520 (gnus-close-group group)
5521 (gnus-summary-clear-local-variables)
5522 (set-buffer gnus-group-buffer)
5523 (gnus-summary-clear-local-variables)
5524 (when (get-buffer gnus-summary-buffer)
5525 (kill-buffer gnus-summary-buffer)))
5526 (unless gnus-single-article-buffer
5527 (setq gnus-article-current nil))
5528 (when gnus-use-trees
5529 (gnus-tree-close group))
5530 (gnus-async-prefetch-remove-group group)
5531 (when (get-buffer gnus-article-buffer)
5532 (bury-buffer gnus-article-buffer))
5533 ;; Return to the group buffer.
5534 (gnus-configure-windows 'group 'force)
5535 ;; Clear the current group name.
5536 (setq gnus-newsgroup-name nil)
5537 (when (equal (gnus-group-group-name) group)
5538 (gnus-group-next-unread-group 1))
5540 (gnus-handle-ephemeral-exit quit-config)))))
5542 (defun gnus-handle-ephemeral-exit (quit-config)
5543 "Handle movement when leaving an ephemeral group.
5544 The state which existed when entering the ephemeral is reset."
5545 (if (not (buffer-name (car quit-config)))
5546 (gnus-configure-windows 'group 'force)
5547 (set-buffer (car quit-config))
5548 (cond ((eq major-mode 'gnus-summary-mode)
5549 (gnus-set-global-variables))
5550 ((eq major-mode 'gnus-article-mode)
5552 ;; The `gnus-summary-buffer' variable may point
5553 ;; to the old summary buffer when using a single
5555 (unless (gnus-buffer-live-p gnus-summary-buffer)
5556 (set-buffer gnus-group-buffer))
5557 (set-buffer gnus-summary-buffer)
5558 (gnus-set-global-variables))))
5559 (if (or (eq (cdr quit-config) 'article)
5560 (eq (cdr quit-config) 'pick))
5562 ;; The current article may be from the ephemeral group
5563 ;; thus it is best that we reload this article
5564 (gnus-summary-show-article)
5565 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5566 (gnus-configure-windows 'pick 'force)
5567 (gnus-configure-windows (cdr quit-config) 'force)))
5568 (gnus-configure-windows (cdr quit-config) 'force))
5569 (when (eq major-mode 'gnus-summary-mode)
5570 (gnus-summary-next-subject 1 nil t)
5571 (gnus-summary-recenter)
5572 (gnus-summary-position-point))))
5576 (defvar gnus-dead-summary-mode-map nil)
5578 (unless gnus-dead-summary-mode-map
5579 (setq gnus-dead-summary-mode-map (make-keymap))
5580 (suppress-keymap gnus-dead-summary-mode-map)
5581 (substitute-key-definition
5582 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5583 (let ((keys '("\C-d" "\r" "\177" [delete])))
5585 (define-key gnus-dead-summary-mode-map
5586 (pop keys) 'gnus-summary-wake-up-the-dead))))
5588 (defvar gnus-dead-summary-mode nil
5589 "Minor mode for Gnus summary buffers.")
5591 (defun gnus-dead-summary-mode (&optional arg)
5592 "Minor mode for Gnus summary buffers."
5594 (when (eq major-mode 'gnus-summary-mode)
5595 (make-local-variable 'gnus-dead-summary-mode)
5596 (setq gnus-dead-summary-mode
5597 (if (null arg) (not gnus-dead-summary-mode)
5598 (> (prefix-numeric-value arg) 0)))
5599 (when gnus-dead-summary-mode
5600 (gnus-add-minor-mode
5601 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5603 (defun gnus-deaden-summary ()
5604 "Make the current summary buffer into a dead summary buffer."
5605 ;; Kill any previous dead summary buffer.
5606 (when (and gnus-dead-summary
5607 (buffer-name gnus-dead-summary))
5609 (set-buffer gnus-dead-summary)
5610 (when gnus-dead-summary-mode
5611 (kill-buffer (current-buffer)))))
5612 ;; Make this the current dead summary.
5613 (setq gnus-dead-summary (current-buffer))
5614 (gnus-dead-summary-mode 1)
5615 (let ((name (buffer-name)))
5616 (when (string-match "Summary" name)
5618 (concat (substring name 0 (match-beginning 0)) "Dead "
5619 (substring name (match-beginning 0)))
5623 (defun gnus-kill-or-deaden-summary (buffer)
5624 "Kill or deaden the summary BUFFER."
5626 (when (and (buffer-name buffer)
5627 (not gnus-single-article-buffer))
5630 (gnus-kill-buffer gnus-article-buffer)
5631 (gnus-kill-buffer gnus-original-article-buffer)))
5632 (cond (gnus-kill-summary-on-exit
5633 (when (and gnus-use-trees
5634 (gnus-buffer-exists-p buffer))
5637 (gnus-tree-close gnus-newsgroup-name)))
5638 (gnus-kill-buffer buffer))
5639 ((gnus-buffer-exists-p buffer)
5642 (gnus-deaden-summary))))))
5644 (defun gnus-summary-wake-up-the-dead (&rest args)
5645 "Wake up the dead summary buffer."
5647 (gnus-dead-summary-mode -1)
5648 (let ((name (buffer-name)))
5649 (when (string-match "Dead " name)
5651 (concat (substring name 0 (match-beginning 0))
5652 (substring name (match-end 0)))
5654 (gnus-message 3 "This dead summary is now alive again"))
5656 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5657 (defun gnus-summary-fetch-faq (&optional faq-dir)
5658 "Fetch the FAQ for the current group.
5659 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5663 (when current-prefix-arg
5665 "Faq dir: " (and (listp gnus-group-faq-directory)
5666 (mapcar (lambda (file) (list file))
5667 gnus-group-faq-directory))))))
5668 (let (gnus-faq-buffer)
5669 (when (setq gnus-faq-buffer
5670 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5671 (gnus-configure-windows 'summary-faq))))
5673 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5674 (defun gnus-summary-describe-group (&optional force)
5675 "Describe the current newsgroup."
5677 (gnus-group-describe-group force gnus-newsgroup-name))
5679 (defun gnus-summary-describe-briefly ()
5680 "Describe summary mode commands briefly."
5682 (gnus-message 6 (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")))
5684 ;; Walking around group mode buffer from summary mode.
5686 (defun gnus-summary-next-group (&optional no-article target-group backward)
5687 "Exit current newsgroup and then select next unread newsgroup.
5688 If prefix argument NO-ARTICLE is non-nil, no article is selected
5689 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5690 previous group instead."
5692 ;; Stop pre-fetching.
5693 (gnus-async-halt-prefetch)
5694 (let ((current-group gnus-newsgroup-name)
5695 (current-buffer (current-buffer))
5697 ;; First we semi-exit this group to update Xrefs and all variables.
5698 ;; We can't do a real exit, because the window conf must remain
5699 ;; the same in case the user is prompted for info, and we don't
5700 ;; want the window conf to change before that...
5701 (gnus-summary-exit t)
5702 (while (not entered)
5703 ;; Then we find what group we are supposed to enter.
5704 (set-buffer gnus-group-buffer)
5705 (gnus-group-jump-to-group current-group)
5708 (if (eq gnus-keep-same-level 'best)
5709 (gnus-summary-best-group gnus-newsgroup-name)
5710 (gnus-summary-search-group backward gnus-keep-same-level))))
5711 (if (not target-group)
5712 ;; There are no further groups, so we return to the group
5715 (gnus-message 5 "Returning to the group buffer")
5717 (when (gnus-buffer-live-p current-buffer)
5718 (set-buffer current-buffer)
5719 (gnus-summary-exit))
5720 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5721 ;; We try to enter the target group.
5722 (gnus-group-jump-to-group target-group)
5723 (let ((unreads (gnus-group-group-unread)))
5724 (if (and (or (eq t unreads)
5725 (and unreads (not (zerop unreads))))
5726 (gnus-summary-read-group
5727 target-group nil no-article
5728 (and (buffer-name current-buffer) current-buffer)
5731 (setq current-group target-group
5732 target-group nil)))))))
5734 (defun gnus-summary-prev-group (&optional no-article)
5735 "Exit current newsgroup and then select previous unread newsgroup.
5736 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5738 (gnus-summary-next-group no-article nil t))
5740 ;; Walking around summary lines.
5742 (defun gnus-summary-first-subject (&optional unread undownloaded)
5743 "Go to the first unread subject.
5744 If UNREAD is non-nil, go to the first unread article.
5745 Returns the article selected or nil if there are no unread articles."
5750 ((null gnus-newsgroup-data)
5751 (gnus-message 3 "No articles in the group")
5753 ;; Pick the first article.
5755 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5756 (gnus-data-number (car gnus-newsgroup-data)))
5757 ;; No unread articles.
5758 ((null gnus-newsgroup-unreads)
5759 (gnus-message 3 "No more unread articles")
5761 ;; Find the first unread article.
5763 (let ((data gnus-newsgroup-data))
5765 (and (not (and undownloaded
5766 (eq gnus-undownloaded-mark
5767 (gnus-data-mark (car data)))))
5768 (not (gnus-data-unread-p (car data)))))
5769 (setq data (cdr data)))
5771 (goto-char (gnus-data-pos (car data)))
5772 (gnus-data-number (car data))))))
5773 (gnus-summary-position-point)))
5775 (defun gnus-summary-next-subject (n &optional unread dont-display)
5776 "Go to next N'th summary line.
5777 If N is negative, go to the previous N'th subject line.
5778 If UNREAD is non-nil, only unread articles are selected.
5779 The difference between N and the actual number of steps taken is
5782 (let ((backward (< n 0))
5786 (gnus-summary-find-prev unread)
5787 (gnus-summary-find-next unread)))
5788 (unless (zerop (setq n (1- n)))
5789 (gnus-summary-show-thread)))
5791 (gnus-message 7 "No more%s articles"
5792 (if unread " unread" "")))
5793 (unless dont-display
5794 (gnus-summary-recenter)
5795 (gnus-summary-position-point))
5798 (defun gnus-summary-next-unread-subject (n)
5799 "Go to next N'th unread summary line."
5801 (gnus-summary-next-subject n t))
5803 (defun gnus-summary-prev-subject (n &optional unread)
5804 "Go to previous N'th summary line.
5805 If optional argument UNREAD is non-nil, only unread article is selected."
5807 (gnus-summary-next-subject (- n) unread))
5809 (defun gnus-summary-prev-unread-subject (n)
5810 "Go to previous N'th unread summary line."
5812 (gnus-summary-next-subject (- n) t))
5814 (defun gnus-summary-goto-subject (article &optional force silent)
5815 "Go the subject line of ARTICLE.
5816 If FORCE, also allow jumping to articles not currently shown."
5817 (interactive "nArticle number: ")
5819 (data (gnus-data-find article)))
5820 ;; We read in the article if we have to.
5823 (gnus-summary-insert-subject
5825 (if (or (numberp force) (vectorp force)) force)
5827 (setq data (gnus-data-find article)))
5832 (gnus-message 3 "Can't find article %d" article))
5834 (goto-char (gnus-data-pos data))
5835 (gnus-summary-position-point)
5838 ;; Walking around summary lines with displaying articles.
5840 (defun gnus-summary-expand-window (&optional arg)
5841 "Make the summary buffer take up the entire Emacs frame.
5842 Given a prefix, will force an `article' buffer configuration."
5845 (gnus-configure-windows 'article 'force)
5846 (gnus-configure-windows 'summary 'force)))
5848 (defun gnus-summary-display-article (article &optional all-header)
5849 "Display ARTICLE in article buffer."
5850 (when (gnus-buffer-live-p gnus-article-buffer)
5851 (with-current-buffer gnus-article-buffer
5852 (mm-enable-multibyte-mule4)))
5853 (gnus-set-global-variables)
5857 (if gnus-summary-display-article-function
5858 (funcall gnus-summary-display-article-function article all-header)
5859 (gnus-article-prepare article all-header))
5860 (gnus-run-hooks 'gnus-select-article-hook)
5861 (when (and gnus-current-article
5862 (not (zerop gnus-current-article)))
5863 (gnus-summary-goto-subject gnus-current-article))
5864 (gnus-summary-recenter)
5865 (when (and gnus-use-trees gnus-show-threads)
5866 (gnus-possibly-generate-tree article)
5867 (gnus-highlight-selected-tree article))
5868 ;; Successfully display article.
5869 (gnus-article-set-window-start
5870 (cdr (assq article gnus-newsgroup-bookmarks))))))
5872 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5873 "Select the current article.
5874 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5875 non-nil, the article will be re-fetched even if it already present in
5876 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5878 ;; Make sure we are in the summary buffer to work around bbdb bug.
5879 (unless (eq major-mode 'gnus-summary-mode)
5880 (set-buffer gnus-summary-buffer))
5881 (let ((article (or article (gnus-summary-article-number)))
5882 (all-headers (not (not all-headers))) ;Must be T or NIL.
5883 gnus-summary-display-article-function)
5885 (gnus-summary-article-pseudo-p article)
5886 (error "This is a pseudo-article"))
5888 (set-buffer gnus-summary-buffer)
5889 (if (or (and gnus-single-article-buffer
5890 (or (null gnus-current-article)
5891 (null gnus-article-current)
5892 (null (get-buffer gnus-article-buffer))
5893 (not (eq article (cdr gnus-article-current)))
5894 (not (equal (car gnus-article-current)
5895 gnus-newsgroup-name))))
5896 (and (not gnus-single-article-buffer)
5897 (or (null gnus-current-article)
5898 (not (eq gnus-current-article article))))
5900 ;; The requested article is different from the current article.
5902 (gnus-summary-display-article article all-headers)
5903 (when (gnus-buffer-live-p gnus-article-buffer)
5904 (with-current-buffer gnus-article-buffer
5905 (if (not gnus-article-decoded-p) ;; a local variable
5906 (mm-disable-multibyte-mule4))))
5907 (when (or all-headers gnus-show-all-headers)
5908 (gnus-article-show-all-headers))
5909 (gnus-article-set-window-start
5910 (cdr (assq article gnus-newsgroup-bookmarks)))
5912 (when (or all-headers gnus-show-all-headers)
5913 (gnus-article-show-all-headers))
5916 (defun gnus-summary-set-current-mark (&optional current-mark)
5917 "Obsolete function."
5920 (defun gnus-summary-next-article (&optional unread subject backward push)
5921 "Select the next article.
5922 If UNREAD, only unread articles are selected.
5923 If SUBJECT, only articles with SUBJECT are selected.
5924 If BACKWARD, the previous article is selected instead of the next."
5927 ;; Is there such an article?
5928 ((and (gnus-summary-search-forward unread subject backward)
5929 (or (gnus-summary-display-article (gnus-summary-article-number))
5930 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5931 (gnus-summary-position-point))
5932 ;; If not, we try the first unread, if that is wanted.
5934 gnus-auto-select-same
5935 (gnus-summary-first-unread-article))
5936 (gnus-summary-position-point)
5937 (gnus-message 6 "Wrapped"))
5938 ;; Try to get next/previous article not displayed in this group.
5939 ((and gnus-auto-extend-newsgroup
5940 (not unread) (not subject))
5941 (gnus-summary-goto-article
5942 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5943 nil (count-lines (point-min) (point))))
5944 ;; Go to next/previous group.
5946 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5947 (gnus-summary-jump-to-group gnus-newsgroup-name))
5948 (let ((cmd last-command-char)
5951 (set-buffer gnus-group-buffer)
5954 (if (eq gnus-keep-same-level 'best)
5955 (gnus-summary-best-group gnus-newsgroup-name)
5956 (gnus-summary-search-group backward gnus-keep-same-level))))
5957 ;; For some reason, the group window gets selected. We change
5959 (select-window (get-buffer-window (current-buffer)))
5960 ;; Select next unread newsgroup automagically.
5962 ((or (not gnus-auto-select-next)
5964 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5965 ((or (eq gnus-auto-select-next 'quietly)
5966 (and (eq gnus-auto-select-next 'slightly-quietly)
5968 (and (eq gnus-auto-select-next 'almost-quietly)
5969 (gnus-summary-last-article-p)))
5971 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5973 (gnus-message 7 "No more%s articles (%s)..."
5974 (if unread " unread" "")
5975 (if group (concat "selecting " group)
5977 (gnus-summary-next-group nil group backward)))
5979 (when (gnus-key-press-event-p last-input-event)
5980 (gnus-summary-walk-group-buffer
5981 gnus-newsgroup-name cmd unread backward point))))))))
5983 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5984 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5985 (?\C-p (gnus-group-prev-unread-group 1))))
5986 (cursor-in-echo-area t)
5987 keve key group ended)
5989 (set-buffer gnus-group-buffer)
5992 (if (eq gnus-keep-same-level 'best)
5993 (gnus-summary-best-group gnus-newsgroup-name)
5994 (gnus-summary-search-group backward gnus-keep-same-level))))
5997 5 "No more%s articles%s" (if unread " unread" "")
5999 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6000 (format " (Type %s for %s [%s])"
6001 (single-key-description cmd) group
6002 (car (gnus-gethash group gnus-newsrc-hashtb)))
6003 (format " (Type %s to exit %s)"
6004 (single-key-description cmd)
6005 gnus-newsgroup-name)))
6006 ;; Confirm auto selection.
6007 (setq key (car (setq keve (gnus-read-event-char))))
6010 ((assq key keystrokes)
6011 (let ((obuf (current-buffer)))
6012 (switch-to-buffer gnus-group-buffer)
6014 (gnus-group-jump-to-group group))
6015 (eval (cadr (assq key keystrokes)))
6016 (setq group (gnus-group-group-name))
6017 (switch-to-buffer obuf))
6021 (gnus-ephemeral-group-p gnus-newsgroup-name))
6023 (gnus-summary-next-group nil group backward)))
6025 (push (cdr keve) unread-command-events))))))
6027 (defun gnus-summary-next-unread-article ()
6028 "Select unread article after current one."
6030 (gnus-summary-next-article
6031 (or (not (eq gnus-summary-goto-unread 'never))
6032 (gnus-summary-last-article-p (gnus-summary-article-number)))
6033 (and gnus-auto-select-same
6034 (gnus-summary-article-subject))))
6036 (defun gnus-summary-prev-article (&optional unread subject)
6037 "Select the article after the current one.
6038 If UNREAD is non-nil, only unread articles are selected."
6040 (gnus-summary-next-article unread subject t))
6042 (defun gnus-summary-prev-unread-article ()
6043 "Select unread article before current one."
6045 (gnus-summary-prev-article
6046 (or (not (eq gnus-summary-goto-unread 'never))
6047 (gnus-summary-first-article-p (gnus-summary-article-number)))
6048 (and gnus-auto-select-same
6049 (gnus-summary-article-subject))))
6051 (defun gnus-summary-next-page (&optional lines circular)
6052 "Show next page of the selected article.
6053 If at the end of the current article, select the next article.
6054 LINES says how many lines should be scrolled up.
6056 If CIRCULAR is non-nil, go to the start of the article instead of
6057 selecting the next article when reaching the end of the current
6060 (setq gnus-summary-buffer (current-buffer))
6061 (gnus-set-global-variables)
6062 (let ((article (gnus-summary-article-number))
6063 (article-window (get-buffer-window gnus-article-buffer t))
6065 ;; If the buffer is empty, we have no article.
6067 (error "No article to select"))
6068 (gnus-configure-windows 'article)
6069 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6070 (if (and (eq gnus-summary-goto-unread 'never)
6071 (not (gnus-summary-last-article-p article)))
6072 (gnus-summary-next-article)
6073 (gnus-summary-next-unread-article))
6074 (if (or (null gnus-current-article)
6075 (null gnus-article-current)
6076 (/= article (cdr gnus-article-current))
6077 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6078 ;; Selected subject is different from current article's.
6079 (gnus-summary-display-article article)
6080 (when article-window
6081 (gnus-eval-in-buffer-window gnus-article-buffer
6082 (setq endp (gnus-article-next-page lines)))
6085 (gnus-summary-beginning-of-article))
6087 (gnus-message 3 "End of message"))
6089 (if (and (eq gnus-summary-goto-unread 'never)
6090 (not (gnus-summary-last-article-p article)))
6091 (gnus-summary-next-article)
6092 (gnus-summary-next-unread-article))))))))
6093 (gnus-summary-recenter)
6094 (gnus-summary-position-point)))
6096 (defun gnus-summary-prev-page (&optional lines move)
6097 "Show previous page of selected article.
6098 Argument LINES specifies lines to be scrolled down.
6099 If MOVE, move to the previous unread article if point is at
6100 the beginning of the buffer."
6102 (let ((article (gnus-summary-article-number))
6103 (article-window (get-buffer-window gnus-article-buffer t))
6105 (gnus-configure-windows 'article)
6106 (if (or (null gnus-current-article)
6107 (null gnus-article-current)
6108 (/= article (cdr gnus-article-current))
6109 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6110 ;; Selected subject is different from current article's.
6111 (gnus-summary-display-article article)
6112 (gnus-summary-recenter)
6113 (when article-window
6114 (gnus-eval-in-buffer-window gnus-article-buffer
6115 (setq endp (gnus-article-prev-page lines)))
6116 (when (and move endp)
6118 (gnus-message 3 "Beginning of message"))
6120 (if (and (eq gnus-summary-goto-unread 'never)
6121 (not (gnus-summary-first-article-p article)))
6122 (gnus-summary-prev-article)
6123 (gnus-summary-prev-unread-article))))))))
6124 (gnus-summary-position-point))
6126 (defun gnus-summary-prev-page-or-article (&optional lines)
6127 "Show previous page of selected article.
6128 Argument LINES specifies lines to be scrolled down.
6129 If at the beginning of the article, go to the next article."
6131 (gnus-summary-prev-page lines t))
6133 (defun gnus-summary-scroll-up (lines)
6134 "Scroll up (or down) one line current article.
6135 Argument LINES specifies lines to be scrolled up (or down if negative)."
6137 (gnus-configure-windows 'article)
6138 (gnus-summary-show-thread)
6139 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6140 (gnus-eval-in-buffer-window gnus-article-buffer
6142 (when (gnus-article-next-page lines)
6143 (gnus-message 3 "End of message")))
6145 (gnus-article-prev-page (- lines))))))
6146 (gnus-summary-recenter)
6147 (gnus-summary-position-point))
6149 (defun gnus-summary-scroll-down (lines)
6150 "Scroll down (or up) one line current article.
6151 Argument LINES specifies lines to be scrolled down (or up if negative)."
6153 (gnus-summary-scroll-up (- lines)))
6155 (defun gnus-summary-next-same-subject ()
6156 "Select next article which has the same subject as current one."
6158 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6160 (defun gnus-summary-prev-same-subject ()
6161 "Select previous article which has the same subject as current one."
6163 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6165 (defun gnus-summary-next-unread-same-subject ()
6166 "Select next unread article which has the same subject as current one."
6168 (gnus-summary-next-article t (gnus-summary-article-subject)))
6170 (defun gnus-summary-prev-unread-same-subject ()
6171 "Select previous unread article which has the same subject as current one."
6173 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6175 (defun gnus-summary-first-unread-article ()
6176 "Select the first unread article.
6177 Return nil if there are no unread articles."
6180 (when (gnus-summary-first-subject t)
6181 (gnus-summary-show-thread)
6182 (gnus-summary-first-subject t)
6183 (gnus-summary-display-article (gnus-summary-article-number)))
6184 (gnus-summary-position-point)))
6186 (defun gnus-summary-first-unread-subject ()
6187 "Place the point on the subject line of the first unread article.
6188 Return nil if there are no unread articles."
6191 (when (gnus-summary-first-subject t)
6192 (gnus-summary-show-thread)
6193 (gnus-summary-first-subject t))
6194 (gnus-summary-position-point)))
6196 (defun gnus-summary-first-article ()
6197 "Select the first article.
6198 Return nil if there are no articles."
6201 (when (gnus-summary-first-subject)
6202 (gnus-summary-show-thread)
6203 (gnus-summary-first-subject)
6204 (gnus-summary-display-article (gnus-summary-article-number)))
6205 (gnus-summary-position-point)))
6207 (defun gnus-summary-best-unread-article ()
6208 "Select the unread article with the highest score."
6210 (let ((best -1000000)
6211 (data gnus-newsgroup-data)
6214 (and (gnus-data-unread-p (car data))
6216 (gnus-summary-article-score (gnus-data-number (car data))))
6219 article (gnus-data-number (car data))))
6220 (setq data (cdr data)))
6223 (gnus-summary-goto-article article)
6224 (error "No unread articles"))
6225 (gnus-summary-position-point))))
6227 (defun gnus-summary-last-subject ()
6228 "Go to the last displayed subject line in the group."
6229 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6231 (gnus-summary-goto-subject article))))
6233 (defun gnus-summary-goto-article (article &optional all-headers force)
6234 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6235 If ALL-HEADERS is non-nil, no header lines are hidden.
6236 If FORCE, go to the article even if it isn't displayed. If FORCE
6237 is a number, it is the line the article is to be displayed on."
6241 "Article number or Message-ID: "
6242 (mapcar (lambda (number) (list (int-to-string number)))
6243 gnus-newsgroup-limit))
6247 (if (and (stringp article)
6248 (string-match "@" article))
6249 (gnus-summary-refer-article article)
6250 (when (stringp article)
6251 (setq article (string-to-number article)))
6252 (if (gnus-summary-goto-subject article force)
6253 (gnus-summary-display-article article all-headers)
6254 (gnus-message 4 "Couldn't go to article %s" article) nil))
6255 (gnus-summary-position-point)))
6257 (defun gnus-summary-goto-last-article ()
6258 "Go to the previously read article."
6261 (when gnus-last-article
6262 (gnus-summary-goto-article gnus-last-article nil t))
6263 (gnus-summary-position-point)))
6265 (defun gnus-summary-pop-article (number)
6266 "Pop one article off the history and go to the previous.
6267 NUMBER articles will be popped off."
6270 (setq gnus-newsgroup-history
6271 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6273 (gnus-summary-goto-article (car to) nil t)
6274 (error "Article history empty")))
6275 (gnus-summary-position-point))
6277 ;; Summary commands and functions for limiting the summary buffer.
6279 (defun gnus-summary-limit-to-articles (n)
6280 "Limit the summary buffer to the next N articles.
6281 If not given a prefix, use the process marked articles instead."
6284 (let ((articles (gnus-summary-work-articles n)))
6285 (setq gnus-newsgroup-processable nil)
6286 (gnus-summary-limit articles))
6287 (gnus-summary-position-point)))
6289 (defun gnus-summary-pop-limit (&optional total)
6290 "Restore the previous limit.
6291 If given a prefix, remove all limits."
6294 (setq gnus-newsgroup-limits
6295 (list (mapcar (lambda (h) (mail-header-number h))
6296 gnus-newsgroup-headers))))
6297 (unless gnus-newsgroup-limits
6298 (error "No limit to pop"))
6300 (gnus-summary-limit nil 'pop)
6301 (gnus-summary-position-point)))
6303 (defun gnus-summary-limit-to-subject (subject &optional header)
6304 "Limit the summary buffer to articles that have subjects that match a regexp."
6305 (interactive "sLimit to subject (regexp): ")
6307 (setq header "subject"))
6308 (when (not (equal "" subject))
6310 (let ((articles (gnus-summary-find-matching
6311 (or header "subject") subject 'all)))
6313 (error "Found no matches for \"%s\"" subject))
6314 (gnus-summary-limit articles))
6315 (gnus-summary-position-point))))
6317 (defun gnus-summary-limit-to-author (from)
6318 "Limit the summary buffer to articles that have authors that match a regexp."
6319 (interactive "sLimit to author (regexp): ")
6320 (gnus-summary-limit-to-subject from "from"))
6322 (defun gnus-summary-limit-to-age (age &optional younger-p)
6323 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6324 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6325 articles that are younger than AGE days."
6327 (let ((younger current-prefix-arg)
6330 (while (not days-got)
6331 (setq days (if younger
6332 (read-string "Limit to articles within (in days): ")
6333 (read-string "Limit to articles old than (in days): ")))
6334 (when (> (length days) 0)
6335 (setq days (read days)))
6338 (message "Please enter a number.")
6340 (list days younger)))
6342 (let ((data gnus-newsgroup-data)
6343 (cutoff (days-to-time age))
6344 articles d date is-younger)
6345 (while (setq d (pop data))
6346 (when (and (vectorp (gnus-data-header d))
6347 (setq date (mail-header-date (gnus-data-header d))))
6348 (setq is-younger (time-less-p
6349 (time-since (condition-case ()
6356 (push (gnus-data-number d) articles))))
6357 (gnus-summary-limit (nreverse articles)))
6358 (gnus-summary-position-point)))
6360 (defun gnus-summary-limit-to-extra (header regexp)
6361 "Limit the summary buffer to articles that match an 'extra' header."
6365 (gnus-completing-read
6366 (symbol-name (car gnus-extra-headers))
6367 "Limit extra header:"
6369 (cons (symbol-name x) x))
6374 (read-string (format "Limit to header %s (regexp): " header)))))
6375 (when (not (equal "" regexp))
6377 (let ((articles (gnus-summary-find-matching
6378 (cons 'extra header) regexp 'all)))
6380 (error "Found no matches for \"%s\"" regexp))
6381 (gnus-summary-limit articles))
6382 (gnus-summary-position-point))))
6384 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6386 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6388 (defun gnus-summary-limit-to-unread (&optional all)
6389 "Limit the summary buffer to articles that are not marked as read.
6390 If ALL is non-nil, limit strictly to unread articles."
6393 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6394 (gnus-summary-limit-to-marks
6395 ;; Concat all the marks that say that an article is read and have
6397 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6398 gnus-killed-mark gnus-kill-file-mark
6399 gnus-low-score-mark gnus-expirable-mark
6400 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6401 gnus-duplicate-mark gnus-souped-mark)
6404 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6405 (make-obsolete 'gnus-summary-delete-marked-with
6406 'gnus-summary-limit-exlude-marks)
6408 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6409 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6410 If REVERSE, limit the summary buffer to articles that are marked
6411 with MARKS. MARKS can either be a string of marks or a list of marks.
6412 Returns how many articles were removed."
6413 (interactive "sMarks: ")
6414 (gnus-summary-limit-to-marks marks t))
6416 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6417 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6418 If REVERSE (the prefix), limit the summary buffer to articles that are
6419 not marked with MARKS. MARKS can either be a string of marks or a
6421 Returns how many articles were removed."
6422 (interactive "sMarks: \nP")
6424 (let ((data gnus-newsgroup-data)
6425 (marks (if (listp marks) marks
6426 (append marks nil))) ; Transform to list.
6429 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6430 (memq (gnus-data-mark (car data)) marks))
6431 (push (gnus-data-number (car data)) articles))
6432 (setq data (cdr data)))
6433 (gnus-summary-limit articles))
6434 (gnus-summary-position-point)))
6436 (defun gnus-summary-limit-to-score (&optional score)
6437 "Limit to articles with score at or above SCORE."
6439 (setq score (if score
6440 (prefix-numeric-value score)
6441 (or gnus-summary-default-score 0)))
6442 (let ((data gnus-newsgroup-data)
6445 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6447 (push (gnus-data-number (car data)) articles))
6448 (setq data (cdr data)))
6450 (gnus-summary-limit articles)
6451 (gnus-summary-position-point))))
6453 (defun gnus-summary-limit-include-thread (id)
6454 "Display all the hidden articles that in the current thread."
6455 (interactive (list (mail-header-id (gnus-summary-article-header))))
6456 (let ((articles (gnus-articles-in-thread
6457 (gnus-id-to-thread (gnus-root-id id)))))
6459 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6460 (gnus-summary-position-point))))
6462 (defun gnus-summary-limit-include-dormant ()
6463 "Display all the hidden articles that are marked as dormant.
6464 Note that this command only works on a subset of the articles currently
6465 fetched for this group."
6467 (unless gnus-newsgroup-dormant
6468 (error "There are no dormant articles in this group"))
6470 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6471 (gnus-summary-position-point)))
6473 (defun gnus-summary-limit-exclude-dormant ()
6474 "Hide all dormant articles."
6477 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6478 (gnus-summary-position-point)))
6480 (defun gnus-summary-limit-exclude-childless-dormant ()
6481 "Hide all dormant articles that have no children."
6483 (let ((data (gnus-data-list t))
6484 articles d children)
6485 ;; Find all articles that are either not dormant or have
6487 (while (setq d (pop data))
6488 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6490 (gnus-article-children (gnus-data-number d)))
6493 (when (memq (car children) articles)
6498 (push (gnus-data-number d) articles)))
6501 (gnus-summary-limit articles)
6502 (gnus-summary-position-point))))
6504 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6505 "Mark all unread excluded articles as read.
6506 If ALL, mark even excluded ticked and dormants as read."
6508 (let ((articles (gnus-sorted-complement
6510 (mapcar (lambda (h) (mail-header-number h))
6511 gnus-newsgroup-headers)
6513 (sort gnus-newsgroup-limit '<)))
6515 (setq gnus-newsgroup-unreads
6516 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6518 (setq gnus-newsgroup-dormant nil
6519 gnus-newsgroup-marked nil
6520 gnus-newsgroup-reads
6522 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6523 gnus-newsgroup-reads))
6524 (while (setq article (pop articles))
6525 (unless (or (memq article gnus-newsgroup-dormant)
6526 (memq article gnus-newsgroup-marked))
6527 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6529 (defun gnus-summary-limit (articles &optional pop)
6531 ;; We pop the previous limit off the stack and use that.
6532 (setq articles (car gnus-newsgroup-limits)
6533 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6534 ;; We use the new limit, so we push the old limit on the stack.
6535 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6537 (setq gnus-newsgroup-limit articles)
6538 (let ((total (length gnus-newsgroup-data))
6539 (data (gnus-data-find-list (gnus-summary-article-number)))
6540 (gnus-summary-mark-below nil) ; Inhibit this.
6542 ;; This will do all the work of generating the new summary buffer
6543 ;; according to the new limit.
6544 (gnus-summary-prepare)
6545 ;; Hide any threads, possibly.
6546 (and gnus-show-threads
6547 gnus-thread-hide-subtree
6548 (gnus-summary-hide-all-threads))
6549 ;; Try to return to the article you were at, or one in the
6552 ;; We try to find some article after the current one.
6554 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6557 (setq data (cdr data))))
6559 ;; If there is no data, that means that we were after the last
6560 ;; article. The same goes when we can't find any articles
6561 ;; after the current one.
6562 (goto-char (point-max))
6563 (gnus-summary-find-prev))
6564 (gnus-set-mode-line 'summary)
6565 ;; We return how many articles were removed from the summary
6566 ;; buffer as a result of the new limit.
6567 (- total (length gnus-newsgroup-data))))
6569 (defsubst gnus-invisible-cut-children (threads)
6572 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6577 (defsubst gnus-cut-thread (thread)
6578 "Go forwards in the thread until we find an article that we want to display."
6579 (when (or (eq gnus-fetch-old-headers 'some)
6580 (eq gnus-fetch-old-headers 'invisible)
6581 (numberp gnus-fetch-old-headers)
6582 (eq gnus-build-sparse-threads 'some)
6583 (eq gnus-build-sparse-threads 'more))
6584 ;; Deal with old-fetched headers and sparse threads.
6588 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6589 (gnus-summary-article-ancient-p
6590 (mail-header-number (car thread))))
6591 (if (or (<= (length (cdr thread)) 1)
6592 (eq gnus-fetch-old-headers 'invisible))
6593 (setq gnus-newsgroup-limit
6594 (delq (mail-header-number (car thread))
6595 gnus-newsgroup-limit)
6596 thread (cadr thread))
6597 (when (gnus-invisible-cut-children (cdr thread))
6598 (let ((th (cdr thread)))
6600 (if (memq (mail-header-number (caar th))
6601 gnus-newsgroup-limit)
6602 (setq thread (car th)
6604 (setq th (cdr th))))))))))
6607 (defun gnus-cut-threads (threads)
6608 "Cut off all uninteresting articles from the beginning of threads."
6609 (when (or (eq gnus-fetch-old-headers 'some)
6610 (eq gnus-fetch-old-headers 'invisible)
6611 (numberp gnus-fetch-old-headers)
6612 (eq gnus-build-sparse-threads 'some)
6613 (eq gnus-build-sparse-threads 'more))
6616 (setcar th (gnus-cut-thread (car th)))
6617 (setq th (cdr th)))))
6618 ;; Remove nixed out threads.
6621 (defun gnus-summary-initial-limit (&optional show-if-empty)
6622 "Figure out what the initial limit is supposed to be on group entry.
6623 This entails weeding out unwanted dormants, low-scored articles,
6624 fetch-old-headers verbiage, and so on."
6625 ;; Most groups have nothing to remove.
6626 (if (or gnus-inhibit-limiting
6627 (and (null gnus-newsgroup-dormant)
6628 (not (eq gnus-fetch-old-headers 'some))
6629 (not (numberp gnus-fetch-old-headers))
6630 (not (eq gnus-fetch-old-headers 'invisible))
6631 (null gnus-summary-expunge-below)
6632 (not (eq gnus-build-sparse-threads 'some))
6633 (not (eq gnus-build-sparse-threads 'more))
6634 (null gnus-thread-expunge-below)
6635 (not gnus-use-nocem)))
6637 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6638 (setq gnus-newsgroup-limit nil)
6641 (unless (car (symbol-value node))
6642 ;; These threads have no parents -- they are roots.
6643 (let ((nodes (cdr (symbol-value node)))
6646 (if (and gnus-thread-expunge-below
6647 (< (gnus-thread-total-score (car nodes))
6648 gnus-thread-expunge-below))
6649 (gnus-expunge-thread (pop nodes))
6650 (setq thread (pop nodes))
6651 (gnus-summary-limit-children thread))))))
6652 gnus-newsgroup-dependencies)
6653 ;; If this limitation resulted in an empty group, we might
6654 ;; pop the previous limit and use it instead.
6655 (when (and (not gnus-newsgroup-limit)
6657 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6658 gnus-newsgroup-limit))
6660 (defun gnus-summary-limit-children (thread)
6661 "Return 1 if this subthread is visible and 0 if it is not."
6662 ;; First we get the number of visible children to this thread. This
6663 ;; is done by recursing down the thread using this function, so this
6664 ;; will really go down to a leaf article first, before slowly
6665 ;; working its way up towards the root.
6669 (apply '+ (mapcar 'gnus-summary-limit-children
6672 (number (mail-header-number (car thread)))
6675 (not (memq number gnus-newsgroup-marked))
6677 ;; If this article is dormant and has absolutely no visible
6678 ;; children, then this article isn't visible.
6679 (and (memq number gnus-newsgroup-dormant)
6681 ;; If this is "fetch-old-headered" and there is no
6682 ;; visible children, then we don't want this article.
6683 (and (or (eq gnus-fetch-old-headers 'some)
6684 (numberp gnus-fetch-old-headers))
6685 (gnus-summary-article-ancient-p number)
6687 ;; If this is "fetch-old-headered" and `invisible', then
6688 ;; we don't want this article.
6689 (and (eq gnus-fetch-old-headers 'invisible)
6690 (gnus-summary-article-ancient-p number))
6691 ;; If this is a sparsely inserted article with no children,
6692 ;; we don't want it.
6693 (and (eq gnus-build-sparse-threads 'some)
6694 (gnus-summary-article-sparse-p number)
6696 ;; If we use expunging, and this article is really
6697 ;; low-scored, then we don't want this article.
6698 (when (and gnus-summary-expunge-below
6700 (or (cdr (assq number gnus-newsgroup-scored))
6701 gnus-summary-default-score))
6702 gnus-summary-expunge-below))
6703 ;; We increase the expunge-tally here, but that has
6704 ;; nothing to do with the limits, really.
6705 (incf gnus-newsgroup-expunged-tally)
6706 ;; We also mark as read here, if that's wanted.
6707 (when (and gnus-summary-mark-below
6708 (< score gnus-summary-mark-below))
6709 (setq gnus-newsgroup-unreads
6710 (delq number gnus-newsgroup-unreads))
6711 (if gnus-newsgroup-auto-expire
6712 (push number gnus-newsgroup-expirable)
6713 (push (cons number gnus-low-score-mark)
6714 gnus-newsgroup-reads)))
6716 ;; Check NoCeM things.
6717 (if (and gnus-use-nocem
6718 (gnus-nocem-unwanted-article-p
6719 (mail-header-id (car thread))))
6721 (setq gnus-newsgroup-unreads
6722 (delq number gnus-newsgroup-unreads))
6724 ;; Nope, invisible article.
6726 ;; Ok, this article is to be visible, so we add it to the limit
6728 (push number gnus-newsgroup-limit)
6731 (defun gnus-expunge-thread (thread)
6732 "Mark all articles in THREAD as read."
6733 (let* ((number (mail-header-number (car thread))))
6734 (incf gnus-newsgroup-expunged-tally)
6735 ;; We also mark as read here, if that's wanted.
6736 (setq gnus-newsgroup-unreads
6737 (delq number gnus-newsgroup-unreads))
6738 (if gnus-newsgroup-auto-expire
6739 (push number gnus-newsgroup-expirable)
6740 (push (cons number gnus-low-score-mark)
6741 gnus-newsgroup-reads)))
6742 ;; Go recursively through all subthreads.
6743 (mapcar 'gnus-expunge-thread (cdr thread)))
6745 ;; Summary article oriented commands
6747 (defun gnus-summary-refer-parent-article (n)
6748 "Refer parent article N times.
6749 If N is negative, go to ancestor -N instead.
6750 The difference between N and the number of articles fetched is returned."
6754 (when (not (natnump n))
6759 (setq header (gnus-summary-article-header))
6760 (if (and (eq (mail-header-number header)
6761 (cdr gnus-article-current))
6762 (equal gnus-newsgroup-name
6763 (car gnus-article-current)))
6764 ;; If we try to find the parent of the currently
6765 ;; displayed article, then we take a look at the actual
6766 ;; References header, since this is slightly more
6767 ;; reliable than the References field we got from the
6770 (set-buffer gnus-original-article-buffer)
6771 (nnheader-narrow-to-headers)
6772 (unless (setq ref (message-fetch-field "references"))
6773 (setq ref (message-fetch-field "in-reply-to")))
6776 ;; It's not the current article, so we take a bet on
6777 ;; the value we got from the server.
6778 (mail-header-references header)))
6780 (not (equal ref "")))
6781 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6782 (gnus-message 1 "Couldn't find parent"))
6783 (gnus-message 1 "No references in article %d"
6784 (gnus-summary-article-number))
6787 (gnus-summary-position-point)
6790 (defun gnus-summary-refer-references ()
6791 "Fetch all articles mentioned in the References header.
6792 Return the number of articles fetched."
6794 (let ((ref (mail-header-references (gnus-summary-article-header)))
6795 (current (gnus-summary-article-number))
6799 (error "No References in the current article")
6800 ;; For each Message-ID in the References header...
6801 (while (string-match "<[^>]*>" ref)
6803 ;; ... fetch that article.
6804 (gnus-summary-refer-article
6805 (prog1 (match-string 0 ref)
6806 (setq ref (substring ref (match-end 0))))))
6807 (gnus-summary-goto-subject current)
6808 (gnus-summary-position-point)
6811 (defun gnus-summary-refer-thread (&optional limit)
6812 "Fetch all articles in the current thread.
6813 If LIMIT (the numerical prefix), fetch that many old headers instead
6814 of what's specified by the `gnus-refer-thread-limit' variable."
6816 (let ((id (mail-header-id (gnus-summary-article-header)))
6817 (limit (if limit (prefix-numeric-value limit)
6818 gnus-refer-thread-limit)))
6819 ;; We want to fetch LIMIT *old* headers, but we also have to
6820 ;; re-fetch all the headers in the current buffer, because many of
6821 ;; them may be undisplayed. So we adjust LIMIT.
6822 (when (numberp limit)
6823 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6824 (unless (eq gnus-fetch-old-headers 'invisible)
6825 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6826 ;; Retrieve the headers and read them in.
6827 (if (eq (gnus-retrieve-headers
6828 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6830 (gnus-build-all-threads)
6831 (error "Can't fetch thread from backends that don't support NOV"))
6832 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6833 (gnus-summary-limit-include-thread id)))
6835 (defun gnus-summary-refer-article (message-id)
6836 "Fetch an article specified by MESSAGE-ID."
6837 (interactive "sMessage-ID: ")
6838 (when (and (stringp message-id)
6839 (not (zerop (length message-id))))
6840 ;; Construct the correct Message-ID if necessary.
6841 ;; Suggested by tale@pawl.rpi.edu.
6842 (unless (string-match "^<" message-id)
6843 (setq message-id (concat "<" message-id)))
6844 (unless (string-match ">$" message-id)
6845 (setq message-id (concat message-id ">")))
6846 (let* ((header (gnus-id-to-header message-id))
6848 (gnus-summary-article-sparse-p
6849 (mail-header-number header))
6850 (memq (mail-header-number header)
6851 gnus-newsgroup-limit)))
6854 ;; If the article is present in the buffer we just go to it.
6856 (or (not (gnus-summary-article-sparse-p
6857 (mail-header-number header)))
6860 (gnus-summary-goto-article
6861 (mail-header-number header) nil t)
6863 (gnus-summary-update-article (mail-header-number header)))))
6865 ;; We fetch the article.
6867 (dolist (gnus-override-method (gnus-refer-article-methods))
6868 (gnus-check-server gnus-override-method)
6869 ;; Fetch the header, and display the article.
6870 (when (setq number (gnus-summary-insert-subject message-id))
6871 (gnus-summary-select-article nil nil nil number)
6873 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6875 (defun gnus-refer-article-methods ()
6876 "Return a list of referrable methods."
6878 ;; No method, so we default to current and native.
6879 ((null gnus-refer-article-method)
6880 (list gnus-current-select-method gnus-select-method))
6882 ((eq 'current gnus-refer-article-method)
6883 (list gnus-current-select-method))
6884 ;; List of select methods.
6885 ((not (and (symbolp (car gnus-refer-article-method))
6886 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6888 (dolist (method gnus-refer-article-method)
6889 (push (if (eq 'current method)
6890 gnus-current-select-method
6894 ;; One single select method.
6896 (list gnus-refer-article-method))))
6898 (defun gnus-summary-edit-parameters ()
6899 "Edit the group parameters of the current group."
6901 (gnus-group-edit-group gnus-newsgroup-name 'params))
6903 (defun gnus-summary-customize-parameters ()
6904 "Customize the group parameters of the current group."
6906 (gnus-group-customize gnus-newsgroup-name))
6908 (defun gnus-summary-enter-digest-group (&optional force)
6909 "Enter an nndoc group based on the current article.
6910 If FORCE, force a digest interpretation. If not, try
6911 to guess what the document format is."
6913 (let ((conf gnus-current-window-configuration))
6915 (gnus-summary-select-article))
6916 (setq gnus-current-window-configuration conf)
6917 (let* ((name (format "%s-%d"
6918 (gnus-group-prefixed-name
6919 gnus-newsgroup-name (list 'nndoc ""))
6921 (set-buffer gnus-summary-buffer)
6922 gnus-current-article)))
6923 (ogroup gnus-newsgroup-name)
6924 (params (append (gnus-info-params (gnus-get-info ogroup))
6925 (list (cons 'to-group ogroup))
6926 (list (cons 'save-article-group ogroup))))
6927 (case-fold-search t)
6928 (buf (current-buffer))
6931 (set-buffer gnus-original-article-buffer)
6932 ;; Have the digest group inherit the main mail address of
6933 ;; the parent article.
6934 (when (setq to-address (or (message-fetch-field "reply-to")
6935 (message-fetch-field "from")))
6936 (setq params (append
6937 (list (cons 'to-address
6938 (funcall gnus-decode-encoded-word-function
6940 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6941 (insert-buffer-substring gnus-original-article-buffer)
6942 ;; Remove lines that may lead nndoc to misinterpret the
6945 (goto-char (point-min))
6946 (or (search-forward "\n\n" nil t) (point)))
6947 (goto-char (point-min))
6948 (delete-matching-lines "^Path:\\|^From ")
6951 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6952 (gnus-newsgroup-ephemeral-ignored-charsets
6953 gnus-newsgroup-ignored-charsets))
6954 (gnus-group-read-ephemeral-group
6955 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6957 ,(if force 'mbox 'guess))) t))
6958 ;; Make all postings to this group go to the parent group.
6959 (nconc (gnus-info-params (gnus-get-info name))
6961 ;; Couldn't select this doc group.
6962 (switch-to-buffer buf)
6963 (gnus-set-global-variables)
6964 (gnus-configure-windows 'summary)
6965 (gnus-message 3 "Article couldn't be entered?"))
6966 (kill-buffer dig)))))
6968 (defun gnus-summary-read-document (n)
6969 "Open a new group based on the current article(s).
6970 This will allow you to read digests and other similar
6971 documents as newsgroups.
6972 Obeys the standard process/prefix convention."
6974 (let* ((articles (gnus-summary-work-articles n))
6975 (ogroup gnus-newsgroup-name)
6976 (params (append (gnus-info-params (gnus-get-info ogroup))
6977 (list (cons 'to-group ogroup))))
6978 article group egroup groups vgroup)
6979 (while (setq article (pop articles))
6980 (setq group (format "%s-%d" gnus-newsgroup-name article))
6981 (gnus-summary-remove-process-mark article)
6982 (when (gnus-summary-display-article article)
6985 (insert-buffer-substring gnus-original-article-buffer)
6986 ;; Remove some headers that may lead nndoc to make
6988 (message-narrow-to-head)
6989 (goto-char (point-min))
6990 (delete-matching-lines "^\\(Path\\):\\|^From ")
6993 (gnus-group-read-ephemeral-group
6994 group `(nndoc ,group (nndoc-address ,(current-buffer))
6995 (nndoc-article-type guess))
6998 ;; Make all postings to this group go to the parent group.
6999 (nconc (gnus-info-params (gnus-get-info egroup))
7001 (push egroup groups))
7002 ;; Couldn't select this doc group.
7003 (gnus-error 3 "Article couldn't be entered"))))))
7004 ;; Now we have selected all the documents.
7007 (error "None of the articles could be interpreted as documents"))
7008 ((gnus-group-read-ephemeral-group
7009 (setq vgroup (format
7010 "nnvirtual:%s-%s" gnus-newsgroup-name
7011 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7012 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7014 (cons (current-buffer) 'summary)))
7016 (error "Couldn't select virtual nndoc group")))))
7018 (defun gnus-summary-isearch-article (&optional regexp-p)
7019 "Do incremental search forward on the current article.
7020 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7022 (gnus-summary-select-article)
7023 (gnus-configure-windows 'article)
7024 (gnus-eval-in-buffer-window gnus-article-buffer
7027 (isearch-forward regexp-p))))
7029 (defun gnus-summary-search-article-forward (regexp &optional backward)
7030 "Search for an article containing REGEXP forward.
7031 If BACKWARD, search backward instead."
7034 (format "Search article %s (regexp%s): "
7035 (if current-prefix-arg "backward" "forward")
7036 (if gnus-last-search-regexp
7037 (concat ", default " gnus-last-search-regexp)
7039 current-prefix-arg))
7040 (if (string-equal regexp "")
7041 (setq regexp (or gnus-last-search-regexp ""))
7042 (setq gnus-last-search-regexp regexp))
7043 (if (gnus-summary-search-article regexp backward)
7044 (gnus-summary-show-thread)
7045 (error "Search failed: \"%s\"" regexp)))
7047 (defun gnus-summary-search-article-backward (regexp)
7048 "Search for an article containing REGEXP backward."
7051 (format "Search article backward (regexp%s): "
7052 (if gnus-last-search-regexp
7053 (concat ", default " gnus-last-search-regexp)
7055 (gnus-summary-search-article-forward regexp 'backward))
7057 (defun gnus-summary-search-article (regexp &optional backward)
7058 "Search for an article containing REGEXP.
7059 Optional argument BACKWARD means do search for backward.
7060 `gnus-select-article-hook' is not called during the search."
7061 ;; We have to require this here to make sure that the following
7062 ;; dynamic binding isn't shadowed by autoloading.
7063 (require 'gnus-async)
7065 (let ((gnus-select-article-hook nil) ;Disable hook.
7066 (gnus-article-prepare-hook nil)
7067 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7068 (gnus-use-article-prefetch nil)
7069 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7070 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7071 (sum (current-buffer))
7072 (gnus-display-mime-function nil)
7075 (gnus-save-hidden-threads
7076 (gnus-summary-select-article)
7077 (set-buffer gnus-article-buffer)
7078 (goto-char (window-point (get-buffer-window (current-buffer))))
7082 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7084 (re-search-backward regexp nil t)
7085 (re-search-forward regexp nil t))
7086 ;; We found the regexp.
7091 (get-buffer-window (current-buffer))
7095 (get-buffer-window (current-buffer))
7098 (setq point (point)))
7099 ;; We didn't find it, so we go to the next article.
7102 (while (eq found 'not)
7103 (if (not (if backward (gnus-summary-find-prev)
7104 (gnus-summary-find-next)))
7105 ;; No more articles.
7107 ;; Select the next article and adjust point.
7108 (unless (gnus-summary-article-sparse-p
7109 (gnus-summary-article-number))
7111 (gnus-summary-select-article)
7112 (set-buffer gnus-article-buffer)
7114 (goto-char (if backward (point-max) (point-min))))))))
7115 (gnus-message 7 ""))
7116 ;; Return whether we found the regexp.
7117 (when (eq found 'found)
7119 (gnus-summary-show-thread)
7120 (gnus-summary-goto-subject gnus-current-article)
7121 (gnus-summary-position-point)
7124 (defun gnus-summary-find-matching (header regexp &optional backward unread
7126 "Return a list of all articles that match REGEXP on HEADER.
7127 The search stars on the current article and goes forwards unless
7128 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7129 If UNREAD is non-nil, only unread articles will
7130 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7131 in the comparisons."
7132 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7133 (gnus-data-find-list
7134 (gnus-summary-article-number) (gnus-data-list backward))))
7135 (case-fold-search (not not-case-fold))
7138 (if (eq (car header) 'extra)
7141 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7143 (error "%s is an invalid header" header))
7144 (unless (fboundp (intern (concat "mail-header-" header)))
7145 (error "%s is not a valid header" header))
7146 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7149 (and (or (not unread) ; We want all articles...
7150 (gnus-data-unread-p d)) ; Or just unreads.
7151 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7152 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7153 (push (gnus-data-number d) articles)) ; Success!
7154 (setq data (cdr data)))
7155 (nreverse articles)))
7157 (defun gnus-summary-execute-command (header regexp command &optional backward)
7158 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7159 If HEADER is an empty string (or nil), the match is done on the entire
7160 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7162 (list (let ((completion-ignore-case t))
7165 (mapcar (lambda (string) (list string))
7166 '("Number" "Subject" "From" "Lines" "Date"
7167 "Message-ID" "Xref" "References" "Body"))
7168 nil 'require-match))
7169 (read-string "Regexp: ")
7170 (read-key-sequence "Command: ")
7171 current-prefix-arg))
7172 (when (equal header "Body")
7174 ;; Hidden thread subtrees must be searched as well.
7175 (gnus-summary-show-all-threads)
7176 ;; We don't want to change current point nor window configuration.
7178 (save-window-excursion
7179 (gnus-message 6 "Executing %s..." (key-description command))
7180 ;; We'd like to execute COMMAND interactively so as to give arguments.
7181 (gnus-execute header regexp
7182 `(call-interactively ',(key-binding command))
7184 (gnus-message 6 "Executing %s...done" (key-description command)))))
7186 (defun gnus-summary-beginning-of-article ()
7187 "Scroll the article back to the beginning."
7189 (gnus-summary-select-article)
7190 (gnus-configure-windows 'article)
7191 (gnus-eval-in-buffer-window gnus-article-buffer
7193 (goto-char (point-min))
7194 (when gnus-page-broken
7195 (gnus-narrow-to-page))))
7197 (defun gnus-summary-end-of-article ()
7198 "Scroll to the end of the article."
7200 (gnus-summary-select-article)
7201 (gnus-configure-windows 'article)
7202 (gnus-eval-in-buffer-window gnus-article-buffer
7204 (goto-char (point-max))
7206 (when gnus-page-broken
7207 (gnus-narrow-to-page))))
7209 (defun gnus-summary-print-article (&optional filename n)
7210 "Generate and print a PostScript image of the N next (mail) articles.
7212 If N is negative, print the N previous articles. If N is nil and articles
7213 have been marked with the process mark, print these instead.
7215 If the optional first argument FILENAME is nil, send the image to the
7216 printer. If FILENAME is a string, save the PostScript image in a file with
7217 that name. If FILENAME is a number, prompt the user for the name of the file
7219 (interactive (list (ps-print-preprint current-prefix-arg)
7220 current-prefix-arg))
7221 (dolist (article (gnus-summary-work-articles n))
7222 (gnus-summary-select-article nil nil 'pseudo article)
7223 (gnus-eval-in-buffer-window gnus-article-buffer
7224 (let ((buffer (generate-new-buffer " *print*")))
7227 (copy-to-buffer buffer (point-min) (point-max))
7229 (gnus-article-delete-invisible-text)
7230 (let ((ps-left-header
7233 (mail-header-subject gnus-current-headers) ")")
7235 (mail-header-from gnus-current-headers) ")")))
7238 "/pagenumberstring load"
7240 (mail-header-date gnus-current-headers) ")"))))
7241 (gnus-run-hooks 'gnus-ps-print-hook)
7243 (ps-print-buffer-with-faces filename))))
7244 (kill-buffer buffer))))))
7246 (defun gnus-summary-show-article (&optional arg)
7247 "Force re-fetching of the current article.
7248 If ARG (the prefix) is a number, show the article with the charset
7249 defined in `gnus-summary-show-article-charset-alist', or the charset
7251 If ARG (the prefix) is non-nil and not a number, show the raw article
7252 without any article massaging functions being run."
7256 (let ((gnus-newsgroup-charset
7257 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7258 (read-coding-system "Charset: ")))
7259 (gnus-newsgroup-ignored-charsets 'gnus-all))
7260 (gnus-summary-select-article nil 'force)))
7262 ;; Select the article the normal way.
7263 (gnus-summary-select-article nil 'force))
7265 ;; We have to require this here to make sure that the following
7266 ;; dynamic binding isn't shadowed by autoloading.
7267 (require 'gnus-async)
7269 ;; Bind the article treatment functions to nil.
7270 (let ((gnus-have-all-headers t)
7271 gnus-article-prepare-hook
7272 gnus-article-decode-hook
7273 gnus-display-mime-function
7275 ;; Destroy any MIME parts.
7276 (when (gnus-buffer-live-p gnus-article-buffer)
7278 (set-buffer gnus-article-buffer)
7279 (mm-destroy-parts gnus-article-mime-handles)
7280 ;; Set it to nil for safety reason.
7281 (setq gnus-article-mime-handle-alist nil)
7282 (setq gnus-article-mime-handles nil)))
7283 (gnus-summary-select-article nil 'force))))
7284 (gnus-summary-goto-subject gnus-current-article)
7285 (gnus-summary-position-point))
7287 (defun gnus-summary-verbose-headers (&optional arg)
7288 "Toggle permanent full header display.
7289 If ARG is a positive number, turn header display on.
7290 If ARG is a negative number, turn header display off."
7292 (setq gnus-show-all-headers
7293 (cond ((or (not (numberp arg))
7295 (not gnus-show-all-headers))
7298 (gnus-summary-show-article))
7300 (defun gnus-summary-toggle-header (&optional arg)
7301 "Show the headers if they are hidden, or hide them if they are shown.
7302 If ARG is a positive number, show the entire header.
7303 If ARG is a negative number, hide the unwanted header lines."
7306 (set-buffer gnus-article-buffer)
7308 (let* ((buffer-read-only nil)
7309 (inhibit-point-motion-hooks t)
7315 (article-narrow-to-head)
7316 (gnus-article-hidden-text-p 'headers))))
7317 (goto-char (point-min))
7318 (when (search-forward "\n\n" nil t)
7319 (delete-region (point-min) (1- (point))))
7320 (goto-char (point-min))
7322 (set-buffer gnus-original-article-buffer)
7323 (goto-char (point-min))
7324 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7325 (insert-buffer-substring gnus-original-article-buffer 1 e)
7327 (narrow-to-region (point-min) (point))
7328 (article-decode-encoded-words)
7330 (let ((gnus-treat-hide-headers nil)
7331 (gnus-treat-hide-boring-headers nil))
7332 (setq gnus-article-wash-types
7333 (delq 'headers gnus-article-wash-types))
7334 (gnus-treat-article 'head))
7335 (gnus-treat-article 'head)))
7336 (gnus-set-mode-line 'article)))))
7338 (defun gnus-summary-show-all-headers ()
7339 "Make all header lines visible."
7341 (gnus-article-show-all-headers))
7343 (defun gnus-summary-caesar-message (&optional arg)
7344 "Caesar rotate the current article by 13.
7345 The numerical prefix specifies how many places to rotate each letter
7348 (gnus-summary-select-article)
7349 (let ((mail-header-separator ""))
7350 (gnus-eval-in-buffer-window gnus-article-buffer
7353 (let ((start (window-start))
7355 (message-caesar-buffer-body arg)
7356 (set-window-start (get-buffer-window (current-buffer)) start))))))
7358 (defun gnus-summary-stop-page-breaking ()
7359 "Stop page breaking in the current article."
7361 (gnus-summary-select-article)
7362 (gnus-eval-in-buffer-window gnus-article-buffer
7364 (when (gnus-visual-p 'page-marker)
7365 (let ((buffer-read-only nil))
7366 (gnus-remove-text-with-property 'gnus-prev)
7367 (gnus-remove-text-with-property 'gnus-next))
7368 (setq gnus-page-broken nil))))
7370 (defun gnus-summary-move-article (&optional n to-newsgroup
7371 select-method action)
7372 "Move the current article to a different newsgroup.
7373 If N is a positive number, move the N next articles.
7374 If N is a negative number, move the N previous articles.
7375 If N is nil and any articles have been marked with the process mark,
7376 move those articles instead.
7377 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7378 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7379 re-spool using this method.
7381 For this function to work, both the current newsgroup and the
7382 newsgroup that you want to move to have to support the `request-move'
7383 and `request-accept' functions.
7385 ACTION can be either `move' (the default), `crosspost' or `copy'."
7388 (setq action 'move))
7389 ;; Disable marking as read.
7390 (let (gnus-mark-article-hook)
7391 (save-window-excursion
7392 (gnus-summary-select-article)))
7393 ;; Check whether the source group supports the required functions.
7394 (cond ((and (eq action 'move)
7395 (not (gnus-check-backend-function
7396 'request-move-article gnus-newsgroup-name)))
7397 (error "The current group does not support article moving"))
7398 ((and (eq action 'crosspost)
7399 (not (gnus-check-backend-function
7400 'request-replace-article gnus-newsgroup-name)))
7401 (error "The current group does not support article editing")))
7402 (let ((articles (gnus-summary-work-articles n))
7403 (prefix (if (gnus-check-backend-function
7404 'request-move-article gnus-newsgroup-name)
7405 (gnus-group-real-prefix gnus-newsgroup-name)
7407 (names '((move "Move" "Moving")
7408 (copy "Copy" "Copying")
7409 (crosspost "Crosspost" "Crossposting")))
7410 (copy-buf (save-excursion
7411 (nnheader-set-temp-buffer " *copy article*")))
7412 art-group to-method new-xref article to-groups)
7413 (unless (assq action names)
7414 (error "Unknown action %s" action))
7415 ;; Read the newsgroup name.
7416 (when (and (not to-newsgroup)
7417 (not select-method))
7419 (gnus-read-move-group-name
7420 (cadr (assq action names))
7421 (symbol-value (intern (format "gnus-current-%s-group" action)))
7423 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7424 (setq to-method (or select-method
7425 (gnus-server-to-method
7426 (gnus-group-method to-newsgroup))))
7427 ;; Check the method we are to move this article to...
7428 (unless (gnus-check-backend-function
7429 'request-accept-article (car to-method))
7430 (error "%s does not support article copying" (car to-method)))
7431 (unless (gnus-check-server to-method)
7432 (error "Can't open server %s" (car to-method)))
7433 (gnus-message 6 "%s to %s: %s..."
7434 (caddr (assq action names))
7435 (or (car select-method) to-newsgroup) articles)
7437 (setq article (pop articles))
7441 ;; Move the article.
7443 ;; Remove this article from future suppression.
7444 (gnus-dup-unsuppress-article article)
7445 (gnus-request-move-article
7446 article ; Article to move
7447 gnus-newsgroup-name ; From newsgroup
7448 (nth 1 (gnus-find-method-for-group
7449 gnus-newsgroup-name)) ; Server
7450 (list 'gnus-request-accept-article
7451 to-newsgroup (list 'quote select-method)
7452 (not articles) t) ; Accept form
7453 (not articles))) ; Only save nov last time
7454 ;; Copy the article.
7457 (set-buffer copy-buf)
7458 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7459 (gnus-request-accept-article
7460 to-newsgroup select-method (not articles) t))))
7461 ;; Crosspost the article.
7462 ((eq action 'crosspost)
7463 (let ((xref (message-tokenize-header
7464 (mail-header-xref (gnus-summary-article-header article))
7466 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7469 (setq xref (list (system-name))))
7472 (mapconcat 'identity
7473 (delete "Xref:" (delete new-xref xref))
7477 (set-buffer copy-buf)
7478 ;; First put the article in the destination group.
7479 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7480 (when (consp (setq art-group
7481 (gnus-request-accept-article
7482 to-newsgroup select-method (not articles))))
7483 (setq new-xref (concat new-xref " " (car art-group)
7484 ":" (cdr art-group)))
7485 ;; Now we have the new Xrefs header, so we insert
7486 ;; it and replace the new article.
7487 (nnheader-replace-header "Xref" new-xref)
7488 (gnus-request-replace-article
7489 (cdr art-group) to-newsgroup (current-buffer))
7493 (gnus-message 1 "Couldn't %s article %s: %s"
7494 (cadr (assq action names)) article
7495 (nnheader-get-report (car to-method))))
7496 ((eq art-group 'junk)
7497 (when (eq action 'move)
7498 (gnus-summary-mark-article article gnus-canceled-mark)
7499 (gnus-message 4 "Deleted article %s" article)))
7501 (let* ((pto-group (gnus-group-prefixed-name
7502 (car art-group) to-method))
7504 (gnus-gethash pto-group gnus-newsrc-hashtb))
7505 (info (nth 2 entry))
7506 (to-group (gnus-info-group info))
7508 ;; Update the group that has been moved to.
7510 (memq action '(move copy)))
7511 (unless (member to-group to-groups)
7512 (push to-group to-groups))
7514 (unless (memq article gnus-newsgroup-unreads)
7515 (push 'read to-marks)
7517 info (gnus-add-to-range (gnus-info-read info)
7518 (list (cdr art-group)))))
7520 ;; See whether the article is to be put in the cache.
7521 (let ((marks gnus-article-mark-lists)
7522 (to-article (cdr art-group)))
7524 ;; Enter the article into the cache in the new group,
7525 ;; if that is required.
7526 (when gnus-use-cache
7527 (gnus-cache-possibly-enter-article
7529 (memq article gnus-newsgroup-marked)
7530 (memq article gnus-newsgroup-dormant)
7531 (memq article gnus-newsgroup-unreads)))
7533 (when gnus-preserve-marks
7534 ;; Copy any marks over to the new group.
7535 (when (and (equal to-group gnus-newsgroup-name)
7536 (not (memq article gnus-newsgroup-unreads)))
7537 ;; Mark this article as read in this group.
7538 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7539 (setcdr (gnus-active to-group) to-article)
7540 (setcdr gnus-newsgroup-active to-article))
7543 (when (memq article (symbol-value
7544 (intern (format "gnus-newsgroup-%s"
7546 (push (cdar marks) to-marks)
7547 ;; If the other group is the same as this group,
7548 ;; then we have to add the mark to the list.
7549 (when (equal to-group gnus-newsgroup-name)
7550 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7553 (intern (format "gnus-newsgroup-%s"
7555 ;; Copy the marks to other group.
7556 (gnus-add-marked-articles
7557 to-group (cdar marks) (list to-article) info))
7558 (setq marks (cdr marks)))
7560 (gnus-request-set-mark to-group (list (list (list to-article)
7565 (concat "(gnus-group-set-info '"
7566 (gnus-prin1-to-string (gnus-get-info to-group))
7569 ;; Update the Xref header in this article to point to
7570 ;; the new crossposted article we have just created.
7571 (when (eq action 'crosspost)
7573 (set-buffer copy-buf)
7574 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7575 (nnheader-replace-header "Xref" new-xref)
7576 (gnus-request-replace-article
7577 article gnus-newsgroup-name (current-buffer)))))
7579 ;;;!!!Why is this necessary?
7580 (set-buffer gnus-summary-buffer)
7582 (gnus-summary-goto-subject article)
7583 (when (eq action 'move)
7584 (gnus-summary-mark-article article gnus-canceled-mark))))
7585 (gnus-summary-remove-process-mark article))
7586 ;; Re-activate all groups that have been moved to.
7589 (set-buffer gnus-group-buffer)
7590 (when (gnus-group-goto-group (car to-groups) t)
7591 (gnus-group-get-new-news-this-group 1 t))
7594 (gnus-kill-buffer copy-buf)
7595 (gnus-summary-position-point)
7596 (gnus-set-mode-line 'summary)))
7598 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7599 "Move the current article to a different newsgroup.
7600 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7601 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7602 re-spool using this method."
7604 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7606 (defun gnus-summary-crosspost-article (&optional n)
7607 "Crosspost the current article to some other group."
7609 (gnus-summary-move-article n nil nil 'crosspost))
7611 (defcustom gnus-summary-respool-default-method nil
7612 "Default method for respooling an article.
7613 If nil, use to the current newsgroup method."
7614 :type '(choice (gnus-select-method :value (nnml ""))
7616 :group 'gnus-summary-mail)
7618 (defun gnus-summary-respool-article (&optional n method)
7619 "Respool the current article.
7620 The article will be squeezed through the mail spooling process again,
7621 which means that it will be put in some mail newsgroup or other
7622 depending on `nnmail-split-methods'.
7623 If N is a positive number, respool the N next articles.
7624 If N is a negative number, respool the N previous articles.
7625 If N is nil and any articles have been marked with the process mark,
7626 respool those articles instead.
7628 Respooling can be done both from mail groups and \"real\" newsgroups.
7629 In the former case, the articles in question will be moved from the
7630 current group into whatever groups they are destined to. In the
7631 latter case, they will be copied into the relevant groups."
7633 (list current-prefix-arg
7634 (let* ((methods (gnus-methods-using 'respool))
7636 (symbol-name (or gnus-summary-respool-default-method
7637 (car (gnus-find-method-for-group
7638 gnus-newsgroup-name)))))
7640 (gnus-completing-read
7641 methname "What backend do you want to use when respooling?"
7642 methods nil t nil 'gnus-mail-method-history))
7645 ((zerop (length (setq ms (gnus-servers-using-backend
7647 (list (intern method) ""))
7651 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7652 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7655 (error "No method given for respooling"))
7656 (if (assoc (symbol-name
7657 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7658 (gnus-methods-using 'respool))
7659 (gnus-summary-move-article n nil method)
7660 (gnus-summary-copy-article n nil method)))
7662 (defun gnus-summary-import-article (file)
7663 "Import an arbitrary file into a mail newsgroup."
7664 (interactive "fImport file: ")
7665 (let ((group gnus-newsgroup-name)
7666 (now (current-time))
7668 (unless (gnus-check-backend-function 'request-accept-article group)
7669 (error "%s does not support article importing" group))
7670 (or (file-readable-p file)
7671 (not (file-regular-p file))
7672 (error "Can't read %s" file))
7674 (set-buffer (gnus-get-buffer-create " *import file*"))
7676 (nnheader-insert-file-contents file)
7677 (goto-char (point-min))
7678 (unless (nnheader-article-p)
7679 ;; This doesn't look like an article, so we fudge some headers.
7680 (setq atts (file-attributes file)
7681 lines (count-lines (point-min) (point-max)))
7682 (insert "From: " (read-string "From: ") "\n"
7683 "Subject: " (read-string "Subject: ") "\n"
7684 "Date: " (message-make-date (nth 5 atts))
7686 "Message-ID: " (message-make-message-id) "\n"
7687 "Lines: " (int-to-string lines) "\n"
7688 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7689 (gnus-request-accept-article group nil t)
7690 (kill-buffer (current-buffer)))))
7692 (defun gnus-summary-article-posted-p ()
7693 "Say whether the current (mail) article is available from news as well.
7694 This will be the case if the article has both been mailed and posted."
7696 (let ((id (mail-header-references (gnus-summary-article-header)))
7697 (gnus-override-method (car (gnus-refer-article-methods))))
7698 (if (gnus-request-head id "")
7699 (gnus-message 2 "The current message was found on %s"
7700 gnus-override-method)
7701 (gnus-message 2 "The current message couldn't be found on %s"
7702 gnus-override-method)
7705 (defun gnus-summary-expire-articles (&optional now)
7706 "Expire all articles that are marked as expirable in the current group."
7708 (when (gnus-check-backend-function
7709 'request-expire-articles gnus-newsgroup-name)
7710 ;; This backend supports expiry.
7711 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7712 (expirable (if total
7714 ;; We need to update the info for
7715 ;; this group for `gnus-list-of-read-articles'
7716 ;; to give us the right answer.
7717 (gnus-run-hooks 'gnus-exit-group-hook)
7718 (gnus-summary-update-info)
7719 (gnus-list-of-read-articles gnus-newsgroup-name))
7720 (setq gnus-newsgroup-expirable
7721 (sort gnus-newsgroup-expirable '<))))
7722 (expiry-wait (if now 'immediate
7723 (gnus-group-find-parameter
7724 gnus-newsgroup-name 'expiry-wait)))
7725 (nnmail-expiry-target
7726 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7727 nnmail-expiry-target))
7730 ;; There are expirable articles in this group, so we run them
7731 ;; through the expiry process.
7732 (gnus-message 6 "Expiring articles...")
7733 (unless (gnus-check-group gnus-newsgroup-name)
7734 (error "Can't open server for %s" gnus-newsgroup-name))
7735 ;; The list of articles that weren't expired is returned.
7738 (let ((nnmail-expiry-wait-function nil)
7739 (nnmail-expiry-wait expiry-wait))
7740 (setq es (gnus-request-expire-articles
7741 expirable gnus-newsgroup-name)))
7742 (setq es (gnus-request-expire-articles
7743 expirable gnus-newsgroup-name))))
7745 (setq gnus-newsgroup-expirable es))
7746 ;; We go through the old list of expirable, and mark all
7747 ;; really expired articles as nonexistent.
7748 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7749 (let ((gnus-use-cache nil))
7751 (unless (memq (car expirable) es)
7752 (when (gnus-data-find (car expirable))
7753 (gnus-summary-mark-article
7754 (car expirable) gnus-canceled-mark)))
7755 (setq expirable (cdr expirable)))))
7756 (gnus-message 6 "Expiring articles...done")))))
7758 (defun gnus-summary-expire-articles-now ()
7759 "Expunge all expirable articles in the current group.
7760 This means that *all* articles that are marked as expirable will be
7761 deleted forever, right now."
7763 (or gnus-expert-user
7765 "Are you really, really, really sure you want to delete all these messages? ")
7767 (gnus-summary-expire-articles t))
7769 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7770 (defun gnus-summary-delete-article (&optional n)
7771 "Delete the N next (mail) articles.
7772 This command actually deletes articles. This is not a marking
7773 command. The article will disappear forever from your life, never to
7775 If N is negative, delete backwards.
7776 If N is nil and articles have been marked with the process mark,
7777 delete these instead."
7779 (unless (gnus-check-backend-function 'request-expire-articles
7780 gnus-newsgroup-name)
7781 (error "The current newsgroup does not support article deletion"))
7782 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7783 (error "Couldn't open server"))
7784 ;; Compute the list of articles to delete.
7785 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7787 (if (and gnus-novice-user
7788 (not (gnus-yes-or-no-p
7789 (format "Do you really want to delete %s forever? "
7790 (if (> (length articles) 1)
7791 (format "these %s articles" (length articles))
7794 ;; Delete the articles.
7795 (setq not-deleted (gnus-request-expire-articles
7796 articles gnus-newsgroup-name 'force))
7798 (gnus-summary-remove-process-mark (car articles))
7799 ;; The backend might not have been able to delete the article
7801 (unless (memq (car articles) not-deleted)
7802 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7803 (setq articles (cdr articles)))
7805 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7806 (gnus-summary-position-point)
7807 (gnus-set-mode-line 'summary)
7810 (defun gnus-summary-edit-article (&optional arg)
7811 "Edit the current article.
7812 This will have permanent effect only in mail groups.
7813 If ARG is nil, edit the decoded articles.
7814 If ARG is 1, edit the raw articles.
7815 If ARG is 2, edit the raw articles even in read-only groups.
7816 Otherwise, allow editing of articles even in read-only
7822 ((eq arg 1) (setq raw t))
7823 ((eq arg 2) (setq raw t
7826 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
7827 (error "Can't edit the raw article in group nndraft:drafts."))
7829 (set-buffer gnus-summary-buffer)
7830 (let ((mail-parse-charset gnus-newsgroup-charset)
7831 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7832 (gnus-set-global-variables)
7833 (when (and (not force)
7834 (gnus-group-read-only-p))
7835 (error "The current newsgroup does not support article editing"))
7836 (gnus-summary-show-article t)
7837 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
7838 (with-current-buffer gnus-article-buffer
7839 (mm-enable-multibyte-mule4)))
7840 (if (equal gnus-newsgroup-name "nndraft:drafts")
7842 (gnus-article-edit-article
7845 (let ((mbl mml-buffer-list))
7846 (setq mml-buffer-list nil)
7848 (make-local-hook 'kill-buffer-hook)
7849 (let ((mml-buffer-list mml-buffer-list))
7850 (setq mml-buffer-list mbl)
7851 (make-local-variable 'mml-buffer-list))
7852 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
7853 `(lambda (no-highlight)
7854 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7855 (message-options message-options)
7856 (message-options-set-recipient)
7857 (mail-parse-ignored-charsets
7858 ',gnus-newsgroup-ignored-charsets))
7859 ,(if (not raw) '(progn
7861 (mml-destroy-buffers)
7862 (remove-hook 'kill-buffer-hook
7863 'mml-destroy-buffers t)
7864 (kill-local-variable 'mml-buffer-list)))
7865 (gnus-summary-edit-article-done
7866 ,(or (mail-header-references gnus-current-headers) "")
7867 ,(gnus-group-read-only-p)
7868 ,gnus-summary-buffer no-highlight))))))))
7870 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7872 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7874 "Make edits to the current article permanent."
7876 ;; Replace the article.
7877 (let ((buf (current-buffer)))
7879 (insert-buffer-substring buf)
7880 (if (and (not read-only)
7881 (not (gnus-request-replace-article
7882 (cdr gnus-article-current) (car gnus-article-current)
7883 (current-buffer) t)))
7884 (error "Couldn't replace article")
7885 ;; Update the summary buffer.
7887 (equal (message-tokenize-header references " ")
7888 (message-tokenize-header
7889 (or (message-fetch-field "references") "") " ")))
7890 ;; We only have to update this line.
7893 (message-narrow-to-head)
7894 (let ((head (buffer-string))
7897 (insert (format "211 %d Article retrieved.\n"
7898 (cdr gnus-article-current)))
7901 (let ((nntp-server-buffer (current-buffer)))
7902 (setq header (car (gnus-get-newsgroup-headers
7904 (set-buffer gnus-summary-buffer)
7905 gnus-newsgroup-dependencies)
7908 (set-buffer gnus-summary-buffer)
7909 (gnus-data-set-header
7910 (gnus-data-find (cdr gnus-article-current))
7912 (gnus-summary-update-article-line
7913 (cdr gnus-article-current) header))))))
7915 (set-buffer (or buffer gnus-summary-buffer))
7916 (gnus-summary-update-article (cdr gnus-article-current)))
7917 ;; Prettify the article buffer again.
7918 (unless no-highlight
7920 (set-buffer gnus-article-buffer)
7921 ;;;!!! Fix this -- article should be rehighlighted.
7922 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7923 (set-buffer gnus-original-article-buffer)
7924 (gnus-request-article
7925 (cdr gnus-article-current)
7926 (car gnus-article-current) (current-buffer))))
7927 ;; Prettify the summary buffer line.
7928 (when (gnus-visual-p 'summary-highlight 'highlight)
7929 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7931 (defun gnus-summary-edit-wash (key)
7932 "Perform editing command KEY in the article buffer."
7936 (message "%s" (concat (this-command-keys) "- "))
7939 (gnus-summary-edit-article)
7940 (execute-kbd-macro (concat (this-command-keys) key))
7941 (gnus-article-edit-done))
7945 (defun gnus-summary-respool-query (&optional silent trace)
7946 "Query where the respool algorithm would put this article."
7948 (let (gnus-mark-article-hook)
7949 (gnus-summary-select-article)
7951 (set-buffer gnus-original-article-buffer)
7953 (message-narrow-to-head)
7954 (let ((groups (nnmail-article-group 'identity trace)))
7957 (message "This message would go to %s"
7958 (mapconcat 'car groups ", "))
7959 (message "This message would go to no groups"))
7962 (defun gnus-summary-respool-trace ()
7963 "Trace where the respool algorithm would put this article.
7964 Display a buffer showing all fancy splitting patterns which matched."
7966 (gnus-summary-respool-query nil t))
7968 ;; Summary marking commands.
7970 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7971 "Mark articles which has the same subject as read, and then select the next.
7972 If UNMARK is positive, remove any kind of mark.
7973 If UNMARK is negative, tick articles."
7976 (setq unmark (prefix-numeric-value unmark)))
7978 (gnus-summary-mark-same-subject
7979 (gnus-summary-article-subject) unmark)))
7980 ;; Select next unread article. If auto-select-same mode, should
7981 ;; select the first unread article.
7982 (gnus-summary-next-article t (and gnus-auto-select-same
7983 (gnus-summary-article-subject)))
7984 (gnus-message 7 "%d article%s marked as %s"
7985 count (if (= count 1) " is" "s are")
7986 (if unmark "unread" "read"))))
7988 (defun gnus-summary-kill-same-subject (&optional unmark)
7989 "Mark articles which has the same subject as read.
7990 If UNMARK is positive, remove any kind of mark.
7991 If UNMARK is negative, tick articles."
7994 (setq unmark (prefix-numeric-value unmark)))
7996 (gnus-summary-mark-same-subject
7997 (gnus-summary-article-subject) unmark)))
7998 ;; If marked as read, go to next unread subject.
8000 ;; Go to next unread subject.
8001 (gnus-summary-next-subject 1 t))
8002 (gnus-message 7 "%d articles are marked as %s"
8003 count (if unmark "unread" "read"))))
8005 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8006 "Mark articles with same SUBJECT as read, and return marked number.
8007 If optional argument UNMARK is positive, remove any kinds of marks.
8008 If optional argument UNMARK is negative, mark articles as unread instead."
8012 ((null unmark) ; Mark as read.
8015 (gnus-summary-mark-article-as-read gnus-killed-mark)
8016 (gnus-summary-show-thread) t)
8017 (gnus-summary-find-subject subject))
8018 (setq count (1+ count))))
8019 ((> unmark 0) ; Tick.
8022 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8023 (gnus-summary-show-thread) t)
8024 (gnus-summary-find-subject subject))
8025 (setq count (1+ count))))
8026 (t ; Mark as unread.
8029 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8030 (gnus-summary-show-thread) t)
8031 (gnus-summary-find-subject subject))
8032 (setq count (1+ count)))))
8033 (gnus-set-mode-line 'summary)
8034 ;; Return the number of marked articles.
8037 (defun gnus-summary-mark-as-processable (n &optional unmark)
8038 "Set the process mark on the next N articles.
8039 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8040 the process mark instead. The difference between N and the actual
8041 number of articles marked is returned."
8043 (let ((backward (< n 0))
8048 (gnus-summary-remove-process-mark
8049 (gnus-summary-article-number))
8050 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8051 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8054 (gnus-message 7 "No more articles"))
8055 (gnus-summary-recenter)
8056 (gnus-summary-position-point)
8059 (defun gnus-summary-unmark-as-processable (n)
8060 "Remove the process mark from the next N articles.
8061 If N is negative, unmark backward instead. The difference between N and
8062 the actual number of articles unmarked is returned."
8064 (gnus-summary-mark-as-processable n t))
8066 (defun gnus-summary-unmark-all-processable ()
8067 "Remove the process mark from all articles."
8070 (while gnus-newsgroup-processable
8071 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8072 (gnus-summary-position-point))
8074 (defun gnus-summary-mark-as-expirable (n)
8075 "Mark N articles forward as expirable.
8076 If N is negative, mark backward instead. The difference between N and
8077 the actual number of articles marked is returned."
8079 (gnus-summary-mark-forward n gnus-expirable-mark))
8081 (defun gnus-summary-mark-article-as-replied (article)
8082 "Mark ARTICLE replied and update the summary line."
8083 (push article gnus-newsgroup-replied)
8084 (let ((buffer-read-only nil))
8085 (when (gnus-summary-goto-subject article nil t)
8086 (gnus-summary-update-secondary-mark article))))
8088 (defun gnus-summary-set-bookmark (article)
8089 "Set a bookmark in current article."
8090 (interactive (list (gnus-summary-article-number)))
8091 (when (or (not (get-buffer gnus-article-buffer))
8092 (not gnus-current-article)
8093 (not gnus-article-current)
8094 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8095 (error "No current article selected"))
8096 ;; Remove old bookmark, if one exists.
8097 (let ((old (assq article gnus-newsgroup-bookmarks)))
8099 (setq gnus-newsgroup-bookmarks
8100 (delq old gnus-newsgroup-bookmarks))))
8101 ;; Set the new bookmark, which is on the form
8102 ;; (article-number . line-number-in-body).
8106 (set-buffer gnus-article-buffer)
8110 (goto-char (point-min))
8111 (search-forward "\n\n" nil t)
8114 gnus-newsgroup-bookmarks)
8115 (gnus-message 6 "A bookmark has been added to the current article."))
8117 (defun gnus-summary-remove-bookmark (article)
8118 "Remove the bookmark from the current article."
8119 (interactive (list (gnus-summary-article-number)))
8120 ;; Remove old bookmark, if one exists.
8121 (let ((old (assq article gnus-newsgroup-bookmarks)))
8124 (setq gnus-newsgroup-bookmarks
8125 (delq old gnus-newsgroup-bookmarks))
8126 (gnus-message 6 "Removed bookmark."))
8127 (gnus-message 6 "No bookmark in current article."))))
8129 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8130 (defun gnus-summary-mark-as-dormant (n)
8131 "Mark N articles forward as dormant.
8132 If N is negative, mark backward instead. The difference between N and
8133 the actual number of articles marked is returned."
8135 (gnus-summary-mark-forward n gnus-dormant-mark))
8137 (defun gnus-summary-set-process-mark (article)
8138 "Set the process mark on ARTICLE and update the summary line."
8139 (setq gnus-newsgroup-processable
8141 (delq article gnus-newsgroup-processable)))
8142 (when (gnus-summary-goto-subject article)
8143 (gnus-summary-show-thread)
8144 (gnus-summary-goto-subject article)
8145 (gnus-summary-update-secondary-mark article)))
8147 (defun gnus-summary-remove-process-mark (article)
8148 "Remove the process mark from ARTICLE and update the summary line."
8149 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8150 (when (gnus-summary-goto-subject article)
8151 (gnus-summary-show-thread)
8152 (gnus-summary-goto-subject article)
8153 (gnus-summary-update-secondary-mark article)))
8155 (defun gnus-summary-set-saved-mark (article)
8156 "Set the process mark on ARTICLE and update the summary line."
8157 (push article gnus-newsgroup-saved)
8158 (when (gnus-summary-goto-subject article)
8159 (gnus-summary-update-secondary-mark article)))
8161 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8162 "Mark N articles as read forwards.
8163 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8164 The difference between N and the actual number of articles marked is
8166 Iff NO-EXPIRE, auto-expiry will be inhibited."
8168 (gnus-summary-show-thread)
8169 (let ((backward (< n 0))
8170 (gnus-summary-goto-unread
8171 (and gnus-summary-goto-unread
8172 (not (eq gnus-summary-goto-unread 'never))
8173 (not (memq mark (list gnus-unread-mark
8174 gnus-ticked-mark gnus-dormant-mark)))))
8176 (mark (or mark gnus-del-mark)))
8178 (gnus-summary-mark-article nil mark no-expire)
8179 (zerop (gnus-summary-next-subject
8181 (and gnus-summary-goto-unread
8182 (not (eq gnus-summary-goto-unread 'never)))
8186 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8187 (gnus-summary-recenter)
8188 (gnus-summary-position-point)
8189 (gnus-set-mode-line 'summary)
8192 (defun gnus-summary-mark-article-as-read (mark)
8193 "Mark the current article quickly as read with MARK."
8194 (let ((article (gnus-summary-article-number)))
8195 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8196 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8197 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8198 (push (cons article mark) gnus-newsgroup-reads)
8199 ;; Possibly remove from cache, if that is used.
8200 (when gnus-use-cache
8201 (gnus-cache-enter-remove-article article))
8202 ;; Allow the backend to change the mark.
8203 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8204 ;; Check for auto-expiry.
8205 (when (and gnus-newsgroup-auto-expire
8206 (memq mark gnus-auto-expirable-marks))
8207 (setq mark gnus-expirable-mark)
8208 ;; Let the backend know about the mark change.
8209 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8210 (push article gnus-newsgroup-expirable))
8211 ;; Set the mark in the buffer.
8212 (gnus-summary-update-mark mark 'unread)
8215 (defun gnus-summary-mark-article-as-unread (mark)
8216 "Mark the current article quickly as unread with MARK."
8217 (let* ((article (gnus-summary-article-number))
8218 (old-mark (gnus-summary-article-mark article)))
8219 ;; Allow the backend to change the mark.
8220 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8221 (if (eq mark old-mark)
8225 (gnus-error 1 "Can't mark negative article numbers")
8227 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8228 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8229 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8230 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8231 (cond ((= mark gnus-ticked-mark)
8232 (push article gnus-newsgroup-marked))
8233 ((= mark gnus-dormant-mark)
8234 (push article gnus-newsgroup-dormant))
8236 (push article gnus-newsgroup-unreads)))
8237 (gnus-pull article gnus-newsgroup-reads)
8239 ;; See whether the article is to be put in the cache.
8241 (vectorp (gnus-summary-article-header article))
8243 (gnus-cache-possibly-enter-article
8244 gnus-newsgroup-name article
8245 (= mark gnus-ticked-mark)
8246 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8249 (gnus-summary-update-mark mark 'unread)
8252 (defun gnus-summary-mark-article (&optional article mark no-expire)
8253 "Mark ARTICLE with MARK. MARK can be any character.
8254 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8255 `??' (dormant) and `?E' (expirable).
8256 If MARK is nil, then the default character `?r' is used.
8257 If ARTICLE is nil, then the article on the current line will be
8259 Iff NO-EXPIRE, auto-expiry will be inhibited."
8260 ;; The mark might be a string.
8261 (when (stringp mark)
8262 (setq mark (aref mark 0)))
8263 ;; If no mark is given, then we check auto-expiring.
8265 (setq mark gnus-del-mark))
8266 (when (and (not no-expire)
8267 gnus-newsgroup-auto-expire
8268 (memq mark gnus-auto-expirable-marks))
8269 (setq mark gnus-expirable-mark))
8270 (let ((article (or article (gnus-summary-article-number)))
8271 (old-mark (gnus-summary-article-mark article)))
8272 ;; Allow the backend to change the mark.
8273 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8274 (if (eq mark old-mark)
8277 (error "No article on current line"))
8278 (if (not (if (or (= mark gnus-unread-mark)
8279 (= mark gnus-ticked-mark)
8280 (= mark gnus-dormant-mark))
8281 (gnus-mark-article-as-unread article mark)
8282 (gnus-mark-article-as-read article mark)))
8284 ;; See whether the article is to be put in the cache.
8286 (not (= mark gnus-canceled-mark))
8287 (vectorp (gnus-summary-article-header article))
8289 (gnus-cache-possibly-enter-article
8290 gnus-newsgroup-name article
8291 (= mark gnus-ticked-mark)
8292 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8294 (when (gnus-summary-goto-subject article nil t)
8295 (let ((buffer-read-only nil))
8296 (gnus-summary-show-thread)
8298 (gnus-summary-update-mark mark 'unread)
8301 (defun gnus-summary-update-secondary-mark (article)
8302 "Update the secondary (read, process, cache) mark."
8303 (gnus-summary-update-mark
8304 (cond ((memq article gnus-newsgroup-processable)
8306 ((memq article gnus-newsgroup-cached)
8308 ((memq article gnus-newsgroup-replied)
8310 ((memq article gnus-newsgroup-saved)
8312 (t gnus-unread-mark))
8314 (when (gnus-visual-p 'summary-highlight 'highlight)
8315 (gnus-run-hooks 'gnus-summary-update-hook))
8318 (defun gnus-summary-update-mark (mark type)
8319 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8320 (buffer-read-only nil))
8321 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8323 (when (looking-at "\r")
8325 (when (<= (+ forward (point)) (point-max))
8326 ;; Go to the right position on the line.
8327 (goto-char (+ forward (point)))
8328 ;; Replace the old mark with the new mark.
8329 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8330 ;; Optionally update the marks by some user rule.
8331 (when (eq type 'unread)
8333 (gnus-data-find (gnus-summary-article-number)) mark)
8334 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8336 (defun gnus-mark-article-as-read (article &optional mark)
8337 "Enter ARTICLE in the pertinent lists and remove it from others."
8338 ;; Make the article expirable.
8339 (let ((mark (or mark gnus-del-mark)))
8340 (if (= mark gnus-expirable-mark)
8341 (push article gnus-newsgroup-expirable)
8342 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8343 ;; Remove from unread and marked lists.
8344 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8345 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8346 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8347 (push (cons article mark) gnus-newsgroup-reads)
8348 ;; Possibly remove from cache, if that is used.
8349 (when gnus-use-cache
8350 (gnus-cache-enter-remove-article article))
8353 (defun gnus-mark-article-as-unread (article &optional mark)
8354 "Enter ARTICLE in the pertinent lists and remove it from others."
8355 (let ((mark (or mark gnus-ticked-mark)))
8358 (gnus-error 1 "Can't mark negative article numbers")
8360 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8361 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8362 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8363 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8365 ;; Unsuppress duplicates?
8366 (when gnus-suppress-duplicates
8367 (gnus-dup-unsuppress-article article))
8369 (cond ((= mark gnus-ticked-mark)
8370 (push article gnus-newsgroup-marked))
8371 ((= mark gnus-dormant-mark)
8372 (push article gnus-newsgroup-dormant))
8374 (push article gnus-newsgroup-unreads)))
8375 (gnus-pull article gnus-newsgroup-reads)
8378 (defalias 'gnus-summary-mark-as-unread-forward
8379 'gnus-summary-tick-article-forward)
8380 (make-obsolete 'gnus-summary-mark-as-unread-forward
8381 'gnus-summary-tick-article-forward)
8382 (defun gnus-summary-tick-article-forward (n)
8383 "Tick N articles forwards.
8384 If N is negative, tick backwards instead.
8385 The difference between N and the number of articles ticked is returned."
8387 (gnus-summary-mark-forward n gnus-ticked-mark))
8389 (defalias 'gnus-summary-mark-as-unread-backward
8390 'gnus-summary-tick-article-backward)
8391 (make-obsolete 'gnus-summary-mark-as-unread-backward
8392 'gnus-summary-tick-article-backward)
8393 (defun gnus-summary-tick-article-backward (n)
8394 "Tick N articles backwards.
8395 The difference between N and the number of articles ticked is returned."
8397 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8399 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8400 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8401 (defun gnus-summary-tick-article (&optional article clear-mark)
8402 "Mark current article as unread.
8403 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8404 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8406 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8409 (defun gnus-summary-mark-as-read-forward (n)
8410 "Mark N articles as read forwards.
8411 If N is negative, mark backwards instead.
8412 The difference between N and the actual number of articles marked is
8415 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8417 (defun gnus-summary-mark-as-read-backward (n)
8418 "Mark the N articles as read backwards.
8419 The difference between N and the actual number of articles marked is
8422 (gnus-summary-mark-forward
8423 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8425 (defun gnus-summary-mark-as-read (&optional article mark)
8426 "Mark current article as read.
8427 ARTICLE specifies the article to be marked as read.
8428 MARK specifies a string to be inserted at the beginning of the line."
8429 (gnus-summary-mark-article article mark))
8431 (defun gnus-summary-clear-mark-forward (n)
8432 "Clear marks from N articles forward.
8433 If N is negative, clear backward instead.
8434 The difference between N and the number of marks cleared is returned."
8436 (gnus-summary-mark-forward n gnus-unread-mark))
8438 (defun gnus-summary-clear-mark-backward (n)
8439 "Clear marks from N articles backward.
8440 The difference between N and the number of marks cleared is returned."
8442 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8444 (defun gnus-summary-mark-unread-as-read ()
8445 "Intended to be used by `gnus-summary-mark-article-hook'."
8446 (when (memq gnus-current-article gnus-newsgroup-unreads)
8447 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8449 (defun gnus-summary-mark-read-and-unread-as-read ()
8450 "Intended to be used by `gnus-summary-mark-article-hook'."
8451 (let ((mark (gnus-summary-article-mark)))
8452 (when (or (gnus-unread-mark-p mark)
8453 (gnus-read-mark-p mark))
8454 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8456 (defun gnus-summary-mark-region-as-read (point mark all)
8457 "Mark all unread articles between point and mark as read.
8458 If given a prefix, mark all articles between point and mark as read,
8459 even ticked and dormant ones."
8460 (interactive "r\nP")
8469 (memq (setq article (gnus-summary-article-number))
8470 gnus-newsgroup-unreads))
8471 (gnus-summary-mark-article article gnus-del-mark))
8473 (gnus-summary-find-next))))))
8475 (defun gnus-summary-mark-below (score mark)
8476 "Mark articles with score less than SCORE with MARK."
8477 (interactive "P\ncMark: ")
8478 (setq score (if score
8479 (prefix-numeric-value score)
8480 (or gnus-summary-default-score 0)))
8482 (set-buffer gnus-summary-buffer)
8483 (goto-char (point-min))
8486 (and (< (gnus-summary-article-score) score)
8487 (gnus-summary-mark-article nil mark))
8488 (gnus-summary-find-next)))))
8490 (defun gnus-summary-kill-below (&optional score)
8491 "Mark articles with score below SCORE as read."
8493 (gnus-summary-mark-below score gnus-killed-mark))
8495 (defun gnus-summary-clear-above (&optional score)
8496 "Clear all marks from articles with score above SCORE."
8498 (gnus-summary-mark-above score gnus-unread-mark))
8500 (defun gnus-summary-tick-above (&optional score)
8501 "Tick all articles with score above SCORE."
8503 (gnus-summary-mark-above score gnus-ticked-mark))
8505 (defun gnus-summary-mark-above (score mark)
8506 "Mark articles with score over SCORE with MARK."
8507 (interactive "P\ncMark: ")
8508 (setq score (if score
8509 (prefix-numeric-value score)
8510 (or gnus-summary-default-score 0)))
8512 (set-buffer gnus-summary-buffer)
8513 (goto-char (point-min))
8515 (when (> (gnus-summary-article-score) score)
8516 (gnus-summary-mark-article nil mark))
8518 (gnus-summary-find-next)))))
8520 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8521 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8522 (defun gnus-summary-limit-include-expunged (&optional no-error)
8523 "Display all the hidden articles that were expunged for low scores."
8525 (let ((buffer-read-only nil))
8526 (let ((scored gnus-newsgroup-scored)
8529 (unless (gnus-summary-goto-subject (caar scored))
8530 (and (setq h (gnus-summary-article-header (caar scored)))
8531 (< (cdar scored) gnus-summary-expunge-below)
8533 (setq scored (cdr scored)))
8535 (when (not no-error)
8536 (error "No expunged articles hidden"))
8537 (goto-char (point-min))
8538 (gnus-summary-prepare-unthreaded (nreverse headers))
8539 (goto-char (point-min))
8540 (gnus-summary-position-point)
8543 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8544 "Mark all unread articles in this newsgroup as read.
8545 If prefix argument ALL is non-nil, ticked and dormant articles will
8546 also be marked as read.
8547 If QUIETLY is non-nil, no questions will be asked.
8548 If TO-HERE is non-nil, it should be a point in the buffer. All
8549 articles before this point will be marked as read.
8550 Note that this function will only catch up the unread article
8551 in the current summary buffer limitation.
8552 The number of articles marked as read is returned."
8557 (not gnus-interactive-catchup) ;Without confirmation?
8561 "Mark absolutely all articles as read? "
8562 "Mark all unread articles as read? ")))
8564 (not gnus-newsgroup-adaptive)
8565 (not gnus-newsgroup-auto-expire)
8566 (not gnus-suppress-duplicates)
8567 (or (not gnus-use-cache)
8568 (eq gnus-use-cache 'passive)))
8571 (setq gnus-newsgroup-marked nil
8572 gnus-newsgroup-dormant nil))
8573 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8574 ;; We actually mark all articles as canceled, which we
8575 ;; have to do when using auto-expiry or adaptive scoring.
8576 (gnus-summary-show-all-threads)
8577 (when (gnus-summary-first-subject (not all) t)
8579 (if to-here (< (point) to-here) t)
8580 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8581 (gnus-summary-find-next (not all) nil nil t))))
8582 (gnus-set-mode-line 'summary))
8584 (gnus-summary-position-point)))
8586 (defun gnus-summary-catchup-to-here (&optional all)
8587 "Mark all unticked articles before the current one as read.
8588 If ALL is non-nil, also mark ticked and dormant articles as read."
8591 (gnus-save-hidden-threads
8592 (let ((beg (point)))
8593 ;; We check that there are unread articles.
8594 (when (or all (gnus-summary-find-prev))
8595 (gnus-summary-catchup all t beg)))))
8596 (gnus-summary-position-point))
8598 (defun gnus-summary-catchup-all (&optional quietly)
8599 "Mark all articles in this newsgroup as read."
8601 (gnus-summary-catchup t quietly))
8603 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8604 "Mark all unread articles in this group as read, then exit.
8605 If prefix argument ALL is non-nil, all articles are marked as read."
8607 (when (gnus-summary-catchup all quietly nil 'fast)
8608 ;; Select next newsgroup or exit.
8609 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8610 (eq gnus-auto-select-next 'quietly))
8611 (gnus-summary-next-group nil)
8612 (gnus-summary-exit))))
8614 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8615 "Mark all articles in this newsgroup as read, and then exit."
8617 (gnus-summary-catchup-and-exit t quietly))
8619 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8620 "Mark all articles in this group as read and select the next group.
8621 If given a prefix, mark all articles, unread as well as ticked, as
8625 (gnus-summary-catchup all))
8626 (gnus-summary-next-group))
8632 (defmacro gnus-with-article (article &rest forms)
8633 "Select ARTICLE and perform FORMS in the original article buffer.
8634 Then replace the article with the result."
8636 ;; We don't want the article to be marked as read.
8637 (let (gnus-mark-article-hook)
8638 (gnus-summary-select-article t t nil ,article))
8639 (set-buffer gnus-original-article-buffer)
8641 (if (not (gnus-check-backend-function
8642 'request-replace-article (car gnus-article-current)))
8643 (gnus-message 5 "Read-only group; not replacing")
8644 (unless (gnus-request-replace-article
8645 ,article (car gnus-article-current)
8647 (error "Couldn't replace article")))
8648 ;; The cache and backlog have to be flushed somewhat.
8649 (when gnus-keep-backlog
8650 (gnus-backlog-remove-article
8651 (car gnus-article-current) (cdr gnus-article-current)))
8652 (when gnus-use-cache
8653 (gnus-cache-update-article
8654 (car gnus-article-current) (cdr gnus-article-current)))))
8656 (put 'gnus-with-article 'lisp-indent-function 1)
8657 (put 'gnus-with-article 'edebug-form-spec '(form body))
8659 ;; Thread-based commands.
8661 (defun gnus-summary-articles-in-thread (&optional article)
8662 "Return a list of all articles in the current thread.
8663 If ARTICLE is non-nil, return all articles in the thread that starts
8665 (let* ((article (or article (gnus-summary-article-number)))
8666 (data (gnus-data-find-list article))
8667 (top-level (gnus-data-level (car data)))
8669 (cond ((null gnus-thread-operation-ignore-subject)
8670 (gnus-simplify-subject-re
8671 (mail-header-subject (gnus-data-header (car data)))))
8672 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8673 (gnus-simplify-subject-fuzzy
8674 (mail-header-subject (gnus-data-header (car data)))))
8676 (end-point (save-excursion
8677 (if (gnus-summary-go-to-next-thread)
8678 (point) (point-max))))
8681 (< (gnus-data-pos (car data)) end-point))
8682 (when (or (not top-subject)
8683 (string= top-subject
8684 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8685 (gnus-simplify-subject-fuzzy
8686 (mail-header-subject
8687 (gnus-data-header (car data))))
8688 (gnus-simplify-subject-re
8689 (mail-header-subject
8690 (gnus-data-header (car data)))))))
8691 (push (gnus-data-number (car data)) articles))
8692 (unless (and (setq data (cdr data))
8693 (> (gnus-data-level (car data)) top-level))
8695 ;; Return the list of articles.
8696 (nreverse articles)))
8698 (defun gnus-summary-rethread-current ()
8699 "Rethread the thread the current article is part of."
8701 (let* ((gnus-show-threads t)
8702 (article (gnus-summary-article-number))
8703 (id (mail-header-id (gnus-summary-article-header)))
8704 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8706 (error "No article on the current line"))
8707 (gnus-rebuild-thread id)
8708 (gnus-summary-goto-subject article)))
8710 (defun gnus-summary-reparent-thread ()
8711 "Make the current article child of the marked (or previous) article.
8713 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8714 is non-nil or the Subject: of both articles are the same."
8716 (unless (not (gnus-group-read-only-p))
8717 (error "The current newsgroup does not support article editing"))
8718 (unless (<= (length gnus-newsgroup-processable) 1)
8719 (error "No more than one article may be marked"))
8720 (save-window-excursion
8721 (let ((gnus-article-buffer " *reparent*")
8722 (current-article (gnus-summary-article-number))
8723 ;; First grab the marked article, otherwise one line up.
8724 (parent-article (if (not (null gnus-newsgroup-processable))
8725 (car gnus-newsgroup-processable)
8727 (if (eq (forward-line -1) 0)
8728 (gnus-summary-article-number)
8729 (error "Beginning of summary buffer"))))))
8730 (unless (not (eq current-article parent-article))
8731 (error "An article may not be self-referential"))
8732 (let ((message-id (mail-header-id
8733 (gnus-summary-article-header parent-article))))
8734 (unless (and message-id (not (equal message-id "")))
8735 (error "No message-id in desired parent"))
8736 (gnus-with-article current-article
8738 (goto-char (point-min))
8739 (message-narrow-to-head)
8740 (if (re-search-forward "^References: " nil t)
8742 (re-search-forward "^[^ \t]" nil t)
8745 (insert " " message-id))
8746 (insert "References: " message-id "\n"))))
8747 (set-buffer gnus-summary-buffer)
8748 (gnus-summary-unmark-all-processable)
8749 (gnus-summary-update-article current-article)
8750 (gnus-summary-rethread-current)
8751 (gnus-message 3 "Article %d is now the child of article %d"
8752 current-article parent-article)))))
8754 (defun gnus-summary-toggle-threads (&optional arg)
8755 "Toggle showing conversation threads.
8756 If ARG is positive number, turn showing conversation threads on."
8758 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8759 (setq gnus-show-threads
8760 (if (null arg) (not gnus-show-threads)
8761 (> (prefix-numeric-value arg) 0)))
8762 (gnus-summary-prepare)
8763 (gnus-summary-goto-subject current)
8764 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8765 (gnus-summary-position-point)))
8767 (defun gnus-summary-show-all-threads ()
8771 (let ((buffer-read-only nil))
8772 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8773 (gnus-summary-position-point))
8775 (defun gnus-summary-show-thread ()
8776 "Show thread subtrees.
8777 Returns nil if no thread was there to be shown."
8779 (let ((buffer-read-only nil)
8781 ;; first goto end then to beg, to have point at beg after let
8782 (end (progn (end-of-line) (point)))
8783 (beg (progn (beginning-of-line) (point))))
8785 ;; Any hidden lines here?
8786 (search-forward "\r" end t)
8787 (subst-char-in-region beg end ?\^M ?\n t)
8789 (gnus-summary-position-point))))
8791 (defun gnus-summary-hide-all-threads ()
8792 "Hide all thread subtrees."
8795 (goto-char (point-min))
8796 (gnus-summary-hide-thread)
8797 (while (zerop (gnus-summary-next-thread 1 t))
8798 (gnus-summary-hide-thread)))
8799 (gnus-summary-position-point))
8801 (defun gnus-summary-hide-thread ()
8802 "Hide thread subtrees.
8803 Returns nil if no threads were there to be hidden."
8805 (let ((buffer-read-only nil)
8807 (article (gnus-summary-article-number)))
8809 ;; Go forward until either the buffer ends or the subthread
8811 (when (and (not (eobp))
8812 (or (zerop (gnus-summary-next-thread 1 t))
8813 (goto-char (point-max))))
8815 (if (and (> (point) start)
8816 (search-backward "\n" start t))
8818 (subst-char-in-region start (point) ?\n ?\^M)
8819 (gnus-summary-goto-subject article))
8823 (defun gnus-summary-go-to-next-thread (&optional previous)
8824 "Go to the same level (or less) next thread.
8825 If PREVIOUS is non-nil, go to previous thread instead.
8826 Return the article number moved to, or nil if moving was impossible."
8827 (let ((level (gnus-summary-thread-level))
8828 (way (if previous -1 1))
8831 (while (and (not (eobp))
8832 (< level (gnus-summary-thread-level)))
8840 (gnus-summary-article-number)
8843 (defun gnus-summary-next-thread (n &optional silent)
8844 "Go to the same level next N'th thread.
8845 If N is negative, search backward instead.
8846 Returns the difference between N and the number of skips actually
8849 If SILENT, don't output messages."
8851 (let ((backward (< n 0))
8854 (gnus-summary-go-to-next-thread backward))
8857 (gnus-summary-position-point))
8858 (when (and (not silent) (/= 0 n))
8859 (gnus-message 7 "No more threads"))
8862 (defun gnus-summary-prev-thread (n)
8863 "Go to the same level previous N'th thread.
8864 Returns the difference between N and the number of skips actually
8867 (gnus-summary-next-thread (- n)))
8869 (defun gnus-summary-go-down-thread ()
8870 "Go down one level in the current thread."
8871 (let ((children (gnus-summary-article-children)))
8873 (gnus-summary-goto-subject (car children)))))
8875 (defun gnus-summary-go-up-thread ()
8876 "Go up one level in the current thread."
8877 (let ((parent (gnus-summary-article-parent)))
8879 (gnus-summary-goto-subject parent))))
8881 (defun gnus-summary-down-thread (n)
8882 "Go down thread N steps.
8883 If N is negative, go up instead.
8884 Returns the difference between N and how many steps down that were
8890 (if up (gnus-summary-go-up-thread)
8891 (gnus-summary-go-down-thread)))
8893 (gnus-summary-position-point)
8895 (gnus-message 7 "Can't go further"))
8898 (defun gnus-summary-up-thread (n)
8899 "Go up thread N steps.
8900 If N is negative, go up instead.
8901 Returns the difference between N and how many steps down that were
8904 (gnus-summary-down-thread (- n)))
8906 (defun gnus-summary-top-thread ()
8907 "Go to the top of the thread."
8909 (while (gnus-summary-go-up-thread))
8910 (gnus-summary-article-number))
8912 (defun gnus-summary-kill-thread (&optional unmark)
8913 "Mark articles under current thread as read.
8914 If the prefix argument is positive, remove any kinds of marks.
8915 If the prefix argument is negative, tick articles instead."
8918 (setq unmark (prefix-numeric-value unmark)))
8919 (let ((articles (gnus-summary-articles-in-thread)))
8921 ;; Expand the thread.
8922 (gnus-summary-show-thread)
8923 ;; Mark all the articles.
8925 (gnus-summary-goto-subject (car articles))
8926 (cond ((null unmark)
8927 (gnus-summary-mark-article-as-read gnus-killed-mark))
8929 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8931 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8932 (setq articles (cdr articles))))
8933 ;; Hide killed subtrees.
8935 gnus-thread-hide-killed
8936 (gnus-summary-hide-thread))
8937 ;; If marked as read, go to next unread subject.
8939 ;; Go to next unread subject.
8940 (gnus-summary-next-subject 1 t)))
8941 (gnus-set-mode-line 'summary))
8943 ;; Summary sorting commands
8945 (defun gnus-summary-sort-by-number (&optional reverse)
8946 "Sort the summary buffer by article number.
8947 Argument REVERSE means reverse order."
8949 (gnus-summary-sort 'number reverse))
8951 (defun gnus-summary-sort-by-author (&optional reverse)
8952 "Sort the summary buffer by author name alphabetically.
8953 If `case-fold-search' is non-nil, case of letters is ignored.
8954 Argument REVERSE means reverse order."
8956 (gnus-summary-sort 'author reverse))
8958 (defun gnus-summary-sort-by-subject (&optional reverse)
8959 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8960 If `case-fold-search' is non-nil, case of letters is ignored.
8961 Argument REVERSE means reverse order."
8963 (gnus-summary-sort 'subject reverse))
8965 (defun gnus-summary-sort-by-date (&optional reverse)
8966 "Sort the summary buffer by date.
8967 Argument REVERSE means reverse order."
8969 (gnus-summary-sort 'date reverse))
8971 (defun gnus-summary-sort-by-score (&optional reverse)
8972 "Sort the summary buffer by score.
8973 Argument REVERSE means reverse order."
8975 (gnus-summary-sort 'score reverse))
8977 (defun gnus-summary-sort-by-lines (&optional reverse)
8978 "Sort the summary buffer by the number of lines.
8979 Argument REVERSE means reverse order."
8981 (gnus-summary-sort 'lines reverse))
8983 (defun gnus-summary-sort-by-chars (&optional reverse)
8984 "Sort the summary buffer by article length.
8985 Argument REVERSE means reverse order."
8987 (gnus-summary-sort 'chars reverse))
8989 (defun gnus-summary-sort (predicate reverse)
8990 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8991 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8992 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8993 (gnus-thread-sort-functions
8998 (gnus-sort-gathered-threads-function
8999 gnus-thread-sort-functions)
9000 (gnus-article-sort-functions
9006 (gnus-summary-prepare-hook nil))
9007 ;; We do the sorting by regenerating the threads.
9008 (gnus-summary-prepare)
9009 ;; Hide subthreads if needed.
9010 (when (and gnus-show-threads gnus-thread-hide-subtree)
9011 (gnus-summary-hide-all-threads))))
9013 ;; Summary saving commands.
9015 (defun gnus-summary-save-article (&optional n not-saved)
9016 "Save the current article using the default saver function.
9017 If N is a positive number, save the N next articles.
9018 If N is a negative number, save the N previous articles.
9019 If N is nil and any articles have been marked with the process mark,
9020 save those articles instead.
9021 The variable `gnus-default-article-saver' specifies the saver function."
9023 (let* ((articles (gnus-summary-work-articles n))
9024 (save-buffer (save-excursion
9025 (nnheader-set-temp-buffer " *Gnus Save*")))
9026 (num (length articles))
9028 (dolist (article articles)
9029 (setq header (gnus-summary-article-header article))
9030 (if (not (vectorp header))
9031 ;; This is a pseudo-article.
9032 (if (assq 'name header)
9033 (gnus-copy-file (cdr (assq 'name header)))
9034 (gnus-message 1 "Article %d is unsaveable" article))
9035 ;; This is a real article.
9036 (save-window-excursion
9037 (gnus-summary-select-article t nil nil article))
9039 (set-buffer save-buffer)
9041 (insert-buffer-substring gnus-original-article-buffer))
9042 (setq file (gnus-article-save save-buffer file num))
9043 (gnus-summary-remove-process-mark article)
9045 (gnus-summary-set-saved-mark article))))
9046 (gnus-kill-buffer save-buffer)
9047 (gnus-summary-position-point)
9048 (gnus-set-mode-line 'summary)
9051 (defun gnus-summary-pipe-output (&optional arg)
9052 "Pipe the current article to a subprocess.
9053 If N is a positive number, pipe the N next articles.
9054 If N is a negative number, pipe the N previous articles.
9055 If N is nil and any articles have been marked with the process mark,
9056 pipe those articles instead."
9058 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9059 (gnus-summary-save-article arg t))
9060 (gnus-configure-windows 'pipe))
9062 (defun gnus-summary-save-article-mail (&optional arg)
9063 "Append the current article to an mail file.
9064 If N is a positive number, save the N next articles.
9065 If N is a negative number, save the N previous articles.
9066 If N is nil and any articles have been marked with the process mark,
9067 save those articles instead."
9069 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9070 (gnus-summary-save-article arg)))
9072 (defun gnus-summary-save-article-rmail (&optional arg)
9073 "Append the current article to an rmail file.
9074 If N is a positive number, save the N next articles.
9075 If N is a negative number, save the N previous articles.
9076 If N is nil and any articles have been marked with the process mark,
9077 save those articles instead."
9079 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9080 (gnus-summary-save-article arg)))
9082 (defun gnus-summary-save-article-file (&optional arg)
9083 "Append the current article to a file.
9084 If N is a positive number, save the N next articles.
9085 If N is a negative number, save the N previous articles.
9086 If N is nil and any articles have been marked with the process mark,
9087 save those articles instead."
9089 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9090 (gnus-summary-save-article arg)))
9092 (defun gnus-summary-write-article-file (&optional arg)
9093 "Write the current article to a file, deleting the previous file.
9094 If N is a positive number, save the N next articles.
9095 If N is a negative number, save the N previous articles.
9096 If N is nil and any articles have been marked with the process mark,
9097 save those articles instead."
9099 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9100 (gnus-summary-save-article arg)))
9102 (defun gnus-summary-save-article-body-file (&optional arg)
9103 "Append the current article body to a file.
9104 If N is a positive number, save the N next articles.
9105 If N is a negative number, save the N previous articles.
9106 If N is nil and any articles have been marked with the process mark,
9107 save those articles instead."
9109 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9110 (gnus-summary-save-article arg)))
9112 (defun gnus-summary-pipe-message (program)
9113 "Pipe the current article through PROGRAM."
9114 (interactive "sProgram: ")
9115 (gnus-summary-select-article)
9116 (let ((mail-header-separator ""))
9117 (gnus-eval-in-buffer-window gnus-article-buffer
9120 (let ((start (window-start))
9122 (message-pipe-buffer-body program)
9123 (set-window-start (get-buffer-window (current-buffer)) start))))))
9125 (defun gnus-get-split-value (methods)
9126 "Return a value based on the split METHODS."
9127 (let (split-name method result match)
9130 (set-buffer gnus-original-article-buffer)
9132 (nnheader-narrow-to-headers)
9133 (while (and methods (not split-name))
9134 (goto-char (point-min))
9135 (setq method (pop methods))
9136 (setq match (car method))
9139 ;; Regular expression.
9141 (re-search-forward match nil t)))
9142 ((gnus-functionp match)
9146 (setq result (funcall match gnus-newsgroup-name))))
9151 (setq result (eval match)))))
9152 (setq split-name (cdr method))
9153 (cond ((stringp result)
9154 (push (expand-file-name
9155 result gnus-article-save-directory)
9158 (setq split-name (append result split-name)))))))))
9159 (nreverse split-name)))
9161 (defun gnus-valid-move-group-p (group)
9164 (symbol-value group)
9165 (gnus-get-function (gnus-find-method-for-group
9166 (symbol-name group)) 'request-accept-article t)))
9168 (defun gnus-read-move-group-name (prompt default articles prefix)
9169 "Read a group name."
9170 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9171 (minibuffer-confirm-incomplete nil) ; XEmacs
9175 (if (> (length articles) 1)
9176 (format "these %d articles" (length articles))
9181 (gnus-completing-read default prom
9183 'gnus-valid-move-group-p
9185 'gnus-group-history))
9186 ((= 1 (length split-name))
9187 (gnus-completing-read (car split-name) prom
9189 'gnus-valid-move-group-p
9191 'gnus-group-history))
9193 (gnus-completing-read nil prom
9194 (mapcar (lambda (el) (list el))
9195 (nreverse split-name))
9197 'gnus-group-history))))
9198 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9200 (if (or (string= to-newsgroup "")
9201 (string= to-newsgroup prefix))
9202 (setq to-newsgroup default))
9203 (unless to-newsgroup
9204 (error "No group name entered"))
9205 (or (gnus-active to-newsgroup)
9206 (gnus-activate-group to-newsgroup nil nil to-method)
9207 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9209 (or (and (gnus-request-create-group to-newsgroup to-method)
9210 (gnus-activate-group
9211 to-newsgroup nil nil to-method)
9212 (gnus-subscribe-group to-newsgroup))
9213 (error "Couldn't create group %s" to-newsgroup)))
9214 (error "No such group: %s" to-newsgroup)))
9217 (defun gnus-summary-save-parts (type dir n &optional reverse)
9218 "Save parts matching TYPE to DIR.
9219 If REVERSE, save parts that do not match TYPE."
9221 (list (read-string "Save parts of type: "
9222 (or (car gnus-summary-save-parts-type-history)
9223 gnus-summary-save-parts-default-mime)
9224 'gnus-summary-save-parts-type-history)
9225 (setq gnus-summary-save-parts-last-directory
9226 (read-file-name "Save to directory: "
9227 gnus-summary-save-parts-last-directory
9229 current-prefix-arg))
9230 (gnus-summary-iterate n
9231 (let ((gnus-display-mime-function nil)
9232 (gnus-inhibit-treatment t))
9233 (gnus-summary-select-article))
9235 (set-buffer gnus-article-buffer)
9236 (let ((handles (or gnus-article-mime-handles
9237 (mm-dissect-buffer) (mm-uu-dissect))))
9239 (gnus-summary-save-parts-1 type dir handles reverse)
9240 (unless gnus-article-mime-handles ;; Don't destroy this case.
9241 (mm-destroy-parts handles)))))))
9243 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9244 (if (stringp (car handle))
9245 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9248 (not (string-match type (mm-handle-media-type handle)))
9249 (string-match type (mm-handle-media-type handle)))
9250 (let ((file (expand-file-name
9251 (file-name-nondirectory
9253 (mail-content-type-get
9254 (mm-handle-disposition handle) 'filename)
9255 (concat gnus-newsgroup-name
9256 "." (number-to-string
9257 (cdr gnus-article-current)))))
9259 (unless (file-exists-p file)
9260 (mm-save-part-to-file handle file))))))
9262 ;; Summary extract commands
9264 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9265 (let ((buffer-read-only nil)
9266 (article (gnus-summary-article-number))
9268 (unless (gnus-summary-goto-subject article)
9269 (error "No such article: %d" article))
9270 (gnus-summary-position-point)
9271 ;; If all commands are to be bunched up on one line, we collect
9273 (unless gnus-view-pseudos-separately
9274 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9277 (setq action (cdr (assq 'action (car ps))))
9278 (setq files (list (cdr (assq 'name (car ps)))))
9279 (while (and ps (cdr ps)
9280 (string= (or action "1")
9281 (or (cdr (assq 'action (cadr ps))) "2")))
9282 (push (cdr (assq 'name (cadr ps))) files)
9283 (setcdr ps (cddr ps)))
9285 (when (not (string-match "%s" action))
9288 (when (assq 'execute (car ps))
9289 (setcdr (assq 'execute (car ps))
9290 (funcall (if (string-match "%s" action)
9299 (setq ps (cdr ps)))))
9300 (if (and gnus-view-pseudos (not not-view))
9302 (when (assq 'execute (car pslist))
9303 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9304 (eq gnus-view-pseudos 'not-confirm)))
9305 (setq pslist (cdr pslist)))
9308 (setq after-article (or (cdr (assq 'article (car pslist)))
9309 (gnus-summary-article-number)))
9310 (gnus-summary-goto-subject after-article)
9313 (insert " " (file-name-nondirectory
9314 (cdr (assq 'name (car pslist))))
9315 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9317 (forward-line -1) ; back to `b'
9318 (gnus-add-text-properties
9319 b (1- e) (list 'gnus-number gnus-reffed-article-number
9320 gnus-mouse-face-prop gnus-mouse-face))
9322 after-article gnus-reffed-article-number
9323 gnus-unread-mark b (car pslist) 0 (- e b))
9324 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9325 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9326 (setq pslist (cdr pslist)))))))
9328 (defun gnus-pseudos< (p1 p2)
9329 (let ((c1 (cdr (assq 'action p1)))
9330 (c2 (cdr (assq 'action p2))))
9331 (and c1 c2 (string< c1 c2))))
9333 (defun gnus-request-pseudo-article (props)
9334 (cond ((assq 'execute props)
9335 (gnus-execute-command (cdr (assq 'execute props)))))
9336 (let ((gnus-current-article (gnus-summary-article-number)))
9337 (gnus-run-hooks 'gnus-mark-article-hook)))
9339 (defun gnus-execute-command (command &optional automatic)
9341 (gnus-article-setup-buffer)
9342 (set-buffer gnus-article-buffer)
9343 (setq buffer-read-only nil)
9344 (let ((command (if automatic command
9345 (read-string "Command: " (cons command 0)))))
9347 (insert "$ " command "\n\n")
9348 (if gnus-view-pseudo-asynchronously
9349 (start-process "gnus-execute" (current-buffer) shell-file-name
9350 shell-command-switch command)
9351 (call-process shell-file-name nil t nil
9352 shell-command-switch command)))))
9354 ;; Summary kill commands.
9356 (defun gnus-summary-edit-global-kill (article)
9357 "Edit the \"global\" kill file."
9358 (interactive (list (gnus-summary-article-number)))
9359 (gnus-group-edit-global-kill article))
9361 (defun gnus-summary-edit-local-kill ()
9362 "Edit a local kill file applied to the current newsgroup."
9364 (setq gnus-current-headers (gnus-summary-article-header))
9365 (gnus-group-edit-local-kill
9366 (gnus-summary-article-number) gnus-newsgroup-name))
9370 (defun gnus-read-header (id &optional header)
9371 "Read the headers of article ID and enter them into the Gnus system."
9372 (let ((group gnus-newsgroup-name)
9373 (gnus-override-method
9375 gnus-override-method
9376 (and (gnus-news-group-p gnus-newsgroup-name)
9377 (car (gnus-refer-article-methods)))))
9379 ;; First we check to see whether the header in question is already
9382 ;; This is a Message-ID.
9383 (setq header (or header (gnus-id-to-header id)))
9384 ;; This is an article number.
9385 (setq header (or header (gnus-summary-article-header id))))
9387 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9388 ;; We have found the header.
9390 ;; If this is a sparse article, we have to nix out its
9391 ;; previous entry in the thread hashtb.
9393 (gnus-summary-article-sparse-p (mail-header-number header)))
9394 (let* ((parent (gnus-parent-id (mail-header-references header)))
9395 (thread (and parent (gnus-id-to-thread parent))))
9397 (delq (assq header thread) thread))))
9398 ;; We have to really fetch the header to this article.
9400 (set-buffer nntp-server-buffer)
9401 (when (setq where (gnus-request-head id group))
9402 (nnheader-fold-continuation-lines)
9403 (goto-char (point-max))
9405 (goto-char (point-min))
9409 ((cdr where) (cdr where))
9410 (header (mail-header-number header))
9411 (t gnus-reffed-article-number))
9413 (insert " Article retrieved.\n"))
9415 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9416 () ; Malformed head.
9417 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9418 (when (and (stringp id)
9419 (not (string= (gnus-group-real-name group)
9421 ;; If we fetched by Message-ID and the article came
9422 ;; from a different group, we fudge some bogus article
9423 ;; numbers for this article.
9424 (mail-header-set-number header gnus-reffed-article-number))
9426 (set-buffer gnus-summary-buffer)
9427 (decf gnus-reffed-article-number)
9428 (gnus-remove-header (mail-header-number header))
9429 (push header gnus-newsgroup-headers)
9430 (setq gnus-current-headers header)
9431 (push (mail-header-number header) gnus-newsgroup-limit)))
9434 (defun gnus-remove-header (number)
9435 "Remove header NUMBER from `gnus-newsgroup-headers'."
9436 (if (and gnus-newsgroup-headers
9437 (= number (mail-header-number (car gnus-newsgroup-headers))))
9438 (pop gnus-newsgroup-headers)
9439 (let ((headers gnus-newsgroup-headers))
9440 (while (and (cdr headers)
9441 (not (= number (mail-header-number (cadr headers)))))
9444 (setcdr headers (cddr headers))))))
9447 ;;; summary highlights
9450 (defun gnus-highlight-selected-summary ()
9451 "Highlight selected article in summary buffer."
9452 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9453 (when gnus-summary-selected-face
9455 (let* ((beg (progn (beginning-of-line) (point)))
9456 (end (progn (end-of-line) (point)))
9457 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9458 (from (if (get-text-property beg gnus-mouse-face-prop)
9460 (or (next-single-property-change
9461 beg gnus-mouse-face-prop nil end)
9466 (or (next-single-property-change
9467 from gnus-mouse-face-prop nil end)
9469 ;; If no mouse-face prop on line we will have to = from = end,
9470 ;; so we highlight the entire line instead.
9471 (when (= (+ to 2) from)
9474 (if gnus-newsgroup-selected-overlay
9475 ;; Move old overlay.
9477 gnus-newsgroup-selected-overlay from to (current-buffer))
9478 ;; Create new overlay.
9480 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9481 'face gnus-summary-selected-face))))))
9483 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9484 (defun gnus-summary-highlight-line ()
9485 "Highlight current line according to `gnus-summary-highlight'."
9486 (let* ((list gnus-summary-highlight)
9488 (end (progn (end-of-line) (point)))
9489 ;; now find out where the line starts and leave point there.
9490 (beg (progn (beginning-of-line) (point)))
9491 (article (gnus-summary-article-number))
9492 (score (or (cdr (assq (or article gnus-current-article)
9493 gnus-newsgroup-scored))
9494 gnus-summary-default-score 0))
9495 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9496 (inhibit-read-only t))
9497 ;; Eval the cars of the lists until we find a match.
9498 (let ((default gnus-summary-default-score))
9500 (not (eval (caar list))))
9501 (setq list (cdr list))))
9502 (let ((face (cdar list)))
9503 (unless (eq face (get-text-property beg 'face))
9504 (gnus-put-text-property-excluding-characters-with-faces
9506 (setq face (if (boundp face) (symbol-value face) face)))
9507 (when gnus-summary-highlight-line-function
9508 (funcall gnus-summary-highlight-line-function article face))))
9511 (defun gnus-update-read-articles (group unread &optional compute)
9512 "Update the list of read articles in GROUP."
9513 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9514 (entry (gnus-gethash group gnus-newsrc-hashtb))
9515 (info (nth 2 entry))
9517 (unread (sort (copy-sequence unread) '<))
9519 (if (or (not info) (not active))
9520 ;; There is no info on this group if it was, in fact,
9521 ;; killed. Gnus stores no information on killed groups, so
9522 ;; there's nothing to be done.
9523 ;; One could store the information somewhere temporarily,
9524 ;; perhaps... Hmmm...
9526 ;; Remove any negative articles numbers.
9527 (while (and unread (< (car unread) 0))
9528 (setq unread (cdr unread)))
9529 ;; Remove any expired article numbers
9530 (while (and unread (< (car unread) (car active)))
9531 (setq unread (cdr unread)))
9532 ;; Compute the ranges of read articles by looking at the list of
9535 (when (/= (car unread) prev)
9536 (push (if (= prev (1- (car unread))) prev
9537 (cons prev (1- (car unread))))
9539 (setq prev (1+ (car unread)))
9540 (setq unread (cdr unread)))
9541 (when (<= prev (cdr active))
9542 (push (cons prev (cdr active)) read))
9543 (setq read (if (> (length read) 1) (nreverse read) read))
9548 ;; Propagate the read marks to the backend.
9549 (when (gnus-check-backend-function 'request-set-mark group)
9550 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9551 (add (gnus-remove-from-range read (gnus-info-read info))))
9553 (unless (gnus-check-group group)
9554 (error "Can't open server for %s" group))
9555 (gnus-request-set-mark
9556 group (delq nil (list (if add (list add 'add '(read)))
9557 (if del (list del 'del '(read))))))
9559 `(gnus-request-set-mark
9562 (if del (list del 'add '(read)))
9563 (if add (list add 'del '(read))))))))))
9564 (set-buffer gnus-group-buffer)
9567 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9568 (gnus-info-set-read ',info ',(gnus-info-read info))
9569 (gnus-get-unread-articles-in-group ',info
9570 (gnus-active ,group))
9571 (gnus-group-update-group ,group t)
9573 ;; Enter this list into the group info.
9574 (gnus-info-set-read info read)
9575 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9576 (gnus-get-unread-articles-in-group info (gnus-active group))
9579 (defun gnus-offer-save-summaries ()
9580 "Offer to save all active summary buffers."
9582 (let ((buflist (buffer-list))
9584 ;; Go through all buffers and find all summaries.
9586 (and (setq bufname (buffer-name (car buflist)))
9587 (string-match "Summary" bufname)
9589 (set-buffer bufname)
9590 ;; We check that this is, indeed, a summary buffer.
9591 (and (eq major-mode 'gnus-summary-mode)
9592 ;; Also make sure this isn't bogus.
9593 gnus-newsgroup-prepared
9594 ;; Also make sure that this isn't a dead summary buffer.
9595 (not gnus-dead-summary-mode)))
9596 (push bufname buffers))
9597 (setq buflist (cdr buflist)))
9598 ;; Go through all these summary buffers and offer to save them.
9601 "Update summary buffer %s? "
9603 (switch-to-buffer buf)
9604 (gnus-summary-exit))
9607 (defun gnus-summary-setup-default-charset ()
9608 "Setup newsgroup default charset."
9609 (if (equal gnus-newsgroup-name "nndraft:drafts")
9610 (setq gnus-newsgroup-charset nil)
9611 (let* ((name (and gnus-newsgroup-name
9612 (gnus-group-real-name gnus-newsgroup-name)))
9614 (or gnus-newsgroup-ephemeral-ignored-charsets
9616 (and gnus-newsgroup-name
9617 (or (gnus-group-find-parameter gnus-newsgroup-name
9618 'ignored-charsets t)
9619 (let ((alist gnus-group-ignored-charsets-alist)
9620 elem (charsets nil))
9621 (while (setq elem (pop alist))
9623 (string-match (car elem) name))
9625 charsets (cdr elem))))
9627 gnus-newsgroup-ignored-charsets))))
9628 (setq gnus-newsgroup-charset
9629 (or gnus-newsgroup-ephemeral-charset
9630 (and gnus-newsgroup-name
9631 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9632 (let ((alist gnus-group-charset-alist)
9634 (while (setq elem (pop alist))
9636 (string-match (car elem) name))
9638 charset (cadr elem))))
9640 gnus-default-charset))
9641 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9642 ignored-charsets))))
9648 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9649 "Display the current article buffer fully MIME-buttonized.
9650 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9651 treated as multipart/mixed."
9654 (let ((gnus-unbuttonized-mime-types nil)
9655 (gnus-mime-display-multipart-as-mixed show-all-parts))
9656 (gnus-summary-show-article)))
9658 (defun gnus-summary-repair-multipart (article)
9659 "Add a Content-Type header to a multipart article without one."
9660 (interactive (list (gnus-summary-article-number)))
9661 (gnus-with-article article
9662 (message-narrow-to-head)
9663 (goto-char (point-max))
9665 (when (search-forward "\n--" nil t)
9666 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9667 (message-narrow-to-head)
9668 (message-remove-header "Mime-Version")
9669 (message-remove-header "Content-Type")
9670 (goto-char (point-max))
9671 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9673 (insert "Mime-Version: 1.0\n")
9675 (let (gnus-mark-article-hook)
9676 (gnus-summary-select-article t t nil article)))
9678 (defun gnus-summary-toggle-display-buttonized ()
9679 "Toggle the buttonizing of the article buffer."
9682 (if (setq gnus-inhibit-mime-unbuttonizing
9683 (not gnus-inhibit-mime-unbuttonizing))
9684 (let ((gnus-unbuttonized-mime-types nil))
9685 (gnus-summary-show-article))
9686 (gnus-summary-show-article)))
9689 ;;; Generic summary marking commands
9692 (defvar gnus-summary-marking-alist
9693 '((read gnus-del-mark "d")
9694 (unread gnus-unread-mark "u")
9695 (ticked gnus-ticked-mark "!")
9696 (dormant gnus-dormant-mark "?")
9697 (expirable gnus-expirable-mark "e"))
9698 "An alist of names/marks/keystrokes.")
9700 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9701 (defvar gnus-summary-mark-map)
9703 (defun gnus-summary-make-all-marking-commands ()
9704 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9705 (dolist (elem gnus-summary-marking-alist)
9706 (apply 'gnus-summary-make-marking-command elem)))
9708 (defun gnus-summary-make-marking-command (name mark keystroke)
9709 (let ((map (make-sparse-keymap)))
9710 (define-key gnus-summary-generic-mark-map keystroke map)
9711 (dolist (lway `((next "next" next nil "n")
9712 (next-unread "next unread" next t "N")
9713 (prev "previous" prev nil "p")
9714 (prev-unread "previous unread" prev t "P")
9715 (nomove "" nil nil ,keystroke)))
9716 (let ((func (gnus-summary-make-marking-command-1
9717 mark (car lway) lway name)))
9718 (setq func (eval func))
9719 (define-key map (nth 4 lway) func)))))
9721 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9723 (format "gnus-summary-put-mark-as-%s%s"
9724 name (if (eq way 'nomove)
9726 (concat "-" (symbol-name way)))))
9729 "Mark the current article as %s%s.
9730 If N, the prefix, then repeat N times.
9731 If N is negative, move in reverse order.
9732 The difference between N and the actual number of articles marked is
9736 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9738 (defun gnus-summary-generic-mark (n mark move unread)
9739 "Mark N articles with MARK."
9740 (unless (eq major-mode 'gnus-summary-mode)
9741 (error "This command can only be used in the summary buffer"))
9742 (gnus-summary-show-thread)
9746 ((eq move 'prev) -1)
9752 nummove (* -1 nummove))))
9754 (gnus-summary-mark-article nil mark)
9755 (zerop (gnus-summary-next-subject nummove unread t)))
9758 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9759 (gnus-summary-recenter)
9760 (gnus-summary-position-point)
9761 (gnus-set-mode-line 'summary)
9764 (gnus-summary-make-all-marking-commands)
9770 (run-hooks 'gnus-sum-load-hook)
9772 ;;; gnus-sum.el ends here