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 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
654 (when (featurep 'xemacs)
655 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
656 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
657 (add-hook 'gnus-summary-mode-hook
658 'gnus-xmas-switch-horizontal-scrollbar-off))
660 (defcustom gnus-summary-menu-hook nil
661 "*Hook run after the creation of the summary mode menu."
662 :group 'gnus-summary-visual
665 (defcustom gnus-summary-exit-hook nil
666 "*A hook called on exit from the summary buffer.
667 It will be called with point in the group buffer."
668 :group 'gnus-summary-exit
671 (defcustom gnus-summary-prepare-hook nil
672 "*A hook called after the summary buffer has been generated.
673 If you want to modify the summary buffer, you can use this hook."
674 :group 'gnus-summary-various
677 (defcustom gnus-summary-prepared-hook nil
678 "*A hook called as the last thing after the summary buffer has been generated."
679 :group 'gnus-summary-various
682 (defcustom gnus-summary-generate-hook nil
683 "*A hook run just before generating the summary buffer.
684 This hook is commonly used to customize threading variables and the
686 :group 'gnus-summary-various
689 (defcustom gnus-select-group-hook nil
690 "*A hook called when a newsgroup is selected.
692 If you'd like to simplify subjects like the
693 `gnus-summary-next-same-subject' command does, you can use the
696 (setq gnus-select-group-hook
699 (mapcar (lambda (header)
700 (mail-header-set-subject
702 (gnus-simplify-subject
703 (mail-header-subject header) 're-only)))
704 gnus-newsgroup-headers))))"
705 :group 'gnus-group-select
708 (defcustom gnus-select-article-hook nil
709 "*A hook called when an article is selected."
710 :group 'gnus-summary-choose
713 (defcustom gnus-visual-mark-article-hook
714 (list 'gnus-highlight-selected-summary)
715 "*Hook run after selecting an article in the summary buffer.
716 It is meant to be used for highlighting the article in some way. It
717 is not run if `gnus-visual' is nil."
718 :group 'gnus-summary-visual
721 (defcustom gnus-parse-headers-hook nil
722 "*A hook called before parsing the headers."
726 (defcustom gnus-exit-group-hook nil
727 "*A hook called when exiting summary mode.
728 This hook is not called from the non-updating exit commands like `Q'."
732 (defcustom gnus-summary-update-hook
733 (list 'gnus-summary-highlight-line)
734 "*A hook called when a summary line is changed.
735 The hook will not be called if `gnus-visual' is nil.
737 The default function `gnus-summary-highlight-line' will
738 highlight the line according to the `gnus-summary-highlight'
740 :group 'gnus-summary-visual
743 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
744 "*A hook called when an article is selected for the first time.
745 The hook is intended to mark an article as read (or unread)
746 automatically when it is selected."
747 :group 'gnus-summary-choose
750 (defcustom gnus-group-no-more-groups-hook nil
751 "*A hook run when returning to group mode having no more (unread) groups."
752 :group 'gnus-group-select
755 (defcustom gnus-ps-print-hook nil
756 "*A hook run before ps-printing something from Gnus."
760 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
761 "Face used for highlighting the current article in the summary buffer."
762 :group 'gnus-summary-visual
765 (defcustom gnus-summary-highlight
766 '(((= mark gnus-canceled-mark)
767 . gnus-summary-cancelled-face)
768 ((and (> score default)
769 (or (= mark gnus-dormant-mark)
770 (= mark gnus-ticked-mark)))
771 . gnus-summary-high-ticked-face)
772 ((and (< score default)
773 (or (= mark gnus-dormant-mark)
774 (= mark gnus-ticked-mark)))
775 . gnus-summary-low-ticked-face)
776 ((or (= mark gnus-dormant-mark)
777 (= mark gnus-ticked-mark))
778 . gnus-summary-normal-ticked-face)
779 ((and (> score default) (= mark gnus-ancient-mark))
780 . gnus-summary-high-ancient-face)
781 ((and (< score default) (= mark gnus-ancient-mark))
782 . gnus-summary-low-ancient-face)
783 ((= mark gnus-ancient-mark)
784 . gnus-summary-normal-ancient-face)
785 ((and (> score default) (= mark gnus-unread-mark))
786 . gnus-summary-high-unread-face)
787 ((and (< score default) (= mark gnus-unread-mark))
788 . gnus-summary-low-unread-face)
789 ((= mark gnus-unread-mark)
790 . gnus-summary-normal-unread-face)
791 ((and (> score default) (memq mark (list gnus-downloadable-mark
792 gnus-undownloaded-mark)))
793 . gnus-summary-high-unread-face)
794 ((and (< score default) (memq mark (list gnus-downloadable-mark
795 gnus-undownloaded-mark)))
796 . gnus-summary-low-unread-face)
797 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
798 . gnus-summary-normal-unread-face)
800 . gnus-summary-high-read-face)
802 . gnus-summary-low-read-face)
804 . gnus-summary-normal-read-face))
805 "*Controls the highlighting of summary buffer lines.
807 A list of (FORM . FACE) pairs. When deciding how a a particular
808 summary line should be displayed, each form is evaluated. The content
809 of the face field after the first true form is used. You can change
810 how those summary lines are displayed, by editing the face field.
812 You can use the following variables in the FORM field.
814 score: The articles score
815 default: The default article score.
816 below: The score below which articles are automatically marked as read.
817 mark: The articles mark."
818 :group 'gnus-summary-visual
819 :type '(repeat (cons (sexp :tag "Form" nil)
822 (defcustom gnus-alter-header-function nil
823 "Function called to allow alteration of article header structures.
824 The function is called with one parameter, the article header vector,
825 which it may alter in any way.")
827 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
828 "Variable that says which function should be used to decode a string with encoded words.")
830 (defcustom gnus-extra-headers nil
831 "*Extra headers to parse."
834 :type '(repeat symbol))
836 (defcustom gnus-ignored-from-addresses
837 (and user-mail-address (regexp-quote user-mail-address))
838 "*Regexp of From headers that may be suppressed in favor of To headers."
843 (defcustom gnus-group-charset-alist
844 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
845 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
846 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
847 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
848 ("^relcom\\>" koi8-r)
850 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
851 ("^israel\\>" iso-8859-1)
853 ("^alt.chinese.text.big5\\>" chinese-big5)
854 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
855 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
857 "Alist of regexps (to match group names) and default charsets to be used when reading."
858 :type '(repeat (list (regexp :tag "Group")
859 (symbol :tag "Charset")))
860 :group 'gnus-charset)
862 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
863 "List of charsets that should be ignored.
864 When these charsets are used in the \"charset\" parameter, the
865 default charset will be used instead."
867 :type '(repeat symbol)
868 :group 'gnus-charset)
870 (defcustom gnus-group-ignored-charsets-alist
871 '(("alt\\.chinese\\.text" iso-8859-1))
872 "Alist of regexps (to match group names) and charsets that should be ignored.
873 When these charsets are used in the \"charset\" parameter, the
874 default charset will be used instead."
875 :type '(repeat (cons (regexp :tag "Group")
877 :group 'gnus-charset)
879 (defcustom gnus-group-highlight-words-alist nil
880 "Alist of group regexps and highlight regexps.
881 This variable uses the same syntax as `gnus-emphasis-alist'."
883 :type '(repeat (cons (regexp :tag "Group")
884 (repeat (list (regexp :tag "Highlight regexp")
885 (number :tag "Group for entire word" 0)
886 (number :tag "Group for displayed part" 0)
888 gnus-emphasis-highlight-words)))))
889 :group 'gnus-summary-visual)
891 (defcustom gnus-summary-show-article-charset-alist
893 "Alist of number and charset.
894 The article will be shown with the charset corresponding to the
896 For example: ((1 . cn-gb-2312) (2 . big5))."
898 :type '(repeat (cons (number :tag "Argument" 1)
899 (symbol :tag "Charset")))
900 :group 'gnus-charset)
902 (defcustom gnus-preserve-marks t
903 "Whether marks are preserved when moving, copying and respooling messages."
906 :group 'gnus-summary-marks)
908 (defcustom gnus-alter-articles-to-read-function nil
909 "Function to be called to alter the list of articles to be selected."
911 :group 'gnus-summary)
913 (defcustom gnus-orphan-score nil
914 "*All orphans get this score added. Set in the score file."
915 :group 'gnus-score-default
916 :type '(choice (const nil)
919 (defcustom gnus-summary-save-parts-default-mime "image/.*"
920 "*A regexp to match MIME parts when saving multiple parts of a message
921 with gnus-summary-save-parts (X m). This regexp will be used by default
922 when prompting the user for which type of files to save."
927 (defcustom gnus-summary-save-parts-default-mime "image/.*"
928 "*A regexp to match MIME parts when saving multiple parts of a message
929 with gnus-summary-save-parts (X m). This regexp will be used by default
930 when prompting the user for which type of files to save."
935 ;;; Internal variables
937 (defvar gnus-article-mime-handles nil)
938 (defvar gnus-article-decoded-p nil)
939 (defvar gnus-article-charset nil)
940 (defvar gnus-article-ignored-charsets nil)
941 (defvar gnus-scores-exclude-files nil)
942 (defvar gnus-page-broken nil)
943 (defvar gnus-inhibit-mime-unbuttonizing nil)
945 (defvar gnus-original-article nil)
946 (defvar gnus-article-internal-prepare-hook nil)
947 (defvar gnus-newsgroup-process-stack nil)
949 (defvar gnus-thread-indent-array nil)
950 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
951 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
952 "Function called to sort the articles within a thread after it has been gathered together.")
954 (defvar gnus-summary-save-parts-type-history nil)
955 (defvar gnus-summary-save-parts-last-directory nil)
957 (defvar gnus-summary-save-parts-type-history nil)
958 (defvar gnus-summary-save-parts-last-directory nil)
960 ;; Avoid highlighting in kill files.
961 (defvar gnus-summary-inhibit-highlight nil)
962 (defvar gnus-newsgroup-selected-overlay nil)
963 (defvar gnus-inhibit-limiting nil)
964 (defvar gnus-newsgroup-adaptive-score-file nil)
965 (defvar gnus-current-score-file nil)
966 (defvar gnus-current-move-group nil)
967 (defvar gnus-current-copy-group nil)
968 (defvar gnus-current-crosspost-group nil)
970 (defvar gnus-newsgroup-dependencies nil)
971 (defvar gnus-newsgroup-adaptive nil)
972 (defvar gnus-summary-display-article-function nil)
973 (defvar gnus-summary-highlight-line-function nil
974 "Function called after highlighting a summary line.")
976 (defvar gnus-summary-line-format-alist
977 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
978 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
979 (?s gnus-tmp-subject-or-nil ?s)
980 (?n gnus-tmp-name ?s)
981 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
983 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
985 (?F gnus-tmp-from ?s)
986 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
987 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
988 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
989 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
990 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
991 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
992 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
993 (?L gnus-tmp-lines ?d)
994 (?I gnus-tmp-indentation ?s)
995 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
996 (?R gnus-tmp-replied ?c)
997 (?\[ gnus-tmp-opening-bracket ?c)
998 (?\] gnus-tmp-closing-bracket ?c)
999 (?\> (make-string gnus-tmp-level ? ) ?s)
1000 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1001 (?i gnus-tmp-score ?d)
1002 (?z gnus-tmp-score-char ?c)
1003 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1004 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1005 (?U gnus-tmp-unread ?c)
1006 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1007 (?t (gnus-summary-number-of-articles-in-thread
1008 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1010 (?e (gnus-summary-number-of-articles-in-thread
1011 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1013 (?u gnus-tmp-user-defined ?s)
1014 (?P (gnus-pick-line-number) ?d))
1015 "An alist of format specifications that can appear in summary lines.
1016 These are paired with what variables they correspond with, along with
1017 the type of the variable (string, integer, character, etc).")
1019 (defvar gnus-summary-dummy-line-format-alist
1020 `((?S gnus-tmp-subject ?s)
1021 (?N gnus-tmp-number ?d)
1022 (?u gnus-tmp-user-defined ?s)))
1024 (defvar gnus-summary-mode-line-format-alist
1025 `((?G gnus-tmp-group-name ?s)
1026 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1027 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1028 (?A gnus-tmp-article-number ?d)
1029 (?Z gnus-tmp-unread-and-unselected ?s)
1030 (?V gnus-version ?s)
1031 (?U gnus-tmp-unread-and-unticked ?d)
1032 (?S gnus-tmp-subject ?s)
1033 (?e gnus-tmp-unselected ?d)
1034 (?u gnus-tmp-user-defined ?s)
1035 (?d (length gnus-newsgroup-dormant) ?d)
1036 (?t (length gnus-newsgroup-marked) ?d)
1037 (?r (length gnus-newsgroup-reads) ?d)
1038 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1039 (?E gnus-newsgroup-expunged-tally ?d)
1040 (?s (gnus-current-score-file-nondirectory) ?s)))
1042 (defvar gnus-last-search-regexp nil
1043 "Default regexp for article search command.")
1045 (defvar gnus-last-shell-command nil
1046 "Default shell command on article.")
1048 (defvar gnus-newsgroup-begin nil)
1049 (defvar gnus-newsgroup-end nil)
1050 (defvar gnus-newsgroup-last-rmail nil)
1051 (defvar gnus-newsgroup-last-mail nil)
1052 (defvar gnus-newsgroup-last-folder nil)
1053 (defvar gnus-newsgroup-last-file nil)
1054 (defvar gnus-newsgroup-auto-expire nil)
1055 (defvar gnus-newsgroup-active nil)
1057 (defvar gnus-newsgroup-data nil)
1058 (defvar gnus-newsgroup-data-reverse nil)
1059 (defvar gnus-newsgroup-limit nil)
1060 (defvar gnus-newsgroup-limits nil)
1062 (defvar gnus-newsgroup-unreads nil
1063 "List of unread articles in the current newsgroup.")
1065 (defvar gnus-newsgroup-unselected nil
1066 "List of unselected unread articles in the current newsgroup.")
1068 (defvar gnus-newsgroup-reads nil
1069 "Alist of read articles and article marks in the current newsgroup.")
1071 (defvar gnus-newsgroup-expunged-tally nil)
1073 (defvar gnus-newsgroup-marked nil
1074 "List of ticked articles in the current newsgroup (a subset of unread art).")
1076 (defvar gnus-newsgroup-killed nil
1077 "List of ranges of articles that have been through the scoring process.")
1079 (defvar gnus-newsgroup-cached nil
1080 "List of articles that come from the article cache.")
1082 (defvar gnus-newsgroup-saved nil
1083 "List of articles that have been saved.")
1085 (defvar gnus-newsgroup-kill-headers nil)
1087 (defvar gnus-newsgroup-replied nil
1088 "List of articles that have been replied to in the current newsgroup.")
1090 (defvar gnus-newsgroup-expirable nil
1091 "List of articles in the current newsgroup that can be expired.")
1093 (defvar gnus-newsgroup-processable nil
1094 "List of articles in the current newsgroup that can be processed.")
1096 (defvar gnus-newsgroup-downloadable nil
1097 "List of articles in the current newsgroup that can be processed.")
1099 (defvar gnus-newsgroup-undownloaded nil
1100 "List of articles in the current newsgroup that haven't been downloaded..")
1102 (defvar gnus-newsgroup-unsendable nil
1103 "List of articles in the current newsgroup that won't be sent.")
1105 (defvar gnus-newsgroup-bookmarks nil
1106 "List of articles in the current newsgroup that have bookmarks.")
1108 (defvar gnus-newsgroup-dormant nil
1109 "List of dormant articles in the current newsgroup.")
1111 (defvar gnus-newsgroup-scored nil
1112 "List of scored articles in the current newsgroup.")
1114 (defvar gnus-newsgroup-headers nil
1115 "List of article headers in the current newsgroup.")
1117 (defvar gnus-newsgroup-threads nil)
1119 (defvar gnus-newsgroup-prepared nil
1120 "Whether the current group has been prepared properly.")
1122 (defvar gnus-newsgroup-ancient nil
1123 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1125 (defvar gnus-newsgroup-sparse nil)
1127 (defvar gnus-current-article nil)
1128 (defvar gnus-article-current nil)
1129 (defvar gnus-current-headers nil)
1130 (defvar gnus-have-all-headers nil)
1131 (defvar gnus-last-article nil)
1132 (defvar gnus-newsgroup-history nil)
1133 (defvar gnus-newsgroup-charset nil)
1134 (defvar gnus-newsgroup-ephemeral-charset nil)
1135 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1137 (defvar gnus-article-before-search nil)
1139 (defconst gnus-summary-local-variables
1140 '(gnus-newsgroup-name
1141 gnus-newsgroup-begin gnus-newsgroup-end
1142 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1143 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1144 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1145 gnus-newsgroup-unselected gnus-newsgroup-marked
1146 gnus-newsgroup-reads gnus-newsgroup-saved
1147 gnus-newsgroup-replied gnus-newsgroup-expirable
1148 gnus-newsgroup-processable gnus-newsgroup-killed
1149 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1150 gnus-newsgroup-unsendable
1151 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1152 gnus-newsgroup-headers gnus-newsgroup-threads
1153 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1154 gnus-current-article gnus-current-headers gnus-have-all-headers
1155 gnus-last-article gnus-article-internal-prepare-hook
1156 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1157 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1158 gnus-thread-expunge-below
1159 gnus-score-alist gnus-current-score-file
1160 (gnus-summary-expunge-below . global)
1161 (gnus-summary-mark-below . global)
1162 (gnus-orphan-score . global)
1163 gnus-newsgroup-active gnus-scores-exclude-files
1164 gnus-newsgroup-history gnus-newsgroup-ancient
1165 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1166 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1167 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1168 (gnus-newsgroup-expunged-tally . 0)
1169 gnus-cache-removable-articles gnus-newsgroup-cached
1170 gnus-newsgroup-data gnus-newsgroup-data-reverse
1171 gnus-newsgroup-limit gnus-newsgroup-limits
1172 gnus-newsgroup-charset)
1173 "Variables that are buffer-local to the summary buffers.")
1175 (defvar gnus-newsgroup-variables nil
1176 "Variables that have separate values in the newsgroups.")
1178 ;; Byte-compiler warning.
1179 (eval-when-compile (defvar gnus-article-mode-map))
1183 (defvar gnus-decode-encoded-word-methods
1184 '(mail-decode-encoded-word-string)
1185 "List of methods used to decode encoded words.
1187 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1188 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1189 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1190 whose names match REGEXP.
1193 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1194 mail-decode-encoded-word-string
1195 (\"chinese\" . rfc1843-decode-string))")
1197 (defvar gnus-decode-encoded-word-methods-cache nil)
1199 (defun gnus-multi-decode-encoded-word-string (string)
1200 "Apply the functions from `gnus-encoded-word-methods' that match."
1201 (unless (and gnus-decode-encoded-word-methods-cache
1202 (eq gnus-newsgroup-name
1203 (car gnus-decode-encoded-word-methods-cache)))
1204 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1207 (nconc gnus-decode-encoded-word-methods-cache (list x))
1208 (if (and gnus-newsgroup-name
1209 (string-match (car x) gnus-newsgroup-name))
1210 (nconc gnus-decode-encoded-word-methods-cache
1212 gnus-decode-encoded-word-methods))
1213 (let ((xlist gnus-decode-encoded-word-methods-cache))
1216 (setq string (funcall (pop xlist) string))))
1219 ;; Subject simplification.
1221 (defun gnus-simplify-whitespace (str)
1222 "Remove excessive whitespace from STR."
1225 (while (string-match "[ \t][ \t]+" mystr)
1226 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1228 (substring mystr (match-end 0)))))
1230 (when (string-match "^[ \t]+" mystr)
1231 (setq mystr (substring mystr (match-end 0))))
1233 (when (string-match "[ \t]+$" mystr)
1234 (setq mystr (substring mystr 0 (match-beginning 0))))
1237 (defsubst gnus-simplify-subject-re (subject)
1238 "Remove \"Re:\" from subject lines."
1239 (if (string-match "^[Rr][Ee]: *" subject)
1240 (substring subject (match-end 0))
1243 (defun gnus-simplify-subject (subject &optional re-only)
1244 "Remove `Re:' and words in parentheses.
1245 If RE-ONLY is non-nil, strip leading `Re:'s only."
1246 (let ((case-fold-search t)) ;Ignore case.
1247 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1248 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1249 (setq subject (substring subject (match-end 0))))
1250 ;; Remove uninteresting prefixes.
1251 (when (and (not re-only)
1252 gnus-simplify-ignored-prefixes
1253 (string-match gnus-simplify-ignored-prefixes subject))
1254 (setq subject (substring subject (match-end 0))))
1255 ;; Remove words in parentheses from end.
1257 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1258 (setq subject (substring subject 0 (match-beginning 0)))))
1259 ;; Return subject string.
1262 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1264 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1265 (goto-char (point-min))
1266 (while (re-search-forward regexp nil t)
1267 (replace-match (or newtext ""))))
1269 (defun gnus-simplify-buffer-fuzzy ()
1270 "Simplify string in the buffer fuzzily.
1271 The string in the accessible portion of the current buffer is simplified.
1272 It is assumed to be a single-line subject.
1273 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1274 matter is removed. Additional things can be deleted by setting
1275 `gnus-simplify-subject-fuzzy-regexp'."
1276 (let ((case-fold-search t)
1278 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1280 (while (not (eq modified-tick (buffer-modified-tick)))
1281 (setq modified-tick (buffer-modified-tick))
1283 ((listp gnus-simplify-subject-fuzzy-regexp)
1284 (mapcar 'gnus-simplify-buffer-fuzzy-step
1285 gnus-simplify-subject-fuzzy-regexp))
1286 (gnus-simplify-subject-fuzzy-regexp
1287 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1288 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1289 (gnus-simplify-buffer-fuzzy-step
1290 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1291 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1293 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1294 (gnus-simplify-buffer-fuzzy-step " +" " ")
1295 (gnus-simplify-buffer-fuzzy-step " $")
1296 (gnus-simplify-buffer-fuzzy-step "^ +")))
1298 (defun gnus-simplify-subject-fuzzy (subject)
1299 "Simplify a subject string fuzzily.
1300 See `gnus-simplify-buffer-fuzzy' for details."
1302 (gnus-set-work-buffer)
1303 (let ((case-fold-search t))
1304 ;; Remove uninteresting prefixes.
1305 (when (and gnus-simplify-ignored-prefixes
1306 (string-match gnus-simplify-ignored-prefixes subject))
1307 (setq subject (substring subject (match-end 0))))
1309 (inline (gnus-simplify-buffer-fuzzy))
1312 (defsubst gnus-simplify-subject-fully (subject)
1313 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1315 (gnus-simplify-subject-functions
1316 (gnus-map-function gnus-simplify-subject-functions subject))
1317 ((null gnus-summary-gather-subject-limit)
1318 (gnus-simplify-subject-re subject))
1319 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1320 (gnus-simplify-subject-fuzzy subject))
1321 ((numberp gnus-summary-gather-subject-limit)
1322 (gnus-limit-string (gnus-simplify-subject-re subject)
1323 gnus-summary-gather-subject-limit))
1327 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1328 "Check whether two subjects are equal.
1329 If optional argument simple-first is t, first argument is already
1332 ((null simple-first)
1333 (equal (gnus-simplify-subject-fully s1)
1334 (gnus-simplify-subject-fully s2)))
1337 (gnus-simplify-subject-fully s2)))))
1339 (defun gnus-summary-bubble-group ()
1340 "Increase the score of the current group.
1341 This is a handy function to add to `gnus-summary-exit-hook' to
1342 increase the score of each group you read."
1343 (gnus-group-add-score gnus-newsgroup-name))
1347 ;;; Gnus summary mode
1350 (put 'gnus-summary-mode 'mode-class 'special)
1353 ;; Non-orthogonal keys
1355 (gnus-define-keys gnus-summary-mode-map
1356 " " gnus-summary-next-page
1357 "\177" gnus-summary-prev-page
1358 [delete] gnus-summary-prev-page
1359 [backspace] gnus-summary-prev-page
1360 "\r" gnus-summary-scroll-up
1361 "\M-\r" gnus-summary-scroll-down
1362 "n" gnus-summary-next-unread-article
1363 "p" gnus-summary-prev-unread-article
1364 "N" gnus-summary-next-article
1365 "P" gnus-summary-prev-article
1366 "\M-\C-n" gnus-summary-next-same-subject
1367 "\M-\C-p" gnus-summary-prev-same-subject
1368 "\M-n" gnus-summary-next-unread-subject
1369 "\M-p" gnus-summary-prev-unread-subject
1370 "." gnus-summary-first-unread-article
1371 "," gnus-summary-best-unread-article
1372 "\M-s" gnus-summary-search-article-forward
1373 "\M-r" gnus-summary-search-article-backward
1374 "<" gnus-summary-beginning-of-article
1375 ">" gnus-summary-end-of-article
1376 "j" gnus-summary-goto-article
1377 "^" gnus-summary-refer-parent-article
1378 "\M-^" gnus-summary-refer-article
1379 "u" gnus-summary-tick-article-forward
1380 "!" gnus-summary-tick-article-forward
1381 "U" gnus-summary-tick-article-backward
1382 "d" gnus-summary-mark-as-read-forward
1383 "D" gnus-summary-mark-as-read-backward
1384 "E" gnus-summary-mark-as-expirable
1385 "\M-u" gnus-summary-clear-mark-forward
1386 "\M-U" gnus-summary-clear-mark-backward
1387 "k" gnus-summary-kill-same-subject-and-select
1388 "\C-k" gnus-summary-kill-same-subject
1389 "\M-\C-k" gnus-summary-kill-thread
1390 "\M-\C-l" gnus-summary-lower-thread
1391 "e" gnus-summary-edit-article
1392 "#" gnus-summary-mark-as-processable
1393 "\M-#" gnus-summary-unmark-as-processable
1394 "\M-\C-t" gnus-summary-toggle-threads
1395 "\M-\C-s" gnus-summary-show-thread
1396 "\M-\C-h" gnus-summary-hide-thread
1397 "\M-\C-f" gnus-summary-next-thread
1398 "\M-\C-b" gnus-summary-prev-thread
1399 [(meta down)] gnus-summary-next-thread
1400 [(meta up)] gnus-summary-prev-thread
1401 "\M-\C-u" gnus-summary-up-thread
1402 "\M-\C-d" gnus-summary-down-thread
1403 "&" gnus-summary-execute-command
1404 "c" gnus-summary-catchup-and-exit
1405 "\C-w" gnus-summary-mark-region-as-read
1406 "\C-t" gnus-summary-toggle-truncation
1407 "?" gnus-summary-mark-as-dormant
1408 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1409 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1410 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1411 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1412 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1413 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1414 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1415 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1416 "=" gnus-summary-expand-window
1417 "\C-x\C-s" gnus-summary-reselect-current-group
1418 "\M-g" gnus-summary-rescan-group
1419 "w" gnus-summary-stop-page-breaking
1420 "\C-c\C-r" gnus-summary-caesar-message
1421 "f" gnus-summary-followup
1422 "F" gnus-summary-followup-with-original
1423 "C" gnus-summary-cancel-article
1424 "r" gnus-summary-reply
1425 "R" gnus-summary-reply-with-original
1426 "\C-c\C-f" gnus-summary-mail-forward
1427 "o" gnus-summary-save-article
1428 "\C-o" gnus-summary-save-article-mail
1429 "|" gnus-summary-pipe-output
1430 "\M-k" gnus-summary-edit-local-kill
1431 "\M-K" gnus-summary-edit-global-kill
1433 "\C-c\C-d" gnus-summary-describe-group
1434 "q" gnus-summary-exit
1435 "Q" gnus-summary-exit-no-update
1436 "\C-c\C-i" gnus-info-find-node
1437 gnus-mouse-2 gnus-mouse-pick-article
1438 "m" gnus-summary-mail-other-window
1439 "a" gnus-summary-post-news
1440 "x" gnus-summary-limit-to-unread
1441 "s" gnus-summary-isearch-article
1442 "t" gnus-summary-toggle-header
1443 "g" gnus-summary-show-article
1444 "l" gnus-summary-goto-last-article
1445 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1446 "\C-d" gnus-summary-enter-digest-group
1447 "\M-\C-d" gnus-summary-read-document
1448 "\M-\C-e" gnus-summary-edit-parameters
1449 "\M-\C-a" gnus-summary-customize-parameters
1451 "*" gnus-cache-enter-article
1452 "\M-*" gnus-cache-remove-article
1453 "\M-&" gnus-summary-universal-argument
1454 "\C-l" gnus-recenter
1455 "I" gnus-summary-increase-score
1456 "L" gnus-summary-lower-score
1457 "\M-i" gnus-symbolic-argument
1458 "h" gnus-summary-select-article-buffer
1460 "b" gnus-article-view-part
1461 "\M-t" gnus-summary-toggle-display-buttonized
1463 "V" gnus-summary-score-map
1464 "X" gnus-uu-extract-map
1465 "S" gnus-summary-send-map)
1467 ;; Sort of orthogonal keymap
1468 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1469 "t" gnus-summary-tick-article-forward
1470 "!" gnus-summary-tick-article-forward
1471 "d" gnus-summary-mark-as-read-forward
1472 "r" gnus-summary-mark-as-read-forward
1473 "c" gnus-summary-clear-mark-forward
1474 " " gnus-summary-clear-mark-forward
1475 "e" gnus-summary-mark-as-expirable
1476 "x" gnus-summary-mark-as-expirable
1477 "?" gnus-summary-mark-as-dormant
1478 "b" gnus-summary-set-bookmark
1479 "B" gnus-summary-remove-bookmark
1480 "#" gnus-summary-mark-as-processable
1481 "\M-#" gnus-summary-unmark-as-processable
1482 "S" gnus-summary-limit-include-expunged
1483 "C" gnus-summary-catchup
1484 "H" gnus-summary-catchup-to-here
1485 "\C-c" gnus-summary-catchup-all
1486 "k" gnus-summary-kill-same-subject-and-select
1487 "K" gnus-summary-kill-same-subject
1488 "P" gnus-uu-mark-map)
1490 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1491 "c" gnus-summary-clear-above
1492 "u" gnus-summary-tick-above
1493 "m" gnus-summary-mark-above
1494 "k" gnus-summary-kill-below)
1496 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1497 "/" gnus-summary-limit-to-subject
1498 "n" gnus-summary-limit-to-articles
1499 "w" gnus-summary-pop-limit
1500 "s" gnus-summary-limit-to-subject
1501 "a" gnus-summary-limit-to-author
1502 "u" gnus-summary-limit-to-unread
1503 "m" gnus-summary-limit-to-marks
1504 "M" gnus-summary-limit-exclude-marks
1505 "v" gnus-summary-limit-to-score
1506 "*" gnus-summary-limit-include-cached
1507 "D" gnus-summary-limit-include-dormant
1508 "T" gnus-summary-limit-include-thread
1509 "d" gnus-summary-limit-exclude-dormant
1510 "t" gnus-summary-limit-to-age
1511 "x" gnus-summary-limit-to-extra
1512 "E" gnus-summary-limit-include-expunged
1513 "c" gnus-summary-limit-exclude-childless-dormant
1514 "C" gnus-summary-limit-mark-excluded-as-read)
1516 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1517 "n" gnus-summary-next-unread-article
1518 "p" gnus-summary-prev-unread-article
1519 "N" gnus-summary-next-article
1520 "P" gnus-summary-prev-article
1521 "\C-n" gnus-summary-next-same-subject
1522 "\C-p" gnus-summary-prev-same-subject
1523 "\M-n" gnus-summary-next-unread-subject
1524 "\M-p" gnus-summary-prev-unread-subject
1525 "f" gnus-summary-first-unread-article
1526 "b" gnus-summary-best-unread-article
1527 "j" gnus-summary-goto-article
1528 "g" gnus-summary-goto-subject
1529 "l" gnus-summary-goto-last-article
1530 "o" gnus-summary-pop-article)
1532 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1533 "k" gnus-summary-kill-thread
1534 "l" gnus-summary-lower-thread
1535 "i" gnus-summary-raise-thread
1536 "T" gnus-summary-toggle-threads
1537 "t" gnus-summary-rethread-current
1538 "^" gnus-summary-reparent-thread
1539 "s" gnus-summary-show-thread
1540 "S" gnus-summary-show-all-threads
1541 "h" gnus-summary-hide-thread
1542 "H" gnus-summary-hide-all-threads
1543 "n" gnus-summary-next-thread
1544 "p" gnus-summary-prev-thread
1545 "u" gnus-summary-up-thread
1546 "o" gnus-summary-top-thread
1547 "d" gnus-summary-down-thread
1548 "#" gnus-uu-mark-thread
1549 "\M-#" gnus-uu-unmark-thread)
1551 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1552 "g" gnus-summary-prepare
1553 "c" gnus-summary-insert-cached-articles)
1555 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1556 "c" gnus-summary-catchup-and-exit
1557 "C" gnus-summary-catchup-all-and-exit
1558 "E" gnus-summary-exit-no-update
1559 "Q" gnus-summary-exit
1560 "Z" gnus-summary-exit
1561 "n" gnus-summary-catchup-and-goto-next-group
1562 "R" gnus-summary-reselect-current-group
1563 "G" gnus-summary-rescan-group
1564 "N" gnus-summary-next-group
1565 "s" gnus-summary-save-newsrc
1566 "P" gnus-summary-prev-group)
1568 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1569 " " gnus-summary-next-page
1570 "n" gnus-summary-next-page
1571 "\177" gnus-summary-prev-page
1572 [delete] gnus-summary-prev-page
1573 "p" gnus-summary-prev-page
1574 "\r" gnus-summary-scroll-up
1575 "\M-\r" gnus-summary-scroll-down
1576 "<" gnus-summary-beginning-of-article
1577 ">" gnus-summary-end-of-article
1578 "b" gnus-summary-beginning-of-article
1579 "e" gnus-summary-end-of-article
1580 "^" gnus-summary-refer-parent-article
1581 "r" gnus-summary-refer-parent-article
1582 "D" gnus-summary-enter-digest-group
1583 "R" gnus-summary-refer-references
1584 "T" gnus-summary-refer-thread
1585 "g" gnus-summary-show-article
1586 "s" gnus-summary-isearch-article
1587 "P" gnus-summary-print-article
1588 "M" gnus-mailing-list-insinuate
1589 "t" gnus-article-babel)
1591 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1592 "b" gnus-article-add-buttons
1593 "B" gnus-article-add-buttons-to-head
1594 "o" gnus-article-treat-overstrike
1595 "e" gnus-article-emphasize
1596 "w" gnus-article-fill-cited-article
1597 "Q" gnus-article-fill-long-lines
1598 "C" gnus-article-capitalize-sentences
1599 "c" gnus-article-remove-cr
1600 "q" gnus-article-de-quoted-unreadable
1601 "6" gnus-article-de-base64-unreadable
1602 "Z" gnus-article-decode-HZ
1603 "h" gnus-article-wash-html
1604 "s" gnus-summary-force-verify-and-decrypt
1605 "f" gnus-article-display-x-face
1606 "l" gnus-summary-stop-page-breaking
1607 "r" gnus-summary-caesar-message
1608 "t" gnus-summary-toggle-header
1609 "v" gnus-summary-verbose-headers
1610 "H" gnus-article-strip-headers-in-body
1611 "p" gnus-article-verify-x-pgp-sig
1612 "d" gnus-article-treat-dumbquotes)
1614 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1615 "a" gnus-article-hide
1616 "h" gnus-article-hide-headers
1617 "b" gnus-article-hide-boring-headers
1618 "s" gnus-article-hide-signature
1619 "c" gnus-article-hide-citation
1620 "C" gnus-article-hide-citation-in-followups
1621 "l" gnus-article-hide-list-identifiers
1622 "p" gnus-article-hide-pgp
1623 "B" gnus-article-strip-banner
1624 "P" gnus-article-hide-pem
1625 "\C-c" gnus-article-hide-citation-maybe)
1627 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1628 "a" gnus-article-highlight
1629 "h" gnus-article-highlight-headers
1630 "c" gnus-article-highlight-citation
1631 "s" gnus-article-highlight-signature)
1633 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1634 "w" gnus-article-decode-mime-words
1635 "c" gnus-article-decode-charset
1636 "v" gnus-mime-view-all-parts
1637 "b" gnus-article-view-part)
1639 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1640 "z" gnus-article-date-ut
1641 "u" gnus-article-date-ut
1642 "l" gnus-article-date-local
1643 "p" gnus-article-date-english
1644 "e" gnus-article-date-lapsed
1645 "o" gnus-article-date-original
1646 "i" gnus-article-date-iso8601
1647 "s" gnus-article-date-user)
1649 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1650 "t" gnus-article-remove-trailing-blank-lines
1651 "l" gnus-article-strip-leading-blank-lines
1652 "m" gnus-article-strip-multiple-blank-lines
1653 "a" gnus-article-strip-blank-lines
1654 "A" gnus-article-strip-all-blank-lines
1655 "s" gnus-article-strip-leading-space
1656 "e" gnus-article-strip-trailing-space)
1658 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1660 "f" gnus-summary-fetch-faq
1661 "d" gnus-summary-describe-group
1662 "h" gnus-summary-describe-briefly
1663 "i" gnus-info-find-node)
1665 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1666 "e" gnus-summary-expire-articles
1667 "\M-\C-e" gnus-summary-expire-articles-now
1668 "\177" gnus-summary-delete-article
1669 [delete] gnus-summary-delete-article
1670 [backspace] gnus-summary-delete-article
1671 "m" gnus-summary-move-article
1672 "r" gnus-summary-respool-article
1673 "w" gnus-summary-edit-article
1674 "c" gnus-summary-copy-article
1675 "B" gnus-summary-crosspost-article
1676 "q" gnus-summary-respool-query
1677 "t" gnus-summary-respool-trace
1678 "i" gnus-summary-import-article
1679 "p" gnus-summary-article-posted-p)
1681 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1682 "o" gnus-summary-save-article
1683 "m" gnus-summary-save-article-mail
1684 "F" gnus-summary-write-article-file
1685 "r" gnus-summary-save-article-rmail
1686 "f" gnus-summary-save-article-file
1687 "b" gnus-summary-save-article-body-file
1688 "h" gnus-summary-save-article-folder
1689 "v" gnus-summary-save-article-vm
1690 "p" gnus-summary-pipe-output
1691 "s" gnus-soup-add-article)
1693 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1694 "b" gnus-summary-display-buttonized
1695 "m" gnus-summary-repair-multipart
1696 "v" gnus-article-view-part
1697 "o" gnus-article-save-part
1698 "c" gnus-article-copy-part
1699 "C" gnus-article-view-part-as-charset
1700 "e" gnus-article-externalize-part
1701 "E" gnus-article-encrypt-body
1702 "i" gnus-article-inline-part
1703 "|" gnus-article-pipe-part))
1705 (defun gnus-summary-make-menu-bar ()
1706 (gnus-turn-off-edit-menu 'summary)
1708 (unless (boundp 'gnus-summary-misc-menu)
1711 gnus-summary-kill-menu gnus-summary-mode-map ""
1716 ["Customize" gnus-score-customize t])
1717 (gnus-make-score-map 'increase)
1718 (gnus-make-score-map 'lower)
1720 ["Kill below" gnus-summary-kill-below t]
1721 ["Mark above" gnus-summary-mark-above t]
1722 ["Tick above" gnus-summary-tick-above t]
1723 ["Clear above" gnus-summary-clear-above t])
1724 ["Current score" gnus-summary-current-score t]
1725 ["Set score" gnus-summary-set-score t]
1726 ["Switch current score file..." gnus-score-change-score-file t]
1727 ["Set mark below..." gnus-score-set-mark-below t]
1728 ["Set expunge below..." gnus-score-set-expunge-below t]
1729 ["Edit current score file" gnus-score-edit-current-scores t]
1730 ["Edit score file" gnus-score-edit-file t]
1731 ["Trace score" gnus-score-find-trace t]
1732 ["Find words" gnus-score-find-favourite-words t]
1733 ["Rescore buffer" gnus-summary-rescore t]
1734 ["Increase score..." gnus-summary-increase-score t]
1735 ["Lower score..." gnus-summary-lower-score t]))))
1737 ;; Define both the Article menu in the summary buffer and the equivalent
1738 ;; Commands menu in the article buffer here for consistency.
1741 ["All" gnus-article-hide t]
1742 ["Headers" gnus-article-hide-headers t]
1743 ["Signature" gnus-article-hide-signature t]
1744 ["Citation" gnus-article-hide-citation t]
1745 ["List identifiers" gnus-article-hide-list-identifiers t]
1746 ["PGP" gnus-article-hide-pgp t]
1747 ["Banner" gnus-article-strip-banner t]
1748 ["Boring headers" gnus-article-hide-boring-headers t])
1750 ["All" gnus-article-highlight t]
1751 ["Headers" gnus-article-highlight-headers t]
1752 ["Signature" gnus-article-highlight-signature t]
1753 ["Citation" gnus-article-highlight-citation t])
1755 ["Words" gnus-article-decode-mime-words t]
1756 ["Charset" gnus-article-decode-charset t]
1757 ["QP" gnus-article-de-quoted-unreadable t]
1758 ["Base64" gnus-article-de-base64-unreadable t]
1759 ["View all" gnus-mime-view-all-parts t]
1760 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1761 ["Encrypt body" gnus-article-encrypt-body t])
1763 ["Local" gnus-article-date-local t]
1764 ["ISO8601" gnus-article-date-iso8601 t]
1765 ["UT" gnus-article-date-ut t]
1766 ["Original" gnus-article-date-original t]
1767 ["Lapsed" gnus-article-date-lapsed t]
1768 ["User-defined" gnus-article-date-user t])
1771 ["Leading" gnus-article-strip-leading-blank-lines t]
1772 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1773 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1774 ["All of the above" gnus-article-strip-blank-lines t]
1775 ["All" gnus-article-strip-all-blank-lines t]
1776 ["Leading space" gnus-article-strip-leading-space t]
1777 ["Trailing space" gnus-article-strip-trailing-space t])
1778 ["Overstrike" gnus-article-treat-overstrike t]
1779 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1780 ["Emphasis" gnus-article-emphasize t]
1781 ["Word wrap" gnus-article-fill-cited-article t]
1782 ["Fill long lines" gnus-article-fill-long-lines t]
1783 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1784 ["CR" gnus-article-remove-cr t]
1785 ["Show X-Face" gnus-article-display-x-face t]
1786 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1787 ["Base64" gnus-article-de-base64-unreadable t]
1788 ["Rot 13" gnus-summary-caesar-message
1789 ,@(if (featurep 'xemacs) nil
1790 '(:help "\"Caesar rotate\" article by 13"))]
1791 ["Unix pipe" gnus-summary-pipe-message t]
1792 ["Add buttons" gnus-article-add-buttons t]
1793 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1794 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1795 ["Verbose header" gnus-summary-verbose-headers t]
1796 ["Toggle header" gnus-summary-toggle-header t]
1797 ["Html" gnus-article-wash-html t]
1798 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1799 ["HZ" gnus-article-decode-HZ t])
1801 ["Save in default format" gnus-summary-save-article
1802 ,@(if (featurep 'xemacs) nil
1803 '(:help "Save article using default method"))]
1804 ["Save in file" gnus-summary-save-article-file
1805 ,@(if (featurep 'xemacs) nil
1806 '(:help "Save article in file"))]
1807 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1808 ["Save in MH folder" gnus-summary-save-article-folder t]
1809 ["Save in VM folder" gnus-summary-save-article-vm t]
1810 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1811 ["Save body in file" gnus-summary-save-article-body-file t]
1812 ["Pipe through a filter" gnus-summary-pipe-output t]
1813 ["Add to SOUP packet" gnus-soup-add-article t]
1814 ["Print" gnus-summary-print-article t])
1816 ["Respool article..." gnus-summary-respool-article t]
1817 ["Move article..." gnus-summary-move-article
1818 (gnus-check-backend-function
1819 'request-move-article gnus-newsgroup-name)]
1820 ["Copy article..." gnus-summary-copy-article t]
1821 ["Crosspost article..." gnus-summary-crosspost-article
1822 (gnus-check-backend-function
1823 'request-replace-article gnus-newsgroup-name)]
1824 ["Import file..." gnus-summary-import-article t]
1825 ["Check if posted" gnus-summary-article-posted-p t]
1826 ["Edit article" gnus-summary-edit-article
1827 (not (gnus-group-read-only-p))]
1828 ["Delete article" gnus-summary-delete-article
1829 (gnus-check-backend-function
1830 'request-expire-articles gnus-newsgroup-name)]
1831 ["Query respool" gnus-summary-respool-query t]
1832 ["Trace respool" gnus-summary-respool-trace t]
1833 ["Delete expirable articles" gnus-summary-expire-articles-now
1834 (gnus-check-backend-function
1835 'request-expire-articles gnus-newsgroup-name)])
1837 ["Uudecode" gnus-uu-decode-uu
1838 ,@(if (featurep 'xemacs) nil
1839 '(:help "Decode uuencoded article(s)"))]
1840 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1841 ["Unshar" gnus-uu-decode-unshar t]
1842 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1843 ["Save" gnus-uu-decode-save t]
1844 ["Binhex" gnus-uu-decode-binhex t]
1845 ["Postscript" gnus-uu-decode-postscript t])
1847 ["Enter article" gnus-cache-enter-article t]
1848 ["Remove article" gnus-cache-remove-article t])
1849 ["Translate" gnus-article-babel t]
1850 ["Select article buffer" gnus-summary-select-article-buffer t]
1851 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1852 ["Isearch article..." gnus-summary-isearch-article t]
1853 ["Beginning of the article" gnus-summary-beginning-of-article t]
1854 ["End of the article" gnus-summary-end-of-article t]
1855 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1856 ["Fetch referenced articles" gnus-summary-refer-references t]
1857 ["Fetch current thread" gnus-summary-refer-thread t]
1858 ["Fetch article with id..." gnus-summary-refer-article t]
1859 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1860 ["Redisplay" gnus-summary-show-article t])))
1862 gnus-summary-article-menu gnus-summary-mode-map ""
1863 (cons "Article" innards))
1866 gnus-article-commands-menu gnus-article-mode-map ""
1867 (cons "Commands" innards)))
1870 gnus-summary-thread-menu gnus-summary-mode-map ""
1872 ["Toggle threading" gnus-summary-toggle-threads t]
1873 ["Hide threads" gnus-summary-hide-all-threads t]
1874 ["Show threads" gnus-summary-show-all-threads t]
1875 ["Hide thread" gnus-summary-hide-thread t]
1876 ["Show thread" gnus-summary-show-thread t]
1877 ["Go to next thread" gnus-summary-next-thread t]
1878 ["Go to previous thread" gnus-summary-prev-thread t]
1879 ["Go down thread" gnus-summary-down-thread t]
1880 ["Go up thread" gnus-summary-up-thread t]
1881 ["Top of thread" gnus-summary-top-thread t]
1882 ["Mark thread as read" gnus-summary-kill-thread t]
1883 ["Lower thread score" gnus-summary-lower-thread t]
1884 ["Raise thread score" gnus-summary-raise-thread t]
1885 ["Rethread current" gnus-summary-rethread-current t]))
1888 gnus-summary-post-menu gnus-summary-mode-map ""
1890 ["Post an article" gnus-summary-post-news
1891 ,@(if (featurep 'xemacs) nil
1892 '(:help "Post an article"))]
1893 ["Followup" gnus-summary-followup
1894 ,@(if (featurep 'xemacs) nil
1895 '(:help "Post followup to this article"))]
1896 ["Followup and yank" gnus-summary-followup-with-original
1897 ,@(if (featurep 'xemacs) nil
1898 '(:help "Post followup to this article, quoting its contents"))]
1899 ["Supersede article" gnus-summary-supersede-article t]
1900 ["Cancel article" gnus-summary-cancel-article
1901 ,@(if (featurep 'xemacs) nil
1902 '(:help "Cancel an article you posted"))]
1903 ["Reply" gnus-summary-reply t]
1904 ["Reply and yank" gnus-summary-reply-with-original t]
1905 ["Wide reply" gnus-summary-wide-reply t]
1906 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1907 ,@(if (featurep 'xemacs) nil
1908 '(:help "Mail a reply, quoting this article"))]
1909 ["Mail forward" gnus-summary-mail-forward t]
1910 ["Post forward" gnus-summary-post-forward t]
1911 ["Digest and mail" gnus-uu-digest-mail-forward t]
1912 ["Digest and post" gnus-uu-digest-post-forward t]
1913 ["Resend message" gnus-summary-resend-message t]
1914 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1915 ["Send a mail" gnus-summary-mail-other-window t]
1916 ["Uuencode and post" gnus-uu-post-news
1917 ,@(if (featurep 'xemacs) nil
1918 '(:help "Post a uuencoded article"))]
1919 ["Followup via news" gnus-summary-followup-to-mail t]
1920 ["Followup via news and yank"
1921 gnus-summary-followup-to-mail-with-original t]
1923 ;;["Send" gnus-summary-send-draft t]
1924 ;;["Send bounced" gnus-resend-bounced-mail t])
1928 gnus-summary-misc-menu gnus-summary-mode-map ""
1931 ["Mark as read" gnus-summary-mark-as-read-forward t]
1932 ["Mark same subject and select"
1933 gnus-summary-kill-same-subject-and-select t]
1934 ["Mark same subject" gnus-summary-kill-same-subject t]
1935 ["Catchup" gnus-summary-catchup
1936 ,@(if (featurep 'xemacs) nil
1937 '(:help "Mark unread articles in this group as read"))]
1938 ["Catchup all" gnus-summary-catchup-all t]
1939 ["Catchup to here" gnus-summary-catchup-to-here t]
1940 ["Catchup region" gnus-summary-mark-region-as-read t]
1941 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1943 ["Tick" gnus-summary-tick-article-forward t]
1944 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1945 ["Remove marks" gnus-summary-clear-mark-forward t]
1946 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1947 ["Set bookmark" gnus-summary-set-bookmark t]
1948 ["Remove bookmark" gnus-summary-remove-bookmark t])
1950 ["Marks..." gnus-summary-limit-to-marks t]
1951 ["Subject..." gnus-summary-limit-to-subject t]
1952 ["Author..." gnus-summary-limit-to-author t]
1953 ["Age..." gnus-summary-limit-to-age t]
1954 ["Extra..." gnus-summary-limit-to-extra t]
1955 ["Score" gnus-summary-limit-to-score t]
1956 ["Unread" gnus-summary-limit-to-unread t]
1957 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1958 ["Articles" gnus-summary-limit-to-articles t]
1959 ["Pop limit" gnus-summary-pop-limit t]
1960 ["Show dormant" gnus-summary-limit-include-dormant t]
1961 ["Hide childless dormant"
1962 gnus-summary-limit-exclude-childless-dormant t]
1963 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1964 ["Hide marked" gnus-summary-limit-exclude-marks t]
1965 ["Show expunged" gnus-summary-show-all-expunged t])
1967 ["Set mark" gnus-summary-mark-as-processable t]
1968 ["Remove mark" gnus-summary-unmark-as-processable t]
1969 ["Remove all marks" gnus-summary-unmark-all-processable t]
1970 ["Mark above" gnus-uu-mark-over t]
1971 ["Mark series" gnus-uu-mark-series t]
1972 ["Mark region" gnus-uu-mark-region t]
1973 ["Unmark region" gnus-uu-unmark-region t]
1974 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1975 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1976 ["Mark all" gnus-uu-mark-all t]
1977 ["Mark buffer" gnus-uu-mark-buffer t]
1978 ["Mark sparse" gnus-uu-mark-sparse t]
1979 ["Mark thread" gnus-uu-mark-thread t]
1980 ["Unmark thread" gnus-uu-unmark-thread t]
1981 ("Process Mark Sets"
1982 ["Kill" gnus-summary-kill-process-mark t]
1983 ["Yank" gnus-summary-yank-process-mark
1984 gnus-newsgroup-process-stack]
1985 ["Save" gnus-summary-save-process-mark t]))
1987 ["Page forward" gnus-summary-next-page
1988 ,@(if (featurep 'xemacs) nil
1989 '(:help "Show next page of article"))]
1990 ["Page backward" gnus-summary-prev-page
1991 ,@(if (featurep 'xemacs) nil
1992 '(:help "Show previous page of article"))]
1993 ["Line forward" gnus-summary-scroll-up t])
1995 ["Next unread article" gnus-summary-next-unread-article t]
1996 ["Previous unread article" gnus-summary-prev-unread-article t]
1997 ["Next article" gnus-summary-next-article t]
1998 ["Previous article" gnus-summary-prev-article t]
1999 ["Next unread subject" gnus-summary-next-unread-subject t]
2000 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2001 ["Next article same subject" gnus-summary-next-same-subject t]
2002 ["Previous article same subject" gnus-summary-prev-same-subject t]
2003 ["First unread article" gnus-summary-first-unread-article t]
2004 ["Best unread article" gnus-summary-best-unread-article t]
2005 ["Go to subject number..." gnus-summary-goto-subject t]
2006 ["Go to article number..." gnus-summary-goto-article t]
2007 ["Go to the last article" gnus-summary-goto-last-article t]
2008 ["Pop article off history" gnus-summary-pop-article t])
2010 ["Sort by number" gnus-summary-sort-by-number t]
2011 ["Sort by author" gnus-summary-sort-by-author t]
2012 ["Sort by subject" gnus-summary-sort-by-subject t]
2013 ["Sort by date" gnus-summary-sort-by-date t]
2014 ["Sort by score" gnus-summary-sort-by-score t]
2015 ["Sort by lines" gnus-summary-sort-by-lines t]
2016 ["Sort by characters" gnus-summary-sort-by-chars t])
2018 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2019 ["Describe group" gnus-summary-describe-group t]
2020 ["Read manual" gnus-info-find-node t])
2022 ["Pick and read" gnus-pick-mode t]
2023 ["Binary" gnus-binary-mode t])
2025 ["Regenerate" gnus-summary-prepare t]
2026 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2027 ["Toggle threading" gnus-summary-toggle-threads t])
2028 ["Filter articles..." gnus-summary-execute-command t]
2029 ["Run command on subjects..." gnus-summary-universal-argument t]
2030 ["Search articles forward..." gnus-summary-search-article-forward t]
2031 ["Search articles backward..." gnus-summary-search-article-backward t]
2032 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2033 ["Expand window" gnus-summary-expand-window t]
2034 ["Expire expirable articles" gnus-summary-expire-articles
2035 (gnus-check-backend-function
2036 'request-expire-articles gnus-newsgroup-name)]
2037 ["Edit local kill file" gnus-summary-edit-local-kill t]
2038 ["Edit main kill file" gnus-summary-edit-global-kill t]
2039 ["Edit group parameters" gnus-summary-edit-parameters t]
2040 ["Customize group parameters" gnus-summary-customize-parameters t]
2041 ["Send a bug report" gnus-bug t]
2043 ["Catchup and exit" gnus-summary-catchup-and-exit
2044 ,@(if (featurep 'xemacs) nil
2045 '(:help "Mark unread articles in this group as read, then exit"))]
2046 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2047 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2048 ["Exit group" gnus-summary-exit
2049 ,@(if (featurep 'xemacs) nil
2050 '(:help "Exit current group, return to group selection mode"))]
2051 ["Exit group without updating" gnus-summary-exit-no-update t]
2052 ["Exit and goto next group" gnus-summary-next-group t]
2053 ["Exit and goto prev group" gnus-summary-prev-group t]
2054 ["Reselect group" gnus-summary-reselect-current-group t]
2055 ["Rescan group" gnus-summary-rescan-group t]
2056 ["Update dribble" gnus-summary-save-newsrc t])))
2058 (gnus-run-hooks 'gnus-summary-menu-hook)))
2060 (defvar gnus-summary-tool-bar-map nil)
2062 ;; Emacs 21 tool bar. Should be no-op otherwise.
2063 (defun gnus-summary-make-tool-bar ()
2064 (if (and (fboundp 'tool-bar-add-item-from-menu)
2065 (default-value 'tool-bar-mode)
2066 (not gnus-summary-tool-bar-map))
2067 (setq gnus-summary-tool-bar-map
2068 (let ((tool-bar-map (make-sparse-keymap))
2069 (load-path (mm-image-load-path)))
2070 (tool-bar-add-item-from-menu
2071 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2072 (tool-bar-add-item-from-menu
2073 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2074 (tool-bar-add-item-from-menu
2075 'gnus-summary-post-news "post" gnus-summary-mode-map)
2076 (tool-bar-add-item-from-menu
2077 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2078 (tool-bar-add-item-from-menu
2079 'gnus-summary-followup "followup" gnus-summary-mode-map)
2080 (tool-bar-add-item-from-menu
2081 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2082 (tool-bar-add-item-from-menu
2083 'gnus-summary-reply "reply" gnus-summary-mode-map)
2084 (tool-bar-add-item-from-menu
2085 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2086 (tool-bar-add-item-from-menu
2087 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2088 (tool-bar-add-item-from-menu
2089 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2090 (tool-bar-add-item-from-menu
2091 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2092 (tool-bar-add-item-from-menu
2093 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2094 (tool-bar-add-item-from-menu
2095 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2096 (tool-bar-add-item-from-menu
2097 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2098 (tool-bar-add-item-from-menu
2099 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2101 (if gnus-summary-tool-bar-map
2102 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2104 (defun gnus-score-set-default (var value)
2105 "A version of set that updates the GNU Emacs menu-bar."
2107 ;; It is the message that forces the active status to be updated.
2110 (defun gnus-make-score-map (type)
2111 "Make a summary score map of type TYPE."
2114 (let ((headers '(("author" "from" string)
2115 ("subject" "subject" string)
2116 ("article body" "body" string)
2117 ("article head" "head" string)
2118 ("xref" "xref" string)
2119 ("extra header" "extra" string)
2120 ("lines" "lines" number)
2121 ("followups to author" "followup" string)))
2122 (types '((number ("less than" <)
2125 (string ("substring" s)
2129 (perms '(("temporary" (current-time-string))
2137 (if (eq type 'lower)
2142 (setq header (car headers))
2148 (let ((ts (cdr (assoc (nth 2 header) types)))
2164 'gnus-summary-score-entry
2166 (if (or (string= (nth 1 header)
2168 (string= (nth 1 header)
2171 (list 'gnus-summary-header
2173 (list 'quote (nth 1 (car ts)))
2174 (list 'gnus-score-delta-default
2181 (list (nreverse outp))))
2184 (list (nreverse outt))))
2186 (setq headers (cdr headers)))
2187 (list (nreverse outh))))))))
2191 (defun gnus-summary-mode (&optional group)
2192 "Major mode for reading articles.
2194 All normal editing commands are switched off.
2195 \\<gnus-summary-mode-map>
2196 Each line in this buffer represents one article. To read an
2197 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2198 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2201 You can also post articles and send mail from this buffer. To
2202 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2203 of an article, type `\\[gnus-summary-reply]'.
2205 There are approx. one gazillion commands you can execute in this
2206 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2208 The following commands are available:
2210 \\{gnus-summary-mode-map}"
2212 (kill-all-local-variables)
2213 (when (gnus-visual-p 'summary-menu 'menu)
2214 (gnus-summary-make-menu-bar)
2215 (gnus-summary-make-tool-bar))
2216 (gnus-summary-make-local-variables)
2217 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2218 (gnus-summary-make-local-variables))
2219 (gnus-make-thread-indent-array)
2220 (gnus-simplify-mode-line)
2221 (setq major-mode 'gnus-summary-mode)
2222 (setq mode-name "Summary")
2223 (make-local-variable 'minor-mode-alist)
2224 (use-local-map gnus-summary-mode-map)
2225 (buffer-disable-undo)
2226 (setq buffer-read-only t) ;Disable modification
2227 (setq truncate-lines t)
2228 (setq selective-display t)
2229 (setq selective-display-ellipses t) ;Display `...'
2230 (gnus-summary-set-display-table)
2231 (gnus-set-default-directory)
2232 (setq gnus-newsgroup-name group)
2233 (make-local-variable 'gnus-summary-line-format)
2234 (make-local-variable 'gnus-summary-line-format-spec)
2235 (make-local-variable 'gnus-summary-dummy-line-format)
2236 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2237 (make-local-variable 'gnus-summary-mark-positions)
2238 (make-local-hook 'pre-command-hook)
2239 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2240 (gnus-run-hooks 'gnus-summary-mode-hook)
2241 (turn-on-gnus-mailing-list-mode)
2242 (mm-enable-multibyte-mule4)
2243 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2244 (gnus-update-summary-mark-positions))
2246 (defun gnus-summary-make-local-variables ()
2247 "Make all the local summary buffer variables."
2249 (dolist (local gnus-summary-local-variables)
2252 (if (eq (cdr local) 'global)
2253 ;; Copy the global value of the variable.
2254 (setq global (symbol-value (car local)))
2255 ;; Use the value from the list.
2256 (setq global (eval (cdr local))))
2257 (set (make-local-variable (car local)) global))
2258 ;; Simple nil-valued local variable.
2259 (set (make-local-variable local) nil)))))
2261 (defun gnus-summary-clear-local-variables ()
2262 (let ((locals gnus-summary-local-variables))
2264 (if (consp (car locals))
2265 (and (vectorp (caar locals))
2266 (set (caar locals) nil))
2267 (and (vectorp (car locals))
2268 (set (car locals) nil)))
2269 (setq locals (cdr locals)))))
2271 ;; Summary data functions.
2273 (defmacro gnus-data-number (data)
2276 (defmacro gnus-data-set-number (data number)
2277 `(setcar ,data ,number))
2279 (defmacro gnus-data-mark (data)
2282 (defmacro gnus-data-set-mark (data mark)
2283 `(setcar (nthcdr 1 ,data) ,mark))
2285 (defmacro gnus-data-pos (data)
2288 (defmacro gnus-data-set-pos (data pos)
2289 `(setcar (nthcdr 2 ,data) ,pos))
2291 (defmacro gnus-data-header (data)
2294 (defmacro gnus-data-set-header (data header)
2295 `(setf (nth 3 ,data) ,header))
2297 (defmacro gnus-data-level (data)
2300 (defmacro gnus-data-unread-p (data)
2301 `(= (nth 1 ,data) gnus-unread-mark))
2303 (defmacro gnus-data-read-p (data)
2304 `(/= (nth 1 ,data) gnus-unread-mark))
2306 (defmacro gnus-data-pseudo-p (data)
2307 `(consp (nth 3 ,data)))
2309 (defmacro gnus-data-find (number)
2310 `(assq ,number gnus-newsgroup-data))
2312 (defmacro gnus-data-find-list (number &optional data)
2313 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2314 (memq (assq ,number bdata)
2317 (defmacro gnus-data-make (number mark pos header level)
2318 `(list ,number ,mark ,pos ,header ,level))
2320 (defun gnus-data-enter (after-article number mark pos header level offset)
2321 (let ((data (gnus-data-find-list after-article)))
2323 (error "No such article: %d" after-article))
2324 (setcdr data (cons (gnus-data-make number mark pos header level)
2326 (setq gnus-newsgroup-data-reverse nil)
2327 (gnus-data-update-list (cddr data) offset)))
2329 (defun gnus-data-enter-list (after-article list &optional offset)
2331 (let ((data (and after-article (gnus-data-find-list after-article)))
2335 (let ((odata gnus-newsgroup-data))
2336 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2338 (gnus-data-update-list odata offset)))
2339 ;; Find the last element in the list to be spliced into the main
2342 (setq list (cdr list)))
2345 (setcdr list gnus-newsgroup-data)
2346 (setq gnus-newsgroup-data ilist)
2348 (gnus-data-update-list (cdr list) offset)))
2349 (setcdr list (cdr data))
2352 (gnus-data-update-list (cdr list) offset))))
2353 (setq gnus-newsgroup-data-reverse nil))))
2355 (defun gnus-data-remove (article &optional offset)
2356 (let ((data gnus-newsgroup-data))
2357 (if (= (gnus-data-number (car data)) article)
2359 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2360 gnus-newsgroup-data-reverse nil)
2362 (gnus-data-update-list gnus-newsgroup-data offset)))
2364 (when (= (gnus-data-number (cadr data)) article)
2365 (setcdr data (cddr data))
2367 (gnus-data-update-list (cdr data) offset))
2369 gnus-newsgroup-data-reverse nil))
2370 (setq data (cdr data))))))
2372 (defmacro gnus-data-list (backward)
2374 (or gnus-newsgroup-data-reverse
2375 (setq gnus-newsgroup-data-reverse
2376 (reverse gnus-newsgroup-data)))
2377 gnus-newsgroup-data))
2379 (defun gnus-data-update-list (data offset)
2380 "Add OFFSET to the POS of all data entries in DATA."
2381 (setq gnus-newsgroup-data-reverse nil)
2383 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2384 (setq data (cdr data))))
2386 (defun gnus-summary-article-pseudo-p (article)
2387 "Say whether this article is a pseudo article or not."
2388 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2390 (defmacro gnus-summary-article-sparse-p (article)
2391 "Say whether this article is a sparse article or not."
2392 `(memq ,article gnus-newsgroup-sparse))
2394 (defmacro gnus-summary-article-ancient-p (article)
2395 "Say whether this article is a sparse article or not."
2396 `(memq ,article gnus-newsgroup-ancient))
2398 (defun gnus-article-parent-p (number)
2399 "Say whether this article is a parent or not."
2400 (let ((data (gnus-data-find-list number)))
2401 (and (cdr data) ; There has to be an article after...
2402 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2403 (gnus-data-level (nth 1 data))))))
2405 (defun gnus-article-children (number)
2406 "Return a list of all children to NUMBER."
2407 (let* ((data (gnus-data-find-list number))
2408 (level (gnus-data-level (car data)))
2410 (setq data (cdr data))
2412 (= (gnus-data-level (car data)) (1+ level)))
2413 (push (gnus-data-number (car data)) children)
2414 (setq data (cdr data)))
2417 (defmacro gnus-summary-skip-intangible ()
2418 "If the current article is intangible, then jump to a different article."
2419 '(let ((to (get-text-property (point) 'gnus-intangible)))
2420 (and to (gnus-summary-goto-subject to))))
2422 (defmacro gnus-summary-article-intangible-p ()
2423 "Say whether this article is intangible or not."
2424 '(get-text-property (point) 'gnus-intangible))
2426 (defun gnus-article-read-p (article)
2427 "Say whether ARTICLE is read or not."
2428 (not (or (memq article gnus-newsgroup-marked)
2429 (memq article gnus-newsgroup-unreads)
2430 (memq article gnus-newsgroup-unselected)
2431 (memq article gnus-newsgroup-dormant))))
2433 ;; Some summary mode macros.
2435 (defmacro gnus-summary-article-number ()
2436 "The article number of the article on the current line.
2437 If there isn's an article number here, then we return the current
2440 (gnus-summary-skip-intangible)
2441 (or (get-text-property (point) 'gnus-number)
2442 (gnus-summary-last-subject))))
2444 (defmacro gnus-summary-article-header (&optional number)
2445 "Return the header of article NUMBER."
2446 `(gnus-data-header (gnus-data-find
2447 ,(or number '(gnus-summary-article-number)))))
2449 (defmacro gnus-summary-thread-level (&optional number)
2450 "Return the level of thread that starts with article NUMBER."
2451 `(if (and (eq gnus-summary-make-false-root 'dummy)
2452 (get-text-property (point) 'gnus-intangible))
2454 (gnus-data-level (gnus-data-find
2455 ,(or number '(gnus-summary-article-number))))))
2457 (defmacro gnus-summary-article-mark (&optional number)
2458 "Return the mark of article NUMBER."
2459 `(gnus-data-mark (gnus-data-find
2460 ,(or number '(gnus-summary-article-number)))))
2462 (defmacro gnus-summary-article-pos (&optional number)
2463 "Return the position of the line of article NUMBER."
2464 `(gnus-data-pos (gnus-data-find
2465 ,(or number '(gnus-summary-article-number)))))
2467 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2468 (defmacro gnus-summary-article-subject (&optional number)
2469 "Return current subject string or nil if nothing."
2472 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2473 '(gnus-data-header (assq (gnus-summary-article-number)
2474 gnus-newsgroup-data)))))
2477 (mail-header-subject headers))))
2479 (defmacro gnus-summary-article-score (&optional number)
2480 "Return current article score."
2481 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2482 gnus-newsgroup-scored))
2483 gnus-summary-default-score 0))
2485 (defun gnus-summary-article-children (&optional number)
2486 "Return a list of article numbers that are children of article NUMBER."
2487 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2488 (level (gnus-data-level (car data)))
2490 (while (and (setq data (cdr data))
2491 (> (setq l (gnus-data-level (car data))) level))
2492 (and (= (1+ level) l)
2493 (push (gnus-data-number (car data))
2495 (nreverse children)))
2497 (defun gnus-summary-article-parent (&optional number)
2498 "Return the article number of the parent of article NUMBER."
2499 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2500 (gnus-data-list t)))
2501 (level (gnus-data-level (car data))))
2503 () ; This is a root.
2504 ;; We search until we find an article with a level less than
2505 ;; this one. That function has to be the parent.
2506 (while (and (setq data (cdr data))
2507 (not (< (gnus-data-level (car data)) level))))
2508 (and data (gnus-data-number (car data))))))
2510 (defun gnus-unread-mark-p (mark)
2511 "Say whether MARK is the unread mark."
2512 (= mark gnus-unread-mark))
2514 (defun gnus-read-mark-p (mark)
2515 "Say whether MARK is one of the marks that mark as read.
2516 This is all marks except unread, ticked, dormant, and expirable."
2517 (not (or (= mark gnus-unread-mark)
2518 (= mark gnus-ticked-mark)
2519 (= mark gnus-dormant-mark)
2520 (= mark gnus-expirable-mark))))
2522 (defmacro gnus-article-mark (number)
2523 "Return the MARK of article NUMBER.
2524 This macro should only be used when computing the mark the \"first\"
2525 time; i.e., when generating the summary lines. After that,
2526 `gnus-summary-article-mark' should be used to examine the
2529 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2530 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2531 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2532 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2533 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2534 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2535 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2536 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2537 gnus-ancient-mark))))
2539 ;; Saving hidden threads.
2541 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2542 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2544 (defmacro gnus-save-hidden-threads (&rest forms)
2545 "Save hidden threads, eval FORMS, and restore the hidden threads."
2546 (let ((config (make-symbol "config")))
2547 `(let ((,config (gnus-hidden-threads-configuration)))
2551 (gnus-restore-hidden-threads-configuration ,config)))))
2553 (defun gnus-data-compute-positions ()
2554 "Compute the positions of all articles."
2555 (setq gnus-newsgroup-data-reverse nil)
2556 (let ((data gnus-newsgroup-data))
2558 (gnus-save-hidden-threads
2559 (gnus-summary-show-all-threads)
2560 (goto-char (point-min))
2562 (while (get-text-property (point) 'gnus-intangible)
2564 (gnus-data-set-pos (car data) (+ (point) 3))
2565 (setq data (cdr data))
2566 (forward-line 1))))))
2568 (defun gnus-hidden-threads-configuration ()
2569 "Return the current hidden threads configuration."
2572 (goto-char (point-min))
2573 (while (search-forward "\r" nil t)
2574 (push (1- (point)) config))
2577 (defun gnus-restore-hidden-threads-configuration (config)
2578 "Restore hidden threads configuration from CONFIG."
2580 (let (point buffer-read-only)
2581 (while (setq point (pop config))
2582 (when (and (< point (point-max))
2584 (eq (char-after) ?\n))
2585 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2587 ;; Various summary mode internalish functions.
2589 (defun gnus-mouse-pick-article (e)
2592 (gnus-summary-next-page nil t))
2594 (defun gnus-summary-set-display-table ()
2595 "Change the display table.
2596 Odd characters have a tendency to mess
2597 up nicely formatted displays - we make all possible glyphs
2598 display only a single character."
2600 ;; We start from the standard display table, if any.
2601 (let ((table (or (copy-sequence standard-display-table)
2602 (make-display-table)))
2604 ;; Nix out all the control chars...
2605 (while (>= (setq i (1- i)) 0)
2606 (aset table i [??]))
2607 ;; ... but not newline and cr, of course. (cr is necessary for the
2608 ;; selective display).
2609 (aset table ?\n nil)
2610 (aset table ?\r nil)
2611 ;; We keep TAB as well.
2612 (aset table ?\t nil)
2613 ;; We nix out any glyphs over 126 that are not set already.
2615 (while (>= (setq i (1- i)) 127)
2616 ;; Only modify if the entry is nil.
2617 (unless (aref table i)
2618 (aset table i [??]))))
2619 (setq buffer-display-table table)))
2621 (defun gnus-summary-buffer-name (group)
2622 "Return the summary buffer name of GROUP."
2623 (concat "*Summary " group "*"))
2625 (defun gnus-summary-setup-buffer (group)
2626 "Initialize summary buffer."
2627 (let ((buffer (gnus-summary-buffer-name group)))
2628 (if (get-buffer buffer)
2631 (setq gnus-summary-buffer (current-buffer))
2632 (not gnus-newsgroup-prepared))
2633 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2634 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2635 (gnus-summary-mode group)
2637 (gnus-carpal-setup-buffer 'summary))
2638 (unless gnus-single-article-buffer
2639 (make-local-variable 'gnus-article-buffer)
2640 (make-local-variable 'gnus-article-current)
2641 (make-local-variable 'gnus-original-article-buffer))
2642 (setq gnus-newsgroup-name group)
2645 (defun gnus-set-global-variables ()
2646 "Set the global equivalents of the buffer-local variables.
2647 They are set to the latest values they had. These reflect the summary
2648 buffer that was in action when the last article was fetched."
2649 (when (eq major-mode 'gnus-summary-mode)
2650 (setq gnus-summary-buffer (current-buffer))
2651 (let ((name gnus-newsgroup-name)
2652 (marked gnus-newsgroup-marked)
2653 (unread gnus-newsgroup-unreads)
2654 (headers gnus-current-headers)
2655 (data gnus-newsgroup-data)
2656 (summary gnus-summary-buffer)
2657 (article-buffer gnus-article-buffer)
2658 (original gnus-original-article-buffer)
2659 (gac gnus-article-current)
2660 (reffed gnus-reffed-article-number)
2661 (score-file gnus-current-score-file)
2662 (default-charset gnus-newsgroup-charset)
2664 (let ((locals gnus-newsgroup-variables))
2666 (if (consp (car locals))
2667 (push (eval (caar locals)) vlist)
2668 (push (eval (car locals)) vlist))
2669 (setq locals (cdr locals)))
2670 (setq vlist (nreverse vlist)))
2672 (set-buffer gnus-group-buffer)
2673 (setq gnus-newsgroup-name name
2674 gnus-newsgroup-marked marked
2675 gnus-newsgroup-unreads unread
2676 gnus-current-headers headers
2677 gnus-newsgroup-data data
2678 gnus-article-current gac
2679 gnus-summary-buffer summary
2680 gnus-article-buffer article-buffer
2681 gnus-original-article-buffer original
2682 gnus-reffed-article-number reffed
2683 gnus-current-score-file score-file
2684 gnus-newsgroup-charset default-charset)
2685 (let ((locals gnus-newsgroup-variables))
2687 (if (consp (car locals))
2688 (set (caar locals) (pop vlist))
2689 (set (car locals) (pop vlist)))
2690 (setq locals (cdr locals))))
2691 ;; The article buffer also has local variables.
2692 (when (gnus-buffer-live-p gnus-article-buffer)
2693 (set-buffer gnus-article-buffer)
2694 (setq gnus-summary-buffer summary))))))
2696 (defun gnus-summary-article-unread-p (article)
2697 "Say whether ARTICLE is unread or not."
2698 (memq article gnus-newsgroup-unreads))
2700 (defun gnus-summary-first-article-p (&optional article)
2701 "Return whether ARTICLE is the first article in the buffer."
2702 (if (not (setq article (or article (gnus-summary-article-number))))
2704 (eq article (caar gnus-newsgroup-data))))
2706 (defun gnus-summary-last-article-p (&optional article)
2707 "Return whether ARTICLE is the last article in the buffer."
2708 (if (not (setq article (or article (gnus-summary-article-number))))
2709 ;; All non-existent numbers are the last article. :-)
2711 (not (cdr (gnus-data-find-list article)))))
2713 (defun gnus-make-thread-indent-array ()
2715 (unless (and gnus-thread-indent-array
2716 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2717 (setq gnus-thread-indent-array (make-vector 201 "")
2718 gnus-thread-indent-array-level gnus-thread-indent-level)
2720 (aset gnus-thread-indent-array n
2721 (make-string (* n gnus-thread-indent-level) ? ))
2724 (defun gnus-update-summary-mark-positions ()
2725 "Compute where the summary marks are to go."
2727 (when (gnus-buffer-exists-p gnus-summary-buffer)
2728 (set-buffer gnus-summary-buffer))
2729 (let ((gnus-replied-mark 129)
2730 (gnus-score-below-mark 130)
2731 (gnus-score-over-mark 130)
2732 (gnus-download-mark 131)
2733 (spec gnus-summary-line-format-spec)
2736 (gnus-set-work-buffer)
2737 (let ((gnus-summary-line-format-spec spec)
2738 (gnus-newsgroup-downloadable '((0 . t))))
2739 (gnus-summary-insert-line
2740 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2741 (goto-char (point-min))
2742 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2744 (goto-char (point-min))
2745 (push (cons 'replied (and (search-forward "\201" nil t)
2748 (goto-char (point-min))
2749 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2751 (goto-char (point-min))
2752 (push (cons 'download
2753 (and (search-forward "\203" nil t) (- (point) 2)))
2755 (setq gnus-summary-mark-positions pos))))
2757 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2758 "Insert a dummy root in the summary buffer."
2760 (gnus-add-text-properties
2761 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2762 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2764 (defun gnus-summary-from-or-to-or-newsgroups (header)
2765 (let ((to (cdr (assq 'To (mail-header-extra header))))
2766 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2767 (mail-parse-charset gnus-newsgroup-charset)
2768 (mail-parse-ignored-charsets
2769 (save-excursion (set-buffer gnus-summary-buffer)
2770 gnus-newsgroup-ignored-charsets)))
2773 gnus-ignored-from-addresses
2774 (string-match gnus-ignored-from-addresses
2775 (mail-header-from header)))
2777 (or (car (funcall gnus-extract-address-components
2779 gnus-decode-encoded-word-function to)))
2780 (funcall gnus-decode-encoded-word-function to))))
2782 gnus-ignored-from-addresses
2783 (string-match gnus-ignored-from-addresses
2784 (mail-header-from header)))
2785 (concat "=> " newsgroups))
2787 (or (car (funcall gnus-extract-address-components
2788 (mail-header-from header)))
2789 (mail-header-from header))))))
2791 (defun gnus-summary-insert-line (gnus-tmp-header
2792 gnus-tmp-level gnus-tmp-current
2793 gnus-tmp-unread gnus-tmp-replied
2794 gnus-tmp-expirable gnus-tmp-subject-or-nil
2795 &optional gnus-tmp-dummy gnus-tmp-score
2797 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2798 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2799 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2800 (gnus-tmp-score-char
2801 (if (or (null gnus-summary-default-score)
2802 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2803 gnus-summary-zcore-fuzz))
2805 (if (< gnus-tmp-score gnus-summary-default-score)
2806 gnus-score-below-mark gnus-score-over-mark)))
2808 (cond (gnus-tmp-process gnus-process-mark)
2809 ((memq gnus-tmp-current gnus-newsgroup-cached)
2811 (gnus-tmp-replied gnus-replied-mark)
2812 ((memq gnus-tmp-current gnus-newsgroup-saved)
2815 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2818 ((string-match "<[^>]+> *$" gnus-tmp-from)
2819 (let ((beg (match-beginning 0)))
2820 (or (and (string-match "^\".+\"" gnus-tmp-from)
2821 (substring gnus-tmp-from 1 (1- (match-end 0))))
2822 (substring gnus-tmp-from 0 beg))))
2823 ((string-match "(.+)" gnus-tmp-from)
2824 (substring gnus-tmp-from
2825 (1+ (match-beginning 0)) (1- (match-end 0))))
2827 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2828 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2829 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2830 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2831 (buffer-read-only nil))
2832 (when (string= gnus-tmp-name "")
2833 (setq gnus-tmp-name gnus-tmp-from))
2834 (unless (numberp gnus-tmp-lines)
2835 (setq gnus-tmp-lines 0))
2836 (gnus-put-text-property
2838 (progn (eval gnus-summary-line-format-spec) (point))
2839 'gnus-number gnus-tmp-number)
2840 (when (gnus-visual-p 'summary-highlight 'highlight)
2842 (gnus-run-hooks 'gnus-summary-update-hook)
2845 (defun gnus-summary-update-line (&optional dont-update)
2846 "Update summary line after change."
2847 (when (and gnus-summary-default-score
2848 (not gnus-summary-inhibit-highlight))
2849 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2850 (article (gnus-summary-article-number))
2851 (score (gnus-summary-article-score article)))
2853 (if (and gnus-summary-mark-below
2854 (< (gnus-summary-article-score)
2855 gnus-summary-mark-below))
2856 ;; This article has a low score, so we mark it as read.
2857 (when (memq article gnus-newsgroup-unreads)
2858 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2859 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2860 ;; This article was previously marked as read on account
2861 ;; of a low score, but now it has risen, so we mark it as
2863 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2864 (gnus-summary-update-mark
2865 (if (or (null gnus-summary-default-score)
2866 (<= (abs (- score gnus-summary-default-score))
2867 gnus-summary-zcore-fuzz))
2869 (if (< score gnus-summary-default-score)
2870 gnus-score-below-mark gnus-score-over-mark))
2872 ;; Do visual highlighting.
2873 (when (gnus-visual-p 'summary-highlight 'highlight)
2874 (gnus-run-hooks 'gnus-summary-update-hook)))))
2876 (defvar gnus-tmp-new-adopts nil)
2878 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2879 "Return the number of articles in THREAD.
2880 This may be 0 in some cases -- if none of the articles in
2881 the thread are to be displayed."
2883 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2885 ((not (listp thread))
2887 ((and (consp thread) (cdr thread))
2890 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2893 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2896 (when (and level (zerop level) gnus-tmp-new-adopts)
2899 'gnus-summary-number-of-articles-in-thread
2900 gnus-tmp-new-adopts))))
2902 (if (> number 1) gnus-not-empty-thread-mark
2903 gnus-empty-thread-mark)
2906 (defun gnus-summary-set-local-parameters (group)
2907 "Go through the local params of GROUP and set all variable specs in that list."
2908 (let ((params (gnus-group-find-parameter group))
2911 (setq elem (car params)
2912 params (cdr params))
2913 (and (consp elem) ; Has to be a cons.
2914 (consp (cdr elem)) ; The cdr has to be a list.
2915 (symbolp (car elem)) ; Has to be a symbol in there.
2916 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2917 (ignore-errors ; So we set it.
2918 (make-local-variable (car elem))
2919 (set (car elem) (eval (nth 1 elem))))))))
2921 (defun gnus-summary-read-group (group &optional show-all no-article
2922 kill-buffer no-display backward
2924 "Start reading news in newsgroup GROUP.
2925 If SHOW-ALL is non-nil, already read articles are also listed.
2926 If NO-ARTICLE is non-nil, no article is selected initially.
2927 If NO-DISPLAY, don't generate a summary buffer."
2931 (let ((gnus-auto-select-next nil))
2932 (or (gnus-summary-read-group-1
2933 group show-all no-article
2934 kill-buffer no-display
2937 select-articles nil)))))
2938 (eq gnus-auto-select-next 'quietly))
2939 (set-buffer gnus-group-buffer)
2940 ;; The entry function called above goes to the next
2941 ;; group automatically, so we go two groups back
2942 ;; if we are searching for the previous group.
2944 (gnus-group-prev-unread-group 2))
2945 (if (not (equal group (gnus-group-group-name)))
2946 (setq group (gnus-group-group-name))
2950 (defun gnus-summary-read-group-1 (group show-all no-article
2951 kill-buffer no-display
2952 &optional select-articles)
2953 ;; Killed foreign groups can't be entered.
2954 ;; (when (and (not (gnus-group-native-p group))
2955 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
2956 ;; (error "Dead non-native groups can't be entered"))
2957 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2958 (let* ((new-group (gnus-summary-setup-buffer group))
2959 (quit-config (gnus-group-quit-config group))
2960 (did-select (and new-group (gnus-select-newsgroup
2961 group show-all select-articles))))
2963 ;; This summary buffer exists already, so we just select it.
2965 (gnus-set-global-variables)
2967 (gnus-kill-or-deaden-summary kill-buffer))
2968 (gnus-configure-windows 'summary 'force)
2969 (gnus-set-mode-line 'summary)
2970 (gnus-summary-position-point)
2973 ;; We couldn't select this group.
2975 (when (and (eq major-mode 'gnus-summary-mode)
2976 (not (equal (current-buffer) kill-buffer)))
2977 (kill-buffer (current-buffer))
2978 (if (not quit-config)
2980 ;; Update the info -- marks might need to be removed,
2982 (gnus-summary-update-info)
2983 (set-buffer gnus-group-buffer)
2984 (gnus-group-jump-to-group group)
2985 (gnus-group-next-unread-group 1))
2986 (gnus-handle-ephemeral-exit quit-config)))
2987 (let ((grpinfo (gnus-get-info group)))
2988 (if (null (gnus-info-read grpinfo))
2989 (gnus-message 3 "Group %s contains no messages" group)
2990 (gnus-message 3 "Can't select group")))
2992 ;; The user did a `C-g' while prompting for number of articles,
2993 ;; so we exit this group.
2994 ((eq did-select 'quit)
2995 (and (eq major-mode 'gnus-summary-mode)
2996 (not (equal (current-buffer) kill-buffer))
2997 (kill-buffer (current-buffer)))
2999 (gnus-kill-or-deaden-summary kill-buffer))
3000 (if (not quit-config)
3002 (set-buffer gnus-group-buffer)
3003 (gnus-group-jump-to-group group)
3004 (gnus-group-next-unread-group 1)
3005 (gnus-configure-windows 'group 'force))
3006 (gnus-handle-ephemeral-exit quit-config))
3007 ;; Finally signal the quit.
3009 ;; The group was successfully selected.
3011 (gnus-set-global-variables)
3012 ;; Save the active value in effect when the group was entered.
3013 (setq gnus-newsgroup-active
3015 (gnus-active gnus-newsgroup-name)))
3016 ;; You can change the summary buffer in some way with this hook.
3017 (gnus-run-hooks 'gnus-select-group-hook)
3018 ;; Set any local variables in the group parameters.
3019 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3020 (gnus-update-format-specifications
3021 nil 'summary 'summary-mode 'summary-dummy)
3022 (gnus-update-summary-mark-positions)
3023 ;; Do score processing.
3024 (when gnus-use-scoring
3025 (gnus-possibly-score-headers))
3026 ;; Check whether to fill in the gaps in the threads.
3027 (when gnus-build-sparse-threads
3028 (gnus-build-sparse-threads))
3029 ;; Find the initial limit.
3030 (if gnus-show-threads
3032 (let ((gnus-newsgroup-dormant nil))
3033 (gnus-summary-initial-limit show-all))
3034 (gnus-summary-initial-limit show-all))
3035 ;; When untreaded, all articles are always shown.
3036 (setq gnus-newsgroup-limit
3038 (lambda (header) (mail-header-number header))
3039 gnus-newsgroup-headers)))
3040 ;; Generate the summary buffer.
3042 (gnus-summary-prepare))
3043 (when gnus-use-trees
3044 (gnus-tree-open group)
3045 (setq gnus-summary-highlight-line-function
3046 'gnus-tree-highlight-article))
3047 ;; If the summary buffer is empty, but there are some low-scored
3048 ;; articles or some excluded dormants, we include these in the
3050 (when (and (zerop (buffer-size))
3052 (cond (gnus-newsgroup-dormant
3053 (gnus-summary-limit-include-dormant))
3054 ((and gnus-newsgroup-scored show-all)
3055 (gnus-summary-limit-include-expunged t))))
3056 ;; Function `gnus-apply-kill-file' must be called in this hook.
3057 (gnus-run-hooks 'gnus-apply-kill-hook)
3058 (if (and (zerop (buffer-size))
3061 ;; This newsgroup is empty.
3062 (gnus-summary-catchup-and-exit nil t)
3063 (gnus-message 6 "No unread news")
3065 (gnus-kill-or-deaden-summary kill-buffer))
3066 ;; Return nil from this function.
3068 ;; Hide conversation thread subtrees. We cannot do this in
3069 ;; gnus-summary-prepare-hook since kill processing may not
3070 ;; work with hidden articles.
3071 (and gnus-show-threads
3072 gnus-thread-hide-subtree
3073 (gnus-summary-hide-all-threads))
3075 (gnus-kill-or-deaden-summary kill-buffer))
3076 ;; Show first unread article if requested.
3077 (if (and (not no-article)
3079 gnus-newsgroup-unreads
3080 gnus-auto-select-first)
3082 (gnus-configure-windows 'summary)
3084 ((eq gnus-auto-select-first 'best)
3085 (gnus-summary-best-unread-article))
3086 ((eq gnus-auto-select-first t)
3087 (gnus-summary-first-unread-article))
3088 ((gnus-functionp gnus-auto-select-first)
3089 (funcall gnus-auto-select-first))))
3090 ;; Don't select any articles, just move point to the first
3091 ;; article in the group.
3092 (goto-char (point-min))
3093 (gnus-summary-position-point)
3094 (gnus-configure-windows 'summary 'force)
3095 (gnus-set-mode-line 'summary))
3096 (when (get-buffer-window gnus-group-buffer t)
3097 ;; Gotta use windows, because recenter does weird stuff if
3098 ;; the current buffer ain't the displayed window.
3099 (let ((owin (selected-window)))
3100 (select-window (get-buffer-window gnus-group-buffer t))
3101 (when (gnus-group-goto-group group)
3103 (select-window owin)))
3104 ;; Mark this buffer as "prepared".
3105 (setq gnus-newsgroup-prepared t)
3106 (gnus-run-hooks 'gnus-summary-prepared-hook)
3109 (defun gnus-summary-prepare ()
3110 "Generate the summary buffer."
3112 (let ((buffer-read-only nil))
3114 (setq gnus-newsgroup-data nil
3115 gnus-newsgroup-data-reverse nil)
3116 (gnus-run-hooks 'gnus-summary-generate-hook)
3117 ;; Generate the buffer, either with threads or without.
3118 (when gnus-newsgroup-headers
3119 (gnus-summary-prepare-threads
3120 (if gnus-show-threads
3121 (gnus-sort-gathered-threads
3122 (funcall gnus-summary-thread-gathering-function
3124 (gnus-cut-threads (gnus-make-threads)))))
3125 ;; Unthreaded display.
3126 (gnus-sort-articles gnus-newsgroup-headers))))
3127 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3128 ;; Call hooks for modifying summary buffer.
3129 (goto-char (point-min))
3130 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3132 (defsubst gnus-general-simplify-subject (subject)
3133 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3136 ;; Truncate the subject.
3137 (gnus-simplify-subject-functions
3138 (gnus-map-function gnus-simplify-subject-functions subject))
3139 ((numberp gnus-summary-gather-subject-limit)
3140 (setq subject (gnus-simplify-subject-re subject))
3141 (if (> (length subject) gnus-summary-gather-subject-limit)
3142 (substring subject 0 gnus-summary-gather-subject-limit)
3144 ;; Fuzzily simplify it.
3145 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3146 (gnus-simplify-subject-fuzzy subject))
3147 ;; Just remove the leading "Re:".
3149 (gnus-simplify-subject-re subject))))
3151 (if (and gnus-summary-gather-exclude-subject
3152 (string-match gnus-summary-gather-exclude-subject subject))
3153 nil ; This article shouldn't be gathered
3156 (defun gnus-summary-simplify-subject-query ()
3157 "Query where the respool algorithm would put this article."
3159 (gnus-summary-select-article)
3160 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3162 (defun gnus-gather-threads-by-subject (threads)
3163 "Gather threads by looking at Subject headers."
3164 (if (not gnus-summary-make-false-root)
3166 (let ((hashtb (gnus-make-hashtable 1024))
3169 subject hthread whole-subject)
3171 (setq subject (gnus-general-simplify-subject
3172 (setq whole-subject (mail-header-subject
3175 (if (setq hthread (gnus-gethash subject hashtb))
3177 ;; We enter a dummy root into the thread, if we
3178 ;; haven't done that already.
3179 (unless (stringp (caar hthread))
3180 (setcar hthread (list whole-subject (car hthread))))
3181 ;; We add this new gathered thread to this gathered
3183 (setcdr (car hthread)
3184 (nconc (cdar hthread) (list (car threads))))
3185 ;; Remove it from the list of threads.
3186 (setcdr prev (cdr threads))
3187 (setq threads prev))
3188 ;; Enter this thread into the hash table.
3189 (gnus-sethash subject threads hashtb)))
3191 (setq threads (cdr threads)))
3194 (defun gnus-gather-threads-by-references (threads)
3195 "Gather threads by looking at References headers."
3196 (let ((idhashtb (gnus-make-hashtable 1024))
3197 (thhashtb (gnus-make-hashtable 1024))
3200 ids references id gthread gid entered ref)
3202 (when (setq references (mail-header-references (caar threads)))
3203 (setq id (mail-header-id (caar threads))
3204 ids (gnus-split-references references)
3206 (while (setq ref (pop ids))
3207 (setq ids (delete ref ids))
3208 (if (not (setq gid (gnus-gethash ref idhashtb)))
3210 (gnus-sethash ref id idhashtb)
3211 (gnus-sethash id threads thhashtb))
3212 (setq gthread (gnus-gethash gid thhashtb))
3214 ;; We enter a dummy root into the thread, if we
3215 ;; haven't done that already.
3216 (unless (stringp (caar gthread))
3217 (setcar gthread (list (mail-header-subject (caar gthread))
3219 ;; We add this new gathered thread to this gathered
3221 (setcdr (car gthread)
3222 (nconc (cdar gthread) (list (car threads)))))
3223 ;; Add it into the thread hash table.
3224 (gnus-sethash id gthread thhashtb)
3226 ;; Remove it from the list of threads.
3227 (setcdr prev (cdr threads))
3228 (setq threads prev))))
3230 (setq threads (cdr threads)))
3233 (defun gnus-sort-gathered-threads (threads)
3234 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3235 (let ((result threads))
3237 (when (stringp (caar threads))
3238 (setcdr (car threads)
3239 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3240 (setq threads (cdr threads)))
3243 (defun gnus-thread-loop-p (root thread)
3244 "Say whether ROOT is in THREAD."
3245 (let ((stack (list thread))
3248 (while (setq thread (pop stack))
3249 (setq th (cdr thread))
3251 (not (eq (caar th) root)))
3254 ;; We have found a loop.
3256 (setcdr thread (delq (car th) (cdr thread)))
3257 (if (boundp (setq ref-dep (intern "none"
3258 gnus-newsgroup-dependencies)))
3259 (setcdr (symbol-value ref-dep)
3260 (nconc (cdr (symbol-value ref-dep))
3262 (set ref-dep (list nil (car th))))
3265 ;; Push all the subthreads onto the stack.
3266 (push (cdr thread) stack)))
3269 (defun gnus-make-threads ()
3270 "Go through the dependency hashtb and find the roots. Return all threads."
3272 (while (catch 'infloop
3275 ;; Deal with self-referencing References loops.
3276 (when (and (car (symbol-value refs))
3283 (car (symbol-value refs)) thread))
3284 (cdr (symbol-value refs)))))))
3287 (unless (car (symbol-value refs))
3288 ;; These threads do not refer back to any other articles,
3289 ;; so they're roots.
3290 (setq threads (append (cdr (symbol-value refs)) threads))))
3291 gnus-newsgroup-dependencies)))
3294 ;; Build the thread tree.
3295 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3296 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3298 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3299 if it was already present.
3301 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3302 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3303 Message-IDs will be renamed be renamed to a unique Message-ID before
3306 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3307 (let* ((id (mail-header-id header))
3308 (id-dep (and id (intern id dependencies)))
3309 ref ref-dep ref-header)
3310 ;; Enter this `header' in the `dependencies' table.
3314 ;; The first two cases do the normal part: enter a new `header'
3315 ;; in the `dependencies' table.
3316 ((not (boundp id-dep))
3317 (set id-dep (list header)))
3318 ((null (car (symbol-value id-dep)))
3319 (setcar (symbol-value id-dep) header))
3321 ;; From here the `header' was already present in the
3322 ;; `dependencies' table.
3324 ;; Overrides an existing entry;
3325 ;; just set the header part of the entry.
3326 (setcar (symbol-value id-dep) header))
3328 ;; Renames the existing `header' to a unique Message-ID.
3329 ((not gnus-summary-ignore-duplicates)
3330 ;; An article with this Message-ID has already been seen.
3331 ;; We rename the Message-ID.
3332 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3334 (mail-header-set-id header id))
3336 ;; The last case ignores an existing entry, except it adds any
3337 ;; additional Xrefs (in case the two articles came from different
3339 ;; Also sets `header' to `nil' meaning that the `dependencies'
3340 ;; table was *not* modified.
3342 (mail-header-set-xref
3343 (car (symbol-value id-dep))
3344 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3346 (or (mail-header-xref header) "")))
3350 ;; First check if that we are not creating a References loop.
3351 (setq ref (gnus-parent-id (mail-header-references header)))
3353 (setq ref-dep (intern-soft ref dependencies))
3355 (setq ref-header (car (symbol-value ref-dep))))
3356 (if (string= id ref)
3357 ;; Yuk! This is a reference loop. Make the article be a
3360 (mail-header-set-references (car (symbol-value id-dep)) "none")
3362 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3363 (setq ref (gnus-parent-id (mail-header-references header)))
3364 (setq ref-dep (intern (or ref "none") dependencies))
3365 (if (boundp ref-dep)
3366 (setcdr (symbol-value ref-dep)
3367 (nconc (cdr (symbol-value ref-dep))
3368 (list (symbol-value id-dep))))
3369 (set ref-dep (list nil (symbol-value id-dep)))))
3372 (defun gnus-build-sparse-threads ()
3373 (let ((headers gnus-newsgroup-headers)
3374 (mail-parse-charset gnus-newsgroup-charset)
3375 (gnus-summary-ignore-duplicates t)
3376 header references generation relations
3377 subject child end new-child date)
3378 ;; First we create an alist of generations/relations, where
3379 ;; generations is how much we trust the relation, and the relation
3381 (gnus-message 7 "Making sparse threads...")
3383 (nnheader-set-temp-buffer " *gnus sparse threads*")
3384 (while (setq header (pop headers))
3385 (when (and (setq references (mail-header-references header))
3386 (not (string= references "")))
3388 (setq child (mail-header-id header)
3389 subject (mail-header-subject header)
3390 date (mail-header-date header)
3392 (while (search-backward ">" nil t)
3393 (setq end (1+ (point)))
3394 (when (search-backward "<" nil t)
3395 (setq new-child (buffer-substring (point) end))
3396 (push (list (incf generation)
3397 child (setq child new-child)
3401 (push (list (1+ generation) child nil subject) relations))
3403 (kill-buffer (current-buffer)))
3404 ;; Sort over trustworthiness.
3407 (when (gnus-dependencies-add-header
3408 (make-full-mail-header
3409 gnus-reffed-article-number
3410 (nth 3 relation) "" (or (nth 4 relation) "")
3412 (or (nth 2 relation) "") 0 0 "")
3413 gnus-newsgroup-dependencies nil)
3414 (push gnus-reffed-article-number gnus-newsgroup-limit)
3415 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3416 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3417 gnus-newsgroup-reads)
3418 (decf gnus-reffed-article-number)))
3419 (sort relations 'car-less-than-car))
3420 (gnus-message 7 "Making sparse threads...done")))
3422 (defun gnus-build-old-threads ()
3423 ;; Look at all the articles that refer back to old articles, and
3424 ;; fetch the headers for the articles that aren't there. This will
3425 ;; build complete threads - if the roots haven't been expired by the
3427 (let ((mail-parse-charset gnus-newsgroup-charset)
3431 (when (not (car (symbol-value refs)))
3432 (setq heads (cdr (symbol-value refs)))
3434 (if (memq (mail-header-number (caar heads))
3435 gnus-newsgroup-dormant)
3436 (setq heads (cdr heads))
3437 (setq id (symbol-name refs))
3438 (while (and (setq id (gnus-build-get-header id))
3439 (not (car (gnus-id-to-thread id)))))
3440 (setq heads nil)))))
3441 gnus-newsgroup-dependencies)))
3443 ;; This function has to be called with point after the article number
3444 ;; on the beginning of the line.
3445 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3446 (let ((eol (gnus-point-at-eol))
3447 (buffer (current-buffer))
3450 ;; overview: [num subject from date id refs chars lines misc]
3453 (narrow-to-region (point) eol)
3458 (make-full-mail-header
3460 (funcall gnus-decode-encoded-word-function
3461 (nnheader-nov-field)) ; subject
3462 (funcall gnus-decode-encoded-word-function
3463 (nnheader-nov-field)) ; from
3464 (nnheader-nov-field) ; date
3465 (nnheader-nov-read-message-id) ; id
3466 (nnheader-nov-field) ; refs
3467 (nnheader-nov-read-integer) ; chars
3468 (nnheader-nov-read-integer) ; lines
3470 (if (looking-at "Xref: ")
3471 (goto-char (match-end 0)))
3472 (nnheader-nov-field)) ; Xref
3473 (nnheader-nov-parse-extra)))) ; extra
3477 (when gnus-alter-header-function
3478 (funcall gnus-alter-header-function header))
3479 (gnus-dependencies-add-header header dependencies force-new)))
3481 (defun gnus-build-get-header (id)
3482 "Look through the buffer of NOV lines and find the header to ID.
3483 Enter this line into the dependencies hash table, and return
3484 the id of the parent article (if any)."
3485 (let ((deps gnus-newsgroup-dependencies)
3489 (set-buffer nntp-server-buffer)
3490 (let ((case-fold-search nil))
3491 (goto-char (point-min))
3492 (while (and (not found)
3493 (search-forward id nil t))
3495 (setq found (looking-at
3496 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3497 (regexp-quote id))))
3498 (or found (beginning-of-line 2)))
3502 (setq header (gnus-nov-parse-line
3503 (read (current-buffer)) deps))
3504 (gnus-parent-id (mail-header-references header))))))
3506 (let ((number (mail-header-number header)))
3507 (push number gnus-newsgroup-limit)
3508 (push header gnus-newsgroup-headers)
3509 (if (memq number gnus-newsgroup-unselected)
3511 (push number gnus-newsgroup-unreads)
3512 (setq gnus-newsgroup-unselected
3513 (delq number gnus-newsgroup-unselected)))
3514 (push number gnus-newsgroup-ancient)))))))
3516 (defun gnus-build-all-threads ()
3517 "Read all the headers."
3518 (let ((gnus-summary-ignore-duplicates t)
3519 (mail-parse-charset gnus-newsgroup-charset)
3520 (dependencies gnus-newsgroup-dependencies)
3523 (set-buffer nntp-server-buffer)
3524 (let ((case-fold-search nil))
3525 (goto-char (point-min))
3528 (setq article (read (current-buffer))
3529 header (gnus-nov-parse-line article dependencies)))
3532 (set-buffer gnus-summary-buffer)
3533 (push header gnus-newsgroup-headers)
3534 (if (memq (setq article (mail-header-number header))
3535 gnus-newsgroup-unselected)
3537 (push article gnus-newsgroup-unreads)
3538 (setq gnus-newsgroup-unselected
3539 (delq article gnus-newsgroup-unselected)))
3540 (push article gnus-newsgroup-ancient)))
3541 (forward-line 1)))))))
3543 (defun gnus-summary-update-article-line (article header)
3544 "Update the line for ARTICLE using HEADERS."
3545 (let* ((id (mail-header-id header))
3546 (thread (gnus-id-to-thread id)))
3548 (error "Article in no thread"))
3549 ;; Update the thread.
3550 (setcar thread header)
3551 (gnus-summary-goto-subject article)
3552 (let* ((datal (gnus-data-find-list article))
3554 (length (when (cdr datal)
3555 (- (gnus-data-pos data)
3556 (gnus-data-pos (cadr datal)))))
3557 (buffer-read-only nil)
3558 (level (gnus-summary-thread-level)))
3560 (gnus-summary-insert-line
3561 header level nil (gnus-article-mark article)
3562 (memq article gnus-newsgroup-replied)
3563 (memq article gnus-newsgroup-expirable)
3564 ;; Only insert the Subject string when it's different
3565 ;; from the previous Subject string.
3570 (mail-header-subject
3573 (gnus-data-find-list
3575 (gnus-data-list t)))))
3576 ;; Error on the side of excessive subjects.
3578 (mail-header-subject header)))
3580 (mail-header-subject header))
3581 nil (cdr (assq article gnus-newsgroup-scored))
3582 (memq article gnus-newsgroup-processable))
3584 (gnus-data-update-list
3585 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3587 (defun gnus-summary-update-article (article &optional iheader)
3588 "Update ARTICLE in the summary buffer."
3589 (set-buffer gnus-summary-buffer)
3590 (let* ((header (gnus-summary-article-header article))
3591 (id (mail-header-id header))
3592 (data (gnus-data-find article))
3593 (thread (gnus-id-to-thread id))
3594 (references (mail-header-references header))
3598 (when (and references
3599 (not (equal "" references)))
3602 (buffer-read-only nil)
3608 (delq thread parent)))
3609 (if (gnus-summary-insert-subject id header)
3610 ;; Set the (possibly) new article number in the data structure.
3611 (gnus-data-set-number data (gnus-id-to-article id))
3615 (defun gnus-rebuild-thread (id &optional line)
3616 "Rebuild the thread containing ID.
3617 If LINE, insert the rebuilt thread starting on line LINE."
3618 (let ((buffer-read-only nil)
3619 old-pos current thread data)
3620 (if (not gnus-show-threads)
3621 (setq thread (list (car (gnus-id-to-thread id))))
3622 ;; Get the thread this article is part of.
3623 (setq thread (gnus-remove-thread id)))
3624 (setq old-pos (gnus-point-at-bol))
3625 (setq current (save-excursion
3626 (and (zerop (forward-line -1))
3627 (gnus-summary-article-number))))
3628 ;; If this is a gathered thread, we have to go some re-gathering.
3629 (when (stringp (car thread))
3630 (let ((subject (car thread))
3632 (setq thread (cdr thread))
3634 (unless (memq (setq thr (gnus-id-to-thread
3636 (mail-header-id (caar thread)))))
3639 (setq thread (cdr thread)))
3640 ;; We now have all (unique) roots.
3641 (if (= (length roots) 1)
3642 ;; All the loose roots are now one solid root.
3643 (setq thread (car roots))
3644 (setq thread (cons subject (gnus-sort-threads roots))))))
3646 ;; We then insert this thread into the summary buffer.
3648 (goto-char (point-min))
3649 (forward-line (1- line)))
3650 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3651 (if gnus-show-threads
3652 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3653 (gnus-summary-prepare-unthreaded thread))
3654 (setq data (nreverse gnus-newsgroup-data))
3655 (setq threads gnus-newsgroup-threads))
3656 ;; We splice the new data into the data structure.
3657 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3658 ;;!!! then we want to insert at the beginning of the buffer.
3659 ;;!!! That happens to be true with Gnus now, but that may
3660 ;;!!! change in the future. Perhaps.
3661 (gnus-data-enter-list
3662 (if line nil current) data (- (point) old-pos))
3663 (setq gnus-newsgroup-threads
3664 (nconc threads gnus-newsgroup-threads))
3665 (gnus-data-compute-positions))))
3667 (defun gnus-number-to-header (number)
3668 "Return the header for article NUMBER."
3669 (let ((headers gnus-newsgroup-headers))
3671 (not (= number (mail-header-number (car headers)))))
3676 (defun gnus-parent-headers (in-headers &optional generation)
3677 "Return the headers of the GENERATIONeth parent of HEADERS."
3679 (setq generation 1))
3681 (headers in-headers)
3684 (not (zerop generation))
3685 (setq references (mail-header-references headers)))
3686 (setq headers (if (and references
3687 (setq parent (gnus-parent-id references)))
3688 (car (gnus-id-to-thread parent))
3691 (and (not (eq headers in-headers))
3694 (defun gnus-id-to-thread (id)
3695 "Return the (sub-)thread where ID appears."
3696 (gnus-gethash id gnus-newsgroup-dependencies))
3698 (defun gnus-id-to-article (id)
3699 "Return the article number of ID."
3700 (let ((thread (gnus-id-to-thread id)))
3703 (mail-header-number (car thread)))))
3705 (defun gnus-id-to-header (id)
3706 "Return the article headers of ID."
3707 (car (gnus-id-to-thread id)))
3709 (defun gnus-article-displayed-root-p (article)
3710 "Say whether ARTICLE is a root(ish) article."
3711 (let ((level (gnus-summary-thread-level article))
3712 (refs (mail-header-references (gnus-summary-article-header article)))
3718 ((null (gnus-parent-id refs)) t)
3720 (null (setq particle (gnus-id-to-article
3721 (gnus-parent-id refs))))
3722 (null (gnus-summary-thread-level particle)))))))
3724 (defun gnus-root-id (id)
3725 "Return the id of the root of the thread where ID appears."
3727 (while (and id (setq prev (car (gnus-id-to-thread id))))
3729 id (gnus-parent-id (mail-header-references prev))))
3732 (defun gnus-articles-in-thread (thread)
3733 "Return the list of articles in THREAD."
3734 (cons (mail-header-number (car thread))
3735 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3737 (defun gnus-remove-thread (id &optional dont-remove)
3738 "Remove the thread that has ID in it."
3739 (let (headers thread last-id)
3740 ;; First go up in this thread until we find the root.
3741 (setq last-id (gnus-root-id id)
3742 headers (message-flatten-list (gnus-id-to-thread last-id)))
3743 ;; We have now found the real root of this thread. It might have
3744 ;; been gathered into some loose thread, so we have to search
3745 ;; through the threads to find the thread we wanted.
3746 (let ((threads gnus-newsgroup-threads)
3749 (setq sub (car threads))
3750 (if (stringp (car sub))
3751 ;; This is a gathered thread, so we look at the roots
3752 ;; below it to find whether this article is in this
3755 (setq sub (cdr sub))
3757 (when (member (caar sub) headers)
3758 (setq thread (car threads)
3761 (setq sub (cdr sub))))
3762 ;; It's an ordinary thread, so we check it.
3763 (when (eq (car sub) (car headers))
3766 (setq threads (cdr threads)))
3767 ;; If this article is in no thread, then it's a root.
3770 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3771 (setq thread (gnus-id-to-thread last-id)))
3774 thread ; We return this thread.
3776 (if (stringp (car thread))
3778 ;; If we use dummy roots, then we have to remove the
3779 ;; dummy root as well.
3780 (when (eq gnus-summary-make-false-root 'dummy)
3781 ;; We go to the dummy root by going to
3782 ;; the first sub-"thread", and then one line up.
3783 (gnus-summary-goto-article
3784 (mail-header-number (caadr thread)))
3787 (gnus-data-compute-positions))
3788 (setq thread (cdr thread))
3790 (gnus-remove-thread-1 (car thread))
3791 (setq thread (cdr thread))))
3792 (gnus-remove-thread-1 thread))))))))
3794 (defun gnus-remove-thread-1 (thread)
3795 "Remove the thread THREAD recursively."
3796 (let ((number (mail-header-number (pop thread)))
3798 (setq thread (reverse thread))
3800 (gnus-remove-thread-1 (pop thread)))
3801 (when (setq d (gnus-data-find number))
3802 (goto-char (gnus-data-pos d))
3803 (gnus-summary-show-thread)
3806 (- (gnus-point-at-bol)
3808 (1+ (gnus-point-at-eol))
3809 (gnus-delete-line)))))))
3811 (defun gnus-sort-threads-1 (threads func)
3812 (sort (mapcar (lambda (thread)
3815 (gnus-sort-threads-1 (cdr thread) func))))
3818 (defun gnus-sort-threads (threads)
3820 (if (not gnus-thread-sort-functions)
3822 (gnus-message 8 "Sorting threads...")
3824 (gnus-sort-threads-1
3826 (gnus-make-sort-function gnus-thread-sort-functions))
3827 (gnus-message 8 "Sorting threads...done"))))
3829 (defun gnus-sort-articles (articles)
3831 (when gnus-article-sort-functions
3832 (gnus-message 7 "Sorting articles...")
3834 (setq gnus-newsgroup-headers
3835 (sort articles (gnus-make-sort-function
3836 gnus-article-sort-functions)))
3837 (gnus-message 7 "Sorting articles...done"))))
3839 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3840 (defmacro gnus-thread-header (thread)
3841 "Return header of first article in THREAD.
3842 Note that THREAD must never, ever be anything else than a variable -
3843 using some other form will lead to serious barfage."
3844 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3845 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3846 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3849 (defsubst gnus-article-sort-by-number (h1 h2)
3850 "Sort articles by article number."
3851 (< (mail-header-number h1)
3852 (mail-header-number h2)))
3854 (defun gnus-thread-sort-by-number (h1 h2)
3855 "Sort threads by root article number."
3856 (gnus-article-sort-by-number
3857 (gnus-thread-header h1) (gnus-thread-header h2)))
3859 (defsubst gnus-article-sort-by-lines (h1 h2)
3860 "Sort articles by article Lines header."
3861 (< (mail-header-lines h1)
3862 (mail-header-lines h2)))
3864 (defun gnus-thread-sort-by-lines (h1 h2)
3865 "Sort threads by root article Lines header."
3866 (gnus-article-sort-by-lines
3867 (gnus-thread-header h1) (gnus-thread-header h2)))
3869 (defsubst gnus-article-sort-by-chars (h1 h2)
3870 "Sort articles by octet length."
3871 (< (mail-header-chars h1)
3872 (mail-header-chars h2)))
3874 (defun gnus-thread-sort-by-chars (h1 h2)
3875 "Sort threads by root article octet length."
3876 (gnus-article-sort-by-chars
3877 (gnus-thread-header h1) (gnus-thread-header h2)))
3879 (defsubst gnus-article-sort-by-author (h1 h2)
3880 "Sort articles by root author."
3882 (let ((extract (funcall
3883 gnus-extract-address-components
3884 (mail-header-from h1))))
3885 (or (car extract) (cadr extract) ""))
3886 (let ((extract (funcall
3887 gnus-extract-address-components
3888 (mail-header-from h2))))
3889 (or (car extract) (cadr extract) ""))))
3891 (defun gnus-thread-sort-by-author (h1 h2)
3892 "Sort threads by root author."
3893 (gnus-article-sort-by-author
3894 (gnus-thread-header h1) (gnus-thread-header h2)))
3896 (defsubst gnus-article-sort-by-subject (h1 h2)
3897 "Sort articles by root subject."
3899 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3900 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3902 (defun gnus-thread-sort-by-subject (h1 h2)
3903 "Sort threads by root subject."
3904 (gnus-article-sort-by-subject
3905 (gnus-thread-header h1) (gnus-thread-header h2)))
3907 (defsubst gnus-article-sort-by-date (h1 h2)
3908 "Sort articles by root article date."
3910 (gnus-date-get-time (mail-header-date h1))
3911 (gnus-date-get-time (mail-header-date h2))))
3913 (defun gnus-thread-sort-by-date (h1 h2)
3914 "Sort threads by root article date."
3915 (gnus-article-sort-by-date
3916 (gnus-thread-header h1) (gnus-thread-header h2)))
3918 (defsubst gnus-article-sort-by-score (h1 h2)
3919 "Sort articles by root article score.
3920 Unscored articles will be counted as having a score of zero."
3921 (> (or (cdr (assq (mail-header-number h1)
3922 gnus-newsgroup-scored))
3923 gnus-summary-default-score 0)
3924 (or (cdr (assq (mail-header-number h2)
3925 gnus-newsgroup-scored))
3926 gnus-summary-default-score 0)))
3928 (defun gnus-thread-sort-by-score (h1 h2)
3929 "Sort threads by root article score."
3930 (gnus-article-sort-by-score
3931 (gnus-thread-header h1) (gnus-thread-header h2)))
3933 (defun gnus-thread-sort-by-total-score (h1 h2)
3934 "Sort threads by the sum of all scores in the thread.
3935 Unscored articles will be counted as having a score of zero."
3936 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3938 (defun gnus-thread-total-score (thread)
3939 ;; This function find the total score of THREAD.
3940 (cond ((null thread)
3943 (if (stringp (car thread))
3944 (apply gnus-thread-score-function 0
3945 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3946 (gnus-thread-total-score-1 thread)))
3948 (gnus-thread-total-score-1 (list thread)))))
3950 (defun gnus-thread-total-score-1 (root)
3951 ;; This function find the total score of the thread below ROOT.
3952 (setq root (car root))
3953 (apply gnus-thread-score-function
3955 (mapcar 'gnus-thread-total-score
3956 (cdr (gnus-id-to-thread (mail-header-id root))))
3957 (when (> (mail-header-number root) 0)
3958 (list (or (cdr (assq (mail-header-number root)
3959 gnus-newsgroup-scored))
3960 gnus-summary-default-score 0))))
3961 (list gnus-summary-default-score)
3964 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3965 (defvar gnus-tmp-prev-subject nil)
3966 (defvar gnus-tmp-false-parent nil)
3967 (defvar gnus-tmp-root-expunged nil)
3968 (defvar gnus-tmp-dummy-line nil)
3970 (eval-when-compile (defvar gnus-tmp-header))
3971 (defun gnus-extra-header (type &optional header)
3972 "Return the extra header of TYPE."
3973 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3976 (defun gnus-summary-prepare-threads (threads)
3977 "Prepare summary buffer from THREADS and indentation LEVEL.
3978 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3979 or a straight list of headers."
3980 (gnus-message 7 "Generating summary...")
3982 (setq gnus-newsgroup-threads threads)
3985 (let ((gnus-tmp-level 0)
3986 (default-score (or gnus-summary-default-score 0))
3987 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3988 thread number subject stack state gnus-tmp-gathered beg-match
3989 new-roots gnus-tmp-new-adopts thread-end
3990 gnus-tmp-header gnus-tmp-unread
3991 gnus-tmp-replied gnus-tmp-subject-or-nil
3992 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3993 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3994 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3996 (setq gnus-tmp-prev-subject nil)
3998 (if (vectorp (car threads))
3999 ;; If this is a straight (sic) list of headers, then a
4000 ;; threaded summary display isn't required, so we just create
4001 ;; an unthreaded one.
4002 (gnus-summary-prepare-unthreaded threads)
4004 ;; Do the threaded display.
4006 (while (or threads stack gnus-tmp-new-adopts new-roots)
4008 (if (and (= gnus-tmp-level 0)
4011 (not gnus-tmp-false-parent)
4012 (or gnus-tmp-new-adopts new-roots))
4013 (if gnus-tmp-new-adopts
4014 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4015 thread (list (car gnus-tmp-new-adopts))
4016 gnus-tmp-header (caar thread)
4017 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4019 (setq thread (list (car new-roots))
4020 gnus-tmp-header (caar thread)
4021 new-roots (cdr new-roots))))
4024 ;; If there are some threads, we do them before the
4025 ;; threads on the stack.
4026 (setq thread threads
4027 gnus-tmp-header (caar thread))
4028 ;; There were no current threads, so we pop something off
4030 (setq state (car stack)
4031 gnus-tmp-level (car state)
4034 gnus-tmp-header (caar thread))))
4036 (setq gnus-tmp-false-parent nil)
4037 (setq gnus-tmp-root-expunged nil)
4038 (setq thread-end nil)
4040 (if (stringp gnus-tmp-header)
4041 ;; The header is a dummy root.
4043 ((eq gnus-summary-make-false-root 'adopt)
4044 ;; We let the first article adopt the rest.
4045 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4047 (setq gnus-tmp-gathered
4049 (lambda (h) (mail-header-number (car h)))
4052 (setq thread (cons (list (caar thread)
4055 (setq gnus-tmp-level -1
4056 gnus-tmp-false-parent t))
4057 ((eq gnus-summary-make-false-root 'empty)
4058 ;; We print adopted articles with empty subject fields.
4059 (setq gnus-tmp-gathered
4061 (lambda (h) (mail-header-number (car h)))
4064 (setq gnus-tmp-level -1))
4065 ((eq gnus-summary-make-false-root 'dummy)
4066 ;; We remember that we probably want to output a dummy
4068 (setq gnus-tmp-dummy-line gnus-tmp-header)
4069 (setq gnus-tmp-prev-subject gnus-tmp-header))
4071 ;; We do not make a root for the gathered
4072 ;; sub-threads at all.
4073 (setq gnus-tmp-level -1)))
4075 (setq number (mail-header-number gnus-tmp-header)
4076 subject (mail-header-subject gnus-tmp-header))
4079 ;; If the thread has changed subject, we might want to make
4080 ;; this subthread into a root.
4081 ((and (null gnus-thread-ignore-subject)
4082 (not (zerop gnus-tmp-level))
4083 gnus-tmp-prev-subject
4085 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4086 (setq new-roots (nconc new-roots (list (car thread)))
4088 gnus-tmp-header nil))
4089 ;; If the article lies outside the current limit,
4090 ;; then we do not display it.
4091 ((not (memq number gnus-newsgroup-limit))
4092 (setq gnus-tmp-gathered
4094 (lambda (h) (mail-header-number (car h)))
4097 (setq gnus-tmp-new-adopts (if (cdar thread)
4098 (append gnus-tmp-new-adopts
4100 gnus-tmp-new-adopts)
4102 gnus-tmp-header nil)
4103 (when (zerop gnus-tmp-level)
4104 (setq gnus-tmp-root-expunged t)))
4105 ;; Perhaps this article is to be marked as read?
4106 ((and gnus-summary-mark-below
4107 (< (or (cdr (assq number gnus-newsgroup-scored))
4109 gnus-summary-mark-below)
4110 ;; Don't touch sparse articles.
4111 (not (gnus-summary-article-sparse-p number))
4112 (not (gnus-summary-article-ancient-p number)))
4113 (setq gnus-newsgroup-unreads
4114 (delq number gnus-newsgroup-unreads))
4115 (if gnus-newsgroup-auto-expire
4116 (push number gnus-newsgroup-expirable)
4117 (push (cons number gnus-low-score-mark)
4118 gnus-newsgroup-reads))))
4120 (when gnus-tmp-header
4121 ;; We may have an old dummy line to output before this
4123 (when (and gnus-tmp-dummy-line
4126 (mail-header-subject gnus-tmp-header)))
4127 (gnus-summary-insert-dummy-line
4128 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4129 (setq gnus-tmp-dummy-line nil))
4131 ;; Compute the mark.
4132 (setq gnus-tmp-unread (gnus-article-mark number))
4134 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4135 gnus-tmp-header gnus-tmp-level)
4136 gnus-newsgroup-data)
4138 ;; Actually insert the line.
4140 gnus-tmp-subject-or-nil
4142 ((and gnus-thread-ignore-subject
4143 gnus-tmp-prev-subject
4144 (not (inline (gnus-subject-equal
4145 gnus-tmp-prev-subject subject))))
4147 ((zerop gnus-tmp-level)
4148 (if (and (eq gnus-summary-make-false-root 'empty)
4149 (memq number gnus-tmp-gathered)
4150 gnus-tmp-prev-subject
4151 (inline (gnus-subject-equal
4152 gnus-tmp-prev-subject subject)))
4153 gnus-summary-same-subject
4155 (t gnus-summary-same-subject)))
4156 (if (and (eq gnus-summary-make-false-root 'adopt)
4157 (= gnus-tmp-level 1)
4158 (memq number gnus-tmp-gathered))
4159 (setq gnus-tmp-opening-bracket ?\<
4160 gnus-tmp-closing-bracket ?\>)
4161 (setq gnus-tmp-opening-bracket ?\[
4162 gnus-tmp-closing-bracket ?\]))
4164 gnus-tmp-indentation
4165 (aref gnus-thread-indent-array gnus-tmp-level)
4166 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4167 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4168 gnus-summary-default-score 0)
4170 (if (or (null gnus-summary-default-score)
4171 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4172 gnus-summary-zcore-fuzz))
4174 (if (< gnus-tmp-score gnus-summary-default-score)
4175 gnus-score-below-mark gnus-score-over-mark))
4177 (cond ((memq number gnus-newsgroup-processable)
4179 ((memq number gnus-newsgroup-cached)
4181 ((memq number gnus-newsgroup-replied)
4183 ((memq number gnus-newsgroup-saved)
4186 gnus-tmp-from (mail-header-from gnus-tmp-header)
4189 ((string-match "<[^>]+> *$" gnus-tmp-from)
4190 (setq beg-match (match-beginning 0))
4191 (or (and (string-match "^\".+\"" gnus-tmp-from)
4192 (substring gnus-tmp-from 1 (1- (match-end 0))))
4193 (substring gnus-tmp-from 0 beg-match)))
4194 ((string-match "(.+)" gnus-tmp-from)
4195 (substring gnus-tmp-from
4196 (1+ (match-beginning 0)) (1- (match-end 0))))
4198 (when (string= gnus-tmp-name "")
4199 (setq gnus-tmp-name gnus-tmp-from))
4200 (unless (numberp gnus-tmp-lines)
4201 (setq gnus-tmp-lines 0))
4202 (gnus-put-text-property
4204 (progn (eval gnus-summary-line-format-spec) (point))
4205 'gnus-number number)
4208 (gnus-run-hooks 'gnus-summary-update-hook)
4211 (setq gnus-tmp-prev-subject subject)))
4213 (when (nth 1 thread)
4214 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4215 (incf gnus-tmp-level)
4216 (setq threads (if thread-end nil (cdar thread)))
4218 (setq gnus-tmp-level 0)))))
4219 (gnus-message 7 "Generating summary...done"))
4221 (defun gnus-summary-prepare-unthreaded (headers)
4222 "Generate an unthreaded summary buffer based on HEADERS."
4223 (let (header number mark)
4228 ;; We may have to root out some bad articles...
4229 (when (memq (setq number (mail-header-number
4230 (setq header (pop headers))))
4231 gnus-newsgroup-limit)
4232 ;; Mark article as read when it has a low score.
4233 (when (and gnus-summary-mark-below
4234 (< (or (cdr (assq number gnus-newsgroup-scored))
4235 gnus-summary-default-score 0)
4236 gnus-summary-mark-below)
4237 (not (gnus-summary-article-ancient-p number)))
4238 (setq gnus-newsgroup-unreads
4239 (delq number gnus-newsgroup-unreads))
4240 (if gnus-newsgroup-auto-expire
4241 (push number gnus-newsgroup-expirable)
4242 (push (cons number gnus-low-score-mark)
4243 gnus-newsgroup-reads)))
4245 (setq mark (gnus-article-mark number))
4246 (push (gnus-data-make number mark (1+ (point)) header 0)
4247 gnus-newsgroup-data)
4248 (gnus-summary-insert-line
4250 mark (memq number gnus-newsgroup-replied)
4251 (memq number gnus-newsgroup-expirable)
4252 (mail-header-subject header) nil
4253 (cdr (assq number gnus-newsgroup-scored))
4254 (memq number gnus-newsgroup-processable))))))
4256 (defun gnus-summary-remove-list-identifiers ()
4257 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4258 (let ((regexp (if (stringp gnus-list-identifiers)
4259 gnus-list-identifiers
4260 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4261 (dolist (header gnus-newsgroup-headers)
4262 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4263 " *\\)\\)+\\(Re: +\\)?\\)")
4264 (mail-header-subject header))
4265 (mail-header-set-subject
4266 header (concat (substring (mail-header-subject header)
4267 0 (match-beginning 1))
4269 (match-string 3 (mail-header-subject header))
4270 (match-string 5 (mail-header-subject header)))
4271 (substring (mail-header-subject header)
4272 (match-end 1))))))))
4274 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4275 "Select newsgroup GROUP.
4276 If READ-ALL is non-nil, all articles in the group are selected.
4277 If SELECT-ARTICLES, only select those articles from GROUP."
4278 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4279 ;;!!! Dirty hack; should be removed.
4280 (gnus-summary-ignore-duplicates
4281 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4283 gnus-summary-ignore-duplicates))
4284 (info (nth 2 entry))
4285 articles fetched-articles cached)
4287 (unless (gnus-check-server
4288 (setq gnus-current-select-method
4289 (gnus-find-method-for-group group)))
4290 (error "Couldn't open server"))
4292 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4293 (gnus-activate-group group) ; Or we can activate it...
4294 (progn ; Or we bug out.
4295 (when (equal major-mode 'gnus-summary-mode)
4296 (kill-buffer (current-buffer)))
4297 (error "Couldn't activate group %s: %s"
4298 group (gnus-status-message group))))
4300 (unless (gnus-request-group group t)
4301 (when (equal major-mode 'gnus-summary-mode)
4302 (kill-buffer (current-buffer)))
4303 (error "Couldn't request group %s: %s"
4304 group (gnus-status-message group)))
4306 (setq gnus-newsgroup-name group)
4307 (setq gnus-newsgroup-unselected nil)
4308 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4309 (gnus-summary-setup-default-charset)
4311 ;; Adjust and set lists of article marks.
4313 (gnus-adjust-marked-articles info))
4315 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4316 (when (gnus-virtual-group-p group)
4317 (setq cached gnus-newsgroup-cached))
4319 (setq gnus-newsgroup-unreads
4320 (gnus-set-difference
4321 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4322 gnus-newsgroup-dormant))
4324 (setq gnus-newsgroup-processable nil)
4326 (gnus-update-read-articles group gnus-newsgroup-unreads)
4328 (if (setq articles select-articles)
4329 (setq gnus-newsgroup-unselected
4330 (gnus-sorted-intersection
4331 gnus-newsgroup-unreads
4332 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4333 (setq articles (gnus-articles-to-read group read-all)))
4337 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4339 ((eq articles 0) nil)
4341 ;; Init the dependencies hash table.
4342 (setq gnus-newsgroup-dependencies
4343 (gnus-make-hashtable (length articles)))
4344 (gnus-set-global-variables)
4345 ;; Retrieve the headers and read them in.
4346 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4347 (setq gnus-newsgroup-headers
4349 (setq gnus-headers-retrieved-by
4350 (gnus-retrieve-headers
4351 articles gnus-newsgroup-name
4352 ;; We might want to fetch old headers, but
4353 ;; not if there is only 1 article.
4355 (not (eq gnus-fetch-old-headers 'some))
4356 (not (numberp gnus-fetch-old-headers)))
4357 (> (length articles) 1))
4358 gnus-fetch-old-headers))))
4359 (gnus-get-newsgroup-headers-xover
4360 articles nil nil gnus-newsgroup-name t)
4361 (gnus-get-newsgroup-headers)))
4362 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4364 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4366 (setq gnus-newsgroup-cached cached))
4368 ;; Suppress duplicates?
4369 (when gnus-suppress-duplicates
4370 (gnus-dup-suppress-articles))
4372 ;; Set the initial limit.
4373 (setq gnus-newsgroup-limit (copy-sequence articles))
4374 ;; Remove canceled articles from the list of unread articles.
4375 (setq gnus-newsgroup-unreads
4376 (gnus-set-sorted-intersection
4377 gnus-newsgroup-unreads
4378 (setq fetched-articles
4379 (mapcar (lambda (headers) (mail-header-number headers))
4380 gnus-newsgroup-headers))))
4381 ;; Removed marked articles that do not exist.
4382 (gnus-update-missing-marks
4383 (gnus-sorted-complement fetched-articles articles))
4384 ;; We might want to build some more threads first.
4385 (when (and gnus-fetch-old-headers
4386 (eq gnus-headers-retrieved-by 'nov))
4387 (if (eq gnus-fetch-old-headers 'invisible)
4388 (gnus-build-all-threads)
4389 (gnus-build-old-threads)))
4390 ;; Let the Gnus agent mark articles as read.
4392 (gnus-agent-get-undownloaded-list))
4393 ;; Remove list identifiers from subject
4394 (when gnus-list-identifiers
4395 (gnus-summary-remove-list-identifiers))
4396 ;; Check whether auto-expire is to be done in this group.
4397 (setq gnus-newsgroup-auto-expire
4398 (gnus-group-auto-expirable-p group))
4399 ;; Set up the article buffer now, if necessary.
4400 (unless gnus-single-article-buffer
4401 (gnus-article-setup-buffer))
4402 ;; First and last article in this newsgroup.
4403 (when gnus-newsgroup-headers
4404 (setq gnus-newsgroup-begin
4405 (mail-header-number (car gnus-newsgroup-headers))
4408 (gnus-last-element gnus-newsgroup-headers))))
4409 ;; GROUP is successfully selected.
4410 (or gnus-newsgroup-headers t)))))
4412 (defun gnus-articles-to-read (group &optional read-all)
4413 "Find out what articles the user wants to read."
4415 ;; Select all articles if `read-all' is non-nil, or if there
4416 ;; are no unread articles.
4418 (and (zerop (length gnus-newsgroup-marked))
4419 (zerop (length gnus-newsgroup-unreads)))
4420 (eq (gnus-group-find-parameter group 'display)
4423 (gnus-uncompress-range (gnus-active group))
4424 (gnus-cache-articles-in-group group))
4425 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4426 (copy-sequence gnus-newsgroup-unreads))
4428 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4429 (scored (length scored-list))
4430 (number (length articles))
4431 (marked (+ (length gnus-newsgroup-marked)
4432 (length gnus-newsgroup-dormant)))
4440 ((and (or (<= scored marked) (= scored number))
4441 (numberp gnus-large-newsgroup)
4442 (> number gnus-large-newsgroup))
4446 "How many articles from %s (default %d): "
4447 (gnus-limit-string gnus-newsgroup-name 35)
4449 (if (string-match "^[ \t]*$" input) number input)))
4450 ((and (> scored marked) (< scored number)
4451 (> (- scored number) 20))
4454 (format "%s %s (%d scored, %d total): "
4455 "How many articles from"
4456 group scored number))))
4457 (if (string-match "^[ \t]*$" input)
4461 (message "Quit getting the articles to read")
4463 (setq select (if (stringp select) (string-to-number select) select))
4464 (if (or (null select) (zerop select))
4466 (if (and (not (zerop scored)) (<= (abs select) scored))
4468 (setq articles (sort scored-list '<))
4469 (setq number (length articles)))
4470 (setq articles (copy-sequence articles)))
4472 (when (< (abs select) number)
4474 ;; Select the N oldest articles.
4475 (setcdr (nthcdr (1- (abs select)) articles) nil)
4476 ;; Select the N most recent articles.
4477 (setq articles (nthcdr (- number select) articles))))
4478 (setq gnus-newsgroup-unselected
4479 (gnus-sorted-intersection
4480 gnus-newsgroup-unreads
4481 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4482 (when gnus-alter-articles-to-read-function
4483 (setq gnus-newsgroup-unreads
4485 (funcall gnus-alter-articles-to-read-function
4486 gnus-newsgroup-name gnus-newsgroup-unreads)
4490 (defun gnus-killed-articles (killed articles)
4493 (when (inline (gnus-member-of-range (car articles) killed))
4494 (push (car articles) out))
4495 (setq articles (cdr articles)))
4498 (defun gnus-uncompress-marks (marks)
4499 "Uncompress the mark ranges in MARKS."
4500 (let ((uncompressed '(score bookmark))
4503 (if (memq (caar marks) uncompressed)
4504 (push (car marks) out)
4505 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4506 (setq marks (cdr marks)))
4509 (defun gnus-adjust-marked-articles (info)
4510 "Set all article lists and remove all marks that are no longer valid."
4511 (let* ((marked-lists (gnus-info-marks info))
4512 (active (gnus-active (gnus-info-group info)))
4515 (types gnus-article-mark-lists)
4516 (uncompressed '(score bookmark killed))
4517 marks var articles article mark)
4520 (setq marks (pop marked-lists))
4521 (set (setq var (intern (format "gnus-newsgroup-%s"
4522 (car (rassq (setq mark (car marks))
4524 (if (memq (car marks) uncompressed) (cdr marks)
4525 (gnus-uncompress-range (cdr marks))))
4527 (setq articles (symbol-value var))
4529 ;; All articles have to be subsets of the active articles.
4531 ;; Adjust "simple" lists.
4532 ((memq mark '(tick dormant expire reply save))
4534 (when (or (< (setq article (pop articles)) min) (> article max))
4535 (set var (delq article (symbol-value var))))))
4537 ((memq mark uncompressed)
4538 (when (not (listp (cdr (symbol-value var))))
4539 (set var (list (symbol-value var))))
4540 (when (not (listp (cdr articles)))
4541 (setq articles (list articles)))
4543 (when (or (not (consp (setq article (pop articles))))
4544 (< (car article) min)
4545 (> (car article) max))
4546 (set var (delq article (symbol-value var))))))))))
4548 (defun gnus-update-missing-marks (missing)
4549 "Go through the list of MISSING articles and remove them from the mark lists."
4551 (let ((types gnus-article-mark-lists)
4553 ;; Go through all types.
4555 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4556 (when (symbol-value var)
4557 ;; This list has articles. So we delete all missing articles
4561 (set var (delq (pop m) (symbol-value var)))))))))
4563 (defun gnus-update-marks ()
4564 "Enter the various lists of marked articles into the newsgroup info list."
4565 (let ((types gnus-article-mark-lists)
4566 (info (gnus-get-info gnus-newsgroup-name))
4567 (uncompressed '(score bookmark killed))
4568 type list newmarked symbol delta-marks)
4570 ;; Add all marks lists to the list of marks lists.
4571 (while (setq type (pop types))
4572 (setq list (symbol-value
4574 (intern (format "gnus-newsgroup-%s"
4578 ;; Get rid of the entries of the articles that have the
4580 (when (and (eq (cdr type) 'score)
4584 (prev (cons nil list))
4587 (if (or (not (consp (car arts)))
4588 (= (cdar arts) gnus-summary-default-score))
4589 (setcdr prev (cdr arts))
4591 (setq arts (cdr arts)))
4592 (setq list (cdr all)))))
4594 (unless (memq (cdr type) uncompressed)
4595 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4597 (when (gnus-check-backend-function
4598 'request-set-mark gnus-newsgroup-name)
4599 ;; propagate flags to server, with the following exceptions:
4600 ;; uncompressed:s are not proper flags (they are cons cells)
4601 ;; cache is a internal gnus flag
4602 ;; download are local to one gnus installation (well)
4603 ;; unsend are for nndraft groups only
4604 ;; xxx: generality of this? this suits nnimap anyway
4605 (unless (memq (cdr type) (append '(cache download unsend)
4607 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4608 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4609 (add (gnus-remove-from-range
4610 (gnus-copy-sequence list) old)))
4612 (push (list add 'add (list (cdr type))) delta-marks))
4614 (push (list del 'del (list (cdr type))) delta-marks)))))
4617 (push (cons (cdr type) list) newmarked)))
4620 (unless (gnus-check-group gnus-newsgroup-name)
4621 (error "Can't open server for %s" gnus-newsgroup-name))
4622 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4624 ;; Enter these new marks into the info of the group.
4626 (setcar (nthcdr 3 info) newmarked)
4627 ;; Add the marks lists to the end of the info.
4629 (setcdr (nthcdr 2 info) (list newmarked))))
4631 ;; Cut off the end of the info if there's nothing else there.
4635 (when (nthcdr (decf i) info)
4636 (setcdr (nthcdr i info) nil)))))))
4638 (defun gnus-set-mode-line (where)
4639 "Set the mode line of the article or summary buffers.
4640 If WHERE is `summary', the summary mode line format will be used."
4641 ;; Is this mode line one we keep updated?
4642 (when (and (memq where gnus-updated-mode-lines)
4644 (intern (format "gnus-%s-mode-line-format-spec" where))))
4647 ;; We evaluate this in the summary buffer since these
4648 ;; variables are buffer-local to that buffer.
4649 (set-buffer gnus-summary-buffer)
4650 ;; We bind all these variables that are used in the `eval' form
4652 (let* ((mformat (symbol-value
4654 (format "gnus-%s-mode-line-format-spec" where))))
4655 (gnus-tmp-group-name (gnus-group-name-decode
4657 (gnus-group-name-charset
4659 gnus-newsgroup-name)))
4660 (gnus-tmp-article-number (or gnus-current-article 0))
4661 (gnus-tmp-unread gnus-newsgroup-unreads)
4662 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4663 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4664 (gnus-tmp-unread-and-unselected
4665 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4666 (zerop gnus-tmp-unselected))
4668 ((zerop gnus-tmp-unselected)
4669 (format "{%d more}" gnus-tmp-unread-and-unticked))
4670 (t (format "{%d(+%d) more}"
4671 gnus-tmp-unread-and-unticked
4672 gnus-tmp-unselected))))
4674 (if (and gnus-current-headers
4675 (vectorp gnus-current-headers))
4676 (gnus-mode-string-quote
4677 (mail-header-subject gnus-current-headers))
4679 bufname-length max-len
4680 gnus-tmp-header);; passed as argument to any user-format-funcs
4681 (setq mode-string (eval mformat))
4682 (setq bufname-length (if (string-match "%b" mode-string)
4685 (if (eq where 'summary)
4687 (get-buffer gnus-article-buffer))))
4690 (setq max-len (max 4 (if gnus-mode-non-string-length
4692 gnus-mode-non-string-length
4694 (length mode-string))))
4695 ;; We might have to chop a bit of the string off...
4696 (when (> (length mode-string) max-len)
4698 (concat (truncate-string-to-width mode-string (- max-len 3))
4700 ;; Pad the mode string a bit.
4701 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4702 ;; Update the mode line.
4703 (setq mode-line-buffer-identification
4704 (gnus-mode-line-buffer-identification (list mode-string)))
4705 (set-buffer-modified-p t))))
4707 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4708 "Go through the HEADERS list and add all Xrefs to a hash table.
4709 The resulting hash table is returned, or nil if no Xrefs were found."
4710 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4711 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4712 (xref-hashtb (gnus-make-hashtable))
4713 start group entry number xrefs header)
4715 (setq header (pop headers))
4716 (when (and (setq xrefs (mail-header-xref header))
4717 (not (memq (setq number (mail-header-number header))
4720 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4721 (setq start (match-end 0))
4722 (setq group (if prefix
4723 (concat prefix (substring xrefs (match-beginning 1)
4725 (substring xrefs (match-beginning 1) (match-end 1))))
4727 (string-to-int (substring xrefs (match-beginning 2)
4729 (if (setq entry (gnus-gethash group xref-hashtb))
4730 (setcdr entry (cons number (cdr entry)))
4731 (gnus-sethash group (cons number nil) xref-hashtb)))))
4732 (and start xref-hashtb)))
4734 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4735 "Look through all the headers and mark the Xrefs as read."
4736 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4737 name entry info xref-hashtb idlist method nth4)
4739 (set-buffer gnus-group-buffer)
4740 (when (setq xref-hashtb
4741 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4744 (unless (string= from-newsgroup (setq name (symbol-name group)))
4745 (setq idlist (symbol-value group))
4746 ;; Dead groups are not updated.
4748 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4750 (when (stringp (setq nth4 (gnus-info-method info)))
4751 (setq nth4 (gnus-server-to-method nth4))))
4752 ;; Only do the xrefs if the group has the same
4753 ;; select method as the group we have just read.
4754 (or (gnus-methods-equal-p
4755 nth4 (gnus-find-method-for-group from-newsgroup))
4757 (equal nth4 (setq method (gnus-find-method-for-group
4759 (and (equal (car nth4) (car method))
4760 (equal (nth 1 nth4) (nth 1 method))))
4761 gnus-use-cross-reference
4762 (or (not (eq gnus-use-cross-reference t))
4764 ;; Only do cross-references on subscribed
4765 ;; groups, if that is what is wanted.
4766 (<= (gnus-info-level info) gnus-level-subscribed))
4767 (gnus-group-make-articles-read name idlist))))
4770 (defun gnus-compute-read-articles (group articles)
4771 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4772 (info (nth 2 entry))
4773 (active (gnus-active group))
4776 ;; First peel off all invalid article numbers.
4778 (let ((ids articles)
4780 (while (setq id (pop ids))
4781 (when (and first (> id (cdr active)))
4782 ;; We'll end up in this situation in one particular
4783 ;; obscure situation. If you re-scan a group and get
4784 ;; a new article that is cross-posted to a different
4785 ;; group that has not been re-scanned, you might get
4786 ;; crossposted article that has a higher number than
4787 ;; Gnus believes possible. So we re-activate this
4788 ;; group as well. This might mean doing the
4789 ;; crossposting thingy will *increase* the number
4790 ;; of articles in some groups. Tsk, tsk.
4791 (setq active (or (gnus-activate-group group) active)))
4792 (when (or (> id (cdr active))
4793 (< id (car active)))
4794 (setq articles (delq id articles))))))
4795 ;; If the read list is nil, we init it.
4797 (null (gnus-info-read info))
4799 (setq ninfo (cons 1 (1- (car active))))
4800 (setq ninfo (gnus-info-read info)))
4801 ;; Then we add the read articles to the range.
4803 ninfo (setq articles (sort articles '<))))))
4805 (defun gnus-group-make-articles-read (group articles)
4806 "Update the info of GROUP to say that ARTICLES are read."
4808 (entry (gnus-gethash group gnus-newsrc-hashtb))
4809 (info (nth 2 entry))
4810 (active (gnus-active group))
4813 (setq range (gnus-compute-read-articles group articles))
4815 (set-buffer gnus-group-buffer)
4818 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4819 (gnus-info-set-read ',info ',(gnus-info-read info))
4820 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4821 (gnus-group-update-group ,group t))))
4822 ;; Add the read articles to the range.
4823 (gnus-info-set-read info range)
4824 ;; Then we have to re-compute how many unread
4825 ;; articles there are in this group.
4829 (setq num (- (1+ (cdr active)) (car active))))
4830 ((not (listp (cdr range)))
4831 (setq num (- (cdr active) (- (1+ (cdr range))
4835 (if (numberp (car range))
4837 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4838 (setq range (cdr range)))
4839 (setq num (- (cdr active) num))))
4840 ;; Update the number of unread articles.
4842 ;; Update the group buffer.
4843 (gnus-group-update-group group t)))))
4845 (defvar gnus-newsgroup-none-id 0)
4847 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4848 (let ((cur nntp-server-buffer)
4851 (save-excursion (set-buffer gnus-summary-buffer)
4852 gnus-newsgroup-dependencies)))
4854 (mail-parse-charset gnus-newsgroup-charset)
4855 (mail-parse-ignored-charsets
4856 (save-excursion (condition-case nil
4857 (set-buffer gnus-summary-buffer)
4859 gnus-newsgroup-ignored-charsets)))
4861 (set-buffer nntp-server-buffer)
4862 ;; Translate all TAB characters into SPACE characters.
4863 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4864 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4865 (gnus-run-hooks 'gnus-parse-headers-hook)
4866 (let ((case-fold-search t)
4867 in-reply-to header p lines chars)
4868 (goto-char (point-min))
4869 ;; Search to the beginning of the next header. Error messages
4870 ;; do not begin with 2 or 3.
4871 (while (re-search-forward "^[23][0-9]+ " nil t)
4874 ;; This implementation of this function, with nine
4875 ;; search-forwards instead of the one re-search-forward and
4876 ;; a case (which basically was the old function) is actually
4877 ;; about twice as fast, even though it looks messier. You
4878 ;; can't have everything, I guess. Speed and elegance
4879 ;; doesn't always go hand in hand.
4888 (narrow-to-region (point)
4889 (or (and (search-forward "\n.\n" nil t)
4895 (if (search-forward "\nsubject: " nil t)
4896 (funcall gnus-decode-encoded-word-function
4897 (nnheader-header-value))
4902 (if (or (search-forward "\nfrom: " nil t)
4903 (search-forward "\nfrom:" nil t))
4904 (funcall gnus-decode-encoded-word-function
4905 (nnheader-header-value))
4910 (if (search-forward "\ndate: " nil t)
4911 (nnheader-header-value) ""))
4915 (setq id (if (re-search-forward
4916 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4917 ;; We do it this way to make sure the Message-ID
4918 ;; is (somewhat) syntactically valid.
4919 (buffer-substring (match-beginning 1)
4921 ;; If there was no message-id, we just fake one
4922 ;; to make subsequent routines simpler.
4923 (nnheader-generate-fake-message-id))))
4927 (if (search-forward "\nreferences: " nil t)
4931 (nnheader-header-value)
4936 (search-backward ">" end t)
4939 (search-backward "<" end t)
4941 ;; Get the references from the in-reply-to header if there
4942 ;; were no references and the in-reply-to header looks
4944 (if (and (search-forward "\nin-reply-to: " nil t)
4945 (setq in-reply-to (nnheader-header-value))
4946 (string-match "<[^>]+>" in-reply-to))
4948 (setq ref (substring in-reply-to (match-beginning 0)
4950 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4951 (setq ref2 (substring in-reply-to (match-beginning 0)
4953 (when (> (length ref2) (length ref))
4960 (if (search-forward "\nchars: " nil t)
4961 (if (numberp (setq chars (ignore-errors (read cur))))
4967 (if (search-forward "\nlines: " nil t)
4968 (if (numberp (setq lines (ignore-errors (read cur))))
4974 (and (search-forward "\nxref: " nil t)
4975 (nnheader-header-value)))
4977 (when gnus-extra-headers
4978 (let ((extra gnus-extra-headers)
4982 (when (search-forward
4983 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4984 (push (cons (car extra) (nnheader-header-value))
4988 (when (equal id ref)
4991 (when gnus-alter-header-function
4992 (funcall gnus-alter-header-function header)
4993 (setq id (mail-header-id header)
4994 ref (gnus-parent-id (mail-header-references header))))
4997 (gnus-dependencies-add-header
4998 header dependencies force-new))
4999 (push header headers))
5000 (goto-char (point-max))
5002 (nreverse headers)))))
5004 ;; Goes through the xover lines and returns a list of vectors
5005 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5006 force-new dependencies
5007 group also-fetch-heads)
5008 "Parse the news overview data in the server buffer.
5009 Return a list of headers that match SEQUENCE (see
5010 `nntp-retrieve-headers')."
5011 ;; Get the Xref when the users reads the articles since most/some
5012 ;; NNTP servers do not include Xrefs when using XOVER.
5013 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5014 (let ((mail-parse-charset gnus-newsgroup-charset)
5015 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5016 (cur nntp-server-buffer)
5017 (dependencies (or dependencies gnus-newsgroup-dependencies))
5018 number headers header)
5020 (set-buffer nntp-server-buffer)
5021 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5022 ;; Allow the user to mangle the headers before parsing them.
5023 (gnus-run-hooks 'gnus-parse-headers-hook)
5024 (goto-char (point-min))
5027 (while (and sequence (not (eobp)))
5028 (setq number (read cur))
5029 (while (and sequence
5030 (< (car sequence) number))
5031 (setq sequence (cdr sequence)))
5033 (eq number (car sequence))
5035 (setq sequence (cdr sequence))
5036 (setq header (inline
5037 (gnus-nov-parse-line
5038 number dependencies force-new))))
5039 (push header headers))
5042 (gnus-error 4 "Strange nov line (%d)"
5043 (count-lines (point-min) (point)))))
5045 ;; A common bug in inn is that if you have posted an article and
5046 ;; then retrieves the active file, it will answer correctly --
5047 ;; the new article is included. However, a NOV entry for the
5048 ;; article may not have been generated yet, so this may fail.
5049 ;; We work around this problem by retrieving the last few
5050 ;; headers using HEAD.
5051 (if (or (not also-fetch-heads)
5053 ;; We (probably) got all the headers.
5055 (let ((gnus-nov-is-evil t))
5058 (when (gnus-retrieve-headers sequence group)
5059 (gnus-get-newsgroup-headers))))))))
5061 (defun gnus-article-get-xrefs ()
5062 "Fill in the Xref value in `gnus-current-headers', if necessary.
5063 This is meant to be called in `gnus-article-internal-prepare-hook'."
5064 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5065 gnus-current-headers)))
5066 (or (not gnus-use-cross-reference)
5068 (and (mail-header-xref headers)
5069 (not (string= (mail-header-xref headers) "")))
5070 (let ((case-fold-search t)
5073 (nnheader-narrow-to-headers)
5074 (goto-char (point-min))
5075 (when (or (and (not (eobp))
5076 (eq (downcase (char-after)) ?x)
5077 (looking-at "Xref:"))
5078 (search-forward "\nXref:" nil t))
5079 (goto-char (1+ (match-end 0)))
5080 (setq xref (buffer-substring (point)
5081 (progn (end-of-line) (point))))
5082 (mail-header-set-xref headers xref)))))))
5084 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5085 "Find article ID and insert the summary line for that article.
5086 OLD-HEADER can either be a header or a line number to insert
5087 the subject line on."
5088 (let* ((line (and (numberp old-header) old-header))
5089 (old-header (and (vectorp old-header) old-header))
5090 (header (cond ((and old-header use-old-header)
5093 (gnus-number-to-header id))
5094 (gnus-number-to-header id))
5096 (gnus-read-header id))))
5097 (number (and (numberp id) id))
5100 ;; Rebuild the thread that this article is part of and go to the
5101 ;; article we have fetched.
5102 (when (and (not gnus-show-threads)
5105 (setq d (gnus-data-find (mail-header-number old-header))))
5106 (goto-char (gnus-data-pos d))
5109 (- (gnus-point-at-bol)
5111 (1+ (gnus-point-at-eol))
5112 (gnus-delete-line))))))
5114 (mail-header-set-number header (mail-header-number old-header)))
5115 (setq gnus-newsgroup-sparse
5116 (delq (setq number (mail-header-number header))
5117 gnus-newsgroup-sparse))
5118 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5119 (push number gnus-newsgroup-limit)
5120 (gnus-rebuild-thread (mail-header-id header) line)
5121 (gnus-summary-goto-subject number nil t))
5122 (when (and (numberp number)
5124 ;; We have to update the boundaries even if we can't fetch the
5125 ;; article if ID is a number -- so that the next `P' or `N'
5126 ;; command will fetch the previous (or next) article even
5127 ;; if the one we tried to fetch this time has been canceled.
5128 (when (> number gnus-newsgroup-end)
5129 (setq gnus-newsgroup-end number))
5130 (when (< number gnus-newsgroup-begin)
5131 (setq gnus-newsgroup-begin number))
5132 (setq gnus-newsgroup-unselected
5133 (delq number gnus-newsgroup-unselected)))
5134 ;; Report back a success?
5135 (and header (mail-header-number header))))
5137 ;;; Process/prefix in the summary buffer
5139 (defun gnus-summary-work-articles (n)
5140 "Return a list of articles to be worked upon.
5141 The prefix argument, the list of process marked articles, and the
5142 current article will be taken into consideration."
5144 (set-buffer gnus-summary-buffer)
5147 ;; A numerical prefix has been given.
5148 (setq n (prefix-numeric-value n))
5149 (let ((backward (< n 0))
5150 (n (abs (prefix-numeric-value n)))
5155 (push (setq article (gnus-summary-article-number))
5158 (gnus-summary-find-prev nil article)
5159 (gnus-summary-find-next nil article)))
5161 (nreverse articles)))
5162 ((and (gnus-region-active-p) (mark))
5163 (message "region active")
5164 ;; Work on the region between point and mark.
5165 (let ((max (max (point) (mark)))
5168 (goto-char (min (min (point) (mark))))
5171 (push (setq article (gnus-summary-article-number)) articles)
5172 (gnus-summary-find-next nil article)
5174 (nreverse articles))))
5175 (gnus-newsgroup-processable
5176 ;; There are process-marked articles present.
5177 ;; Save current state.
5178 (gnus-summary-save-process-mark)
5180 (reverse gnus-newsgroup-processable))
5182 ;; Just return the current article.
5183 (list (gnus-summary-article-number))))))
5185 (defmacro gnus-summary-iterate (arg &rest forms)
5186 "Iterate over the process/prefixed articles and do FORMS.
5187 ARG is the interactive prefix given to the command. FORMS will be
5188 executed with point over the summary line of the articles."
5189 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5190 `(let ((,articles (gnus-summary-work-articles ,arg)))
5192 (gnus-summary-goto-subject (car ,articles))
5196 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5197 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5199 (defun gnus-summary-save-process-mark ()
5200 "Push the current set of process marked articles on the stack."
5202 (push (copy-sequence gnus-newsgroup-processable)
5203 gnus-newsgroup-process-stack))
5205 (defun gnus-summary-kill-process-mark ()
5206 "Push the current set of process marked articles on the stack and unmark."
5208 (gnus-summary-save-process-mark)
5209 (gnus-summary-unmark-all-processable))
5211 (defun gnus-summary-yank-process-mark ()
5212 "Pop the last process mark state off the stack and restore it."
5214 (unless gnus-newsgroup-process-stack
5215 (error "Empty mark stack"))
5216 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5218 (defun gnus-summary-process-mark-set (set)
5219 "Make SET into the current process marked articles."
5220 (gnus-summary-unmark-all-processable)
5222 (gnus-summary-set-process-mark (pop set))))
5224 ;;; Searching and stuff
5226 (defun gnus-summary-search-group (&optional backward use-level)
5227 "Search for next unread newsgroup.
5228 If optional argument BACKWARD is non-nil, search backward instead."
5230 (set-buffer gnus-group-buffer)
5231 (when (gnus-group-search-forward
5232 backward nil (if use-level (gnus-group-group-level) nil))
5233 (gnus-group-group-name))))
5235 (defun gnus-summary-best-group (&optional exclude-group)
5236 "Find the name of the best unread group.
5237 If EXCLUDE-GROUP, do not go to this group."
5239 (set-buffer gnus-group-buffer)
5241 (gnus-group-best-unread-group exclude-group))))
5243 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5244 (if backward (gnus-summary-find-prev)
5245 (let* ((dummy (gnus-summary-article-intangible-p))
5246 (article (or article (gnus-summary-article-number)))
5247 (arts (gnus-data-find-list article))
5249 (when (and (not dummy)
5250 (or (not gnus-summary-check-current)
5252 (not (gnus-data-unread-p (car arts)))))
5253 (setq arts (cdr arts)))
5258 (when (or (and undownloaded
5259 (eq gnus-undownloaded-mark
5260 (gnus-data-mark (car arts))))
5261 (gnus-data-unread-p (car arts)))
5262 (setq result (car arts)
5264 (setq arts (cdr arts)))
5267 (goto-char (gnus-data-pos result))
5268 (gnus-data-number result)))))
5270 (defun gnus-summary-find-prev (&optional unread article)
5271 (let* ((eobp (eobp))
5272 (article (or article (gnus-summary-article-number)))
5273 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5275 (when (and (not eobp)
5276 (or (not gnus-summary-check-current)
5278 (not (gnus-data-unread-p (car arts)))))
5279 (setq arts (cdr arts)))
5284 (when (gnus-data-unread-p (car arts))
5285 (setq result (car arts)
5287 (setq arts (cdr arts)))
5290 (goto-char (gnus-data-pos result))
5291 (gnus-data-number result))))
5293 (defun gnus-summary-find-subject (subject &optional unread backward article)
5294 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5295 (article (or article (gnus-summary-article-number)))
5296 (articles (gnus-data-list backward))
5297 (arts (gnus-data-find-list article articles))
5299 (when (or (not gnus-summary-check-current)
5301 (not (gnus-data-unread-p (car arts))))
5302 (setq arts (cdr arts)))
5304 (and (or (not unread)
5305 (gnus-data-unread-p (car arts)))
5306 (vectorp (gnus-data-header (car arts)))
5308 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5309 (setq result (car arts)
5311 (setq arts (cdr arts)))
5313 (goto-char (gnus-data-pos result))
5314 (gnus-data-number result))))
5316 (defun gnus-summary-search-forward (&optional unread subject backward)
5317 "Search forward for an article.
5318 If UNREAD, look for unread articles. If SUBJECT, look for
5319 articles with that subject. If BACKWARD, search backward instead."
5320 (cond (subject (gnus-summary-find-subject subject unread backward))
5321 (backward (gnus-summary-find-prev unread))
5322 (t (gnus-summary-find-next unread))))
5324 (defun gnus-recenter (&optional n)
5325 "Center point in window and redisplay frame.
5326 Also do horizontal recentering."
5328 (when (and gnus-auto-center-summary
5329 (not (eq gnus-auto-center-summary 'vertical)))
5330 (gnus-horizontal-recenter))
5333 (defun gnus-summary-recenter ()
5334 "Center point in the summary window.
5335 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5336 displayed, no centering will be performed."
5337 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5338 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5340 (let* ((top (cond ((< (window-height) 4) 0)
5341 ((< (window-height) 7) 1)
5342 (t (if (numberp gnus-auto-center-summary)
5343 gnus-auto-center-summary
5345 (height (1- (window-height)))
5346 (bottom (save-excursion (goto-char (point-max))
5347 (forward-line (- height))
5349 (window (get-buffer-window (current-buffer))))
5350 ;; The user has to want it.
5351 (when gnus-auto-center-summary
5352 (when (get-buffer-window gnus-article-buffer)
5353 ;; Only do recentering when the article buffer is displayed,
5354 ;; Set the window start to either `bottom', which is the biggest
5355 ;; possible valid number, or the second line from the top,
5356 ;; whichever is the least.
5357 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5358 (if (> bottom top-pos)
5359 ;; Keep the second line from the top visible
5360 (set-window-start window top-pos t)
5361 ;; Try to keep the bottom line visible; if it's partially
5362 ;; obscured, either scroll one more line to make it fully
5363 ;; visible, or revert to using TOP-POS.
5365 (goto-char (point-max))
5367 (let ((last-line-start (point)))
5369 (set-window-start window (point) t)
5370 (when (not (pos-visible-in-window-p last-line-start window))
5372 (set-window-start window (min (point) top-pos) t)))))))
5373 ;; Do horizontal recentering while we're at it.
5374 (when (and (get-buffer-window (current-buffer) t)
5375 (not (eq gnus-auto-center-summary 'vertical)))
5376 (let ((selected (selected-window)))
5377 (select-window (get-buffer-window (current-buffer) t))
5378 (gnus-summary-position-point)
5379 (gnus-horizontal-recenter)
5380 (select-window selected))))))
5382 (defun gnus-summary-jump-to-group (newsgroup)
5383 "Move point to NEWSGROUP in group mode buffer."
5384 ;; Keep update point of group mode buffer if visible.
5385 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5386 (save-window-excursion
5387 ;; Take care of tree window mode.
5388 (when (get-buffer-window gnus-group-buffer)
5389 (pop-to-buffer gnus-group-buffer))
5390 (gnus-group-jump-to-group newsgroup))
5392 ;; Take care of tree window mode.
5393 (if (get-buffer-window gnus-group-buffer)
5394 (pop-to-buffer gnus-group-buffer)
5395 (set-buffer gnus-group-buffer))
5396 (gnus-group-jump-to-group newsgroup))))
5398 ;; This function returns a list of article numbers based on the
5399 ;; difference between the ranges of read articles in this group and
5400 ;; the range of active articles.
5401 (defun gnus-list-of-unread-articles (group)
5402 (let* ((read (gnus-info-read (gnus-get-info group)))
5403 (active (or (gnus-active group) (gnus-activate-group group)))
5406 ;; If none are read, then all are unread.
5408 (setq first (car active))
5409 ;; If the range of read articles is a single range, then the
5410 ;; first unread article is the article after the last read
5411 ;; article. Sounds logical, doesn't it?
5412 (if (and (not (listp (cdr read)))
5413 (or (< (car read) (car active))
5414 (progn (setq read (list read))
5416 (setq first (max (car active) (1+ (cdr read))))
5417 ;; `read' is a list of ranges.
5418 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5421 (setq first (car active)))
5424 (while (< first nlast)
5426 (setq first (1+ first))))
5427 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5428 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5429 (setq read (cdr read)))))
5430 ;; And add the last unread articles.
5431 (while (<= first last)
5433 (setq first (1+ first)))
5434 ;; Return the list of unread articles.
5435 (delq 0 (nreverse unread))))
5437 (defun gnus-list-of-read-articles (group)
5438 "Return a list of unread, unticked and non-dormant articles."
5439 (let* ((info (gnus-get-info group))
5440 (marked (gnus-info-marks info))
5441 (active (gnus-active group)))
5443 (gnus-set-difference
5444 (gnus-sorted-complement
5445 (gnus-uncompress-range active)
5446 (gnus-list-of-unread-articles group))
5448 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5449 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5451 ;; Various summary commands
5453 (defun gnus-summary-select-article-buffer ()
5454 "Reconfigure windows to show article buffer."
5456 (if (not (gnus-buffer-live-p gnus-article-buffer))
5457 (error "There is no article buffer for this summary buffer")
5458 (gnus-configure-windows 'article)
5459 (select-window (get-buffer-window gnus-article-buffer))))
5461 (defun gnus-summary-universal-argument (arg)
5462 "Perform any operation on all articles that are process/prefixed."
5464 (let ((articles (gnus-summary-work-articles arg))
5471 (substitute-command-keys
5472 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5474 (gnus-error 1 "Undefined key")
5477 (gnus-summary-goto-subject (setq article (pop articles)))
5478 (let (gnus-newsgroup-processable)
5479 (command-execute func))
5480 (gnus-summary-remove-process-mark article)))))
5481 (gnus-summary-position-point))
5483 (defun gnus-summary-toggle-truncation (&optional arg)
5484 "Toggle truncation of summary lines.
5485 With arg, turn line truncation on iff arg is positive."
5487 (setq truncate-lines
5488 (if (null arg) (not truncate-lines)
5489 (> (prefix-numeric-value arg) 0)))
5492 (defun gnus-summary-reselect-current-group (&optional all rescan)
5493 "Exit and then reselect the current newsgroup.
5494 The prefix argument ALL means to select all articles."
5496 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5497 (error "Ephemeral groups can't be reselected"))
5498 (let ((current-subject (gnus-summary-article-number))
5499 (group gnus-newsgroup-name))
5500 (setq gnus-newsgroup-begin nil)
5502 ;; We have to adjust the point of group mode buffer because
5503 ;; point was moved to the next unread newsgroup by exiting.
5504 (gnus-summary-jump-to-group group)
5507 (gnus-group-get-new-news-this-group 1)))
5508 (gnus-group-read-group all t)
5509 (gnus-summary-goto-subject current-subject nil t)))
5511 (defun gnus-summary-rescan-group (&optional all)
5512 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5514 (gnus-summary-reselect-current-group all t))
5516 (defun gnus-summary-update-info (&optional non-destructive)
5518 (let ((group gnus-newsgroup-name))
5520 (when gnus-newsgroup-kill-headers
5521 (setq gnus-newsgroup-killed
5522 (gnus-compress-sequence
5524 (gnus-set-sorted-intersection
5525 (gnus-uncompress-range gnus-newsgroup-killed)
5526 (setq gnus-newsgroup-unselected
5527 (sort gnus-newsgroup-unselected '<)))
5528 (setq gnus-newsgroup-unreads
5529 (sort gnus-newsgroup-unreads '<)))
5531 (unless (listp (cdr gnus-newsgroup-killed))
5532 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5533 (let ((headers gnus-newsgroup-headers))
5534 ;; Set the new ranges of read articles.
5536 (set-buffer gnus-group-buffer)
5537 (gnus-undo-force-boundary))
5538 (gnus-update-read-articles
5539 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5540 ;; Set the current article marks.
5541 (let ((gnus-newsgroup-scored
5542 (if (and (not gnus-save-score)
5543 (not non-destructive))
5545 gnus-newsgroup-scored)))
5547 (gnus-update-marks)))
5548 ;; Do the cross-ref thing.
5549 (when gnus-use-cross-reference
5550 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5551 ;; Do not switch windows but change the buffer to work.
5552 (set-buffer gnus-group-buffer)
5553 (unless (gnus-ephemeral-group-p group)
5554 (gnus-group-update-group group)))))))
5556 (defun gnus-summary-save-newsrc (&optional force)
5557 "Save the current number of read/marked articles in the dribble buffer.
5558 The dribble buffer will then be saved.
5559 If FORCE (the prefix), also save the .newsrc file(s)."
5561 (gnus-summary-update-info t)
5563 (gnus-save-newsrc-file)
5564 (gnus-dribble-save)))
5566 (defun gnus-summary-exit (&optional temporary)
5567 "Exit reading current newsgroup, and then return to group selection mode.
5568 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5570 (gnus-set-global-variables)
5571 (when (gnus-buffer-live-p gnus-article-buffer)
5573 (set-buffer gnus-article-buffer)
5574 (mm-destroy-parts gnus-article-mime-handles)
5575 ;; Set it to nil for safety reason.
5576 (setq gnus-article-mime-handle-alist nil)
5577 (setq gnus-article-mime-handles nil)))
5578 (gnus-kill-save-kill-buffer)
5579 (gnus-async-halt-prefetch)
5580 (let* ((group gnus-newsgroup-name)
5581 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5584 (buf (current-buffer)))
5586 ;; Do adaptive scoring, and possibly save score files.
5587 (when gnus-newsgroup-adaptive
5588 (gnus-score-adaptive))
5589 (when gnus-use-scoring
5591 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5592 ;; If we have several article buffers, we kill them at exit.
5593 (unless gnus-single-article-buffer
5594 (gnus-kill-buffer gnus-original-article-buffer)
5595 (setq gnus-article-current nil))
5596 (when gnus-use-cache
5597 (gnus-cache-possibly-remove-articles)
5598 (gnus-cache-save-buffers))
5599 (gnus-async-prefetch-remove-group group)
5600 (when gnus-suppress-duplicates
5601 (gnus-dup-enter-articles))
5602 (when gnus-use-trees
5603 (gnus-tree-close group))
5604 (when gnus-use-cache
5605 (gnus-cache-write-active))
5606 ;; Remove entries for this group.
5607 (nnmail-purge-split-history (gnus-group-real-name group))
5608 ;; Make all changes in this group permanent.
5610 (gnus-run-hooks 'gnus-exit-group-hook)
5611 (gnus-summary-update-info))
5612 (gnus-close-group group)
5613 ;; Make sure where we were, and go to next newsgroup.
5614 (set-buffer gnus-group-buffer)
5616 (gnus-group-jump-to-group group))
5617 (gnus-run-hooks 'gnus-summary-exit-hook)
5618 (unless (or quit-config
5619 ;; If this group has disappeared from the summary
5620 ;; buffer, don't skip forwards.
5621 (not (string= group (gnus-group-group-name))))
5622 (gnus-group-next-unread-group 1))
5623 (setq group-point (point))
5626 ;; If we have several article buffers, we kill them at exit.
5627 (unless gnus-single-article-buffer
5628 (gnus-kill-buffer gnus-article-buffer)
5629 (gnus-kill-buffer gnus-original-article-buffer)
5630 (setq gnus-article-current nil))
5632 (if (not gnus-kill-summary-on-exit)
5633 (gnus-deaden-summary)
5634 ;; We set all buffer-local variables to nil. It is unclear why
5635 ;; this is needed, but if we don't, buffer-local variables are
5636 ;; not garbage-collected, it seems. This would the lead to en
5637 ;; ever-growing Emacs.
5638 (gnus-summary-clear-local-variables)
5639 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5640 (gnus-summary-clear-local-variables))
5641 (when (get-buffer gnus-article-buffer)
5642 (bury-buffer gnus-article-buffer))
5643 ;; We clear the global counterparts of the buffer-local
5644 ;; variables as well, just to be on the safe side.
5645 (set-buffer gnus-group-buffer)
5646 (gnus-summary-clear-local-variables)
5647 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5648 (gnus-summary-clear-local-variables))
5649 ;; Return to group mode buffer.
5650 (when (eq mode 'gnus-summary-mode)
5651 (gnus-kill-buffer buf)))
5652 (setq gnus-current-select-method gnus-select-method)
5653 (pop-to-buffer gnus-group-buffer)
5654 (if (not quit-config)
5656 (goto-char group-point)
5657 (gnus-configure-windows 'group 'force))
5658 (gnus-handle-ephemeral-exit quit-config))
5659 ;; Clear the current group name.
5661 (setq gnus-newsgroup-name nil)))))
5663 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5664 (defun gnus-summary-exit-no-update (&optional no-questions)
5665 "Quit reading current newsgroup without updating read article info."
5667 (let* ((group gnus-newsgroup-name)
5668 (quit-config (gnus-group-quit-config group)))
5669 (when (or no-questions
5671 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5672 (gnus-async-halt-prefetch)
5674 (delq 'gnus-summary-expire-articles
5675 (copy-sequence gnus-summary-prepare-exit-hook)))
5676 (when (gnus-buffer-live-p gnus-article-buffer)
5678 (set-buffer gnus-article-buffer)
5679 (mm-destroy-parts gnus-article-mime-handles)
5680 ;; Set it to nil for safety reason.
5681 (setq gnus-article-mime-handle-alist nil)
5682 (setq gnus-article-mime-handles nil)))
5683 ;; If we have several article buffers, we kill them at exit.
5684 (unless gnus-single-article-buffer
5685 (gnus-kill-buffer gnus-article-buffer)
5686 (gnus-kill-buffer gnus-original-article-buffer)
5687 (setq gnus-article-current nil))
5688 (if (not gnus-kill-summary-on-exit)
5689 (gnus-deaden-summary)
5690 (gnus-close-group group)
5691 (gnus-summary-clear-local-variables)
5692 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5693 (gnus-summary-clear-local-variables))
5694 (set-buffer gnus-group-buffer)
5695 (gnus-summary-clear-local-variables)
5696 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5697 (gnus-summary-clear-local-variables))
5698 (when (get-buffer gnus-summary-buffer)
5699 (kill-buffer gnus-summary-buffer)))
5700 (unless gnus-single-article-buffer
5701 (setq gnus-article-current nil))
5702 (when gnus-use-trees
5703 (gnus-tree-close group))
5704 (gnus-async-prefetch-remove-group group)
5705 (when (get-buffer gnus-article-buffer)
5706 (bury-buffer gnus-article-buffer))
5707 ;; Return to the group buffer.
5708 (gnus-configure-windows 'group 'force)
5709 ;; Clear the current group name.
5710 (setq gnus-newsgroup-name nil)
5711 (when (equal (gnus-group-group-name) group)
5712 (gnus-group-next-unread-group 1))
5714 (gnus-handle-ephemeral-exit quit-config)))))
5716 (defun gnus-handle-ephemeral-exit (quit-config)
5717 "Handle movement when leaving an ephemeral group.
5718 The state which existed when entering the ephemeral is reset."
5719 (if (not (buffer-name (car quit-config)))
5720 (gnus-configure-windows 'group 'force)
5721 (set-buffer (car quit-config))
5722 (cond ((eq major-mode 'gnus-summary-mode)
5723 (gnus-set-global-variables))
5724 ((eq major-mode 'gnus-article-mode)
5726 ;; The `gnus-summary-buffer' variable may point
5727 ;; to the old summary buffer when using a single
5729 (unless (gnus-buffer-live-p gnus-summary-buffer)
5730 (set-buffer gnus-group-buffer))
5731 (set-buffer gnus-summary-buffer)
5732 (gnus-set-global-variables))))
5733 (if (or (eq (cdr quit-config) 'article)
5734 (eq (cdr quit-config) 'pick))
5736 ;; The current article may be from the ephemeral group
5737 ;; thus it is best that we reload this article
5738 (gnus-summary-show-article)
5739 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5740 (gnus-configure-windows 'pick 'force)
5741 (gnus-configure-windows (cdr quit-config) 'force)))
5742 (gnus-configure-windows (cdr quit-config) 'force))
5743 (when (eq major-mode 'gnus-summary-mode)
5744 (gnus-summary-next-subject 1 nil t)
5745 (gnus-summary-recenter)
5746 (gnus-summary-position-point))))
5750 (defvar gnus-dead-summary-mode-map nil)
5752 (unless gnus-dead-summary-mode-map
5753 (setq gnus-dead-summary-mode-map (make-keymap))
5754 (suppress-keymap gnus-dead-summary-mode-map)
5755 (substitute-key-definition
5756 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5757 (let ((keys '("\C-d" "\r" "\177" [delete])))
5759 (define-key gnus-dead-summary-mode-map
5760 (pop keys) 'gnus-summary-wake-up-the-dead))))
5762 (defvar gnus-dead-summary-mode nil
5763 "Minor mode for Gnus summary buffers.")
5765 (defun gnus-dead-summary-mode (&optional arg)
5766 "Minor mode for Gnus summary buffers."
5768 (when (eq major-mode 'gnus-summary-mode)
5769 (make-local-variable 'gnus-dead-summary-mode)
5770 (setq gnus-dead-summary-mode
5771 (if (null arg) (not gnus-dead-summary-mode)
5772 (> (prefix-numeric-value arg) 0)))
5773 (when gnus-dead-summary-mode
5774 (gnus-add-minor-mode
5775 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5777 (defun gnus-deaden-summary ()
5778 "Make the current summary buffer into a dead summary buffer."
5779 ;; Kill any previous dead summary buffer.
5780 (when (and gnus-dead-summary
5781 (buffer-name gnus-dead-summary))
5783 (set-buffer gnus-dead-summary)
5784 (when gnus-dead-summary-mode
5785 (kill-buffer (current-buffer)))))
5786 ;; Make this the current dead summary.
5787 (setq gnus-dead-summary (current-buffer))
5788 (gnus-dead-summary-mode 1)
5789 (let ((name (buffer-name)))
5790 (when (string-match "Summary" name)
5792 (concat (substring name 0 (match-beginning 0)) "Dead "
5793 (substring name (match-beginning 0)))
5797 (defun gnus-kill-or-deaden-summary (buffer)
5798 "Kill or deaden the summary BUFFER."
5800 (when (and (buffer-name buffer)
5801 (not gnus-single-article-buffer))
5804 (gnus-kill-buffer gnus-article-buffer)
5805 (gnus-kill-buffer gnus-original-article-buffer)))
5806 (cond (gnus-kill-summary-on-exit
5807 (when (and gnus-use-trees
5808 (gnus-buffer-exists-p buffer))
5811 (gnus-tree-close gnus-newsgroup-name)))
5812 (gnus-kill-buffer buffer))
5813 ((gnus-buffer-exists-p buffer)
5816 (gnus-deaden-summary))))))
5818 (defun gnus-summary-wake-up-the-dead (&rest args)
5819 "Wake up the dead summary buffer."
5821 (gnus-dead-summary-mode -1)
5822 (let ((name (buffer-name)))
5823 (when (string-match "Dead " name)
5825 (concat (substring name 0 (match-beginning 0))
5826 (substring name (match-end 0)))
5828 (gnus-message 3 "This dead summary is now alive again"))
5830 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5831 (defun gnus-summary-fetch-faq (&optional faq-dir)
5832 "Fetch the FAQ for the current group.
5833 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5837 (when current-prefix-arg
5839 "Faq dir: " (and (listp gnus-group-faq-directory)
5840 (mapcar (lambda (file) (list file))
5841 gnus-group-faq-directory))))))
5842 (let (gnus-faq-buffer)
5843 (when (setq gnus-faq-buffer
5844 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5845 (gnus-configure-windows 'summary-faq))))
5847 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5848 (defun gnus-summary-describe-group (&optional force)
5849 "Describe the current newsgroup."
5851 (gnus-group-describe-group force gnus-newsgroup-name))
5853 (defun gnus-summary-describe-briefly ()
5854 "Describe summary mode commands briefly."
5856 (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")))
5858 ;; Walking around group mode buffer from summary mode.
5860 (defun gnus-summary-next-group (&optional no-article target-group backward)
5861 "Exit current newsgroup and then select next unread newsgroup.
5862 If prefix argument NO-ARTICLE is non-nil, no article is selected
5863 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5864 previous group instead."
5866 ;; Stop pre-fetching.
5867 (gnus-async-halt-prefetch)
5868 (let ((current-group gnus-newsgroup-name)
5869 (current-buffer (current-buffer))
5871 ;; First we semi-exit this group to update Xrefs and all variables.
5872 ;; We can't do a real exit, because the window conf must remain
5873 ;; the same in case the user is prompted for info, and we don't
5874 ;; want the window conf to change before that...
5875 (gnus-summary-exit t)
5876 (while (not entered)
5877 ;; Then we find what group we are supposed to enter.
5878 (set-buffer gnus-group-buffer)
5879 (gnus-group-jump-to-group current-group)
5882 (if (eq gnus-keep-same-level 'best)
5883 (gnus-summary-best-group gnus-newsgroup-name)
5884 (gnus-summary-search-group backward gnus-keep-same-level))))
5885 (if (not target-group)
5886 ;; There are no further groups, so we return to the group
5889 (gnus-message 5 "Returning to the group buffer")
5891 (when (gnus-buffer-live-p current-buffer)
5892 (set-buffer current-buffer)
5893 (gnus-summary-exit))
5894 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5895 ;; We try to enter the target group.
5896 (gnus-group-jump-to-group target-group)
5897 (let ((unreads (gnus-group-group-unread)))
5898 (if (and (or (eq t unreads)
5899 (and unreads (not (zerop unreads))))
5900 (gnus-summary-read-group
5901 target-group nil no-article
5902 (and (buffer-name current-buffer) current-buffer)
5905 (setq current-group target-group
5906 target-group nil)))))))
5908 (defun gnus-summary-prev-group (&optional no-article)
5909 "Exit current newsgroup and then select previous unread newsgroup.
5910 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5912 (gnus-summary-next-group no-article nil t))
5914 ;; Walking around summary lines.
5916 (defun gnus-summary-first-subject (&optional unread undownloaded)
5917 "Go to the first unread subject.
5918 If UNREAD is non-nil, go to the first unread article.
5919 Returns the article selected or nil if there are no unread articles."
5924 ((null gnus-newsgroup-data)
5925 (gnus-message 3 "No articles in the group")
5927 ;; Pick the first article.
5929 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5930 (gnus-data-number (car gnus-newsgroup-data)))
5931 ;; No unread articles.
5932 ((null gnus-newsgroup-unreads)
5933 (gnus-message 3 "No more unread articles")
5935 ;; Find the first unread article.
5937 (let ((data gnus-newsgroup-data))
5939 (and (not (and undownloaded
5940 (eq gnus-undownloaded-mark
5941 (gnus-data-mark (car data)))))
5942 (not (gnus-data-unread-p (car data)))))
5943 (setq data (cdr data)))
5945 (goto-char (gnus-data-pos (car data)))
5946 (gnus-data-number (car data))))))
5947 (gnus-summary-position-point)))
5949 (defun gnus-summary-next-subject (n &optional unread dont-display)
5950 "Go to next N'th summary line.
5951 If N is negative, go to the previous N'th subject line.
5952 If UNREAD is non-nil, only unread articles are selected.
5953 The difference between N and the actual number of steps taken is
5956 (let ((backward (< n 0))
5960 (gnus-summary-find-prev unread)
5961 (gnus-summary-find-next unread)))
5962 (unless (zerop (setq n (1- n)))
5963 (gnus-summary-show-thread)))
5965 (gnus-message 7 "No more%s articles"
5966 (if unread " unread" "")))
5967 (unless dont-display
5968 (gnus-summary-recenter)
5969 (gnus-summary-position-point))
5972 (defun gnus-summary-next-unread-subject (n)
5973 "Go to next N'th unread summary line."
5975 (gnus-summary-next-subject n t))
5977 (defun gnus-summary-prev-subject (n &optional unread)
5978 "Go to previous N'th summary line.
5979 If optional argument UNREAD is non-nil, only unread article is selected."
5981 (gnus-summary-next-subject (- n) unread))
5983 (defun gnus-summary-prev-unread-subject (n)
5984 "Go to previous N'th unread summary line."
5986 (gnus-summary-next-subject (- n) t))
5988 (defun gnus-summary-goto-subject (article &optional force silent)
5989 "Go the subject line of ARTICLE.
5990 If FORCE, also allow jumping to articles not currently shown."
5991 (interactive "nArticle number: ")
5993 (data (gnus-data-find article)))
5994 ;; We read in the article if we have to.
5997 (gnus-summary-insert-subject
5999 (if (or (numberp force) (vectorp force)) force)
6001 (setq data (gnus-data-find article)))
6006 (gnus-message 3 "Can't find article %d" article))
6008 (goto-char (gnus-data-pos data))
6009 (gnus-summary-position-point)
6012 ;; Walking around summary lines with displaying articles.
6014 (defun gnus-summary-expand-window (&optional arg)
6015 "Make the summary buffer take up the entire Emacs frame.
6016 Given a prefix, will force an `article' buffer configuration."
6019 (gnus-configure-windows 'article 'force)
6020 (gnus-configure-windows 'summary 'force)))
6022 (defun gnus-summary-display-article (article &optional all-header)
6023 "Display ARTICLE in article buffer."
6024 (when (gnus-buffer-live-p gnus-article-buffer)
6025 (with-current-buffer gnus-article-buffer
6026 (mm-enable-multibyte-mule4)))
6027 (gnus-set-global-variables)
6028 (when (gnus-buffer-live-p gnus-article-buffer)
6029 (with-current-buffer gnus-article-buffer
6030 (setq gnus-article-charset gnus-newsgroup-charset)
6031 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6032 (mm-enable-multibyte-mule4)))
6036 (if gnus-summary-display-article-function
6037 (funcall gnus-summary-display-article-function article all-header)
6038 (gnus-article-prepare article all-header))
6039 (gnus-run-hooks 'gnus-select-article-hook)
6040 (when (and gnus-current-article
6041 (not (zerop gnus-current-article)))
6042 (gnus-summary-goto-subject gnus-current-article))
6043 (gnus-summary-recenter)
6044 (when (and gnus-use-trees gnus-show-threads)
6045 (gnus-possibly-generate-tree article)
6046 (gnus-highlight-selected-tree article))
6047 ;; Successfully display article.
6048 (gnus-article-set-window-start
6049 (cdr (assq article gnus-newsgroup-bookmarks))))))
6051 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6052 "Select the current article.
6053 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6054 non-nil, the article will be re-fetched even if it already present in
6055 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6057 ;; Make sure we are in the summary buffer to work around bbdb bug.
6058 (unless (eq major-mode 'gnus-summary-mode)
6059 (set-buffer gnus-summary-buffer))
6060 (let ((article (or article (gnus-summary-article-number)))
6061 (all-headers (not (not all-headers))) ;Must be T or NIL.
6062 gnus-summary-display-article-function)
6064 (gnus-summary-article-pseudo-p article)
6065 (error "This is a pseudo-article"))
6067 (set-buffer gnus-summary-buffer)
6068 (if (or (and gnus-single-article-buffer
6069 (or (null gnus-current-article)
6070 (null gnus-article-current)
6071 (null (get-buffer gnus-article-buffer))
6072 (not (eq article (cdr gnus-article-current)))
6073 (not (equal (car gnus-article-current)
6074 gnus-newsgroup-name))))
6075 (and (not gnus-single-article-buffer)
6076 (or (null gnus-current-article)
6077 (not (eq gnus-current-article article))))
6079 ;; The requested article is different from the current article.
6081 (gnus-summary-display-article article all-headers)
6082 (when (gnus-buffer-live-p gnus-article-buffer)
6083 (with-current-buffer gnus-article-buffer
6084 (if (not gnus-article-decoded-p) ;; a local variable
6085 (mm-disable-multibyte-mule4))))
6086 (when (or all-headers gnus-show-all-headers)
6087 (gnus-article-show-all-headers))
6088 (gnus-article-set-window-start
6089 (cdr (assq article gnus-newsgroup-bookmarks)))
6091 (when (or all-headers gnus-show-all-headers)
6092 (gnus-article-show-all-headers))
6095 (defun gnus-summary-force-verify-and-decrypt ()
6097 (let ((mm-verify-option 'known)
6098 (mm-decrypt-option 'known))
6099 (gnus-summary-select-article nil 'force)))
6101 (defun gnus-summary-set-current-mark (&optional current-mark)
6102 "Obsolete function."
6105 (defun gnus-summary-next-article (&optional unread subject backward push)
6106 "Select the next article.
6107 If UNREAD, only unread articles are selected.
6108 If SUBJECT, only articles with SUBJECT are selected.
6109 If BACKWARD, the previous article is selected instead of the next."
6112 ;; Is there such an article?
6113 ((and (gnus-summary-search-forward unread subject backward)
6114 (or (gnus-summary-display-article (gnus-summary-article-number))
6115 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6116 (gnus-summary-position-point))
6117 ;; If not, we try the first unread, if that is wanted.
6119 gnus-auto-select-same
6120 (gnus-summary-first-unread-article))
6121 (gnus-summary-position-point)
6122 (gnus-message 6 "Wrapped"))
6123 ;; Try to get next/previous article not displayed in this group.
6124 ((and gnus-auto-extend-newsgroup
6125 (not unread) (not subject))
6126 (gnus-summary-goto-article
6127 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6128 nil (count-lines (point-min) (point))))
6129 ;; Go to next/previous group.
6131 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6132 (gnus-summary-jump-to-group gnus-newsgroup-name))
6133 (let ((cmd last-command-char)
6136 (set-buffer gnus-group-buffer)
6139 (if (eq gnus-keep-same-level 'best)
6140 (gnus-summary-best-group gnus-newsgroup-name)
6141 (gnus-summary-search-group backward gnus-keep-same-level))))
6142 ;; For some reason, the group window gets selected. We change
6144 (select-window (get-buffer-window (current-buffer)))
6145 ;; Select next unread newsgroup automagically.
6147 ((or (not gnus-auto-select-next)
6149 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6150 ((or (eq gnus-auto-select-next 'quietly)
6151 (and (eq gnus-auto-select-next 'slightly-quietly)
6153 (and (eq gnus-auto-select-next 'almost-quietly)
6154 (gnus-summary-last-article-p)))
6156 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6158 (gnus-message 7 "No more%s articles (%s)..."
6159 (if unread " unread" "")
6160 (if group (concat "selecting " group)
6162 (gnus-summary-next-group nil group backward)))
6164 (when (gnus-key-press-event-p last-input-event)
6165 (gnus-summary-walk-group-buffer
6166 gnus-newsgroup-name cmd unread backward point))))))))
6168 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6169 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6170 (?\C-p (gnus-group-prev-unread-group 1))))
6171 (cursor-in-echo-area t)
6172 keve key group ended)
6174 (set-buffer gnus-group-buffer)
6177 (if (eq gnus-keep-same-level 'best)
6178 (gnus-summary-best-group gnus-newsgroup-name)
6179 (gnus-summary-search-group backward gnus-keep-same-level))))
6182 5 "No more%s articles%s" (if unread " unread" "")
6184 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6185 (format " (Type %s for %s [%s])"
6186 (single-key-description cmd) group
6187 (car (gnus-gethash group gnus-newsrc-hashtb)))
6188 (format " (Type %s to exit %s)"
6189 (single-key-description cmd)
6190 gnus-newsgroup-name)))
6191 ;; Confirm auto selection.
6192 (setq key (car (setq keve (gnus-read-event-char))))
6195 ((assq key keystrokes)
6196 (let ((obuf (current-buffer)))
6197 (switch-to-buffer gnus-group-buffer)
6199 (gnus-group-jump-to-group group))
6200 (eval (cadr (assq key keystrokes)))
6201 (setq group (gnus-group-group-name))
6202 (switch-to-buffer obuf))
6206 (gnus-ephemeral-group-p gnus-newsgroup-name))
6208 (gnus-summary-next-group nil group backward)))
6210 (push (cdr keve) unread-command-events))))))
6212 (defun gnus-summary-next-unread-article ()
6213 "Select unread article after current one."
6215 (gnus-summary-next-article
6216 (or (not (eq gnus-summary-goto-unread 'never))
6217 (gnus-summary-last-article-p (gnus-summary-article-number)))
6218 (and gnus-auto-select-same
6219 (gnus-summary-article-subject))))
6221 (defun gnus-summary-prev-article (&optional unread subject)
6222 "Select the article after the current one.
6223 If UNREAD is non-nil, only unread articles are selected."
6225 (gnus-summary-next-article unread subject t))
6227 (defun gnus-summary-prev-unread-article ()
6228 "Select unread article before current one."
6230 (gnus-summary-prev-article
6231 (or (not (eq gnus-summary-goto-unread 'never))
6232 (gnus-summary-first-article-p (gnus-summary-article-number)))
6233 (and gnus-auto-select-same
6234 (gnus-summary-article-subject))))
6236 (defun gnus-summary-next-page (&optional lines circular)
6237 "Show next page of the selected article.
6238 If at the end of the current article, select the next article.
6239 LINES says how many lines should be scrolled up.
6241 If CIRCULAR is non-nil, go to the start of the article instead of
6242 selecting the next article when reaching the end of the current
6245 (setq gnus-summary-buffer (current-buffer))
6246 (gnus-set-global-variables)
6247 (let ((article (gnus-summary-article-number))
6248 (article-window (get-buffer-window gnus-article-buffer t))
6250 ;; If the buffer is empty, we have no article.
6252 (error "No article to select"))
6253 (gnus-configure-windows 'article)
6254 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6255 (if (and (eq gnus-summary-goto-unread 'never)
6256 (not (gnus-summary-last-article-p article)))
6257 (gnus-summary-next-article)
6258 (gnus-summary-next-unread-article))
6259 (if (or (null gnus-current-article)
6260 (null gnus-article-current)
6261 (/= article (cdr gnus-article-current))
6262 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6263 ;; Selected subject is different from current article's.
6264 (gnus-summary-display-article article)
6265 (when article-window
6266 (gnus-eval-in-buffer-window gnus-article-buffer
6267 (setq endp (gnus-article-next-page lines)))
6270 (gnus-summary-beginning-of-article))
6272 (gnus-message 3 "End of message"))
6274 (if (and (eq gnus-summary-goto-unread 'never)
6275 (not (gnus-summary-last-article-p article)))
6276 (gnus-summary-next-article)
6277 (gnus-summary-next-unread-article))))))))
6278 (gnus-summary-recenter)
6279 (gnus-summary-position-point)))
6281 (defun gnus-summary-prev-page (&optional lines move)
6282 "Show previous page of selected article.
6283 Argument LINES specifies lines to be scrolled down.
6284 If MOVE, move to the previous unread article if point is at
6285 the beginning of the buffer."
6287 (let ((article (gnus-summary-article-number))
6288 (article-window (get-buffer-window gnus-article-buffer t))
6290 (gnus-configure-windows 'article)
6291 (if (or (null gnus-current-article)
6292 (null gnus-article-current)
6293 (/= article (cdr gnus-article-current))
6294 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6295 ;; Selected subject is different from current article's.
6296 (gnus-summary-display-article article)
6297 (gnus-summary-recenter)
6298 (when article-window
6299 (gnus-eval-in-buffer-window gnus-article-buffer
6300 (setq endp (gnus-article-prev-page lines)))
6301 (when (and move endp)
6303 (gnus-message 3 "Beginning of message"))
6305 (if (and (eq gnus-summary-goto-unread 'never)
6306 (not (gnus-summary-first-article-p article)))
6307 (gnus-summary-prev-article)
6308 (gnus-summary-prev-unread-article))))))))
6309 (gnus-summary-position-point))
6311 (defun gnus-summary-prev-page-or-article (&optional lines)
6312 "Show previous page of selected article.
6313 Argument LINES specifies lines to be scrolled down.
6314 If at the beginning of the article, go to the next article."
6316 (gnus-summary-prev-page lines t))
6318 (defun gnus-summary-scroll-up (lines)
6319 "Scroll up (or down) one line current article.
6320 Argument LINES specifies lines to be scrolled up (or down if negative)."
6322 (gnus-configure-windows 'article)
6323 (gnus-summary-show-thread)
6324 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6325 (gnus-eval-in-buffer-window gnus-article-buffer
6327 (when (gnus-article-next-page lines)
6328 (gnus-message 3 "End of message")))
6330 (gnus-article-prev-page (- lines))))))
6331 (gnus-summary-recenter)
6332 (gnus-summary-position-point))
6334 (defun gnus-summary-scroll-down (lines)
6335 "Scroll down (or up) one line current article.
6336 Argument LINES specifies lines to be scrolled down (or up if negative)."
6338 (gnus-summary-scroll-up (- lines)))
6340 (defun gnus-summary-next-same-subject ()
6341 "Select next article which has the same subject as current one."
6343 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6345 (defun gnus-summary-prev-same-subject ()
6346 "Select previous article which has the same subject as current one."
6348 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6350 (defun gnus-summary-next-unread-same-subject ()
6351 "Select next unread article which has the same subject as current one."
6353 (gnus-summary-next-article t (gnus-summary-article-subject)))
6355 (defun gnus-summary-prev-unread-same-subject ()
6356 "Select previous unread article which has the same subject as current one."
6358 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6360 (defun gnus-summary-first-unread-article ()
6361 "Select the first unread article.
6362 Return nil if there are no unread articles."
6365 (when (gnus-summary-first-subject t)
6366 (gnus-summary-show-thread)
6367 (gnus-summary-first-subject t)
6368 (gnus-summary-display-article (gnus-summary-article-number)))
6369 (gnus-summary-position-point)))
6371 (defun gnus-summary-first-unread-subject ()
6372 "Place the point on the subject line of the first unread article.
6373 Return nil if there are no unread articles."
6376 (when (gnus-summary-first-subject t)
6377 (gnus-summary-show-thread)
6378 (gnus-summary-first-subject t))
6379 (gnus-summary-position-point)))
6381 (defun gnus-summary-first-article ()
6382 "Select the first article.
6383 Return nil if there are no articles."
6386 (when (gnus-summary-first-subject)
6387 (gnus-summary-show-thread)
6388 (gnus-summary-first-subject)
6389 (gnus-summary-display-article (gnus-summary-article-number)))
6390 (gnus-summary-position-point)))
6392 (defun gnus-summary-best-unread-article ()
6393 "Select the unread article with the highest score."
6395 (let ((best -1000000)
6396 (data gnus-newsgroup-data)
6399 (and (gnus-data-unread-p (car data))
6401 (gnus-summary-article-score (gnus-data-number (car data))))
6404 article (gnus-data-number (car data))))
6405 (setq data (cdr data)))
6408 (gnus-summary-goto-article article)
6409 (error "No unread articles"))
6410 (gnus-summary-position-point))))
6412 (defun gnus-summary-last-subject ()
6413 "Go to the last displayed subject line in the group."
6414 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6416 (gnus-summary-goto-subject article))))
6418 (defun gnus-summary-goto-article (article &optional all-headers force)
6419 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6420 If ALL-HEADERS is non-nil, no header lines are hidden.
6421 If FORCE, go to the article even if it isn't displayed. If FORCE
6422 is a number, it is the line the article is to be displayed on."
6426 "Article number or Message-ID: "
6427 (mapcar (lambda (number) (list (int-to-string number)))
6428 gnus-newsgroup-limit))
6432 (if (and (stringp article)
6433 (string-match "@" article))
6434 (gnus-summary-refer-article article)
6435 (when (stringp article)
6436 (setq article (string-to-number article)))
6437 (if (gnus-summary-goto-subject article force)
6438 (gnus-summary-display-article article all-headers)
6439 (gnus-message 4 "Couldn't go to article %s" article) nil))
6440 (gnus-summary-position-point)))
6442 (defun gnus-summary-goto-last-article ()
6443 "Go to the previously read article."
6446 (when gnus-last-article
6447 (gnus-summary-goto-article gnus-last-article nil t))
6448 (gnus-summary-position-point)))
6450 (defun gnus-summary-pop-article (number)
6451 "Pop one article off the history and go to the previous.
6452 NUMBER articles will be popped off."
6455 (setq gnus-newsgroup-history
6456 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6458 (gnus-summary-goto-article (car to) nil t)
6459 (error "Article history empty")))
6460 (gnus-summary-position-point))
6462 ;; Summary commands and functions for limiting the summary buffer.
6464 (defun gnus-summary-limit-to-articles (n)
6465 "Limit the summary buffer to the next N articles.
6466 If not given a prefix, use the process marked articles instead."
6469 (let ((articles (gnus-summary-work-articles n)))
6470 (setq gnus-newsgroup-processable nil)
6471 (gnus-summary-limit articles))
6472 (gnus-summary-position-point)))
6474 (defun gnus-summary-pop-limit (&optional total)
6475 "Restore the previous limit.
6476 If given a prefix, remove all limits."
6479 (setq gnus-newsgroup-limits
6480 (list (mapcar (lambda (h) (mail-header-number h))
6481 gnus-newsgroup-headers))))
6482 (unless gnus-newsgroup-limits
6483 (error "No limit to pop"))
6485 (gnus-summary-limit nil 'pop)
6486 (gnus-summary-position-point)))
6488 (defun gnus-summary-limit-to-subject (subject &optional header)
6489 "Limit the summary buffer to articles that have subjects that match a regexp."
6490 (interactive "sLimit to subject (regexp): ")
6492 (setq header "subject"))
6493 (when (not (equal "" subject))
6495 (let ((articles (gnus-summary-find-matching
6496 (or header "subject") subject 'all)))
6498 (error "Found no matches for \"%s\"" subject))
6499 (gnus-summary-limit articles))
6500 (gnus-summary-position-point))))
6502 (defun gnus-summary-limit-to-author (from)
6503 "Limit the summary buffer to articles that have authors that match a regexp."
6504 (interactive "sLimit to author (regexp): ")
6505 (gnus-summary-limit-to-subject from "from"))
6507 (defun gnus-summary-limit-to-age (age &optional younger-p)
6508 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6509 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6510 articles that are younger than AGE days."
6512 (let ((younger current-prefix-arg)
6515 (while (not days-got)
6516 (setq days (if younger
6517 (read-string "Limit to articles within (in days): ")
6518 (read-string "Limit to articles older than (in days): ")))
6519 (when (> (length days) 0)
6520 (setq days (read days)))
6523 (message "Please enter a number.")
6525 (list days younger)))
6527 (let ((data gnus-newsgroup-data)
6528 (cutoff (days-to-time age))
6529 articles d date is-younger)
6530 (while (setq d (pop data))
6531 (when (and (vectorp (gnus-data-header d))
6532 (setq date (mail-header-date (gnus-data-header d))))
6533 (setq is-younger (time-less-p
6534 (time-since (condition-case ()
6541 (push (gnus-data-number d) articles))))
6542 (gnus-summary-limit (nreverse articles)))
6543 (gnus-summary-position-point)))
6545 (defun gnus-summary-limit-to-extra (header regexp)
6546 "Limit the summary buffer to articles that match an 'extra' header."
6550 (gnus-completing-read
6551 (symbol-name (car gnus-extra-headers))
6552 "Limit extra header:"
6554 (cons (symbol-name x) x))
6559 (read-string (format "Limit to header %s (regexp): " header)))))
6560 (when (not (equal "" regexp))
6562 (let ((articles (gnus-summary-find-matching
6563 (cons 'extra header) regexp 'all)))
6565 (error "Found no matches for \"%s\"" regexp))
6566 (gnus-summary-limit articles))
6567 (gnus-summary-position-point))))
6569 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6571 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6573 (defun gnus-summary-limit-to-unread (&optional all)
6574 "Limit the summary buffer to articles that are not marked as read.
6575 If ALL is non-nil, limit strictly to unread articles."
6578 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6579 (gnus-summary-limit-to-marks
6580 ;; Concat all the marks that say that an article is read and have
6582 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6583 gnus-killed-mark gnus-kill-file-mark
6584 gnus-low-score-mark gnus-expirable-mark
6585 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6586 gnus-duplicate-mark gnus-souped-mark)
6589 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6590 (make-obsolete 'gnus-summary-delete-marked-with
6591 'gnus-summary-limit-exlude-marks)
6593 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6594 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6595 If REVERSE, limit the summary buffer to articles that are marked
6596 with MARKS. MARKS can either be a string of marks or a list of marks.
6597 Returns how many articles were removed."
6598 (interactive "sMarks: ")
6599 (gnus-summary-limit-to-marks marks t))
6601 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6602 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6603 If REVERSE (the prefix), limit the summary buffer to articles that are
6604 not marked with MARKS. MARKS can either be a string of marks or a
6606 Returns how many articles were removed."
6607 (interactive "sMarks: \nP")
6609 (let ((data gnus-newsgroup-data)
6610 (marks (if (listp marks) marks
6611 (append marks nil))) ; Transform to list.
6614 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6615 (memq (gnus-data-mark (car data)) marks))
6616 (push (gnus-data-number (car data)) articles))
6617 (setq data (cdr data)))
6618 (gnus-summary-limit articles))
6619 (gnus-summary-position-point)))
6621 (defun gnus-summary-limit-to-score (&optional score)
6622 "Limit to articles with score at or above SCORE."
6624 (setq score (if score
6625 (prefix-numeric-value score)
6626 (or gnus-summary-default-score 0)))
6627 (let ((data gnus-newsgroup-data)
6630 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6632 (push (gnus-data-number (car data)) articles))
6633 (setq data (cdr data)))
6635 (gnus-summary-limit articles)
6636 (gnus-summary-position-point))))
6638 (defun gnus-summary-limit-include-thread (id)
6639 "Display all the hidden articles that in the current thread."
6640 (interactive (list (mail-header-id (gnus-summary-article-header))))
6641 (let ((articles (gnus-articles-in-thread
6642 (gnus-id-to-thread (gnus-root-id id)))))
6644 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6645 (gnus-summary-position-point))))
6647 (defun gnus-summary-limit-include-dormant ()
6648 "Display all the hidden articles that are marked as dormant.
6649 Note that this command only works on a subset of the articles currently
6650 fetched for this group."
6652 (unless gnus-newsgroup-dormant
6653 (error "There are no dormant articles in this group"))
6655 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6656 (gnus-summary-position-point)))
6658 (defun gnus-summary-limit-exclude-dormant ()
6659 "Hide all dormant articles."
6662 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6663 (gnus-summary-position-point)))
6665 (defun gnus-summary-limit-exclude-childless-dormant ()
6666 "Hide all dormant articles that have no children."
6668 (let ((data (gnus-data-list t))
6669 articles d children)
6670 ;; Find all articles that are either not dormant or have
6672 (while (setq d (pop data))
6673 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6675 (gnus-article-children (gnus-data-number d)))
6678 (when (memq (car children) articles)
6683 (push (gnus-data-number d) articles)))
6686 (gnus-summary-limit articles)
6687 (gnus-summary-position-point))))
6689 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6690 "Mark all unread excluded articles as read.
6691 If ALL, mark even excluded ticked and dormants as read."
6693 (let ((articles (gnus-sorted-complement
6695 (mapcar (lambda (h) (mail-header-number h))
6696 gnus-newsgroup-headers)
6698 (sort gnus-newsgroup-limit '<)))
6700 (setq gnus-newsgroup-unreads
6701 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6703 (setq gnus-newsgroup-dormant nil
6704 gnus-newsgroup-marked nil
6705 gnus-newsgroup-reads
6707 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6708 gnus-newsgroup-reads))
6709 (while (setq article (pop articles))
6710 (unless (or (memq article gnus-newsgroup-dormant)
6711 (memq article gnus-newsgroup-marked))
6712 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6714 (defun gnus-summary-limit (articles &optional pop)
6716 ;; We pop the previous limit off the stack and use that.
6717 (setq articles (car gnus-newsgroup-limits)
6718 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6719 ;; We use the new limit, so we push the old limit on the stack.
6720 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6722 (setq gnus-newsgroup-limit articles)
6723 (let ((total (length gnus-newsgroup-data))
6724 (data (gnus-data-find-list (gnus-summary-article-number)))
6725 (gnus-summary-mark-below nil) ; Inhibit this.
6727 ;; This will do all the work of generating the new summary buffer
6728 ;; according to the new limit.
6729 (gnus-summary-prepare)
6730 ;; Hide any threads, possibly.
6731 (and gnus-show-threads
6732 gnus-thread-hide-subtree
6733 (gnus-summary-hide-all-threads))
6734 ;; Try to return to the article you were at, or one in the
6737 ;; We try to find some article after the current one.
6739 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6742 (setq data (cdr data))))
6744 ;; If there is no data, that means that we were after the last
6745 ;; article. The same goes when we can't find any articles
6746 ;; after the current one.
6747 (goto-char (point-max))
6748 (gnus-summary-find-prev))
6749 (gnus-set-mode-line 'summary)
6750 ;; We return how many articles were removed from the summary
6751 ;; buffer as a result of the new limit.
6752 (- total (length gnus-newsgroup-data))))
6754 (defsubst gnus-invisible-cut-children (threads)
6757 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6762 (defsubst gnus-cut-thread (thread)
6763 "Go forwards in the thread until we find an article that we want to display."
6764 (when (or (eq gnus-fetch-old-headers 'some)
6765 (eq gnus-fetch-old-headers 'invisible)
6766 (numberp gnus-fetch-old-headers)
6767 (eq gnus-build-sparse-threads 'some)
6768 (eq gnus-build-sparse-threads 'more))
6769 ;; Deal with old-fetched headers and sparse threads.
6773 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6774 (gnus-summary-article-ancient-p
6775 (mail-header-number (car thread))))
6776 (if (or (<= (length (cdr thread)) 1)
6777 (eq gnus-fetch-old-headers 'invisible))
6778 (setq gnus-newsgroup-limit
6779 (delq (mail-header-number (car thread))
6780 gnus-newsgroup-limit)
6781 thread (cadr thread))
6782 (when (gnus-invisible-cut-children (cdr thread))
6783 (let ((th (cdr thread)))
6785 (if (memq (mail-header-number (caar th))
6786 gnus-newsgroup-limit)
6787 (setq thread (car th)
6789 (setq th (cdr th))))))))))
6792 (defun gnus-cut-threads (threads)
6793 "Cut off all uninteresting articles from the beginning of threads."
6794 (when (or (eq gnus-fetch-old-headers 'some)
6795 (eq gnus-fetch-old-headers 'invisible)
6796 (numberp gnus-fetch-old-headers)
6797 (eq gnus-build-sparse-threads 'some)
6798 (eq gnus-build-sparse-threads 'more))
6801 (setcar th (gnus-cut-thread (car th)))
6802 (setq th (cdr th)))))
6803 ;; Remove nixed out threads.
6806 (defun gnus-summary-initial-limit (&optional show-if-empty)
6807 "Figure out what the initial limit is supposed to be on group entry.
6808 This entails weeding out unwanted dormants, low-scored articles,
6809 fetch-old-headers verbiage, and so on."
6810 ;; Most groups have nothing to remove.
6811 (if (or gnus-inhibit-limiting
6812 (and (null gnus-newsgroup-dormant)
6813 (not (eq gnus-fetch-old-headers 'some))
6814 (not (numberp gnus-fetch-old-headers))
6815 (not (eq gnus-fetch-old-headers 'invisible))
6816 (null gnus-summary-expunge-below)
6817 (not (eq gnus-build-sparse-threads 'some))
6818 (not (eq gnus-build-sparse-threads 'more))
6819 (null gnus-thread-expunge-below)
6820 (not gnus-use-nocem)))
6822 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6823 (setq gnus-newsgroup-limit nil)
6826 (unless (car (symbol-value node))
6827 ;; These threads have no parents -- they are roots.
6828 (let ((nodes (cdr (symbol-value node)))
6831 (if (and gnus-thread-expunge-below
6832 (< (gnus-thread-total-score (car nodes))
6833 gnus-thread-expunge-below))
6834 (gnus-expunge-thread (pop nodes))
6835 (setq thread (pop nodes))
6836 (gnus-summary-limit-children thread))))))
6837 gnus-newsgroup-dependencies)
6838 ;; If this limitation resulted in an empty group, we might
6839 ;; pop the previous limit and use it instead.
6840 (when (and (not gnus-newsgroup-limit)
6842 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6843 gnus-newsgroup-limit))
6845 (defun gnus-summary-limit-children (thread)
6846 "Return 1 if this subthread is visible and 0 if it is not."
6847 ;; First we get the number of visible children to this thread. This
6848 ;; is done by recursing down the thread using this function, so this
6849 ;; will really go down to a leaf article first, before slowly
6850 ;; working its way up towards the root.
6854 (apply '+ (mapcar 'gnus-summary-limit-children
6857 (number (mail-header-number (car thread)))
6860 (not (memq number gnus-newsgroup-marked))
6862 ;; If this article is dormant and has absolutely no visible
6863 ;; children, then this article isn't visible.
6864 (and (memq number gnus-newsgroup-dormant)
6866 ;; If this is "fetch-old-headered" and there is no
6867 ;; visible children, then we don't want this article.
6868 (and (or (eq gnus-fetch-old-headers 'some)
6869 (numberp gnus-fetch-old-headers))
6870 (gnus-summary-article-ancient-p number)
6872 ;; If this is "fetch-old-headered" and `invisible', then
6873 ;; we don't want this article.
6874 (and (eq gnus-fetch-old-headers 'invisible)
6875 (gnus-summary-article-ancient-p number))
6876 ;; If this is a sparsely inserted article with no children,
6877 ;; we don't want it.
6878 (and (eq gnus-build-sparse-threads 'some)
6879 (gnus-summary-article-sparse-p number)
6881 ;; If we use expunging, and this article is really
6882 ;; low-scored, then we don't want this article.
6883 (when (and gnus-summary-expunge-below
6885 (or (cdr (assq number gnus-newsgroup-scored))
6886 gnus-summary-default-score))
6887 gnus-summary-expunge-below))
6888 ;; We increase the expunge-tally here, but that has
6889 ;; nothing to do with the limits, really.
6890 (incf gnus-newsgroup-expunged-tally)
6891 ;; We also mark as read here, if that's wanted.
6892 (when (and gnus-summary-mark-below
6893 (< score gnus-summary-mark-below))
6894 (setq gnus-newsgroup-unreads
6895 (delq number gnus-newsgroup-unreads))
6896 (if gnus-newsgroup-auto-expire
6897 (push number gnus-newsgroup-expirable)
6898 (push (cons number gnus-low-score-mark)
6899 gnus-newsgroup-reads)))
6901 ;; Check NoCeM things.
6902 (if (and gnus-use-nocem
6903 (gnus-nocem-unwanted-article-p
6904 (mail-header-id (car thread))))
6906 (setq gnus-newsgroup-unreads
6907 (delq number gnus-newsgroup-unreads))
6909 ;; Nope, invisible article.
6911 ;; Ok, this article is to be visible, so we add it to the limit
6913 (push number gnus-newsgroup-limit)
6916 (defun gnus-expunge-thread (thread)
6917 "Mark all articles in THREAD as read."
6918 (let* ((number (mail-header-number (car thread))))
6919 (incf gnus-newsgroup-expunged-tally)
6920 ;; We also mark as read here, if that's wanted.
6921 (setq gnus-newsgroup-unreads
6922 (delq number gnus-newsgroup-unreads))
6923 (if gnus-newsgroup-auto-expire
6924 (push number gnus-newsgroup-expirable)
6925 (push (cons number gnus-low-score-mark)
6926 gnus-newsgroup-reads)))
6927 ;; Go recursively through all subthreads.
6928 (mapcar 'gnus-expunge-thread (cdr thread)))
6930 ;; Summary article oriented commands
6932 (defun gnus-summary-refer-parent-article (n)
6933 "Refer parent article N times.
6934 If N is negative, go to ancestor -N instead.
6935 The difference between N and the number of articles fetched is returned."
6939 (when (not (natnump n))
6944 (setq header (gnus-summary-article-header))
6945 (if (and (eq (mail-header-number header)
6946 (cdr gnus-article-current))
6947 (equal gnus-newsgroup-name
6948 (car gnus-article-current)))
6949 ;; If we try to find the parent of the currently
6950 ;; displayed article, then we take a look at the actual
6951 ;; References header, since this is slightly more
6952 ;; reliable than the References field we got from the
6955 (set-buffer gnus-original-article-buffer)
6956 (nnheader-narrow-to-headers)
6957 (unless (setq ref (message-fetch-field "references"))
6958 (setq ref (message-fetch-field "in-reply-to")))
6961 ;; It's not the current article, so we take a bet on
6962 ;; the value we got from the server.
6963 (mail-header-references header)))
6965 (not (equal ref "")))
6966 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6967 (gnus-message 1 "Couldn't find parent"))
6968 (gnus-message 1 "No references in article %d"
6969 (gnus-summary-article-number))
6972 (gnus-summary-position-point)
6975 (defun gnus-summary-refer-references ()
6976 "Fetch all articles mentioned in the References header.
6977 Return the number of articles fetched."
6979 (let ((ref (mail-header-references (gnus-summary-article-header)))
6980 (current (gnus-summary-article-number))
6984 (error "No References in the current article")
6985 ;; For each Message-ID in the References header...
6986 (while (string-match "<[^>]*>" ref)
6988 ;; ... fetch that article.
6989 (gnus-summary-refer-article
6990 (prog1 (match-string 0 ref)
6991 (setq ref (substring ref (match-end 0))))))
6992 (gnus-summary-goto-subject current)
6993 (gnus-summary-position-point)
6996 (defun gnus-summary-refer-thread (&optional limit)
6997 "Fetch all articles in the current thread.
6998 If LIMIT (the numerical prefix), fetch that many old headers instead
6999 of what's specified by the `gnus-refer-thread-limit' variable."
7001 (let ((id (mail-header-id (gnus-summary-article-header)))
7002 (limit (if limit (prefix-numeric-value limit)
7003 gnus-refer-thread-limit)))
7004 ;; We want to fetch LIMIT *old* headers, but we also have to
7005 ;; re-fetch all the headers in the current buffer, because many of
7006 ;; them may be undisplayed. So we adjust LIMIT.
7007 (when (numberp limit)
7008 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7009 (unless (eq gnus-fetch-old-headers 'invisible)
7010 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7011 ;; Retrieve the headers and read them in.
7012 (if (eq (gnus-retrieve-headers
7013 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7015 (gnus-build-all-threads)
7016 (error "Can't fetch thread from backends that don't support NOV"))
7017 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7018 (gnus-summary-limit-include-thread id)))
7020 (defun gnus-summary-refer-article (message-id)
7021 "Fetch an article specified by MESSAGE-ID."
7022 (interactive "sMessage-ID: ")
7023 (when (and (stringp message-id)
7024 (not (zerop (length message-id))))
7025 ;; Construct the correct Message-ID if necessary.
7026 ;; Suggested by tale@pawl.rpi.edu.
7027 (unless (string-match "^<" message-id)
7028 (setq message-id (concat "<" message-id)))
7029 (unless (string-match ">$" message-id)
7030 (setq message-id (concat message-id ">")))
7031 (let* ((header (gnus-id-to-header message-id))
7033 (gnus-summary-article-sparse-p
7034 (mail-header-number header))
7035 (memq (mail-header-number header)
7036 gnus-newsgroup-limit)))
7039 ;; If the article is present in the buffer we just go to it.
7041 (or (not (gnus-summary-article-sparse-p
7042 (mail-header-number header)))
7045 (gnus-summary-goto-article
7046 (mail-header-number header) nil t)
7048 (gnus-summary-update-article (mail-header-number header)))))
7050 ;; We fetch the article.
7052 (dolist (gnus-override-method (gnus-refer-article-methods))
7053 (gnus-check-server gnus-override-method)
7054 ;; Fetch the header, and display the article.
7055 (when (setq number (gnus-summary-insert-subject message-id))
7056 (gnus-summary-select-article nil nil nil number)
7058 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7060 (defun gnus-refer-article-methods ()
7061 "Return a list of referrable methods."
7063 ;; No method, so we default to current and native.
7064 ((null gnus-refer-article-method)
7065 (list gnus-current-select-method gnus-select-method))
7067 ((eq 'current gnus-refer-article-method)
7068 (list gnus-current-select-method))
7069 ;; List of select methods.
7070 ((not (and (symbolp (car gnus-refer-article-method))
7071 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7073 (dolist (method gnus-refer-article-method)
7074 (push (if (eq 'current method)
7075 gnus-current-select-method
7079 ;; One single select method.
7081 (list gnus-refer-article-method))))
7083 (defun gnus-summary-edit-parameters ()
7084 "Edit the group parameters of the current group."
7086 (gnus-group-edit-group gnus-newsgroup-name 'params))
7088 (defun gnus-summary-customize-parameters ()
7089 "Customize the group parameters of the current group."
7091 (gnus-group-customize gnus-newsgroup-name))
7093 (defun gnus-summary-enter-digest-group (&optional force)
7094 "Enter an nndoc group based on the current article.
7095 If FORCE, force a digest interpretation. If not, try
7096 to guess what the document format is."
7098 (let ((conf gnus-current-window-configuration))
7100 (gnus-summary-select-article))
7101 (setq gnus-current-window-configuration conf)
7102 (let* ((name (format "%s-%d"
7103 (gnus-group-prefixed-name
7104 gnus-newsgroup-name (list 'nndoc ""))
7106 (set-buffer gnus-summary-buffer)
7107 gnus-current-article)))
7108 (ogroup gnus-newsgroup-name)
7109 (params (append (gnus-info-params (gnus-get-info ogroup))
7110 (list (cons 'to-group ogroup))
7111 (list (cons 'save-article-group ogroup))))
7112 (case-fold-search t)
7113 (buf (current-buffer))
7116 (set-buffer gnus-original-article-buffer)
7117 ;; Have the digest group inherit the main mail address of
7118 ;; the parent article.
7119 (when (setq to-address (or (message-fetch-field "reply-to")
7120 (message-fetch-field "from")))
7121 (setq params (append
7122 (list (cons 'to-address
7123 (funcall gnus-decode-encoded-word-function
7125 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7126 (insert-buffer-substring gnus-original-article-buffer)
7127 ;; Remove lines that may lead nndoc to misinterpret the
7130 (goto-char (point-min))
7131 (or (search-forward "\n\n" nil t) (point)))
7132 (goto-char (point-min))
7133 (delete-matching-lines "^Path:\\|^From ")
7136 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7137 (gnus-newsgroup-ephemeral-ignored-charsets
7138 gnus-newsgroup-ignored-charsets))
7139 (gnus-group-read-ephemeral-group
7140 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7142 ,(if force 'mbox 'guess))) t))
7143 ;; Make all postings to this group go to the parent group.
7144 (nconc (gnus-info-params (gnus-get-info name))
7146 ;; Couldn't select this doc group.
7147 (switch-to-buffer buf)
7148 (gnus-set-global-variables)
7149 (gnus-configure-windows 'summary)
7150 (gnus-message 3 "Article couldn't be entered?"))
7151 (kill-buffer dig)))))
7153 (defun gnus-summary-read-document (n)
7154 "Open a new group based on the current article(s).
7155 This will allow you to read digests and other similar
7156 documents as newsgroups.
7157 Obeys the standard process/prefix convention."
7159 (let* ((articles (gnus-summary-work-articles n))
7160 (ogroup gnus-newsgroup-name)
7161 (params (append (gnus-info-params (gnus-get-info ogroup))
7162 (list (cons 'to-group ogroup))))
7163 article group egroup groups vgroup)
7164 (while (setq article (pop articles))
7165 (setq group (format "%s-%d" gnus-newsgroup-name article))
7166 (gnus-summary-remove-process-mark article)
7167 (when (gnus-summary-display-article article)
7170 (insert-buffer-substring gnus-original-article-buffer)
7171 ;; Remove some headers that may lead nndoc to make
7173 (message-narrow-to-head)
7174 (goto-char (point-min))
7175 (delete-matching-lines "^\\(Path\\):\\|^From ")
7178 (gnus-group-read-ephemeral-group
7179 group `(nndoc ,group (nndoc-address ,(current-buffer))
7180 (nndoc-article-type guess))
7183 ;; Make all postings to this group go to the parent group.
7184 (nconc (gnus-info-params (gnus-get-info egroup))
7186 (push egroup groups))
7187 ;; Couldn't select this doc group.
7188 (gnus-error 3 "Article couldn't be entered"))))))
7189 ;; Now we have selected all the documents.
7192 (error "None of the articles could be interpreted as documents"))
7193 ((gnus-group-read-ephemeral-group
7194 (setq vgroup (format
7195 "nnvirtual:%s-%s" gnus-newsgroup-name
7196 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7197 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7199 (cons (current-buffer) 'summary)))
7201 (error "Couldn't select virtual nndoc group")))))
7203 (defun gnus-summary-isearch-article (&optional regexp-p)
7204 "Do incremental search forward on the current article.
7205 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7207 (gnus-summary-select-article)
7208 (gnus-configure-windows 'article)
7209 (gnus-eval-in-buffer-window gnus-article-buffer
7212 (isearch-forward regexp-p))))
7214 (defun gnus-summary-search-article-forward (regexp &optional backward)
7215 "Search for an article containing REGEXP forward.
7216 If BACKWARD, search backward instead."
7219 (format "Search article %s (regexp%s): "
7220 (if current-prefix-arg "backward" "forward")
7221 (if gnus-last-search-regexp
7222 (concat ", default " gnus-last-search-regexp)
7224 current-prefix-arg))
7225 (if (string-equal regexp "")
7226 (setq regexp (or gnus-last-search-regexp ""))
7227 (setq gnus-last-search-regexp regexp)
7228 (setq gnus-article-before-search gnus-current-article))
7229 ;; Intentionally set gnus-last-article.
7230 (setq gnus-last-article gnus-article-before-search)
7231 (let ((gnus-last-article gnus-last-article))
7232 (if (gnus-summary-search-article regexp backward)
7233 (gnus-summary-show-thread)
7234 (error "Search failed: \"%s\"" regexp))))
7236 (defun gnus-summary-search-article-backward (regexp)
7237 "Search for an article containing REGEXP backward."
7240 (format "Search article backward (regexp%s): "
7241 (if gnus-last-search-regexp
7242 (concat ", default " gnus-last-search-regexp)
7244 (gnus-summary-search-article-forward regexp 'backward))
7246 (defun gnus-summary-search-article (regexp &optional backward)
7247 "Search for an article containing REGEXP.
7248 Optional argument BACKWARD means do search for backward.
7249 `gnus-select-article-hook' is not called during the search."
7250 ;; We have to require this here to make sure that the following
7251 ;; dynamic binding isn't shadowed by autoloading.
7252 (require 'gnus-async)
7254 (let ((gnus-select-article-hook nil) ;Disable hook.
7255 (gnus-article-prepare-hook nil)
7256 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7257 (gnus-use-article-prefetch nil)
7258 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7259 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7260 (sum (current-buffer))
7261 (gnus-display-mime-function nil)
7264 (gnus-save-hidden-threads
7265 (gnus-summary-select-article)
7266 (set-buffer gnus-article-buffer)
7267 (goto-char (window-point (get-buffer-window (current-buffer))))
7271 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7273 (re-search-backward regexp nil t)
7274 (re-search-forward regexp nil t))
7275 ;; We found the regexp.
7280 (get-buffer-window (current-buffer))
7284 (get-buffer-window (current-buffer))
7287 (setq point (point)))
7288 ;; We didn't find it, so we go to the next article.
7291 (while (eq found 'not)
7292 (if (not (if backward (gnus-summary-find-prev)
7293 (gnus-summary-find-next)))
7294 ;; No more articles.
7296 ;; Select the next article and adjust point.
7297 (unless (gnus-summary-article-sparse-p
7298 (gnus-summary-article-number))
7300 (gnus-summary-select-article)
7301 (set-buffer gnus-article-buffer)
7303 (goto-char (if backward (point-max) (point-min))))))))
7304 (gnus-message 7 ""))
7305 ;; Return whether we found the regexp.
7306 (when (eq found 'found)
7308 (gnus-summary-show-thread)
7309 (gnus-summary-goto-subject gnus-current-article)
7310 (gnus-summary-position-point)
7313 (defun gnus-summary-find-matching (header regexp &optional backward unread
7315 "Return a list of all articles that match REGEXP on HEADER.
7316 The search stars on the current article and goes forwards unless
7317 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7318 If UNREAD is non-nil, only unread articles will
7319 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7320 in the comparisons."
7321 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7322 (gnus-data-find-list
7323 (gnus-summary-article-number) (gnus-data-list backward))))
7324 (case-fold-search (not not-case-fold))
7327 (if (eq (car header) 'extra)
7330 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7332 (error "%s is an invalid header" header))
7333 (unless (fboundp (intern (concat "mail-header-" header)))
7334 (error "%s is not a valid header" header))
7335 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7338 (and (or (not unread) ; We want all articles...
7339 (gnus-data-unread-p d)) ; Or just unreads.
7340 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7341 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7342 (push (gnus-data-number d) articles)) ; Success!
7343 (setq data (cdr data)))
7344 (nreverse articles)))
7346 (defun gnus-summary-execute-command (header regexp command &optional backward)
7347 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7348 If HEADER is an empty string (or nil), the match is done on the entire
7349 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7351 (list (let ((completion-ignore-case t))
7354 (mapcar (lambda (string) (list string))
7355 '("Number" "Subject" "From" "Lines" "Date"
7356 "Message-ID" "Xref" "References" "Body"))
7357 nil 'require-match))
7358 (read-string "Regexp: ")
7359 (read-key-sequence "Command: ")
7360 current-prefix-arg))
7361 (when (equal header "Body")
7363 ;; Hidden thread subtrees must be searched as well.
7364 (gnus-summary-show-all-threads)
7365 ;; We don't want to change current point nor window configuration.
7367 (save-window-excursion
7368 (gnus-message 6 "Executing %s..." (key-description command))
7369 ;; We'd like to execute COMMAND interactively so as to give arguments.
7370 (gnus-execute header regexp
7371 `(call-interactively ',(key-binding command))
7373 (gnus-message 6 "Executing %s...done" (key-description command)))))
7375 (defun gnus-summary-beginning-of-article ()
7376 "Scroll the article back to the beginning."
7378 (gnus-summary-select-article)
7379 (gnus-configure-windows 'article)
7380 (gnus-eval-in-buffer-window gnus-article-buffer
7382 (goto-char (point-min))
7383 (when gnus-page-broken
7384 (gnus-narrow-to-page))))
7386 (defun gnus-summary-end-of-article ()
7387 "Scroll to the end of the article."
7389 (gnus-summary-select-article)
7390 (gnus-configure-windows 'article)
7391 (gnus-eval-in-buffer-window gnus-article-buffer
7393 (goto-char (point-max))
7395 (when gnus-page-broken
7396 (gnus-narrow-to-page))))
7398 (defun gnus-summary-print-article (&optional filename n)
7399 "Generate and print a PostScript image of the N next (mail) articles.
7401 If N is negative, print the N previous articles. If N is nil and articles
7402 have been marked with the process mark, print these instead.
7404 If the optional first argument FILENAME is nil, send the image to the
7405 printer. If FILENAME is a string, save the PostScript image in a file with
7406 that name. If FILENAME is a number, prompt the user for the name of the file
7408 (interactive (list (ps-print-preprint current-prefix-arg)))
7409 (dolist (article (gnus-summary-work-articles n))
7410 (gnus-summary-select-article nil nil 'pseudo article)
7411 (gnus-eval-in-buffer-window gnus-article-buffer
7412 (let ((buffer (generate-new-buffer " *print*")))
7415 (copy-to-buffer buffer (point-min) (point-max))
7417 (gnus-article-delete-invisible-text)
7418 (let ((ps-left-header
7421 (mail-header-subject gnus-current-headers) ")")
7423 (mail-header-from gnus-current-headers) ")")))
7426 "/pagenumberstring load"
7428 (mail-header-date gnus-current-headers) ")"))))
7429 (gnus-run-hooks 'gnus-ps-print-hook)
7431 (ps-spool-buffer-with-faces))))
7432 (kill-buffer buffer)))))
7433 (ps-despool filename))
7435 (defun gnus-summary-show-article (&optional arg)
7436 "Force re-fetching of the current article.
7437 If ARG (the prefix) is a number, show the article with the charset
7438 defined in `gnus-summary-show-article-charset-alist', or the charset
7440 If ARG (the prefix) is non-nil and not a number, show the raw article
7441 without any article massaging functions being run."
7445 (let ((gnus-newsgroup-charset
7446 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7447 (read-coding-system "Charset: ")))
7448 (gnus-newsgroup-ignored-charsets 'gnus-all))
7449 (gnus-summary-select-article nil 'force)
7450 (let ((deps gnus-newsgroup-dependencies)
7453 (set-buffer gnus-original-article-buffer)
7455 (message-narrow-to-head)
7456 (setq head (buffer-string)))
7458 (insert (format "211 %d Article retrieved.\n"
7459 (cdr gnus-article-current)))
7462 (let ((nntp-server-buffer (current-buffer)))
7463 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7464 (gnus-data-set-header
7465 (gnus-data-find (cdr gnus-article-current))
7467 (gnus-summary-update-article-line
7468 (cdr gnus-article-current) header))))
7470 ;; Select the article the normal way.
7471 (gnus-summary-select-article nil 'force))
7473 ;; We have to require this here to make sure that the following
7474 ;; dynamic binding isn't shadowed by autoloading.
7475 (require 'gnus-async)
7477 ;; Bind the article treatment functions to nil.
7478 (let ((gnus-have-all-headers t)
7479 gnus-article-prepare-hook
7480 gnus-article-decode-hook
7481 gnus-display-mime-function
7483 ;; Destroy any MIME parts.
7484 (when (gnus-buffer-live-p gnus-article-buffer)
7486 (set-buffer gnus-article-buffer)
7487 (mm-destroy-parts gnus-article-mime-handles)
7488 ;; Set it to nil for safety reason.
7489 (setq gnus-article-mime-handle-alist nil)
7490 (setq gnus-article-mime-handles nil)))
7491 (gnus-summary-select-article nil 'force))))
7492 (gnus-summary-goto-subject gnus-current-article)
7493 (gnus-summary-position-point))
7495 (defun gnus-summary-verbose-headers (&optional arg)
7496 "Toggle permanent full header display.
7497 If ARG is a positive number, turn header display on.
7498 If ARG is a negative number, turn header display off."
7500 (setq gnus-show-all-headers
7501 (cond ((or (not (numberp arg))
7503 (not gnus-show-all-headers))
7506 (gnus-summary-show-article))
7508 (defun gnus-summary-toggle-header (&optional arg)
7509 "Show the headers if they are hidden, or hide them if they are shown.
7510 If ARG is a positive number, show the entire header.
7511 If ARG is a negative number, hide the unwanted header lines."
7514 (set-buffer gnus-article-buffer)
7516 (let* ((buffer-read-only nil)
7517 (inhibit-point-motion-hooks t)
7523 (article-narrow-to-head)
7524 (gnus-article-hidden-text-p 'headers))))
7525 (goto-char (point-min))
7526 (when (search-forward "\n\n" nil t)
7527 (delete-region (point-min) (1- (point))))
7528 (goto-char (point-min))
7530 (set-buffer gnus-original-article-buffer)
7531 (goto-char (point-min))
7532 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7533 (insert-buffer-substring gnus-original-article-buffer 1 e)
7535 (narrow-to-region (point-min) (point))
7536 (article-decode-encoded-words)
7538 (let ((gnus-treat-hide-headers nil)
7539 (gnus-treat-hide-boring-headers nil))
7540 (setq gnus-article-wash-types
7541 (delq 'headers gnus-article-wash-types))
7542 (gnus-treat-article 'head))
7543 (gnus-treat-article 'head)))
7544 (gnus-set-mode-line 'article)))))
7546 (defun gnus-summary-show-all-headers ()
7547 "Make all header lines visible."
7549 (gnus-article-show-all-headers))
7551 (defun gnus-summary-caesar-message (&optional arg)
7552 "Caesar rotate the current article by 13.
7553 The numerical prefix specifies how many places to rotate each letter
7556 (gnus-summary-select-article)
7557 (let ((mail-header-separator ""))
7558 (gnus-eval-in-buffer-window gnus-article-buffer
7561 (let ((start (window-start))
7563 (message-caesar-buffer-body arg)
7564 (set-window-start (get-buffer-window (current-buffer)) start))))))
7566 (defun gnus-summary-stop-page-breaking ()
7567 "Stop page breaking in the current article."
7569 (gnus-summary-select-article)
7570 (gnus-eval-in-buffer-window gnus-article-buffer
7572 (when (gnus-visual-p 'page-marker)
7573 (let ((buffer-read-only nil))
7574 (gnus-remove-text-with-property 'gnus-prev)
7575 (gnus-remove-text-with-property 'gnus-next))
7576 (setq gnus-page-broken nil))))
7578 (defun gnus-summary-move-article (&optional n to-newsgroup
7579 select-method action)
7580 "Move the current article to a different newsgroup.
7581 If N is a positive number, move the N next articles.
7582 If N is a negative number, move the N previous articles.
7583 If N is nil and any articles have been marked with the process mark,
7584 move those articles instead.
7585 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7586 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7587 re-spool using this method.
7589 For this function to work, both the current newsgroup and the
7590 newsgroup that you want to move to have to support the `request-move'
7591 and `request-accept' functions.
7593 ACTION can be either `move' (the default), `crosspost' or `copy'."
7596 (setq action 'move))
7597 ;; Disable marking as read.
7598 (let (gnus-mark-article-hook)
7599 (save-window-excursion
7600 (gnus-summary-select-article)))
7601 ;; Check whether the source group supports the required functions.
7602 (cond ((and (eq action 'move)
7603 (not (gnus-check-backend-function
7604 'request-move-article gnus-newsgroup-name)))
7605 (error "The current group does not support article moving"))
7606 ((and (eq action 'crosspost)
7607 (not (gnus-check-backend-function
7608 'request-replace-article gnus-newsgroup-name)))
7609 (error "The current group does not support article editing")))
7610 (let ((articles (gnus-summary-work-articles n))
7611 (prefix (if (gnus-check-backend-function
7612 'request-move-article gnus-newsgroup-name)
7613 (gnus-group-real-prefix gnus-newsgroup-name)
7615 (names '((move "Move" "Moving")
7616 (copy "Copy" "Copying")
7617 (crosspost "Crosspost" "Crossposting")))
7618 (copy-buf (save-excursion
7619 (nnheader-set-temp-buffer " *copy article*")))
7620 art-group to-method new-xref article to-groups)
7621 (unless (assq action names)
7622 (error "Unknown action %s" action))
7623 ;; Read the newsgroup name.
7624 (when (and (not to-newsgroup)
7625 (not select-method))
7627 (gnus-read-move-group-name
7628 (cadr (assq action names))
7629 (symbol-value (intern (format "gnus-current-%s-group" action)))
7631 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7632 (setq to-method (or select-method
7633 (gnus-server-to-method
7634 (gnus-group-method to-newsgroup))))
7635 ;; Check the method we are to move this article to...
7636 (unless (gnus-check-backend-function
7637 'request-accept-article (car to-method))
7638 (error "%s does not support article copying" (car to-method)))
7639 (unless (gnus-check-server to-method)
7640 (error "Can't open server %s" (car to-method)))
7641 (gnus-message 6 "%s to %s: %s..."
7642 (caddr (assq action names))
7643 (or (car select-method) to-newsgroup) articles)
7645 (setq article (pop articles))
7649 ;; Move the article.
7651 ;; Remove this article from future suppression.
7652 (gnus-dup-unsuppress-article article)
7653 (gnus-request-move-article
7654 article ; Article to move
7655 gnus-newsgroup-name ; From newsgroup
7656 (nth 1 (gnus-find-method-for-group
7657 gnus-newsgroup-name)) ; Server
7658 (list 'gnus-request-accept-article
7659 to-newsgroup (list 'quote select-method)
7660 (not articles) t) ; Accept form
7661 (not articles))) ; Only save nov last time
7662 ;; Copy the article.
7665 (set-buffer copy-buf)
7666 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7667 (gnus-request-accept-article
7668 to-newsgroup select-method (not articles) t))))
7669 ;; Crosspost the article.
7670 ((eq action 'crosspost)
7671 (let ((xref (message-tokenize-header
7672 (mail-header-xref (gnus-summary-article-header article))
7674 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7677 (setq xref (list (system-name))))
7680 (mapconcat 'identity
7681 (delete "Xref:" (delete new-xref xref))
7685 (set-buffer copy-buf)
7686 ;; First put the article in the destination group.
7687 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7688 (when (consp (setq art-group
7689 (gnus-request-accept-article
7690 to-newsgroup select-method (not articles))))
7691 (setq new-xref (concat new-xref " " (car art-group)
7692 ":" (cdr art-group)))
7693 ;; Now we have the new Xrefs header, so we insert
7694 ;; it and replace the new article.
7695 (nnheader-replace-header "Xref" new-xref)
7696 (gnus-request-replace-article
7697 (cdr art-group) to-newsgroup (current-buffer))
7701 (gnus-message 1 "Couldn't %s article %s: %s"
7702 (cadr (assq action names)) article
7703 (nnheader-get-report (car to-method))))
7704 ((eq art-group 'junk)
7705 (when (eq action 'move)
7706 (gnus-summary-mark-article article gnus-canceled-mark)
7707 (gnus-message 4 "Deleted article %s" article)))
7709 (let* ((pto-group (gnus-group-prefixed-name
7710 (car art-group) to-method))
7712 (gnus-gethash pto-group gnus-newsrc-hashtb))
7713 (info (nth 2 entry))
7714 (to-group (gnus-info-group info))
7716 ;; Update the group that has been moved to.
7718 (memq action '(move copy)))
7719 (unless (member to-group to-groups)
7720 (push to-group to-groups))
7722 (unless (memq article gnus-newsgroup-unreads)
7723 (push 'read to-marks)
7725 info (gnus-add-to-range (gnus-info-read info)
7726 (list (cdr art-group)))))
7728 ;; See whether the article is to be put in the cache.
7729 (let ((marks gnus-article-mark-lists)
7730 (to-article (cdr art-group)))
7732 ;; Enter the article into the cache in the new group,
7733 ;; if that is required.
7734 (when gnus-use-cache
7735 (gnus-cache-possibly-enter-article
7737 (memq article gnus-newsgroup-marked)
7738 (memq article gnus-newsgroup-dormant)
7739 (memq article gnus-newsgroup-unreads)))
7741 (when gnus-preserve-marks
7742 ;; Copy any marks over to the new group.
7743 (when (and (equal to-group gnus-newsgroup-name)
7744 (not (memq article gnus-newsgroup-unreads)))
7745 ;; Mark this article as read in this group.
7746 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7747 (setcdr (gnus-active to-group) to-article)
7748 (setcdr gnus-newsgroup-active to-article))
7751 (when (memq article (symbol-value
7752 (intern (format "gnus-newsgroup-%s"
7754 (push (cdar marks) to-marks)
7755 ;; If the other group is the same as this group,
7756 ;; then we have to add the mark to the list.
7757 (when (equal to-group gnus-newsgroup-name)
7758 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7761 (intern (format "gnus-newsgroup-%s"
7763 ;; Copy the marks to other group.
7764 (gnus-add-marked-articles
7765 to-group (cdar marks) (list to-article) info))
7766 (setq marks (cdr marks)))
7768 (gnus-request-set-mark to-group (list (list (list to-article)
7773 (concat "(gnus-group-set-info '"
7774 (gnus-prin1-to-string (gnus-get-info to-group))
7777 ;; Update the Xref header in this article to point to
7778 ;; the new crossposted article we have just created.
7779 (when (eq action 'crosspost)
7781 (set-buffer copy-buf)
7782 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7783 (nnheader-replace-header "Xref" new-xref)
7784 (gnus-request-replace-article
7785 article gnus-newsgroup-name (current-buffer)))))
7787 ;;;!!!Why is this necessary?
7788 (set-buffer gnus-summary-buffer)
7790 (gnus-summary-goto-subject article)
7791 (when (eq action 'move)
7792 (gnus-summary-mark-article article gnus-canceled-mark))))
7793 (gnus-summary-remove-process-mark article))
7794 ;; Re-activate all groups that have been moved to.
7797 (set-buffer gnus-group-buffer)
7798 (when (gnus-group-goto-group (car to-groups) t)
7799 (gnus-group-get-new-news-this-group 1 t))
7802 (gnus-kill-buffer copy-buf)
7803 (gnus-summary-position-point)
7804 (gnus-set-mode-line 'summary)))
7806 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7807 "Move the current article to a different newsgroup.
7808 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7809 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7810 re-spool using this method."
7812 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7814 (defun gnus-summary-crosspost-article (&optional n)
7815 "Crosspost the current article to some other group."
7817 (gnus-summary-move-article n nil nil 'crosspost))
7819 (defcustom gnus-summary-respool-default-method nil
7820 "Default method for respooling an article.
7821 If nil, use to the current newsgroup method."
7822 :type '(choice (gnus-select-method :value (nnml ""))
7824 :group 'gnus-summary-mail)
7826 (defun gnus-summary-respool-article (&optional n method)
7827 "Respool the current article.
7828 The article will be squeezed through the mail spooling process again,
7829 which means that it will be put in some mail newsgroup or other
7830 depending on `nnmail-split-methods'.
7831 If N is a positive number, respool the N next articles.
7832 If N is a negative number, respool the N previous articles.
7833 If N is nil and any articles have been marked with the process mark,
7834 respool those articles instead.
7836 Respooling can be done both from mail groups and \"real\" newsgroups.
7837 In the former case, the articles in question will be moved from the
7838 current group into whatever groups they are destined to. In the
7839 latter case, they will be copied into the relevant groups."
7841 (list current-prefix-arg
7842 (let* ((methods (gnus-methods-using 'respool))
7844 (symbol-name (or gnus-summary-respool-default-method
7845 (car (gnus-find-method-for-group
7846 gnus-newsgroup-name)))))
7848 (gnus-completing-read
7849 methname "What backend do you want to use when respooling?"
7850 methods nil t nil 'gnus-mail-method-history))
7853 ((zerop (length (setq ms (gnus-servers-using-backend
7855 (list (intern method) ""))
7859 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7860 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7863 (error "No method given for respooling"))
7864 (if (assoc (symbol-name
7865 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7866 (gnus-methods-using 'respool))
7867 (gnus-summary-move-article n nil method)
7868 (gnus-summary-copy-article n nil method)))
7870 (defun gnus-summary-import-article (file)
7871 "Import an arbitrary file into a mail newsgroup."
7872 (interactive "fImport file: ")
7873 (let ((group gnus-newsgroup-name)
7874 (now (current-time))
7876 (unless (gnus-check-backend-function 'request-accept-article group)
7877 (error "%s does not support article importing" group))
7878 (or (file-readable-p file)
7879 (not (file-regular-p file))
7880 (error "Can't read %s" file))
7882 (set-buffer (gnus-get-buffer-create " *import file*"))
7884 (nnheader-insert-file-contents file)
7885 (goto-char (point-min))
7886 (unless (nnheader-article-p)
7887 ;; This doesn't look like an article, so we fudge some headers.
7888 (setq atts (file-attributes file)
7889 lines (count-lines (point-min) (point-max)))
7890 (insert "From: " (read-string "From: ") "\n"
7891 "Subject: " (read-string "Subject: ") "\n"
7892 "Date: " (message-make-date (nth 5 atts))
7894 "Message-ID: " (message-make-message-id) "\n"
7895 "Lines: " (int-to-string lines) "\n"
7896 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7897 (gnus-request-accept-article group nil t)
7898 (kill-buffer (current-buffer)))))
7900 (defun gnus-summary-article-posted-p ()
7901 "Say whether the current (mail) article is available from news as well.
7902 This will be the case if the article has both been mailed and posted."
7904 (let ((id (mail-header-references (gnus-summary-article-header)))
7905 (gnus-override-method (car (gnus-refer-article-methods))))
7906 (if (gnus-request-head id "")
7907 (gnus-message 2 "The current message was found on %s"
7908 gnus-override-method)
7909 (gnus-message 2 "The current message couldn't be found on %s"
7910 gnus-override-method)
7913 (defun gnus-summary-expire-articles (&optional now)
7914 "Expire all articles that are marked as expirable in the current group."
7916 (when (gnus-check-backend-function
7917 'request-expire-articles gnus-newsgroup-name)
7918 ;; This backend supports expiry.
7919 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7920 (expirable (if total
7922 ;; We need to update the info for
7923 ;; this group for `gnus-list-of-read-articles'
7924 ;; to give us the right answer.
7925 (gnus-run-hooks 'gnus-exit-group-hook)
7926 (gnus-summary-update-info)
7927 (gnus-list-of-read-articles gnus-newsgroup-name))
7928 (setq gnus-newsgroup-expirable
7929 (sort gnus-newsgroup-expirable '<))))
7930 (expiry-wait (if now 'immediate
7931 (gnus-group-find-parameter
7932 gnus-newsgroup-name 'expiry-wait)))
7933 (nnmail-expiry-target
7934 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7935 nnmail-expiry-target))
7938 ;; There are expirable articles in this group, so we run them
7939 ;; through the expiry process.
7940 (gnus-message 6 "Expiring articles...")
7941 (unless (gnus-check-group gnus-newsgroup-name)
7942 (error "Can't open server for %s" gnus-newsgroup-name))
7943 ;; The list of articles that weren't expired is returned.
7946 (let ((nnmail-expiry-wait-function nil)
7947 (nnmail-expiry-wait expiry-wait))
7948 (setq es (gnus-request-expire-articles
7949 expirable gnus-newsgroup-name)))
7950 (setq es (gnus-request-expire-articles
7951 expirable gnus-newsgroup-name)))
7953 (setq gnus-newsgroup-expirable es))
7954 ;; We go through the old list of expirable, and mark all
7955 ;; really expired articles as nonexistent.
7956 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7957 (let ((gnus-use-cache nil))
7959 (unless (memq (car expirable) es)
7960 (when (gnus-data-find (car expirable))
7961 (gnus-summary-mark-article
7962 (car expirable) gnus-canceled-mark)))
7963 (setq expirable (cdr expirable))))))
7964 (gnus-message 6 "Expiring articles...done")))))
7966 (defun gnus-summary-expire-articles-now ()
7967 "Expunge all expirable articles in the current group.
7968 This means that *all* articles that are marked as expirable will be
7969 deleted forever, right now."
7971 (or gnus-expert-user
7973 "Are you really, really, really sure you want to delete all these messages? ")
7975 (gnus-summary-expire-articles t))
7977 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7978 (defun gnus-summary-delete-article (&optional n)
7979 "Delete the N next (mail) articles.
7980 This command actually deletes articles. This is not a marking
7981 command. The article will disappear forever from your life, never to
7983 If N is negative, delete backwards.
7984 If N is nil and articles have been marked with the process mark,
7985 delete these instead."
7987 (unless (gnus-check-backend-function 'request-expire-articles
7988 gnus-newsgroup-name)
7989 (error "The current newsgroup does not support article deletion"))
7990 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7991 (error "Couldn't open server"))
7992 ;; Compute the list of articles to delete.
7993 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7995 (if (and gnus-novice-user
7996 (not (gnus-yes-or-no-p
7997 (format "Do you really want to delete %s forever? "
7998 (if (> (length articles) 1)
7999 (format "these %s articles" (length articles))
8002 ;; Delete the articles.
8003 (setq not-deleted (gnus-request-expire-articles
8004 articles gnus-newsgroup-name 'force))
8006 (gnus-summary-remove-process-mark (car articles))
8007 ;; The backend might not have been able to delete the article
8009 (unless (memq (car articles) not-deleted)
8010 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8011 (setq articles (cdr articles)))
8013 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8014 (gnus-summary-position-point)
8015 (gnus-set-mode-line 'summary)
8018 (defun gnus-summary-edit-article (&optional arg)
8019 "Edit the current article.
8020 This will have permanent effect only in mail groups.
8021 If ARG is nil, edit the decoded articles.
8022 If ARG is 1, edit the raw articles.
8023 If ARG is 2, edit the raw articles even in read-only groups.
8024 If ARG is 3, edit the articles with the current handles.
8025 Otherwise, allow editing of articles even in read-only
8028 (let (force raw current-handles)
8031 ((eq arg 1) (setq raw t))
8032 ((eq arg 2) (setq raw t
8034 ((eq arg 3) (setq current-handles
8035 (and (gnus-buffer-live-p gnus-article-buffer)
8036 (with-current-buffer gnus-article-buffer
8038 gnus-article-mime-handles
8039 (setq gnus-article-mime-handles nil))))))
8041 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8042 (error "Can't edit the raw article in group nndraft:drafts."))
8044 (set-buffer gnus-summary-buffer)
8045 (let ((mail-parse-charset gnus-newsgroup-charset)
8046 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8047 (gnus-set-global-variables)
8048 (when (and (not force)
8049 (gnus-group-read-only-p))
8050 (error "The current newsgroup does not support article editing"))
8051 (gnus-summary-show-article t)
8052 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8053 (with-current-buffer gnus-article-buffer
8054 (mm-enable-multibyte-mule4)))
8055 (if (equal gnus-newsgroup-name "nndraft:drafts")
8057 (gnus-article-edit-article
8060 (let ((mbl mml-buffer-list))
8061 (setq mml-buffer-list nil)
8062 (mime-to-mml ,'current-handles)
8063 (make-local-hook 'kill-buffer-hook)
8064 (let ((mbl1 mml-buffer-list))
8065 (setq mml-buffer-list mbl)
8066 (set (make-local-variable 'mml-buffer-list) mbl1))
8067 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8068 `(lambda (no-highlight)
8069 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8070 (message-options message-options)
8071 (message-options-set-recipient)
8072 (mail-parse-ignored-charsets
8073 ',gnus-newsgroup-ignored-charsets))
8074 ,(if (not raw) '(progn
8076 (mml-destroy-buffers)
8077 (remove-hook 'kill-buffer-hook
8078 'mml-destroy-buffers t)
8079 (kill-local-variable 'mml-buffer-list)))
8080 (gnus-summary-edit-article-done
8081 ,(or (mail-header-references gnus-current-headers) "")
8082 ,(gnus-group-read-only-p)
8083 ,gnus-summary-buffer no-highlight))))))))
8085 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8087 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8089 "Make edits to the current article permanent."
8092 ;; The buffer restriction contains the entire article if it exists.
8093 (when (article-goto-body)
8094 (let ((lines (count-lines (point) (point-max)))
8095 (length (- (point-max) (point)))
8096 (case-fold-search t)
8097 (body (copy-marker (point))))
8098 (goto-char (point-min))
8099 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8100 (delete-region (match-beginning 1) (match-end 1))
8101 (insert (number-to-string length)))
8102 (goto-char (point-min))
8103 (when (re-search-forward
8104 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8105 (delete-region (match-beginning 1) (match-end 1))
8106 (insert (number-to-string length)))
8107 (goto-char (point-min))
8108 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8109 (delete-region (match-beginning 1) (match-end 1))
8110 (insert (number-to-string lines))))))
8111 ;; Replace the article.
8112 (let ((buf (current-buffer)))
8114 (insert-buffer-substring buf)
8116 (if (and (not read-only)
8117 (not (gnus-request-replace-article
8118 (cdr gnus-article-current) (car gnus-article-current)
8119 (current-buffer) t)))
8120 (error "Couldn't replace article")
8121 ;; Update the summary buffer.
8123 (equal (message-tokenize-header references " ")
8124 (message-tokenize-header
8125 (or (message-fetch-field "references") "") " ")))
8126 ;; We only have to update this line.
8129 (message-narrow-to-head)
8130 (let ((head (buffer-string))
8133 (insert (format "211 %d Article retrieved.\n"
8134 (cdr gnus-article-current)))
8137 (let ((nntp-server-buffer (current-buffer)))
8138 (setq header (car (gnus-get-newsgroup-headers
8140 (set-buffer gnus-summary-buffer)
8141 gnus-newsgroup-dependencies)
8144 (set-buffer gnus-summary-buffer)
8145 (gnus-data-set-header
8146 (gnus-data-find (cdr gnus-article-current))
8148 (gnus-summary-update-article-line
8149 (cdr gnus-article-current) header))))))
8151 (set-buffer (or buffer gnus-summary-buffer))
8152 (gnus-summary-update-article (cdr gnus-article-current)))
8153 ;; Prettify the article buffer again.
8154 (unless no-highlight
8156 (set-buffer gnus-article-buffer)
8157 ;;;!!! Fix this -- article should be rehighlighted.
8158 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8159 (set-buffer gnus-original-article-buffer)
8160 (gnus-request-article
8161 (cdr gnus-article-current)
8162 (car gnus-article-current) (current-buffer))))
8163 ;; Prettify the summary buffer line.
8164 (when (gnus-visual-p 'summary-highlight 'highlight)
8165 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8167 (defun gnus-summary-edit-wash (key)
8168 "Perform editing command KEY in the article buffer."
8172 (message "%s" (concat (this-command-keys) "- "))
8175 (gnus-summary-edit-article)
8176 (execute-kbd-macro (concat (this-command-keys) key))
8177 (gnus-article-edit-done))
8181 (defun gnus-summary-respool-query (&optional silent trace)
8182 "Query where the respool algorithm would put this article."
8184 (let (gnus-mark-article-hook)
8185 (gnus-summary-select-article)
8187 (set-buffer gnus-original-article-buffer)
8189 (message-narrow-to-head)
8190 (let ((groups (nnmail-article-group 'identity trace)))
8193 (message "This message would go to %s"
8194 (mapconcat 'car groups ", "))
8195 (message "This message would go to no groups"))
8198 (defun gnus-summary-respool-trace ()
8199 "Trace where the respool algorithm would put this article.
8200 Display a buffer showing all fancy splitting patterns which matched."
8202 (gnus-summary-respool-query nil t))
8204 ;; Summary marking commands.
8206 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8207 "Mark articles which has the same subject as read, and then select the next.
8208 If UNMARK is positive, remove any kind of mark.
8209 If UNMARK is negative, tick articles."
8212 (setq unmark (prefix-numeric-value unmark)))
8214 (gnus-summary-mark-same-subject
8215 (gnus-summary-article-subject) unmark)))
8216 ;; Select next unread article. If auto-select-same mode, should
8217 ;; select the first unread article.
8218 (gnus-summary-next-article t (and gnus-auto-select-same
8219 (gnus-summary-article-subject)))
8220 (gnus-message 7 "%d article%s marked as %s"
8221 count (if (= count 1) " is" "s are")
8222 (if unmark "unread" "read"))))
8224 (defun gnus-summary-kill-same-subject (&optional unmark)
8225 "Mark articles which has the same subject as read.
8226 If UNMARK is positive, remove any kind of mark.
8227 If UNMARK is negative, tick articles."
8230 (setq unmark (prefix-numeric-value unmark)))
8232 (gnus-summary-mark-same-subject
8233 (gnus-summary-article-subject) unmark)))
8234 ;; If marked as read, go to next unread subject.
8236 ;; Go to next unread subject.
8237 (gnus-summary-next-subject 1 t))
8238 (gnus-message 7 "%d articles are marked as %s"
8239 count (if unmark "unread" "read"))))
8241 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8242 "Mark articles with same SUBJECT as read, and return marked number.
8243 If optional argument UNMARK is positive, remove any kinds of marks.
8244 If optional argument UNMARK is negative, mark articles as unread instead."
8248 ((null unmark) ; Mark as read.
8251 (gnus-summary-mark-article-as-read gnus-killed-mark)
8252 (gnus-summary-show-thread) t)
8253 (gnus-summary-find-subject subject))
8254 (setq count (1+ count))))
8255 ((> unmark 0) ; Tick.
8258 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8259 (gnus-summary-show-thread) t)
8260 (gnus-summary-find-subject subject))
8261 (setq count (1+ count))))
8262 (t ; Mark as unread.
8265 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8266 (gnus-summary-show-thread) t)
8267 (gnus-summary-find-subject subject))
8268 (setq count (1+ count)))))
8269 (gnus-set-mode-line 'summary)
8270 ;; Return the number of marked articles.
8273 (defun gnus-summary-mark-as-processable (n &optional unmark)
8274 "Set the process mark on the next N articles.
8275 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8276 the process mark instead. The difference between N and the actual
8277 number of articles marked is returned."
8279 (let ((backward (< n 0))
8284 (gnus-summary-remove-process-mark
8285 (gnus-summary-article-number))
8286 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8287 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8290 (gnus-message 7 "No more articles"))
8291 (gnus-summary-recenter)
8292 (gnus-summary-position-point)
8295 (defun gnus-summary-unmark-as-processable (n)
8296 "Remove the process mark from the next N articles.
8297 If N is negative, unmark backward instead. The difference between N and
8298 the actual number of articles unmarked is returned."
8300 (gnus-summary-mark-as-processable n t))
8302 (defun gnus-summary-unmark-all-processable ()
8303 "Remove the process mark from all articles."
8306 (while gnus-newsgroup-processable
8307 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8308 (gnus-summary-position-point))
8310 (defun gnus-summary-add-mark (article type)
8311 "Mark ARTICLE with a mark of TYPE."
8312 (let ((vtype (car (assq type gnus-article-mark-lists)))
8315 (error "No such mark type: %s" type)
8316 (setq var (intern (format "gnus-newsgroup-%s" type)))
8317 (set var (cons article (symbol-value var)))
8318 (if (memq type '(processable cached replied saved))
8319 (gnus-summary-update-secondary-mark article)
8320 ;;; !!! This is bobus. We should find out what primary
8321 ;;; !!! mark we want to set.
8322 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8324 (defun gnus-summary-mark-as-expirable (n)
8325 "Mark N articles forward as expirable.
8326 If N is negative, mark backward instead. The difference between N and
8327 the actual number of articles marked is returned."
8329 (gnus-summary-mark-forward n gnus-expirable-mark))
8331 (defun gnus-summary-mark-article-as-replied (article)
8332 "Mark ARTICLE replied and update the summary line."
8333 (push article gnus-newsgroup-replied)
8334 (let ((buffer-read-only nil))
8335 (when (gnus-summary-goto-subject article nil t)
8336 (gnus-summary-update-secondary-mark article))))
8338 (defun gnus-summary-set-bookmark (article)
8339 "Set a bookmark in current article."
8340 (interactive (list (gnus-summary-article-number)))
8341 (when (or (not (get-buffer gnus-article-buffer))
8342 (not gnus-current-article)
8343 (not gnus-article-current)
8344 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8345 (error "No current article selected"))
8346 ;; Remove old bookmark, if one exists.
8347 (let ((old (assq article gnus-newsgroup-bookmarks)))
8349 (setq gnus-newsgroup-bookmarks
8350 (delq old gnus-newsgroup-bookmarks))))
8351 ;; Set the new bookmark, which is on the form
8352 ;; (article-number . line-number-in-body).
8356 (set-buffer gnus-article-buffer)
8360 (goto-char (point-min))
8361 (search-forward "\n\n" nil t)
8364 gnus-newsgroup-bookmarks)
8365 (gnus-message 6 "A bookmark has been added to the current article."))
8367 (defun gnus-summary-remove-bookmark (article)
8368 "Remove the bookmark from the current article."
8369 (interactive (list (gnus-summary-article-number)))
8370 ;; Remove old bookmark, if one exists.
8371 (let ((old (assq article gnus-newsgroup-bookmarks)))
8374 (setq gnus-newsgroup-bookmarks
8375 (delq old gnus-newsgroup-bookmarks))
8376 (gnus-message 6 "Removed bookmark."))
8377 (gnus-message 6 "No bookmark in current article."))))
8379 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8380 (defun gnus-summary-mark-as-dormant (n)
8381 "Mark N articles forward as dormant.
8382 If N is negative, mark backward instead. The difference between N and
8383 the actual number of articles marked is returned."
8385 (gnus-summary-mark-forward n gnus-dormant-mark))
8387 (defun gnus-summary-set-process-mark (article)
8388 "Set the process mark on ARTICLE and update the summary line."
8389 (setq gnus-newsgroup-processable
8391 (delq article gnus-newsgroup-processable)))
8392 (when (gnus-summary-goto-subject article)
8393 (gnus-summary-show-thread)
8394 (gnus-summary-goto-subject article)
8395 (gnus-summary-update-secondary-mark article)))
8397 (defun gnus-summary-remove-process-mark (article)
8398 "Remove the process mark from ARTICLE and update the summary line."
8399 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8400 (when (gnus-summary-goto-subject article)
8401 (gnus-summary-show-thread)
8402 (gnus-summary-goto-subject article)
8403 (gnus-summary-update-secondary-mark article)))
8405 (defun gnus-summary-set-saved-mark (article)
8406 "Set the process mark on ARTICLE and update the summary line."
8407 (push article gnus-newsgroup-saved)
8408 (when (gnus-summary-goto-subject article)
8409 (gnus-summary-update-secondary-mark article)))
8411 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8412 "Mark N articles as read forwards.
8413 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8414 The difference between N and the actual number of articles marked is
8416 Iff NO-EXPIRE, auto-expiry will be inhibited."
8418 (gnus-summary-show-thread)
8419 (let ((backward (< n 0))
8420 (gnus-summary-goto-unread
8421 (and gnus-summary-goto-unread
8422 (not (eq gnus-summary-goto-unread 'never))
8423 (not (memq mark (list gnus-unread-mark
8424 gnus-ticked-mark gnus-dormant-mark)))))
8426 (mark (or mark gnus-del-mark)))
8428 (gnus-summary-mark-article nil mark no-expire)
8429 (zerop (gnus-summary-next-subject
8431 (and gnus-summary-goto-unread
8432 (not (eq gnus-summary-goto-unread 'never)))
8436 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8437 (gnus-summary-recenter)
8438 (gnus-summary-position-point)
8439 (gnus-set-mode-line 'summary)
8442 (defun gnus-summary-mark-article-as-read (mark)
8443 "Mark the current article quickly as read with MARK."
8444 (let ((article (gnus-summary-article-number)))
8445 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8446 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8447 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8448 (push (cons article mark) gnus-newsgroup-reads)
8449 ;; Possibly remove from cache, if that is used.
8450 (when gnus-use-cache
8451 (gnus-cache-enter-remove-article article))
8452 ;; Allow the backend to change the mark.
8453 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8454 ;; Check for auto-expiry.
8455 (when (and gnus-newsgroup-auto-expire
8456 (memq mark gnus-auto-expirable-marks))
8457 (setq mark gnus-expirable-mark)
8458 ;; Let the backend know about the mark change.
8459 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8460 (push article gnus-newsgroup-expirable))
8461 ;; Set the mark in the buffer.
8462 (gnus-summary-update-mark mark 'unread)
8465 (defun gnus-summary-mark-article-as-unread (mark)
8466 "Mark the current article quickly as unread with MARK."
8467 (let* ((article (gnus-summary-article-number))
8468 (old-mark (gnus-summary-article-mark article)))
8469 ;; Allow the backend to change the mark.
8470 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8471 (if (eq mark old-mark)
8475 (gnus-error 1 "Can't mark negative article numbers")
8477 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8478 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8479 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8480 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8481 (cond ((= mark gnus-ticked-mark)
8482 (push article gnus-newsgroup-marked))
8483 ((= mark gnus-dormant-mark)
8484 (push article gnus-newsgroup-dormant))
8486 (push article gnus-newsgroup-unreads)))
8487 (gnus-pull article gnus-newsgroup-reads)
8489 ;; See whether the article is to be put in the cache.
8491 (vectorp (gnus-summary-article-header article))
8493 (gnus-cache-possibly-enter-article
8494 gnus-newsgroup-name article
8495 (= mark gnus-ticked-mark)
8496 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8499 (gnus-summary-update-mark mark 'unread)
8502 (defun gnus-summary-mark-article (&optional article mark no-expire)
8503 "Mark ARTICLE with MARK. MARK can be any character.
8504 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8505 `??' (dormant) and `?E' (expirable).
8506 If MARK is nil, then the default character `?r' is used.
8507 If ARTICLE is nil, then the article on the current line will be
8509 Iff NO-EXPIRE, auto-expiry will be inhibited."
8510 ;; The mark might be a string.
8511 (when (stringp mark)
8512 (setq mark (aref mark 0)))
8513 ;; If no mark is given, then we check auto-expiring.
8515 (setq mark gnus-del-mark))
8516 (when (and (not no-expire)
8517 gnus-newsgroup-auto-expire
8518 (memq mark gnus-auto-expirable-marks))
8519 (setq mark gnus-expirable-mark))
8520 (let ((article (or article (gnus-summary-article-number)))
8521 (old-mark (gnus-summary-article-mark article)))
8522 ;; Allow the backend to change the mark.
8523 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8524 (if (eq mark old-mark)
8527 (error "No article on current line"))
8528 (if (not (if (or (= mark gnus-unread-mark)
8529 (= mark gnus-ticked-mark)
8530 (= mark gnus-dormant-mark))
8531 (gnus-mark-article-as-unread article mark)
8532 (gnus-mark-article-as-read article mark)))
8534 ;; See whether the article is to be put in the cache.
8536 (not (= mark gnus-canceled-mark))
8537 (vectorp (gnus-summary-article-header article))
8539 (gnus-cache-possibly-enter-article
8540 gnus-newsgroup-name article
8541 (= mark gnus-ticked-mark)
8542 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8544 (when (gnus-summary-goto-subject article nil t)
8545 (let ((buffer-read-only nil))
8546 (gnus-summary-show-thread)
8548 (gnus-summary-update-mark mark 'unread)
8551 (defun gnus-summary-update-secondary-mark (article)
8552 "Update the secondary (read, process, cache) mark."
8553 (gnus-summary-update-mark
8554 (cond ((memq article gnus-newsgroup-processable)
8556 ((memq article gnus-newsgroup-cached)
8558 ((memq article gnus-newsgroup-replied)
8560 ((memq article gnus-newsgroup-saved)
8564 (when (gnus-visual-p 'summary-highlight 'highlight)
8565 (gnus-run-hooks 'gnus-summary-update-hook))
8568 (defun gnus-summary-update-mark (mark type)
8569 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8570 (buffer-read-only nil))
8571 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8573 (when (looking-at "\r")
8575 (when (<= (+ forward (point)) (point-max))
8576 ;; Go to the right position on the line.
8577 (goto-char (+ forward (point)))
8578 ;; Replace the old mark with the new mark.
8579 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8580 ;; Optionally update the marks by some user rule.
8581 (when (eq type 'unread)
8583 (gnus-data-find (gnus-summary-article-number)) mark)
8584 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8586 (defun gnus-mark-article-as-read (article &optional mark)
8587 "Enter ARTICLE in the pertinent lists and remove it from others."
8588 ;; Make the article expirable.
8589 (let ((mark (or mark gnus-del-mark)))
8590 (if (= mark gnus-expirable-mark)
8591 (push article gnus-newsgroup-expirable)
8592 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8593 ;; Remove from unread and marked lists.
8594 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8595 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8596 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8597 (push (cons article mark) gnus-newsgroup-reads)
8598 ;; Possibly remove from cache, if that is used.
8599 (when gnus-use-cache
8600 (gnus-cache-enter-remove-article article))
8603 (defun gnus-mark-article-as-unread (article &optional mark)
8604 "Enter ARTICLE in the pertinent lists and remove it from others."
8605 (let ((mark (or mark gnus-ticked-mark)))
8608 (gnus-error 1 "Can't mark negative article numbers")
8610 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8611 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8612 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8613 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8615 ;; Unsuppress duplicates?
8616 (when gnus-suppress-duplicates
8617 (gnus-dup-unsuppress-article article))
8619 (cond ((= mark gnus-ticked-mark)
8620 (push article gnus-newsgroup-marked))
8621 ((= mark gnus-dormant-mark)
8622 (push article gnus-newsgroup-dormant))
8624 (push article gnus-newsgroup-unreads)))
8625 (gnus-pull article gnus-newsgroup-reads)
8628 (defalias 'gnus-summary-mark-as-unread-forward
8629 'gnus-summary-tick-article-forward)
8630 (make-obsolete 'gnus-summary-mark-as-unread-forward
8631 'gnus-summary-tick-article-forward)
8632 (defun gnus-summary-tick-article-forward (n)
8633 "Tick N articles forwards.
8634 If N is negative, tick backwards instead.
8635 The difference between N and the number of articles ticked is returned."
8637 (gnus-summary-mark-forward n gnus-ticked-mark))
8639 (defalias 'gnus-summary-mark-as-unread-backward
8640 'gnus-summary-tick-article-backward)
8641 (make-obsolete 'gnus-summary-mark-as-unread-backward
8642 'gnus-summary-tick-article-backward)
8643 (defun gnus-summary-tick-article-backward (n)
8644 "Tick N articles backwards.
8645 The difference between N and the number of articles ticked is returned."
8647 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8649 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8650 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8651 (defun gnus-summary-tick-article (&optional article clear-mark)
8652 "Mark current article as unread.
8653 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8654 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8656 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8659 (defun gnus-summary-mark-as-read-forward (n)
8660 "Mark N articles as read forwards.
8661 If N is negative, mark backwards instead.
8662 The difference between N and the actual number of articles marked is
8665 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8667 (defun gnus-summary-mark-as-read-backward (n)
8668 "Mark the N articles as read backwards.
8669 The difference between N and the actual number of articles marked is
8672 (gnus-summary-mark-forward
8673 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8675 (defun gnus-summary-mark-as-read (&optional article mark)
8676 "Mark current article as read.
8677 ARTICLE specifies the article to be marked as read.
8678 MARK specifies a string to be inserted at the beginning of the line."
8679 (gnus-summary-mark-article article mark))
8681 (defun gnus-summary-clear-mark-forward (n)
8682 "Clear marks from N articles forward.
8683 If N is negative, clear backward instead.
8684 The difference between N and the number of marks cleared is returned."
8686 (gnus-summary-mark-forward n gnus-unread-mark))
8688 (defun gnus-summary-clear-mark-backward (n)
8689 "Clear marks from N articles backward.
8690 The difference between N and the number of marks cleared is returned."
8692 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8694 (defun gnus-summary-mark-unread-as-read ()
8695 "Intended to be used by `gnus-summary-mark-article-hook'."
8696 (when (memq gnus-current-article gnus-newsgroup-unreads)
8697 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8699 (defun gnus-summary-mark-read-and-unread-as-read ()
8700 "Intended to be used by `gnus-summary-mark-article-hook'."
8701 (let ((mark (gnus-summary-article-mark)))
8702 (when (or (gnus-unread-mark-p mark)
8703 (gnus-read-mark-p mark))
8704 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8706 (defun gnus-summary-mark-unread-as-ticked ()
8707 "Intended to be used by `gnus-summary-mark-article-hook'."
8708 (when (memq gnus-current-article gnus-newsgroup-unreads)
8709 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8711 (defun gnus-summary-mark-region-as-read (point mark all)
8712 "Mark all unread articles between point and mark as read.
8713 If given a prefix, mark all articles between point and mark as read,
8714 even ticked and dormant ones."
8715 (interactive "r\nP")
8724 (memq (setq article (gnus-summary-article-number))
8725 gnus-newsgroup-unreads))
8726 (gnus-summary-mark-article article gnus-del-mark))
8728 (gnus-summary-find-next))))))
8730 (defun gnus-summary-mark-below (score mark)
8731 "Mark articles with score less than SCORE with MARK."
8732 (interactive "P\ncMark: ")
8733 (setq score (if score
8734 (prefix-numeric-value score)
8735 (or gnus-summary-default-score 0)))
8737 (set-buffer gnus-summary-buffer)
8738 (goto-char (point-min))
8741 (and (< (gnus-summary-article-score) score)
8742 (gnus-summary-mark-article nil mark))
8743 (gnus-summary-find-next)))))
8745 (defun gnus-summary-kill-below (&optional score)
8746 "Mark articles with score below SCORE as read."
8748 (gnus-summary-mark-below score gnus-killed-mark))
8750 (defun gnus-summary-clear-above (&optional score)
8751 "Clear all marks from articles with score above SCORE."
8753 (gnus-summary-mark-above score gnus-unread-mark))
8755 (defun gnus-summary-tick-above (&optional score)
8756 "Tick all articles with score above SCORE."
8758 (gnus-summary-mark-above score gnus-ticked-mark))
8760 (defun gnus-summary-mark-above (score mark)
8761 "Mark articles with score over SCORE with MARK."
8762 (interactive "P\ncMark: ")
8763 (setq score (if score
8764 (prefix-numeric-value score)
8765 (or gnus-summary-default-score 0)))
8767 (set-buffer gnus-summary-buffer)
8768 (goto-char (point-min))
8770 (when (> (gnus-summary-article-score) score)
8771 (gnus-summary-mark-article nil mark))
8773 (gnus-summary-find-next)))))
8775 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8776 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8777 (defun gnus-summary-limit-include-expunged (&optional no-error)
8778 "Display all the hidden articles that were expunged for low scores."
8780 (let ((buffer-read-only nil))
8781 (let ((scored gnus-newsgroup-scored)
8784 (unless (gnus-number-to-header (caar scored))
8785 (and (setq h (gnus-summary-article-header (caar scored)))
8786 (< (cdar scored) gnus-summary-expunge-below)
8788 (setq scored (cdr scored)))
8790 (when (not no-error)
8791 (error "No expunged articles hidden"))
8792 (goto-char (point-min))
8793 (gnus-summary-prepare-unthreaded (nreverse headers))
8794 (goto-char (point-min))
8795 (gnus-summary-position-point)
8798 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8799 "Mark all unread articles in this newsgroup as read.
8800 If prefix argument ALL is non-nil, ticked and dormant articles will
8801 also be marked as read.
8802 If QUIETLY is non-nil, no questions will be asked.
8803 If TO-HERE is non-nil, it should be a point in the buffer. All
8804 articles before this point will be marked as read.
8805 Note that this function will only catch up the unread article
8806 in the current summary buffer limitation.
8807 The number of articles marked as read is returned."
8812 (not gnus-interactive-catchup) ;Without confirmation?
8816 "Mark absolutely all articles as read? "
8817 "Mark all unread articles as read? ")))
8819 (not gnus-newsgroup-adaptive)
8820 (not gnus-newsgroup-auto-expire)
8821 (not gnus-suppress-duplicates)
8822 (or (not gnus-use-cache)
8823 (eq gnus-use-cache 'passive)))
8826 (setq gnus-newsgroup-marked nil
8827 gnus-newsgroup-dormant nil))
8828 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8829 ;; We actually mark all articles as canceled, which we
8830 ;; have to do when using auto-expiry or adaptive scoring.
8831 (gnus-summary-show-all-threads)
8832 (when (gnus-summary-first-subject (not all) t)
8834 (if to-here (< (point) to-here) t)
8835 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8836 (gnus-summary-find-next (not all) nil nil t))))
8837 (gnus-set-mode-line 'summary))
8839 (gnus-summary-position-point)))
8841 (defun gnus-summary-catchup-to-here (&optional all)
8842 "Mark all unticked articles before the current one as read.
8843 If ALL is non-nil, also mark ticked and dormant articles as read."
8846 (gnus-save-hidden-threads
8847 (let ((beg (point)))
8848 ;; We check that there are unread articles.
8849 (when (or all (gnus-summary-find-prev))
8850 (gnus-summary-catchup all t beg)))))
8851 (gnus-summary-position-point))
8853 (defun gnus-summary-catchup-all (&optional quietly)
8854 "Mark all articles in this newsgroup as read."
8856 (gnus-summary-catchup t quietly))
8858 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8859 "Mark all unread articles in this group as read, then exit.
8860 If prefix argument ALL is non-nil, all articles are marked as read."
8862 (when (gnus-summary-catchup all quietly nil 'fast)
8863 ;; Select next newsgroup or exit.
8864 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8865 (eq gnus-auto-select-next 'quietly))
8866 (gnus-summary-next-group nil)
8867 (gnus-summary-exit))))
8869 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8870 "Mark all articles in this newsgroup as read, and then exit."
8872 (gnus-summary-catchup-and-exit t quietly))
8874 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8875 "Mark all articles in this group as read and select the next group.
8876 If given a prefix, mark all articles, unread as well as ticked, as
8880 (gnus-summary-catchup all))
8881 (gnus-summary-next-group))
8887 (defmacro gnus-with-article (article &rest forms)
8888 "Select ARTICLE and perform FORMS in the original article buffer.
8889 Then replace the article with the result."
8891 ;; We don't want the article to be marked as read.
8892 (let (gnus-mark-article-hook)
8893 (gnus-summary-select-article t t nil ,article))
8894 (set-buffer gnus-original-article-buffer)
8896 (if (not (gnus-check-backend-function
8897 'request-replace-article (car gnus-article-current)))
8898 (gnus-message 5 "Read-only group; not replacing")
8899 (unless (gnus-request-replace-article
8900 ,article (car gnus-article-current)
8902 (error "Couldn't replace article")))
8903 ;; The cache and backlog have to be flushed somewhat.
8904 (when gnus-keep-backlog
8905 (gnus-backlog-remove-article
8906 (car gnus-article-current) (cdr gnus-article-current)))
8907 (when gnus-use-cache
8908 (gnus-cache-update-article
8909 (car gnus-article-current) (cdr gnus-article-current)))))
8911 (put 'gnus-with-article 'lisp-indent-function 1)
8912 (put 'gnus-with-article 'edebug-form-spec '(form body))
8914 ;; Thread-based commands.
8916 (defun gnus-summary-articles-in-thread (&optional article)
8917 "Return a list of all articles in the current thread.
8918 If ARTICLE is non-nil, return all articles in the thread that starts
8920 (let* ((article (or article (gnus-summary-article-number)))
8921 (data (gnus-data-find-list article))
8922 (top-level (gnus-data-level (car data)))
8924 (cond ((null gnus-thread-operation-ignore-subject)
8925 (gnus-simplify-subject-re
8926 (mail-header-subject (gnus-data-header (car data)))))
8927 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8928 (gnus-simplify-subject-fuzzy
8929 (mail-header-subject (gnus-data-header (car data)))))
8931 (end-point (save-excursion
8932 (if (gnus-summary-go-to-next-thread)
8933 (point) (point-max))))
8936 (< (gnus-data-pos (car data)) end-point))
8937 (when (or (not top-subject)
8938 (string= top-subject
8939 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8940 (gnus-simplify-subject-fuzzy
8941 (mail-header-subject
8942 (gnus-data-header (car data))))
8943 (gnus-simplify-subject-re
8944 (mail-header-subject
8945 (gnus-data-header (car data)))))))
8946 (push (gnus-data-number (car data)) articles))
8947 (unless (and (setq data (cdr data))
8948 (> (gnus-data-level (car data)) top-level))
8950 ;; Return the list of articles.
8951 (nreverse articles)))
8953 (defun gnus-summary-rethread-current ()
8954 "Rethread the thread the current article is part of."
8956 (let* ((gnus-show-threads t)
8957 (article (gnus-summary-article-number))
8958 (id (mail-header-id (gnus-summary-article-header)))
8959 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8961 (error "No article on the current line"))
8962 (gnus-rebuild-thread id)
8963 (gnus-summary-goto-subject article)))
8965 (defun gnus-summary-reparent-thread ()
8966 "Make the current article child of the marked (or previous) article.
8968 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8969 is non-nil or the Subject: of both articles are the same."
8971 (unless (not (gnus-group-read-only-p))
8972 (error "The current newsgroup does not support article editing"))
8973 (unless (<= (length gnus-newsgroup-processable) 1)
8974 (error "No more than one article may be marked"))
8975 (save-window-excursion
8976 (let ((gnus-article-buffer " *reparent*")
8977 (current-article (gnus-summary-article-number))
8978 ;; First grab the marked article, otherwise one line up.
8979 (parent-article (if (not (null gnus-newsgroup-processable))
8980 (car gnus-newsgroup-processable)
8982 (if (eq (forward-line -1) 0)
8983 (gnus-summary-article-number)
8984 (error "Beginning of summary buffer"))))))
8985 (unless (not (eq current-article parent-article))
8986 (error "An article may not be self-referential"))
8987 (let ((message-id (mail-header-id
8988 (gnus-summary-article-header parent-article))))
8989 (unless (and message-id (not (equal message-id "")))
8990 (error "No message-id in desired parent"))
8991 (gnus-with-article current-article
8993 (goto-char (point-min))
8994 (message-narrow-to-head)
8995 (if (re-search-forward "^References: " nil t)
8997 (re-search-forward "^[^ \t]" nil t)
9000 (insert " " message-id))
9001 (insert "References: " message-id "\n"))))
9002 (set-buffer gnus-summary-buffer)
9003 (gnus-summary-unmark-all-processable)
9004 (gnus-summary-update-article current-article)
9005 (gnus-summary-rethread-current)
9006 (gnus-message 3 "Article %d is now the child of article %d"
9007 current-article parent-article)))))
9009 (defun gnus-summary-toggle-threads (&optional arg)
9010 "Toggle showing conversation threads.
9011 If ARG is positive number, turn showing conversation threads on."
9013 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9014 (setq gnus-show-threads
9015 (if (null arg) (not gnus-show-threads)
9016 (> (prefix-numeric-value arg) 0)))
9017 (gnus-summary-prepare)
9018 (gnus-summary-goto-subject current)
9019 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9020 (gnus-summary-position-point)))
9022 (defun gnus-summary-show-all-threads ()
9026 (let ((buffer-read-only nil))
9027 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9028 (gnus-summary-position-point))
9030 (defun gnus-summary-show-thread ()
9031 "Show thread subtrees.
9032 Returns nil if no thread was there to be shown."
9034 (let ((buffer-read-only nil)
9036 ;; first goto end then to beg, to have point at beg after let
9037 (end (progn (end-of-line) (point)))
9038 (beg (progn (beginning-of-line) (point))))
9040 ;; Any hidden lines here?
9041 (search-forward "\r" end t)
9042 (subst-char-in-region beg end ?\^M ?\n t)
9044 (gnus-summary-position-point))))
9046 (defun gnus-summary-hide-all-threads ()
9047 "Hide all thread subtrees."
9050 (goto-char (point-min))
9051 (gnus-summary-hide-thread)
9052 (while (zerop (gnus-summary-next-thread 1 t))
9053 (gnus-summary-hide-thread)))
9054 (gnus-summary-position-point))
9056 (defun gnus-summary-hide-thread ()
9057 "Hide thread subtrees.
9058 Returns nil if no threads were there to be hidden."
9060 (let ((buffer-read-only nil)
9062 (article (gnus-summary-article-number)))
9064 ;; Go forward until either the buffer ends or the subthread
9066 (when (and (not (eobp))
9067 (or (zerop (gnus-summary-next-thread 1 t))
9068 (goto-char (point-max))))
9070 (if (and (> (point) start)
9071 (search-backward "\n" start t))
9073 (subst-char-in-region start (point) ?\n ?\^M)
9074 (gnus-summary-goto-subject article))
9078 (defun gnus-summary-go-to-next-thread (&optional previous)
9079 "Go to the same level (or less) next thread.
9080 If PREVIOUS is non-nil, go to previous thread instead.
9081 Return the article number moved to, or nil if moving was impossible."
9082 (let ((level (gnus-summary-thread-level))
9083 (way (if previous -1 1))
9086 (while (and (not (eobp))
9087 (< level (gnus-summary-thread-level)))
9095 (gnus-summary-article-number)
9098 (defun gnus-summary-next-thread (n &optional silent)
9099 "Go to the same level next N'th thread.
9100 If N is negative, search backward instead.
9101 Returns the difference between N and the number of skips actually
9104 If SILENT, don't output messages."
9106 (let ((backward (< n 0))
9109 (gnus-summary-go-to-next-thread backward))
9112 (gnus-summary-position-point))
9113 (when (and (not silent) (/= 0 n))
9114 (gnus-message 7 "No more threads"))
9117 (defun gnus-summary-prev-thread (n)
9118 "Go to the same level previous N'th thread.
9119 Returns the difference between N and the number of skips actually
9122 (gnus-summary-next-thread (- n)))
9124 (defun gnus-summary-go-down-thread ()
9125 "Go down one level in the current thread."
9126 (let ((children (gnus-summary-article-children)))
9128 (gnus-summary-goto-subject (car children)))))
9130 (defun gnus-summary-go-up-thread ()
9131 "Go up one level in the current thread."
9132 (let ((parent (gnus-summary-article-parent)))
9134 (gnus-summary-goto-subject parent))))
9136 (defun gnus-summary-down-thread (n)
9137 "Go down thread N steps.
9138 If N is negative, go up instead.
9139 Returns the difference between N and how many steps down that were
9145 (if up (gnus-summary-go-up-thread)
9146 (gnus-summary-go-down-thread)))
9148 (gnus-summary-position-point)
9150 (gnus-message 7 "Can't go further"))
9153 (defun gnus-summary-up-thread (n)
9154 "Go up thread N steps.
9155 If N is negative, go up instead.
9156 Returns the difference between N and how many steps down that were
9159 (gnus-summary-down-thread (- n)))
9161 (defun gnus-summary-top-thread ()
9162 "Go to the top of the thread."
9164 (while (gnus-summary-go-up-thread))
9165 (gnus-summary-article-number))
9167 (defun gnus-summary-kill-thread (&optional unmark)
9168 "Mark articles under current thread as read.
9169 If the prefix argument is positive, remove any kinds of marks.
9170 If the prefix argument is negative, tick articles instead."
9173 (setq unmark (prefix-numeric-value unmark)))
9174 (let ((articles (gnus-summary-articles-in-thread)))
9176 ;; Expand the thread.
9177 (gnus-summary-show-thread)
9178 ;; Mark all the articles.
9180 (gnus-summary-goto-subject (car articles))
9181 (cond ((null unmark)
9182 (gnus-summary-mark-article-as-read gnus-killed-mark))
9184 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9186 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9187 (setq articles (cdr articles))))
9188 ;; Hide killed subtrees.
9190 gnus-thread-hide-killed
9191 (gnus-summary-hide-thread))
9192 ;; If marked as read, go to next unread subject.
9194 ;; Go to next unread subject.
9195 (gnus-summary-next-subject 1 t)))
9196 (gnus-set-mode-line 'summary))
9198 ;; Summary sorting commands
9200 (defun gnus-summary-sort-by-number (&optional reverse)
9201 "Sort the summary buffer by article number.
9202 Argument REVERSE means reverse order."
9204 (gnus-summary-sort 'number reverse))
9206 (defun gnus-summary-sort-by-author (&optional reverse)
9207 "Sort the summary buffer by author name alphabetically.
9208 If `case-fold-search' is non-nil, case of letters is ignored.
9209 Argument REVERSE means reverse order."
9211 (gnus-summary-sort 'author reverse))
9213 (defun gnus-summary-sort-by-subject (&optional reverse)
9214 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9215 If `case-fold-search' is non-nil, case of letters is ignored.
9216 Argument REVERSE means reverse order."
9218 (gnus-summary-sort 'subject reverse))
9220 (defun gnus-summary-sort-by-date (&optional reverse)
9221 "Sort the summary buffer by date.
9222 Argument REVERSE means reverse order."
9224 (gnus-summary-sort 'date reverse))
9226 (defun gnus-summary-sort-by-score (&optional reverse)
9227 "Sort the summary buffer by score.
9228 Argument REVERSE means reverse order."
9230 (gnus-summary-sort 'score reverse))
9232 (defun gnus-summary-sort-by-lines (&optional reverse)
9233 "Sort the summary buffer by the number of lines.
9234 Argument REVERSE means reverse order."
9236 (gnus-summary-sort 'lines reverse))
9238 (defun gnus-summary-sort-by-chars (&optional reverse)
9239 "Sort the summary buffer by article length.
9240 Argument REVERSE means reverse order."
9242 (gnus-summary-sort 'chars reverse))
9244 (defun gnus-summary-sort (predicate reverse)
9245 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9246 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9247 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9248 (gnus-thread-sort-functions
9253 (gnus-sort-gathered-threads-function
9254 gnus-thread-sort-functions)
9255 (gnus-article-sort-functions
9261 (gnus-summary-prepare-hook nil))
9262 ;; We do the sorting by regenerating the threads.
9263 (gnus-summary-prepare)
9264 ;; Hide subthreads if needed.
9265 (when (and gnus-show-threads gnus-thread-hide-subtree)
9266 (gnus-summary-hide-all-threads))))
9268 ;; Summary saving commands.
9270 (defun gnus-summary-save-article (&optional n not-saved)
9271 "Save the current article using the default saver function.
9272 If N is a positive number, save the N next articles.
9273 If N is a negative number, save the N previous articles.
9274 If N is nil and any articles have been marked with the process mark,
9275 save those articles instead.
9276 The variable `gnus-default-article-saver' specifies the saver function."
9278 (let* ((articles (gnus-summary-work-articles n))
9279 (save-buffer (save-excursion
9280 (nnheader-set-temp-buffer " *Gnus Save*")))
9281 (num (length articles))
9283 (dolist (article articles)
9284 (setq header (gnus-summary-article-header article))
9285 (if (not (vectorp header))
9286 ;; This is a pseudo-article.
9287 (if (assq 'name header)
9288 (gnus-copy-file (cdr (assq 'name header)))
9289 (gnus-message 1 "Article %d is unsaveable" article))
9290 ;; This is a real article.
9291 (save-window-excursion
9292 (gnus-summary-select-article t nil nil article))
9294 (set-buffer save-buffer)
9296 (insert-buffer-substring gnus-original-article-buffer))
9297 (setq file (gnus-article-save save-buffer file num))
9298 (gnus-summary-remove-process-mark article)
9300 (gnus-summary-set-saved-mark article))))
9301 (gnus-kill-buffer save-buffer)
9302 (gnus-summary-position-point)
9303 (gnus-set-mode-line 'summary)
9306 (defun gnus-summary-pipe-output (&optional arg)
9307 "Pipe the current article to a subprocess.
9308 If N is a positive number, pipe the N next articles.
9309 If N is a negative number, pipe the N previous articles.
9310 If N is nil and any articles have been marked with the process mark,
9311 pipe those articles instead."
9314 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9315 (gnus-summary-save-article arg t))
9316 (gnus-configure-windows 'pipe))
9318 (defun gnus-summary-save-article-mail (&optional arg)
9319 "Append the current article to an mail file.
9320 If N is a positive number, save the N next articles.
9321 If N is a negative number, save the N previous articles.
9322 If N is nil and any articles have been marked with the process mark,
9323 save those articles instead."
9326 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9327 (gnus-summary-save-article arg)))
9329 (defun gnus-summary-save-article-rmail (&optional arg)
9330 "Append the current article to an rmail file.
9331 If N is a positive number, save the N next articles.
9332 If N is a negative number, save the N previous articles.
9333 If N is nil and any articles have been marked with the process mark,
9334 save those articles instead."
9337 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9338 (gnus-summary-save-article arg)))
9340 (defun gnus-summary-save-article-file (&optional arg)
9341 "Append the current article to a file.
9342 If N is a positive number, save the N next articles.
9343 If N is a negative number, save the N previous articles.
9344 If N is nil and any articles have been marked with the process mark,
9345 save those articles instead."
9348 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9349 (gnus-summary-save-article arg)))
9351 (defun gnus-summary-write-article-file (&optional arg)
9352 "Write the current article to a file, deleting the previous file.
9353 If N is a positive number, save the N next articles.
9354 If N is a negative number, save the N previous articles.
9355 If N is nil and any articles have been marked with the process mark,
9356 save those articles instead."
9359 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9360 (gnus-summary-save-article arg)))
9362 (defun gnus-summary-save-article-body-file (&optional arg)
9363 "Append the current article body to a file.
9364 If N is a positive number, save the N next articles.
9365 If N is a negative number, save the N previous articles.
9366 If N is nil and any articles have been marked with the process mark,
9367 save those articles instead."
9370 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9371 (gnus-summary-save-article arg)))
9373 (defun gnus-summary-pipe-message (program)
9374 "Pipe the current article through PROGRAM."
9375 (interactive "sProgram: ")
9376 (gnus-summary-select-article)
9377 (let ((mail-header-separator ""))
9378 (gnus-eval-in-buffer-window gnus-article-buffer
9381 (let ((start (window-start))
9383 (message-pipe-buffer-body program)
9384 (set-window-start (get-buffer-window (current-buffer)) start))))))
9386 (defun gnus-get-split-value (methods)
9387 "Return a value based on the split METHODS."
9388 (let (split-name method result match)
9391 (set-buffer gnus-original-article-buffer)
9393 (nnheader-narrow-to-headers)
9394 (while (and methods (not split-name))
9395 (goto-char (point-min))
9396 (setq method (pop methods))
9397 (setq match (car method))
9400 ;; Regular expression.
9402 (re-search-forward match nil t)))
9403 ((gnus-functionp match)
9407 (setq result (funcall match gnus-newsgroup-name))))
9412 (setq result (eval match)))))
9413 (setq split-name (cdr method))
9414 (cond ((stringp result)
9415 (push (expand-file-name
9416 result gnus-article-save-directory)
9419 (setq split-name (append result split-name)))))))))
9420 (nreverse split-name)))
9422 (defun gnus-valid-move-group-p (group)
9425 (symbol-value group)
9426 (gnus-get-function (gnus-find-method-for-group
9427 (symbol-name group)) 'request-accept-article t)))
9429 (defun gnus-read-move-group-name (prompt default articles prefix)
9430 "Read a group name."
9431 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9432 (minibuffer-confirm-incomplete nil) ; XEmacs
9436 (if (> (length articles) 1)
9437 (format "these %d articles" (length articles))
9442 (gnus-completing-read default prom
9444 'gnus-valid-move-group-p
9446 'gnus-group-history))
9447 ((= 1 (length split-name))
9448 (gnus-completing-read (car split-name) prom
9450 'gnus-valid-move-group-p
9452 'gnus-group-history))
9454 (gnus-completing-read nil prom
9455 (mapcar (lambda (el) (list el))
9456 (nreverse split-name))
9458 'gnus-group-history))))
9459 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9461 (if (or (string= to-newsgroup "")
9462 (string= to-newsgroup prefix))
9463 (setq to-newsgroup default))
9464 (unless to-newsgroup
9465 (error "No group name entered"))
9466 (or (gnus-active to-newsgroup)
9467 (gnus-activate-group to-newsgroup nil nil to-method)
9468 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9470 (or (and (gnus-request-create-group to-newsgroup to-method)
9471 (gnus-activate-group
9472 to-newsgroup nil nil to-method)
9473 (gnus-subscribe-group to-newsgroup))
9474 (error "Couldn't create group %s" to-newsgroup)))
9475 (error "No such group: %s" to-newsgroup)))
9478 (defun gnus-summary-save-parts (type dir n &optional reverse)
9479 "Save parts matching TYPE to DIR.
9480 If REVERSE, save parts that do not match TYPE."
9482 (list (read-string "Save parts of type: "
9483 (or (car gnus-summary-save-parts-type-history)
9484 gnus-summary-save-parts-default-mime)
9485 'gnus-summary-save-parts-type-history)
9486 (setq gnus-summary-save-parts-last-directory
9487 (read-file-name "Save to directory: "
9488 gnus-summary-save-parts-last-directory
9490 current-prefix-arg))
9491 (gnus-summary-iterate n
9492 (let ((gnus-display-mime-function nil)
9493 (gnus-inhibit-treatment t))
9494 (gnus-summary-select-article))
9496 (set-buffer gnus-article-buffer)
9497 (let ((handles (or gnus-article-mime-handles
9498 (mm-dissect-buffer) (mm-uu-dissect))))
9500 (gnus-summary-save-parts-1 type dir handles reverse)
9501 (unless gnus-article-mime-handles ;; Don't destroy this case.
9502 (mm-destroy-parts handles)))))))
9504 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9505 (if (stringp (car handle))
9506 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9509 (not (string-match type (mm-handle-media-type handle)))
9510 (string-match type (mm-handle-media-type handle)))
9511 (let ((file (expand-file-name
9512 (file-name-nondirectory
9514 (mail-content-type-get
9515 (mm-handle-disposition handle) 'filename)
9516 (concat gnus-newsgroup-name
9517 "." (number-to-string
9518 (cdr gnus-article-current)))))
9520 (unless (file-exists-p file)
9521 (mm-save-part-to-file handle file))))))
9523 ;; Summary extract commands
9525 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9526 (let ((buffer-read-only nil)
9527 (article (gnus-summary-article-number))
9529 (unless (gnus-summary-goto-subject article)
9530 (error "No such article: %d" article))
9531 (gnus-summary-position-point)
9532 ;; If all commands are to be bunched up on one line, we collect
9534 (unless gnus-view-pseudos-separately
9535 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9538 (setq action (cdr (assq 'action (car ps))))
9539 (setq files (list (cdr (assq 'name (car ps)))))
9540 (while (and ps (cdr ps)
9541 (string= (or action "1")
9542 (or (cdr (assq 'action (cadr ps))) "2")))
9543 (push (cdr (assq 'name (cadr ps))) files)
9544 (setcdr ps (cddr ps)))
9546 (when (not (string-match "%s" action))
9549 (when (assq 'execute (car ps))
9550 (setcdr (assq 'execute (car ps))
9551 (funcall (if (string-match "%s" action)
9560 (setq ps (cdr ps)))))
9561 (if (and gnus-view-pseudos (not not-view))
9563 (when (assq 'execute (car pslist))
9564 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9565 (eq gnus-view-pseudos 'not-confirm)))
9566 (setq pslist (cdr pslist)))
9569 (setq after-article (or (cdr (assq 'article (car pslist)))
9570 (gnus-summary-article-number)))
9571 (gnus-summary-goto-subject after-article)
9574 (insert " " (file-name-nondirectory
9575 (cdr (assq 'name (car pslist))))
9576 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9578 (forward-line -1) ; back to `b'
9579 (gnus-add-text-properties
9580 b (1- e) (list 'gnus-number gnus-reffed-article-number
9581 gnus-mouse-face-prop gnus-mouse-face))
9583 after-article gnus-reffed-article-number
9584 gnus-unread-mark b (car pslist) 0 (- e b))
9585 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9586 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9587 (setq pslist (cdr pslist)))))))
9589 (defun gnus-pseudos< (p1 p2)
9590 (let ((c1 (cdr (assq 'action p1)))
9591 (c2 (cdr (assq 'action p2))))
9592 (and c1 c2 (string< c1 c2))))
9594 (defun gnus-request-pseudo-article (props)
9595 (cond ((assq 'execute props)
9596 (gnus-execute-command (cdr (assq 'execute props)))))
9597 (let ((gnus-current-article (gnus-summary-article-number)))
9598 (gnus-run-hooks 'gnus-mark-article-hook)))
9600 (defun gnus-execute-command (command &optional automatic)
9602 (gnus-article-setup-buffer)
9603 (set-buffer gnus-article-buffer)
9604 (setq buffer-read-only nil)
9605 (let ((command (if automatic command
9606 (read-string "Command: " (cons command 0)))))
9608 (insert "$ " command "\n\n")
9609 (if gnus-view-pseudo-asynchronously
9610 (start-process "gnus-execute" (current-buffer) shell-file-name
9611 shell-command-switch command)
9612 (call-process shell-file-name nil t nil
9613 shell-command-switch command)))))
9615 ;; Summary kill commands.
9617 (defun gnus-summary-edit-global-kill (article)
9618 "Edit the \"global\" kill file."
9619 (interactive (list (gnus-summary-article-number)))
9620 (gnus-group-edit-global-kill article))
9622 (defun gnus-summary-edit-local-kill ()
9623 "Edit a local kill file applied to the current newsgroup."
9625 (setq gnus-current-headers (gnus-summary-article-header))
9626 (gnus-group-edit-local-kill
9627 (gnus-summary-article-number) gnus-newsgroup-name))
9631 (defun gnus-read-header (id &optional header)
9632 "Read the headers of article ID and enter them into the Gnus system."
9633 (let ((group gnus-newsgroup-name)
9634 (gnus-override-method
9636 gnus-override-method
9637 (and (gnus-news-group-p gnus-newsgroup-name)
9638 (car (gnus-refer-article-methods)))))
9640 ;; First we check to see whether the header in question is already
9643 ;; This is a Message-ID.
9644 (setq header (or header (gnus-id-to-header id)))
9645 ;; This is an article number.
9646 (setq header (or header (gnus-summary-article-header id))))
9648 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9649 ;; We have found the header.
9651 ;; If this is a sparse article, we have to nix out its
9652 ;; previous entry in the thread hashtb.
9654 (gnus-summary-article-sparse-p (mail-header-number header)))
9655 (let* ((parent (gnus-parent-id (mail-header-references header)))
9656 (thread (and parent (gnus-id-to-thread parent))))
9658 (delq (assq header thread) thread))))
9659 ;; We have to really fetch the header to this article.
9661 (set-buffer nntp-server-buffer)
9662 (when (setq where (gnus-request-head id group))
9663 (nnheader-fold-continuation-lines)
9664 (goto-char (point-max))
9666 (goto-char (point-min))
9670 ((cdr where) (cdr where))
9671 (header (mail-header-number header))
9672 (t gnus-reffed-article-number))
9674 (insert " Article retrieved.\n"))
9676 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9677 () ; Malformed head.
9678 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9679 (when (and (stringp id)
9680 (not (string= (gnus-group-real-name group)
9682 ;; If we fetched by Message-ID and the article came
9683 ;; from a different group, we fudge some bogus article
9684 ;; numbers for this article.
9685 (mail-header-set-number header gnus-reffed-article-number))
9687 (set-buffer gnus-summary-buffer)
9688 (decf gnus-reffed-article-number)
9689 (gnus-remove-header (mail-header-number header))
9690 (push header gnus-newsgroup-headers)
9691 (setq gnus-current-headers header)
9692 (push (mail-header-number header) gnus-newsgroup-limit)))
9695 (defun gnus-remove-header (number)
9696 "Remove header NUMBER from `gnus-newsgroup-headers'."
9697 (if (and gnus-newsgroup-headers
9698 (= number (mail-header-number (car gnus-newsgroup-headers))))
9699 (pop gnus-newsgroup-headers)
9700 (let ((headers gnus-newsgroup-headers))
9701 (while (and (cdr headers)
9702 (not (= number (mail-header-number (cadr headers)))))
9705 (setcdr headers (cddr headers))))))
9708 ;;; summary highlights
9711 (defun gnus-highlight-selected-summary ()
9712 "Highlight selected article in summary buffer."
9713 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9714 (when gnus-summary-selected-face
9716 (let* ((beg (progn (beginning-of-line) (point)))
9717 (end (progn (end-of-line) (point)))
9718 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9719 (from (if (get-text-property beg gnus-mouse-face-prop)
9721 (or (next-single-property-change
9722 beg gnus-mouse-face-prop nil end)
9727 (or (next-single-property-change
9728 from gnus-mouse-face-prop nil end)
9730 ;; If no mouse-face prop on line we will have to = from = end,
9731 ;; so we highlight the entire line instead.
9732 (when (= (+ to 2) from)
9735 (if gnus-newsgroup-selected-overlay
9736 ;; Move old overlay.
9738 gnus-newsgroup-selected-overlay from to (current-buffer))
9739 ;; Create new overlay.
9741 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9742 'face gnus-summary-selected-face))))))
9744 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9745 (defun gnus-summary-highlight-line ()
9746 "Highlight current line according to `gnus-summary-highlight'."
9747 (let* ((list gnus-summary-highlight)
9749 (end (progn (end-of-line) (point)))
9750 ;; now find out where the line starts and leave point there.
9751 (beg (progn (beginning-of-line) (point)))
9752 (article (gnus-summary-article-number))
9753 (score (or (cdr (assq (or article gnus-current-article)
9754 gnus-newsgroup-scored))
9755 gnus-summary-default-score 0))
9756 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9757 (inhibit-read-only t))
9758 ;; Eval the cars of the lists until we find a match.
9759 (let ((default gnus-summary-default-score))
9761 (not (eval (caar list))))
9762 (setq list (cdr list))))
9763 (let ((face (cdar list)))
9764 (unless (eq face (get-text-property beg 'face))
9765 (gnus-put-text-property-excluding-characters-with-faces
9767 (setq face (if (boundp face) (symbol-value face) face)))
9768 (when gnus-summary-highlight-line-function
9769 (funcall gnus-summary-highlight-line-function article face))))
9772 (defun gnus-update-read-articles (group unread &optional compute)
9773 "Update the list of read articles in GROUP."
9774 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9775 (entry (gnus-gethash group gnus-newsrc-hashtb))
9776 (info (nth 2 entry))
9778 (unread (sort (copy-sequence unread) '<))
9780 (if (or (not info) (not active))
9781 ;; There is no info on this group if it was, in fact,
9782 ;; killed. Gnus stores no information on killed groups, so
9783 ;; there's nothing to be done.
9784 ;; One could store the information somewhere temporarily,
9785 ;; perhaps... Hmmm...
9787 ;; Remove any negative articles numbers.
9788 (while (and unread (< (car unread) 0))
9789 (setq unread (cdr unread)))
9790 ;; Remove any expired article numbers
9791 (while (and unread (< (car unread) (car active)))
9792 (setq unread (cdr unread)))
9793 ;; Compute the ranges of read articles by looking at the list of
9796 (when (/= (car unread) prev)
9797 (push (if (= prev (1- (car unread))) prev
9798 (cons prev (1- (car unread))))
9800 (setq prev (1+ (car unread)))
9801 (setq unread (cdr unread)))
9802 (when (<= prev (cdr active))
9803 (push (cons prev (cdr active)) read))
9804 (setq read (if (> (length read) 1) (nreverse read) read))
9809 ;; Propagate the read marks to the backend.
9810 (when (gnus-check-backend-function 'request-set-mark group)
9811 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9812 (add (gnus-remove-from-range read (gnus-info-read info))))
9814 (unless (gnus-check-group group)
9815 (error "Can't open server for %s" group))
9816 (gnus-request-set-mark
9817 group (delq nil (list (if add (list add 'add '(read)))
9818 (if del (list del 'del '(read))))))
9820 `(gnus-request-set-mark
9823 (if del (list del 'add '(read)))
9824 (if add (list add 'del '(read))))))))))
9825 (set-buffer gnus-group-buffer)
9828 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9829 (gnus-info-set-read ',info ',(gnus-info-read info))
9830 (gnus-get-unread-articles-in-group ',info
9831 (gnus-active ,group))
9832 (gnus-group-update-group ,group t)
9834 ;; Enter this list into the group info.
9835 (gnus-info-set-read info read)
9836 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9837 (gnus-get-unread-articles-in-group info (gnus-active group))
9840 (defun gnus-offer-save-summaries ()
9841 "Offer to save all active summary buffers."
9843 (let ((buflist (buffer-list))
9845 ;; Go through all buffers and find all summaries.
9847 (and (setq bufname (buffer-name (car buflist)))
9848 (string-match "Summary" bufname)
9850 (set-buffer bufname)
9851 ;; We check that this is, indeed, a summary buffer.
9852 (and (eq major-mode 'gnus-summary-mode)
9853 ;; Also make sure this isn't bogus.
9854 gnus-newsgroup-prepared
9855 ;; Also make sure that this isn't a dead summary buffer.
9856 (not gnus-dead-summary-mode)))
9857 (push bufname buffers))
9858 (setq buflist (cdr buflist)))
9859 ;; Go through all these summary buffers and offer to save them.
9862 "Update summary buffer %s? "
9864 (switch-to-buffer buf)
9865 (gnus-summary-exit))
9868 (defun gnus-summary-setup-default-charset ()
9869 "Setup newsgroup default charset."
9870 (if (equal gnus-newsgroup-name "nndraft:drafts")
9871 (setq gnus-newsgroup-charset nil)
9872 (let* ((name (and gnus-newsgroup-name
9873 (gnus-group-real-name gnus-newsgroup-name)))
9875 (or gnus-newsgroup-ephemeral-ignored-charsets
9877 (and gnus-newsgroup-name
9878 (or (gnus-group-find-parameter gnus-newsgroup-name
9879 'ignored-charsets t)
9880 (let ((alist gnus-group-ignored-charsets-alist)
9881 elem (charsets nil))
9882 (while (setq elem (pop alist))
9884 (string-match (car elem) name))
9886 charsets (cdr elem))))
9888 gnus-newsgroup-ignored-charsets))))
9889 (setq gnus-newsgroup-charset
9890 (or gnus-newsgroup-ephemeral-charset
9891 (and gnus-newsgroup-name
9892 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9893 (let ((alist gnus-group-charset-alist)
9895 (while (setq elem (pop alist))
9897 (string-match (car elem) name))
9899 charset (cadr elem))))
9901 gnus-default-charset))
9902 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9903 ignored-charsets))))
9909 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9910 "Display the current article buffer fully MIME-buttonized.
9911 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9912 treated as multipart/mixed."
9915 (let ((gnus-unbuttonized-mime-types nil)
9916 (gnus-mime-display-multipart-as-mixed show-all-parts))
9917 (gnus-summary-show-article)))
9919 (defun gnus-summary-repair-multipart (article)
9920 "Add a Content-Type header to a multipart article without one."
9921 (interactive (list (gnus-summary-article-number)))
9922 (gnus-with-article article
9923 (message-narrow-to-head)
9924 (message-remove-header "Mime-Version")
9925 (goto-char (point-max))
9926 (insert "Mime-Version: 1.0\n")
9928 (when (search-forward "\n--" nil t)
9929 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9930 (message-narrow-to-head)
9931 (message-remove-header "Content-Type")
9932 (goto-char (point-max))
9933 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9936 (let (gnus-mark-article-hook)
9937 (gnus-summary-select-article t t nil article)))
9939 (defun gnus-summary-toggle-display-buttonized ()
9940 "Toggle the buttonizing of the article buffer."
9943 (if (setq gnus-inhibit-mime-unbuttonizing
9944 (not gnus-inhibit-mime-unbuttonizing))
9945 (let ((gnus-unbuttonized-mime-types nil))
9946 (gnus-summary-show-article))
9947 (gnus-summary-show-article)))
9950 ;;; Generic summary marking commands
9953 (defvar gnus-summary-marking-alist
9954 '((read gnus-del-mark "d")
9955 (unread gnus-unread-mark "u")
9956 (ticked gnus-ticked-mark "!")
9957 (dormant gnus-dormant-mark "?")
9958 (expirable gnus-expirable-mark "e"))
9959 "An alist of names/marks/keystrokes.")
9961 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9962 (defvar gnus-summary-mark-map)
9964 (defun gnus-summary-make-all-marking-commands ()
9965 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9966 (dolist (elem gnus-summary-marking-alist)
9967 (apply 'gnus-summary-make-marking-command elem)))
9969 (defun gnus-summary-make-marking-command (name mark keystroke)
9970 (let ((map (make-sparse-keymap)))
9971 (define-key gnus-summary-generic-mark-map keystroke map)
9972 (dolist (lway `((next "next" next nil "n")
9973 (next-unread "next unread" next t "N")
9974 (prev "previous" prev nil "p")
9975 (prev-unread "previous unread" prev t "P")
9976 (nomove "" nil nil ,keystroke)))
9977 (let ((func (gnus-summary-make-marking-command-1
9978 mark (car lway) lway name)))
9979 (setq func (eval func))
9980 (define-key map (nth 4 lway) func)))))
9982 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9984 (format "gnus-summary-put-mark-as-%s%s"
9985 name (if (eq way 'nomove)
9987 (concat "-" (symbol-name way)))))
9990 "Mark the current article as %s%s.
9991 If N, the prefix, then repeat N times.
9992 If N is negative, move in reverse order.
9993 The difference between N and the actual number of articles marked is
9997 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9999 (defun gnus-summary-generic-mark (n mark move unread)
10000 "Mark N articles with MARK."
10001 (unless (eq major-mode 'gnus-summary-mode)
10002 (error "This command can only be used in the summary buffer"))
10003 (gnus-summary-show-thread)
10006 ((eq move 'next) 1)
10007 ((eq move 'prev) -1)
10009 (if (zerop nummove)
10013 nummove (* -1 nummove))))
10014 (while (and (> n 0)
10015 (gnus-summary-mark-article nil mark)
10016 (zerop (gnus-summary-next-subject nummove unread t)))
10019 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10020 (gnus-summary-recenter)
10021 (gnus-summary-position-point)
10022 (gnus-set-mode-line 'summary)
10025 (gnus-summary-make-all-marking-commands)
10027 (gnus-ems-redefine)
10029 (provide 'gnus-sum)
10031 (run-hooks 'gnus-sum-load-hook)
10033 ;;; gnus-sum.el ends here