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))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
46 (autoload 'mm-uu-dissect "mm-uu")
48 (defcustom gnus-kill-summary-on-exit t
49 "*If non-nil, kill the summary buffer when you exit from it.
50 If nil, the summary will become a \"*Dead Summary*\" buffer, and
51 it will be killed sometime later."
52 :group 'gnus-summary-exit
55 (defcustom gnus-fetch-old-headers nil
56 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
57 If an unread article in the group refers to an older, already read (or
58 just marked as read) article, the old article will not normally be
59 displayed in the Summary buffer. If this variable is non-nil, Gnus
60 will attempt to grab the headers to the old articles, and thereby
61 build complete threads. If it has the value `some', only enough
62 headers to connect otherwise loose threads will be displayed. This
63 variable can also be a number. In that case, no more than that number
64 of old headers will be fetched. If it has the value `invisible', all
65 old headers will be fetched, but none will be displayed.
67 The server has to support NOV for any of this to work."
69 :type '(choice (const :tag "off" nil)
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-refer-thread-limit 200
75 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
76 If t, fetch all the available old headers."
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-summary-make-false-root 'adopt
82 "*nil means that Gnus won't gather loose threads.
83 If the root of a thread has expired or been read in a previous
84 session, the information necessary to build a complete thread has been
85 lost. Instead of having many small sub-threads from this original thread
86 scattered all over the summary buffer, Gnus can gather them.
88 If non-nil, Gnus will try to gather all loose sub-threads from an
89 original thread into one large thread.
91 If this variable is non-nil, it should be one of `none', `adopt',
94 If this variable is `none', Gnus will not make a false root, but just
95 present the sub-threads after another.
96 If this variable is `dummy', Gnus will create a dummy root that will
97 have all the sub-threads as children.
98 If this variable is `adopt', Gnus will make one of the \"children\"
99 the parent and mark all the step-children as such.
100 If this variable is `empty', the \"children\" are printed with empty
101 subject fields. (Or rather, they will be printed with a string
102 given by the `gnus-summary-same-subject' variable.)"
104 :type '(choice (const :tag "off" nil)
110 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
111 "*A regexp to match subjects to be excluded from loose thread gathering.
112 As loose thread gathering is done on subjects only, that means that
113 there can be many false gatherings performed. By rooting out certain
114 common subjects, gathering might become saner."
118 (defcustom gnus-summary-gather-subject-limit nil
119 "*Maximum length of subject comparisons when gathering loose threads.
120 Use nil to compare full subjects. Setting this variable to a low
121 number will help gather threads that have been corrupted by
122 newsreaders chopping off subject lines, but it might also mean that
123 unrelated articles that have subject that happen to begin with the
124 same few characters will be incorrectly gathered.
126 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
129 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "on" t)))
133 (defcustom gnus-simplify-subject-functions nil
134 "List of functions taking a string argument that simplify subjects.
135 The functions are applied recursively.
137 Useful functions to put in this list include: `gnus-simplify-subject-re',
138 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
140 :type '(repeat function))
142 (defcustom gnus-simplify-ignored-prefixes nil
143 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
145 :type '(choice (const :tag "off" nil)
148 (defcustom gnus-build-sparse-threads nil
149 "*If non-nil, fill in the gaps in threads.
150 If `some', only fill in the gaps that are needed to tie loose threads
151 together. If `more', fill in all leaf nodes that Gnus can find. If
152 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
154 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "all" t)))
159 (defcustom gnus-summary-thread-gathering-function
160 'gnus-gather-threads-by-subject
161 "*Function used for gathering loose threads.
162 There are two pre-defined functions: `gnus-gather-threads-by-subject',
163 which only takes Subjects into consideration; and
164 `gnus-gather-threads-by-references', which compared the References
165 headers of the articles to find matches."
167 :type '(radio (function-item gnus-gather-threads-by-subject)
168 (function-item gnus-gather-threads-by-references)
169 (function :tag "other")))
171 (defcustom gnus-summary-same-subject ""
172 "*String indicating that the current article has the same subject as the previous.
173 This variable will only be used if the value of
174 `gnus-summary-make-false-root' is `empty'."
175 :group 'gnus-summary-format
178 (defcustom gnus-summary-goto-unread t
179 "*If t, many commands will go to the next unread article.
180 This applies to marking commands as well as other commands that
181 \"naturally\" select the next article, like, for instance, `SPC' at
182 the end of an article.
184 If nil, the marking commands do NOT go to the next unread article
185 (they go to the next article instead). If `never', commands that
186 usually go to the next unread article, will go to the next article,
187 whether it is read or not."
188 :group 'gnus-summary-marks
189 :link '(custom-manual "(gnus)Setting Marks")
190 :type '(choice (const :tag "off" nil)
192 (sexp :menu-tag "on" t)))
194 (defcustom gnus-summary-default-score 0
195 "*Default article score level.
196 All scores generated by the score files will be added to this score.
197 If this variable is nil, scoring will be disabled."
198 :group 'gnus-score-default
199 :type '(choice (const :tag "disable")
202 (defcustom gnus-summary-zcore-fuzz 0
203 "*Fuzziness factor for the zcore in the summary buffer.
204 Articles with scores closer than this to `gnus-summary-default-score'
206 :group 'gnus-summary-format
209 (defcustom gnus-simplify-subject-fuzzy-regexp nil
210 "*Strings to be removed when doing fuzzy matches.
211 This can either be a regular expression or list of regular expressions
212 that will be removed from subject strings if fuzzy subject
213 simplification is selected."
215 :type '(repeat regexp))
217 (defcustom gnus-show-threads t
218 "*If non-nil, display threads in summary mode."
222 (defcustom gnus-thread-hide-subtree nil
223 "*If non-nil, hide all threads initially.
224 If threads are hidden, you have to run the command
225 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
226 to expose hidden threads."
230 (defcustom gnus-thread-hide-killed t
231 "*If non-nil, hide killed threads automatically."
235 (defcustom gnus-thread-ignore-subject t
236 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
237 If nil, articles that have different subjects from their parents will
238 start separate threads."
242 (defcustom gnus-thread-operation-ignore-subject t
243 "*If non-nil, subjects will be ignored when doing thread commands.
244 This affects commands like `gnus-summary-kill-thread' and
245 `gnus-summary-lower-thread'.
247 If this variable is nil, articles in the same thread with different
248 subjects will not be included in the operation in question. If this
249 variable is `fuzzy', only articles that have subjects that are fuzzily
250 equal will be included."
252 :type '(choice (const :tag "off" nil)
256 (defcustom gnus-thread-indent-level 4
257 "*Number that says how much each sub-thread should be indented."
261 (defcustom gnus-auto-extend-newsgroup t
262 "*If non-nil, extend newsgroup forward and backward when requested."
263 :group 'gnus-summary-choose
266 (defcustom gnus-auto-select-first t
267 "*If nil, don't select the first unread article when entering a group.
268 If this variable is `best', select the highest-scored unread article
269 in the group. If t, select the first unread article.
271 This variable can also be a function to place point on a likely
272 subject line. Useful values include `gnus-summary-first-unread-subject',
273 `gnus-summary-first-unread-article' and
274 `gnus-summary-best-unread-article'.
276 If you want to prevent automatic selection of the first unread article
277 in some newsgroups, set the variable to nil in
278 `gnus-select-group-hook'."
279 :group 'gnus-group-select
280 :type '(choice (const :tag "none" nil)
282 (sexp :menu-tag "first" t)
283 (function-item gnus-summary-first-unread-subject)
284 (function-item gnus-summary-first-unread-article)
285 (function-item gnus-summary-best-unread-article)))
287 (defcustom gnus-auto-select-next t
288 "*If non-nil, offer to go to the next group from the end of the previous.
289 If the value is t and the next newsgroup is empty, Gnus will exit
290 summary mode and go back to group mode. If the value is neither nil
291 nor t, Gnus will select the following unread newsgroup. In
292 particular, if the value is the symbol `quietly', the next unread
293 newsgroup will be selected without any confirmation, and if it is
294 `almost-quietly', the next group will be selected without any
295 confirmation if you are located on the last article in the group.
296 Finally, if this variable is `slightly-quietly', the `Z n' command
297 will go to the next group without confirmation."
298 :group 'gnus-summary-maneuvering
299 :type '(choice (const :tag "off" nil)
301 (const almost-quietly)
302 (const slightly-quietly)
303 (sexp :menu-tag "on" t)))
305 (defcustom gnus-auto-select-same nil
306 "*If non-nil, select the next article with the same subject.
307 If there are no more articles with the same subject, go to
308 the first unread article."
309 :group 'gnus-summary-maneuvering
312 (defcustom gnus-summary-check-current nil
313 "*If non-nil, consider the current article when moving.
314 The \"unread\" movement commands will stay on the same line if the
315 current article is unread."
316 :group 'gnus-summary-maneuvering
319 (defcustom gnus-auto-center-summary t
320 "*If non-nil, always center the current summary buffer.
321 In particular, if `vertical' do only vertical recentering. If non-nil
322 and non-`vertical', do both horizontal and vertical recentering."
323 :group 'gnus-summary-maneuvering
324 :type '(choice (const :tag "none" nil)
326 (integer :tag "height")
327 (sexp :menu-tag "both" t)))
329 (defcustom gnus-show-all-headers nil
330 "*If non-nil, don't hide any headers."
331 :group 'gnus-article-hiding
332 :group 'gnus-article-headers
335 (defcustom gnus-summary-ignore-duplicates nil
336 "*If non-nil, ignore articles with identical Message-ID headers."
340 (defcustom gnus-single-article-buffer t
341 "*If non-nil, display all articles in the same buffer.
342 If nil, each group will get its own article buffer."
343 :group 'gnus-article-various
346 (defcustom gnus-break-pages t
347 "*If non-nil, do page breaking on articles.
348 The page delimiter is specified by the `gnus-page-delimiter'
350 :group 'gnus-article-various
353 (defcustom gnus-move-split-methods nil
354 "*Variable used to suggest where articles are to be moved to.
355 It uses the same syntax as the `gnus-split-methods' variable.
356 However, whereas `gnus-split-methods' specifies file names as targets,
357 this variable specifies group names."
358 :group 'gnus-summary-mail
359 :type '(repeat (choice (list :value (fun) function)
360 (cons :value ("" "") regexp (repeat string))
363 (defcustom gnus-unread-mark ? ;Whitespace
364 "*Mark used for unread articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-ticked-mark ?!
369 "*Mark used for ticked articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-dormant-mark ??
374 "*Mark used for dormant articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-del-mark ?r
379 "*Mark used for del'd articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-read-mark ?R
384 "*Mark used for read articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-expirable-mark ?E
389 "*Mark used for expirable articles."
390 :group 'gnus-summary-marks
393 (defcustom gnus-killed-mark ?K
394 "*Mark used for killed articles."
395 :group 'gnus-summary-marks
398 (defcustom gnus-souped-mark ?F
399 "*Mark used for killed articles."
400 :group 'gnus-summary-marks
403 (defcustom gnus-kill-file-mark ?X
404 "*Mark used for articles killed by kill files."
405 :group 'gnus-summary-marks
408 (defcustom gnus-low-score-mark ?Y
409 "*Mark used for articles with a low score."
410 :group 'gnus-summary-marks
413 (defcustom gnus-catchup-mark ?C
414 "*Mark used for articles that are caught up."
415 :group 'gnus-summary-marks
418 (defcustom gnus-replied-mark ?A
419 "*Mark used for articles that have been replied to."
420 :group 'gnus-summary-marks
423 (defcustom gnus-cached-mark ?*
424 "*Mark used for articles that are in the cache."
425 :group 'gnus-summary-marks
428 (defcustom gnus-saved-mark ?S
429 "*Mark used for articles that have been saved to."
430 :group 'gnus-summary-marks
433 (defcustom gnus-no-mark ? ;Whitespace
434 "*Mark used for articles that have no other secondary mark."
435 :group 'gnus-summary-marks
438 (defcustom gnus-ancient-mark ?O
439 "*Mark used for ancient articles."
440 :group 'gnus-summary-marks
443 (defcustom gnus-sparse-mark ?Q
444 "*Mark used for sparsely reffed articles."
445 :group 'gnus-summary-marks
448 (defcustom gnus-canceled-mark ?G
449 "*Mark used for canceled articles."
450 :group 'gnus-summary-marks
453 (defcustom gnus-duplicate-mark ?M
454 "*Mark used for duplicate articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-undownloaded-mark ?@
459 "*Mark used for articles that weren't downloaded."
460 :group 'gnus-summary-marks
463 (defcustom gnus-downloadable-mark ?%
464 "*Mark used for articles that are to be downloaded."
465 :group 'gnus-summary-marks
468 (defcustom gnus-unsendable-mark ?=
469 "*Mark used for articles that won't be sent."
470 :group 'gnus-summary-marks
473 (defcustom gnus-score-over-mark ?+
474 "*Score mark used for articles with high scores."
475 :group 'gnus-summary-marks
478 (defcustom gnus-score-below-mark ?-
479 "*Score mark used for articles with low scores."
480 :group 'gnus-summary-marks
483 (defcustom gnus-empty-thread-mark ? ;Whitespace
484 "*There is no thread under the article."
485 :group 'gnus-summary-marks
488 (defcustom gnus-not-empty-thread-mark ?=
489 "*There is a thread under the article."
490 :group 'gnus-summary-marks
493 (defcustom gnus-view-pseudo-asynchronously nil
494 "*If non-nil, Gnus will view pseudo-articles asynchronously."
495 :group 'gnus-extract-view
498 (defcustom gnus-auto-expirable-marks
499 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
500 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
501 gnus-souped-mark gnus-duplicate-mark)
502 "*The list of marks converted into expiration if a group is auto-expirable."
505 :type '(repeat character))
507 (defcustom gnus-inhibit-user-auto-expire t
508 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
513 (defcustom gnus-view-pseudos nil
514 "*If `automatic', pseudo-articles will be viewed automatically.
515 If `not-confirm', pseudos will be viewed automatically, and the user
516 will not be asked to confirm the command."
517 :group 'gnus-extract-view
518 :type '(choice (const :tag "off" nil)
520 (const not-confirm)))
522 (defcustom gnus-view-pseudos-separately t
523 "*If non-nil, one pseudo-article will be created for each file to be viewed.
524 If nil, all files that use the same viewing command will be given as a
525 list of parameters to that command."
526 :group 'gnus-extract-view
529 (defcustom gnus-insert-pseudo-articles t
530 "*If non-nil, insert pseudo-articles when decoding articles."
531 :group 'gnus-extract-view
534 (defcustom gnus-summary-dummy-line-format
536 "*The format specification for the dummy roots in the summary buffer.
537 It works along the same lines as a normal formatting string,
538 with some simple extensions.
541 :group 'gnus-threading
544 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
545 "*The format specification for the summary mode line.
546 It works along the same lines as a normal formatting string,
547 with some simple extensions:
550 %p Unprefixed group name
551 %A Current article number
552 %z Current article score
554 %U Number of unread articles in the group
555 %e Number of unselected articles in the group
556 %Z A string with unread/unselected article counts
557 %g Shortish group name
558 %S Subject of the current article
560 %s Current score file name
561 %d Number of dormant articles
562 %r Number of articles that have been marked as read in this session
563 %E Number of articles expunged by the score files"
564 :group 'gnus-summary-format
567 (defcustom gnus-list-identifiers nil
568 "Regexp that matches list identifiers to be removed from subject.
569 This can also be a list of regexps."
571 :group 'gnus-summary-format
572 :group 'gnus-article-hiding
573 :type '(choice (const :tag "none" nil)
575 (repeat :value (".*") regexp)))
577 (defcustom gnus-summary-mark-below 0
578 "*Mark all articles with a score below this variable as read.
579 This variable is local to each summary buffer and usually set by the
581 :group 'gnus-score-default
584 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
585 "*List of functions used for sorting articles in the summary buffer.
586 This variable is only used when not using a threaded display."
587 :group 'gnus-summary-sort
588 :type '(repeat (choice (function-item gnus-article-sort-by-number)
589 (function-item gnus-article-sort-by-author)
590 (function-item gnus-article-sort-by-subject)
591 (function-item gnus-article-sort-by-date)
592 (function-item gnus-article-sort-by-score)
593 (function :tag "other"))))
595 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
596 "*List of functions used for sorting threads in the summary buffer.
597 By default, threads are sorted by article number.
599 Each function takes two threads and return non-nil if the first thread
600 should be sorted before the other. If you use more than one function,
601 the primary sort function should be the last. You should probably
602 always include `gnus-thread-sort-by-number' in the list of sorting
603 functions -- preferably first.
605 Ready-made functions include `gnus-thread-sort-by-number',
606 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
607 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
608 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
609 :group 'gnus-summary-sort
610 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
611 (function-item gnus-thread-sort-by-author)
612 (function-item gnus-thread-sort-by-subject)
613 (function-item gnus-thread-sort-by-date)
614 (function-item gnus-thread-sort-by-score)
615 (function-item gnus-thread-sort-by-total-score)
616 (function :tag "other"))))
618 (defcustom gnus-thread-score-function '+
619 "*Function used for calculating the total score of a thread.
621 The function is called with the scores of the article and each
622 subthread and should then return the score of the thread.
624 Some functions you can use are `+', `max', or `min'."
625 :group 'gnus-summary-sort
628 (defcustom gnus-summary-expunge-below nil
629 "All articles that have a score less than this variable will be expunged.
630 This variable is local to the summary buffers."
631 :group 'gnus-score-default
632 :type '(choice (const :tag "off" nil)
635 (defcustom gnus-thread-expunge-below nil
636 "All threads that have a total score less than this variable will be expunged.
637 See `gnus-thread-score-function' for en explanation of what a
640 This variable is local to the summary buffers."
641 :group 'gnus-threading
642 :group 'gnus-score-default
643 :type '(choice (const :tag "off" nil)
646 (defcustom gnus-summary-mode-hook nil
647 "*A hook for Gnus summary mode.
648 This hook is run before any variables are set in the summary buffer."
649 :options '(turn-on-gnus-mailing-list-mode)
650 :group 'gnus-summary-various
653 (defcustom gnus-summary-menu-hook nil
654 "*Hook run after the creation of the summary mode menu."
655 :group 'gnus-summary-visual
658 (defcustom gnus-summary-exit-hook nil
659 "*A hook called on exit from the summary buffer.
660 It will be called with point in the group buffer."
661 :group 'gnus-summary-exit
664 (defcustom gnus-summary-prepare-hook nil
665 "*A hook called after the summary buffer has been generated.
666 If you want to modify the summary buffer, you can use this hook."
667 :group 'gnus-summary-various
670 (defcustom gnus-summary-prepared-hook nil
671 "*A hook called as the last thing after the summary buffer has been generated."
672 :group 'gnus-summary-various
675 (defcustom gnus-summary-generate-hook nil
676 "*A hook run just before generating the summary buffer.
677 This hook is commonly used to customize threading variables and the
679 :group 'gnus-summary-various
682 (defcustom gnus-select-group-hook nil
683 "*A hook called when a newsgroup is selected.
685 If you'd like to simplify subjects like the
686 `gnus-summary-next-same-subject' command does, you can use the
689 (setq gnus-select-group-hook
692 (mapcar (lambda (header)
693 (mail-header-set-subject
695 (gnus-simplify-subject
696 (mail-header-subject header) 're-only)))
697 gnus-newsgroup-headers))))"
698 :group 'gnus-group-select
701 (defcustom gnus-select-article-hook nil
702 "*A hook called when an article is selected."
703 :group 'gnus-summary-choose
706 (defcustom gnus-visual-mark-article-hook
707 (list 'gnus-highlight-selected-summary)
708 "*Hook run after selecting an article in the summary buffer.
709 It is meant to be used for highlighting the article in some way. It
710 is not run if `gnus-visual' is nil."
711 :group 'gnus-summary-visual
714 (defcustom gnus-parse-headers-hook nil
715 "*A hook called before parsing the headers."
719 (defcustom gnus-exit-group-hook nil
720 "*A hook called when exiting summary mode.
721 This hook is not called from the non-updating exit commands like `Q'."
725 (defcustom gnus-summary-update-hook
726 (list 'gnus-summary-highlight-line)
727 "*A hook called when a summary line is changed.
728 The hook will not be called if `gnus-visual' is nil.
730 The default function `gnus-summary-highlight-line' will
731 highlight the line according to the `gnus-summary-highlight'
733 :group 'gnus-summary-visual
736 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
737 "*A hook called when an article is selected for the first time.
738 The hook is intended to mark an article as read (or unread)
739 automatically when it is selected."
740 :group 'gnus-summary-choose
743 (defcustom gnus-group-no-more-groups-hook nil
744 "*A hook run when returning to group mode having no more (unread) groups."
745 :group 'gnus-group-select
748 (defcustom gnus-ps-print-hook nil
749 "*A hook run before ps-printing something from Gnus."
753 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
754 "Face used for highlighting the current article in the summary buffer."
755 :group 'gnus-summary-visual
758 (defcustom gnus-summary-highlight
759 '(((= mark gnus-canceled-mark)
760 . gnus-summary-cancelled-face)
761 ((and (> score default)
762 (or (= mark gnus-dormant-mark)
763 (= mark gnus-ticked-mark)))
764 . gnus-summary-high-ticked-face)
765 ((and (< score default)
766 (or (= mark gnus-dormant-mark)
767 (= mark gnus-ticked-mark)))
768 . gnus-summary-low-ticked-face)
769 ((or (= mark gnus-dormant-mark)
770 (= mark gnus-ticked-mark))
771 . gnus-summary-normal-ticked-face)
772 ((and (> score default) (= mark gnus-ancient-mark))
773 . gnus-summary-high-ancient-face)
774 ((and (< score default) (= mark gnus-ancient-mark))
775 . gnus-summary-low-ancient-face)
776 ((= mark gnus-ancient-mark)
777 . gnus-summary-normal-ancient-face)
778 ((and (> score default) (= mark gnus-unread-mark))
779 . gnus-summary-high-unread-face)
780 ((and (< score default) (= mark gnus-unread-mark))
781 . gnus-summary-low-unread-face)
782 ((= mark gnus-unread-mark)
783 . gnus-summary-normal-unread-face)
784 ((and (> score default) (memq mark (list gnus-downloadable-mark
785 gnus-undownloaded-mark)))
786 . gnus-summary-high-unread-face)
787 ((and (< score default) (memq mark (list gnus-downloadable-mark
788 gnus-undownloaded-mark)))
789 . gnus-summary-low-unread-face)
790 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
791 . gnus-summary-normal-unread-face)
793 . gnus-summary-high-read-face)
795 . gnus-summary-low-read-face)
797 . gnus-summary-normal-read-face))
798 "*Controls the highlighting of summary buffer lines.
800 A list of (FORM . FACE) pairs. When deciding how a a particular
801 summary line should be displayed, each form is evaluated. The content
802 of the face field after the first true form is used. You can change
803 how those summary lines are displayed, by editing the face field.
805 You can use the following variables in the FORM field.
807 score: The articles score
808 default: The default article score.
809 below: The score below which articles are automatically marked as read.
810 mark: The articles mark."
811 :group 'gnus-summary-visual
812 :type '(repeat (cons (sexp :tag "Form" nil)
815 (defcustom gnus-alter-header-function nil
816 "Function called to allow alteration of article header structures.
817 The function is called with one parameter, the article header vector,
818 which it may alter in any way.")
820 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
821 "Variable that says which function should be used to decode a string with encoded words.")
823 (defcustom gnus-extra-headers nil
824 "*Extra headers to parse."
827 :type '(repeat symbol))
829 (defcustom gnus-ignored-from-addresses
830 (and user-mail-address (regexp-quote user-mail-address))
831 "*Regexp of From headers that may be suppressed in favor of To headers."
836 (defcustom gnus-group-charset-alist
837 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
838 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
839 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
840 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
841 ("^relcom\\>" koi8-r)
843 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
844 ("^israel\\>" iso-8859-1)
846 ("^alt.chinese.text.big5\\>" chinese-big5)
847 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
848 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
850 "Alist of regexps (to match group names) and default charsets to be used when reading."
851 :type '(repeat (list (regexp :tag "Group")
852 (symbol :tag "Charset")))
853 :group 'gnus-charset)
855 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
856 "List of charsets that should be ignored.
857 When these charsets are used in the \"charset\" parameter, the
858 default charset will be used instead."
860 :type '(repeat symbol)
861 :group 'gnus-charset)
863 (defcustom gnus-group-ignored-charsets-alist
864 '(("alt\\.chinese\\.text" iso-8859-1))
865 "Alist of regexps (to match group names) and charsets that should be ignored.
866 When these charsets are used in the \"charset\" parameter, the
867 default charset will be used instead."
868 :type '(repeat (cons (regexp :tag "Group")
870 :group 'gnus-charset)
872 (defcustom gnus-group-highlight-words-alist nil
873 "Alist of group regexps and highlight regexps.
874 This variable uses the same syntax as `gnus-emphasis-alist'."
876 :type '(repeat (cons (regexp :tag "Group")
877 (repeat (list (regexp :tag "Highlight regexp")
878 (number :tag "Group for entire word" 0)
879 (number :tag "Group for displayed part" 0)
881 gnus-emphasis-highlight-words)))))
882 :group 'gnus-summary-visual)
884 (defcustom gnus-summary-show-article-charset-alist
886 "Alist of number and charset.
887 The article will be shown with the charset corresponding to the
889 For example: ((1 . cn-gb-2312) (2 . big5))."
891 :type '(repeat (cons (number :tag "Argument" 1)
892 (symbol :tag "Charset")))
893 :group 'gnus-charset)
895 (defcustom gnus-preserve-marks t
896 "Whether marks are preserved when moving, copying and respooling messages."
899 :group 'gnus-summary-marks)
901 (defcustom gnus-alter-articles-to-read-function nil
902 "Function to be called to alter the list of articles to be selected."
904 :group 'gnus-summary)
906 (defcustom gnus-orphan-score nil
907 "*All orphans get this score added. Set in the score file."
908 :group 'gnus-score-default
909 :type '(choice (const nil)
912 (defcustom gnus-summary-save-parts-default-mime "image/.*"
913 "*A regexp to match MIME parts when saving multiple parts of a message
914 with gnus-summary-save-parts (X m). This regexp will be used by default
915 when prompting the user for which type of files to save."
920 (defcustom gnus-summary-save-parts-default-mime "image/.*"
921 "*A regexp to match MIME parts when saving multiple parts of a message
922 with gnus-summary-save-parts (X m). This regexp will be used by default
923 when prompting the user for which type of files to save."
928 ;;; Internal variables
930 (defvar gnus-article-mime-handles nil)
931 (defvar gnus-article-decoded-p nil)
932 (defvar gnus-article-charset nil)
933 (defvar gnus-article-ignored-charsets nil)
934 (defvar gnus-scores-exclude-files nil)
935 (defvar gnus-page-broken nil)
936 (defvar gnus-inhibit-mime-unbuttonizing nil)
938 (defvar gnus-original-article nil)
939 (defvar gnus-article-internal-prepare-hook nil)
940 (defvar gnus-newsgroup-process-stack nil)
942 (defvar gnus-thread-indent-array nil)
943 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
944 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
945 "Function called to sort the articles within a thread after it has been gathered together.")
947 (defvar gnus-summary-save-parts-type-history nil)
948 (defvar gnus-summary-save-parts-last-directory nil)
950 (defvar gnus-summary-save-parts-type-history nil)
951 (defvar gnus-summary-save-parts-last-directory nil)
953 ;; Avoid highlighting in kill files.
954 (defvar gnus-summary-inhibit-highlight nil)
955 (defvar gnus-newsgroup-selected-overlay nil)
956 (defvar gnus-inhibit-limiting nil)
957 (defvar gnus-newsgroup-adaptive-score-file nil)
958 (defvar gnus-current-score-file nil)
959 (defvar gnus-current-move-group nil)
960 (defvar gnus-current-copy-group nil)
961 (defvar gnus-current-crosspost-group nil)
963 (defvar gnus-newsgroup-dependencies nil)
964 (defvar gnus-newsgroup-adaptive nil)
965 (defvar gnus-summary-display-article-function nil)
966 (defvar gnus-summary-highlight-line-function nil
967 "Function called after highlighting a summary line.")
969 (defvar gnus-summary-line-format-alist
970 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
971 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
972 (?s gnus-tmp-subject-or-nil ?s)
973 (?n gnus-tmp-name ?s)
974 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
976 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
978 (?F gnus-tmp-from ?s)
979 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
980 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
981 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
982 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
983 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
984 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
985 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
986 (?L gnus-tmp-lines ?d)
987 (?I gnus-tmp-indentation ?s)
988 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
989 (?R gnus-tmp-replied ?c)
990 (?\[ gnus-tmp-opening-bracket ?c)
991 (?\] gnus-tmp-closing-bracket ?c)
992 (?\> (make-string gnus-tmp-level ? ) ?s)
993 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
994 (?i gnus-tmp-score ?d)
995 (?z gnus-tmp-score-char ?c)
996 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
997 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
998 (?U gnus-tmp-unread ?c)
999 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1000 (?t (gnus-summary-number-of-articles-in-thread
1001 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1003 (?e (gnus-summary-number-of-articles-in-thread
1004 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1006 (?u gnus-tmp-user-defined ?s)
1007 (?P (gnus-pick-line-number) ?d))
1008 "An alist of format specifications that can appear in summary lines.
1009 These are paired with what variables they correspond with, along with
1010 the type of the variable (string, integer, character, etc).")
1012 (defvar gnus-summary-dummy-line-format-alist
1013 `((?S gnus-tmp-subject ?s)
1014 (?N gnus-tmp-number ?d)
1015 (?u gnus-tmp-user-defined ?s)))
1017 (defvar gnus-summary-mode-line-format-alist
1018 `((?G gnus-tmp-group-name ?s)
1019 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1020 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1021 (?A gnus-tmp-article-number ?d)
1022 (?Z gnus-tmp-unread-and-unselected ?s)
1023 (?V gnus-version ?s)
1024 (?U gnus-tmp-unread-and-unticked ?d)
1025 (?S gnus-tmp-subject ?s)
1026 (?e gnus-tmp-unselected ?d)
1027 (?u gnus-tmp-user-defined ?s)
1028 (?d (length gnus-newsgroup-dormant) ?d)
1029 (?t (length gnus-newsgroup-marked) ?d)
1030 (?r (length gnus-newsgroup-reads) ?d)
1031 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1032 (?E gnus-newsgroup-expunged-tally ?d)
1033 (?s (gnus-current-score-file-nondirectory) ?s)))
1035 (defvar gnus-last-search-regexp nil
1036 "Default regexp for article search command.")
1038 (defvar gnus-last-shell-command nil
1039 "Default shell command on article.")
1041 (defvar gnus-newsgroup-begin nil)
1042 (defvar gnus-newsgroup-end nil)
1043 (defvar gnus-newsgroup-last-rmail nil)
1044 (defvar gnus-newsgroup-last-mail nil)
1045 (defvar gnus-newsgroup-last-folder nil)
1046 (defvar gnus-newsgroup-last-file nil)
1047 (defvar gnus-newsgroup-auto-expire nil)
1048 (defvar gnus-newsgroup-active nil)
1050 (defvar gnus-newsgroup-data nil)
1051 (defvar gnus-newsgroup-data-reverse nil)
1052 (defvar gnus-newsgroup-limit nil)
1053 (defvar gnus-newsgroup-limits nil)
1055 (defvar gnus-newsgroup-unreads nil
1056 "List of unread articles in the current newsgroup.")
1058 (defvar gnus-newsgroup-unselected nil
1059 "List of unselected unread articles in the current newsgroup.")
1061 (defvar gnus-newsgroup-reads nil
1062 "Alist of read articles and article marks in the current newsgroup.")
1064 (defvar gnus-newsgroup-expunged-tally nil)
1066 (defvar gnus-newsgroup-marked nil
1067 "List of ticked articles in the current newsgroup (a subset of unread art).")
1069 (defvar gnus-newsgroup-killed nil
1070 "List of ranges of articles that have been through the scoring process.")
1072 (defvar gnus-newsgroup-cached nil
1073 "List of articles that come from the article cache.")
1075 (defvar gnus-newsgroup-saved nil
1076 "List of articles that have been saved.")
1078 (defvar gnus-newsgroup-kill-headers nil)
1080 (defvar gnus-newsgroup-replied nil
1081 "List of articles that have been replied to in the current newsgroup.")
1083 (defvar gnus-newsgroup-expirable nil
1084 "List of articles in the current newsgroup that can be expired.")
1086 (defvar gnus-newsgroup-processable nil
1087 "List of articles in the current newsgroup that can be processed.")
1089 (defvar gnus-newsgroup-downloadable nil
1090 "List of articles in the current newsgroup that can be processed.")
1092 (defvar gnus-newsgroup-undownloaded nil
1093 "List of articles in the current newsgroup that haven't been downloaded..")
1095 (defvar gnus-newsgroup-unsendable nil
1096 "List of articles in the current newsgroup that won't be sent.")
1098 (defvar gnus-newsgroup-bookmarks nil
1099 "List of articles in the current newsgroup that have bookmarks.")
1101 (defvar gnus-newsgroup-dormant nil
1102 "List of dormant articles in the current newsgroup.")
1104 (defvar gnus-newsgroup-scored nil
1105 "List of scored articles in the current newsgroup.")
1107 (defvar gnus-newsgroup-headers nil
1108 "List of article headers in the current newsgroup.")
1110 (defvar gnus-newsgroup-threads nil)
1112 (defvar gnus-newsgroup-prepared nil
1113 "Whether the current group has been prepared properly.")
1115 (defvar gnus-newsgroup-ancient nil
1116 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1118 (defvar gnus-newsgroup-sparse nil)
1120 (defvar gnus-current-article nil)
1121 (defvar gnus-article-current nil)
1122 (defvar gnus-current-headers nil)
1123 (defvar gnus-have-all-headers nil)
1124 (defvar gnus-last-article nil)
1125 (defvar gnus-newsgroup-history nil)
1126 (defvar gnus-newsgroup-charset nil)
1127 (defvar gnus-newsgroup-ephemeral-charset nil)
1128 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1130 (defvar gnus-article-before-search nil)
1132 (defconst gnus-summary-local-variables
1133 '(gnus-newsgroup-name
1134 gnus-newsgroup-begin gnus-newsgroup-end
1135 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1136 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1137 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1138 gnus-newsgroup-unselected gnus-newsgroup-marked
1139 gnus-newsgroup-reads gnus-newsgroup-saved
1140 gnus-newsgroup-replied gnus-newsgroup-expirable
1141 gnus-newsgroup-processable gnus-newsgroup-killed
1142 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1143 gnus-newsgroup-unsendable
1144 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1145 gnus-newsgroup-headers gnus-newsgroup-threads
1146 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1147 gnus-current-article gnus-current-headers gnus-have-all-headers
1148 gnus-last-article gnus-article-internal-prepare-hook
1149 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1150 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1151 gnus-thread-expunge-below
1152 gnus-score-alist gnus-current-score-file
1153 (gnus-summary-expunge-below . global)
1154 (gnus-summary-mark-below . global)
1155 (gnus-orphan-score . global)
1156 gnus-newsgroup-active gnus-scores-exclude-files
1157 gnus-newsgroup-history gnus-newsgroup-ancient
1158 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1159 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1160 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1161 (gnus-newsgroup-expunged-tally . 0)
1162 gnus-cache-removable-articles gnus-newsgroup-cached
1163 gnus-newsgroup-data gnus-newsgroup-data-reverse
1164 gnus-newsgroup-limit gnus-newsgroup-limits
1165 gnus-newsgroup-charset)
1166 "Variables that are buffer-local to the summary buffers.")
1168 (defvar gnus-newsgroup-variables nil
1169 "Variables that have separate values in the newsgroups.")
1171 ;; Byte-compiler warning.
1172 (eval-when-compile (defvar gnus-article-mode-map))
1176 (defvar gnus-decode-encoded-word-methods
1177 '(mail-decode-encoded-word-string)
1178 "List of methods used to decode encoded words.
1180 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1181 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1182 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1183 whose names match REGEXP.
1186 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1187 mail-decode-encoded-word-string
1188 (\"chinese\" . rfc1843-decode-string))")
1190 (defvar gnus-decode-encoded-word-methods-cache nil)
1192 (defun gnus-multi-decode-encoded-word-string (string)
1193 "Apply the functions from `gnus-encoded-word-methods' that match."
1194 (unless (and gnus-decode-encoded-word-methods-cache
1195 (eq gnus-newsgroup-name
1196 (car gnus-decode-encoded-word-methods-cache)))
1197 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1200 (nconc gnus-decode-encoded-word-methods-cache (list x))
1201 (if (and gnus-newsgroup-name
1202 (string-match (car x) gnus-newsgroup-name))
1203 (nconc gnus-decode-encoded-word-methods-cache
1205 gnus-decode-encoded-word-methods))
1206 (let ((xlist gnus-decode-encoded-word-methods-cache))
1209 (setq string (funcall (pop xlist) string))))
1212 ;; Subject simplification.
1214 (defun gnus-simplify-whitespace (str)
1215 "Remove excessive whitespace from STR."
1218 (while (string-match "[ \t][ \t]+" mystr)
1219 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1221 (substring mystr (match-end 0)))))
1223 (when (string-match "^[ \t]+" mystr)
1224 (setq mystr (substring mystr (match-end 0))))
1226 (when (string-match "[ \t]+$" mystr)
1227 (setq mystr (substring mystr 0 (match-beginning 0))))
1230 (defsubst gnus-simplify-subject-re (subject)
1231 "Remove \"Re:\" from subject lines."
1232 (if (string-match "^[Rr][Ee]: *" subject)
1233 (substring subject (match-end 0))
1236 (defun gnus-simplify-subject (subject &optional re-only)
1237 "Remove `Re:' and words in parentheses.
1238 If RE-ONLY is non-nil, strip leading `Re:'s only."
1239 (let ((case-fold-search t)) ;Ignore case.
1240 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1241 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1242 (setq subject (substring subject (match-end 0))))
1243 ;; Remove uninteresting prefixes.
1244 (when (and (not re-only)
1245 gnus-simplify-ignored-prefixes
1246 (string-match gnus-simplify-ignored-prefixes subject))
1247 (setq subject (substring subject (match-end 0))))
1248 ;; Remove words in parentheses from end.
1250 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1251 (setq subject (substring subject 0 (match-beginning 0)))))
1252 ;; Return subject string.
1255 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1257 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1258 (goto-char (point-min))
1259 (while (re-search-forward regexp nil t)
1260 (replace-match (or newtext ""))))
1262 (defun gnus-simplify-buffer-fuzzy ()
1263 "Simplify string in the buffer fuzzily.
1264 The string in the accessible portion of the current buffer is simplified.
1265 It is assumed to be a single-line subject.
1266 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1267 matter is removed. Additional things can be deleted by setting
1268 `gnus-simplify-subject-fuzzy-regexp'."
1269 (let ((case-fold-search t)
1271 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1273 (while (not (eq modified-tick (buffer-modified-tick)))
1274 (setq modified-tick (buffer-modified-tick))
1276 ((listp gnus-simplify-subject-fuzzy-regexp)
1277 (mapcar 'gnus-simplify-buffer-fuzzy-step
1278 gnus-simplify-subject-fuzzy-regexp))
1279 (gnus-simplify-subject-fuzzy-regexp
1280 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1281 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1282 (gnus-simplify-buffer-fuzzy-step
1283 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1284 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1286 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1287 (gnus-simplify-buffer-fuzzy-step " +" " ")
1288 (gnus-simplify-buffer-fuzzy-step " $")
1289 (gnus-simplify-buffer-fuzzy-step "^ +")))
1291 (defun gnus-simplify-subject-fuzzy (subject)
1292 "Simplify a subject string fuzzily.
1293 See `gnus-simplify-buffer-fuzzy' for details."
1295 (gnus-set-work-buffer)
1296 (let ((case-fold-search t))
1297 ;; Remove uninteresting prefixes.
1298 (when (and gnus-simplify-ignored-prefixes
1299 (string-match gnus-simplify-ignored-prefixes subject))
1300 (setq subject (substring subject (match-end 0))))
1302 (inline (gnus-simplify-buffer-fuzzy))
1305 (defsubst gnus-simplify-subject-fully (subject)
1306 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1308 (gnus-simplify-subject-functions
1309 (gnus-map-function gnus-simplify-subject-functions subject))
1310 ((null gnus-summary-gather-subject-limit)
1311 (gnus-simplify-subject-re subject))
1312 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1313 (gnus-simplify-subject-fuzzy subject))
1314 ((numberp gnus-summary-gather-subject-limit)
1315 (gnus-limit-string (gnus-simplify-subject-re subject)
1316 gnus-summary-gather-subject-limit))
1320 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1321 "Check whether two subjects are equal.
1322 If optional argument simple-first is t, first argument is already
1325 ((null simple-first)
1326 (equal (gnus-simplify-subject-fully s1)
1327 (gnus-simplify-subject-fully s2)))
1330 (gnus-simplify-subject-fully s2)))))
1332 (defun gnus-summary-bubble-group ()
1333 "Increase the score of the current group.
1334 This is a handy function to add to `gnus-summary-exit-hook' to
1335 increase the score of each group you read."
1336 (gnus-group-add-score gnus-newsgroup-name))
1340 ;;; Gnus summary mode
1343 (put 'gnus-summary-mode 'mode-class 'special)
1346 ;; Non-orthogonal keys
1348 (gnus-define-keys gnus-summary-mode-map
1349 " " gnus-summary-next-page
1350 "\177" gnus-summary-prev-page
1351 [delete] gnus-summary-prev-page
1352 [backspace] gnus-summary-prev-page
1353 "\r" gnus-summary-scroll-up
1354 "\M-\r" gnus-summary-scroll-down
1355 "n" gnus-summary-next-unread-article
1356 "p" gnus-summary-prev-unread-article
1357 "N" gnus-summary-next-article
1358 "P" gnus-summary-prev-article
1359 "\M-\C-n" gnus-summary-next-same-subject
1360 "\M-\C-p" gnus-summary-prev-same-subject
1361 "\M-n" gnus-summary-next-unread-subject
1362 "\M-p" gnus-summary-prev-unread-subject
1363 "." gnus-summary-first-unread-article
1364 "," gnus-summary-best-unread-article
1365 "\M-s" gnus-summary-search-article-forward
1366 "\M-r" gnus-summary-search-article-backward
1367 "<" gnus-summary-beginning-of-article
1368 ">" gnus-summary-end-of-article
1369 "j" gnus-summary-goto-article
1370 "^" gnus-summary-refer-parent-article
1371 "\M-^" gnus-summary-refer-article
1372 "u" gnus-summary-tick-article-forward
1373 "!" gnus-summary-tick-article-forward
1374 "U" gnus-summary-tick-article-backward
1375 "d" gnus-summary-mark-as-read-forward
1376 "D" gnus-summary-mark-as-read-backward
1377 "E" gnus-summary-mark-as-expirable
1378 "\M-u" gnus-summary-clear-mark-forward
1379 "\M-U" gnus-summary-clear-mark-backward
1380 "k" gnus-summary-kill-same-subject-and-select
1381 "\C-k" gnus-summary-kill-same-subject
1382 "\M-\C-k" gnus-summary-kill-thread
1383 "\M-\C-l" gnus-summary-lower-thread
1384 "e" gnus-summary-edit-article
1385 "#" gnus-summary-mark-as-processable
1386 "\M-#" gnus-summary-unmark-as-processable
1387 "\M-\C-t" gnus-summary-toggle-threads
1388 "\M-\C-s" gnus-summary-show-thread
1389 "\M-\C-h" gnus-summary-hide-thread
1390 "\M-\C-f" gnus-summary-next-thread
1391 "\M-\C-b" gnus-summary-prev-thread
1392 [(meta down)] gnus-summary-next-thread
1393 [(meta up)] gnus-summary-prev-thread
1394 "\M-\C-u" gnus-summary-up-thread
1395 "\M-\C-d" gnus-summary-down-thread
1396 "&" gnus-summary-execute-command
1397 "c" gnus-summary-catchup-and-exit
1398 "\C-w" gnus-summary-mark-region-as-read
1399 "\C-t" gnus-summary-toggle-truncation
1400 "?" gnus-summary-mark-as-dormant
1401 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1402 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1403 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1404 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1405 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1406 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1407 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1408 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1409 "=" gnus-summary-expand-window
1410 "\C-x\C-s" gnus-summary-reselect-current-group
1411 "\M-g" gnus-summary-rescan-group
1412 "w" gnus-summary-stop-page-breaking
1413 "\C-c\C-r" gnus-summary-caesar-message
1414 "f" gnus-summary-followup
1415 "F" gnus-summary-followup-with-original
1416 "C" gnus-summary-cancel-article
1417 "r" gnus-summary-reply
1418 "R" gnus-summary-reply-with-original
1419 "\C-c\C-f" gnus-summary-mail-forward
1420 "o" gnus-summary-save-article
1421 "\C-o" gnus-summary-save-article-mail
1422 "|" gnus-summary-pipe-output
1423 "\M-k" gnus-summary-edit-local-kill
1424 "\M-K" gnus-summary-edit-global-kill
1426 "\C-c\C-d" gnus-summary-describe-group
1427 "q" gnus-summary-exit
1428 "Q" gnus-summary-exit-no-update
1429 "\C-c\C-i" gnus-info-find-node
1430 gnus-mouse-2 gnus-mouse-pick-article
1431 "m" gnus-summary-mail-other-window
1432 "a" gnus-summary-post-news
1433 "x" gnus-summary-limit-to-unread
1434 "s" gnus-summary-isearch-article
1435 "t" gnus-summary-toggle-header
1436 "g" gnus-summary-show-article
1437 "l" gnus-summary-goto-last-article
1438 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1439 "\C-d" gnus-summary-enter-digest-group
1440 "\M-\C-d" gnus-summary-read-document
1441 "\M-\C-e" gnus-summary-edit-parameters
1442 "\M-\C-a" gnus-summary-customize-parameters
1444 "*" gnus-cache-enter-article
1445 "\M-*" gnus-cache-remove-article
1446 "\M-&" gnus-summary-universal-argument
1447 "\C-l" gnus-recenter
1448 "I" gnus-summary-increase-score
1449 "L" gnus-summary-lower-score
1450 "\M-i" gnus-symbolic-argument
1451 "h" gnus-summary-select-article-buffer
1453 "b" gnus-article-view-part
1454 "\M-t" gnus-summary-toggle-display-buttonized
1456 "V" gnus-summary-score-map
1457 "X" gnus-uu-extract-map
1458 "S" gnus-summary-send-map)
1460 ;; Sort of orthogonal keymap
1461 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1462 "t" gnus-summary-tick-article-forward
1463 "!" gnus-summary-tick-article-forward
1464 "d" gnus-summary-mark-as-read-forward
1465 "r" gnus-summary-mark-as-read-forward
1466 "c" gnus-summary-clear-mark-forward
1467 " " gnus-summary-clear-mark-forward
1468 "e" gnus-summary-mark-as-expirable
1469 "x" gnus-summary-mark-as-expirable
1470 "?" gnus-summary-mark-as-dormant
1471 "b" gnus-summary-set-bookmark
1472 "B" gnus-summary-remove-bookmark
1473 "#" gnus-summary-mark-as-processable
1474 "\M-#" gnus-summary-unmark-as-processable
1475 "S" gnus-summary-limit-include-expunged
1476 "C" gnus-summary-catchup
1477 "H" gnus-summary-catchup-to-here
1478 "\C-c" gnus-summary-catchup-all
1479 "k" gnus-summary-kill-same-subject-and-select
1480 "K" gnus-summary-kill-same-subject
1481 "P" gnus-uu-mark-map)
1483 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1484 "c" gnus-summary-clear-above
1485 "u" gnus-summary-tick-above
1486 "m" gnus-summary-mark-above
1487 "k" gnus-summary-kill-below)
1489 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1490 "/" gnus-summary-limit-to-subject
1491 "n" gnus-summary-limit-to-articles
1492 "w" gnus-summary-pop-limit
1493 "s" gnus-summary-limit-to-subject
1494 "a" gnus-summary-limit-to-author
1495 "u" gnus-summary-limit-to-unread
1496 "m" gnus-summary-limit-to-marks
1497 "M" gnus-summary-limit-exclude-marks
1498 "v" gnus-summary-limit-to-score
1499 "*" gnus-summary-limit-include-cached
1500 "D" gnus-summary-limit-include-dormant
1501 "T" gnus-summary-limit-include-thread
1502 "d" gnus-summary-limit-exclude-dormant
1503 "t" gnus-summary-limit-to-age
1504 "x" gnus-summary-limit-to-extra
1505 "E" gnus-summary-limit-include-expunged
1506 "c" gnus-summary-limit-exclude-childless-dormant
1507 "C" gnus-summary-limit-mark-excluded-as-read)
1509 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1510 "n" gnus-summary-next-unread-article
1511 "p" gnus-summary-prev-unread-article
1512 "N" gnus-summary-next-article
1513 "P" gnus-summary-prev-article
1514 "\C-n" gnus-summary-next-same-subject
1515 "\C-p" gnus-summary-prev-same-subject
1516 "\M-n" gnus-summary-next-unread-subject
1517 "\M-p" gnus-summary-prev-unread-subject
1518 "f" gnus-summary-first-unread-article
1519 "b" gnus-summary-best-unread-article
1520 "j" gnus-summary-goto-article
1521 "g" gnus-summary-goto-subject
1522 "l" gnus-summary-goto-last-article
1523 "o" gnus-summary-pop-article)
1525 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1526 "k" gnus-summary-kill-thread
1527 "l" gnus-summary-lower-thread
1528 "i" gnus-summary-raise-thread
1529 "T" gnus-summary-toggle-threads
1530 "t" gnus-summary-rethread-current
1531 "^" gnus-summary-reparent-thread
1532 "s" gnus-summary-show-thread
1533 "S" gnus-summary-show-all-threads
1534 "h" gnus-summary-hide-thread
1535 "H" gnus-summary-hide-all-threads
1536 "n" gnus-summary-next-thread
1537 "p" gnus-summary-prev-thread
1538 "u" gnus-summary-up-thread
1539 "o" gnus-summary-top-thread
1540 "d" gnus-summary-down-thread
1541 "#" gnus-uu-mark-thread
1542 "\M-#" gnus-uu-unmark-thread)
1544 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1545 "g" gnus-summary-prepare
1546 "c" gnus-summary-insert-cached-articles)
1548 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1549 "c" gnus-summary-catchup-and-exit
1550 "C" gnus-summary-catchup-all-and-exit
1551 "E" gnus-summary-exit-no-update
1552 "Q" gnus-summary-exit
1553 "Z" gnus-summary-exit
1554 "n" gnus-summary-catchup-and-goto-next-group
1555 "R" gnus-summary-reselect-current-group
1556 "G" gnus-summary-rescan-group
1557 "N" gnus-summary-next-group
1558 "s" gnus-summary-save-newsrc
1559 "P" gnus-summary-prev-group)
1561 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1562 " " gnus-summary-next-page
1563 "n" gnus-summary-next-page
1564 "\177" gnus-summary-prev-page
1565 [delete] gnus-summary-prev-page
1566 "p" gnus-summary-prev-page
1567 "\r" gnus-summary-scroll-up
1568 "\M-\r" gnus-summary-scroll-down
1569 "<" gnus-summary-beginning-of-article
1570 ">" gnus-summary-end-of-article
1571 "b" gnus-summary-beginning-of-article
1572 "e" gnus-summary-end-of-article
1573 "^" gnus-summary-refer-parent-article
1574 "r" gnus-summary-refer-parent-article
1575 "D" gnus-summary-enter-digest-group
1576 "R" gnus-summary-refer-references
1577 "T" gnus-summary-refer-thread
1578 "g" gnus-summary-show-article
1579 "s" gnus-summary-isearch-article
1580 "P" gnus-summary-print-article
1581 "M" gnus-mailing-list-insinuate
1582 "t" gnus-article-babel)
1584 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1585 "b" gnus-article-add-buttons
1586 "B" gnus-article-add-buttons-to-head
1587 "o" gnus-article-treat-overstrike
1588 "e" gnus-article-emphasize
1589 "w" gnus-article-fill-cited-article
1590 "Q" gnus-article-fill-long-lines
1591 "C" gnus-article-capitalize-sentences
1592 "c" gnus-article-remove-cr
1593 "q" gnus-article-de-quoted-unreadable
1594 "6" gnus-article-de-base64-unreadable
1595 "Z" gnus-article-decode-HZ
1596 "h" gnus-article-wash-html
1597 "s" gnus-summary-force-verify-and-decrypt
1598 "f" gnus-article-display-x-face
1599 "l" gnus-summary-stop-page-breaking
1600 "r" gnus-summary-caesar-message
1601 "t" gnus-summary-toggle-header
1602 "v" gnus-summary-verbose-headers
1603 "H" gnus-article-strip-headers-in-body
1604 "p" gnus-article-verify-x-pgp-sig
1605 "d" gnus-article-treat-dumbquotes)
1607 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1608 "a" gnus-article-hide
1609 "h" gnus-article-hide-headers
1610 "b" gnus-article-hide-boring-headers
1611 "s" gnus-article-hide-signature
1612 "c" gnus-article-hide-citation
1613 "C" gnus-article-hide-citation-in-followups
1614 "l" gnus-article-hide-list-identifiers
1615 "p" gnus-article-hide-pgp
1616 "B" gnus-article-strip-banner
1617 "P" gnus-article-hide-pem
1618 "\C-c" gnus-article-hide-citation-maybe)
1620 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1621 "a" gnus-article-highlight
1622 "h" gnus-article-highlight-headers
1623 "c" gnus-article-highlight-citation
1624 "s" gnus-article-highlight-signature)
1626 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1627 "w" gnus-article-decode-mime-words
1628 "c" gnus-article-decode-charset
1629 "v" gnus-mime-view-all-parts
1630 "b" gnus-article-view-part)
1632 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1633 "z" gnus-article-date-ut
1634 "u" gnus-article-date-ut
1635 "l" gnus-article-date-local
1636 "e" gnus-article-date-lapsed
1637 "o" gnus-article-date-original
1638 "i" gnus-article-date-iso8601
1639 "s" gnus-article-date-user)
1641 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1642 "t" gnus-article-remove-trailing-blank-lines
1643 "l" gnus-article-strip-leading-blank-lines
1644 "m" gnus-article-strip-multiple-blank-lines
1645 "a" gnus-article-strip-blank-lines
1646 "A" gnus-article-strip-all-blank-lines
1647 "s" gnus-article-strip-leading-space
1648 "e" gnus-article-strip-trailing-space)
1650 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1652 "f" gnus-summary-fetch-faq
1653 "d" gnus-summary-describe-group
1654 "h" gnus-summary-describe-briefly
1655 "i" gnus-info-find-node)
1657 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1658 "e" gnus-summary-expire-articles
1659 "\M-\C-e" gnus-summary-expire-articles-now
1660 "\177" gnus-summary-delete-article
1661 [delete] gnus-summary-delete-article
1662 [backspace] gnus-summary-delete-article
1663 "m" gnus-summary-move-article
1664 "r" gnus-summary-respool-article
1665 "w" gnus-summary-edit-article
1666 "c" gnus-summary-copy-article
1667 "B" gnus-summary-crosspost-article
1668 "q" gnus-summary-respool-query
1669 "t" gnus-summary-respool-trace
1670 "i" gnus-summary-import-article
1671 "p" gnus-summary-article-posted-p)
1673 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1674 "o" gnus-summary-save-article
1675 "m" gnus-summary-save-article-mail
1676 "F" gnus-summary-write-article-file
1677 "r" gnus-summary-save-article-rmail
1678 "f" gnus-summary-save-article-file
1679 "b" gnus-summary-save-article-body-file
1680 "h" gnus-summary-save-article-folder
1681 "v" gnus-summary-save-article-vm
1682 "p" gnus-summary-pipe-output
1683 "s" gnus-soup-add-article)
1685 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1686 "b" gnus-summary-display-buttonized
1687 "m" gnus-summary-repair-multipart
1688 "v" gnus-article-view-part
1689 "o" gnus-article-save-part
1690 "c" gnus-article-copy-part
1691 "C" gnus-article-view-part-as-charset
1692 "e" gnus-article-externalize-part
1693 "E" gnus-article-encrypt-body
1694 "i" gnus-article-inline-part
1695 "|" gnus-article-pipe-part))
1697 (defun gnus-summary-make-menu-bar ()
1698 (gnus-turn-off-edit-menu 'summary)
1700 (unless (boundp 'gnus-summary-misc-menu)
1703 gnus-summary-kill-menu gnus-summary-mode-map ""
1708 ["Enter score..." gnus-summary-score-entry t]
1709 ["Customize" gnus-score-customize t])
1710 (gnus-make-score-map 'increase)
1711 (gnus-make-score-map 'lower)
1713 ["Kill below" gnus-summary-kill-below t]
1714 ["Mark above" gnus-summary-mark-above t]
1715 ["Tick above" gnus-summary-tick-above t]
1716 ["Clear above" gnus-summary-clear-above t])
1717 ["Current score" gnus-summary-current-score t]
1718 ["Set score" gnus-summary-set-score t]
1719 ["Switch current score file..." gnus-score-change-score-file t]
1720 ["Set mark below..." gnus-score-set-mark-below t]
1721 ["Set expunge below..." gnus-score-set-expunge-below t]
1722 ["Edit current score file" gnus-score-edit-current-scores t]
1723 ["Edit score file" gnus-score-edit-file t]
1724 ["Trace score" gnus-score-find-trace t]
1725 ["Find words" gnus-score-find-favourite-words t]
1726 ["Rescore buffer" gnus-summary-rescore t]
1727 ["Increase score..." gnus-summary-increase-score t]
1728 ["Lower score..." gnus-summary-lower-score t]))))
1730 ;; Define both the Article menu in the summary buffer and the equivalent
1731 ;; Commands menu in the article buffer here for consistency.
1734 ["All" gnus-article-hide t]
1735 ["Headers" gnus-article-hide-headers t]
1736 ["Signature" gnus-article-hide-signature t]
1737 ["Citation" gnus-article-hide-citation t]
1738 ["List identifiers" gnus-article-hide-list-identifiers t]
1739 ["PGP" gnus-article-hide-pgp t]
1740 ["Banner" gnus-article-strip-banner t]
1741 ["Boring headers" gnus-article-hide-boring-headers t])
1743 ["All" gnus-article-highlight t]
1744 ["Headers" gnus-article-highlight-headers t]
1745 ["Signature" gnus-article-highlight-signature t]
1746 ["Citation" gnus-article-highlight-citation t])
1748 ["Words" gnus-article-decode-mime-words t]
1749 ["Charset" gnus-article-decode-charset t]
1750 ["QP" gnus-article-de-quoted-unreadable t]
1751 ["Base64" gnus-article-de-base64-unreadable t]
1752 ["View all" gnus-mime-view-all-parts t]
1753 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1754 ["Encrypt body" gnus-article-encrypt-body t])
1756 ["Local" gnus-article-date-local t]
1757 ["ISO8601" gnus-article-date-iso8601 t]
1758 ["UT" gnus-article-date-ut t]
1759 ["Original" gnus-article-date-original t]
1760 ["Lapsed" gnus-article-date-lapsed t]
1761 ["User-defined" gnus-article-date-user t])
1764 ["Leading" gnus-article-strip-leading-blank-lines t]
1765 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1766 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1767 ["All of the above" gnus-article-strip-blank-lines t]
1768 ["All" gnus-article-strip-all-blank-lines t]
1769 ["Leading space" gnus-article-strip-leading-space t]
1770 ["Trailing space" gnus-article-strip-trailing-space t])
1771 ["Overstrike" gnus-article-treat-overstrike t]
1772 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1773 ["Emphasis" gnus-article-emphasize t]
1774 ["Word wrap" gnus-article-fill-cited-article t]
1775 ["Fill long lines" gnus-article-fill-long-lines t]
1776 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1777 ["CR" gnus-article-remove-cr t]
1778 ["Show X-Face" gnus-article-display-x-face t]
1779 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1780 ["Base64" gnus-article-de-base64-unreadable t]
1781 ["Rot 13" gnus-summary-caesar-message
1782 ,@(if (featurep 'xemacs) nil
1783 '(:help "\"Caesar rotate\" article by 13"))]
1784 ["Unix pipe" gnus-summary-pipe-message t]
1785 ["Add buttons" gnus-article-add-buttons t]
1786 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1787 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1788 ["Verbose header" gnus-summary-verbose-headers t]
1789 ["Toggle header" gnus-summary-toggle-header t]
1790 ["Html" gnus-article-wash-html t]
1791 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1792 ["HZ" gnus-article-decode-HZ t])
1794 ["Save in default format" gnus-summary-save-article
1795 ,@(if (featurep 'xemacs) nil
1796 '(:help "Save article using default method"))]
1797 ["Save in file" gnus-summary-save-article-file
1798 ,@(if (featurep 'xemacs) nil
1799 '(:help "Save article in file"))]
1800 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1801 ["Save in MH folder" gnus-summary-save-article-folder t]
1802 ["Save in VM folder" gnus-summary-save-article-vm t]
1803 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1804 ["Save body in file" gnus-summary-save-article-body-file t]
1805 ["Pipe through a filter" gnus-summary-pipe-output t]
1806 ["Add to SOUP packet" gnus-soup-add-article t]
1807 ["Print" gnus-summary-print-article t])
1809 ["Respool article..." gnus-summary-respool-article t]
1810 ["Move article..." gnus-summary-move-article
1811 (gnus-check-backend-function
1812 'request-move-article gnus-newsgroup-name)]
1813 ["Copy article..." gnus-summary-copy-article t]
1814 ["Crosspost article..." gnus-summary-crosspost-article
1815 (gnus-check-backend-function
1816 'request-replace-article gnus-newsgroup-name)]
1817 ["Import file..." gnus-summary-import-article t]
1818 ["Check if posted" gnus-summary-article-posted-p t]
1819 ["Edit article" gnus-summary-edit-article
1820 (not (gnus-group-read-only-p))]
1821 ["Delete article" gnus-summary-delete-article
1822 (gnus-check-backend-function
1823 'request-expire-articles gnus-newsgroup-name)]
1824 ["Query respool" gnus-summary-respool-query t]
1825 ["Trace respool" gnus-summary-respool-trace t]
1826 ["Delete expirable articles" gnus-summary-expire-articles-now
1827 (gnus-check-backend-function
1828 'request-expire-articles gnus-newsgroup-name)])
1830 ["Uudecode" gnus-uu-decode-uu
1831 ,@(if (featurep 'xemacs) nil
1832 '(:help "Decode uuencoded article(s)"))]
1833 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1834 ["Unshar" gnus-uu-decode-unshar t]
1835 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1836 ["Save" gnus-uu-decode-save t]
1837 ["Binhex" gnus-uu-decode-binhex t]
1838 ["Postscript" gnus-uu-decode-postscript t])
1840 ["Enter article" gnus-cache-enter-article t]
1841 ["Remove article" gnus-cache-remove-article t])
1842 ["Translate" gnus-article-babel t]
1843 ["Select article buffer" gnus-summary-select-article-buffer t]
1844 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1845 ["Isearch article..." gnus-summary-isearch-article t]
1846 ["Beginning of the article" gnus-summary-beginning-of-article t]
1847 ["End of the article" gnus-summary-end-of-article t]
1848 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1849 ["Fetch referenced articles" gnus-summary-refer-references t]
1850 ["Fetch current thread" gnus-summary-refer-thread t]
1851 ["Fetch article with id..." gnus-summary-refer-article t]
1852 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1853 ["Redisplay" gnus-summary-show-article t])))
1855 gnus-summary-article-menu gnus-summary-mode-map ""
1856 (cons "Article" innards))
1859 gnus-article-commands-menu gnus-article-mode-map ""
1860 (cons "Commands" innards)))
1863 gnus-summary-thread-menu gnus-summary-mode-map ""
1865 ["Toggle threading" gnus-summary-toggle-threads t]
1866 ["Hide threads" gnus-summary-hide-all-threads t]
1867 ["Show threads" gnus-summary-show-all-threads t]
1868 ["Hide thread" gnus-summary-hide-thread t]
1869 ["Show thread" gnus-summary-show-thread t]
1870 ["Go to next thread" gnus-summary-next-thread t]
1871 ["Go to previous thread" gnus-summary-prev-thread t]
1872 ["Go down thread" gnus-summary-down-thread t]
1873 ["Go up thread" gnus-summary-up-thread t]
1874 ["Top of thread" gnus-summary-top-thread t]
1875 ["Mark thread as read" gnus-summary-kill-thread t]
1876 ["Lower thread score" gnus-summary-lower-thread t]
1877 ["Raise thread score" gnus-summary-raise-thread t]
1878 ["Rethread current" gnus-summary-rethread-current t]))
1881 gnus-summary-post-menu gnus-summary-mode-map ""
1883 ["Post an article" gnus-summary-post-news
1884 ,@(if (featurep 'xemacs) nil
1885 '(:help "Post an article"))]
1886 ["Followup" gnus-summary-followup
1887 ,@(if (featurep 'xemacs) nil
1888 '(:help "Post followup to this article"))]
1889 ["Followup and yank" gnus-summary-followup-with-original
1890 ,@(if (featurep 'xemacs) nil
1891 '(:help "Post followup to this article, quoting its contents"))]
1892 ["Supersede article" gnus-summary-supersede-article t]
1893 ["Cancel article" gnus-summary-cancel-article
1894 ,@(if (featurep 'xemacs) nil
1895 '(:help "Cancel an article you posted"))]
1896 ["Reply" gnus-summary-reply t]
1897 ["Reply and yank" gnus-summary-reply-with-original t]
1898 ["Wide reply" gnus-summary-wide-reply t]
1899 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1900 ,@(if (featurep 'xemacs) nil
1901 '(:help "Mail a reply, quoting this article"))]
1902 ["Mail forward" gnus-summary-mail-forward t]
1903 ["Post forward" gnus-summary-post-forward t]
1904 ["Digest and mail" gnus-uu-digest-mail-forward t]
1905 ["Digest and post" gnus-uu-digest-post-forward t]
1906 ["Resend message" gnus-summary-resend-message t]
1907 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1908 ["Send a mail" gnus-summary-mail-other-window t]
1909 ["Uuencode and post" gnus-uu-post-news
1910 ,@(if (featurep 'xemacs) nil
1911 '(:help "Post a uuencoded article"))]
1912 ["Followup via news" gnus-summary-followup-to-mail t]
1913 ["Followup via news and yank"
1914 gnus-summary-followup-to-mail-with-original t]
1916 ;;["Send" gnus-summary-send-draft t]
1917 ;;["Send bounced" gnus-resend-bounced-mail t])
1921 gnus-summary-misc-menu gnus-summary-mode-map ""
1924 ["Mark as read" gnus-summary-mark-as-read-forward t]
1925 ["Mark same subject and select"
1926 gnus-summary-kill-same-subject-and-select t]
1927 ["Mark same subject" gnus-summary-kill-same-subject t]
1928 ["Catchup" gnus-summary-catchup
1929 ,@(if (featurep 'xemacs) nil
1930 '(:help "Mark unread articles in this group as read"))]
1931 ["Catchup all" gnus-summary-catchup-all t]
1932 ["Catchup to here" gnus-summary-catchup-to-here t]
1933 ["Catchup region" gnus-summary-mark-region-as-read t]
1934 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1936 ["Tick" gnus-summary-tick-article-forward t]
1937 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1938 ["Remove marks" gnus-summary-clear-mark-forward t]
1939 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1940 ["Set bookmark" gnus-summary-set-bookmark t]
1941 ["Remove bookmark" gnus-summary-remove-bookmark t])
1943 ["Marks..." gnus-summary-limit-to-marks t]
1944 ["Subject..." gnus-summary-limit-to-subject t]
1945 ["Author..." gnus-summary-limit-to-author t]
1946 ["Age..." gnus-summary-limit-to-age t]
1947 ["Extra..." gnus-summary-limit-to-extra t]
1948 ["Score" gnus-summary-limit-to-score t]
1949 ["Unread" gnus-summary-limit-to-unread t]
1950 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1951 ["Articles" gnus-summary-limit-to-articles t]
1952 ["Pop limit" gnus-summary-pop-limit t]
1953 ["Show dormant" gnus-summary-limit-include-dormant t]
1954 ["Hide childless dormant"
1955 gnus-summary-limit-exclude-childless-dormant t]
1956 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1957 ["Hide marked" gnus-summary-limit-exclude-marks t]
1958 ["Show expunged" gnus-summary-show-all-expunged t])
1960 ["Set mark" gnus-summary-mark-as-processable t]
1961 ["Remove mark" gnus-summary-unmark-as-processable t]
1962 ["Remove all marks" gnus-summary-unmark-all-processable t]
1963 ["Mark above" gnus-uu-mark-over t]
1964 ["Mark series" gnus-uu-mark-series t]
1965 ["Mark region" gnus-uu-mark-region t]
1966 ["Unmark region" gnus-uu-unmark-region t]
1967 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1968 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1969 ["Mark all" gnus-uu-mark-all t]
1970 ["Mark buffer" gnus-uu-mark-buffer t]
1971 ["Mark sparse" gnus-uu-mark-sparse t]
1972 ["Mark thread" gnus-uu-mark-thread t]
1973 ["Unmark thread" gnus-uu-unmark-thread t]
1974 ("Process Mark Sets"
1975 ["Kill" gnus-summary-kill-process-mark t]
1976 ["Yank" gnus-summary-yank-process-mark
1977 gnus-newsgroup-process-stack]
1978 ["Save" gnus-summary-save-process-mark t]))
1980 ["Page forward" gnus-summary-next-page
1981 ,@(if (featurep 'xemacs) nil
1982 '(:help "Show next page of article"))]
1983 ["Page backward" gnus-summary-prev-page
1984 ,@(if (featurep 'xemacs) nil
1985 '(:help "Show previous page of article"))]
1986 ["Line forward" gnus-summary-scroll-up t])
1988 ["Next unread article" gnus-summary-next-unread-article t]
1989 ["Previous unread article" gnus-summary-prev-unread-article t]
1990 ["Next article" gnus-summary-next-article t]
1991 ["Previous article" gnus-summary-prev-article t]
1992 ["Next unread subject" gnus-summary-next-unread-subject t]
1993 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1994 ["Next article same subject" gnus-summary-next-same-subject t]
1995 ["Previous article same subject" gnus-summary-prev-same-subject t]
1996 ["First unread article" gnus-summary-first-unread-article t]
1997 ["Best unread article" gnus-summary-best-unread-article t]
1998 ["Go to subject number..." gnus-summary-goto-subject t]
1999 ["Go to article number..." gnus-summary-goto-article t]
2000 ["Go to the last article" gnus-summary-goto-last-article t]
2001 ["Pop article off history" gnus-summary-pop-article t])
2003 ["Sort by number" gnus-summary-sort-by-number t]
2004 ["Sort by author" gnus-summary-sort-by-author t]
2005 ["Sort by subject" gnus-summary-sort-by-subject t]
2006 ["Sort by date" gnus-summary-sort-by-date t]
2007 ["Sort by score" gnus-summary-sort-by-score t]
2008 ["Sort by lines" gnus-summary-sort-by-lines t]
2009 ["Sort by characters" gnus-summary-sort-by-chars t])
2011 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2012 ["Describe group" gnus-summary-describe-group t]
2013 ["Read manual" gnus-info-find-node t])
2015 ["Pick and read" gnus-pick-mode t]
2016 ["Binary" gnus-binary-mode t])
2018 ["Regenerate" gnus-summary-prepare t]
2019 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2020 ["Toggle threading" gnus-summary-toggle-threads t])
2021 ["Filter articles..." gnus-summary-execute-command t]
2022 ["Run command on subjects..." gnus-summary-universal-argument t]
2023 ["Search articles forward..." gnus-summary-search-article-forward t]
2024 ["Search articles backward..." gnus-summary-search-article-backward t]
2025 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2026 ["Expand window" gnus-summary-expand-window t]
2027 ["Expire expirable articles" gnus-summary-expire-articles
2028 (gnus-check-backend-function
2029 'request-expire-articles gnus-newsgroup-name)]
2030 ["Edit local kill file" gnus-summary-edit-local-kill t]
2031 ["Edit main kill file" gnus-summary-edit-global-kill t]
2032 ["Edit group parameters" gnus-summary-edit-parameters t]
2033 ["Customize group parameters" gnus-summary-customize-parameters t]
2034 ["Send a bug report" gnus-bug t]
2036 ["Catchup and exit" gnus-summary-catchup-and-exit
2037 ,@(if (featurep 'xemacs) nil
2038 '(:help "Mark unread articles in this group as read, then exit"))]
2039 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2040 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2041 ["Exit group" gnus-summary-exit
2042 ,@(if (featurep 'xemacs) nil
2043 '(:help "Exit current group, return to group selection mode"))]
2044 ["Exit group without updating" gnus-summary-exit-no-update t]
2045 ["Exit and goto next group" gnus-summary-next-group t]
2046 ["Exit and goto prev group" gnus-summary-prev-group t]
2047 ["Reselect group" gnus-summary-reselect-current-group t]
2048 ["Rescan group" gnus-summary-rescan-group t]
2049 ["Update dribble" gnus-summary-save-newsrc t])))
2051 (gnus-run-hooks 'gnus-summary-menu-hook)))
2053 (defvar gnus-summary-tool-bar-map nil)
2055 ;; Emacs 21 tool bar. Should be no-op otherwise.
2056 (defun gnus-summary-make-tool-bar ()
2057 (if (and (fboundp 'tool-bar-add-item-from-menu)
2058 (default-value 'tool-bar-mode)
2059 (not gnus-summary-tool-bar-map))
2060 (setq gnus-summary-tool-bar-map
2061 (let ((tool-bar-map (make-sparse-keymap))
2062 (load-path (mm-image-load-path)))
2063 (tool-bar-add-item-from-menu
2064 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2065 (tool-bar-add-item-from-menu
2066 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2067 (tool-bar-add-item-from-menu
2068 'gnus-summary-post-news "post" gnus-summary-mode-map)
2069 (tool-bar-add-item-from-menu
2070 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2071 (tool-bar-add-item-from-menu
2072 'gnus-summary-followup "followup" gnus-summary-mode-map)
2073 (tool-bar-add-item-from-menu
2074 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2075 (tool-bar-add-item-from-menu
2076 'gnus-summary-reply "reply" gnus-summary-mode-map)
2077 (tool-bar-add-item-from-menu
2078 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2079 (tool-bar-add-item-from-menu
2080 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2081 (tool-bar-add-item-from-menu
2082 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2083 (tool-bar-add-item-from-menu
2084 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2085 (tool-bar-add-item-from-menu
2086 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2087 (tool-bar-add-item-from-menu
2088 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2089 (tool-bar-add-item-from-menu
2090 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2091 (tool-bar-add-item-from-menu
2092 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2094 (if gnus-summary-tool-bar-map
2095 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2097 (defun gnus-score-set-default (var value)
2098 "A version of set that updates the GNU Emacs menu-bar."
2100 ;; It is the message that forces the active status to be updated.
2103 (defun gnus-make-score-map (type)
2104 "Make a summary score map of type TYPE."
2107 (let ((headers '(("author" "from" string)
2108 ("subject" "subject" string)
2109 ("article body" "body" string)
2110 ("article head" "head" string)
2111 ("xref" "xref" string)
2112 ("extra header" "extra" string)
2113 ("lines" "lines" number)
2114 ("followups to author" "followup" string)))
2115 (types '((number ("less than" <)
2118 (string ("substring" s)
2122 (perms '(("temporary" (current-time-string))
2130 (if (eq type 'lower)
2135 (setq header (car headers))
2141 (let ((ts (cdr (assoc (nth 2 header) types)))
2157 'gnus-summary-score-entry
2159 (if (or (string= (nth 1 header)
2161 (string= (nth 1 header)
2164 (list 'gnus-summary-header
2166 (list 'quote (nth 1 (car ts)))
2167 (list 'gnus-score-delta-default
2174 (list (nreverse outp))))
2177 (list (nreverse outt))))
2179 (setq headers (cdr headers)))
2180 (list (nreverse outh))))))))
2184 (defun gnus-summary-mode (&optional group)
2185 "Major mode for reading articles.
2187 All normal editing commands are switched off.
2188 \\<gnus-summary-mode-map>
2189 Each line in this buffer represents one article. To read an
2190 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2191 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2194 You can also post articles and send mail from this buffer. To
2195 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2196 of an article, type `\\[gnus-summary-reply]'.
2198 There are approx. one gazillion commands you can execute in this
2199 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2201 The following commands are available:
2203 \\{gnus-summary-mode-map}"
2205 (kill-all-local-variables)
2206 (when (gnus-visual-p 'summary-menu 'menu)
2207 (gnus-summary-make-menu-bar)
2208 (gnus-summary-make-tool-bar))
2209 (gnus-summary-make-local-variables)
2210 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2211 (gnus-summary-make-local-variables))
2212 (gnus-make-thread-indent-array)
2213 (gnus-simplify-mode-line)
2214 (setq major-mode 'gnus-summary-mode)
2215 (setq mode-name "Summary")
2216 (make-local-variable 'minor-mode-alist)
2217 (use-local-map gnus-summary-mode-map)
2218 (buffer-disable-undo)
2219 (setq buffer-read-only t) ;Disable modification
2220 (setq truncate-lines t)
2221 (setq selective-display t)
2222 (setq selective-display-ellipses t) ;Display `...'
2223 (gnus-summary-set-display-table)
2224 (gnus-set-default-directory)
2225 (setq gnus-newsgroup-name group)
2226 (make-local-variable 'gnus-summary-line-format)
2227 (make-local-variable 'gnus-summary-line-format-spec)
2228 (make-local-variable 'gnus-summary-dummy-line-format)
2229 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2230 (make-local-variable 'gnus-summary-mark-positions)
2231 (make-local-hook 'pre-command-hook)
2232 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2233 (gnus-run-hooks 'gnus-summary-mode-hook)
2234 (turn-on-gnus-mailing-list-mode)
2235 (mm-enable-multibyte-mule4)
2236 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2237 (gnus-update-summary-mark-positions))
2239 (defun gnus-summary-make-local-variables ()
2240 "Make all the local summary buffer variables."
2242 (dolist (local gnus-summary-local-variables)
2245 (if (eq (cdr local) 'global)
2246 ;; Copy the global value of the variable.
2247 (setq global (symbol-value (car local)))
2248 ;; Use the value from the list.
2249 (setq global (eval (cdr local))))
2250 (set (make-local-variable (car local)) global))
2251 ;; Simple nil-valued local variable.
2252 (set (make-local-variable local) nil)))))
2254 (defun gnus-summary-clear-local-variables ()
2255 (let ((locals gnus-summary-local-variables))
2257 (if (consp (car locals))
2258 (and (vectorp (caar locals))
2259 (set (caar locals) nil))
2260 (and (vectorp (car locals))
2261 (set (car locals) nil)))
2262 (setq locals (cdr locals)))))
2264 ;; Summary data functions.
2266 (defmacro gnus-data-number (data)
2269 (defmacro gnus-data-set-number (data number)
2270 `(setcar ,data ,number))
2272 (defmacro gnus-data-mark (data)
2275 (defmacro gnus-data-set-mark (data mark)
2276 `(setcar (nthcdr 1 ,data) ,mark))
2278 (defmacro gnus-data-pos (data)
2281 (defmacro gnus-data-set-pos (data pos)
2282 `(setcar (nthcdr 2 ,data) ,pos))
2284 (defmacro gnus-data-header (data)
2287 (defmacro gnus-data-set-header (data header)
2288 `(setf (nth 3 ,data) ,header))
2290 (defmacro gnus-data-level (data)
2293 (defmacro gnus-data-unread-p (data)
2294 `(= (nth 1 ,data) gnus-unread-mark))
2296 (defmacro gnus-data-read-p (data)
2297 `(/= (nth 1 ,data) gnus-unread-mark))
2299 (defmacro gnus-data-pseudo-p (data)
2300 `(consp (nth 3 ,data)))
2302 (defmacro gnus-data-find (number)
2303 `(assq ,number gnus-newsgroup-data))
2305 (defmacro gnus-data-find-list (number &optional data)
2306 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2307 (memq (assq ,number bdata)
2310 (defmacro gnus-data-make (number mark pos header level)
2311 `(list ,number ,mark ,pos ,header ,level))
2313 (defun gnus-data-enter (after-article number mark pos header level offset)
2314 (let ((data (gnus-data-find-list after-article)))
2316 (error "No such article: %d" after-article))
2317 (setcdr data (cons (gnus-data-make number mark pos header level)
2319 (setq gnus-newsgroup-data-reverse nil)
2320 (gnus-data-update-list (cddr data) offset)))
2322 (defun gnus-data-enter-list (after-article list &optional offset)
2324 (let ((data (and after-article (gnus-data-find-list after-article)))
2328 (let ((odata gnus-newsgroup-data))
2329 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2331 (gnus-data-update-list odata offset)))
2332 ;; Find the last element in the list to be spliced into the main
2335 (setq list (cdr list)))
2338 (setcdr list gnus-newsgroup-data)
2339 (setq gnus-newsgroup-data ilist)
2341 (gnus-data-update-list (cdr list) offset)))
2342 (setcdr list (cdr data))
2345 (gnus-data-update-list (cdr list) offset))))
2346 (setq gnus-newsgroup-data-reverse nil))))
2348 (defun gnus-data-remove (article &optional offset)
2349 (let ((data gnus-newsgroup-data))
2350 (if (= (gnus-data-number (car data)) article)
2352 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2353 gnus-newsgroup-data-reverse nil)
2355 (gnus-data-update-list gnus-newsgroup-data offset)))
2357 (when (= (gnus-data-number (cadr data)) article)
2358 (setcdr data (cddr data))
2360 (gnus-data-update-list (cdr data) offset))
2362 gnus-newsgroup-data-reverse nil))
2363 (setq data (cdr data))))))
2365 (defmacro gnus-data-list (backward)
2367 (or gnus-newsgroup-data-reverse
2368 (setq gnus-newsgroup-data-reverse
2369 (reverse gnus-newsgroup-data)))
2370 gnus-newsgroup-data))
2372 (defun gnus-data-update-list (data offset)
2373 "Add OFFSET to the POS of all data entries in DATA."
2374 (setq gnus-newsgroup-data-reverse nil)
2376 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2377 (setq data (cdr data))))
2379 (defun gnus-summary-article-pseudo-p (article)
2380 "Say whether this article is a pseudo article or not."
2381 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2383 (defmacro gnus-summary-article-sparse-p (article)
2384 "Say whether this article is a sparse article or not."
2385 `(memq ,article gnus-newsgroup-sparse))
2387 (defmacro gnus-summary-article-ancient-p (article)
2388 "Say whether this article is a sparse article or not."
2389 `(memq ,article gnus-newsgroup-ancient))
2391 (defun gnus-article-parent-p (number)
2392 "Say whether this article is a parent or not."
2393 (let ((data (gnus-data-find-list number)))
2394 (and (cdr data) ; There has to be an article after...
2395 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2396 (gnus-data-level (nth 1 data))))))
2398 (defun gnus-article-children (number)
2399 "Return a list of all children to NUMBER."
2400 (let* ((data (gnus-data-find-list number))
2401 (level (gnus-data-level (car data)))
2403 (setq data (cdr data))
2405 (= (gnus-data-level (car data)) (1+ level)))
2406 (push (gnus-data-number (car data)) children)
2407 (setq data (cdr data)))
2410 (defmacro gnus-summary-skip-intangible ()
2411 "If the current article is intangible, then jump to a different article."
2412 '(let ((to (get-text-property (point) 'gnus-intangible)))
2413 (and to (gnus-summary-goto-subject to))))
2415 (defmacro gnus-summary-article-intangible-p ()
2416 "Say whether this article is intangible or not."
2417 '(get-text-property (point) 'gnus-intangible))
2419 (defun gnus-article-read-p (article)
2420 "Say whether ARTICLE is read or not."
2421 (not (or (memq article gnus-newsgroup-marked)
2422 (memq article gnus-newsgroup-unreads)
2423 (memq article gnus-newsgroup-unselected)
2424 (memq article gnus-newsgroup-dormant))))
2426 ;; Some summary mode macros.
2428 (defmacro gnus-summary-article-number ()
2429 "The article number of the article on the current line.
2430 If there isn's an article number here, then we return the current
2433 (gnus-summary-skip-intangible)
2434 (or (get-text-property (point) 'gnus-number)
2435 (gnus-summary-last-subject))))
2437 (defmacro gnus-summary-article-header (&optional number)
2438 "Return the header of article NUMBER."
2439 `(gnus-data-header (gnus-data-find
2440 ,(or number '(gnus-summary-article-number)))))
2442 (defmacro gnus-summary-thread-level (&optional number)
2443 "Return the level of thread that starts with article NUMBER."
2444 `(if (and (eq gnus-summary-make-false-root 'dummy)
2445 (get-text-property (point) 'gnus-intangible))
2447 (gnus-data-level (gnus-data-find
2448 ,(or number '(gnus-summary-article-number))))))
2450 (defmacro gnus-summary-article-mark (&optional number)
2451 "Return the mark of article NUMBER."
2452 `(gnus-data-mark (gnus-data-find
2453 ,(or number '(gnus-summary-article-number)))))
2455 (defmacro gnus-summary-article-pos (&optional number)
2456 "Return the position of the line of article NUMBER."
2457 `(gnus-data-pos (gnus-data-find
2458 ,(or number '(gnus-summary-article-number)))))
2460 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2461 (defmacro gnus-summary-article-subject (&optional number)
2462 "Return current subject string or nil if nothing."
2465 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2466 '(gnus-data-header (assq (gnus-summary-article-number)
2467 gnus-newsgroup-data)))))
2470 (mail-header-subject headers))))
2472 (defmacro gnus-summary-article-score (&optional number)
2473 "Return current article score."
2474 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2475 gnus-newsgroup-scored))
2476 gnus-summary-default-score 0))
2478 (defun gnus-summary-article-children (&optional number)
2479 "Return a list of article numbers that are children of article NUMBER."
2480 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2481 (level (gnus-data-level (car data)))
2483 (while (and (setq data (cdr data))
2484 (> (setq l (gnus-data-level (car data))) level))
2485 (and (= (1+ level) l)
2486 (push (gnus-data-number (car data))
2488 (nreverse children)))
2490 (defun gnus-summary-article-parent (&optional number)
2491 "Return the article number of the parent of article NUMBER."
2492 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2493 (gnus-data-list t)))
2494 (level (gnus-data-level (car data))))
2496 () ; This is a root.
2497 ;; We search until we find an article with a level less than
2498 ;; this one. That function has to be the parent.
2499 (while (and (setq data (cdr data))
2500 (not (< (gnus-data-level (car data)) level))))
2501 (and data (gnus-data-number (car data))))))
2503 (defun gnus-unread-mark-p (mark)
2504 "Say whether MARK is the unread mark."
2505 (= mark gnus-unread-mark))
2507 (defun gnus-read-mark-p (mark)
2508 "Say whether MARK is one of the marks that mark as read.
2509 This is all marks except unread, ticked, dormant, and expirable."
2510 (not (or (= mark gnus-unread-mark)
2511 (= mark gnus-ticked-mark)
2512 (= mark gnus-dormant-mark)
2513 (= mark gnus-expirable-mark))))
2515 (defmacro gnus-article-mark (number)
2516 "Return the MARK of article NUMBER.
2517 This macro should only be used when computing the mark the \"first\"
2518 time; i.e., when generating the summary lines. After that,
2519 `gnus-summary-article-mark' should be used to examine the
2522 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2523 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2524 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2525 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2526 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2527 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2528 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2529 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2530 gnus-ancient-mark))))
2532 ;; Saving hidden threads.
2534 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2535 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2537 (defmacro gnus-save-hidden-threads (&rest forms)
2538 "Save hidden threads, eval FORMS, and restore the hidden threads."
2539 (let ((config (make-symbol "config")))
2540 `(let ((,config (gnus-hidden-threads-configuration)))
2544 (gnus-restore-hidden-threads-configuration ,config)))))
2546 (defun gnus-data-compute-positions ()
2547 "Compute the positions of all articles."
2548 (setq gnus-newsgroup-data-reverse nil)
2549 (let ((data gnus-newsgroup-data))
2551 (gnus-save-hidden-threads
2552 (gnus-summary-show-all-threads)
2553 (goto-char (point-min))
2555 (while (get-text-property (point) 'gnus-intangible)
2557 (gnus-data-set-pos (car data) (+ (point) 3))
2558 (setq data (cdr data))
2559 (forward-line 1))))))
2561 (defun gnus-hidden-threads-configuration ()
2562 "Return the current hidden threads configuration."
2565 (goto-char (point-min))
2566 (while (search-forward "\r" nil t)
2567 (push (1- (point)) config))
2570 (defun gnus-restore-hidden-threads-configuration (config)
2571 "Restore hidden threads configuration from CONFIG."
2573 (let (point buffer-read-only)
2574 (while (setq point (pop config))
2575 (when (and (< point (point-max))
2577 (eq (char-after) ?\n))
2578 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2580 ;; Various summary mode internalish functions.
2582 (defun gnus-mouse-pick-article (e)
2585 (gnus-summary-next-page nil t))
2587 (defun gnus-summary-set-display-table ()
2588 "Change the display table.
2589 Odd characters have a tendency to mess
2590 up nicely formatted displays - we make all possible glyphs
2591 display only a single character."
2593 ;; We start from the standard display table, if any.
2594 (let ((table (or (copy-sequence standard-display-table)
2595 (make-display-table)))
2597 ;; Nix out all the control chars...
2598 (while (>= (setq i (1- i)) 0)
2599 (aset table i [??]))
2600 ;; ... but not newline and cr, of course. (cr is necessary for the
2601 ;; selective display).
2602 (aset table ?\n nil)
2603 (aset table ?\r nil)
2604 ;; We keep TAB as well.
2605 (aset table ?\t nil)
2606 ;; We nix out any glyphs over 126 that are not set already.
2608 (while (>= (setq i (1- i)) 127)
2609 ;; Only modify if the entry is nil.
2610 (unless (aref table i)
2611 (aset table i [??]))))
2612 (setq buffer-display-table table)))
2614 (defun gnus-summary-setup-buffer (group)
2615 "Initialize summary buffer."
2616 (let ((buffer (concat "*Summary " group "*")))
2617 (if (get-buffer buffer)
2620 (setq gnus-summary-buffer (current-buffer))
2621 (not gnus-newsgroup-prepared))
2622 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2623 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2624 (gnus-summary-mode group)
2626 (gnus-carpal-setup-buffer 'summary))
2627 (unless gnus-single-article-buffer
2628 (make-local-variable 'gnus-article-buffer)
2629 (make-local-variable 'gnus-article-current)
2630 (make-local-variable 'gnus-original-article-buffer))
2631 (setq gnus-newsgroup-name group)
2634 (defun gnus-set-global-variables ()
2635 "Set the global equivalents of the buffer-local variables.
2636 They are set to the latest values they had. These reflect the summary
2637 buffer that was in action when the last article was fetched."
2638 (when (eq major-mode 'gnus-summary-mode)
2639 (setq gnus-summary-buffer (current-buffer))
2640 (let ((name gnus-newsgroup-name)
2641 (marked gnus-newsgroup-marked)
2642 (unread gnus-newsgroup-unreads)
2643 (headers gnus-current-headers)
2644 (data gnus-newsgroup-data)
2645 (summary gnus-summary-buffer)
2646 (article-buffer gnus-article-buffer)
2647 (original gnus-original-article-buffer)
2648 (gac gnus-article-current)
2649 (reffed gnus-reffed-article-number)
2650 (score-file gnus-current-score-file)
2651 (default-charset gnus-newsgroup-charset)
2653 (let ((locals gnus-newsgroup-variables))
2655 (if (consp (car locals))
2656 (push (eval (caar locals)) vlist)
2657 (push (eval (car locals)) vlist))
2658 (setq locals (cdr locals)))
2659 (setq vlist (nreverse vlist)))
2661 (set-buffer gnus-group-buffer)
2662 (setq gnus-newsgroup-name name
2663 gnus-newsgroup-marked marked
2664 gnus-newsgroup-unreads unread
2665 gnus-current-headers headers
2666 gnus-newsgroup-data data
2667 gnus-article-current gac
2668 gnus-summary-buffer summary
2669 gnus-article-buffer article-buffer
2670 gnus-original-article-buffer original
2671 gnus-reffed-article-number reffed
2672 gnus-current-score-file score-file
2673 gnus-newsgroup-charset default-charset)
2674 (let ((locals gnus-newsgroup-variables))
2676 (if (consp (car locals))
2677 (set (caar locals) (pop vlist))
2678 (set (car locals) (pop vlist)))
2679 (setq locals (cdr locals))))
2680 ;; The article buffer also has local variables.
2681 (when (gnus-buffer-live-p gnus-article-buffer)
2682 (set-buffer gnus-article-buffer)
2683 (setq gnus-summary-buffer summary))))))
2685 (defun gnus-summary-article-unread-p (article)
2686 "Say whether ARTICLE is unread or not."
2687 (memq article gnus-newsgroup-unreads))
2689 (defun gnus-summary-first-article-p (&optional article)
2690 "Return whether ARTICLE is the first article in the buffer."
2691 (if (not (setq article (or article (gnus-summary-article-number))))
2693 (eq article (caar gnus-newsgroup-data))))
2695 (defun gnus-summary-last-article-p (&optional article)
2696 "Return whether ARTICLE is the last article in the buffer."
2697 (if (not (setq article (or article (gnus-summary-article-number))))
2698 ;; All non-existent numbers are the last article. :-)
2700 (not (cdr (gnus-data-find-list article)))))
2702 (defun gnus-make-thread-indent-array ()
2704 (unless (and gnus-thread-indent-array
2705 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2706 (setq gnus-thread-indent-array (make-vector 201 "")
2707 gnus-thread-indent-array-level gnus-thread-indent-level)
2709 (aset gnus-thread-indent-array n
2710 (make-string (* n gnus-thread-indent-level) ? ))
2713 (defun gnus-update-summary-mark-positions ()
2714 "Compute where the summary marks are to go."
2716 (when (gnus-buffer-exists-p gnus-summary-buffer)
2717 (set-buffer gnus-summary-buffer))
2718 (let ((gnus-replied-mark 129)
2719 (gnus-score-below-mark 130)
2720 (gnus-score-over-mark 130)
2721 (gnus-download-mark 131)
2722 (spec gnus-summary-line-format-spec)
2725 (gnus-set-work-buffer)
2726 (let ((gnus-summary-line-format-spec spec)
2727 (gnus-newsgroup-downloadable '((0 . t))))
2728 (gnus-summary-insert-line
2729 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2730 (goto-char (point-min))
2731 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2733 (goto-char (point-min))
2734 (push (cons 'replied (and (search-forward "\201" nil t)
2737 (goto-char (point-min))
2738 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2740 (goto-char (point-min))
2741 (push (cons 'download
2742 (and (search-forward "\203" nil t) (- (point) 2)))
2744 (setq gnus-summary-mark-positions pos))))
2746 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2747 "Insert a dummy root in the summary buffer."
2749 (gnus-add-text-properties
2750 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2751 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2753 (defun gnus-summary-from-or-to-or-newsgroups (header)
2754 (let ((to (cdr (assq 'To (mail-header-extra header))))
2755 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2756 (mail-parse-charset gnus-newsgroup-charset)
2757 (mail-parse-ignored-charsets
2758 (save-excursion (set-buffer gnus-summary-buffer)
2759 gnus-newsgroup-ignored-charsets)))
2762 gnus-ignored-from-addresses
2763 (string-match gnus-ignored-from-addresses
2764 (mail-header-from header)))
2766 (or (car (funcall gnus-extract-address-components
2768 gnus-decode-encoded-word-function to)))
2769 (funcall gnus-decode-encoded-word-function to))))
2771 gnus-ignored-from-addresses
2772 (string-match gnus-ignored-from-addresses
2773 (mail-header-from header)))
2774 (concat "=> " newsgroups))
2776 (or (car (funcall gnus-extract-address-components
2777 (mail-header-from header)))
2778 (mail-header-from header))))))
2780 (defun gnus-summary-insert-line (gnus-tmp-header
2781 gnus-tmp-level gnus-tmp-current
2782 gnus-tmp-unread gnus-tmp-replied
2783 gnus-tmp-expirable gnus-tmp-subject-or-nil
2784 &optional gnus-tmp-dummy gnus-tmp-score
2786 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2787 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2788 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2789 (gnus-tmp-score-char
2790 (if (or (null gnus-summary-default-score)
2791 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2792 gnus-summary-zcore-fuzz))
2794 (if (< gnus-tmp-score gnus-summary-default-score)
2795 gnus-score-below-mark gnus-score-over-mark)))
2797 (cond (gnus-tmp-process gnus-process-mark)
2798 ((memq gnus-tmp-current gnus-newsgroup-cached)
2800 (gnus-tmp-replied gnus-replied-mark)
2801 ((memq gnus-tmp-current gnus-newsgroup-saved)
2804 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2807 ((string-match "<[^>]+> *$" gnus-tmp-from)
2808 (let ((beg (match-beginning 0)))
2809 (or (and (string-match "^\".+\"" gnus-tmp-from)
2810 (substring gnus-tmp-from 1 (1- (match-end 0))))
2811 (substring gnus-tmp-from 0 beg))))
2812 ((string-match "(.+)" gnus-tmp-from)
2813 (substring gnus-tmp-from
2814 (1+ (match-beginning 0)) (1- (match-end 0))))
2816 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2817 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2818 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2819 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2820 (buffer-read-only nil))
2821 (when (string= gnus-tmp-name "")
2822 (setq gnus-tmp-name gnus-tmp-from))
2823 (unless (numberp gnus-tmp-lines)
2824 (setq gnus-tmp-lines 0))
2825 (gnus-put-text-property
2827 (progn (eval gnus-summary-line-format-spec) (point))
2828 'gnus-number gnus-tmp-number)
2829 (when (gnus-visual-p 'summary-highlight 'highlight)
2831 (gnus-run-hooks 'gnus-summary-update-hook)
2834 (defun gnus-summary-update-line (&optional dont-update)
2835 "Update summary line after change."
2836 (when (and gnus-summary-default-score
2837 (not gnus-summary-inhibit-highlight))
2838 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2839 (article (gnus-summary-article-number))
2840 (score (gnus-summary-article-score article)))
2842 (if (and gnus-summary-mark-below
2843 (< (gnus-summary-article-score)
2844 gnus-summary-mark-below))
2845 ;; This article has a low score, so we mark it as read.
2846 (when (memq article gnus-newsgroup-unreads)
2847 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2848 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2849 ;; This article was previously marked as read on account
2850 ;; of a low score, but now it has risen, so we mark it as
2852 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2853 (gnus-summary-update-mark
2854 (if (or (null gnus-summary-default-score)
2855 (<= (abs (- score gnus-summary-default-score))
2856 gnus-summary-zcore-fuzz))
2858 (if (< score gnus-summary-default-score)
2859 gnus-score-below-mark gnus-score-over-mark))
2861 ;; Do visual highlighting.
2862 (when (gnus-visual-p 'summary-highlight 'highlight)
2863 (gnus-run-hooks 'gnus-summary-update-hook)))))
2865 (defvar gnus-tmp-new-adopts nil)
2867 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2868 "Return the number of articles in THREAD.
2869 This may be 0 in some cases -- if none of the articles in
2870 the thread are to be displayed."
2872 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2874 ((not (listp thread))
2876 ((and (consp thread) (cdr thread))
2879 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2882 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2885 (when (and level (zerop level) gnus-tmp-new-adopts)
2888 'gnus-summary-number-of-articles-in-thread
2889 gnus-tmp-new-adopts))))
2891 (if (> number 1) gnus-not-empty-thread-mark
2892 gnus-empty-thread-mark)
2895 (defun gnus-summary-set-local-parameters (group)
2896 "Go through the local params of GROUP and set all variable specs in that list."
2897 (let ((params (gnus-group-find-parameter group))
2900 (setq elem (car params)
2901 params (cdr params))
2902 (and (consp elem) ; Has to be a cons.
2903 (consp (cdr elem)) ; The cdr has to be a list.
2904 (symbolp (car elem)) ; Has to be a symbol in there.
2905 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2906 (ignore-errors ; So we set it.
2907 (make-local-variable (car elem))
2908 (set (car elem) (eval (nth 1 elem))))))))
2910 (defun gnus-summary-read-group (group &optional show-all no-article
2911 kill-buffer no-display backward
2913 "Start reading news in newsgroup GROUP.
2914 If SHOW-ALL is non-nil, already read articles are also listed.
2915 If NO-ARTICLE is non-nil, no article is selected initially.
2916 If NO-DISPLAY, don't generate a summary buffer."
2920 (let ((gnus-auto-select-next nil))
2921 (or (gnus-summary-read-group-1
2922 group show-all no-article
2923 kill-buffer no-display
2926 select-articles nil)))))
2927 (eq gnus-auto-select-next 'quietly))
2928 (set-buffer gnus-group-buffer)
2929 ;; The entry function called above goes to the next
2930 ;; group automatically, so we go two groups back
2931 ;; if we are searching for the previous group.
2933 (gnus-group-prev-unread-group 2))
2934 (if (not (equal group (gnus-group-group-name)))
2935 (setq group (gnus-group-group-name))
2939 (defun gnus-summary-read-group-1 (group show-all no-article
2940 kill-buffer no-display
2941 &optional select-articles)
2942 ;; Killed foreign groups can't be entered.
2943 (when (and (not (gnus-group-native-p group))
2944 (not (gnus-gethash group gnus-newsrc-hashtb)))
2945 (error "Dead non-native groups can't be entered"))
2946 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2947 (let* ((new-group (gnus-summary-setup-buffer group))
2948 (quit-config (gnus-group-quit-config group))
2949 (did-select (and new-group (gnus-select-newsgroup
2950 group show-all select-articles))))
2952 ;; This summary buffer exists already, so we just select it.
2954 (gnus-set-global-variables)
2956 (gnus-kill-or-deaden-summary kill-buffer))
2957 (gnus-configure-windows 'summary 'force)
2958 (gnus-set-mode-line 'summary)
2959 (gnus-summary-position-point)
2962 ;; We couldn't select this group.
2964 (when (and (eq major-mode 'gnus-summary-mode)
2965 (not (equal (current-buffer) kill-buffer)))
2966 (kill-buffer (current-buffer))
2967 (if (not quit-config)
2969 ;; Update the info -- marks might need to be removed,
2971 (gnus-summary-update-info)
2972 (set-buffer gnus-group-buffer)
2973 (gnus-group-jump-to-group group)
2974 (gnus-group-next-unread-group 1))
2975 (gnus-handle-ephemeral-exit quit-config)))
2976 (gnus-message 3 "Can't select group")
2978 ;; The user did a `C-g' while prompting for number of articles,
2979 ;; so we exit this group.
2980 ((eq did-select 'quit)
2981 (and (eq major-mode 'gnus-summary-mode)
2982 (not (equal (current-buffer) kill-buffer))
2983 (kill-buffer (current-buffer)))
2985 (gnus-kill-or-deaden-summary kill-buffer))
2986 (if (not quit-config)
2988 (set-buffer gnus-group-buffer)
2989 (gnus-group-jump-to-group group)
2990 (gnus-group-next-unread-group 1)
2991 (gnus-configure-windows 'group 'force))
2992 (gnus-handle-ephemeral-exit quit-config))
2993 ;; Finally signal the quit.
2995 ;; The group was successfully selected.
2997 (gnus-set-global-variables)
2998 ;; Save the active value in effect when the group was entered.
2999 (setq gnus-newsgroup-active
3001 (gnus-active gnus-newsgroup-name)))
3002 ;; You can change the summary buffer in some way with this hook.
3003 (gnus-run-hooks 'gnus-select-group-hook)
3004 ;; Set any local variables in the group parameters.
3005 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3006 (gnus-update-format-specifications
3007 nil 'summary 'summary-mode 'summary-dummy)
3008 (gnus-update-summary-mark-positions)
3009 ;; Do score processing.
3010 (when gnus-use-scoring
3011 (gnus-possibly-score-headers))
3012 ;; Check whether to fill in the gaps in the threads.
3013 (when gnus-build-sparse-threads
3014 (gnus-build-sparse-threads))
3015 ;; Find the initial limit.
3016 (if gnus-show-threads
3018 (let ((gnus-newsgroup-dormant nil))
3019 (gnus-summary-initial-limit show-all))
3020 (gnus-summary-initial-limit show-all))
3021 ;; When untreaded, all articles are always shown.
3022 (setq gnus-newsgroup-limit
3024 (lambda (header) (mail-header-number header))
3025 gnus-newsgroup-headers)))
3026 ;; Generate the summary buffer.
3028 (gnus-summary-prepare))
3029 (when gnus-use-trees
3030 (gnus-tree-open group)
3031 (setq gnus-summary-highlight-line-function
3032 'gnus-tree-highlight-article))
3033 ;; If the summary buffer is empty, but there are some low-scored
3034 ;; articles or some excluded dormants, we include these in the
3036 (when (and (zerop (buffer-size))
3038 (cond (gnus-newsgroup-dormant
3039 (gnus-summary-limit-include-dormant))
3040 ((and gnus-newsgroup-scored show-all)
3041 (gnus-summary-limit-include-expunged t))))
3042 ;; Function `gnus-apply-kill-file' must be called in this hook.
3043 (gnus-run-hooks 'gnus-apply-kill-hook)
3044 (if (and (zerop (buffer-size))
3047 ;; This newsgroup is empty.
3048 (gnus-summary-catchup-and-exit nil t)
3049 (gnus-message 6 "No unread news")
3051 (gnus-kill-or-deaden-summary kill-buffer))
3052 ;; Return nil from this function.
3054 ;; Hide conversation thread subtrees. We cannot do this in
3055 ;; gnus-summary-prepare-hook since kill processing may not
3056 ;; work with hidden articles.
3057 (and gnus-show-threads
3058 gnus-thread-hide-subtree
3059 (gnus-summary-hide-all-threads))
3061 (gnus-kill-or-deaden-summary kill-buffer))
3062 ;; Show first unread article if requested.
3063 (if (and (not no-article)
3065 gnus-newsgroup-unreads
3066 gnus-auto-select-first)
3068 (gnus-configure-windows 'summary)
3070 ((eq gnus-auto-select-first 'best)
3071 (gnus-summary-best-unread-article))
3072 ((eq gnus-auto-select-first t)
3073 (gnus-summary-first-unread-article))
3074 ((gnus-functionp gnus-auto-select-first)
3075 (funcall gnus-auto-select-first))))
3076 ;; Don't select any articles, just move point to the first
3077 ;; article in the group.
3078 (goto-char (point-min))
3079 (gnus-summary-position-point)
3080 (gnus-configure-windows 'summary 'force)
3081 (gnus-set-mode-line 'summary))
3082 (when (get-buffer-window gnus-group-buffer t)
3083 ;; Gotta use windows, because recenter does weird stuff if
3084 ;; the current buffer ain't the displayed window.
3085 (let ((owin (selected-window)))
3086 (select-window (get-buffer-window gnus-group-buffer t))
3087 (when (gnus-group-goto-group group)
3089 (select-window owin)))
3090 ;; Mark this buffer as "prepared".
3091 (setq gnus-newsgroup-prepared t)
3092 (gnus-run-hooks 'gnus-summary-prepared-hook)
3095 (defun gnus-summary-prepare ()
3096 "Generate the summary buffer."
3098 (let ((buffer-read-only nil))
3100 (setq gnus-newsgroup-data nil
3101 gnus-newsgroup-data-reverse nil)
3102 (gnus-run-hooks 'gnus-summary-generate-hook)
3103 ;; Generate the buffer, either with threads or without.
3104 (when gnus-newsgroup-headers
3105 (gnus-summary-prepare-threads
3106 (if gnus-show-threads
3107 (gnus-sort-gathered-threads
3108 (funcall gnus-summary-thread-gathering-function
3110 (gnus-cut-threads (gnus-make-threads)))))
3111 ;; Unthreaded display.
3112 (gnus-sort-articles gnus-newsgroup-headers))))
3113 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3114 ;; Call hooks for modifying summary buffer.
3115 (goto-char (point-min))
3116 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3118 (defsubst gnus-general-simplify-subject (subject)
3119 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3122 ;; Truncate the subject.
3123 (gnus-simplify-subject-functions
3124 (gnus-map-function gnus-simplify-subject-functions subject))
3125 ((numberp gnus-summary-gather-subject-limit)
3126 (setq subject (gnus-simplify-subject-re subject))
3127 (if (> (length subject) gnus-summary-gather-subject-limit)
3128 (substring subject 0 gnus-summary-gather-subject-limit)
3130 ;; Fuzzily simplify it.
3131 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3132 (gnus-simplify-subject-fuzzy subject))
3133 ;; Just remove the leading "Re:".
3135 (gnus-simplify-subject-re subject))))
3137 (if (and gnus-summary-gather-exclude-subject
3138 (string-match gnus-summary-gather-exclude-subject subject))
3139 nil ; This article shouldn't be gathered
3142 (defun gnus-summary-simplify-subject-query ()
3143 "Query where the respool algorithm would put this article."
3145 (gnus-summary-select-article)
3146 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3148 (defun gnus-gather-threads-by-subject (threads)
3149 "Gather threads by looking at Subject headers."
3150 (if (not gnus-summary-make-false-root)
3152 (let ((hashtb (gnus-make-hashtable 1024))
3155 subject hthread whole-subject)
3157 (setq subject (gnus-general-simplify-subject
3158 (setq whole-subject (mail-header-subject
3161 (if (setq hthread (gnus-gethash subject hashtb))
3163 ;; We enter a dummy root into the thread, if we
3164 ;; haven't done that already.
3165 (unless (stringp (caar hthread))
3166 (setcar hthread (list whole-subject (car hthread))))
3167 ;; We add this new gathered thread to this gathered
3169 (setcdr (car hthread)
3170 (nconc (cdar hthread) (list (car threads))))
3171 ;; Remove it from the list of threads.
3172 (setcdr prev (cdr threads))
3173 (setq threads prev))
3174 ;; Enter this thread into the hash table.
3175 (gnus-sethash subject threads hashtb)))
3177 (setq threads (cdr threads)))
3180 (defun gnus-gather-threads-by-references (threads)
3181 "Gather threads by looking at References headers."
3182 (let ((idhashtb (gnus-make-hashtable 1024))
3183 (thhashtb (gnus-make-hashtable 1024))
3186 ids references id gthread gid entered ref)
3188 (when (setq references (mail-header-references (caar threads)))
3189 (setq id (mail-header-id (caar threads))
3190 ids (gnus-split-references references)
3192 (while (setq ref (pop ids))
3193 (setq ids (delete ref ids))
3194 (if (not (setq gid (gnus-gethash ref idhashtb)))
3196 (gnus-sethash ref id idhashtb)
3197 (gnus-sethash id threads thhashtb))
3198 (setq gthread (gnus-gethash gid thhashtb))
3200 ;; We enter a dummy root into the thread, if we
3201 ;; haven't done that already.
3202 (unless (stringp (caar gthread))
3203 (setcar gthread (list (mail-header-subject (caar gthread))
3205 ;; We add this new gathered thread to this gathered
3207 (setcdr (car gthread)
3208 (nconc (cdar gthread) (list (car threads)))))
3209 ;; Add it into the thread hash table.
3210 (gnus-sethash id gthread thhashtb)
3212 ;; Remove it from the list of threads.
3213 (setcdr prev (cdr threads))
3214 (setq threads prev))))
3216 (setq threads (cdr threads)))
3219 (defun gnus-sort-gathered-threads (threads)
3220 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3221 (let ((result threads))
3223 (when (stringp (caar threads))
3224 (setcdr (car threads)
3225 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3226 (setq threads (cdr threads)))
3229 (defun gnus-thread-loop-p (root thread)
3230 "Say whether ROOT is in THREAD."
3231 (let ((stack (list thread))
3234 (while (setq thread (pop stack))
3235 (setq th (cdr thread))
3237 (not (eq (caar th) root)))
3240 ;; We have found a loop.
3242 (setcdr thread (delq (car th) (cdr thread)))
3243 (if (boundp (setq ref-dep (intern "none"
3244 gnus-newsgroup-dependencies)))
3245 (setcdr (symbol-value ref-dep)
3246 (nconc (cdr (symbol-value ref-dep))
3248 (set ref-dep (list nil (car th))))
3251 ;; Push all the subthreads onto the stack.
3252 (push (cdr thread) stack)))
3255 (defun gnus-make-threads ()
3256 "Go through the dependency hashtb and find the roots. Return all threads."
3258 (while (catch 'infloop
3261 ;; Deal with self-referencing References loops.
3262 (when (and (car (symbol-value refs))
3269 (car (symbol-value refs)) thread))
3270 (cdr (symbol-value refs)))))))
3273 (unless (car (symbol-value refs))
3274 ;; These threads do not refer back to any other articles,
3275 ;; so they're roots.
3276 (setq threads (append (cdr (symbol-value refs)) threads))))
3277 gnus-newsgroup-dependencies)))
3280 ;; Build the thread tree.
3281 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3282 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3284 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3285 if it was already present.
3287 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3288 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3289 Message-IDs will be renamed be renamed to a unique Message-ID before
3292 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3293 (let* ((id (mail-header-id header))
3294 (id-dep (and id (intern id dependencies)))
3295 ref ref-dep ref-header)
3296 ;; Enter this `header' in the `dependencies' table.
3300 ;; The first two cases do the normal part: enter a new `header'
3301 ;; in the `dependencies' table.
3302 ((not (boundp id-dep))
3303 (set id-dep (list header)))
3304 ((null (car (symbol-value id-dep)))
3305 (setcar (symbol-value id-dep) header))
3307 ;; From here the `header' was already present in the
3308 ;; `dependencies' table.
3310 ;; Overrides an existing entry;
3311 ;; just set the header part of the entry.
3312 (setcar (symbol-value id-dep) header))
3314 ;; Renames the existing `header' to a unique Message-ID.
3315 ((not gnus-summary-ignore-duplicates)
3316 ;; An article with this Message-ID has already been seen.
3317 ;; We rename the Message-ID.
3318 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3320 (mail-header-set-id header id))
3322 ;; The last case ignores an existing entry, except it adds any
3323 ;; additional Xrefs (in case the two articles came from different
3325 ;; Also sets `header' to `nil' meaning that the `dependencies'
3326 ;; table was *not* modified.
3328 (mail-header-set-xref
3329 (car (symbol-value id-dep))
3330 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3332 (or (mail-header-xref header) "")))
3336 ;; First check if that we are not creating a References loop.
3337 (setq ref (gnus-parent-id (mail-header-references header)))
3339 (setq ref-dep (intern-soft ref dependencies))
3341 (setq ref-header (car (symbol-value ref-dep))))
3342 (if (string= id ref)
3343 ;; Yuk! This is a reference loop. Make the article be a
3346 (mail-header-set-references (car (symbol-value id-dep)) "none")
3348 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3349 (setq ref (gnus-parent-id (mail-header-references header)))
3350 (setq ref-dep (intern (or ref "none") dependencies))
3351 (if (boundp ref-dep)
3352 (setcdr (symbol-value ref-dep)
3353 (nconc (cdr (symbol-value ref-dep))
3354 (list (symbol-value id-dep))))
3355 (set ref-dep (list nil (symbol-value id-dep)))))
3358 (defun gnus-build-sparse-threads ()
3359 (let ((headers gnus-newsgroup-headers)
3360 (mail-parse-charset gnus-newsgroup-charset)
3361 (gnus-summary-ignore-duplicates t)
3362 header references generation relations
3363 subject child end new-child date)
3364 ;; First we create an alist of generations/relations, where
3365 ;; generations is how much we trust the relation, and the relation
3367 (gnus-message 7 "Making sparse threads...")
3369 (nnheader-set-temp-buffer " *gnus sparse threads*")
3370 (while (setq header (pop headers))
3371 (when (and (setq references (mail-header-references header))
3372 (not (string= references "")))
3374 (setq child (mail-header-id header)
3375 subject (mail-header-subject header)
3376 date (mail-header-date header)
3378 (while (search-backward ">" nil t)
3379 (setq end (1+ (point)))
3380 (when (search-backward "<" nil t)
3381 (setq new-child (buffer-substring (point) end))
3382 (push (list (incf generation)
3383 child (setq child new-child)
3387 (push (list (1+ generation) child nil subject) relations))
3389 (kill-buffer (current-buffer)))
3390 ;; Sort over trustworthiness.
3393 (when (gnus-dependencies-add-header
3394 (make-full-mail-header
3395 gnus-reffed-article-number
3396 (nth 3 relation) "" (or (nth 4 relation) "")
3398 (or (nth 2 relation) "") 0 0 "")
3399 gnus-newsgroup-dependencies nil)
3400 (push gnus-reffed-article-number gnus-newsgroup-limit)
3401 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3402 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3403 gnus-newsgroup-reads)
3404 (decf gnus-reffed-article-number)))
3405 (sort relations 'car-less-than-car))
3406 (gnus-message 7 "Making sparse threads...done")))
3408 (defun gnus-build-old-threads ()
3409 ;; Look at all the articles that refer back to old articles, and
3410 ;; fetch the headers for the articles that aren't there. This will
3411 ;; build complete threads - if the roots haven't been expired by the
3413 (let ((mail-parse-charset gnus-newsgroup-charset)
3417 (when (not (car (symbol-value refs)))
3418 (setq heads (cdr (symbol-value refs)))
3420 (if (memq (mail-header-number (caar heads))
3421 gnus-newsgroup-dormant)
3422 (setq heads (cdr heads))
3423 (setq id (symbol-name refs))
3424 (while (and (setq id (gnus-build-get-header id))
3425 (not (car (gnus-id-to-thread id)))))
3426 (setq heads nil)))))
3427 gnus-newsgroup-dependencies)))
3429 ;; This function has to be called with point after the article number
3430 ;; on the beginning of the line.
3431 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3432 (let ((eol (gnus-point-at-eol))
3433 (buffer (current-buffer))
3436 ;; overview: [num subject from date id refs chars lines misc]
3439 (narrow-to-region (point) eol)
3444 (make-full-mail-header
3446 (funcall gnus-decode-encoded-word-function
3447 (nnheader-nov-field)) ; subject
3448 (funcall gnus-decode-encoded-word-function
3449 (nnheader-nov-field)) ; from
3450 (nnheader-nov-field) ; date
3451 (nnheader-nov-read-message-id) ; id
3452 (nnheader-nov-field) ; refs
3453 (nnheader-nov-read-integer) ; chars
3454 (nnheader-nov-read-integer) ; lines
3456 (if (looking-at "Xref: ")
3457 (goto-char (match-end 0)))
3458 (nnheader-nov-field)) ; Xref
3459 (nnheader-nov-parse-extra)))) ; extra
3463 (when gnus-alter-header-function
3464 (funcall gnus-alter-header-function header))
3465 (gnus-dependencies-add-header header dependencies force-new)))
3467 (defun gnus-build-get-header (id)
3468 "Look through the buffer of NOV lines and find the header to ID.
3469 Enter this line into the dependencies hash table, and return
3470 the id of the parent article (if any)."
3471 (let ((deps gnus-newsgroup-dependencies)
3475 (set-buffer nntp-server-buffer)
3476 (let ((case-fold-search nil))
3477 (goto-char (point-min))
3478 (while (and (not found)
3479 (search-forward id nil t))
3481 (setq found (looking-at
3482 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3483 (regexp-quote id))))
3484 (or found (beginning-of-line 2)))
3488 (setq header (gnus-nov-parse-line
3489 (read (current-buffer)) deps))
3490 (gnus-parent-id (mail-header-references header))))))
3492 (let ((number (mail-header-number header)))
3493 (push number gnus-newsgroup-limit)
3494 (push header gnus-newsgroup-headers)
3495 (if (memq number gnus-newsgroup-unselected)
3497 (push number gnus-newsgroup-unreads)
3498 (setq gnus-newsgroup-unselected
3499 (delq number gnus-newsgroup-unselected)))
3500 (push number gnus-newsgroup-ancient)))))))
3502 (defun gnus-build-all-threads ()
3503 "Read all the headers."
3504 (let ((gnus-summary-ignore-duplicates t)
3505 (mail-parse-charset gnus-newsgroup-charset)
3506 (dependencies gnus-newsgroup-dependencies)
3509 (set-buffer nntp-server-buffer)
3510 (let ((case-fold-search nil))
3511 (goto-char (point-min))
3514 (setq article (read (current-buffer))
3515 header (gnus-nov-parse-line article dependencies)))
3518 (set-buffer gnus-summary-buffer)
3519 (push header gnus-newsgroup-headers)
3520 (if (memq (setq article (mail-header-number header))
3521 gnus-newsgroup-unselected)
3523 (push article gnus-newsgroup-unreads)
3524 (setq gnus-newsgroup-unselected
3525 (delq article gnus-newsgroup-unselected)))
3526 (push article gnus-newsgroup-ancient)))
3527 (forward-line 1)))))))
3529 (defun gnus-summary-update-article-line (article header)
3530 "Update the line for ARTICLE using HEADERS."
3531 (let* ((id (mail-header-id header))
3532 (thread (gnus-id-to-thread id)))
3534 (error "Article in no thread"))
3535 ;; Update the thread.
3536 (setcar thread header)
3537 (gnus-summary-goto-subject article)
3538 (let* ((datal (gnus-data-find-list article))
3540 (length (when (cdr datal)
3541 (- (gnus-data-pos data)
3542 (gnus-data-pos (cadr datal)))))
3543 (buffer-read-only nil)
3544 (level (gnus-summary-thread-level)))
3546 (gnus-summary-insert-line
3547 header level nil (gnus-article-mark article)
3548 (memq article gnus-newsgroup-replied)
3549 (memq article gnus-newsgroup-expirable)
3550 ;; Only insert the Subject string when it's different
3551 ;; from the previous Subject string.
3556 (mail-header-subject
3559 (gnus-data-find-list
3561 (gnus-data-list t)))))
3562 ;; Error on the side of excessive subjects.
3564 (mail-header-subject header)))
3566 (mail-header-subject header))
3567 nil (cdr (assq article gnus-newsgroup-scored))
3568 (memq article gnus-newsgroup-processable))
3570 (gnus-data-update-list
3571 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3573 (defun gnus-summary-update-article (article &optional iheader)
3574 "Update ARTICLE in the summary buffer."
3575 (set-buffer gnus-summary-buffer)
3576 (let* ((header (gnus-summary-article-header article))
3577 (id (mail-header-id header))
3578 (data (gnus-data-find article))
3579 (thread (gnus-id-to-thread id))
3580 (references (mail-header-references header))
3584 (when (and references
3585 (not (equal "" references)))
3588 (buffer-read-only nil)
3594 (delq thread parent)))
3595 (if (gnus-summary-insert-subject id header)
3596 ;; Set the (possibly) new article number in the data structure.
3597 (gnus-data-set-number data (gnus-id-to-article id))
3601 (defun gnus-rebuild-thread (id &optional line)
3602 "Rebuild the thread containing ID.
3603 If LINE, insert the rebuilt thread starting on line LINE."
3604 (let ((buffer-read-only nil)
3605 old-pos current thread data)
3606 (if (not gnus-show-threads)
3607 (setq thread (list (car (gnus-id-to-thread id))))
3608 ;; Get the thread this article is part of.
3609 (setq thread (gnus-remove-thread id)))
3610 (setq old-pos (gnus-point-at-bol))
3611 (setq current (save-excursion
3612 (and (zerop (forward-line -1))
3613 (gnus-summary-article-number))))
3614 ;; If this is a gathered thread, we have to go some re-gathering.
3615 (when (stringp (car thread))
3616 (let ((subject (car thread))
3618 (setq thread (cdr thread))
3620 (unless (memq (setq thr (gnus-id-to-thread
3622 (mail-header-id (caar thread)))))
3625 (setq thread (cdr thread)))
3626 ;; We now have all (unique) roots.
3627 (if (= (length roots) 1)
3628 ;; All the loose roots are now one solid root.
3629 (setq thread (car roots))
3630 (setq thread (cons subject (gnus-sort-threads roots))))))
3632 ;; We then insert this thread into the summary buffer.
3634 (goto-char (point-min))
3635 (forward-line (1- line)))
3636 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3637 (if gnus-show-threads
3638 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3639 (gnus-summary-prepare-unthreaded thread))
3640 (setq data (nreverse gnus-newsgroup-data))
3641 (setq threads gnus-newsgroup-threads))
3642 ;; We splice the new data into the data structure.
3643 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3644 ;;!!! then we want to insert at the beginning of the buffer.
3645 ;;!!! That happens to be true with Gnus now, but that may
3646 ;;!!! change in the future. Perhaps.
3647 (gnus-data-enter-list
3648 (if line nil current) data (- (point) old-pos))
3649 (setq gnus-newsgroup-threads
3650 (nconc threads gnus-newsgroup-threads))
3651 (gnus-data-compute-positions))))
3653 (defun gnus-number-to-header (number)
3654 "Return the header for article NUMBER."
3655 (let ((headers gnus-newsgroup-headers))
3657 (not (= number (mail-header-number (car headers)))))
3662 (defun gnus-parent-headers (in-headers &optional generation)
3663 "Return the headers of the GENERATIONeth parent of HEADERS."
3665 (setq generation 1))
3667 (headers in-headers)
3670 (not (zerop generation))
3671 (setq references (mail-header-references headers)))
3672 (setq headers (if (and references
3673 (setq parent (gnus-parent-id references)))
3674 (car (gnus-id-to-thread parent))
3677 (and (not (eq headers in-headers))
3680 (defun gnus-id-to-thread (id)
3681 "Return the (sub-)thread where ID appears."
3682 (gnus-gethash id gnus-newsgroup-dependencies))
3684 (defun gnus-id-to-article (id)
3685 "Return the article number of ID."
3686 (let ((thread (gnus-id-to-thread id)))
3689 (mail-header-number (car thread)))))
3691 (defun gnus-id-to-header (id)
3692 "Return the article headers of ID."
3693 (car (gnus-id-to-thread id)))
3695 (defun gnus-article-displayed-root-p (article)
3696 "Say whether ARTICLE is a root(ish) article."
3697 (let ((level (gnus-summary-thread-level article))
3698 (refs (mail-header-references (gnus-summary-article-header article)))
3704 ((null (gnus-parent-id refs)) t)
3706 (null (setq particle (gnus-id-to-article
3707 (gnus-parent-id refs))))
3708 (null (gnus-summary-thread-level particle)))))))
3710 (defun gnus-root-id (id)
3711 "Return the id of the root of the thread where ID appears."
3713 (while (and id (setq prev (car (gnus-id-to-thread id))))
3715 id (gnus-parent-id (mail-header-references prev))))
3718 (defun gnus-articles-in-thread (thread)
3719 "Return the list of articles in THREAD."
3720 (cons (mail-header-number (car thread))
3721 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3723 (defun gnus-remove-thread (id &optional dont-remove)
3724 "Remove the thread that has ID in it."
3725 (let (headers thread last-id)
3726 ;; First go up in this thread until we find the root.
3727 (setq last-id (gnus-root-id id)
3728 headers (message-flatten-list (gnus-id-to-thread last-id)))
3729 ;; We have now found the real root of this thread. It might have
3730 ;; been gathered into some loose thread, so we have to search
3731 ;; through the threads to find the thread we wanted.
3732 (let ((threads gnus-newsgroup-threads)
3735 (setq sub (car threads))
3736 (if (stringp (car sub))
3737 ;; This is a gathered thread, so we look at the roots
3738 ;; below it to find whether this article is in this
3741 (setq sub (cdr sub))
3743 (when (member (caar sub) headers)
3744 (setq thread (car threads)
3747 (setq sub (cdr sub))))
3748 ;; It's an ordinary thread, so we check it.
3749 (when (eq (car sub) (car headers))
3752 (setq threads (cdr threads)))
3753 ;; If this article is in no thread, then it's a root.
3756 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3757 (setq thread (gnus-id-to-thread last-id)))
3760 thread ; We return this thread.
3762 (if (stringp (car thread))
3764 ;; If we use dummy roots, then we have to remove the
3765 ;; dummy root as well.
3766 (when (eq gnus-summary-make-false-root 'dummy)
3767 ;; We go to the dummy root by going to
3768 ;; the first sub-"thread", and then one line up.
3769 (gnus-summary-goto-article
3770 (mail-header-number (caadr thread)))
3773 (gnus-data-compute-positions))
3774 (setq thread (cdr thread))
3776 (gnus-remove-thread-1 (car thread))
3777 (setq thread (cdr thread))))
3778 (gnus-remove-thread-1 thread))))))))
3780 (defun gnus-remove-thread-1 (thread)
3781 "Remove the thread THREAD recursively."
3782 (let ((number (mail-header-number (pop thread)))
3784 (setq thread (reverse thread))
3786 (gnus-remove-thread-1 (pop thread)))
3787 (when (setq d (gnus-data-find number))
3788 (goto-char (gnus-data-pos d))
3789 (gnus-summary-show-thread)
3792 (- (gnus-point-at-bol)
3794 (1+ (gnus-point-at-eol))
3795 (gnus-delete-line)))))))
3797 (defun gnus-sort-threads-1 (threads func)
3798 (sort (mapcar (lambda (thread)
3801 (gnus-sort-threads-1 (cdr thread) func))))
3804 (defun gnus-sort-threads (threads)
3806 (if (not gnus-thread-sort-functions)
3808 (gnus-message 8 "Sorting threads...")
3810 (gnus-sort-threads-1
3812 (gnus-make-sort-function gnus-thread-sort-functions))
3813 (gnus-message 8 "Sorting threads...done"))))
3815 (defun gnus-sort-articles (articles)
3817 (when gnus-article-sort-functions
3818 (gnus-message 7 "Sorting articles...")
3820 (setq gnus-newsgroup-headers
3821 (sort articles (gnus-make-sort-function
3822 gnus-article-sort-functions)))
3823 (gnus-message 7 "Sorting articles...done"))))
3825 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3826 (defmacro gnus-thread-header (thread)
3827 "Return header of first article in THREAD.
3828 Note that THREAD must never, ever be anything else than a variable -
3829 using some other form will lead to serious barfage."
3830 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3831 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3832 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3835 (defsubst gnus-article-sort-by-number (h1 h2)
3836 "Sort articles by article number."
3837 (< (mail-header-number h1)
3838 (mail-header-number h2)))
3840 (defun gnus-thread-sort-by-number (h1 h2)
3841 "Sort threads by root article number."
3842 (gnus-article-sort-by-number
3843 (gnus-thread-header h1) (gnus-thread-header h2)))
3845 (defsubst gnus-article-sort-by-lines (h1 h2)
3846 "Sort articles by article Lines header."
3847 (< (mail-header-lines h1)
3848 (mail-header-lines h2)))
3850 (defun gnus-thread-sort-by-lines (h1 h2)
3851 "Sort threads by root article Lines header."
3852 (gnus-article-sort-by-lines
3853 (gnus-thread-header h1) (gnus-thread-header h2)))
3855 (defsubst gnus-article-sort-by-chars (h1 h2)
3856 "Sort articles by octet length."
3857 (< (mail-header-chars h1)
3858 (mail-header-chars h2)))
3860 (defun gnus-thread-sort-by-chars (h1 h2)
3861 "Sort threads by root article octet length."
3862 (gnus-article-sort-by-chars
3863 (gnus-thread-header h1) (gnus-thread-header h2)))
3865 (defsubst gnus-article-sort-by-author (h1 h2)
3866 "Sort articles by root author."
3868 (let ((extract (funcall
3869 gnus-extract-address-components
3870 (mail-header-from h1))))
3871 (or (car extract) (cadr extract) ""))
3872 (let ((extract (funcall
3873 gnus-extract-address-components
3874 (mail-header-from h2))))
3875 (or (car extract) (cadr extract) ""))))
3877 (defun gnus-thread-sort-by-author (h1 h2)
3878 "Sort threads by root author."
3879 (gnus-article-sort-by-author
3880 (gnus-thread-header h1) (gnus-thread-header h2)))
3882 (defsubst gnus-article-sort-by-subject (h1 h2)
3883 "Sort articles by root subject."
3885 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3886 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3888 (defun gnus-thread-sort-by-subject (h1 h2)
3889 "Sort threads by root subject."
3890 (gnus-article-sort-by-subject
3891 (gnus-thread-header h1) (gnus-thread-header h2)))
3893 (defsubst gnus-article-sort-by-date (h1 h2)
3894 "Sort articles by root article date."
3896 (gnus-date-get-time (mail-header-date h1))
3897 (gnus-date-get-time (mail-header-date h2))))
3899 (defun gnus-thread-sort-by-date (h1 h2)
3900 "Sort threads by root article date."
3901 (gnus-article-sort-by-date
3902 (gnus-thread-header h1) (gnus-thread-header h2)))
3904 (defsubst gnus-article-sort-by-score (h1 h2)
3905 "Sort articles by root article score.
3906 Unscored articles will be counted as having a score of zero."
3907 (> (or (cdr (assq (mail-header-number h1)
3908 gnus-newsgroup-scored))
3909 gnus-summary-default-score 0)
3910 (or (cdr (assq (mail-header-number h2)
3911 gnus-newsgroup-scored))
3912 gnus-summary-default-score 0)))
3914 (defun gnus-thread-sort-by-score (h1 h2)
3915 "Sort threads by root article score."
3916 (gnus-article-sort-by-score
3917 (gnus-thread-header h1) (gnus-thread-header h2)))
3919 (defun gnus-thread-sort-by-total-score (h1 h2)
3920 "Sort threads by the sum of all scores in the thread.
3921 Unscored articles will be counted as having a score of zero."
3922 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3924 (defun gnus-thread-total-score (thread)
3925 ;; This function find the total score of THREAD.
3926 (cond ((null thread)
3929 (if (stringp (car thread))
3930 (apply gnus-thread-score-function 0
3931 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3932 (gnus-thread-total-score-1 thread)))
3934 (gnus-thread-total-score-1 (list thread)))))
3936 (defun gnus-thread-total-score-1 (root)
3937 ;; This function find the total score of the thread below ROOT.
3938 (setq root (car root))
3939 (apply gnus-thread-score-function
3941 (mapcar 'gnus-thread-total-score
3942 (cdr (gnus-id-to-thread (mail-header-id root))))
3943 (when (> (mail-header-number root) 0)
3944 (list (or (cdr (assq (mail-header-number root)
3945 gnus-newsgroup-scored))
3946 gnus-summary-default-score 0))))
3947 (list gnus-summary-default-score)
3950 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3951 (defvar gnus-tmp-prev-subject nil)
3952 (defvar gnus-tmp-false-parent nil)
3953 (defvar gnus-tmp-root-expunged nil)
3954 (defvar gnus-tmp-dummy-line nil)
3956 (eval-when-compile (defvar gnus-tmp-header))
3957 (defun gnus-extra-header (type &optional header)
3958 "Return the extra header of TYPE."
3959 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3962 (defun gnus-summary-prepare-threads (threads)
3963 "Prepare summary buffer from THREADS and indentation LEVEL.
3964 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3965 or a straight list of headers."
3966 (gnus-message 7 "Generating summary...")
3968 (setq gnus-newsgroup-threads threads)
3971 (let ((gnus-tmp-level 0)
3972 (default-score (or gnus-summary-default-score 0))
3973 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3974 thread number subject stack state gnus-tmp-gathered beg-match
3975 new-roots gnus-tmp-new-adopts thread-end
3976 gnus-tmp-header gnus-tmp-unread
3977 gnus-tmp-replied gnus-tmp-subject-or-nil
3978 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3979 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3980 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3982 (setq gnus-tmp-prev-subject nil)
3984 (if (vectorp (car threads))
3985 ;; If this is a straight (sic) list of headers, then a
3986 ;; threaded summary display isn't required, so we just create
3987 ;; an unthreaded one.
3988 (gnus-summary-prepare-unthreaded threads)
3990 ;; Do the threaded display.
3992 (while (or threads stack gnus-tmp-new-adopts new-roots)
3994 (if (and (= gnus-tmp-level 0)
3997 (not gnus-tmp-false-parent)
3998 (or gnus-tmp-new-adopts new-roots))
3999 (if gnus-tmp-new-adopts
4000 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4001 thread (list (car gnus-tmp-new-adopts))
4002 gnus-tmp-header (caar thread)
4003 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4005 (setq thread (list (car new-roots))
4006 gnus-tmp-header (caar thread)
4007 new-roots (cdr new-roots))))
4010 ;; If there are some threads, we do them before the
4011 ;; threads on the stack.
4012 (setq thread threads
4013 gnus-tmp-header (caar thread))
4014 ;; There were no current threads, so we pop something off
4016 (setq state (car stack)
4017 gnus-tmp-level (car state)
4020 gnus-tmp-header (caar thread))))
4022 (setq gnus-tmp-false-parent nil)
4023 (setq gnus-tmp-root-expunged nil)
4024 (setq thread-end nil)
4026 (if (stringp gnus-tmp-header)
4027 ;; The header is a dummy root.
4029 ((eq gnus-summary-make-false-root 'adopt)
4030 ;; We let the first article adopt the rest.
4031 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4033 (setq gnus-tmp-gathered
4035 (lambda (h) (mail-header-number (car h)))
4038 (setq thread (cons (list (caar thread)
4041 (setq gnus-tmp-level -1
4042 gnus-tmp-false-parent t))
4043 ((eq gnus-summary-make-false-root 'empty)
4044 ;; We print adopted articles with empty subject fields.
4045 (setq gnus-tmp-gathered
4047 (lambda (h) (mail-header-number (car h)))
4050 (setq gnus-tmp-level -1))
4051 ((eq gnus-summary-make-false-root 'dummy)
4052 ;; We remember that we probably want to output a dummy
4054 (setq gnus-tmp-dummy-line gnus-tmp-header)
4055 (setq gnus-tmp-prev-subject gnus-tmp-header))
4057 ;; We do not make a root for the gathered
4058 ;; sub-threads at all.
4059 (setq gnus-tmp-level -1)))
4061 (setq number (mail-header-number gnus-tmp-header)
4062 subject (mail-header-subject gnus-tmp-header))
4065 ;; If the thread has changed subject, we might want to make
4066 ;; this subthread into a root.
4067 ((and (null gnus-thread-ignore-subject)
4068 (not (zerop gnus-tmp-level))
4069 gnus-tmp-prev-subject
4071 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4072 (setq new-roots (nconc new-roots (list (car thread)))
4074 gnus-tmp-header nil))
4075 ;; If the article lies outside the current limit,
4076 ;; then we do not display it.
4077 ((not (memq number gnus-newsgroup-limit))
4078 (setq gnus-tmp-gathered
4080 (lambda (h) (mail-header-number (car h)))
4083 (setq gnus-tmp-new-adopts (if (cdar thread)
4084 (append gnus-tmp-new-adopts
4086 gnus-tmp-new-adopts)
4088 gnus-tmp-header nil)
4089 (when (zerop gnus-tmp-level)
4090 (setq gnus-tmp-root-expunged t)))
4091 ;; Perhaps this article is to be marked as read?
4092 ((and gnus-summary-mark-below
4093 (< (or (cdr (assq number gnus-newsgroup-scored))
4095 gnus-summary-mark-below)
4096 ;; Don't touch sparse articles.
4097 (not (gnus-summary-article-sparse-p number))
4098 (not (gnus-summary-article-ancient-p number)))
4099 (setq gnus-newsgroup-unreads
4100 (delq number gnus-newsgroup-unreads))
4101 (if gnus-newsgroup-auto-expire
4102 (push number gnus-newsgroup-expirable)
4103 (push (cons number gnus-low-score-mark)
4104 gnus-newsgroup-reads))))
4106 (when gnus-tmp-header
4107 ;; We may have an old dummy line to output before this
4109 (when (and gnus-tmp-dummy-line
4112 (mail-header-subject gnus-tmp-header)))
4113 (gnus-summary-insert-dummy-line
4114 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4115 (setq gnus-tmp-dummy-line nil))
4117 ;; Compute the mark.
4118 (setq gnus-tmp-unread (gnus-article-mark number))
4120 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4121 gnus-tmp-header gnus-tmp-level)
4122 gnus-newsgroup-data)
4124 ;; Actually insert the line.
4126 gnus-tmp-subject-or-nil
4128 ((and gnus-thread-ignore-subject
4129 gnus-tmp-prev-subject
4130 (not (inline (gnus-subject-equal
4131 gnus-tmp-prev-subject subject))))
4133 ((zerop gnus-tmp-level)
4134 (if (and (eq gnus-summary-make-false-root 'empty)
4135 (memq number gnus-tmp-gathered)
4136 gnus-tmp-prev-subject
4137 (inline (gnus-subject-equal
4138 gnus-tmp-prev-subject subject)))
4139 gnus-summary-same-subject
4141 (t gnus-summary-same-subject)))
4142 (if (and (eq gnus-summary-make-false-root 'adopt)
4143 (= gnus-tmp-level 1)
4144 (memq number gnus-tmp-gathered))
4145 (setq gnus-tmp-opening-bracket ?\<
4146 gnus-tmp-closing-bracket ?\>)
4147 (setq gnus-tmp-opening-bracket ?\[
4148 gnus-tmp-closing-bracket ?\]))
4150 gnus-tmp-indentation
4151 (aref gnus-thread-indent-array gnus-tmp-level)
4152 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4153 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4154 gnus-summary-default-score 0)
4156 (if (or (null gnus-summary-default-score)
4157 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4158 gnus-summary-zcore-fuzz))
4160 (if (< gnus-tmp-score gnus-summary-default-score)
4161 gnus-score-below-mark gnus-score-over-mark))
4163 (cond ((memq number gnus-newsgroup-processable)
4165 ((memq number gnus-newsgroup-cached)
4167 ((memq number gnus-newsgroup-replied)
4169 ((memq number gnus-newsgroup-saved)
4172 gnus-tmp-from (mail-header-from gnus-tmp-header)
4175 ((string-match "<[^>]+> *$" gnus-tmp-from)
4176 (setq beg-match (match-beginning 0))
4177 (or (and (string-match "^\".+\"" gnus-tmp-from)
4178 (substring gnus-tmp-from 1 (1- (match-end 0))))
4179 (substring gnus-tmp-from 0 beg-match)))
4180 ((string-match "(.+)" gnus-tmp-from)
4181 (substring gnus-tmp-from
4182 (1+ (match-beginning 0)) (1- (match-end 0))))
4184 (when (string= gnus-tmp-name "")
4185 (setq gnus-tmp-name gnus-tmp-from))
4186 (unless (numberp gnus-tmp-lines)
4187 (setq gnus-tmp-lines 0))
4188 (gnus-put-text-property
4190 (progn (eval gnus-summary-line-format-spec) (point))
4191 'gnus-number number)
4194 (gnus-run-hooks 'gnus-summary-update-hook)
4197 (setq gnus-tmp-prev-subject subject)))
4199 (when (nth 1 thread)
4200 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4201 (incf gnus-tmp-level)
4202 (setq threads (if thread-end nil (cdar thread)))
4204 (setq gnus-tmp-level 0)))))
4205 (gnus-message 7 "Generating summary...done"))
4207 (defun gnus-summary-prepare-unthreaded (headers)
4208 "Generate an unthreaded summary buffer based on HEADERS."
4209 (let (header number mark)
4214 ;; We may have to root out some bad articles...
4215 (when (memq (setq number (mail-header-number
4216 (setq header (pop headers))))
4217 gnus-newsgroup-limit)
4218 ;; Mark article as read when it has a low score.
4219 (when (and gnus-summary-mark-below
4220 (< (or (cdr (assq number gnus-newsgroup-scored))
4221 gnus-summary-default-score 0)
4222 gnus-summary-mark-below)
4223 (not (gnus-summary-article-ancient-p number)))
4224 (setq gnus-newsgroup-unreads
4225 (delq number gnus-newsgroup-unreads))
4226 (if gnus-newsgroup-auto-expire
4227 (push number gnus-newsgroup-expirable)
4228 (push (cons number gnus-low-score-mark)
4229 gnus-newsgroup-reads)))
4231 (setq mark (gnus-article-mark number))
4232 (push (gnus-data-make number mark (1+ (point)) header 0)
4233 gnus-newsgroup-data)
4234 (gnus-summary-insert-line
4236 mark (memq number gnus-newsgroup-replied)
4237 (memq number gnus-newsgroup-expirable)
4238 (mail-header-subject header) nil
4239 (cdr (assq number gnus-newsgroup-scored))
4240 (memq number gnus-newsgroup-processable))))))
4242 (defun gnus-summary-remove-list-identifiers ()
4243 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4244 (let ((regexp (if (stringp gnus-list-identifiers)
4245 gnus-list-identifiers
4246 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4247 (dolist (header gnus-newsgroup-headers)
4248 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4249 " *\\)\\)+\\(Re: +\\)?\\)")
4250 (mail-header-subject header))
4251 (mail-header-set-subject
4252 header (concat (substring (mail-header-subject header)
4253 0 (match-beginning 1))
4255 (match-string 3 (mail-header-subject header))
4256 (match-string 5 (mail-header-subject header)))
4257 (substring (mail-header-subject header)
4258 (match-end 1))))))))
4260 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4261 "Select newsgroup GROUP.
4262 If READ-ALL is non-nil, all articles in the group are selected.
4263 If SELECT-ARTICLES, only select those articles from GROUP."
4264 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4265 ;;!!! Dirty hack; should be removed.
4266 (gnus-summary-ignore-duplicates
4267 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4269 gnus-summary-ignore-duplicates))
4270 (info (nth 2 entry))
4271 articles fetched-articles cached)
4273 (unless (gnus-check-server
4274 (setq gnus-current-select-method
4275 (gnus-find-method-for-group group)))
4276 (error "Couldn't open server"))
4278 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4279 (gnus-activate-group group) ; Or we can activate it...
4280 (progn ; Or we bug out.
4281 (when (equal major-mode 'gnus-summary-mode)
4282 (kill-buffer (current-buffer)))
4283 (error "Couldn't activate group %s: %s"
4284 group (gnus-status-message group))))
4286 (unless (gnus-request-group group t)
4287 (when (equal major-mode 'gnus-summary-mode)
4288 (kill-buffer (current-buffer)))
4289 (error "Couldn't request group %s: %s"
4290 group (gnus-status-message group)))
4292 (setq gnus-newsgroup-name group)
4293 (setq gnus-newsgroup-unselected nil)
4294 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4295 (gnus-summary-setup-default-charset)
4297 ;; Adjust and set lists of article marks.
4299 (gnus-adjust-marked-articles info))
4301 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4302 (when (gnus-virtual-group-p group)
4303 (setq cached gnus-newsgroup-cached))
4305 (setq gnus-newsgroup-unreads
4306 (gnus-set-difference
4307 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4308 gnus-newsgroup-dormant))
4310 (setq gnus-newsgroup-processable nil)
4312 (gnus-update-read-articles group gnus-newsgroup-unreads)
4314 (if (setq articles select-articles)
4315 (setq gnus-newsgroup-unselected
4316 (gnus-sorted-intersection
4317 gnus-newsgroup-unreads
4318 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4319 (setq articles (gnus-articles-to-read group read-all)))
4323 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4325 ((eq articles 0) nil)
4327 ;; Init the dependencies hash table.
4328 (setq gnus-newsgroup-dependencies
4329 (gnus-make-hashtable (length articles)))
4330 (gnus-set-global-variables)
4331 ;; Retrieve the headers and read them in.
4332 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4333 (setq gnus-newsgroup-headers
4335 (setq gnus-headers-retrieved-by
4336 (gnus-retrieve-headers
4337 articles gnus-newsgroup-name
4338 ;; We might want to fetch old headers, but
4339 ;; not if there is only 1 article.
4341 (not (eq gnus-fetch-old-headers 'some))
4342 (not (numberp gnus-fetch-old-headers)))
4343 (> (length articles) 1))
4344 gnus-fetch-old-headers))))
4345 (gnus-get-newsgroup-headers-xover
4346 articles nil nil gnus-newsgroup-name t)
4347 (gnus-get-newsgroup-headers)))
4348 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4350 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4352 (setq gnus-newsgroup-cached cached))
4354 ;; Suppress duplicates?
4355 (when gnus-suppress-duplicates
4356 (gnus-dup-suppress-articles))
4358 ;; Set the initial limit.
4359 (setq gnus-newsgroup-limit (copy-sequence articles))
4360 ;; Remove canceled articles from the list of unread articles.
4361 (setq gnus-newsgroup-unreads
4362 (gnus-set-sorted-intersection
4363 gnus-newsgroup-unreads
4364 (setq fetched-articles
4365 (mapcar (lambda (headers) (mail-header-number headers))
4366 gnus-newsgroup-headers))))
4367 ;; Removed marked articles that do not exist.
4368 (gnus-update-missing-marks
4369 (gnus-sorted-complement fetched-articles articles))
4370 ;; We might want to build some more threads first.
4371 (when (and gnus-fetch-old-headers
4372 (eq gnus-headers-retrieved-by 'nov))
4373 (if (eq gnus-fetch-old-headers 'invisible)
4374 (gnus-build-all-threads)
4375 (gnus-build-old-threads)))
4376 ;; Let the Gnus agent mark articles as read.
4378 (gnus-agent-get-undownloaded-list))
4379 ;; Remove list identifiers from subject
4380 (when gnus-list-identifiers
4381 (gnus-summary-remove-list-identifiers))
4382 ;; Check whether auto-expire is to be done in this group.
4383 (setq gnus-newsgroup-auto-expire
4384 (gnus-group-auto-expirable-p group))
4385 ;; Set up the article buffer now, if necessary.
4386 (unless gnus-single-article-buffer
4387 (gnus-article-setup-buffer))
4388 ;; First and last article in this newsgroup.
4389 (when gnus-newsgroup-headers
4390 (setq gnus-newsgroup-begin
4391 (mail-header-number (car gnus-newsgroup-headers))
4394 (gnus-last-element gnus-newsgroup-headers))))
4395 ;; GROUP is successfully selected.
4396 (or gnus-newsgroup-headers t)))))
4398 (defun gnus-articles-to-read (group &optional read-all)
4399 "Find out what articles the user wants to read."
4401 ;; Select all articles if `read-all' is non-nil, or if there
4402 ;; are no unread articles.
4404 (and (zerop (length gnus-newsgroup-marked))
4405 (zerop (length gnus-newsgroup-unreads)))
4406 (eq (gnus-group-find-parameter group 'display)
4409 (gnus-uncompress-range (gnus-active group))
4410 (gnus-cache-articles-in-group group))
4411 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4412 (copy-sequence gnus-newsgroup-unreads))
4414 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4415 (scored (length scored-list))
4416 (number (length articles))
4417 (marked (+ (length gnus-newsgroup-marked)
4418 (length gnus-newsgroup-dormant)))
4426 ((and (or (<= scored marked) (= scored number))
4427 (numberp gnus-large-newsgroup)
4428 (> number gnus-large-newsgroup))
4432 "How many articles from %s (default %d): "
4433 (gnus-limit-string gnus-newsgroup-name 35)
4435 (if (string-match "^[ \t]*$" input) number input)))
4436 ((and (> scored marked) (< scored number)
4437 (> (- scored number) 20))
4440 (format "%s %s (%d scored, %d total): "
4441 "How many articles from"
4442 group scored number))))
4443 (if (string-match "^[ \t]*$" input)
4447 (message "Quit getting the articles to read")
4449 (setq select (if (stringp select) (string-to-number select) select))
4450 (if (or (null select) (zerop select))
4452 (if (and (not (zerop scored)) (<= (abs select) scored))
4454 (setq articles (sort scored-list '<))
4455 (setq number (length articles)))
4456 (setq articles (copy-sequence articles)))
4458 (when (< (abs select) number)
4460 ;; Select the N oldest articles.
4461 (setcdr (nthcdr (1- (abs select)) articles) nil)
4462 ;; Select the N most recent articles.
4463 (setq articles (nthcdr (- number select) articles))))
4464 (setq gnus-newsgroup-unselected
4465 (gnus-sorted-intersection
4466 gnus-newsgroup-unreads
4467 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4468 (when gnus-alter-articles-to-read-function
4469 (setq gnus-newsgroup-unreads
4471 (funcall gnus-alter-articles-to-read-function
4472 gnus-newsgroup-name gnus-newsgroup-unreads)
4476 (defun gnus-killed-articles (killed articles)
4479 (when (inline (gnus-member-of-range (car articles) killed))
4480 (push (car articles) out))
4481 (setq articles (cdr articles)))
4484 (defun gnus-uncompress-marks (marks)
4485 "Uncompress the mark ranges in MARKS."
4486 (let ((uncompressed '(score bookmark))
4489 (if (memq (caar marks) uncompressed)
4490 (push (car marks) out)
4491 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4492 (setq marks (cdr marks)))
4495 (defun gnus-adjust-marked-articles (info)
4496 "Set all article lists and remove all marks that are no longer valid."
4497 (let* ((marked-lists (gnus-info-marks info))
4498 (active (gnus-active (gnus-info-group info)))
4501 (types gnus-article-mark-lists)
4502 (uncompressed '(score bookmark killed))
4503 marks var articles article mark)
4506 (setq marks (pop marked-lists))
4507 (set (setq var (intern (format "gnus-newsgroup-%s"
4508 (car (rassq (setq mark (car marks))
4510 (if (memq (car marks) uncompressed) (cdr marks)
4511 (gnus-uncompress-range (cdr marks))))
4513 (setq articles (symbol-value var))
4515 ;; All articles have to be subsets of the active articles.
4517 ;; Adjust "simple" lists.
4518 ((memq mark '(tick dormant expire reply save))
4520 (when (or (< (setq article (pop articles)) min) (> article max))
4521 (set var (delq article (symbol-value var))))))
4523 ((memq mark uncompressed)
4524 (when (not (listp (cdr (symbol-value var))))
4525 (set var (list (symbol-value var))))
4526 (when (not (listp (cdr articles)))
4527 (setq articles (list articles)))
4529 (when (or (not (consp (setq article (pop articles))))
4530 (< (car article) min)
4531 (> (car article) max))
4532 (set var (delq article (symbol-value var))))))))))
4534 (defun gnus-update-missing-marks (missing)
4535 "Go through the list of MISSING articles and remove them from the mark lists."
4537 (let ((types gnus-article-mark-lists)
4539 ;; Go through all types.
4541 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4542 (when (symbol-value var)
4543 ;; This list has articles. So we delete all missing articles
4547 (set var (delq (pop m) (symbol-value var)))))))))
4549 (defun gnus-update-marks ()
4550 "Enter the various lists of marked articles into the newsgroup info list."
4551 (let ((types gnus-article-mark-lists)
4552 (info (gnus-get-info gnus-newsgroup-name))
4553 (uncompressed '(score bookmark killed))
4554 type list newmarked symbol delta-marks)
4556 ;; Add all marks lists to the list of marks lists.
4557 (while (setq type (pop types))
4558 (setq list (symbol-value
4560 (intern (format "gnus-newsgroup-%s"
4564 ;; Get rid of the entries of the articles that have the
4566 (when (and (eq (cdr type) 'score)
4570 (prev (cons nil list))
4573 (if (or (not (consp (car arts)))
4574 (= (cdar arts) gnus-summary-default-score))
4575 (setcdr prev (cdr arts))
4577 (setq arts (cdr arts)))
4578 (setq list (cdr all)))))
4580 (unless (memq (cdr type) uncompressed)
4581 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4583 (when (gnus-check-backend-function
4584 'request-set-mark gnus-newsgroup-name)
4585 ;; propagate flags to server, with the following exceptions:
4586 ;; uncompressed:s are not proper flags (they are cons cells)
4587 ;; cache is a internal gnus flag
4588 ;; download are local to one gnus installation (well)
4589 ;; unsend are for nndraft groups only
4590 ;; xxx: generality of this? this suits nnimap anyway
4591 (unless (memq (cdr type) (append '(cache download unsend)
4593 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4594 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4595 (add (gnus-remove-from-range
4596 (gnus-copy-sequence list) old)))
4598 (push (list add 'add (list (cdr type))) delta-marks))
4600 (push (list del 'del (list (cdr type))) delta-marks)))))
4603 (push (cons (cdr type) list) newmarked)))
4606 (unless (gnus-check-group gnus-newsgroup-name)
4607 (error "Can't open server for %s" gnus-newsgroup-name))
4608 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4610 ;; Enter these new marks into the info of the group.
4612 (setcar (nthcdr 3 info) newmarked)
4613 ;; Add the marks lists to the end of the info.
4615 (setcdr (nthcdr 2 info) (list newmarked))))
4617 ;; Cut off the end of the info if there's nothing else there.
4621 (when (nthcdr (decf i) info)
4622 (setcdr (nthcdr i info) nil)))))))
4624 (defun gnus-set-mode-line (where)
4625 "Set the mode line of the article or summary buffers.
4626 If WHERE is `summary', the summary mode line format will be used."
4627 ;; Is this mode line one we keep updated?
4628 (when (and (memq where gnus-updated-mode-lines)
4630 (intern (format "gnus-%s-mode-line-format-spec" where))))
4633 ;; We evaluate this in the summary buffer since these
4634 ;; variables are buffer-local to that buffer.
4635 (set-buffer gnus-summary-buffer)
4636 ;; We bind all these variables that are used in the `eval' form
4638 (let* ((mformat (symbol-value
4640 (format "gnus-%s-mode-line-format-spec" where))))
4641 (gnus-tmp-group-name (gnus-group-name-decode
4643 (gnus-group-name-charset
4645 gnus-newsgroup-name)))
4646 (gnus-tmp-article-number (or gnus-current-article 0))
4647 (gnus-tmp-unread gnus-newsgroup-unreads)
4648 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4649 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4650 (gnus-tmp-unread-and-unselected
4651 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4652 (zerop gnus-tmp-unselected))
4654 ((zerop gnus-tmp-unselected)
4655 (format "{%d more}" gnus-tmp-unread-and-unticked))
4656 (t (format "{%d(+%d) more}"
4657 gnus-tmp-unread-and-unticked
4658 gnus-tmp-unselected))))
4660 (if (and gnus-current-headers
4661 (vectorp gnus-current-headers))
4662 (gnus-mode-string-quote
4663 (mail-header-subject gnus-current-headers))
4665 bufname-length max-len
4666 gnus-tmp-header);; passed as argument to any user-format-funcs
4667 (setq mode-string (eval mformat))
4668 (setq bufname-length (if (string-match "%b" mode-string)
4671 (if (eq where 'summary)
4673 (get-buffer gnus-article-buffer))))
4676 (setq max-len (max 4 (if gnus-mode-non-string-length
4678 gnus-mode-non-string-length
4680 (length mode-string))))
4681 ;; We might have to chop a bit of the string off...
4682 (when (> (length mode-string) max-len)
4684 (concat (truncate-string-to-width mode-string (- max-len 3))
4686 ;; Pad the mode string a bit.
4687 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4688 ;; Update the mode line.
4689 (setq mode-line-buffer-identification
4690 (gnus-mode-line-buffer-identification (list mode-string)))
4691 (set-buffer-modified-p t))))
4693 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4694 "Go through the HEADERS list and add all Xrefs to a hash table.
4695 The resulting hash table is returned, or nil if no Xrefs were found."
4696 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4697 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4698 (xref-hashtb (gnus-make-hashtable))
4699 start group entry number xrefs header)
4701 (setq header (pop headers))
4702 (when (and (setq xrefs (mail-header-xref header))
4703 (not (memq (setq number (mail-header-number header))
4706 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4707 (setq start (match-end 0))
4708 (setq group (if prefix
4709 (concat prefix (substring xrefs (match-beginning 1)
4711 (substring xrefs (match-beginning 1) (match-end 1))))
4713 (string-to-int (substring xrefs (match-beginning 2)
4715 (if (setq entry (gnus-gethash group xref-hashtb))
4716 (setcdr entry (cons number (cdr entry)))
4717 (gnus-sethash group (cons number nil) xref-hashtb)))))
4718 (and start xref-hashtb)))
4720 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4721 "Look through all the headers and mark the Xrefs as read."
4722 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4723 name entry info xref-hashtb idlist method nth4)
4725 (set-buffer gnus-group-buffer)
4726 (when (setq xref-hashtb
4727 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4730 (unless (string= from-newsgroup (setq name (symbol-name group)))
4731 (setq idlist (symbol-value group))
4732 ;; Dead groups are not updated.
4734 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4736 (when (stringp (setq nth4 (gnus-info-method info)))
4737 (setq nth4 (gnus-server-to-method nth4))))
4738 ;; Only do the xrefs if the group has the same
4739 ;; select method as the group we have just read.
4740 (or (gnus-methods-equal-p
4741 nth4 (gnus-find-method-for-group from-newsgroup))
4743 (equal nth4 (setq method (gnus-find-method-for-group
4745 (and (equal (car nth4) (car method))
4746 (equal (nth 1 nth4) (nth 1 method))))
4747 gnus-use-cross-reference
4748 (or (not (eq gnus-use-cross-reference t))
4750 ;; Only do cross-references on subscribed
4751 ;; groups, if that is what is wanted.
4752 (<= (gnus-info-level info) gnus-level-subscribed))
4753 (gnus-group-make-articles-read name idlist))))
4756 (defun gnus-compute-read-articles (group articles)
4757 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4758 (info (nth 2 entry))
4759 (active (gnus-active group))
4762 ;; First peel off all invalid article numbers.
4764 (let ((ids articles)
4766 (while (setq id (pop ids))
4767 (when (and first (> id (cdr active)))
4768 ;; We'll end up in this situation in one particular
4769 ;; obscure situation. If you re-scan a group and get
4770 ;; a new article that is cross-posted to a different
4771 ;; group that has not been re-scanned, you might get
4772 ;; crossposted article that has a higher number than
4773 ;; Gnus believes possible. So we re-activate this
4774 ;; group as well. This might mean doing the
4775 ;; crossposting thingy will *increase* the number
4776 ;; of articles in some groups. Tsk, tsk.
4777 (setq active (or (gnus-activate-group group) active)))
4778 (when (or (> id (cdr active))
4779 (< id (car active)))
4780 (setq articles (delq id articles))))))
4781 ;; If the read list is nil, we init it.
4783 (null (gnus-info-read info))
4785 (setq ninfo (cons 1 (1- (car active))))
4786 (setq ninfo (gnus-info-read info)))
4787 ;; Then we add the read articles to the range.
4789 ninfo (setq articles (sort articles '<))))))
4791 (defun gnus-group-make-articles-read (group articles)
4792 "Update the info of GROUP to say that ARTICLES are read."
4794 (entry (gnus-gethash group gnus-newsrc-hashtb))
4795 (info (nth 2 entry))
4796 (active (gnus-active group))
4799 (setq range (gnus-compute-read-articles group articles))
4801 (set-buffer gnus-group-buffer)
4804 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4805 (gnus-info-set-read ',info ',(gnus-info-read info))
4806 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4807 (gnus-group-update-group ,group t))))
4808 ;; Add the read articles to the range.
4809 (gnus-info-set-read info range)
4810 ;; Then we have to re-compute how many unread
4811 ;; articles there are in this group.
4815 (setq num (- (1+ (cdr active)) (car active))))
4816 ((not (listp (cdr range)))
4817 (setq num (- (cdr active) (- (1+ (cdr range))
4821 (if (numberp (car range))
4823 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4824 (setq range (cdr range)))
4825 (setq num (- (cdr active) num))))
4826 ;; Update the number of unread articles.
4828 ;; Update the group buffer.
4829 (gnus-group-update-group group t)))))
4831 (defvar gnus-newsgroup-none-id 0)
4833 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4834 (let ((cur nntp-server-buffer)
4837 (save-excursion (set-buffer gnus-summary-buffer)
4838 gnus-newsgroup-dependencies)))
4840 (mail-parse-charset gnus-newsgroup-charset)
4841 (mail-parse-ignored-charsets
4842 (save-excursion (condition-case nil
4843 (set-buffer gnus-summary-buffer)
4845 gnus-newsgroup-ignored-charsets)))
4847 (set-buffer nntp-server-buffer)
4848 ;; Translate all TAB characters into SPACE characters.
4849 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4850 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4851 (gnus-run-hooks 'gnus-parse-headers-hook)
4852 (let ((case-fold-search t)
4853 in-reply-to header p lines chars)
4854 (goto-char (point-min))
4855 ;; Search to the beginning of the next header. Error messages
4856 ;; do not begin with 2 or 3.
4857 (while (re-search-forward "^[23][0-9]+ " nil t)
4860 ;; This implementation of this function, with nine
4861 ;; search-forwards instead of the one re-search-forward and
4862 ;; a case (which basically was the old function) is actually
4863 ;; about twice as fast, even though it looks messier. You
4864 ;; can't have everything, I guess. Speed and elegance
4865 ;; doesn't always go hand in hand.
4874 (narrow-to-region (point)
4875 (or (and (search-forward "\n.\n" nil t)
4881 (if (search-forward "\nsubject: " nil t)
4882 (funcall gnus-decode-encoded-word-function
4883 (nnheader-header-value))
4888 (if (or (search-forward "\nfrom: " nil t)
4889 (search-forward "\nfrom:" nil t))
4890 (funcall gnus-decode-encoded-word-function
4891 (nnheader-header-value))
4896 (if (search-forward "\ndate: " nil t)
4897 (nnheader-header-value) ""))
4901 (setq id (if (re-search-forward
4902 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4903 ;; We do it this way to make sure the Message-ID
4904 ;; is (somewhat) syntactically valid.
4905 (buffer-substring (match-beginning 1)
4907 ;; If there was no message-id, we just fake one
4908 ;; to make subsequent routines simpler.
4909 (nnheader-generate-fake-message-id))))
4913 (if (search-forward "\nreferences: " nil t)
4917 (nnheader-header-value)
4922 (search-backward ">" end t)
4925 (search-backward "<" end t)
4927 ;; Get the references from the in-reply-to header if there
4928 ;; were no references and the in-reply-to header looks
4930 (if (and (search-forward "\nin-reply-to: " nil t)
4931 (setq in-reply-to (nnheader-header-value))
4932 (string-match "<[^>]+>" in-reply-to))
4934 (setq ref (substring in-reply-to (match-beginning 0)
4936 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4937 (setq ref2 (substring in-reply-to (match-beginning 0)
4939 (when (> (length ref2) (length ref))
4946 (if (search-forward "\nchars: " nil t)
4947 (if (numberp (setq chars (ignore-errors (read cur))))
4953 (if (search-forward "\nlines: " nil t)
4954 (if (numberp (setq lines (ignore-errors (read cur))))
4960 (and (search-forward "\nxref: " nil t)
4961 (nnheader-header-value)))
4963 (when gnus-extra-headers
4964 (let ((extra gnus-extra-headers)
4968 (when (search-forward
4969 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4970 (push (cons (car extra) (nnheader-header-value))
4974 (when (equal id ref)
4977 (when gnus-alter-header-function
4978 (funcall gnus-alter-header-function header)
4979 (setq id (mail-header-id header)
4980 ref (gnus-parent-id (mail-header-references header))))
4983 (gnus-dependencies-add-header
4984 header dependencies force-new))
4985 (push header headers))
4986 (goto-char (point-max))
4988 (nreverse headers)))))
4990 ;; Goes through the xover lines and returns a list of vectors
4991 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4992 force-new dependencies
4993 group also-fetch-heads)
4994 "Parse the news overview data in the server buffer.
4995 Return a list of headers that match SEQUENCE (see
4996 `nntp-retrieve-headers')."
4997 ;; Get the Xref when the users reads the articles since most/some
4998 ;; NNTP servers do not include Xrefs when using XOVER.
4999 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5000 (let ((mail-parse-charset gnus-newsgroup-charset)
5001 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5002 (cur nntp-server-buffer)
5003 (dependencies (or dependencies gnus-newsgroup-dependencies))
5004 number headers header)
5006 (set-buffer nntp-server-buffer)
5007 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5008 ;; Allow the user to mangle the headers before parsing them.
5009 (gnus-run-hooks 'gnus-parse-headers-hook)
5010 (goto-char (point-min))
5013 (while (and sequence (not (eobp)))
5014 (setq number (read cur))
5015 (while (and sequence
5016 (< (car sequence) number))
5017 (setq sequence (cdr sequence)))
5019 (eq number (car sequence))
5021 (setq sequence (cdr sequence))
5022 (setq header (inline
5023 (gnus-nov-parse-line
5024 number dependencies force-new))))
5025 (push header headers))
5028 (gnus-error 4 "Strange nov line (%d)"
5029 (count-lines (point-min) (point)))))
5031 ;; A common bug in inn is that if you have posted an article and
5032 ;; then retrieves the active file, it will answer correctly --
5033 ;; the new article is included. However, a NOV entry for the
5034 ;; article may not have been generated yet, so this may fail.
5035 ;; We work around this problem by retrieving the last few
5036 ;; headers using HEAD.
5037 (if (or (not also-fetch-heads)
5039 ;; We (probably) got all the headers.
5041 (let ((gnus-nov-is-evil t))
5044 (when (gnus-retrieve-headers sequence group)
5045 (gnus-get-newsgroup-headers))))))))
5047 (defun gnus-article-get-xrefs ()
5048 "Fill in the Xref value in `gnus-current-headers', if necessary.
5049 This is meant to be called in `gnus-article-internal-prepare-hook'."
5050 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5051 gnus-current-headers)))
5052 (or (not gnus-use-cross-reference)
5054 (and (mail-header-xref headers)
5055 (not (string= (mail-header-xref headers) "")))
5056 (let ((case-fold-search t)
5059 (nnheader-narrow-to-headers)
5060 (goto-char (point-min))
5061 (when (or (and (not (eobp))
5062 (eq (downcase (char-after)) ?x)
5063 (looking-at "Xref:"))
5064 (search-forward "\nXref:" nil t))
5065 (goto-char (1+ (match-end 0)))
5066 (setq xref (buffer-substring (point)
5067 (progn (end-of-line) (point))))
5068 (mail-header-set-xref headers xref)))))))
5070 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5071 "Find article ID and insert the summary line for that article.
5072 OLD-HEADER can either be a header or a line number to insert
5073 the subject line on."
5074 (let* ((line (and (numberp old-header) old-header))
5075 (old-header (and (vectorp old-header) old-header))
5076 (header (cond ((and old-header use-old-header)
5079 (gnus-number-to-header id))
5080 (gnus-number-to-header id))
5082 (gnus-read-header id))))
5083 (number (and (numberp id) id))
5086 ;; Rebuild the thread that this article is part of and go to the
5087 ;; article we have fetched.
5088 (when (and (not gnus-show-threads)
5091 (setq d (gnus-data-find (mail-header-number old-header))))
5092 (goto-char (gnus-data-pos d))
5095 (- (gnus-point-at-bol)
5097 (1+ (gnus-point-at-eol))
5098 (gnus-delete-line))))))
5100 (mail-header-set-number header (mail-header-number old-header)))
5101 (setq gnus-newsgroup-sparse
5102 (delq (setq number (mail-header-number header))
5103 gnus-newsgroup-sparse))
5104 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5105 (push number gnus-newsgroup-limit)
5106 (gnus-rebuild-thread (mail-header-id header) line)
5107 (gnus-summary-goto-subject number nil t))
5108 (when (and (numberp number)
5110 ;; We have to update the boundaries even if we can't fetch the
5111 ;; article if ID is a number -- so that the next `P' or `N'
5112 ;; command will fetch the previous (or next) article even
5113 ;; if the one we tried to fetch this time has been canceled.
5114 (when (> number gnus-newsgroup-end)
5115 (setq gnus-newsgroup-end number))
5116 (when (< number gnus-newsgroup-begin)
5117 (setq gnus-newsgroup-begin number))
5118 (setq gnus-newsgroup-unselected
5119 (delq number gnus-newsgroup-unselected)))
5120 ;; Report back a success?
5121 (and header (mail-header-number header))))
5123 ;;; Process/prefix in the summary buffer
5125 (defun gnus-summary-work-articles (n)
5126 "Return a list of articles to be worked upon.
5127 The prefix argument, the list of process marked articles, and the
5128 current article will be taken into consideration."
5130 (set-buffer gnus-summary-buffer)
5133 ;; A numerical prefix has been given.
5134 (setq n (prefix-numeric-value n))
5135 (let ((backward (< n 0))
5136 (n (abs (prefix-numeric-value n)))
5141 (push (setq article (gnus-summary-article-number))
5144 (gnus-summary-find-prev nil article)
5145 (gnus-summary-find-next nil article)))
5147 (nreverse articles)))
5148 ((and (gnus-region-active-p) (mark))
5149 (message "region active")
5150 ;; Work on the region between point and mark.
5151 (let ((max (max (point) (mark)))
5154 (goto-char (min (min (point) (mark))))
5157 (push (setq article (gnus-summary-article-number)) articles)
5158 (gnus-summary-find-next nil article)
5160 (nreverse articles))))
5161 (gnus-newsgroup-processable
5162 ;; There are process-marked articles present.
5163 ;; Save current state.
5164 (gnus-summary-save-process-mark)
5166 (reverse gnus-newsgroup-processable))
5168 ;; Just return the current article.
5169 (list (gnus-summary-article-number))))))
5171 (defmacro gnus-summary-iterate (arg &rest forms)
5172 "Iterate over the process/prefixed articles and do FORMS.
5173 ARG is the interactive prefix given to the command. FORMS will be
5174 executed with point over the summary line of the articles."
5175 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5176 `(let ((,articles (gnus-summary-work-articles ,arg)))
5178 (gnus-summary-goto-subject (car ,articles))
5182 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5183 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5185 (defun gnus-summary-save-process-mark ()
5186 "Push the current set of process marked articles on the stack."
5188 (push (copy-sequence gnus-newsgroup-processable)
5189 gnus-newsgroup-process-stack))
5191 (defun gnus-summary-kill-process-mark ()
5192 "Push the current set of process marked articles on the stack and unmark."
5194 (gnus-summary-save-process-mark)
5195 (gnus-summary-unmark-all-processable))
5197 (defun gnus-summary-yank-process-mark ()
5198 "Pop the last process mark state off the stack and restore it."
5200 (unless gnus-newsgroup-process-stack
5201 (error "Empty mark stack"))
5202 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5204 (defun gnus-summary-process-mark-set (set)
5205 "Make SET into the current process marked articles."
5206 (gnus-summary-unmark-all-processable)
5208 (gnus-summary-set-process-mark (pop set))))
5210 ;;; Searching and stuff
5212 (defun gnus-summary-search-group (&optional backward use-level)
5213 "Search for next unread newsgroup.
5214 If optional argument BACKWARD is non-nil, search backward instead."
5216 (set-buffer gnus-group-buffer)
5217 (when (gnus-group-search-forward
5218 backward nil (if use-level (gnus-group-group-level) nil))
5219 (gnus-group-group-name))))
5221 (defun gnus-summary-best-group (&optional exclude-group)
5222 "Find the name of the best unread group.
5223 If EXCLUDE-GROUP, do not go to this group."
5225 (set-buffer gnus-group-buffer)
5227 (gnus-group-best-unread-group exclude-group))))
5229 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5230 (if backward (gnus-summary-find-prev)
5231 (let* ((dummy (gnus-summary-article-intangible-p))
5232 (article (or article (gnus-summary-article-number)))
5233 (arts (gnus-data-find-list article))
5235 (when (and (not dummy)
5236 (or (not gnus-summary-check-current)
5238 (not (gnus-data-unread-p (car arts)))))
5239 (setq arts (cdr arts)))
5244 (when (or (and undownloaded
5245 (eq gnus-undownloaded-mark
5246 (gnus-data-mark (car arts))))
5247 (gnus-data-unread-p (car arts)))
5248 (setq result (car arts)
5250 (setq arts (cdr arts)))
5253 (goto-char (gnus-data-pos result))
5254 (gnus-data-number result)))))
5256 (defun gnus-summary-find-prev (&optional unread article)
5257 (let* ((eobp (eobp))
5258 (article (or article (gnus-summary-article-number)))
5259 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5261 (when (and (not eobp)
5262 (or (not gnus-summary-check-current)
5264 (not (gnus-data-unread-p (car arts)))))
5265 (setq arts (cdr arts)))
5270 (when (gnus-data-unread-p (car arts))
5271 (setq result (car arts)
5273 (setq arts (cdr arts)))
5276 (goto-char (gnus-data-pos result))
5277 (gnus-data-number result))))
5279 (defun gnus-summary-find-subject (subject &optional unread backward article)
5280 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5281 (article (or article (gnus-summary-article-number)))
5282 (articles (gnus-data-list backward))
5283 (arts (gnus-data-find-list article articles))
5285 (when (or (not gnus-summary-check-current)
5287 (not (gnus-data-unread-p (car arts))))
5288 (setq arts (cdr arts)))
5290 (and (or (not unread)
5291 (gnus-data-unread-p (car arts)))
5292 (vectorp (gnus-data-header (car arts)))
5294 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5295 (setq result (car arts)
5297 (setq arts (cdr arts)))
5299 (goto-char (gnus-data-pos result))
5300 (gnus-data-number result))))
5302 (defun gnus-summary-search-forward (&optional unread subject backward)
5303 "Search forward for an article.
5304 If UNREAD, look for unread articles. If SUBJECT, look for
5305 articles with that subject. If BACKWARD, search backward instead."
5306 (cond (subject (gnus-summary-find-subject subject unread backward))
5307 (backward (gnus-summary-find-prev unread))
5308 (t (gnus-summary-find-next unread))))
5310 (defun gnus-recenter (&optional n)
5311 "Center point in window and redisplay frame.
5312 Also do horizontal recentering."
5314 (when (and gnus-auto-center-summary
5315 (not (eq gnus-auto-center-summary 'vertical)))
5316 (gnus-horizontal-recenter))
5319 (defun gnus-summary-recenter ()
5320 "Center point in the summary window.
5321 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5322 displayed, no centering will be performed."
5323 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5324 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5326 (let* ((top (cond ((< (window-height) 4) 0)
5327 ((< (window-height) 7) 1)
5328 (t (if (numberp gnus-auto-center-summary)
5329 gnus-auto-center-summary
5331 (height (1- (window-height)))
5332 (bottom (save-excursion (goto-char (point-max))
5333 (forward-line (- height))
5335 (window (get-buffer-window (current-buffer))))
5336 ;; The user has to want it.
5337 (when gnus-auto-center-summary
5338 (when (get-buffer-window gnus-article-buffer)
5339 ;; Only do recentering when the article buffer is displayed,
5340 ;; Set the window start to either `bottom', which is the biggest
5341 ;; possible valid number, or the second line from the top,
5342 ;; whichever is the least.
5343 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5344 (if (> bottom top-pos)
5345 ;; Keep the second line from the top visible
5346 (set-window-start window top-pos t)
5347 ;; Try to keep the bottom line visible; if it's partially
5348 ;; obscured, either scroll one more line to make it fully
5349 ;; visible, or revert to using TOP-POS.
5351 (goto-char (point-max))
5353 (let ((last-line-start (point)))
5355 (set-window-start window (point) t)
5356 (when (not (pos-visible-in-window-p last-line-start window))
5358 (set-window-start window (min (point) top-pos) t)))))))
5359 ;; Do horizontal recentering while we're at it.
5360 (when (and (get-buffer-window (current-buffer) t)
5361 (not (eq gnus-auto-center-summary 'vertical)))
5362 (let ((selected (selected-window)))
5363 (select-window (get-buffer-window (current-buffer) t))
5364 (gnus-summary-position-point)
5365 (gnus-horizontal-recenter)
5366 (select-window selected))))))
5368 (defun gnus-summary-jump-to-group (newsgroup)
5369 "Move point to NEWSGROUP in group mode buffer."
5370 ;; Keep update point of group mode buffer if visible.
5371 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5372 (save-window-excursion
5373 ;; Take care of tree window mode.
5374 (when (get-buffer-window gnus-group-buffer)
5375 (pop-to-buffer gnus-group-buffer))
5376 (gnus-group-jump-to-group newsgroup))
5378 ;; Take care of tree window mode.
5379 (if (get-buffer-window gnus-group-buffer)
5380 (pop-to-buffer gnus-group-buffer)
5381 (set-buffer gnus-group-buffer))
5382 (gnus-group-jump-to-group newsgroup))))
5384 ;; This function returns a list of article numbers based on the
5385 ;; difference between the ranges of read articles in this group and
5386 ;; the range of active articles.
5387 (defun gnus-list-of-unread-articles (group)
5388 (let* ((read (gnus-info-read (gnus-get-info group)))
5389 (active (or (gnus-active group) (gnus-activate-group group)))
5392 ;; If none are read, then all are unread.
5394 (setq first (car active))
5395 ;; If the range of read articles is a single range, then the
5396 ;; first unread article is the article after the last read
5397 ;; article. Sounds logical, doesn't it?
5398 (if (and (not (listp (cdr read)))
5399 (or (< (car read) (car active))
5400 (progn (setq read (list read))
5402 (setq first (max (car active) (1+ (cdr read))))
5403 ;; `read' is a list of ranges.
5404 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5407 (setq first (car active)))
5410 (while (< first nlast)
5412 (setq first (1+ first))))
5413 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5414 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5415 (setq read (cdr read)))))
5416 ;; And add the last unread articles.
5417 (while (<= first last)
5419 (setq first (1+ first)))
5420 ;; Return the list of unread articles.
5421 (delq 0 (nreverse unread))))
5423 (defun gnus-list-of-read-articles (group)
5424 "Return a list of unread, unticked and non-dormant articles."
5425 (let* ((info (gnus-get-info group))
5426 (marked (gnus-info-marks info))
5427 (active (gnus-active group)))
5429 (gnus-set-difference
5430 (gnus-sorted-complement
5431 (gnus-uncompress-range active)
5432 (gnus-list-of-unread-articles group))
5434 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5435 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5437 ;; Various summary commands
5439 (defun gnus-summary-select-article-buffer ()
5440 "Reconfigure windows to show article buffer."
5442 (if (not (gnus-buffer-live-p gnus-article-buffer))
5443 (error "There is no article buffer for this summary buffer")
5444 (gnus-configure-windows 'article)
5445 (select-window (get-buffer-window gnus-article-buffer))))
5447 (defun gnus-summary-universal-argument (arg)
5448 "Perform any operation on all articles that are process/prefixed."
5450 (let ((articles (gnus-summary-work-articles arg))
5457 (substitute-command-keys
5458 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5460 (gnus-error 1 "Undefined key")
5463 (gnus-summary-goto-subject (setq article (pop articles)))
5464 (let (gnus-newsgroup-processable)
5465 (command-execute func))
5466 (gnus-summary-remove-process-mark article)))))
5467 (gnus-summary-position-point))
5469 (defun gnus-summary-toggle-truncation (&optional arg)
5470 "Toggle truncation of summary lines.
5471 With arg, turn line truncation on iff arg is positive."
5473 (setq truncate-lines
5474 (if (null arg) (not truncate-lines)
5475 (> (prefix-numeric-value arg) 0)))
5478 (defun gnus-summary-reselect-current-group (&optional all rescan)
5479 "Exit and then reselect the current newsgroup.
5480 The prefix argument ALL means to select all articles."
5482 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5483 (error "Ephemeral groups can't be reselected"))
5484 (let ((current-subject (gnus-summary-article-number))
5485 (group gnus-newsgroup-name))
5486 (setq gnus-newsgroup-begin nil)
5488 ;; We have to adjust the point of group mode buffer because
5489 ;; point was moved to the next unread newsgroup by exiting.
5490 (gnus-summary-jump-to-group group)
5493 (gnus-group-get-new-news-this-group 1)))
5494 (gnus-group-read-group all t)
5495 (gnus-summary-goto-subject current-subject nil t)))
5497 (defun gnus-summary-rescan-group (&optional all)
5498 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5500 (gnus-summary-reselect-current-group all t))
5502 (defun gnus-summary-update-info (&optional non-destructive)
5504 (let ((group gnus-newsgroup-name))
5506 (when gnus-newsgroup-kill-headers
5507 (setq gnus-newsgroup-killed
5508 (gnus-compress-sequence
5510 (gnus-set-sorted-intersection
5511 (gnus-uncompress-range gnus-newsgroup-killed)
5512 (setq gnus-newsgroup-unselected
5513 (sort gnus-newsgroup-unselected '<)))
5514 (setq gnus-newsgroup-unreads
5515 (sort gnus-newsgroup-unreads '<)))
5517 (unless (listp (cdr gnus-newsgroup-killed))
5518 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5519 (let ((headers gnus-newsgroup-headers))
5520 ;; Set the new ranges of read articles.
5522 (set-buffer gnus-group-buffer)
5523 (gnus-undo-force-boundary))
5524 (gnus-update-read-articles
5525 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5526 ;; Set the current article marks.
5527 (let ((gnus-newsgroup-scored
5528 (if (and (not gnus-save-score)
5529 (not non-destructive))
5531 gnus-newsgroup-scored)))
5533 (gnus-update-marks)))
5534 ;; Do the cross-ref thing.
5535 (when gnus-use-cross-reference
5536 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5537 ;; Do not switch windows but change the buffer to work.
5538 (set-buffer gnus-group-buffer)
5539 (unless (gnus-ephemeral-group-p group)
5540 (gnus-group-update-group group)))))))
5542 (defun gnus-summary-save-newsrc (&optional force)
5543 "Save the current number of read/marked articles in the dribble buffer.
5544 The dribble buffer will then be saved.
5545 If FORCE (the prefix), also save the .newsrc file(s)."
5547 (gnus-summary-update-info t)
5549 (gnus-save-newsrc-file)
5550 (gnus-dribble-save)))
5552 (defun gnus-summary-exit (&optional temporary)
5553 "Exit reading current newsgroup, and then return to group selection mode.
5554 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5556 (gnus-set-global-variables)
5557 (when (gnus-buffer-live-p gnus-article-buffer)
5559 (set-buffer gnus-article-buffer)
5560 (mm-destroy-parts gnus-article-mime-handles)
5561 ;; Set it to nil for safety reason.
5562 (setq gnus-article-mime-handle-alist nil)
5563 (setq gnus-article-mime-handles nil)))
5564 (gnus-kill-save-kill-buffer)
5565 (gnus-async-halt-prefetch)
5566 (let* ((group gnus-newsgroup-name)
5567 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5570 (buf (current-buffer)))
5572 ;; Do adaptive scoring, and possibly save score files.
5573 (when gnus-newsgroup-adaptive
5574 (gnus-score-adaptive))
5575 (when gnus-use-scoring
5577 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5578 ;; If we have several article buffers, we kill them at exit.
5579 (unless gnus-single-article-buffer
5580 (gnus-kill-buffer gnus-original-article-buffer)
5581 (setq gnus-article-current nil))
5582 (when gnus-use-cache
5583 (gnus-cache-possibly-remove-articles)
5584 (gnus-cache-save-buffers))
5585 (gnus-async-prefetch-remove-group group)
5586 (when gnus-suppress-duplicates
5587 (gnus-dup-enter-articles))
5588 (when gnus-use-trees
5589 (gnus-tree-close group))
5590 (when gnus-use-cache
5591 (gnus-cache-write-active))
5592 ;; Remove entries for this group.
5593 (nnmail-purge-split-history (gnus-group-real-name group))
5594 ;; Make all changes in this group permanent.
5596 (gnus-run-hooks 'gnus-exit-group-hook)
5597 (gnus-summary-update-info))
5598 (gnus-close-group group)
5599 ;; Make sure where we were, and go to next newsgroup.
5600 (set-buffer gnus-group-buffer)
5602 (gnus-group-jump-to-group group))
5603 (gnus-run-hooks 'gnus-summary-exit-hook)
5604 (unless (or quit-config
5605 ;; If this group has disappeared from the summary
5606 ;; buffer, don't skip forwards.
5607 (not (string= group (gnus-group-group-name))))
5608 (gnus-group-next-unread-group 1))
5609 (setq group-point (point))
5612 ;; If we have several article buffers, we kill them at exit.
5613 (unless gnus-single-article-buffer
5614 (gnus-kill-buffer gnus-article-buffer)
5615 (gnus-kill-buffer gnus-original-article-buffer)
5616 (setq gnus-article-current nil))
5618 (if (not gnus-kill-summary-on-exit)
5619 (gnus-deaden-summary)
5620 ;; We set all buffer-local variables to nil. It is unclear why
5621 ;; this is needed, but if we don't, buffer-local variables are
5622 ;; not garbage-collected, it seems. This would the lead to en
5623 ;; ever-growing Emacs.
5624 (gnus-summary-clear-local-variables)
5625 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5626 (gnus-summary-clear-local-variables))
5627 (when (get-buffer gnus-article-buffer)
5628 (bury-buffer gnus-article-buffer))
5629 ;; We clear the global counterparts of the buffer-local
5630 ;; variables as well, just to be on the safe side.
5631 (set-buffer gnus-group-buffer)
5632 (gnus-summary-clear-local-variables)
5633 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5634 (gnus-summary-clear-local-variables))
5635 ;; Return to group mode buffer.
5636 (when (eq mode 'gnus-summary-mode)
5637 (gnus-kill-buffer buf)))
5638 (setq gnus-current-select-method gnus-select-method)
5639 (pop-to-buffer gnus-group-buffer)
5640 (if (not quit-config)
5642 (goto-char group-point)
5643 (gnus-configure-windows 'group 'force))
5644 (gnus-handle-ephemeral-exit quit-config))
5645 ;; Clear the current group name.
5647 (setq gnus-newsgroup-name nil)))))
5649 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5650 (defun gnus-summary-exit-no-update (&optional no-questions)
5651 "Quit reading current newsgroup without updating read article info."
5653 (let* ((group gnus-newsgroup-name)
5654 (quit-config (gnus-group-quit-config group)))
5655 (when (or no-questions
5657 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5658 (gnus-async-halt-prefetch)
5660 (delq 'gnus-summary-expire-articles
5661 (copy-sequence gnus-summary-prepare-exit-hook)))
5662 (when (gnus-buffer-live-p gnus-article-buffer)
5664 (set-buffer gnus-article-buffer)
5665 (mm-destroy-parts gnus-article-mime-handles)
5666 ;; Set it to nil for safety reason.
5667 (setq gnus-article-mime-handle-alist nil)
5668 (setq gnus-article-mime-handles nil)))
5669 ;; If we have several article buffers, we kill them at exit.
5670 (unless gnus-single-article-buffer
5671 (gnus-kill-buffer gnus-article-buffer)
5672 (gnus-kill-buffer gnus-original-article-buffer)
5673 (setq gnus-article-current nil))
5674 (if (not gnus-kill-summary-on-exit)
5675 (gnus-deaden-summary)
5676 (gnus-close-group group)
5677 (gnus-summary-clear-local-variables)
5678 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5679 (gnus-summary-clear-local-variables))
5680 (set-buffer gnus-group-buffer)
5681 (gnus-summary-clear-local-variables)
5682 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5683 (gnus-summary-clear-local-variables))
5684 (when (get-buffer gnus-summary-buffer)
5685 (kill-buffer gnus-summary-buffer)))
5686 (unless gnus-single-article-buffer
5687 (setq gnus-article-current nil))
5688 (when gnus-use-trees
5689 (gnus-tree-close group))
5690 (gnus-async-prefetch-remove-group group)
5691 (when (get-buffer gnus-article-buffer)
5692 (bury-buffer gnus-article-buffer))
5693 ;; Return to the group buffer.
5694 (gnus-configure-windows 'group 'force)
5695 ;; Clear the current group name.
5696 (setq gnus-newsgroup-name nil)
5697 (when (equal (gnus-group-group-name) group)
5698 (gnus-group-next-unread-group 1))
5700 (gnus-handle-ephemeral-exit quit-config)))))
5702 (defun gnus-handle-ephemeral-exit (quit-config)
5703 "Handle movement when leaving an ephemeral group.
5704 The state which existed when entering the ephemeral is reset."
5705 (if (not (buffer-name (car quit-config)))
5706 (gnus-configure-windows 'group 'force)
5707 (set-buffer (car quit-config))
5708 (cond ((eq major-mode 'gnus-summary-mode)
5709 (gnus-set-global-variables))
5710 ((eq major-mode 'gnus-article-mode)
5712 ;; The `gnus-summary-buffer' variable may point
5713 ;; to the old summary buffer when using a single
5715 (unless (gnus-buffer-live-p gnus-summary-buffer)
5716 (set-buffer gnus-group-buffer))
5717 (set-buffer gnus-summary-buffer)
5718 (gnus-set-global-variables))))
5719 (if (or (eq (cdr quit-config) 'article)
5720 (eq (cdr quit-config) 'pick))
5722 ;; The current article may be from the ephemeral group
5723 ;; thus it is best that we reload this article
5724 (gnus-summary-show-article)
5725 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5726 (gnus-configure-windows 'pick 'force)
5727 (gnus-configure-windows (cdr quit-config) 'force)))
5728 (gnus-configure-windows (cdr quit-config) 'force))
5729 (when (eq major-mode 'gnus-summary-mode)
5730 (gnus-summary-next-subject 1 nil t)
5731 (gnus-summary-recenter)
5732 (gnus-summary-position-point))))
5736 (defvar gnus-dead-summary-mode-map nil)
5738 (unless gnus-dead-summary-mode-map
5739 (setq gnus-dead-summary-mode-map (make-keymap))
5740 (suppress-keymap gnus-dead-summary-mode-map)
5741 (substitute-key-definition
5742 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5743 (let ((keys '("\C-d" "\r" "\177" [delete])))
5745 (define-key gnus-dead-summary-mode-map
5746 (pop keys) 'gnus-summary-wake-up-the-dead))))
5748 (defvar gnus-dead-summary-mode nil
5749 "Minor mode for Gnus summary buffers.")
5751 (defun gnus-dead-summary-mode (&optional arg)
5752 "Minor mode for Gnus summary buffers."
5754 (when (eq major-mode 'gnus-summary-mode)
5755 (make-local-variable 'gnus-dead-summary-mode)
5756 (setq gnus-dead-summary-mode
5757 (if (null arg) (not gnus-dead-summary-mode)
5758 (> (prefix-numeric-value arg) 0)))
5759 (when gnus-dead-summary-mode
5760 (gnus-add-minor-mode
5761 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5763 (defun gnus-deaden-summary ()
5764 "Make the current summary buffer into a dead summary buffer."
5765 ;; Kill any previous dead summary buffer.
5766 (when (and gnus-dead-summary
5767 (buffer-name gnus-dead-summary))
5769 (set-buffer gnus-dead-summary)
5770 (when gnus-dead-summary-mode
5771 (kill-buffer (current-buffer)))))
5772 ;; Make this the current dead summary.
5773 (setq gnus-dead-summary (current-buffer))
5774 (gnus-dead-summary-mode 1)
5775 (let ((name (buffer-name)))
5776 (when (string-match "Summary" name)
5778 (concat (substring name 0 (match-beginning 0)) "Dead "
5779 (substring name (match-beginning 0)))
5783 (defun gnus-kill-or-deaden-summary (buffer)
5784 "Kill or deaden the summary BUFFER."
5786 (when (and (buffer-name buffer)
5787 (not gnus-single-article-buffer))
5790 (gnus-kill-buffer gnus-article-buffer)
5791 (gnus-kill-buffer gnus-original-article-buffer)))
5792 (cond (gnus-kill-summary-on-exit
5793 (when (and gnus-use-trees
5794 (gnus-buffer-exists-p buffer))
5797 (gnus-tree-close gnus-newsgroup-name)))
5798 (gnus-kill-buffer buffer))
5799 ((gnus-buffer-exists-p buffer)
5802 (gnus-deaden-summary))))))
5804 (defun gnus-summary-wake-up-the-dead (&rest args)
5805 "Wake up the dead summary buffer."
5807 (gnus-dead-summary-mode -1)
5808 (let ((name (buffer-name)))
5809 (when (string-match "Dead " name)
5811 (concat (substring name 0 (match-beginning 0))
5812 (substring name (match-end 0)))
5814 (gnus-message 3 "This dead summary is now alive again"))
5816 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5817 (defun gnus-summary-fetch-faq (&optional faq-dir)
5818 "Fetch the FAQ for the current group.
5819 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5823 (when current-prefix-arg
5825 "Faq dir: " (and (listp gnus-group-faq-directory)
5826 (mapcar (lambda (file) (list file))
5827 gnus-group-faq-directory))))))
5828 (let (gnus-faq-buffer)
5829 (when (setq gnus-faq-buffer
5830 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5831 (gnus-configure-windows 'summary-faq))))
5833 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5834 (defun gnus-summary-describe-group (&optional force)
5835 "Describe the current newsgroup."
5837 (gnus-group-describe-group force gnus-newsgroup-name))
5839 (defun gnus-summary-describe-briefly ()
5840 "Describe summary mode commands briefly."
5842 (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")))
5844 ;; Walking around group mode buffer from summary mode.
5846 (defun gnus-summary-next-group (&optional no-article target-group backward)
5847 "Exit current newsgroup and then select next unread newsgroup.
5848 If prefix argument NO-ARTICLE is non-nil, no article is selected
5849 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5850 previous group instead."
5852 ;; Stop pre-fetching.
5853 (gnus-async-halt-prefetch)
5854 (let ((current-group gnus-newsgroup-name)
5855 (current-buffer (current-buffer))
5857 ;; First we semi-exit this group to update Xrefs and all variables.
5858 ;; We can't do a real exit, because the window conf must remain
5859 ;; the same in case the user is prompted for info, and we don't
5860 ;; want the window conf to change before that...
5861 (gnus-summary-exit t)
5862 (while (not entered)
5863 ;; Then we find what group we are supposed to enter.
5864 (set-buffer gnus-group-buffer)
5865 (gnus-group-jump-to-group current-group)
5868 (if (eq gnus-keep-same-level 'best)
5869 (gnus-summary-best-group gnus-newsgroup-name)
5870 (gnus-summary-search-group backward gnus-keep-same-level))))
5871 (if (not target-group)
5872 ;; There are no further groups, so we return to the group
5875 (gnus-message 5 "Returning to the group buffer")
5877 (when (gnus-buffer-live-p current-buffer)
5878 (set-buffer current-buffer)
5879 (gnus-summary-exit))
5880 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5881 ;; We try to enter the target group.
5882 (gnus-group-jump-to-group target-group)
5883 (let ((unreads (gnus-group-group-unread)))
5884 (if (and (or (eq t unreads)
5885 (and unreads (not (zerop unreads))))
5886 (gnus-summary-read-group
5887 target-group nil no-article
5888 (and (buffer-name current-buffer) current-buffer)
5891 (setq current-group target-group
5892 target-group nil)))))))
5894 (defun gnus-summary-prev-group (&optional no-article)
5895 "Exit current newsgroup and then select previous unread newsgroup.
5896 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5898 (gnus-summary-next-group no-article nil t))
5900 ;; Walking around summary lines.
5902 (defun gnus-summary-first-subject (&optional unread undownloaded)
5903 "Go to the first unread subject.
5904 If UNREAD is non-nil, go to the first unread article.
5905 Returns the article selected or nil if there are no unread articles."
5910 ((null gnus-newsgroup-data)
5911 (gnus-message 3 "No articles in the group")
5913 ;; Pick the first article.
5915 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5916 (gnus-data-number (car gnus-newsgroup-data)))
5917 ;; No unread articles.
5918 ((null gnus-newsgroup-unreads)
5919 (gnus-message 3 "No more unread articles")
5921 ;; Find the first unread article.
5923 (let ((data gnus-newsgroup-data))
5925 (and (not (and undownloaded
5926 (eq gnus-undownloaded-mark
5927 (gnus-data-mark (car data)))))
5928 (not (gnus-data-unread-p (car data)))))
5929 (setq data (cdr data)))
5931 (goto-char (gnus-data-pos (car data)))
5932 (gnus-data-number (car data))))))
5933 (gnus-summary-position-point)))
5935 (defun gnus-summary-next-subject (n &optional unread dont-display)
5936 "Go to next N'th summary line.
5937 If N is negative, go to the previous N'th subject line.
5938 If UNREAD is non-nil, only unread articles are selected.
5939 The difference between N and the actual number of steps taken is
5942 (let ((backward (< n 0))
5946 (gnus-summary-find-prev unread)
5947 (gnus-summary-find-next unread)))
5948 (unless (zerop (setq n (1- n)))
5949 (gnus-summary-show-thread)))
5951 (gnus-message 7 "No more%s articles"
5952 (if unread " unread" "")))
5953 (unless dont-display
5954 (gnus-summary-recenter)
5955 (gnus-summary-position-point))
5958 (defun gnus-summary-next-unread-subject (n)
5959 "Go to next N'th unread summary line."
5961 (gnus-summary-next-subject n t))
5963 (defun gnus-summary-prev-subject (n &optional unread)
5964 "Go to previous N'th summary line.
5965 If optional argument UNREAD is non-nil, only unread article is selected."
5967 (gnus-summary-next-subject (- n) unread))
5969 (defun gnus-summary-prev-unread-subject (n)
5970 "Go to previous N'th unread summary line."
5972 (gnus-summary-next-subject (- n) t))
5974 (defun gnus-summary-goto-subject (article &optional force silent)
5975 "Go the subject line of ARTICLE.
5976 If FORCE, also allow jumping to articles not currently shown."
5977 (interactive "nArticle number: ")
5979 (data (gnus-data-find article)))
5980 ;; We read in the article if we have to.
5983 (gnus-summary-insert-subject
5985 (if (or (numberp force) (vectorp force)) force)
5987 (setq data (gnus-data-find article)))
5992 (gnus-message 3 "Can't find article %d" article))
5994 (goto-char (gnus-data-pos data))
5995 (gnus-summary-position-point)
5998 ;; Walking around summary lines with displaying articles.
6000 (defun gnus-summary-expand-window (&optional arg)
6001 "Make the summary buffer take up the entire Emacs frame.
6002 Given a prefix, will force an `article' buffer configuration."
6005 (gnus-configure-windows 'article 'force)
6006 (gnus-configure-windows 'summary 'force)))
6008 (defun gnus-summary-display-article (article &optional all-header)
6009 "Display ARTICLE in article buffer."
6010 (when (gnus-buffer-live-p gnus-article-buffer)
6011 (with-current-buffer gnus-article-buffer
6012 (mm-enable-multibyte-mule4)))
6013 (gnus-set-global-variables)
6014 (when (gnus-buffer-live-p gnus-article-buffer)
6015 (with-current-buffer gnus-article-buffer
6016 (setq gnus-article-charset gnus-newsgroup-charset)
6017 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6018 (mm-enable-multibyte-mule4)))
6022 (if gnus-summary-display-article-function
6023 (funcall gnus-summary-display-article-function article all-header)
6024 (gnus-article-prepare article all-header))
6025 (gnus-run-hooks 'gnus-select-article-hook)
6026 (when (and gnus-current-article
6027 (not (zerop gnus-current-article)))
6028 (gnus-summary-goto-subject gnus-current-article))
6029 (gnus-summary-recenter)
6030 (when (and gnus-use-trees gnus-show-threads)
6031 (gnus-possibly-generate-tree article)
6032 (gnus-highlight-selected-tree article))
6033 ;; Successfully display article.
6034 (gnus-article-set-window-start
6035 (cdr (assq article gnus-newsgroup-bookmarks))))))
6037 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6038 "Select the current article.
6039 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6040 non-nil, the article will be re-fetched even if it already present in
6041 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6043 ;; Make sure we are in the summary buffer to work around bbdb bug.
6044 (unless (eq major-mode 'gnus-summary-mode)
6045 (set-buffer gnus-summary-buffer))
6046 (let ((article (or article (gnus-summary-article-number)))
6047 (all-headers (not (not all-headers))) ;Must be T or NIL.
6048 gnus-summary-display-article-function)
6050 (gnus-summary-article-pseudo-p article)
6051 (error "This is a pseudo-article"))
6053 (set-buffer gnus-summary-buffer)
6054 (if (or (and gnus-single-article-buffer
6055 (or (null gnus-current-article)
6056 (null gnus-article-current)
6057 (null (get-buffer gnus-article-buffer))
6058 (not (eq article (cdr gnus-article-current)))
6059 (not (equal (car gnus-article-current)
6060 gnus-newsgroup-name))))
6061 (and (not gnus-single-article-buffer)
6062 (or (null gnus-current-article)
6063 (not (eq gnus-current-article article))))
6065 ;; The requested article is different from the current article.
6067 (gnus-summary-display-article article all-headers)
6068 (when (gnus-buffer-live-p gnus-article-buffer)
6069 (with-current-buffer gnus-article-buffer
6070 (if (not gnus-article-decoded-p) ;; a local variable
6071 (mm-disable-multibyte-mule4))))
6072 (when (or all-headers gnus-show-all-headers)
6073 (gnus-article-show-all-headers))
6074 (gnus-article-set-window-start
6075 (cdr (assq article gnus-newsgroup-bookmarks)))
6077 (when (or all-headers gnus-show-all-headers)
6078 (gnus-article-show-all-headers))
6081 (defun gnus-summary-force-verify-and-decrypt ()
6083 (let ((mm-verify-option 'known)
6084 (mm-decrypt-option 'known))
6085 (gnus-summary-select-article nil 'force)))
6087 (defun gnus-summary-set-current-mark (&optional current-mark)
6088 "Obsolete function."
6091 (defun gnus-summary-next-article (&optional unread subject backward push)
6092 "Select the next article.
6093 If UNREAD, only unread articles are selected.
6094 If SUBJECT, only articles with SUBJECT are selected.
6095 If BACKWARD, the previous article is selected instead of the next."
6098 ;; Is there such an article?
6099 ((and (gnus-summary-search-forward unread subject backward)
6100 (or (gnus-summary-display-article (gnus-summary-article-number))
6101 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6102 (gnus-summary-position-point))
6103 ;; If not, we try the first unread, if that is wanted.
6105 gnus-auto-select-same
6106 (gnus-summary-first-unread-article))
6107 (gnus-summary-position-point)
6108 (gnus-message 6 "Wrapped"))
6109 ;; Try to get next/previous article not displayed in this group.
6110 ((and gnus-auto-extend-newsgroup
6111 (not unread) (not subject))
6112 (gnus-summary-goto-article
6113 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6114 nil (count-lines (point-min) (point))))
6115 ;; Go to next/previous group.
6117 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6118 (gnus-summary-jump-to-group gnus-newsgroup-name))
6119 (let ((cmd last-command-char)
6122 (set-buffer gnus-group-buffer)
6125 (if (eq gnus-keep-same-level 'best)
6126 (gnus-summary-best-group gnus-newsgroup-name)
6127 (gnus-summary-search-group backward gnus-keep-same-level))))
6128 ;; For some reason, the group window gets selected. We change
6130 (select-window (get-buffer-window (current-buffer)))
6131 ;; Select next unread newsgroup automagically.
6133 ((or (not gnus-auto-select-next)
6135 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6136 ((or (eq gnus-auto-select-next 'quietly)
6137 (and (eq gnus-auto-select-next 'slightly-quietly)
6139 (and (eq gnus-auto-select-next 'almost-quietly)
6140 (gnus-summary-last-article-p)))
6142 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6144 (gnus-message 7 "No more%s articles (%s)..."
6145 (if unread " unread" "")
6146 (if group (concat "selecting " group)
6148 (gnus-summary-next-group nil group backward)))
6150 (when (gnus-key-press-event-p last-input-event)
6151 (gnus-summary-walk-group-buffer
6152 gnus-newsgroup-name cmd unread backward point))))))))
6154 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6155 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6156 (?\C-p (gnus-group-prev-unread-group 1))))
6157 (cursor-in-echo-area t)
6158 keve key group ended)
6160 (set-buffer gnus-group-buffer)
6163 (if (eq gnus-keep-same-level 'best)
6164 (gnus-summary-best-group gnus-newsgroup-name)
6165 (gnus-summary-search-group backward gnus-keep-same-level))))
6168 5 "No more%s articles%s" (if unread " unread" "")
6170 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6171 (format " (Type %s for %s [%s])"
6172 (single-key-description cmd) group
6173 (car (gnus-gethash group gnus-newsrc-hashtb)))
6174 (format " (Type %s to exit %s)"
6175 (single-key-description cmd)
6176 gnus-newsgroup-name)))
6177 ;; Confirm auto selection.
6178 (setq key (car (setq keve (gnus-read-event-char))))
6181 ((assq key keystrokes)
6182 (let ((obuf (current-buffer)))
6183 (switch-to-buffer gnus-group-buffer)
6185 (gnus-group-jump-to-group group))
6186 (eval (cadr (assq key keystrokes)))
6187 (setq group (gnus-group-group-name))
6188 (switch-to-buffer obuf))
6192 (gnus-ephemeral-group-p gnus-newsgroup-name))
6194 (gnus-summary-next-group nil group backward)))
6196 (push (cdr keve) unread-command-events))))))
6198 (defun gnus-summary-next-unread-article ()
6199 "Select unread article after current one."
6201 (gnus-summary-next-article
6202 (or (not (eq gnus-summary-goto-unread 'never))
6203 (gnus-summary-last-article-p (gnus-summary-article-number)))
6204 (and gnus-auto-select-same
6205 (gnus-summary-article-subject))))
6207 (defun gnus-summary-prev-article (&optional unread subject)
6208 "Select the article after the current one.
6209 If UNREAD is non-nil, only unread articles are selected."
6211 (gnus-summary-next-article unread subject t))
6213 (defun gnus-summary-prev-unread-article ()
6214 "Select unread article before current one."
6216 (gnus-summary-prev-article
6217 (or (not (eq gnus-summary-goto-unread 'never))
6218 (gnus-summary-first-article-p (gnus-summary-article-number)))
6219 (and gnus-auto-select-same
6220 (gnus-summary-article-subject))))
6222 (defun gnus-summary-next-page (&optional lines circular)
6223 "Show next page of the selected article.
6224 If at the end of the current article, select the next article.
6225 LINES says how many lines should be scrolled up.
6227 If CIRCULAR is non-nil, go to the start of the article instead of
6228 selecting the next article when reaching the end of the current
6231 (setq gnus-summary-buffer (current-buffer))
6232 (gnus-set-global-variables)
6233 (let ((article (gnus-summary-article-number))
6234 (article-window (get-buffer-window gnus-article-buffer t))
6236 ;; If the buffer is empty, we have no article.
6238 (error "No article to select"))
6239 (gnus-configure-windows 'article)
6240 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6241 (if (and (eq gnus-summary-goto-unread 'never)
6242 (not (gnus-summary-last-article-p article)))
6243 (gnus-summary-next-article)
6244 (gnus-summary-next-unread-article))
6245 (if (or (null gnus-current-article)
6246 (null gnus-article-current)
6247 (/= article (cdr gnus-article-current))
6248 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6249 ;; Selected subject is different from current article's.
6250 (gnus-summary-display-article article)
6251 (when article-window
6252 (gnus-eval-in-buffer-window gnus-article-buffer
6253 (setq endp (gnus-article-next-page lines)))
6256 (gnus-summary-beginning-of-article))
6258 (gnus-message 3 "End of message"))
6260 (if (and (eq gnus-summary-goto-unread 'never)
6261 (not (gnus-summary-last-article-p article)))
6262 (gnus-summary-next-article)
6263 (gnus-summary-next-unread-article))))))))
6264 (gnus-summary-recenter)
6265 (gnus-summary-position-point)))
6267 (defun gnus-summary-prev-page (&optional lines move)
6268 "Show previous page of selected article.
6269 Argument LINES specifies lines to be scrolled down.
6270 If MOVE, move to the previous unread article if point is at
6271 the beginning of the buffer."
6273 (let ((article (gnus-summary-article-number))
6274 (article-window (get-buffer-window gnus-article-buffer t))
6276 (gnus-configure-windows 'article)
6277 (if (or (null gnus-current-article)
6278 (null gnus-article-current)
6279 (/= article (cdr gnus-article-current))
6280 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6281 ;; Selected subject is different from current article's.
6282 (gnus-summary-display-article article)
6283 (gnus-summary-recenter)
6284 (when article-window
6285 (gnus-eval-in-buffer-window gnus-article-buffer
6286 (setq endp (gnus-article-prev-page lines)))
6287 (when (and move endp)
6289 (gnus-message 3 "Beginning of message"))
6291 (if (and (eq gnus-summary-goto-unread 'never)
6292 (not (gnus-summary-first-article-p article)))
6293 (gnus-summary-prev-article)
6294 (gnus-summary-prev-unread-article))))))))
6295 (gnus-summary-position-point))
6297 (defun gnus-summary-prev-page-or-article (&optional lines)
6298 "Show previous page of selected article.
6299 Argument LINES specifies lines to be scrolled down.
6300 If at the beginning of the article, go to the next article."
6302 (gnus-summary-prev-page lines t))
6304 (defun gnus-summary-scroll-up (lines)
6305 "Scroll up (or down) one line current article.
6306 Argument LINES specifies lines to be scrolled up (or down if negative)."
6308 (gnus-configure-windows 'article)
6309 (gnus-summary-show-thread)
6310 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6311 (gnus-eval-in-buffer-window gnus-article-buffer
6313 (when (gnus-article-next-page lines)
6314 (gnus-message 3 "End of message")))
6316 (gnus-article-prev-page (- lines))))))
6317 (gnus-summary-recenter)
6318 (gnus-summary-position-point))
6320 (defun gnus-summary-scroll-down (lines)
6321 "Scroll down (or up) one line current article.
6322 Argument LINES specifies lines to be scrolled down (or up if negative)."
6324 (gnus-summary-scroll-up (- lines)))
6326 (defun gnus-summary-next-same-subject ()
6327 "Select next article which has the same subject as current one."
6329 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6331 (defun gnus-summary-prev-same-subject ()
6332 "Select previous article which has the same subject as current one."
6334 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6336 (defun gnus-summary-next-unread-same-subject ()
6337 "Select next unread article which has the same subject as current one."
6339 (gnus-summary-next-article t (gnus-summary-article-subject)))
6341 (defun gnus-summary-prev-unread-same-subject ()
6342 "Select previous unread article which has the same subject as current one."
6344 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6346 (defun gnus-summary-first-unread-article ()
6347 "Select the first unread article.
6348 Return nil if there are no unread articles."
6351 (when (gnus-summary-first-subject t)
6352 (gnus-summary-show-thread)
6353 (gnus-summary-first-subject t)
6354 (gnus-summary-display-article (gnus-summary-article-number)))
6355 (gnus-summary-position-point)))
6357 (defun gnus-summary-first-unread-subject ()
6358 "Place the point on the subject line of the first unread article.
6359 Return nil if there are no unread articles."
6362 (when (gnus-summary-first-subject t)
6363 (gnus-summary-show-thread)
6364 (gnus-summary-first-subject t))
6365 (gnus-summary-position-point)))
6367 (defun gnus-summary-first-article ()
6368 "Select the first article.
6369 Return nil if there are no articles."
6372 (when (gnus-summary-first-subject)
6373 (gnus-summary-show-thread)
6374 (gnus-summary-first-subject)
6375 (gnus-summary-display-article (gnus-summary-article-number)))
6376 (gnus-summary-position-point)))
6378 (defun gnus-summary-best-unread-article ()
6379 "Select the unread article with the highest score."
6381 (let ((best -1000000)
6382 (data gnus-newsgroup-data)
6385 (and (gnus-data-unread-p (car data))
6387 (gnus-summary-article-score (gnus-data-number (car data))))
6390 article (gnus-data-number (car data))))
6391 (setq data (cdr data)))
6394 (gnus-summary-goto-article article)
6395 (error "No unread articles"))
6396 (gnus-summary-position-point))))
6398 (defun gnus-summary-last-subject ()
6399 "Go to the last displayed subject line in the group."
6400 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6402 (gnus-summary-goto-subject article))))
6404 (defun gnus-summary-goto-article (article &optional all-headers force)
6405 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6406 If ALL-HEADERS is non-nil, no header lines are hidden.
6407 If FORCE, go to the article even if it isn't displayed. If FORCE
6408 is a number, it is the line the article is to be displayed on."
6412 "Article number or Message-ID: "
6413 (mapcar (lambda (number) (list (int-to-string number)))
6414 gnus-newsgroup-limit))
6418 (if (and (stringp article)
6419 (string-match "@" article))
6420 (gnus-summary-refer-article article)
6421 (when (stringp article)
6422 (setq article (string-to-number article)))
6423 (if (gnus-summary-goto-subject article force)
6424 (gnus-summary-display-article article all-headers)
6425 (gnus-message 4 "Couldn't go to article %s" article) nil))
6426 (gnus-summary-position-point)))
6428 (defun gnus-summary-goto-last-article ()
6429 "Go to the previously read article."
6432 (when gnus-last-article
6433 (gnus-summary-goto-article gnus-last-article nil t))
6434 (gnus-summary-position-point)))
6436 (defun gnus-summary-pop-article (number)
6437 "Pop one article off the history and go to the previous.
6438 NUMBER articles will be popped off."
6441 (setq gnus-newsgroup-history
6442 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6444 (gnus-summary-goto-article (car to) nil t)
6445 (error "Article history empty")))
6446 (gnus-summary-position-point))
6448 ;; Summary commands and functions for limiting the summary buffer.
6450 (defun gnus-summary-limit-to-articles (n)
6451 "Limit the summary buffer to the next N articles.
6452 If not given a prefix, use the process marked articles instead."
6455 (let ((articles (gnus-summary-work-articles n)))
6456 (setq gnus-newsgroup-processable nil)
6457 (gnus-summary-limit articles))
6458 (gnus-summary-position-point)))
6460 (defun gnus-summary-pop-limit (&optional total)
6461 "Restore the previous limit.
6462 If given a prefix, remove all limits."
6465 (setq gnus-newsgroup-limits
6466 (list (mapcar (lambda (h) (mail-header-number h))
6467 gnus-newsgroup-headers))))
6468 (unless gnus-newsgroup-limits
6469 (error "No limit to pop"))
6471 (gnus-summary-limit nil 'pop)
6472 (gnus-summary-position-point)))
6474 (defun gnus-summary-limit-to-subject (subject &optional header)
6475 "Limit the summary buffer to articles that have subjects that match a regexp."
6476 (interactive "sLimit to subject (regexp): ")
6478 (setq header "subject"))
6479 (when (not (equal "" subject))
6481 (let ((articles (gnus-summary-find-matching
6482 (or header "subject") subject 'all)))
6484 (error "Found no matches for \"%s\"" subject))
6485 (gnus-summary-limit articles))
6486 (gnus-summary-position-point))))
6488 (defun gnus-summary-limit-to-author (from)
6489 "Limit the summary buffer to articles that have authors that match a regexp."
6490 (interactive "sLimit to author (regexp): ")
6491 (gnus-summary-limit-to-subject from "from"))
6493 (defun gnus-summary-limit-to-age (age &optional younger-p)
6494 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6495 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6496 articles that are younger than AGE days."
6498 (let ((younger current-prefix-arg)
6501 (while (not days-got)
6502 (setq days (if younger
6503 (read-string "Limit to articles within (in days): ")
6504 (read-string "Limit to articles older than (in days): ")))
6505 (when (> (length days) 0)
6506 (setq days (read days)))
6509 (message "Please enter a number.")
6511 (list days younger)))
6513 (let ((data gnus-newsgroup-data)
6514 (cutoff (days-to-time age))
6515 articles d date is-younger)
6516 (while (setq d (pop data))
6517 (when (and (vectorp (gnus-data-header d))
6518 (setq date (mail-header-date (gnus-data-header d))))
6519 (setq is-younger (time-less-p
6520 (time-since (condition-case ()
6527 (push (gnus-data-number d) articles))))
6528 (gnus-summary-limit (nreverse articles)))
6529 (gnus-summary-position-point)))
6531 (defun gnus-summary-limit-to-extra (header regexp)
6532 "Limit the summary buffer to articles that match an 'extra' header."
6536 (gnus-completing-read
6537 (symbol-name (car gnus-extra-headers))
6538 "Limit extra header:"
6540 (cons (symbol-name x) x))
6545 (read-string (format "Limit to header %s (regexp): " header)))))
6546 (when (not (equal "" regexp))
6548 (let ((articles (gnus-summary-find-matching
6549 (cons 'extra header) regexp 'all)))
6551 (error "Found no matches for \"%s\"" regexp))
6552 (gnus-summary-limit articles))
6553 (gnus-summary-position-point))))
6555 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6557 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6559 (defun gnus-summary-limit-to-unread (&optional all)
6560 "Limit the summary buffer to articles that are not marked as read.
6561 If ALL is non-nil, limit strictly to unread articles."
6564 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6565 (gnus-summary-limit-to-marks
6566 ;; Concat all the marks that say that an article is read and have
6568 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6569 gnus-killed-mark gnus-kill-file-mark
6570 gnus-low-score-mark gnus-expirable-mark
6571 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6572 gnus-duplicate-mark gnus-souped-mark)
6575 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6576 (make-obsolete 'gnus-summary-delete-marked-with
6577 'gnus-summary-limit-exlude-marks)
6579 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6580 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6581 If REVERSE, limit the summary buffer to articles that are marked
6582 with MARKS. MARKS can either be a string of marks or a list of marks.
6583 Returns how many articles were removed."
6584 (interactive "sMarks: ")
6585 (gnus-summary-limit-to-marks marks t))
6587 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6588 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6589 If REVERSE (the prefix), limit the summary buffer to articles that are
6590 not marked with MARKS. MARKS can either be a string of marks or a
6592 Returns how many articles were removed."
6593 (interactive "sMarks: \nP")
6595 (let ((data gnus-newsgroup-data)
6596 (marks (if (listp marks) marks
6597 (append marks nil))) ; Transform to list.
6600 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6601 (memq (gnus-data-mark (car data)) marks))
6602 (push (gnus-data-number (car data)) articles))
6603 (setq data (cdr data)))
6604 (gnus-summary-limit articles))
6605 (gnus-summary-position-point)))
6607 (defun gnus-summary-limit-to-score (&optional score)
6608 "Limit to articles with score at or above SCORE."
6610 (setq score (if score
6611 (prefix-numeric-value score)
6612 (or gnus-summary-default-score 0)))
6613 (let ((data gnus-newsgroup-data)
6616 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6618 (push (gnus-data-number (car data)) articles))
6619 (setq data (cdr data)))
6621 (gnus-summary-limit articles)
6622 (gnus-summary-position-point))))
6624 (defun gnus-summary-limit-include-thread (id)
6625 "Display all the hidden articles that in the current thread."
6626 (interactive (list (mail-header-id (gnus-summary-article-header))))
6627 (let ((articles (gnus-articles-in-thread
6628 (gnus-id-to-thread (gnus-root-id id)))))
6630 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6631 (gnus-summary-position-point))))
6633 (defun gnus-summary-limit-include-dormant ()
6634 "Display all the hidden articles that are marked as dormant.
6635 Note that this command only works on a subset of the articles currently
6636 fetched for this group."
6638 (unless gnus-newsgroup-dormant
6639 (error "There are no dormant articles in this group"))
6641 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6642 (gnus-summary-position-point)))
6644 (defun gnus-summary-limit-exclude-dormant ()
6645 "Hide all dormant articles."
6648 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6649 (gnus-summary-position-point)))
6651 (defun gnus-summary-limit-exclude-childless-dormant ()
6652 "Hide all dormant articles that have no children."
6654 (let ((data (gnus-data-list t))
6655 articles d children)
6656 ;; Find all articles that are either not dormant or have
6658 (while (setq d (pop data))
6659 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6661 (gnus-article-children (gnus-data-number d)))
6664 (when (memq (car children) articles)
6669 (push (gnus-data-number d) articles)))
6672 (gnus-summary-limit articles)
6673 (gnus-summary-position-point))))
6675 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6676 "Mark all unread excluded articles as read.
6677 If ALL, mark even excluded ticked and dormants as read."
6679 (let ((articles (gnus-sorted-complement
6681 (mapcar (lambda (h) (mail-header-number h))
6682 gnus-newsgroup-headers)
6684 (sort gnus-newsgroup-limit '<)))
6686 (setq gnus-newsgroup-unreads
6687 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6689 (setq gnus-newsgroup-dormant nil
6690 gnus-newsgroup-marked nil
6691 gnus-newsgroup-reads
6693 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6694 gnus-newsgroup-reads))
6695 (while (setq article (pop articles))
6696 (unless (or (memq article gnus-newsgroup-dormant)
6697 (memq article gnus-newsgroup-marked))
6698 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6700 (defun gnus-summary-limit (articles &optional pop)
6702 ;; We pop the previous limit off the stack and use that.
6703 (setq articles (car gnus-newsgroup-limits)
6704 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6705 ;; We use the new limit, so we push the old limit on the stack.
6706 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6708 (setq gnus-newsgroup-limit articles)
6709 (let ((total (length gnus-newsgroup-data))
6710 (data (gnus-data-find-list (gnus-summary-article-number)))
6711 (gnus-summary-mark-below nil) ; Inhibit this.
6713 ;; This will do all the work of generating the new summary buffer
6714 ;; according to the new limit.
6715 (gnus-summary-prepare)
6716 ;; Hide any threads, possibly.
6717 (and gnus-show-threads
6718 gnus-thread-hide-subtree
6719 (gnus-summary-hide-all-threads))
6720 ;; Try to return to the article you were at, or one in the
6723 ;; We try to find some article after the current one.
6725 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6728 (setq data (cdr data))))
6730 ;; If there is no data, that means that we were after the last
6731 ;; article. The same goes when we can't find any articles
6732 ;; after the current one.
6733 (goto-char (point-max))
6734 (gnus-summary-find-prev))
6735 (gnus-set-mode-line 'summary)
6736 ;; We return how many articles were removed from the summary
6737 ;; buffer as a result of the new limit.
6738 (- total (length gnus-newsgroup-data))))
6740 (defsubst gnus-invisible-cut-children (threads)
6743 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6748 (defsubst gnus-cut-thread (thread)
6749 "Go forwards in the thread until we find an article that we want to display."
6750 (when (or (eq gnus-fetch-old-headers 'some)
6751 (eq gnus-fetch-old-headers 'invisible)
6752 (numberp gnus-fetch-old-headers)
6753 (eq gnus-build-sparse-threads 'some)
6754 (eq gnus-build-sparse-threads 'more))
6755 ;; Deal with old-fetched headers and sparse threads.
6759 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6760 (gnus-summary-article-ancient-p
6761 (mail-header-number (car thread))))
6762 (if (or (<= (length (cdr thread)) 1)
6763 (eq gnus-fetch-old-headers 'invisible))
6764 (setq gnus-newsgroup-limit
6765 (delq (mail-header-number (car thread))
6766 gnus-newsgroup-limit)
6767 thread (cadr thread))
6768 (when (gnus-invisible-cut-children (cdr thread))
6769 (let ((th (cdr thread)))
6771 (if (memq (mail-header-number (caar th))
6772 gnus-newsgroup-limit)
6773 (setq thread (car th)
6775 (setq th (cdr th))))))))))
6778 (defun gnus-cut-threads (threads)
6779 "Cut off all uninteresting articles from the beginning of threads."
6780 (when (or (eq gnus-fetch-old-headers 'some)
6781 (eq gnus-fetch-old-headers 'invisible)
6782 (numberp gnus-fetch-old-headers)
6783 (eq gnus-build-sparse-threads 'some)
6784 (eq gnus-build-sparse-threads 'more))
6787 (setcar th (gnus-cut-thread (car th)))
6788 (setq th (cdr th)))))
6789 ;; Remove nixed out threads.
6792 (defun gnus-summary-initial-limit (&optional show-if-empty)
6793 "Figure out what the initial limit is supposed to be on group entry.
6794 This entails weeding out unwanted dormants, low-scored articles,
6795 fetch-old-headers verbiage, and so on."
6796 ;; Most groups have nothing to remove.
6797 (if (or gnus-inhibit-limiting
6798 (and (null gnus-newsgroup-dormant)
6799 (not (eq gnus-fetch-old-headers 'some))
6800 (not (numberp gnus-fetch-old-headers))
6801 (not (eq gnus-fetch-old-headers 'invisible))
6802 (null gnus-summary-expunge-below)
6803 (not (eq gnus-build-sparse-threads 'some))
6804 (not (eq gnus-build-sparse-threads 'more))
6805 (null gnus-thread-expunge-below)
6806 (not gnus-use-nocem)))
6808 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6809 (setq gnus-newsgroup-limit nil)
6812 (unless (car (symbol-value node))
6813 ;; These threads have no parents -- they are roots.
6814 (let ((nodes (cdr (symbol-value node)))
6817 (if (and gnus-thread-expunge-below
6818 (< (gnus-thread-total-score (car nodes))
6819 gnus-thread-expunge-below))
6820 (gnus-expunge-thread (pop nodes))
6821 (setq thread (pop nodes))
6822 (gnus-summary-limit-children thread))))))
6823 gnus-newsgroup-dependencies)
6824 ;; If this limitation resulted in an empty group, we might
6825 ;; pop the previous limit and use it instead.
6826 (when (and (not gnus-newsgroup-limit)
6828 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6829 gnus-newsgroup-limit))
6831 (defun gnus-summary-limit-children (thread)
6832 "Return 1 if this subthread is visible and 0 if it is not."
6833 ;; First we get the number of visible children to this thread. This
6834 ;; is done by recursing down the thread using this function, so this
6835 ;; will really go down to a leaf article first, before slowly
6836 ;; working its way up towards the root.
6840 (apply '+ (mapcar 'gnus-summary-limit-children
6843 (number (mail-header-number (car thread)))
6846 (not (memq number gnus-newsgroup-marked))
6848 ;; If this article is dormant and has absolutely no visible
6849 ;; children, then this article isn't visible.
6850 (and (memq number gnus-newsgroup-dormant)
6852 ;; If this is "fetch-old-headered" and there is no
6853 ;; visible children, then we don't want this article.
6854 (and (or (eq gnus-fetch-old-headers 'some)
6855 (numberp gnus-fetch-old-headers))
6856 (gnus-summary-article-ancient-p number)
6858 ;; If this is "fetch-old-headered" and `invisible', then
6859 ;; we don't want this article.
6860 (and (eq gnus-fetch-old-headers 'invisible)
6861 (gnus-summary-article-ancient-p number))
6862 ;; If this is a sparsely inserted article with no children,
6863 ;; we don't want it.
6864 (and (eq gnus-build-sparse-threads 'some)
6865 (gnus-summary-article-sparse-p number)
6867 ;; If we use expunging, and this article is really
6868 ;; low-scored, then we don't want this article.
6869 (when (and gnus-summary-expunge-below
6871 (or (cdr (assq number gnus-newsgroup-scored))
6872 gnus-summary-default-score))
6873 gnus-summary-expunge-below))
6874 ;; We increase the expunge-tally here, but that has
6875 ;; nothing to do with the limits, really.
6876 (incf gnus-newsgroup-expunged-tally)
6877 ;; We also mark as read here, if that's wanted.
6878 (when (and gnus-summary-mark-below
6879 (< score gnus-summary-mark-below))
6880 (setq gnus-newsgroup-unreads
6881 (delq number gnus-newsgroup-unreads))
6882 (if gnus-newsgroup-auto-expire
6883 (push number gnus-newsgroup-expirable)
6884 (push (cons number gnus-low-score-mark)
6885 gnus-newsgroup-reads)))
6887 ;; Check NoCeM things.
6888 (if (and gnus-use-nocem
6889 (gnus-nocem-unwanted-article-p
6890 (mail-header-id (car thread))))
6892 (setq gnus-newsgroup-unreads
6893 (delq number gnus-newsgroup-unreads))
6895 ;; Nope, invisible article.
6897 ;; Ok, this article is to be visible, so we add it to the limit
6899 (push number gnus-newsgroup-limit)
6902 (defun gnus-expunge-thread (thread)
6903 "Mark all articles in THREAD as read."
6904 (let* ((number (mail-header-number (car thread))))
6905 (incf gnus-newsgroup-expunged-tally)
6906 ;; We also mark as read here, if that's wanted.
6907 (setq gnus-newsgroup-unreads
6908 (delq number gnus-newsgroup-unreads))
6909 (if gnus-newsgroup-auto-expire
6910 (push number gnus-newsgroup-expirable)
6911 (push (cons number gnus-low-score-mark)
6912 gnus-newsgroup-reads)))
6913 ;; Go recursively through all subthreads.
6914 (mapcar 'gnus-expunge-thread (cdr thread)))
6916 ;; Summary article oriented commands
6918 (defun gnus-summary-refer-parent-article (n)
6919 "Refer parent article N times.
6920 If N is negative, go to ancestor -N instead.
6921 The difference between N and the number of articles fetched is returned."
6925 (when (not (natnump n))
6930 (setq header (gnus-summary-article-header))
6931 (if (and (eq (mail-header-number header)
6932 (cdr gnus-article-current))
6933 (equal gnus-newsgroup-name
6934 (car gnus-article-current)))
6935 ;; If we try to find the parent of the currently
6936 ;; displayed article, then we take a look at the actual
6937 ;; References header, since this is slightly more
6938 ;; reliable than the References field we got from the
6941 (set-buffer gnus-original-article-buffer)
6942 (nnheader-narrow-to-headers)
6943 (unless (setq ref (message-fetch-field "references"))
6944 (setq ref (message-fetch-field "in-reply-to")))
6947 ;; It's not the current article, so we take a bet on
6948 ;; the value we got from the server.
6949 (mail-header-references header)))
6951 (not (equal ref "")))
6952 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6953 (gnus-message 1 "Couldn't find parent"))
6954 (gnus-message 1 "No references in article %d"
6955 (gnus-summary-article-number))
6958 (gnus-summary-position-point)
6961 (defun gnus-summary-refer-references ()
6962 "Fetch all articles mentioned in the References header.
6963 Return the number of articles fetched."
6965 (let ((ref (mail-header-references (gnus-summary-article-header)))
6966 (current (gnus-summary-article-number))
6970 (error "No References in the current article")
6971 ;; For each Message-ID in the References header...
6972 (while (string-match "<[^>]*>" ref)
6974 ;; ... fetch that article.
6975 (gnus-summary-refer-article
6976 (prog1 (match-string 0 ref)
6977 (setq ref (substring ref (match-end 0))))))
6978 (gnus-summary-goto-subject current)
6979 (gnus-summary-position-point)
6982 (defun gnus-summary-refer-thread (&optional limit)
6983 "Fetch all articles in the current thread.
6984 If LIMIT (the numerical prefix), fetch that many old headers instead
6985 of what's specified by the `gnus-refer-thread-limit' variable."
6987 (let ((id (mail-header-id (gnus-summary-article-header)))
6988 (limit (if limit (prefix-numeric-value limit)
6989 gnus-refer-thread-limit)))
6990 ;; We want to fetch LIMIT *old* headers, but we also have to
6991 ;; re-fetch all the headers in the current buffer, because many of
6992 ;; them may be undisplayed. So we adjust LIMIT.
6993 (when (numberp limit)
6994 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6995 (unless (eq gnus-fetch-old-headers 'invisible)
6996 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6997 ;; Retrieve the headers and read them in.
6998 (if (eq (gnus-retrieve-headers
6999 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7001 (gnus-build-all-threads)
7002 (error "Can't fetch thread from backends that don't support NOV"))
7003 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7004 (gnus-summary-limit-include-thread id)))
7006 (defun gnus-summary-refer-article (message-id)
7007 "Fetch an article specified by MESSAGE-ID."
7008 (interactive "sMessage-ID: ")
7009 (when (and (stringp message-id)
7010 (not (zerop (length message-id))))
7011 ;; Construct the correct Message-ID if necessary.
7012 ;; Suggested by tale@pawl.rpi.edu.
7013 (unless (string-match "^<" message-id)
7014 (setq message-id (concat "<" message-id)))
7015 (unless (string-match ">$" message-id)
7016 (setq message-id (concat message-id ">")))
7017 (let* ((header (gnus-id-to-header message-id))
7019 (gnus-summary-article-sparse-p
7020 (mail-header-number header))
7021 (memq (mail-header-number header)
7022 gnus-newsgroup-limit)))
7025 ;; If the article is present in the buffer we just go to it.
7027 (or (not (gnus-summary-article-sparse-p
7028 (mail-header-number header)))
7031 (gnus-summary-goto-article
7032 (mail-header-number header) nil t)
7034 (gnus-summary-update-article (mail-header-number header)))))
7036 ;; We fetch the article.
7038 (dolist (gnus-override-method (gnus-refer-article-methods))
7039 (gnus-check-server gnus-override-method)
7040 ;; Fetch the header, and display the article.
7041 (when (setq number (gnus-summary-insert-subject message-id))
7042 (gnus-summary-select-article nil nil nil number)
7044 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7046 (defun gnus-refer-article-methods ()
7047 "Return a list of referrable methods."
7049 ;; No method, so we default to current and native.
7050 ((null gnus-refer-article-method)
7051 (list gnus-current-select-method gnus-select-method))
7053 ((eq 'current gnus-refer-article-method)
7054 (list gnus-current-select-method))
7055 ;; List of select methods.
7056 ((not (and (symbolp (car gnus-refer-article-method))
7057 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7059 (dolist (method gnus-refer-article-method)
7060 (push (if (eq 'current method)
7061 gnus-current-select-method
7065 ;; One single select method.
7067 (list gnus-refer-article-method))))
7069 (defun gnus-summary-edit-parameters ()
7070 "Edit the group parameters of the current group."
7072 (gnus-group-edit-group gnus-newsgroup-name 'params))
7074 (defun gnus-summary-customize-parameters ()
7075 "Customize the group parameters of the current group."
7077 (gnus-group-customize gnus-newsgroup-name))
7079 (defun gnus-summary-enter-digest-group (&optional force)
7080 "Enter an nndoc group based on the current article.
7081 If FORCE, force a digest interpretation. If not, try
7082 to guess what the document format is."
7084 (let ((conf gnus-current-window-configuration))
7086 (gnus-summary-select-article))
7087 (setq gnus-current-window-configuration conf)
7088 (let* ((name (format "%s-%d"
7089 (gnus-group-prefixed-name
7090 gnus-newsgroup-name (list 'nndoc ""))
7092 (set-buffer gnus-summary-buffer)
7093 gnus-current-article)))
7094 (ogroup gnus-newsgroup-name)
7095 (params (append (gnus-info-params (gnus-get-info ogroup))
7096 (list (cons 'to-group ogroup))
7097 (list (cons 'save-article-group ogroup))))
7098 (case-fold-search t)
7099 (buf (current-buffer))
7102 (set-buffer gnus-original-article-buffer)
7103 ;; Have the digest group inherit the main mail address of
7104 ;; the parent article.
7105 (when (setq to-address (or (message-fetch-field "reply-to")
7106 (message-fetch-field "from")))
7107 (setq params (append
7108 (list (cons 'to-address
7109 (funcall gnus-decode-encoded-word-function
7111 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7112 (insert-buffer-substring gnus-original-article-buffer)
7113 ;; Remove lines that may lead nndoc to misinterpret the
7116 (goto-char (point-min))
7117 (or (search-forward "\n\n" nil t) (point)))
7118 (goto-char (point-min))
7119 (delete-matching-lines "^Path:\\|^From ")
7122 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7123 (gnus-newsgroup-ephemeral-ignored-charsets
7124 gnus-newsgroup-ignored-charsets))
7125 (gnus-group-read-ephemeral-group
7126 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7128 ,(if force 'mbox 'guess))) t))
7129 ;; Make all postings to this group go to the parent group.
7130 (nconc (gnus-info-params (gnus-get-info name))
7132 ;; Couldn't select this doc group.
7133 (switch-to-buffer buf)
7134 (gnus-set-global-variables)
7135 (gnus-configure-windows 'summary)
7136 (gnus-message 3 "Article couldn't be entered?"))
7137 (kill-buffer dig)))))
7139 (defun gnus-summary-read-document (n)
7140 "Open a new group based on the current article(s).
7141 This will allow you to read digests and other similar
7142 documents as newsgroups.
7143 Obeys the standard process/prefix convention."
7145 (let* ((articles (gnus-summary-work-articles n))
7146 (ogroup gnus-newsgroup-name)
7147 (params (append (gnus-info-params (gnus-get-info ogroup))
7148 (list (cons 'to-group ogroup))))
7149 article group egroup groups vgroup)
7150 (while (setq article (pop articles))
7151 (setq group (format "%s-%d" gnus-newsgroup-name article))
7152 (gnus-summary-remove-process-mark article)
7153 (when (gnus-summary-display-article article)
7156 (insert-buffer-substring gnus-original-article-buffer)
7157 ;; Remove some headers that may lead nndoc to make
7159 (message-narrow-to-head)
7160 (goto-char (point-min))
7161 (delete-matching-lines "^\\(Path\\):\\|^From ")
7164 (gnus-group-read-ephemeral-group
7165 group `(nndoc ,group (nndoc-address ,(current-buffer))
7166 (nndoc-article-type guess))
7169 ;; Make all postings to this group go to the parent group.
7170 (nconc (gnus-info-params (gnus-get-info egroup))
7172 (push egroup groups))
7173 ;; Couldn't select this doc group.
7174 (gnus-error 3 "Article couldn't be entered"))))))
7175 ;; Now we have selected all the documents.
7178 (error "None of the articles could be interpreted as documents"))
7179 ((gnus-group-read-ephemeral-group
7180 (setq vgroup (format
7181 "nnvirtual:%s-%s" gnus-newsgroup-name
7182 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7183 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7185 (cons (current-buffer) 'summary)))
7187 (error "Couldn't select virtual nndoc group")))))
7189 (defun gnus-summary-isearch-article (&optional regexp-p)
7190 "Do incremental search forward on the current article.
7191 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7193 (gnus-summary-select-article)
7194 (gnus-configure-windows 'article)
7195 (gnus-eval-in-buffer-window gnus-article-buffer
7198 (isearch-forward regexp-p))))
7200 (defun gnus-summary-search-article-forward (regexp &optional backward)
7201 "Search for an article containing REGEXP forward.
7202 If BACKWARD, search backward instead."
7205 (format "Search article %s (regexp%s): "
7206 (if current-prefix-arg "backward" "forward")
7207 (if gnus-last-search-regexp
7208 (concat ", default " gnus-last-search-regexp)
7210 current-prefix-arg))
7211 (if (string-equal regexp "")
7212 (setq regexp (or gnus-last-search-regexp ""))
7213 (setq gnus-last-search-regexp regexp)
7214 (setq gnus-article-before-search gnus-current-article))
7215 ;; Intentionally set gnus-last-article.
7216 (setq gnus-last-article gnus-article-before-search)
7217 (let ((gnus-last-article gnus-last-article))
7218 (if (gnus-summary-search-article regexp backward)
7219 (gnus-summary-show-thread)
7220 (error "Search failed: \"%s\"" regexp))))
7222 (defun gnus-summary-search-article-backward (regexp)
7223 "Search for an article containing REGEXP backward."
7226 (format "Search article backward (regexp%s): "
7227 (if gnus-last-search-regexp
7228 (concat ", default " gnus-last-search-regexp)
7230 (gnus-summary-search-article-forward regexp 'backward))
7232 (defun gnus-summary-search-article (regexp &optional backward)
7233 "Search for an article containing REGEXP.
7234 Optional argument BACKWARD means do search for backward.
7235 `gnus-select-article-hook' is not called during the search."
7236 ;; We have to require this here to make sure that the following
7237 ;; dynamic binding isn't shadowed by autoloading.
7238 (require 'gnus-async)
7240 (let ((gnus-select-article-hook nil) ;Disable hook.
7241 (gnus-article-prepare-hook nil)
7242 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7243 (gnus-use-article-prefetch nil)
7244 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7245 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7246 (sum (current-buffer))
7247 (gnus-display-mime-function nil)
7250 (gnus-save-hidden-threads
7251 (gnus-summary-select-article)
7252 (set-buffer gnus-article-buffer)
7253 (goto-char (window-point (get-buffer-window (current-buffer))))
7257 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7259 (re-search-backward regexp nil t)
7260 (re-search-forward regexp nil t))
7261 ;; We found the regexp.
7266 (get-buffer-window (current-buffer))
7270 (get-buffer-window (current-buffer))
7273 (setq point (point)))
7274 ;; We didn't find it, so we go to the next article.
7277 (while (eq found 'not)
7278 (if (not (if backward (gnus-summary-find-prev)
7279 (gnus-summary-find-next)))
7280 ;; No more articles.
7282 ;; Select the next article and adjust point.
7283 (unless (gnus-summary-article-sparse-p
7284 (gnus-summary-article-number))
7286 (gnus-summary-select-article)
7287 (set-buffer gnus-article-buffer)
7289 (goto-char (if backward (point-max) (point-min))))))))
7290 (gnus-message 7 ""))
7291 ;; Return whether we found the regexp.
7292 (when (eq found 'found)
7294 (gnus-summary-show-thread)
7295 (gnus-summary-goto-subject gnus-current-article)
7296 (gnus-summary-position-point)
7299 (defun gnus-summary-find-matching (header regexp &optional backward unread
7301 "Return a list of all articles that match REGEXP on HEADER.
7302 The search stars on the current article and goes forwards unless
7303 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7304 If UNREAD is non-nil, only unread articles will
7305 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7306 in the comparisons."
7307 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7308 (gnus-data-find-list
7309 (gnus-summary-article-number) (gnus-data-list backward))))
7310 (case-fold-search (not not-case-fold))
7313 (if (eq (car header) 'extra)
7316 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7318 (error "%s is an invalid header" header))
7319 (unless (fboundp (intern (concat "mail-header-" header)))
7320 (error "%s is not a valid header" header))
7321 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7324 (and (or (not unread) ; We want all articles...
7325 (gnus-data-unread-p d)) ; Or just unreads.
7326 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7327 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7328 (push (gnus-data-number d) articles)) ; Success!
7329 (setq data (cdr data)))
7330 (nreverse articles)))
7332 (defun gnus-summary-execute-command (header regexp command &optional backward)
7333 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7334 If HEADER is an empty string (or nil), the match is done on the entire
7335 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7337 (list (let ((completion-ignore-case t))
7340 (mapcar (lambda (string) (list string))
7341 '("Number" "Subject" "From" "Lines" "Date"
7342 "Message-ID" "Xref" "References" "Body"))
7343 nil 'require-match))
7344 (read-string "Regexp: ")
7345 (read-key-sequence "Command: ")
7346 current-prefix-arg))
7347 (when (equal header "Body")
7349 ;; Hidden thread subtrees must be searched as well.
7350 (gnus-summary-show-all-threads)
7351 ;; We don't want to change current point nor window configuration.
7353 (save-window-excursion
7354 (gnus-message 6 "Executing %s..." (key-description command))
7355 ;; We'd like to execute COMMAND interactively so as to give arguments.
7356 (gnus-execute header regexp
7357 `(call-interactively ',(key-binding command))
7359 (gnus-message 6 "Executing %s...done" (key-description command)))))
7361 (defun gnus-summary-beginning-of-article ()
7362 "Scroll the article back to the beginning."
7364 (gnus-summary-select-article)
7365 (gnus-configure-windows 'article)
7366 (gnus-eval-in-buffer-window gnus-article-buffer
7368 (goto-char (point-min))
7369 (when gnus-page-broken
7370 (gnus-narrow-to-page))))
7372 (defun gnus-summary-end-of-article ()
7373 "Scroll to the end of the article."
7375 (gnus-summary-select-article)
7376 (gnus-configure-windows 'article)
7377 (gnus-eval-in-buffer-window gnus-article-buffer
7379 (goto-char (point-max))
7381 (when gnus-page-broken
7382 (gnus-narrow-to-page))))
7384 (defun gnus-summary-print-article (&optional filename n)
7385 "Generate and print a PostScript image of the N next (mail) articles.
7387 If N is negative, print the N previous articles. If N is nil and articles
7388 have been marked with the process mark, print these instead.
7390 If the optional first argument FILENAME is nil, send the image to the
7391 printer. If FILENAME is a string, save the PostScript image in a file with
7392 that name. If FILENAME is a number, prompt the user for the name of the file
7394 (interactive (list (ps-print-preprint current-prefix-arg)
7395 current-prefix-arg))
7396 (dolist (article (gnus-summary-work-articles n))
7397 (gnus-summary-select-article nil nil 'pseudo article)
7398 (gnus-eval-in-buffer-window gnus-article-buffer
7399 (let ((buffer (generate-new-buffer " *print*")))
7402 (copy-to-buffer buffer (point-min) (point-max))
7404 (gnus-article-delete-invisible-text)
7405 (let ((ps-left-header
7408 (mail-header-subject gnus-current-headers) ")")
7410 (mail-header-from gnus-current-headers) ")")))
7413 "/pagenumberstring load"
7415 (mail-header-date gnus-current-headers) ")"))))
7416 (gnus-run-hooks 'gnus-ps-print-hook)
7418 (ps-print-buffer-with-faces filename))))
7419 (kill-buffer buffer))))))
7421 (defun gnus-summary-show-article (&optional arg)
7422 "Force re-fetching of the current article.
7423 If ARG (the prefix) is a number, show the article with the charset
7424 defined in `gnus-summary-show-article-charset-alist', or the charset
7426 If ARG (the prefix) is non-nil and not a number, show the raw article
7427 without any article massaging functions being run."
7431 (let ((gnus-newsgroup-charset
7432 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7433 (read-coding-system "Charset: ")))
7434 (gnus-newsgroup-ignored-charsets 'gnus-all))
7435 (gnus-summary-select-article nil 'force)
7436 (let ((deps gnus-newsgroup-dependencies)
7439 (set-buffer gnus-original-article-buffer)
7441 (message-narrow-to-head)
7442 (setq head (buffer-string)))
7444 (insert (format "211 %d Article retrieved.\n"
7445 (cdr gnus-article-current)))
7448 (let ((nntp-server-buffer (current-buffer)))
7449 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7450 (gnus-data-set-header
7451 (gnus-data-find (cdr gnus-article-current))
7453 (gnus-summary-update-article-line
7454 (cdr gnus-article-current) header))))
7456 ;; Select the article the normal way.
7457 (gnus-summary-select-article nil 'force))
7459 ;; We have to require this here to make sure that the following
7460 ;; dynamic binding isn't shadowed by autoloading.
7461 (require 'gnus-async)
7463 ;; Bind the article treatment functions to nil.
7464 (let ((gnus-have-all-headers t)
7465 gnus-article-prepare-hook
7466 gnus-article-decode-hook
7467 gnus-display-mime-function
7469 ;; Destroy any MIME parts.
7470 (when (gnus-buffer-live-p gnus-article-buffer)
7472 (set-buffer gnus-article-buffer)
7473 (mm-destroy-parts gnus-article-mime-handles)
7474 ;; Set it to nil for safety reason.
7475 (setq gnus-article-mime-handle-alist nil)
7476 (setq gnus-article-mime-handles nil)))
7477 (gnus-summary-select-article nil 'force))))
7478 (gnus-summary-goto-subject gnus-current-article)
7479 (gnus-summary-position-point))
7481 (defun gnus-summary-verbose-headers (&optional arg)
7482 "Toggle permanent full header display.
7483 If ARG is a positive number, turn header display on.
7484 If ARG is a negative number, turn header display off."
7486 (setq gnus-show-all-headers
7487 (cond ((or (not (numberp arg))
7489 (not gnus-show-all-headers))
7492 (gnus-summary-show-article))
7494 (defun gnus-summary-toggle-header (&optional arg)
7495 "Show the headers if they are hidden, or hide them if they are shown.
7496 If ARG is a positive number, show the entire header.
7497 If ARG is a negative number, hide the unwanted header lines."
7500 (set-buffer gnus-article-buffer)
7502 (let* ((buffer-read-only nil)
7503 (inhibit-point-motion-hooks t)
7509 (article-narrow-to-head)
7510 (gnus-article-hidden-text-p 'headers))))
7511 (goto-char (point-min))
7512 (when (search-forward "\n\n" nil t)
7513 (delete-region (point-min) (1- (point))))
7514 (goto-char (point-min))
7516 (set-buffer gnus-original-article-buffer)
7517 (goto-char (point-min))
7518 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7519 (insert-buffer-substring gnus-original-article-buffer 1 e)
7521 (narrow-to-region (point-min) (point))
7522 (article-decode-encoded-words)
7524 (let ((gnus-treat-hide-headers nil)
7525 (gnus-treat-hide-boring-headers nil))
7526 (setq gnus-article-wash-types
7527 (delq 'headers gnus-article-wash-types))
7528 (gnus-treat-article 'head))
7529 (gnus-treat-article 'head)))
7530 (gnus-set-mode-line 'article)))))
7532 (defun gnus-summary-show-all-headers ()
7533 "Make all header lines visible."
7535 (gnus-article-show-all-headers))
7537 (defun gnus-summary-caesar-message (&optional arg)
7538 "Caesar rotate the current article by 13.
7539 The numerical prefix specifies how many places to rotate each letter
7542 (gnus-summary-select-article)
7543 (let ((mail-header-separator ""))
7544 (gnus-eval-in-buffer-window gnus-article-buffer
7547 (let ((start (window-start))
7549 (message-caesar-buffer-body arg)
7550 (set-window-start (get-buffer-window (current-buffer)) start))))))
7552 (defun gnus-summary-stop-page-breaking ()
7553 "Stop page breaking in the current article."
7555 (gnus-summary-select-article)
7556 (gnus-eval-in-buffer-window gnus-article-buffer
7558 (when (gnus-visual-p 'page-marker)
7559 (let ((buffer-read-only nil))
7560 (gnus-remove-text-with-property 'gnus-prev)
7561 (gnus-remove-text-with-property 'gnus-next))
7562 (setq gnus-page-broken nil))))
7564 (defun gnus-summary-move-article (&optional n to-newsgroup
7565 select-method action)
7566 "Move the current article to a different newsgroup.
7567 If N is a positive number, move the N next articles.
7568 If N is a negative number, move the N previous articles.
7569 If N is nil and any articles have been marked with the process mark,
7570 move those articles instead.
7571 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7572 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7573 re-spool using this method.
7575 For this function to work, both the current newsgroup and the
7576 newsgroup that you want to move to have to support the `request-move'
7577 and `request-accept' functions.
7579 ACTION can be either `move' (the default), `crosspost' or `copy'."
7582 (setq action 'move))
7583 ;; Disable marking as read.
7584 (let (gnus-mark-article-hook)
7585 (save-window-excursion
7586 (gnus-summary-select-article)))
7587 ;; Check whether the source group supports the required functions.
7588 (cond ((and (eq action 'move)
7589 (not (gnus-check-backend-function
7590 'request-move-article gnus-newsgroup-name)))
7591 (error "The current group does not support article moving"))
7592 ((and (eq action 'crosspost)
7593 (not (gnus-check-backend-function
7594 'request-replace-article gnus-newsgroup-name)))
7595 (error "The current group does not support article editing")))
7596 (let ((articles (gnus-summary-work-articles n))
7597 (prefix (if (gnus-check-backend-function
7598 'request-move-article gnus-newsgroup-name)
7599 (gnus-group-real-prefix gnus-newsgroup-name)
7601 (names '((move "Move" "Moving")
7602 (copy "Copy" "Copying")
7603 (crosspost "Crosspost" "Crossposting")))
7604 (copy-buf (save-excursion
7605 (nnheader-set-temp-buffer " *copy article*")))
7606 art-group to-method new-xref article to-groups)
7607 (unless (assq action names)
7608 (error "Unknown action %s" action))
7609 ;; Read the newsgroup name.
7610 (when (and (not to-newsgroup)
7611 (not select-method))
7613 (gnus-read-move-group-name
7614 (cadr (assq action names))
7615 (symbol-value (intern (format "gnus-current-%s-group" action)))
7617 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7618 (setq to-method (or select-method
7619 (gnus-server-to-method
7620 (gnus-group-method to-newsgroup))))
7621 ;; Check the method we are to move this article to...
7622 (unless (gnus-check-backend-function
7623 'request-accept-article (car to-method))
7624 (error "%s does not support article copying" (car to-method)))
7625 (unless (gnus-check-server to-method)
7626 (error "Can't open server %s" (car to-method)))
7627 (gnus-message 6 "%s to %s: %s..."
7628 (caddr (assq action names))
7629 (or (car select-method) to-newsgroup) articles)
7631 (setq article (pop articles))
7635 ;; Move the article.
7637 ;; Remove this article from future suppression.
7638 (gnus-dup-unsuppress-article article)
7639 (gnus-request-move-article
7640 article ; Article to move
7641 gnus-newsgroup-name ; From newsgroup
7642 (nth 1 (gnus-find-method-for-group
7643 gnus-newsgroup-name)) ; Server
7644 (list 'gnus-request-accept-article
7645 to-newsgroup (list 'quote select-method)
7646 (not articles) t) ; Accept form
7647 (not articles))) ; Only save nov last time
7648 ;; Copy the article.
7651 (set-buffer copy-buf)
7652 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7653 (gnus-request-accept-article
7654 to-newsgroup select-method (not articles) t))))
7655 ;; Crosspost the article.
7656 ((eq action 'crosspost)
7657 (let ((xref (message-tokenize-header
7658 (mail-header-xref (gnus-summary-article-header article))
7660 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7663 (setq xref (list (system-name))))
7666 (mapconcat 'identity
7667 (delete "Xref:" (delete new-xref xref))
7671 (set-buffer copy-buf)
7672 ;; First put the article in the destination group.
7673 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7674 (when (consp (setq art-group
7675 (gnus-request-accept-article
7676 to-newsgroup select-method (not articles))))
7677 (setq new-xref (concat new-xref " " (car art-group)
7678 ":" (cdr art-group)))
7679 ;; Now we have the new Xrefs header, so we insert
7680 ;; it and replace the new article.
7681 (nnheader-replace-header "Xref" new-xref)
7682 (gnus-request-replace-article
7683 (cdr art-group) to-newsgroup (current-buffer))
7687 (gnus-message 1 "Couldn't %s article %s: %s"
7688 (cadr (assq action names)) article
7689 (nnheader-get-report (car to-method))))
7690 ((eq art-group 'junk)
7691 (when (eq action 'move)
7692 (gnus-summary-mark-article article gnus-canceled-mark)
7693 (gnus-message 4 "Deleted article %s" article)))
7695 (let* ((pto-group (gnus-group-prefixed-name
7696 (car art-group) to-method))
7698 (gnus-gethash pto-group gnus-newsrc-hashtb))
7699 (info (nth 2 entry))
7700 (to-group (gnus-info-group info))
7702 ;; Update the group that has been moved to.
7704 (memq action '(move copy)))
7705 (unless (member to-group to-groups)
7706 (push to-group to-groups))
7708 (unless (memq article gnus-newsgroup-unreads)
7709 (push 'read to-marks)
7711 info (gnus-add-to-range (gnus-info-read info)
7712 (list (cdr art-group)))))
7714 ;; See whether the article is to be put in the cache.
7715 (let ((marks gnus-article-mark-lists)
7716 (to-article (cdr art-group)))
7718 ;; Enter the article into the cache in the new group,
7719 ;; if that is required.
7720 (when gnus-use-cache
7721 (gnus-cache-possibly-enter-article
7723 (memq article gnus-newsgroup-marked)
7724 (memq article gnus-newsgroup-dormant)
7725 (memq article gnus-newsgroup-unreads)))
7727 (when gnus-preserve-marks
7728 ;; Copy any marks over to the new group.
7729 (when (and (equal to-group gnus-newsgroup-name)
7730 (not (memq article gnus-newsgroup-unreads)))
7731 ;; Mark this article as read in this group.
7732 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7733 (setcdr (gnus-active to-group) to-article)
7734 (setcdr gnus-newsgroup-active to-article))
7737 (when (memq article (symbol-value
7738 (intern (format "gnus-newsgroup-%s"
7740 (push (cdar marks) to-marks)
7741 ;; If the other group is the same as this group,
7742 ;; then we have to add the mark to the list.
7743 (when (equal to-group gnus-newsgroup-name)
7744 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7747 (intern (format "gnus-newsgroup-%s"
7749 ;; Copy the marks to other group.
7750 (gnus-add-marked-articles
7751 to-group (cdar marks) (list to-article) info))
7752 (setq marks (cdr marks)))
7754 (gnus-request-set-mark to-group (list (list (list to-article)
7759 (concat "(gnus-group-set-info '"
7760 (gnus-prin1-to-string (gnus-get-info to-group))
7763 ;; Update the Xref header in this article to point to
7764 ;; the new crossposted article we have just created.
7765 (when (eq action 'crosspost)
7767 (set-buffer copy-buf)
7768 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7769 (nnheader-replace-header "Xref" new-xref)
7770 (gnus-request-replace-article
7771 article gnus-newsgroup-name (current-buffer)))))
7773 ;;;!!!Why is this necessary?
7774 (set-buffer gnus-summary-buffer)
7776 (gnus-summary-goto-subject article)
7777 (when (eq action 'move)
7778 (gnus-summary-mark-article article gnus-canceled-mark))))
7779 (gnus-summary-remove-process-mark article))
7780 ;; Re-activate all groups that have been moved to.
7783 (set-buffer gnus-group-buffer)
7784 (when (gnus-group-goto-group (car to-groups) t)
7785 (gnus-group-get-new-news-this-group 1 t))
7788 (gnus-kill-buffer copy-buf)
7789 (gnus-summary-position-point)
7790 (gnus-set-mode-line 'summary)))
7792 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7793 "Move the current article to a different newsgroup.
7794 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7795 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7796 re-spool using this method."
7798 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7800 (defun gnus-summary-crosspost-article (&optional n)
7801 "Crosspost the current article to some other group."
7803 (gnus-summary-move-article n nil nil 'crosspost))
7805 (defcustom gnus-summary-respool-default-method nil
7806 "Default method for respooling an article.
7807 If nil, use to the current newsgroup method."
7808 :type '(choice (gnus-select-method :value (nnml ""))
7810 :group 'gnus-summary-mail)
7812 (defun gnus-summary-respool-article (&optional n method)
7813 "Respool the current article.
7814 The article will be squeezed through the mail spooling process again,
7815 which means that it will be put in some mail newsgroup or other
7816 depending on `nnmail-split-methods'.
7817 If N is a positive number, respool the N next articles.
7818 If N is a negative number, respool the N previous articles.
7819 If N is nil and any articles have been marked with the process mark,
7820 respool those articles instead.
7822 Respooling can be done both from mail groups and \"real\" newsgroups.
7823 In the former case, the articles in question will be moved from the
7824 current group into whatever groups they are destined to. In the
7825 latter case, they will be copied into the relevant groups."
7827 (list current-prefix-arg
7828 (let* ((methods (gnus-methods-using 'respool))
7830 (symbol-name (or gnus-summary-respool-default-method
7831 (car (gnus-find-method-for-group
7832 gnus-newsgroup-name)))))
7834 (gnus-completing-read
7835 methname "What backend do you want to use when respooling?"
7836 methods nil t nil 'gnus-mail-method-history))
7839 ((zerop (length (setq ms (gnus-servers-using-backend
7841 (list (intern method) ""))
7845 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7846 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7849 (error "No method given for respooling"))
7850 (if (assoc (symbol-name
7851 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7852 (gnus-methods-using 'respool))
7853 (gnus-summary-move-article n nil method)
7854 (gnus-summary-copy-article n nil method)))
7856 (defun gnus-summary-import-article (file)
7857 "Import an arbitrary file into a mail newsgroup."
7858 (interactive "fImport file: ")
7859 (let ((group gnus-newsgroup-name)
7860 (now (current-time))
7862 (unless (gnus-check-backend-function 'request-accept-article group)
7863 (error "%s does not support article importing" group))
7864 (or (file-readable-p file)
7865 (not (file-regular-p file))
7866 (error "Can't read %s" file))
7868 (set-buffer (gnus-get-buffer-create " *import file*"))
7870 (nnheader-insert-file-contents file)
7871 (goto-char (point-min))
7872 (unless (nnheader-article-p)
7873 ;; This doesn't look like an article, so we fudge some headers.
7874 (setq atts (file-attributes file)
7875 lines (count-lines (point-min) (point-max)))
7876 (insert "From: " (read-string "From: ") "\n"
7877 "Subject: " (read-string "Subject: ") "\n"
7878 "Date: " (message-make-date (nth 5 atts))
7880 "Message-ID: " (message-make-message-id) "\n"
7881 "Lines: " (int-to-string lines) "\n"
7882 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7883 (gnus-request-accept-article group nil t)
7884 (kill-buffer (current-buffer)))))
7886 (defun gnus-summary-article-posted-p ()
7887 "Say whether the current (mail) article is available from news as well.
7888 This will be the case if the article has both been mailed and posted."
7890 (let ((id (mail-header-references (gnus-summary-article-header)))
7891 (gnus-override-method (car (gnus-refer-article-methods))))
7892 (if (gnus-request-head id "")
7893 (gnus-message 2 "The current message was found on %s"
7894 gnus-override-method)
7895 (gnus-message 2 "The current message couldn't be found on %s"
7896 gnus-override-method)
7899 (defun gnus-summary-expire-articles (&optional now)
7900 "Expire all articles that are marked as expirable in the current group."
7902 (when (gnus-check-backend-function
7903 'request-expire-articles gnus-newsgroup-name)
7904 ;; This backend supports expiry.
7905 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7906 (expirable (if total
7908 ;; We need to update the info for
7909 ;; this group for `gnus-list-of-read-articles'
7910 ;; to give us the right answer.
7911 (gnus-run-hooks 'gnus-exit-group-hook)
7912 (gnus-summary-update-info)
7913 (gnus-list-of-read-articles gnus-newsgroup-name))
7914 (setq gnus-newsgroup-expirable
7915 (sort gnus-newsgroup-expirable '<))))
7916 (expiry-wait (if now 'immediate
7917 (gnus-group-find-parameter
7918 gnus-newsgroup-name 'expiry-wait)))
7919 (nnmail-expiry-target
7920 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7921 nnmail-expiry-target))
7924 ;; There are expirable articles in this group, so we run them
7925 ;; through the expiry process.
7926 (gnus-message 6 "Expiring articles...")
7927 (unless (gnus-check-group gnus-newsgroup-name)
7928 (error "Can't open server for %s" gnus-newsgroup-name))
7929 ;; The list of articles that weren't expired is returned.
7932 (let ((nnmail-expiry-wait-function nil)
7933 (nnmail-expiry-wait expiry-wait))
7934 (setq es (gnus-request-expire-articles
7935 expirable gnus-newsgroup-name)))
7936 (setq es (gnus-request-expire-articles
7937 expirable gnus-newsgroup-name)))
7939 (setq gnus-newsgroup-expirable es))
7940 ;; We go through the old list of expirable, and mark all
7941 ;; really expired articles as nonexistent.
7942 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7943 (let ((gnus-use-cache nil))
7945 (unless (memq (car expirable) es)
7946 (when (gnus-data-find (car expirable))
7947 (gnus-summary-mark-article
7948 (car expirable) gnus-canceled-mark)))
7949 (setq expirable (cdr expirable))))))
7950 (gnus-message 6 "Expiring articles...done")))))
7952 (defun gnus-summary-expire-articles-now ()
7953 "Expunge all expirable articles in the current group.
7954 This means that *all* articles that are marked as expirable will be
7955 deleted forever, right now."
7957 (or gnus-expert-user
7959 "Are you really, really, really sure you want to delete all these messages? ")
7961 (gnus-summary-expire-articles t))
7963 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7964 (defun gnus-summary-delete-article (&optional n)
7965 "Delete the N next (mail) articles.
7966 This command actually deletes articles. This is not a marking
7967 command. The article will disappear forever from your life, never to
7969 If N is negative, delete backwards.
7970 If N is nil and articles have been marked with the process mark,
7971 delete these instead."
7973 (unless (gnus-check-backend-function 'request-expire-articles
7974 gnus-newsgroup-name)
7975 (error "The current newsgroup does not support article deletion"))
7976 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7977 (error "Couldn't open server"))
7978 ;; Compute the list of articles to delete.
7979 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7981 (if (and gnus-novice-user
7982 (not (gnus-yes-or-no-p
7983 (format "Do you really want to delete %s forever? "
7984 (if (> (length articles) 1)
7985 (format "these %s articles" (length articles))
7988 ;; Delete the articles.
7989 (setq not-deleted (gnus-request-expire-articles
7990 articles gnus-newsgroup-name 'force))
7992 (gnus-summary-remove-process-mark (car articles))
7993 ;; The backend might not have been able to delete the article
7995 (unless (memq (car articles) not-deleted)
7996 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7997 (setq articles (cdr articles)))
7999 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8000 (gnus-summary-position-point)
8001 (gnus-set-mode-line 'summary)
8004 (defun gnus-summary-edit-article (&optional arg)
8005 "Edit the current article.
8006 This will have permanent effect only in mail groups.
8007 If ARG is nil, edit the decoded articles.
8008 If ARG is 1, edit the raw articles.
8009 If ARG is 2, edit the raw articles even in read-only groups.
8010 If ARG is 3, edit the articles with the current handles.
8011 Otherwise, allow editing of articles even in read-only
8014 (let (force raw current-handles)
8017 ((eq arg 1) (setq raw t))
8018 ((eq arg 2) (setq raw t
8020 ((eq arg 3) (setq current-handles
8021 (and (gnus-buffer-live-p gnus-article-buffer)
8022 (with-current-buffer gnus-article-buffer
8024 gnus-article-mime-handles
8025 (setq gnus-article-mime-handles nil))))))
8027 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8028 (error "Can't edit the raw article in group nndraft:drafts."))
8030 (set-buffer gnus-summary-buffer)
8031 (let ((mail-parse-charset gnus-newsgroup-charset)
8032 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8033 (gnus-set-global-variables)
8034 (when (and (not force)
8035 (gnus-group-read-only-p))
8036 (error "The current newsgroup does not support article editing"))
8037 (gnus-summary-show-article t)
8038 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8039 (with-current-buffer gnus-article-buffer
8040 (mm-enable-multibyte-mule4)))
8041 (if (equal gnus-newsgroup-name "nndraft:drafts")
8043 (gnus-article-edit-article
8046 (let ((mbl mml-buffer-list))
8047 (setq mml-buffer-list nil)
8048 (mime-to-mml ,'current-handles)
8049 (make-local-hook 'kill-buffer-hook)
8050 (let ((mbl1 mml-buffer-list))
8051 (setq mml-buffer-list mbl)
8052 (set (make-local-variable 'mml-buffer-list) mbl1))
8053 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8054 `(lambda (no-highlight)
8055 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8056 (message-options message-options)
8057 (message-options-set-recipient)
8058 (mail-parse-ignored-charsets
8059 ',gnus-newsgroup-ignored-charsets))
8060 ,(if (not raw) '(progn
8062 (mml-destroy-buffers)
8063 (remove-hook 'kill-buffer-hook
8064 'mml-destroy-buffers t)
8065 (kill-local-variable 'mml-buffer-list)))
8066 (gnus-summary-edit-article-done
8067 ,(or (mail-header-references gnus-current-headers) "")
8068 ,(gnus-group-read-only-p)
8069 ,gnus-summary-buffer no-highlight))))))))
8071 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8073 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8075 "Make edits to the current article permanent."
8078 ;; The buffer restriction contains the entire article if it exists.
8079 (when (article-goto-body)
8080 (let ((lines (count-lines (point) (point-max)))
8081 (length (- (point-max) (point)))
8082 (case-fold-search t)
8083 (body (copy-marker (point))))
8084 (goto-char (point-min))
8085 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8086 (delete-region (match-beginning 1) (match-end 1))
8087 (insert (number-to-string length)))
8088 (goto-char (point-min))
8089 (when (re-search-forward
8090 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8091 (delete-region (match-beginning 1) (match-end 1))
8092 (insert (number-to-string length)))
8093 (goto-char (point-min))
8094 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8095 (delete-region (match-beginning 1) (match-end 1))
8096 (insert (number-to-string lines))))))
8097 ;; Replace the article.
8098 (let ((buf (current-buffer)))
8100 (insert-buffer-substring buf)
8102 (if (and (not read-only)
8103 (not (gnus-request-replace-article
8104 (cdr gnus-article-current) (car gnus-article-current)
8105 (current-buffer) t)))
8106 (error "Couldn't replace article")
8107 ;; Update the summary buffer.
8109 (equal (message-tokenize-header references " ")
8110 (message-tokenize-header
8111 (or (message-fetch-field "references") "") " ")))
8112 ;; We only have to update this line.
8115 (message-narrow-to-head)
8116 (let ((head (buffer-string))
8119 (insert (format "211 %d Article retrieved.\n"
8120 (cdr gnus-article-current)))
8123 (let ((nntp-server-buffer (current-buffer)))
8124 (setq header (car (gnus-get-newsgroup-headers
8126 (set-buffer gnus-summary-buffer)
8127 gnus-newsgroup-dependencies)
8130 (set-buffer gnus-summary-buffer)
8131 (gnus-data-set-header
8132 (gnus-data-find (cdr gnus-article-current))
8134 (gnus-summary-update-article-line
8135 (cdr gnus-article-current) header))))))
8137 (set-buffer (or buffer gnus-summary-buffer))
8138 (gnus-summary-update-article (cdr gnus-article-current)))
8139 ;; Prettify the article buffer again.
8140 (unless no-highlight
8142 (set-buffer gnus-article-buffer)
8143 ;;;!!! Fix this -- article should be rehighlighted.
8144 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8145 (set-buffer gnus-original-article-buffer)
8146 (gnus-request-article
8147 (cdr gnus-article-current)
8148 (car gnus-article-current) (current-buffer))))
8149 ;; Prettify the summary buffer line.
8150 (when (gnus-visual-p 'summary-highlight 'highlight)
8151 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8153 (defun gnus-summary-edit-wash (key)
8154 "Perform editing command KEY in the article buffer."
8158 (message "%s" (concat (this-command-keys) "- "))
8161 (gnus-summary-edit-article)
8162 (execute-kbd-macro (concat (this-command-keys) key))
8163 (gnus-article-edit-done))
8167 (defun gnus-summary-respool-query (&optional silent trace)
8168 "Query where the respool algorithm would put this article."
8170 (let (gnus-mark-article-hook)
8171 (gnus-summary-select-article)
8173 (set-buffer gnus-original-article-buffer)
8175 (message-narrow-to-head)
8176 (let ((groups (nnmail-article-group 'identity trace)))
8179 (message "This message would go to %s"
8180 (mapconcat 'car groups ", "))
8181 (message "This message would go to no groups"))
8184 (defun gnus-summary-respool-trace ()
8185 "Trace where the respool algorithm would put this article.
8186 Display a buffer showing all fancy splitting patterns which matched."
8188 (gnus-summary-respool-query nil t))
8190 ;; Summary marking commands.
8192 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8193 "Mark articles which has the same subject as read, and then select the next.
8194 If UNMARK is positive, remove any kind of mark.
8195 If UNMARK is negative, tick articles."
8198 (setq unmark (prefix-numeric-value unmark)))
8200 (gnus-summary-mark-same-subject
8201 (gnus-summary-article-subject) unmark)))
8202 ;; Select next unread article. If auto-select-same mode, should
8203 ;; select the first unread article.
8204 (gnus-summary-next-article t (and gnus-auto-select-same
8205 (gnus-summary-article-subject)))
8206 (gnus-message 7 "%d article%s marked as %s"
8207 count (if (= count 1) " is" "s are")
8208 (if unmark "unread" "read"))))
8210 (defun gnus-summary-kill-same-subject (&optional unmark)
8211 "Mark articles which has the same subject as read.
8212 If UNMARK is positive, remove any kind of mark.
8213 If UNMARK is negative, tick articles."
8216 (setq unmark (prefix-numeric-value unmark)))
8218 (gnus-summary-mark-same-subject
8219 (gnus-summary-article-subject) unmark)))
8220 ;; If marked as read, go to next unread subject.
8222 ;; Go to next unread subject.
8223 (gnus-summary-next-subject 1 t))
8224 (gnus-message 7 "%d articles are marked as %s"
8225 count (if unmark "unread" "read"))))
8227 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8228 "Mark articles with same SUBJECT as read, and return marked number.
8229 If optional argument UNMARK is positive, remove any kinds of marks.
8230 If optional argument UNMARK is negative, mark articles as unread instead."
8234 ((null unmark) ; Mark as read.
8237 (gnus-summary-mark-article-as-read gnus-killed-mark)
8238 (gnus-summary-show-thread) t)
8239 (gnus-summary-find-subject subject))
8240 (setq count (1+ count))))
8241 ((> unmark 0) ; Tick.
8244 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8245 (gnus-summary-show-thread) t)
8246 (gnus-summary-find-subject subject))
8247 (setq count (1+ count))))
8248 (t ; Mark as unread.
8251 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8252 (gnus-summary-show-thread) t)
8253 (gnus-summary-find-subject subject))
8254 (setq count (1+ count)))))
8255 (gnus-set-mode-line 'summary)
8256 ;; Return the number of marked articles.
8259 (defun gnus-summary-mark-as-processable (n &optional unmark)
8260 "Set the process mark on the next N articles.
8261 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8262 the process mark instead. The difference between N and the actual
8263 number of articles marked is returned."
8265 (let ((backward (< n 0))
8270 (gnus-summary-remove-process-mark
8271 (gnus-summary-article-number))
8272 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8273 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8276 (gnus-message 7 "No more articles"))
8277 (gnus-summary-recenter)
8278 (gnus-summary-position-point)
8281 (defun gnus-summary-unmark-as-processable (n)
8282 "Remove the process mark from the next N articles.
8283 If N is negative, unmark backward instead. The difference between N and
8284 the actual number of articles unmarked is returned."
8286 (gnus-summary-mark-as-processable n t))
8288 (defun gnus-summary-unmark-all-processable ()
8289 "Remove the process mark from all articles."
8292 (while gnus-newsgroup-processable
8293 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8294 (gnus-summary-position-point))
8296 (defun gnus-summary-mark-as-expirable (n)
8297 "Mark N articles forward as expirable.
8298 If N is negative, mark backward instead. The difference between N and
8299 the actual number of articles marked is returned."
8301 (gnus-summary-mark-forward n gnus-expirable-mark))
8303 (defun gnus-summary-mark-article-as-replied (article)
8304 "Mark ARTICLE replied and update the summary line."
8305 (push article gnus-newsgroup-replied)
8306 (let ((buffer-read-only nil))
8307 (when (gnus-summary-goto-subject article nil t)
8308 (gnus-summary-update-secondary-mark article))))
8310 (defun gnus-summary-set-bookmark (article)
8311 "Set a bookmark in current article."
8312 (interactive (list (gnus-summary-article-number)))
8313 (when (or (not (get-buffer gnus-article-buffer))
8314 (not gnus-current-article)
8315 (not gnus-article-current)
8316 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8317 (error "No current article selected"))
8318 ;; Remove old bookmark, if one exists.
8319 (let ((old (assq article gnus-newsgroup-bookmarks)))
8321 (setq gnus-newsgroup-bookmarks
8322 (delq old gnus-newsgroup-bookmarks))))
8323 ;; Set the new bookmark, which is on the form
8324 ;; (article-number . line-number-in-body).
8328 (set-buffer gnus-article-buffer)
8332 (goto-char (point-min))
8333 (search-forward "\n\n" nil t)
8336 gnus-newsgroup-bookmarks)
8337 (gnus-message 6 "A bookmark has been added to the current article."))
8339 (defun gnus-summary-remove-bookmark (article)
8340 "Remove the bookmark from the current article."
8341 (interactive (list (gnus-summary-article-number)))
8342 ;; Remove old bookmark, if one exists.
8343 (let ((old (assq article gnus-newsgroup-bookmarks)))
8346 (setq gnus-newsgroup-bookmarks
8347 (delq old gnus-newsgroup-bookmarks))
8348 (gnus-message 6 "Removed bookmark."))
8349 (gnus-message 6 "No bookmark in current article."))))
8351 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8352 (defun gnus-summary-mark-as-dormant (n)
8353 "Mark N articles forward as dormant.
8354 If N is negative, mark backward instead. The difference between N and
8355 the actual number of articles marked is returned."
8357 (gnus-summary-mark-forward n gnus-dormant-mark))
8359 (defun gnus-summary-set-process-mark (article)
8360 "Set the process mark on ARTICLE and update the summary line."
8361 (setq gnus-newsgroup-processable
8363 (delq article gnus-newsgroup-processable)))
8364 (when (gnus-summary-goto-subject article)
8365 (gnus-summary-show-thread)
8366 (gnus-summary-goto-subject article)
8367 (gnus-summary-update-secondary-mark article)))
8369 (defun gnus-summary-remove-process-mark (article)
8370 "Remove the process mark from ARTICLE and update the summary line."
8371 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8372 (when (gnus-summary-goto-subject article)
8373 (gnus-summary-show-thread)
8374 (gnus-summary-goto-subject article)
8375 (gnus-summary-update-secondary-mark article)))
8377 (defun gnus-summary-set-saved-mark (article)
8378 "Set the process mark on ARTICLE and update the summary line."
8379 (push article gnus-newsgroup-saved)
8380 (when (gnus-summary-goto-subject article)
8381 (gnus-summary-update-secondary-mark article)))
8383 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8384 "Mark N articles as read forwards.
8385 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8386 The difference between N and the actual number of articles marked is
8388 Iff NO-EXPIRE, auto-expiry will be inhibited."
8390 (gnus-summary-show-thread)
8391 (let ((backward (< n 0))
8392 (gnus-summary-goto-unread
8393 (and gnus-summary-goto-unread
8394 (not (eq gnus-summary-goto-unread 'never))
8395 (not (memq mark (list gnus-unread-mark
8396 gnus-ticked-mark gnus-dormant-mark)))))
8398 (mark (or mark gnus-del-mark)))
8400 (gnus-summary-mark-article nil mark no-expire)
8401 (zerop (gnus-summary-next-subject
8403 (and gnus-summary-goto-unread
8404 (not (eq gnus-summary-goto-unread 'never)))
8408 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8409 (gnus-summary-recenter)
8410 (gnus-summary-position-point)
8411 (gnus-set-mode-line 'summary)
8414 (defun gnus-summary-mark-article-as-read (mark)
8415 "Mark the current article quickly as read with MARK."
8416 (let ((article (gnus-summary-article-number)))
8417 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8418 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8419 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8420 (push (cons article mark) gnus-newsgroup-reads)
8421 ;; Possibly remove from cache, if that is used.
8422 (when gnus-use-cache
8423 (gnus-cache-enter-remove-article article))
8424 ;; Allow the backend to change the mark.
8425 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8426 ;; Check for auto-expiry.
8427 (when (and gnus-newsgroup-auto-expire
8428 (memq mark gnus-auto-expirable-marks))
8429 (setq mark gnus-expirable-mark)
8430 ;; Let the backend know about the mark change.
8431 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8432 (push article gnus-newsgroup-expirable))
8433 ;; Set the mark in the buffer.
8434 (gnus-summary-update-mark mark 'unread)
8437 (defun gnus-summary-mark-article-as-unread (mark)
8438 "Mark the current article quickly as unread with MARK."
8439 (let* ((article (gnus-summary-article-number))
8440 (old-mark (gnus-summary-article-mark article)))
8441 ;; Allow the backend to change the mark.
8442 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8443 (if (eq mark old-mark)
8447 (gnus-error 1 "Can't mark negative article numbers")
8449 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8450 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8451 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8452 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8453 (cond ((= mark gnus-ticked-mark)
8454 (push article gnus-newsgroup-marked))
8455 ((= mark gnus-dormant-mark)
8456 (push article gnus-newsgroup-dormant))
8458 (push article gnus-newsgroup-unreads)))
8459 (gnus-pull article gnus-newsgroup-reads)
8461 ;; See whether the article is to be put in the cache.
8463 (vectorp (gnus-summary-article-header article))
8465 (gnus-cache-possibly-enter-article
8466 gnus-newsgroup-name article
8467 (= mark gnus-ticked-mark)
8468 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8471 (gnus-summary-update-mark mark 'unread)
8474 (defun gnus-summary-mark-article (&optional article mark no-expire)
8475 "Mark ARTICLE with MARK. MARK can be any character.
8476 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8477 `??' (dormant) and `?E' (expirable).
8478 If MARK is nil, then the default character `?r' is used.
8479 If ARTICLE is nil, then the article on the current line will be
8481 Iff NO-EXPIRE, auto-expiry will be inhibited."
8482 ;; The mark might be a string.
8483 (when (stringp mark)
8484 (setq mark (aref mark 0)))
8485 ;; If no mark is given, then we check auto-expiring.
8487 (setq mark gnus-del-mark))
8488 (when (and (not no-expire)
8489 gnus-newsgroup-auto-expire
8490 (memq mark gnus-auto-expirable-marks))
8491 (setq mark gnus-expirable-mark))
8492 (let ((article (or article (gnus-summary-article-number)))
8493 (old-mark (gnus-summary-article-mark article)))
8494 ;; Allow the backend to change the mark.
8495 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8496 (if (eq mark old-mark)
8499 (error "No article on current line"))
8500 (if (not (if (or (= mark gnus-unread-mark)
8501 (= mark gnus-ticked-mark)
8502 (= mark gnus-dormant-mark))
8503 (gnus-mark-article-as-unread article mark)
8504 (gnus-mark-article-as-read article mark)))
8506 ;; See whether the article is to be put in the cache.
8508 (not (= mark gnus-canceled-mark))
8509 (vectorp (gnus-summary-article-header article))
8511 (gnus-cache-possibly-enter-article
8512 gnus-newsgroup-name article
8513 (= mark gnus-ticked-mark)
8514 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8516 (when (gnus-summary-goto-subject article nil t)
8517 (let ((buffer-read-only nil))
8518 (gnus-summary-show-thread)
8520 (gnus-summary-update-mark mark 'unread)
8523 (defun gnus-summary-update-secondary-mark (article)
8524 "Update the secondary (read, process, cache) mark."
8525 (gnus-summary-update-mark
8526 (cond ((memq article gnus-newsgroup-processable)
8528 ((memq article gnus-newsgroup-cached)
8530 ((memq article gnus-newsgroup-replied)
8532 ((memq article gnus-newsgroup-saved)
8536 (when (gnus-visual-p 'summary-highlight 'highlight)
8537 (gnus-run-hooks 'gnus-summary-update-hook))
8540 (defun gnus-summary-update-mark (mark type)
8541 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8542 (buffer-read-only nil))
8543 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8545 (when (looking-at "\r")
8547 (when (<= (+ forward (point)) (point-max))
8548 ;; Go to the right position on the line.
8549 (goto-char (+ forward (point)))
8550 ;; Replace the old mark with the new mark.
8551 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8552 ;; Optionally update the marks by some user rule.
8553 (when (eq type 'unread)
8555 (gnus-data-find (gnus-summary-article-number)) mark)
8556 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8558 (defun gnus-mark-article-as-read (article &optional mark)
8559 "Enter ARTICLE in the pertinent lists and remove it from others."
8560 ;; Make the article expirable.
8561 (let ((mark (or mark gnus-del-mark)))
8562 (if (= mark gnus-expirable-mark)
8563 (push article gnus-newsgroup-expirable)
8564 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8565 ;; Remove from unread and marked lists.
8566 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8567 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8568 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8569 (push (cons article mark) gnus-newsgroup-reads)
8570 ;; Possibly remove from cache, if that is used.
8571 (when gnus-use-cache
8572 (gnus-cache-enter-remove-article article))
8575 (defun gnus-mark-article-as-unread (article &optional mark)
8576 "Enter ARTICLE in the pertinent lists and remove it from others."
8577 (let ((mark (or mark gnus-ticked-mark)))
8580 (gnus-error 1 "Can't mark negative article numbers")
8582 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8583 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8584 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8585 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8587 ;; Unsuppress duplicates?
8588 (when gnus-suppress-duplicates
8589 (gnus-dup-unsuppress-article article))
8591 (cond ((= mark gnus-ticked-mark)
8592 (push article gnus-newsgroup-marked))
8593 ((= mark gnus-dormant-mark)
8594 (push article gnus-newsgroup-dormant))
8596 (push article gnus-newsgroup-unreads)))
8597 (gnus-pull article gnus-newsgroup-reads)
8600 (defalias 'gnus-summary-mark-as-unread-forward
8601 'gnus-summary-tick-article-forward)
8602 (make-obsolete 'gnus-summary-mark-as-unread-forward
8603 'gnus-summary-tick-article-forward)
8604 (defun gnus-summary-tick-article-forward (n)
8605 "Tick N articles forwards.
8606 If N is negative, tick backwards instead.
8607 The difference between N and the number of articles ticked is returned."
8609 (gnus-summary-mark-forward n gnus-ticked-mark))
8611 (defalias 'gnus-summary-mark-as-unread-backward
8612 'gnus-summary-tick-article-backward)
8613 (make-obsolete 'gnus-summary-mark-as-unread-backward
8614 'gnus-summary-tick-article-backward)
8615 (defun gnus-summary-tick-article-backward (n)
8616 "Tick N articles backwards.
8617 The difference between N and the number of articles ticked is returned."
8619 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8621 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8622 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8623 (defun gnus-summary-tick-article (&optional article clear-mark)
8624 "Mark current article as unread.
8625 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8626 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8628 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8631 (defun gnus-summary-mark-as-read-forward (n)
8632 "Mark N articles as read forwards.
8633 If N is negative, mark backwards instead.
8634 The difference between N and the actual number of articles marked is
8637 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8639 (defun gnus-summary-mark-as-read-backward (n)
8640 "Mark the N articles as read backwards.
8641 The difference between N and the actual number of articles marked is
8644 (gnus-summary-mark-forward
8645 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8647 (defun gnus-summary-mark-as-read (&optional article mark)
8648 "Mark current article as read.
8649 ARTICLE specifies the article to be marked as read.
8650 MARK specifies a string to be inserted at the beginning of the line."
8651 (gnus-summary-mark-article article mark))
8653 (defun gnus-summary-clear-mark-forward (n)
8654 "Clear marks from N articles forward.
8655 If N is negative, clear backward instead.
8656 The difference between N and the number of marks cleared is returned."
8658 (gnus-summary-mark-forward n gnus-unread-mark))
8660 (defun gnus-summary-clear-mark-backward (n)
8661 "Clear marks from N articles backward.
8662 The difference between N and the number of marks cleared is returned."
8664 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8666 (defun gnus-summary-mark-unread-as-read ()
8667 "Intended to be used by `gnus-summary-mark-article-hook'."
8668 (when (memq gnus-current-article gnus-newsgroup-unreads)
8669 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8671 (defun gnus-summary-mark-read-and-unread-as-read ()
8672 "Intended to be used by `gnus-summary-mark-article-hook'."
8673 (let ((mark (gnus-summary-article-mark)))
8674 (when (or (gnus-unread-mark-p mark)
8675 (gnus-read-mark-p mark))
8676 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8678 (defun gnus-summary-mark-unread-as-ticked ()
8679 "Intended to be used by `gnus-summary-mark-article-hook'."
8680 (when (memq gnus-current-article gnus-newsgroup-unreads)
8681 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8683 (defun gnus-summary-mark-region-as-read (point mark all)
8684 "Mark all unread articles between point and mark as read.
8685 If given a prefix, mark all articles between point and mark as read,
8686 even ticked and dormant ones."
8687 (interactive "r\nP")
8696 (memq (setq article (gnus-summary-article-number))
8697 gnus-newsgroup-unreads))
8698 (gnus-summary-mark-article article gnus-del-mark))
8700 (gnus-summary-find-next))))))
8702 (defun gnus-summary-mark-below (score mark)
8703 "Mark articles with score less than SCORE with MARK."
8704 (interactive "P\ncMark: ")
8705 (setq score (if score
8706 (prefix-numeric-value score)
8707 (or gnus-summary-default-score 0)))
8709 (set-buffer gnus-summary-buffer)
8710 (goto-char (point-min))
8713 (and (< (gnus-summary-article-score) score)
8714 (gnus-summary-mark-article nil mark))
8715 (gnus-summary-find-next)))))
8717 (defun gnus-summary-kill-below (&optional score)
8718 "Mark articles with score below SCORE as read."
8720 (gnus-summary-mark-below score gnus-killed-mark))
8722 (defun gnus-summary-clear-above (&optional score)
8723 "Clear all marks from articles with score above SCORE."
8725 (gnus-summary-mark-above score gnus-unread-mark))
8727 (defun gnus-summary-tick-above (&optional score)
8728 "Tick all articles with score above SCORE."
8730 (gnus-summary-mark-above score gnus-ticked-mark))
8732 (defun gnus-summary-mark-above (score mark)
8733 "Mark articles with score over SCORE with MARK."
8734 (interactive "P\ncMark: ")
8735 (setq score (if score
8736 (prefix-numeric-value score)
8737 (or gnus-summary-default-score 0)))
8739 (set-buffer gnus-summary-buffer)
8740 (goto-char (point-min))
8742 (when (> (gnus-summary-article-score) score)
8743 (gnus-summary-mark-article nil mark))
8745 (gnus-summary-find-next)))))
8747 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8748 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8749 (defun gnus-summary-limit-include-expunged (&optional no-error)
8750 "Display all the hidden articles that were expunged for low scores."
8752 (let ((buffer-read-only nil))
8753 (let ((scored gnus-newsgroup-scored)
8756 (unless (gnus-summary-goto-subject (caar scored))
8757 (and (setq h (gnus-summary-article-header (caar scored)))
8758 (< (cdar scored) gnus-summary-expunge-below)
8760 (setq scored (cdr scored)))
8762 (when (not no-error)
8763 (error "No expunged articles hidden"))
8764 (goto-char (point-min))
8765 (gnus-summary-prepare-unthreaded (nreverse headers))
8766 (goto-char (point-min))
8767 (gnus-summary-position-point)
8770 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8771 "Mark all unread articles in this newsgroup as read.
8772 If prefix argument ALL is non-nil, ticked and dormant articles will
8773 also be marked as read.
8774 If QUIETLY is non-nil, no questions will be asked.
8775 If TO-HERE is non-nil, it should be a point in the buffer. All
8776 articles before this point will be marked as read.
8777 Note that this function will only catch up the unread article
8778 in the current summary buffer limitation.
8779 The number of articles marked as read is returned."
8784 (not gnus-interactive-catchup) ;Without confirmation?
8788 "Mark absolutely all articles as read? "
8789 "Mark all unread articles as read? ")))
8791 (not gnus-newsgroup-adaptive)
8792 (not gnus-newsgroup-auto-expire)
8793 (not gnus-suppress-duplicates)
8794 (or (not gnus-use-cache)
8795 (eq gnus-use-cache 'passive)))
8798 (setq gnus-newsgroup-marked nil
8799 gnus-newsgroup-dormant nil))
8800 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8801 ;; We actually mark all articles as canceled, which we
8802 ;; have to do when using auto-expiry or adaptive scoring.
8803 (gnus-summary-show-all-threads)
8804 (when (gnus-summary-first-subject (not all) t)
8806 (if to-here (< (point) to-here) t)
8807 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8808 (gnus-summary-find-next (not all) nil nil t))))
8809 (gnus-set-mode-line 'summary))
8811 (gnus-summary-position-point)))
8813 (defun gnus-summary-catchup-to-here (&optional all)
8814 "Mark all unticked articles before the current one as read.
8815 If ALL is non-nil, also mark ticked and dormant articles as read."
8818 (gnus-save-hidden-threads
8819 (let ((beg (point)))
8820 ;; We check that there are unread articles.
8821 (when (or all (gnus-summary-find-prev))
8822 (gnus-summary-catchup all t beg)))))
8823 (gnus-summary-position-point))
8825 (defun gnus-summary-catchup-all (&optional quietly)
8826 "Mark all articles in this newsgroup as read."
8828 (gnus-summary-catchup t quietly))
8830 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8831 "Mark all unread articles in this group as read, then exit.
8832 If prefix argument ALL is non-nil, all articles are marked as read."
8834 (when (gnus-summary-catchup all quietly nil 'fast)
8835 ;; Select next newsgroup or exit.
8836 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8837 (eq gnus-auto-select-next 'quietly))
8838 (gnus-summary-next-group nil)
8839 (gnus-summary-exit))))
8841 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8842 "Mark all articles in this newsgroup as read, and then exit."
8844 (gnus-summary-catchup-and-exit t quietly))
8846 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8847 "Mark all articles in this group as read and select the next group.
8848 If given a prefix, mark all articles, unread as well as ticked, as
8852 (gnus-summary-catchup all))
8853 (gnus-summary-next-group))
8859 (defmacro gnus-with-article (article &rest forms)
8860 "Select ARTICLE and perform FORMS in the original article buffer.
8861 Then replace the article with the result."
8863 ;; We don't want the article to be marked as read.
8864 (let (gnus-mark-article-hook)
8865 (gnus-summary-select-article t t nil ,article))
8866 (set-buffer gnus-original-article-buffer)
8868 (if (not (gnus-check-backend-function
8869 'request-replace-article (car gnus-article-current)))
8870 (gnus-message 5 "Read-only group; not replacing")
8871 (unless (gnus-request-replace-article
8872 ,article (car gnus-article-current)
8874 (error "Couldn't replace article")))
8875 ;; The cache and backlog have to be flushed somewhat.
8876 (when gnus-keep-backlog
8877 (gnus-backlog-remove-article
8878 (car gnus-article-current) (cdr gnus-article-current)))
8879 (when gnus-use-cache
8880 (gnus-cache-update-article
8881 (car gnus-article-current) (cdr gnus-article-current)))))
8883 (put 'gnus-with-article 'lisp-indent-function 1)
8884 (put 'gnus-with-article 'edebug-form-spec '(form body))
8886 ;; Thread-based commands.
8888 (defun gnus-summary-articles-in-thread (&optional article)
8889 "Return a list of all articles in the current thread.
8890 If ARTICLE is non-nil, return all articles in the thread that starts
8892 (let* ((article (or article (gnus-summary-article-number)))
8893 (data (gnus-data-find-list article))
8894 (top-level (gnus-data-level (car data)))
8896 (cond ((null gnus-thread-operation-ignore-subject)
8897 (gnus-simplify-subject-re
8898 (mail-header-subject (gnus-data-header (car data)))))
8899 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8900 (gnus-simplify-subject-fuzzy
8901 (mail-header-subject (gnus-data-header (car data)))))
8903 (end-point (save-excursion
8904 (if (gnus-summary-go-to-next-thread)
8905 (point) (point-max))))
8908 (< (gnus-data-pos (car data)) end-point))
8909 (when (or (not top-subject)
8910 (string= top-subject
8911 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8912 (gnus-simplify-subject-fuzzy
8913 (mail-header-subject
8914 (gnus-data-header (car data))))
8915 (gnus-simplify-subject-re
8916 (mail-header-subject
8917 (gnus-data-header (car data)))))))
8918 (push (gnus-data-number (car data)) articles))
8919 (unless (and (setq data (cdr data))
8920 (> (gnus-data-level (car data)) top-level))
8922 ;; Return the list of articles.
8923 (nreverse articles)))
8925 (defun gnus-summary-rethread-current ()
8926 "Rethread the thread the current article is part of."
8928 (let* ((gnus-show-threads t)
8929 (article (gnus-summary-article-number))
8930 (id (mail-header-id (gnus-summary-article-header)))
8931 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8933 (error "No article on the current line"))
8934 (gnus-rebuild-thread id)
8935 (gnus-summary-goto-subject article)))
8937 (defun gnus-summary-reparent-thread ()
8938 "Make the current article child of the marked (or previous) article.
8940 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8941 is non-nil or the Subject: of both articles are the same."
8943 (unless (not (gnus-group-read-only-p))
8944 (error "The current newsgroup does not support article editing"))
8945 (unless (<= (length gnus-newsgroup-processable) 1)
8946 (error "No more than one article may be marked"))
8947 (save-window-excursion
8948 (let ((gnus-article-buffer " *reparent*")
8949 (current-article (gnus-summary-article-number))
8950 ;; First grab the marked article, otherwise one line up.
8951 (parent-article (if (not (null gnus-newsgroup-processable))
8952 (car gnus-newsgroup-processable)
8954 (if (eq (forward-line -1) 0)
8955 (gnus-summary-article-number)
8956 (error "Beginning of summary buffer"))))))
8957 (unless (not (eq current-article parent-article))
8958 (error "An article may not be self-referential"))
8959 (let ((message-id (mail-header-id
8960 (gnus-summary-article-header parent-article))))
8961 (unless (and message-id (not (equal message-id "")))
8962 (error "No message-id in desired parent"))
8963 (gnus-with-article current-article
8965 (goto-char (point-min))
8966 (message-narrow-to-head)
8967 (if (re-search-forward "^References: " nil t)
8969 (re-search-forward "^[^ \t]" nil t)
8972 (insert " " message-id))
8973 (insert "References: " message-id "\n"))))
8974 (set-buffer gnus-summary-buffer)
8975 (gnus-summary-unmark-all-processable)
8976 (gnus-summary-update-article current-article)
8977 (gnus-summary-rethread-current)
8978 (gnus-message 3 "Article %d is now the child of article %d"
8979 current-article parent-article)))))
8981 (defun gnus-summary-toggle-threads (&optional arg)
8982 "Toggle showing conversation threads.
8983 If ARG is positive number, turn showing conversation threads on."
8985 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8986 (setq gnus-show-threads
8987 (if (null arg) (not gnus-show-threads)
8988 (> (prefix-numeric-value arg) 0)))
8989 (gnus-summary-prepare)
8990 (gnus-summary-goto-subject current)
8991 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8992 (gnus-summary-position-point)))
8994 (defun gnus-summary-show-all-threads ()
8998 (let ((buffer-read-only nil))
8999 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9000 (gnus-summary-position-point))
9002 (defun gnus-summary-show-thread ()
9003 "Show thread subtrees.
9004 Returns nil if no thread was there to be shown."
9006 (let ((buffer-read-only nil)
9008 ;; first goto end then to beg, to have point at beg after let
9009 (end (progn (end-of-line) (point)))
9010 (beg (progn (beginning-of-line) (point))))
9012 ;; Any hidden lines here?
9013 (search-forward "\r" end t)
9014 (subst-char-in-region beg end ?\^M ?\n t)
9016 (gnus-summary-position-point))))
9018 (defun gnus-summary-hide-all-threads ()
9019 "Hide all thread subtrees."
9022 (goto-char (point-min))
9023 (gnus-summary-hide-thread)
9024 (while (zerop (gnus-summary-next-thread 1 t))
9025 (gnus-summary-hide-thread)))
9026 (gnus-summary-position-point))
9028 (defun gnus-summary-hide-thread ()
9029 "Hide thread subtrees.
9030 Returns nil if no threads were there to be hidden."
9032 (let ((buffer-read-only nil)
9034 (article (gnus-summary-article-number)))
9036 ;; Go forward until either the buffer ends or the subthread
9038 (when (and (not (eobp))
9039 (or (zerop (gnus-summary-next-thread 1 t))
9040 (goto-char (point-max))))
9042 (if (and (> (point) start)
9043 (search-backward "\n" start t))
9045 (subst-char-in-region start (point) ?\n ?\^M)
9046 (gnus-summary-goto-subject article))
9050 (defun gnus-summary-go-to-next-thread (&optional previous)
9051 "Go to the same level (or less) next thread.
9052 If PREVIOUS is non-nil, go to previous thread instead.
9053 Return the article number moved to, or nil if moving was impossible."
9054 (let ((level (gnus-summary-thread-level))
9055 (way (if previous -1 1))
9058 (while (and (not (eobp))
9059 (< level (gnus-summary-thread-level)))
9067 (gnus-summary-article-number)
9070 (defun gnus-summary-next-thread (n &optional silent)
9071 "Go to the same level next N'th thread.
9072 If N is negative, search backward instead.
9073 Returns the difference between N and the number of skips actually
9076 If SILENT, don't output messages."
9078 (let ((backward (< n 0))
9081 (gnus-summary-go-to-next-thread backward))
9084 (gnus-summary-position-point))
9085 (when (and (not silent) (/= 0 n))
9086 (gnus-message 7 "No more threads"))
9089 (defun gnus-summary-prev-thread (n)
9090 "Go to the same level previous N'th thread.
9091 Returns the difference between N and the number of skips actually
9094 (gnus-summary-next-thread (- n)))
9096 (defun gnus-summary-go-down-thread ()
9097 "Go down one level in the current thread."
9098 (let ((children (gnus-summary-article-children)))
9100 (gnus-summary-goto-subject (car children)))))
9102 (defun gnus-summary-go-up-thread ()
9103 "Go up one level in the current thread."
9104 (let ((parent (gnus-summary-article-parent)))
9106 (gnus-summary-goto-subject parent))))
9108 (defun gnus-summary-down-thread (n)
9109 "Go down thread N steps.
9110 If N is negative, go up instead.
9111 Returns the difference between N and how many steps down that were
9117 (if up (gnus-summary-go-up-thread)
9118 (gnus-summary-go-down-thread)))
9120 (gnus-summary-position-point)
9122 (gnus-message 7 "Can't go further"))
9125 (defun gnus-summary-up-thread (n)
9126 "Go up thread N steps.
9127 If N is negative, go up instead.
9128 Returns the difference between N and how many steps down that were
9131 (gnus-summary-down-thread (- n)))
9133 (defun gnus-summary-top-thread ()
9134 "Go to the top of the thread."
9136 (while (gnus-summary-go-up-thread))
9137 (gnus-summary-article-number))
9139 (defun gnus-summary-kill-thread (&optional unmark)
9140 "Mark articles under current thread as read.
9141 If the prefix argument is positive, remove any kinds of marks.
9142 If the prefix argument is negative, tick articles instead."
9145 (setq unmark (prefix-numeric-value unmark)))
9146 (let ((articles (gnus-summary-articles-in-thread)))
9148 ;; Expand the thread.
9149 (gnus-summary-show-thread)
9150 ;; Mark all the articles.
9152 (gnus-summary-goto-subject (car articles))
9153 (cond ((null unmark)
9154 (gnus-summary-mark-article-as-read gnus-killed-mark))
9156 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9158 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9159 (setq articles (cdr articles))))
9160 ;; Hide killed subtrees.
9162 gnus-thread-hide-killed
9163 (gnus-summary-hide-thread))
9164 ;; If marked as read, go to next unread subject.
9166 ;; Go to next unread subject.
9167 (gnus-summary-next-subject 1 t)))
9168 (gnus-set-mode-line 'summary))
9170 ;; Summary sorting commands
9172 (defun gnus-summary-sort-by-number (&optional reverse)
9173 "Sort the summary buffer by article number.
9174 Argument REVERSE means reverse order."
9176 (gnus-summary-sort 'number reverse))
9178 (defun gnus-summary-sort-by-author (&optional reverse)
9179 "Sort the summary buffer by author name alphabetically.
9180 If `case-fold-search' is non-nil, case of letters is ignored.
9181 Argument REVERSE means reverse order."
9183 (gnus-summary-sort 'author reverse))
9185 (defun gnus-summary-sort-by-subject (&optional reverse)
9186 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9187 If `case-fold-search' is non-nil, case of letters is ignored.
9188 Argument REVERSE means reverse order."
9190 (gnus-summary-sort 'subject reverse))
9192 (defun gnus-summary-sort-by-date (&optional reverse)
9193 "Sort the summary buffer by date.
9194 Argument REVERSE means reverse order."
9196 (gnus-summary-sort 'date reverse))
9198 (defun gnus-summary-sort-by-score (&optional reverse)
9199 "Sort the summary buffer by score.
9200 Argument REVERSE means reverse order."
9202 (gnus-summary-sort 'score reverse))
9204 (defun gnus-summary-sort-by-lines (&optional reverse)
9205 "Sort the summary buffer by the number of lines.
9206 Argument REVERSE means reverse order."
9208 (gnus-summary-sort 'lines reverse))
9210 (defun gnus-summary-sort-by-chars (&optional reverse)
9211 "Sort the summary buffer by article length.
9212 Argument REVERSE means reverse order."
9214 (gnus-summary-sort 'chars reverse))
9216 (defun gnus-summary-sort (predicate reverse)
9217 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9218 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9219 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9220 (gnus-thread-sort-functions
9225 (gnus-sort-gathered-threads-function
9226 gnus-thread-sort-functions)
9227 (gnus-article-sort-functions
9233 (gnus-summary-prepare-hook nil))
9234 ;; We do the sorting by regenerating the threads.
9235 (gnus-summary-prepare)
9236 ;; Hide subthreads if needed.
9237 (when (and gnus-show-threads gnus-thread-hide-subtree)
9238 (gnus-summary-hide-all-threads))))
9240 ;; Summary saving commands.
9242 (defun gnus-summary-save-article (&optional n not-saved)
9243 "Save the current article using the default saver function.
9244 If N is a positive number, save the N next articles.
9245 If N is a negative number, save the N previous articles.
9246 If N is nil and any articles have been marked with the process mark,
9247 save those articles instead.
9248 The variable `gnus-default-article-saver' specifies the saver function."
9250 (let* ((articles (gnus-summary-work-articles n))
9251 (save-buffer (save-excursion
9252 (nnheader-set-temp-buffer " *Gnus Save*")))
9253 (num (length articles))
9255 (dolist (article articles)
9256 (setq header (gnus-summary-article-header article))
9257 (if (not (vectorp header))
9258 ;; This is a pseudo-article.
9259 (if (assq 'name header)
9260 (gnus-copy-file (cdr (assq 'name header)))
9261 (gnus-message 1 "Article %d is unsaveable" article))
9262 ;; This is a real article.
9263 (save-window-excursion
9264 (gnus-summary-select-article t nil nil article))
9266 (set-buffer save-buffer)
9268 (insert-buffer-substring gnus-original-article-buffer))
9269 (setq file (gnus-article-save save-buffer file num))
9270 (gnus-summary-remove-process-mark article)
9272 (gnus-summary-set-saved-mark article))))
9273 (gnus-kill-buffer save-buffer)
9274 (gnus-summary-position-point)
9275 (gnus-set-mode-line 'summary)
9278 (defun gnus-summary-pipe-output (&optional arg)
9279 "Pipe the current article to a subprocess.
9280 If N is a positive number, pipe the N next articles.
9281 If N is a negative number, pipe the N previous articles.
9282 If N is nil and any articles have been marked with the process mark,
9283 pipe those articles instead."
9286 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9287 (gnus-summary-save-article arg t))
9288 (gnus-configure-windows 'pipe))
9290 (defun gnus-summary-save-article-mail (&optional arg)
9291 "Append the current article to an mail file.
9292 If N is a positive number, save the N next articles.
9293 If N is a negative number, save the N previous articles.
9294 If N is nil and any articles have been marked with the process mark,
9295 save those articles instead."
9298 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9299 (gnus-summary-save-article arg)))
9301 (defun gnus-summary-save-article-rmail (&optional arg)
9302 "Append the current article to an rmail file.
9303 If N is a positive number, save the N next articles.
9304 If N is a negative number, save the N previous articles.
9305 If N is nil and any articles have been marked with the process mark,
9306 save those articles instead."
9309 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9310 (gnus-summary-save-article arg)))
9312 (defun gnus-summary-save-article-file (&optional arg)
9313 "Append the current article to a file.
9314 If N is a positive number, save the N next articles.
9315 If N is a negative number, save the N previous articles.
9316 If N is nil and any articles have been marked with the process mark,
9317 save those articles instead."
9320 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9321 (gnus-summary-save-article arg)))
9323 (defun gnus-summary-write-article-file (&optional arg)
9324 "Write the current article to a file, deleting the previous file.
9325 If N is a positive number, save the N next articles.
9326 If N is a negative number, save the N previous articles.
9327 If N is nil and any articles have been marked with the process mark,
9328 save those articles instead."
9331 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9332 (gnus-summary-save-article arg)))
9334 (defun gnus-summary-save-article-body-file (&optional arg)
9335 "Append the current article body to a file.
9336 If N is a positive number, save the N next articles.
9337 If N is a negative number, save the N previous articles.
9338 If N is nil and any articles have been marked with the process mark,
9339 save those articles instead."
9342 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9343 (gnus-summary-save-article arg)))
9345 (defun gnus-summary-pipe-message (program)
9346 "Pipe the current article through PROGRAM."
9347 (interactive "sProgram: ")
9348 (gnus-summary-select-article)
9349 (let ((mail-header-separator ""))
9350 (gnus-eval-in-buffer-window gnus-article-buffer
9353 (let ((start (window-start))
9355 (message-pipe-buffer-body program)
9356 (set-window-start (get-buffer-window (current-buffer)) start))))))
9358 (defun gnus-get-split-value (methods)
9359 "Return a value based on the split METHODS."
9360 (let (split-name method result match)
9363 (set-buffer gnus-original-article-buffer)
9365 (nnheader-narrow-to-headers)
9366 (while (and methods (not split-name))
9367 (goto-char (point-min))
9368 (setq method (pop methods))
9369 (setq match (car method))
9372 ;; Regular expression.
9374 (re-search-forward match nil t)))
9375 ((gnus-functionp match)
9379 (setq result (funcall match gnus-newsgroup-name))))
9384 (setq result (eval match)))))
9385 (setq split-name (cdr method))
9386 (cond ((stringp result)
9387 (push (expand-file-name
9388 result gnus-article-save-directory)
9391 (setq split-name (append result split-name)))))))))
9392 (nreverse split-name)))
9394 (defun gnus-valid-move-group-p (group)
9397 (symbol-value group)
9398 (gnus-get-function (gnus-find-method-for-group
9399 (symbol-name group)) 'request-accept-article t)))
9401 (defun gnus-read-move-group-name (prompt default articles prefix)
9402 "Read a group name."
9403 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9404 (minibuffer-confirm-incomplete nil) ; XEmacs
9408 (if (> (length articles) 1)
9409 (format "these %d articles" (length articles))
9414 (gnus-completing-read default prom
9416 'gnus-valid-move-group-p
9418 'gnus-group-history))
9419 ((= 1 (length split-name))
9420 (gnus-completing-read (car split-name) prom
9422 'gnus-valid-move-group-p
9424 'gnus-group-history))
9426 (gnus-completing-read nil prom
9427 (mapcar (lambda (el) (list el))
9428 (nreverse split-name))
9430 'gnus-group-history))))
9431 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9433 (if (or (string= to-newsgroup "")
9434 (string= to-newsgroup prefix))
9435 (setq to-newsgroup default))
9436 (unless to-newsgroup
9437 (error "No group name entered"))
9438 (or (gnus-active to-newsgroup)
9439 (gnus-activate-group to-newsgroup nil nil to-method)
9440 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9442 (or (and (gnus-request-create-group to-newsgroup to-method)
9443 (gnus-activate-group
9444 to-newsgroup nil nil to-method)
9445 (gnus-subscribe-group to-newsgroup))
9446 (error "Couldn't create group %s" to-newsgroup)))
9447 (error "No such group: %s" to-newsgroup)))
9450 (defun gnus-summary-save-parts (type dir n &optional reverse)
9451 "Save parts matching TYPE to DIR.
9452 If REVERSE, save parts that do not match TYPE."
9454 (list (read-string "Save parts of type: "
9455 (or (car gnus-summary-save-parts-type-history)
9456 gnus-summary-save-parts-default-mime)
9457 'gnus-summary-save-parts-type-history)
9458 (setq gnus-summary-save-parts-last-directory
9459 (read-file-name "Save to directory: "
9460 gnus-summary-save-parts-last-directory
9462 current-prefix-arg))
9463 (gnus-summary-iterate n
9464 (let ((gnus-display-mime-function nil)
9465 (gnus-inhibit-treatment t))
9466 (gnus-summary-select-article))
9468 (set-buffer gnus-article-buffer)
9469 (let ((handles (or gnus-article-mime-handles
9470 (mm-dissect-buffer) (mm-uu-dissect))))
9472 (gnus-summary-save-parts-1 type dir handles reverse)
9473 (unless gnus-article-mime-handles ;; Don't destroy this case.
9474 (mm-destroy-parts handles)))))))
9476 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9477 (if (stringp (car handle))
9478 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9481 (not (string-match type (mm-handle-media-type handle)))
9482 (string-match type (mm-handle-media-type handle)))
9483 (let ((file (expand-file-name
9484 (file-name-nondirectory
9486 (mail-content-type-get
9487 (mm-handle-disposition handle) 'filename)
9488 (concat gnus-newsgroup-name
9489 "." (number-to-string
9490 (cdr gnus-article-current)))))
9492 (unless (file-exists-p file)
9493 (mm-save-part-to-file handle file))))))
9495 ;; Summary extract commands
9497 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9498 (let ((buffer-read-only nil)
9499 (article (gnus-summary-article-number))
9501 (unless (gnus-summary-goto-subject article)
9502 (error "No such article: %d" article))
9503 (gnus-summary-position-point)
9504 ;; If all commands are to be bunched up on one line, we collect
9506 (unless gnus-view-pseudos-separately
9507 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9510 (setq action (cdr (assq 'action (car ps))))
9511 (setq files (list (cdr (assq 'name (car ps)))))
9512 (while (and ps (cdr ps)
9513 (string= (or action "1")
9514 (or (cdr (assq 'action (cadr ps))) "2")))
9515 (push (cdr (assq 'name (cadr ps))) files)
9516 (setcdr ps (cddr ps)))
9518 (when (not (string-match "%s" action))
9521 (when (assq 'execute (car ps))
9522 (setcdr (assq 'execute (car ps))
9523 (funcall (if (string-match "%s" action)
9532 (setq ps (cdr ps)))))
9533 (if (and gnus-view-pseudos (not not-view))
9535 (when (assq 'execute (car pslist))
9536 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9537 (eq gnus-view-pseudos 'not-confirm)))
9538 (setq pslist (cdr pslist)))
9541 (setq after-article (or (cdr (assq 'article (car pslist)))
9542 (gnus-summary-article-number)))
9543 (gnus-summary-goto-subject after-article)
9546 (insert " " (file-name-nondirectory
9547 (cdr (assq 'name (car pslist))))
9548 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9550 (forward-line -1) ; back to `b'
9551 (gnus-add-text-properties
9552 b (1- e) (list 'gnus-number gnus-reffed-article-number
9553 gnus-mouse-face-prop gnus-mouse-face))
9555 after-article gnus-reffed-article-number
9556 gnus-unread-mark b (car pslist) 0 (- e b))
9557 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9558 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9559 (setq pslist (cdr pslist)))))))
9561 (defun gnus-pseudos< (p1 p2)
9562 (let ((c1 (cdr (assq 'action p1)))
9563 (c2 (cdr (assq 'action p2))))
9564 (and c1 c2 (string< c1 c2))))
9566 (defun gnus-request-pseudo-article (props)
9567 (cond ((assq 'execute props)
9568 (gnus-execute-command (cdr (assq 'execute props)))))
9569 (let ((gnus-current-article (gnus-summary-article-number)))
9570 (gnus-run-hooks 'gnus-mark-article-hook)))
9572 (defun gnus-execute-command (command &optional automatic)
9574 (gnus-article-setup-buffer)
9575 (set-buffer gnus-article-buffer)
9576 (setq buffer-read-only nil)
9577 (let ((command (if automatic command
9578 (read-string "Command: " (cons command 0)))))
9580 (insert "$ " command "\n\n")
9581 (if gnus-view-pseudo-asynchronously
9582 (start-process "gnus-execute" (current-buffer) shell-file-name
9583 shell-command-switch command)
9584 (call-process shell-file-name nil t nil
9585 shell-command-switch command)))))
9587 ;; Summary kill commands.
9589 (defun gnus-summary-edit-global-kill (article)
9590 "Edit the \"global\" kill file."
9591 (interactive (list (gnus-summary-article-number)))
9592 (gnus-group-edit-global-kill article))
9594 (defun gnus-summary-edit-local-kill ()
9595 "Edit a local kill file applied to the current newsgroup."
9597 (setq gnus-current-headers (gnus-summary-article-header))
9598 (gnus-group-edit-local-kill
9599 (gnus-summary-article-number) gnus-newsgroup-name))
9603 (defun gnus-read-header (id &optional header)
9604 "Read the headers of article ID and enter them into the Gnus system."
9605 (let ((group gnus-newsgroup-name)
9606 (gnus-override-method
9608 gnus-override-method
9609 (and (gnus-news-group-p gnus-newsgroup-name)
9610 (car (gnus-refer-article-methods)))))
9612 ;; First we check to see whether the header in question is already
9615 ;; This is a Message-ID.
9616 (setq header (or header (gnus-id-to-header id)))
9617 ;; This is an article number.
9618 (setq header (or header (gnus-summary-article-header id))))
9620 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9621 ;; We have found the header.
9623 ;; If this is a sparse article, we have to nix out its
9624 ;; previous entry in the thread hashtb.
9626 (gnus-summary-article-sparse-p (mail-header-number header)))
9627 (let* ((parent (gnus-parent-id (mail-header-references header)))
9628 (thread (and parent (gnus-id-to-thread parent))))
9630 (delq (assq header thread) thread))))
9631 ;; We have to really fetch the header to this article.
9633 (set-buffer nntp-server-buffer)
9634 (when (setq where (gnus-request-head id group))
9635 (nnheader-fold-continuation-lines)
9636 (goto-char (point-max))
9638 (goto-char (point-min))
9642 ((cdr where) (cdr where))
9643 (header (mail-header-number header))
9644 (t gnus-reffed-article-number))
9646 (insert " Article retrieved.\n"))
9648 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9649 () ; Malformed head.
9650 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9651 (when (and (stringp id)
9652 (not (string= (gnus-group-real-name group)
9654 ;; If we fetched by Message-ID and the article came
9655 ;; from a different group, we fudge some bogus article
9656 ;; numbers for this article.
9657 (mail-header-set-number header gnus-reffed-article-number))
9659 (set-buffer gnus-summary-buffer)
9660 (decf gnus-reffed-article-number)
9661 (gnus-remove-header (mail-header-number header))
9662 (push header gnus-newsgroup-headers)
9663 (setq gnus-current-headers header)
9664 (push (mail-header-number header) gnus-newsgroup-limit)))
9667 (defun gnus-remove-header (number)
9668 "Remove header NUMBER from `gnus-newsgroup-headers'."
9669 (if (and gnus-newsgroup-headers
9670 (= number (mail-header-number (car gnus-newsgroup-headers))))
9671 (pop gnus-newsgroup-headers)
9672 (let ((headers gnus-newsgroup-headers))
9673 (while (and (cdr headers)
9674 (not (= number (mail-header-number (cadr headers)))))
9677 (setcdr headers (cddr headers))))))
9680 ;;; summary highlights
9683 (defun gnus-highlight-selected-summary ()
9684 "Highlight selected article in summary buffer."
9685 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9686 (when gnus-summary-selected-face
9688 (let* ((beg (progn (beginning-of-line) (point)))
9689 (end (progn (end-of-line) (point)))
9690 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9691 (from (if (get-text-property beg gnus-mouse-face-prop)
9693 (or (next-single-property-change
9694 beg gnus-mouse-face-prop nil end)
9699 (or (next-single-property-change
9700 from gnus-mouse-face-prop nil end)
9702 ;; If no mouse-face prop on line we will have to = from = end,
9703 ;; so we highlight the entire line instead.
9704 (when (= (+ to 2) from)
9707 (if gnus-newsgroup-selected-overlay
9708 ;; Move old overlay.
9710 gnus-newsgroup-selected-overlay from to (current-buffer))
9711 ;; Create new overlay.
9713 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9714 'face gnus-summary-selected-face))))))
9716 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9717 (defun gnus-summary-highlight-line ()
9718 "Highlight current line according to `gnus-summary-highlight'."
9719 (let* ((list gnus-summary-highlight)
9721 (end (progn (end-of-line) (point)))
9722 ;; now find out where the line starts and leave point there.
9723 (beg (progn (beginning-of-line) (point)))
9724 (article (gnus-summary-article-number))
9725 (score (or (cdr (assq (or article gnus-current-article)
9726 gnus-newsgroup-scored))
9727 gnus-summary-default-score 0))
9728 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9729 (inhibit-read-only t))
9730 ;; Eval the cars of the lists until we find a match.
9731 (let ((default gnus-summary-default-score))
9733 (not (eval (caar list))))
9734 (setq list (cdr list))))
9735 (let ((face (cdar list)))
9736 (unless (eq face (get-text-property beg 'face))
9737 (gnus-put-text-property-excluding-characters-with-faces
9739 (setq face (if (boundp face) (symbol-value face) face)))
9740 (when gnus-summary-highlight-line-function
9741 (funcall gnus-summary-highlight-line-function article face))))
9744 (defun gnus-update-read-articles (group unread &optional compute)
9745 "Update the list of read articles in GROUP."
9746 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9747 (entry (gnus-gethash group gnus-newsrc-hashtb))
9748 (info (nth 2 entry))
9750 (unread (sort (copy-sequence unread) '<))
9752 (if (or (not info) (not active))
9753 ;; There is no info on this group if it was, in fact,
9754 ;; killed. Gnus stores no information on killed groups, so
9755 ;; there's nothing to be done.
9756 ;; One could store the information somewhere temporarily,
9757 ;; perhaps... Hmmm...
9759 ;; Remove any negative articles numbers.
9760 (while (and unread (< (car unread) 0))
9761 (setq unread (cdr unread)))
9762 ;; Remove any expired article numbers
9763 (while (and unread (< (car unread) (car active)))
9764 (setq unread (cdr unread)))
9765 ;; Compute the ranges of read articles by looking at the list of
9768 (when (/= (car unread) prev)
9769 (push (if (= prev (1- (car unread))) prev
9770 (cons prev (1- (car unread))))
9772 (setq prev (1+ (car unread)))
9773 (setq unread (cdr unread)))
9774 (when (<= prev (cdr active))
9775 (push (cons prev (cdr active)) read))
9776 (setq read (if (> (length read) 1) (nreverse read) read))
9781 ;; Propagate the read marks to the backend.
9782 (when (gnus-check-backend-function 'request-set-mark group)
9783 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9784 (add (gnus-remove-from-range read (gnus-info-read info))))
9786 (unless (gnus-check-group group)
9787 (error "Can't open server for %s" group))
9788 (gnus-request-set-mark
9789 group (delq nil (list (if add (list add 'add '(read)))
9790 (if del (list del 'del '(read))))))
9792 `(gnus-request-set-mark
9795 (if del (list del 'add '(read)))
9796 (if add (list add 'del '(read))))))))))
9797 (set-buffer gnus-group-buffer)
9800 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9801 (gnus-info-set-read ',info ',(gnus-info-read info))
9802 (gnus-get-unread-articles-in-group ',info
9803 (gnus-active ,group))
9804 (gnus-group-update-group ,group t)
9806 ;; Enter this list into the group info.
9807 (gnus-info-set-read info read)
9808 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9809 (gnus-get-unread-articles-in-group info (gnus-active group))
9812 (defun gnus-offer-save-summaries ()
9813 "Offer to save all active summary buffers."
9815 (let ((buflist (buffer-list))
9817 ;; Go through all buffers and find all summaries.
9819 (and (setq bufname (buffer-name (car buflist)))
9820 (string-match "Summary" bufname)
9822 (set-buffer bufname)
9823 ;; We check that this is, indeed, a summary buffer.
9824 (and (eq major-mode 'gnus-summary-mode)
9825 ;; Also make sure this isn't bogus.
9826 gnus-newsgroup-prepared
9827 ;; Also make sure that this isn't a dead summary buffer.
9828 (not gnus-dead-summary-mode)))
9829 (push bufname buffers))
9830 (setq buflist (cdr buflist)))
9831 ;; Go through all these summary buffers and offer to save them.
9834 "Update summary buffer %s? "
9836 (switch-to-buffer buf)
9837 (gnus-summary-exit))
9840 (defun gnus-summary-setup-default-charset ()
9841 "Setup newsgroup default charset."
9842 (if (equal gnus-newsgroup-name "nndraft:drafts")
9843 (setq gnus-newsgroup-charset nil)
9844 (let* ((name (and gnus-newsgroup-name
9845 (gnus-group-real-name gnus-newsgroup-name)))
9847 (or gnus-newsgroup-ephemeral-ignored-charsets
9849 (and gnus-newsgroup-name
9850 (or (gnus-group-find-parameter gnus-newsgroup-name
9851 'ignored-charsets t)
9852 (let ((alist gnus-group-ignored-charsets-alist)
9853 elem (charsets nil))
9854 (while (setq elem (pop alist))
9856 (string-match (car elem) name))
9858 charsets (cdr elem))))
9860 gnus-newsgroup-ignored-charsets))))
9861 (setq gnus-newsgroup-charset
9862 (or gnus-newsgroup-ephemeral-charset
9863 (and gnus-newsgroup-name
9864 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9865 (let ((alist gnus-group-charset-alist)
9867 (while (setq elem (pop alist))
9869 (string-match (car elem) name))
9871 charset (cadr elem))))
9873 gnus-default-charset))
9874 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9875 ignored-charsets))))
9881 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9882 "Display the current article buffer fully MIME-buttonized.
9883 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9884 treated as multipart/mixed."
9887 (let ((gnus-unbuttonized-mime-types nil)
9888 (gnus-mime-display-multipart-as-mixed show-all-parts))
9889 (gnus-summary-show-article)))
9891 (defun gnus-summary-repair-multipart (article)
9892 "Add a Content-Type header to a multipart article without one."
9893 (interactive (list (gnus-summary-article-number)))
9894 (gnus-with-article article
9895 (message-narrow-to-head)
9896 (message-remove-header "Mime-Version")
9897 (goto-char (point-max))
9898 (insert "Mime-Version: 1.0\n")
9900 (when (search-forward "\n--" nil t)
9901 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9902 (message-narrow-to-head)
9903 (message-remove-header "Content-Type")
9904 (goto-char (point-max))
9905 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9908 (let (gnus-mark-article-hook)
9909 (gnus-summary-select-article t t nil article)))
9911 (defun gnus-summary-toggle-display-buttonized ()
9912 "Toggle the buttonizing of the article buffer."
9915 (if (setq gnus-inhibit-mime-unbuttonizing
9916 (not gnus-inhibit-mime-unbuttonizing))
9917 (let ((gnus-unbuttonized-mime-types nil))
9918 (gnus-summary-show-article))
9919 (gnus-summary-show-article)))
9922 ;;; Generic summary marking commands
9925 (defvar gnus-summary-marking-alist
9926 '((read gnus-del-mark "d")
9927 (unread gnus-unread-mark "u")
9928 (ticked gnus-ticked-mark "!")
9929 (dormant gnus-dormant-mark "?")
9930 (expirable gnus-expirable-mark "e"))
9931 "An alist of names/marks/keystrokes.")
9933 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9934 (defvar gnus-summary-mark-map)
9936 (defun gnus-summary-make-all-marking-commands ()
9937 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9938 (dolist (elem gnus-summary-marking-alist)
9939 (apply 'gnus-summary-make-marking-command elem)))
9941 (defun gnus-summary-make-marking-command (name mark keystroke)
9942 (let ((map (make-sparse-keymap)))
9943 (define-key gnus-summary-generic-mark-map keystroke map)
9944 (dolist (lway `((next "next" next nil "n")
9945 (next-unread "next unread" next t "N")
9946 (prev "previous" prev nil "p")
9947 (prev-unread "previous unread" prev t "P")
9948 (nomove "" nil nil ,keystroke)))
9949 (let ((func (gnus-summary-make-marking-command-1
9950 mark (car lway) lway name)))
9951 (setq func (eval func))
9952 (define-key map (nth 4 lway) func)))))
9954 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9956 (format "gnus-summary-put-mark-as-%s%s"
9957 name (if (eq way 'nomove)
9959 (concat "-" (symbol-name way)))))
9962 "Mark the current article as %s%s.
9963 If N, the prefix, then repeat N times.
9964 If N is negative, move in reverse order.
9965 The difference between N and the actual number of articles marked is
9969 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9971 (defun gnus-summary-generic-mark (n mark move unread)
9972 "Mark N articles with MARK."
9973 (unless (eq major-mode 'gnus-summary-mode)
9974 (error "This command can only be used in the summary buffer"))
9975 (gnus-summary-show-thread)
9979 ((eq move 'prev) -1)
9985 nummove (* -1 nummove))))
9987 (gnus-summary-mark-article nil mark)
9988 (zerop (gnus-summary-next-subject nummove unread t)))
9991 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9992 (gnus-summary-recenter)
9993 (gnus-summary-position-point)
9994 (gnus-set-mode-line 'summary)
9997 (gnus-summary-make-all-marking-commands)
10001 (provide 'gnus-sum)
10003 (run-hooks 'gnus-sum-load-hook)
10005 ;;; gnus-sum.el ends here