1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
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 souped 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-forwarded-mark ?O
424 "*Mark used for articles that have been forwarded."
425 :group 'gnus-summary-marks
428 (defcustom gnus-cached-mark ?*
429 "*Mark used for articles that are in the cache."
430 :group 'gnus-summary-marks
433 (defcustom gnus-saved-mark ?S
434 "*Mark used for articles that have been saved to."
435 :group 'gnus-summary-marks
438 (defcustom gnus-no-mark ? ;Whitespace
439 "*Mark used for articles that have no other secondary mark."
440 :group 'gnus-summary-marks
443 (defcustom gnus-ancient-mark ?O
444 "*Mark used for ancient articles."
445 :group 'gnus-summary-marks
448 (defcustom gnus-sparse-mark ?Q
449 "*Mark used for sparsely reffed articles."
450 :group 'gnus-summary-marks
453 (defcustom gnus-canceled-mark ?G
454 "*Mark used for canceled articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-duplicate-mark ?M
459 "*Mark used for duplicate articles."
460 :group 'gnus-summary-marks
463 (defcustom gnus-undownloaded-mark ?@
464 "*Mark used for articles that weren't downloaded."
465 :group 'gnus-summary-marks
468 (defcustom gnus-downloadable-mark ?%
469 "*Mark used for articles that are to be downloaded."
470 :group 'gnus-summary-marks
473 (defcustom gnus-unsendable-mark ?=
474 "*Mark used for articles that won't be sent."
475 :group 'gnus-summary-marks
478 (defcustom gnus-score-over-mark ?+
479 "*Score mark used for articles with high scores."
480 :group 'gnus-summary-marks
483 (defcustom gnus-score-below-mark ?-
484 "*Score mark used for articles with low scores."
485 :group 'gnus-summary-marks
488 (defcustom gnus-empty-thread-mark ? ;Whitespace
489 "*There is no thread under the article."
490 :group 'gnus-summary-marks
493 (defcustom gnus-not-empty-thread-mark ?=
494 "*There is a thread under the article."
495 :group 'gnus-summary-marks
498 (defcustom gnus-view-pseudo-asynchronously nil
499 "*If non-nil, Gnus will view pseudo-articles asynchronously."
500 :group 'gnus-extract-view
503 (defcustom gnus-auto-expirable-marks
504 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
505 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
506 gnus-souped-mark gnus-duplicate-mark)
507 "*The list of marks converted into expiration if a group is auto-expirable."
510 :type '(repeat character))
512 (defcustom gnus-inhibit-user-auto-expire t
513 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
518 (defcustom gnus-view-pseudos nil
519 "*If `automatic', pseudo-articles will be viewed automatically.
520 If `not-confirm', pseudos will be viewed automatically, and the user
521 will not be asked to confirm the command."
522 :group 'gnus-extract-view
523 :type '(choice (const :tag "off" nil)
525 (const not-confirm)))
527 (defcustom gnus-view-pseudos-separately t
528 "*If non-nil, one pseudo-article will be created for each file to be viewed.
529 If nil, all files that use the same viewing command will be given as a
530 list of parameters to that command."
531 :group 'gnus-extract-view
534 (defcustom gnus-insert-pseudo-articles t
535 "*If non-nil, insert pseudo-articles when decoding articles."
536 :group 'gnus-extract-view
539 (defcustom gnus-summary-dummy-line-format
541 "*The format specification for the dummy roots in the summary buffer.
542 It works along the same lines as a normal formatting string,
543 with some simple extensions.
546 :group 'gnus-threading
549 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
550 "*The format specification for the summary mode line.
551 It works along the same lines as a normal formatting string,
552 with some simple extensions:
555 %p Unprefixed group name
556 %A Current article number
557 %z Current article score
559 %U Number of unread articles in the group
560 %e Number of unselected articles in the group
561 %Z A string with unread/unselected article counts
562 %g Shortish group name
563 %S Subject of the current article
565 %s Current score file name
566 %d Number of dormant articles
567 %r Number of articles that have been marked as read in this session
568 %E Number of articles expunged by the score files"
569 :group 'gnus-summary-format
572 (defcustom gnus-list-identifiers nil
573 "Regexp that matches list identifiers to be removed from subject.
574 This can also be a list of regexps."
576 :group 'gnus-summary-format
577 :group 'gnus-article-hiding
578 :type '(choice (const :tag "none" nil)
580 (repeat :value (".*") regexp)))
582 (defcustom gnus-summary-mark-below 0
583 "*Mark all articles with a score below this variable as read.
584 This variable is local to each summary buffer and usually set by the
586 :group 'gnus-score-default
589 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
590 "*List of functions used for sorting articles in the summary buffer.
592 Each function takes two articles and returns non-nil if the first
593 article should be sorted before the other. If you use more than one
594 function, the primary sort function should be the last. You should
595 probably always include `gnus-article-sort-by-number' in the list of
596 sorting functions -- preferably first. Also note that sorting by date
597 is often much slower than sorting by number, and the sorting order is
598 very similar. (Sorting by date means sorting by the time the message
599 was sent, sorting by number means sorting by arrival time.)
601 Ready-made functions include `gnus-article-sort-by-number',
602 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
603 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
605 When threading is turned on, the variable `gnus-thread-sort-functions'
606 controls how articles are sorted."
607 :group 'gnus-summary-sort
608 :type '(repeat (choice (function-item gnus-article-sort-by-number)
609 (function-item gnus-article-sort-by-author)
610 (function-item gnus-article-sort-by-subject)
611 (function-item gnus-article-sort-by-date)
612 (function-item gnus-article-sort-by-score)
613 (function :tag "other"))))
615 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
616 "*List of functions used for sorting threads in the summary buffer.
617 By default, threads are sorted by article number.
619 Each function takes two threads and returns non-nil if the first
620 thread should be sorted before the other. If you use more than one
621 function, the primary sort function should be the last. You should
622 probably always include `gnus-thread-sort-by-number' in the list of
623 sorting functions -- preferably first. Also note that sorting by date
624 is often much slower than sorting by number, and the sorting order is
625 very similar. (Sorting by date means sorting by the time the message
626 was sent, sorting by number means sorting by arrival time.)
628 Ready-made functions include `gnus-thread-sort-by-number',
629 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
630 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
631 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
633 When threading is turned off, the variable
634 `gnus-article-sort-functions' controls how articles are sorted."
635 :group 'gnus-summary-sort
636 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
637 (function-item gnus-thread-sort-by-author)
638 (function-item gnus-thread-sort-by-subject)
639 (function-item gnus-thread-sort-by-date)
640 (function-item gnus-thread-sort-by-score)
641 (function-item gnus-thread-sort-by-total-score)
642 (function :tag "other"))))
644 (defcustom gnus-thread-score-function '+
645 "*Function used for calculating the total score of a thread.
647 The function is called with the scores of the article and each
648 subthread and should then return the score of the thread.
650 Some functions you can use are `+', `max', or `min'."
651 :group 'gnus-summary-sort
654 (defcustom gnus-summary-expunge-below nil
655 "All articles that have a score less than this variable will be expunged.
656 This variable is local to the summary buffers."
657 :group 'gnus-score-default
658 :type '(choice (const :tag "off" nil)
661 (defcustom gnus-thread-expunge-below nil
662 "All threads that have a total score less than this variable will be expunged.
663 See `gnus-thread-score-function' for en explanation of what a
666 This variable is local to the summary buffers."
667 :group 'gnus-threading
668 :group 'gnus-score-default
669 :type '(choice (const :tag "off" nil)
672 (defcustom gnus-summary-mode-hook nil
673 "*A hook for Gnus summary mode.
674 This hook is run before any variables are set in the summary buffer."
675 :options '(turn-on-gnus-mailing-list-mode)
676 :group 'gnus-summary-various
679 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
680 (when (featurep 'xemacs)
681 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
682 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
683 (add-hook 'gnus-summary-mode-hook
684 'gnus-xmas-switch-horizontal-scrollbar-off))
686 (defcustom gnus-summary-menu-hook nil
687 "*Hook run after the creation of the summary mode menu."
688 :group 'gnus-summary-visual
691 (defcustom gnus-summary-exit-hook nil
692 "*A hook called on exit from the summary buffer.
693 It will be called with point in the group buffer."
694 :group 'gnus-summary-exit
697 (defcustom gnus-summary-prepare-hook nil
698 "*A hook called after the summary buffer has been generated.
699 If you want to modify the summary buffer, you can use this hook."
700 :group 'gnus-summary-various
703 (defcustom gnus-summary-prepared-hook nil
704 "*A hook called as the last thing after the summary buffer has been generated."
705 :group 'gnus-summary-various
708 (defcustom gnus-summary-generate-hook nil
709 "*A hook run just before generating the summary buffer.
710 This hook is commonly used to customize threading variables and the
712 :group 'gnus-summary-various
715 (defcustom gnus-select-group-hook nil
716 "*A hook called when a newsgroup is selected.
718 If you'd like to simplify subjects like the
719 `gnus-summary-next-same-subject' command does, you can use the
722 (setq gnus-select-group-hook
725 (mapcar (lambda (header)
726 (mail-header-set-subject
728 (gnus-simplify-subject
729 (mail-header-subject header) 're-only)))
730 gnus-newsgroup-headers))))"
731 :group 'gnus-group-select
734 (defcustom gnus-select-article-hook nil
735 "*A hook called when an article is selected."
736 :group 'gnus-summary-choose
739 (defcustom gnus-visual-mark-article-hook
740 (list 'gnus-highlight-selected-summary)
741 "*Hook run after selecting an article in the summary buffer.
742 It is meant to be used for highlighting the article in some way. It
743 is not run if `gnus-visual' is nil."
744 :group 'gnus-summary-visual
747 (defcustom gnus-parse-headers-hook nil
748 "*A hook called before parsing the headers."
752 (defcustom gnus-exit-group-hook nil
753 "*A hook called when exiting summary mode.
754 This hook is not called from the non-updating exit commands like `Q'."
758 (defcustom gnus-summary-update-hook
759 (list 'gnus-summary-highlight-line)
760 "*A hook called when a summary line is changed.
761 The hook will not be called if `gnus-visual' is nil.
763 The default function `gnus-summary-highlight-line' will
764 highlight the line according to the `gnus-summary-highlight'
766 :group 'gnus-summary-visual
769 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
770 "*A hook called when an article is selected for the first time.
771 The hook is intended to mark an article as read (or unread)
772 automatically when it is selected."
773 :group 'gnus-summary-choose
776 (defcustom gnus-group-no-more-groups-hook nil
777 "*A hook run when returning to group mode having no more (unread) groups."
778 :group 'gnus-group-select
781 (defcustom gnus-ps-print-hook nil
782 "*A hook run before ps-printing something from Gnus."
786 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
787 "Face used for highlighting the current article in the summary buffer."
788 :group 'gnus-summary-visual
791 (defcustom gnus-summary-highlight
792 '(((= mark gnus-canceled-mark)
793 . gnus-summary-cancelled-face)
794 ((and (> score default)
795 (or (= mark gnus-dormant-mark)
796 (= mark gnus-ticked-mark)))
797 . gnus-summary-high-ticked-face)
798 ((and (< score default)
799 (or (= mark gnus-dormant-mark)
800 (= mark gnus-ticked-mark)))
801 . gnus-summary-low-ticked-face)
802 ((or (= mark gnus-dormant-mark)
803 (= mark gnus-ticked-mark))
804 . gnus-summary-normal-ticked-face)
805 ((and (> score default) (= mark gnus-ancient-mark))
806 . gnus-summary-high-ancient-face)
807 ((and (< score default) (= mark gnus-ancient-mark))
808 . gnus-summary-low-ancient-face)
809 ((= mark gnus-ancient-mark)
810 . gnus-summary-normal-ancient-face)
811 ((and (> score default) (= mark gnus-unread-mark))
812 . gnus-summary-high-unread-face)
813 ((and (< score default) (= mark gnus-unread-mark))
814 . gnus-summary-low-unread-face)
815 ((= mark gnus-unread-mark)
816 . gnus-summary-normal-unread-face)
817 ((and (> score default) (memq mark (list gnus-downloadable-mark
818 gnus-undownloaded-mark)))
819 . gnus-summary-high-unread-face)
820 ((and (< score default) (memq mark (list gnus-downloadable-mark
821 gnus-undownloaded-mark)))
822 . gnus-summary-low-unread-face)
823 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
824 (memq article gnus-newsgroup-unreads))
825 . gnus-summary-normal-unread-face)
826 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
827 . gnus-summary-normal-read-face)
829 . gnus-summary-high-read-face)
831 . gnus-summary-low-read-face)
833 . gnus-summary-normal-read-face))
834 "*Controls the highlighting of summary buffer lines.
836 A list of (FORM . FACE) pairs. When deciding how a a particular
837 summary line should be displayed, each form is evaluated. The content
838 of the face field after the first true form is used. You can change
839 how those summary lines are displayed, by editing the face field.
841 You can use the following variables in the FORM field.
843 score: The articles score
844 default: The default article score.
845 below: The score below which articles are automatically marked as read.
846 mark: The articles mark."
847 :group 'gnus-summary-visual
848 :type '(repeat (cons (sexp :tag "Form" nil)
851 (defcustom gnus-alter-header-function nil
852 "Function called to allow alteration of article header structures.
853 The function is called with one parameter, the article header vector,
854 which it may alter in any way.")
856 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
857 "Variable that says which function should be used to decode a string with encoded words.")
859 (defcustom gnus-extra-headers nil
860 "*Extra headers to parse."
863 :type '(repeat symbol))
865 (defcustom gnus-ignored-from-addresses
866 (and user-mail-address (regexp-quote user-mail-address))
867 "*Regexp of From headers that may be suppressed in favor of To headers."
872 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
873 "List of charsets that should be ignored.
874 When these charsets are used in the \"charset\" parameter, the
875 default charset will be used instead."
877 :type '(repeat symbol)
878 :group 'gnus-charset)
880 (gnus-define-group-parameter
884 "Return the ignored charsets of GROUP."
885 :variable gnus-group-ignored-charsets-alist
887 '(("alt\\.chinese\\.text" iso-8859-1))
889 "Alist of regexps (to match group names) and charsets that should be ignored.
890 When these charsets are used in the \"charset\" parameter, the
891 default charset will be used instead."
892 :variable-group gnus-charset
893 :variable-type '(repeat (cons (regexp :tag "Group")
895 :parameter-type '(choice :tag "Ignored charsets"
898 :parameter-document "\
899 List of charsets that should be ignored.
901 When these charsets are used in the \"charset\" parameter, the
902 default charset will be used instead.")
904 (defcustom gnus-group-highlight-words-alist nil
905 "Alist of group regexps and highlight regexps.
906 This variable uses the same syntax as `gnus-emphasis-alist'."
908 :type '(repeat (cons (regexp :tag "Group")
909 (repeat (list (regexp :tag "Highlight regexp")
910 (number :tag "Group for entire word" 0)
911 (number :tag "Group for displayed part" 0)
913 gnus-emphasis-highlight-words)))))
914 :group 'gnus-summary-visual)
916 (defcustom gnus-summary-show-article-charset-alist
918 "Alist of number and charset.
919 The article will be shown with the charset corresponding to the
921 For example: ((1 . cn-gb-2312) (2 . big5))."
923 :type '(repeat (cons (number :tag "Argument" 1)
924 (symbol :tag "Charset")))
925 :group 'gnus-charset)
927 (defcustom gnus-preserve-marks t
928 "Whether marks are preserved when moving, copying and respooling messages."
931 :group 'gnus-summary-marks)
933 (defcustom gnus-alter-articles-to-read-function nil
934 "Function to be called to alter the list of articles to be selected."
935 :type '(choice (const nil) function)
936 :group 'gnus-summary)
938 (defcustom gnus-orphan-score nil
939 "*All orphans get this score added. Set in the score file."
940 :group 'gnus-score-default
941 :type '(choice (const nil)
944 (defcustom gnus-summary-save-parts-default-mime "image/.*"
945 "*A regexp to match MIME parts when saving multiple parts of a message
946 with gnus-summary-save-parts (X m). This regexp will be used by default
947 when prompting the user for which type of files to save."
952 (defcustom gnus-summary-save-parts-default-mime "image/.*"
953 "*A regexp to match MIME parts when saving multiple parts of a message
954 with gnus-summary-save-parts (X m). This regexp will be used by default
955 when prompting the user for which type of files to save."
960 ;;; Internal variables
962 (defvar gnus-article-mime-handles nil)
963 (defvar gnus-article-decoded-p nil)
964 (defvar gnus-article-charset nil)
965 (defvar gnus-article-ignored-charsets nil)
966 (defvar gnus-scores-exclude-files nil)
967 (defvar gnus-page-broken nil)
968 (defvar gnus-inhibit-mime-unbuttonizing nil)
970 (defvar gnus-original-article nil)
971 (defvar gnus-article-internal-prepare-hook nil)
972 (defvar gnus-newsgroup-process-stack nil)
974 (defvar gnus-thread-indent-array nil)
975 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
976 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
977 "Function called to sort the articles within a thread after it has been gathered together.")
979 (defvar gnus-summary-save-parts-type-history nil)
980 (defvar gnus-summary-save-parts-last-directory nil)
982 (defvar gnus-summary-save-parts-type-history nil)
983 (defvar gnus-summary-save-parts-last-directory nil)
985 ;; Avoid highlighting in kill files.
986 (defvar gnus-summary-inhibit-highlight nil)
987 (defvar gnus-newsgroup-selected-overlay nil)
988 (defvar gnus-inhibit-limiting nil)
989 (defvar gnus-newsgroup-adaptive-score-file nil)
990 (defvar gnus-current-score-file nil)
991 (defvar gnus-current-move-group nil)
992 (defvar gnus-current-copy-group nil)
993 (defvar gnus-current-crosspost-group nil)
995 (defvar gnus-newsgroup-dependencies nil)
996 (defvar gnus-newsgroup-adaptive nil)
997 (defvar gnus-summary-display-article-function nil)
998 (defvar gnus-summary-highlight-line-function nil
999 "Function called after highlighting a summary line.")
1001 (defvar gnus-summary-line-format-alist
1002 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1003 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1004 (?s gnus-tmp-subject-or-nil ?s)
1005 (?n gnus-tmp-name ?s)
1006 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1008 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1010 (?F gnus-tmp-from ?s)
1011 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1012 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1013 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1014 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1015 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1016 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1017 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1018 (?L gnus-tmp-lines ?s)
1019 (?I gnus-tmp-indentation ?s)
1020 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1021 (?R gnus-tmp-replied ?c)
1022 (?\[ gnus-tmp-opening-bracket ?c)
1023 (?\] gnus-tmp-closing-bracket ?c)
1024 (?\> (make-string gnus-tmp-level ? ) ?s)
1025 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1026 (?i gnus-tmp-score ?d)
1027 (?z gnus-tmp-score-char ?c)
1028 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1029 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1030 (?U gnus-tmp-unread ?c)
1031 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1032 (?t (gnus-summary-number-of-articles-in-thread
1033 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1035 (?e (gnus-summary-number-of-articles-in-thread
1036 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1038 (?u gnus-tmp-user-defined ?s)
1039 (?P (gnus-pick-line-number) ?d))
1040 "An alist of format specifications that can appear in summary lines.
1041 These are paired with what variables they correspond with, along with
1042 the type of the variable (string, integer, character, etc).")
1044 (defvar gnus-summary-dummy-line-format-alist
1045 `((?S gnus-tmp-subject ?s)
1046 (?N gnus-tmp-number ?d)
1047 (?u gnus-tmp-user-defined ?s)))
1049 (defvar gnus-summary-mode-line-format-alist
1050 `((?G gnus-tmp-group-name ?s)
1051 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1052 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1053 (?A gnus-tmp-article-number ?d)
1054 (?Z gnus-tmp-unread-and-unselected ?s)
1055 (?V gnus-version ?s)
1056 (?U gnus-tmp-unread-and-unticked ?d)
1057 (?S gnus-tmp-subject ?s)
1058 (?e gnus-tmp-unselected ?d)
1059 (?u gnus-tmp-user-defined ?s)
1060 (?d (length gnus-newsgroup-dormant) ?d)
1061 (?t (length gnus-newsgroup-marked) ?d)
1062 (?r (length gnus-newsgroup-reads) ?d)
1063 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1064 (?E gnus-newsgroup-expunged-tally ?d)
1065 (?s (gnus-current-score-file-nondirectory) ?s)))
1067 (defvar gnus-last-search-regexp nil
1068 "Default regexp for article search command.")
1070 (defvar gnus-last-shell-command nil
1071 "Default shell command on article.")
1073 (defvar gnus-newsgroup-begin nil)
1074 (defvar gnus-newsgroup-end nil)
1075 (defvar gnus-newsgroup-last-rmail nil)
1076 (defvar gnus-newsgroup-last-mail nil)
1077 (defvar gnus-newsgroup-last-folder nil)
1078 (defvar gnus-newsgroup-last-file nil)
1079 (defvar gnus-newsgroup-auto-expire nil)
1080 (defvar gnus-newsgroup-active nil)
1082 (defvar gnus-newsgroup-data nil)
1083 (defvar gnus-newsgroup-data-reverse nil)
1084 (defvar gnus-newsgroup-limit nil)
1085 (defvar gnus-newsgroup-limits nil)
1087 (defvar gnus-newsgroup-unreads nil
1088 "List of unread articles in the current newsgroup.")
1090 (defvar gnus-newsgroup-unselected nil
1091 "List of unselected unread articles in the current newsgroup.")
1093 (defvar gnus-newsgroup-reads nil
1094 "Alist of read articles and article marks in the current newsgroup.")
1096 (defvar gnus-newsgroup-expunged-tally nil)
1098 (defvar gnus-newsgroup-marked nil
1099 "List of ticked articles in the current newsgroup (a subset of unread art).")
1101 (defvar gnus-newsgroup-killed nil
1102 "List of ranges of articles that have been through the scoring process.")
1104 (defvar gnus-newsgroup-cached nil
1105 "List of articles that come from the article cache.")
1107 (defvar gnus-newsgroup-saved nil
1108 "List of articles that have been saved.")
1110 (defvar gnus-newsgroup-kill-headers nil)
1112 (defvar gnus-newsgroup-replied nil
1113 "List of articles that have been replied to in the current newsgroup.")
1115 (defvar gnus-newsgroup-forwarded nil
1116 "List of articles that have been forwarded in the current newsgroup.")
1118 (defvar gnus-newsgroup-expirable nil
1119 "List of articles in the current newsgroup that can be expired.")
1121 (defvar gnus-newsgroup-processable nil
1122 "List of articles in the current newsgroup that can be processed.")
1124 (defvar gnus-newsgroup-downloadable nil
1125 "List of articles in the current newsgroup that can be processed.")
1127 (defvar gnus-newsgroup-undownloaded nil
1128 "List of articles in the current newsgroup that haven't been downloaded..")
1130 (defvar gnus-newsgroup-unsendable nil
1131 "List of articles in the current newsgroup that won't be sent.")
1133 (defvar gnus-newsgroup-bookmarks nil
1134 "List of articles in the current newsgroup that have bookmarks.")
1136 (defvar gnus-newsgroup-dormant nil
1137 "List of dormant articles in the current newsgroup.")
1139 (defvar gnus-newsgroup-scored nil
1140 "List of scored articles in the current newsgroup.")
1142 (defvar gnus-newsgroup-headers nil
1143 "List of article headers in the current newsgroup.")
1145 (defvar gnus-newsgroup-threads nil)
1147 (defvar gnus-newsgroup-prepared nil
1148 "Whether the current group has been prepared properly.")
1150 (defvar gnus-newsgroup-ancient nil
1151 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1153 (defvar gnus-newsgroup-sparse nil)
1155 (defvar gnus-current-article nil)
1156 (defvar gnus-article-current nil)
1157 (defvar gnus-current-headers nil)
1158 (defvar gnus-have-all-headers nil)
1159 (defvar gnus-last-article nil)
1160 (defvar gnus-newsgroup-history nil)
1161 (defvar gnus-newsgroup-charset nil)
1162 (defvar gnus-newsgroup-ephemeral-charset nil)
1163 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1165 (defvar gnus-article-before-search nil)
1167 (defconst gnus-summary-local-variables
1168 '(gnus-newsgroup-name
1169 gnus-newsgroup-begin gnus-newsgroup-end
1170 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1171 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1172 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1173 gnus-newsgroup-unselected gnus-newsgroup-marked
1174 gnus-newsgroup-reads gnus-newsgroup-saved
1175 gnus-newsgroup-replied gnus-newsgroup-forwarded
1176 gnus-newsgroup-expirable
1177 gnus-newsgroup-processable gnus-newsgroup-killed
1178 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1179 gnus-newsgroup-unsendable
1180 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1181 gnus-newsgroup-headers gnus-newsgroup-threads
1182 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1183 gnus-current-article gnus-current-headers gnus-have-all-headers
1184 gnus-last-article gnus-article-internal-prepare-hook
1185 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1186 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1187 gnus-thread-expunge-below
1188 gnus-score-alist gnus-current-score-file
1189 (gnus-summary-expunge-below . global)
1190 (gnus-summary-mark-below . global)
1191 (gnus-orphan-score . global)
1192 gnus-newsgroup-active gnus-scores-exclude-files
1193 gnus-newsgroup-history gnus-newsgroup-ancient
1194 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1195 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1196 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1197 (gnus-newsgroup-expunged-tally . 0)
1198 gnus-cache-removable-articles gnus-newsgroup-cached
1199 gnus-newsgroup-data gnus-newsgroup-data-reverse
1200 gnus-newsgroup-limit gnus-newsgroup-limits
1201 gnus-newsgroup-charset)
1202 "Variables that are buffer-local to the summary buffers.")
1204 (defvar gnus-newsgroup-variables nil
1205 "Variables that have separate values in the newsgroups.")
1207 ;; Byte-compiler warning.
1208 (eval-when-compile (defvar gnus-article-mode-map))
1212 (defvar gnus-decode-encoded-word-methods
1213 '(mail-decode-encoded-word-string)
1214 "List of methods used to decode encoded words.
1216 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1217 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1218 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1219 whose names match REGEXP.
1222 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1223 mail-decode-encoded-word-string
1224 (\"chinese\" . rfc1843-decode-string))")
1226 (defvar gnus-decode-encoded-word-methods-cache nil)
1228 (defun gnus-multi-decode-encoded-word-string (string)
1229 "Apply the functions from `gnus-encoded-word-methods' that match."
1230 (unless (and gnus-decode-encoded-word-methods-cache
1231 (eq gnus-newsgroup-name
1232 (car gnus-decode-encoded-word-methods-cache)))
1233 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1236 (nconc gnus-decode-encoded-word-methods-cache (list x))
1237 (if (and gnus-newsgroup-name
1238 (string-match (car x) gnus-newsgroup-name))
1239 (nconc gnus-decode-encoded-word-methods-cache
1241 gnus-decode-encoded-word-methods))
1242 (let ((xlist gnus-decode-encoded-word-methods-cache))
1245 (setq string (funcall (pop xlist) string))))
1248 ;; Subject simplification.
1250 (defun gnus-simplify-whitespace (str)
1251 "Remove excessive whitespace from STR."
1254 (while (string-match "[ \t][ \t]+" mystr)
1255 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1257 (substring mystr (match-end 0)))))
1259 (when (string-match "^[ \t]+" mystr)
1260 (setq mystr (substring mystr (match-end 0))))
1262 (when (string-match "[ \t]+$" mystr)
1263 (setq mystr (substring mystr 0 (match-beginning 0))))
1266 (defsubst gnus-simplify-subject-re (subject)
1267 "Remove \"Re:\" from subject lines."
1268 (if (string-match message-subject-re-regexp subject)
1269 (substring subject (match-end 0))
1272 (defun gnus-simplify-subject (subject &optional re-only)
1273 "Remove `Re:' and words in parentheses.
1274 If RE-ONLY is non-nil, strip leading `Re:'s only."
1275 (let ((case-fold-search t)) ;Ignore case.
1276 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1277 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1278 (setq subject (substring subject (match-end 0))))
1279 ;; Remove uninteresting prefixes.
1280 (when (and (not re-only)
1281 gnus-simplify-ignored-prefixes
1282 (string-match gnus-simplify-ignored-prefixes subject))
1283 (setq subject (substring subject (match-end 0))))
1284 ;; Remove words in parentheses from end.
1286 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1287 (setq subject (substring subject 0 (match-beginning 0)))))
1288 ;; Return subject string.
1291 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1293 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1294 (goto-char (point-min))
1295 (while (re-search-forward regexp nil t)
1296 (replace-match (or newtext ""))))
1298 (defun gnus-simplify-buffer-fuzzy ()
1299 "Simplify string in the buffer fuzzily.
1300 The string in the accessible portion of the current buffer is simplified.
1301 It is assumed to be a single-line subject.
1302 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1303 matter is removed. Additional things can be deleted by setting
1304 `gnus-simplify-subject-fuzzy-regexp'."
1305 (let ((case-fold-search t)
1307 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1309 (while (not (eq modified-tick (buffer-modified-tick)))
1310 (setq modified-tick (buffer-modified-tick))
1312 ((listp gnus-simplify-subject-fuzzy-regexp)
1313 (mapcar 'gnus-simplify-buffer-fuzzy-step
1314 gnus-simplify-subject-fuzzy-regexp))
1315 (gnus-simplify-subject-fuzzy-regexp
1316 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1317 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1318 (gnus-simplify-buffer-fuzzy-step
1319 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1320 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1322 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1323 (gnus-simplify-buffer-fuzzy-step " +" " ")
1324 (gnus-simplify-buffer-fuzzy-step " $")
1325 (gnus-simplify-buffer-fuzzy-step "^ +")))
1327 (defun gnus-simplify-subject-fuzzy (subject)
1328 "Simplify a subject string fuzzily.
1329 See `gnus-simplify-buffer-fuzzy' for details."
1331 (gnus-set-work-buffer)
1332 (let ((case-fold-search t))
1333 ;; Remove uninteresting prefixes.
1334 (when (and gnus-simplify-ignored-prefixes
1335 (string-match gnus-simplify-ignored-prefixes subject))
1336 (setq subject (substring subject (match-end 0))))
1338 (inline (gnus-simplify-buffer-fuzzy))
1341 (defsubst gnus-simplify-subject-fully (subject)
1342 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1344 (gnus-simplify-subject-functions
1345 (gnus-map-function gnus-simplify-subject-functions subject))
1346 ((null gnus-summary-gather-subject-limit)
1347 (gnus-simplify-subject-re subject))
1348 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1349 (gnus-simplify-subject-fuzzy subject))
1350 ((numberp gnus-summary-gather-subject-limit)
1351 (gnus-limit-string (gnus-simplify-subject-re subject)
1352 gnus-summary-gather-subject-limit))
1356 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1357 "Check whether two subjects are equal.
1358 If optional argument simple-first is t, first argument is already
1361 ((null simple-first)
1362 (equal (gnus-simplify-subject-fully s1)
1363 (gnus-simplify-subject-fully s2)))
1366 (gnus-simplify-subject-fully s2)))))
1368 (defun gnus-summary-bubble-group ()
1369 "Increase the score of the current group.
1370 This is a handy function to add to `gnus-summary-exit-hook' to
1371 increase the score of each group you read."
1372 (gnus-group-add-score gnus-newsgroup-name))
1376 ;;; Gnus summary mode
1379 (put 'gnus-summary-mode 'mode-class 'special)
1381 (defvar gnus-article-commands-menu)
1384 ;; Non-orthogonal keys
1386 (gnus-define-keys gnus-summary-mode-map
1387 " " gnus-summary-next-page
1388 "\177" gnus-summary-prev-page
1389 [delete] gnus-summary-prev-page
1390 [backspace] gnus-summary-prev-page
1391 "\r" gnus-summary-scroll-up
1392 "\M-\r" gnus-summary-scroll-down
1393 "n" gnus-summary-next-unread-article
1394 "p" gnus-summary-prev-unread-article
1395 "N" gnus-summary-next-article
1396 "P" gnus-summary-prev-article
1397 "\M-\C-n" gnus-summary-next-same-subject
1398 "\M-\C-p" gnus-summary-prev-same-subject
1399 "\M-n" gnus-summary-next-unread-subject
1400 "\M-p" gnus-summary-prev-unread-subject
1401 "." gnus-summary-first-unread-article
1402 "," gnus-summary-best-unread-article
1403 "\M-s" gnus-summary-search-article-forward
1404 "\M-r" gnus-summary-search-article-backward
1405 "<" gnus-summary-beginning-of-article
1406 ">" gnus-summary-end-of-article
1407 "j" gnus-summary-goto-article
1408 "^" gnus-summary-refer-parent-article
1409 "\M-^" gnus-summary-refer-article
1410 "u" gnus-summary-tick-article-forward
1411 "!" gnus-summary-tick-article-forward
1412 "U" gnus-summary-tick-article-backward
1413 "d" gnus-summary-mark-as-read-forward
1414 "D" gnus-summary-mark-as-read-backward
1415 "E" gnus-summary-mark-as-expirable
1416 "\M-u" gnus-summary-clear-mark-forward
1417 "\M-U" gnus-summary-clear-mark-backward
1418 "k" gnus-summary-kill-same-subject-and-select
1419 "\C-k" gnus-summary-kill-same-subject
1420 "\M-\C-k" gnus-summary-kill-thread
1421 "\M-\C-l" gnus-summary-lower-thread
1422 "e" gnus-summary-edit-article
1423 "#" gnus-summary-mark-as-processable
1424 "\M-#" gnus-summary-unmark-as-processable
1425 "\M-\C-t" gnus-summary-toggle-threads
1426 "\M-\C-s" gnus-summary-show-thread
1427 "\M-\C-h" gnus-summary-hide-thread
1428 "\M-\C-f" gnus-summary-next-thread
1429 "\M-\C-b" gnus-summary-prev-thread
1430 [(meta down)] gnus-summary-next-thread
1431 [(meta up)] gnus-summary-prev-thread
1432 "\M-\C-u" gnus-summary-up-thread
1433 "\M-\C-d" gnus-summary-down-thread
1434 "&" gnus-summary-execute-command
1435 "c" gnus-summary-catchup-and-exit
1436 "\C-w" gnus-summary-mark-region-as-read
1437 "\C-t" gnus-summary-toggle-truncation
1438 "?" gnus-summary-mark-as-dormant
1439 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1440 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1441 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1442 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1443 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1444 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1445 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1446 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1447 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1448 "=" gnus-summary-expand-window
1449 "\C-x\C-s" gnus-summary-reselect-current-group
1450 "\M-g" gnus-summary-rescan-group
1451 "w" gnus-summary-stop-page-breaking
1452 "\C-c\C-r" gnus-summary-caesar-message
1453 "f" gnus-summary-followup
1454 "F" gnus-summary-followup-with-original
1455 "C" gnus-summary-cancel-article
1456 "r" gnus-summary-reply
1457 "R" gnus-summary-reply-with-original
1458 "\C-c\C-f" gnus-summary-mail-forward
1459 "o" gnus-summary-save-article
1460 "\C-o" gnus-summary-save-article-mail
1461 "|" gnus-summary-pipe-output
1462 "\M-k" gnus-summary-edit-local-kill
1463 "\M-K" gnus-summary-edit-global-kill
1465 "\C-c\C-d" gnus-summary-describe-group
1466 "q" gnus-summary-exit
1467 "Q" gnus-summary-exit-no-update
1468 "\C-c\C-i" gnus-info-find-node
1469 gnus-mouse-2 gnus-mouse-pick-article
1470 "m" gnus-summary-mail-other-window
1471 "a" gnus-summary-post-news
1472 "x" gnus-summary-limit-to-unread
1473 "s" gnus-summary-isearch-article
1474 "t" gnus-summary-toggle-header
1475 "g" gnus-summary-show-article
1476 "l" gnus-summary-goto-last-article
1477 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1478 "\C-d" gnus-summary-enter-digest-group
1479 "\M-\C-d" gnus-summary-read-document
1480 "\M-\C-e" gnus-summary-edit-parameters
1481 "\M-\C-a" gnus-summary-customize-parameters
1483 "*" gnus-cache-enter-article
1484 "\M-*" gnus-cache-remove-article
1485 "\M-&" gnus-summary-universal-argument
1486 "\C-l" gnus-recenter
1487 "I" gnus-summary-increase-score
1488 "L" gnus-summary-lower-score
1489 "\M-i" gnus-symbolic-argument
1490 "h" gnus-summary-select-article-buffer
1492 "b" gnus-article-view-part
1493 "\M-t" gnus-summary-toggle-display-buttonized
1495 "V" gnus-summary-score-map
1496 "X" gnus-uu-extract-map
1497 "S" gnus-summary-send-map)
1499 ;; Sort of orthogonal keymap
1500 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1501 "t" gnus-summary-tick-article-forward
1502 "!" gnus-summary-tick-article-forward
1503 "d" gnus-summary-mark-as-read-forward
1504 "r" gnus-summary-mark-as-read-forward
1505 "c" gnus-summary-clear-mark-forward
1506 " " gnus-summary-clear-mark-forward
1507 "e" gnus-summary-mark-as-expirable
1508 "x" gnus-summary-mark-as-expirable
1509 "?" gnus-summary-mark-as-dormant
1510 "b" gnus-summary-set-bookmark
1511 "B" gnus-summary-remove-bookmark
1512 "#" gnus-summary-mark-as-processable
1513 "\M-#" gnus-summary-unmark-as-processable
1514 "S" gnus-summary-limit-include-expunged
1515 "C" gnus-summary-catchup
1516 "H" gnus-summary-catchup-to-here
1517 "\C-c" gnus-summary-catchup-all
1518 "k" gnus-summary-kill-same-subject-and-select
1519 "K" gnus-summary-kill-same-subject
1520 "P" gnus-uu-mark-map)
1522 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1523 "c" gnus-summary-clear-above
1524 "u" gnus-summary-tick-above
1525 "m" gnus-summary-mark-above
1526 "k" gnus-summary-kill-below)
1528 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1529 "/" gnus-summary-limit-to-subject
1530 "n" gnus-summary-limit-to-articles
1531 "w" gnus-summary-pop-limit
1532 "s" gnus-summary-limit-to-subject
1533 "a" gnus-summary-limit-to-author
1534 "u" gnus-summary-limit-to-unread
1535 "m" gnus-summary-limit-to-marks
1536 "M" gnus-summary-limit-exclude-marks
1537 "v" gnus-summary-limit-to-score
1538 "*" gnus-summary-limit-include-cached
1539 "D" gnus-summary-limit-include-dormant
1540 "T" gnus-summary-limit-include-thread
1541 "d" gnus-summary-limit-exclude-dormant
1542 "t" gnus-summary-limit-to-age
1543 "x" gnus-summary-limit-to-extra
1544 "E" gnus-summary-limit-include-expunged
1545 "c" gnus-summary-limit-exclude-childless-dormant
1546 "C" gnus-summary-limit-mark-excluded-as-read
1547 "o" gnus-summary-insert-old-articles
1548 "N" gnus-summary-insert-new-articles)
1550 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1551 "n" gnus-summary-next-unread-article
1552 "p" gnus-summary-prev-unread-article
1553 "N" gnus-summary-next-article
1554 "P" gnus-summary-prev-article
1555 "\C-n" gnus-summary-next-same-subject
1556 "\C-p" gnus-summary-prev-same-subject
1557 "\M-n" gnus-summary-next-unread-subject
1558 "\M-p" gnus-summary-prev-unread-subject
1559 "f" gnus-summary-first-unread-article
1560 "b" gnus-summary-best-unread-article
1561 "j" gnus-summary-goto-article
1562 "g" gnus-summary-goto-subject
1563 "l" gnus-summary-goto-last-article
1564 "o" gnus-summary-pop-article)
1566 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1567 "k" gnus-summary-kill-thread
1568 "l" gnus-summary-lower-thread
1569 "i" gnus-summary-raise-thread
1570 "T" gnus-summary-toggle-threads
1571 "t" gnus-summary-rethread-current
1572 "^" gnus-summary-reparent-thread
1573 "s" gnus-summary-show-thread
1574 "S" gnus-summary-show-all-threads
1575 "h" gnus-summary-hide-thread
1576 "H" gnus-summary-hide-all-threads
1577 "n" gnus-summary-next-thread
1578 "p" gnus-summary-prev-thread
1579 "u" gnus-summary-up-thread
1580 "o" gnus-summary-top-thread
1581 "d" gnus-summary-down-thread
1582 "#" gnus-uu-mark-thread
1583 "\M-#" gnus-uu-unmark-thread)
1585 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1586 "g" gnus-summary-prepare
1587 "c" gnus-summary-insert-cached-articles)
1589 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1590 "c" gnus-summary-catchup-and-exit
1591 "C" gnus-summary-catchup-all-and-exit
1592 "E" gnus-summary-exit-no-update
1593 "Q" gnus-summary-exit
1594 "Z" gnus-summary-exit
1595 "n" gnus-summary-catchup-and-goto-next-group
1596 "R" gnus-summary-reselect-current-group
1597 "G" gnus-summary-rescan-group
1598 "N" gnus-summary-next-group
1599 "s" gnus-summary-save-newsrc
1600 "P" gnus-summary-prev-group)
1602 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1603 " " gnus-summary-next-page
1604 "n" gnus-summary-next-page
1605 "\177" gnus-summary-prev-page
1606 [delete] gnus-summary-prev-page
1607 "p" gnus-summary-prev-page
1608 "\r" gnus-summary-scroll-up
1609 "\M-\r" gnus-summary-scroll-down
1610 "<" gnus-summary-beginning-of-article
1611 ">" gnus-summary-end-of-article
1612 "b" gnus-summary-beginning-of-article
1613 "e" gnus-summary-end-of-article
1614 "^" gnus-summary-refer-parent-article
1615 "r" gnus-summary-refer-parent-article
1616 "D" gnus-summary-enter-digest-group
1617 "R" gnus-summary-refer-references
1618 "T" gnus-summary-refer-thread
1619 "g" gnus-summary-show-article
1620 "s" gnus-summary-isearch-article
1621 "P" gnus-summary-print-article
1622 "M" gnus-mailing-list-insinuate
1623 "t" gnus-article-babel)
1625 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1626 "b" gnus-article-add-buttons
1627 "B" gnus-article-add-buttons-to-head
1628 "o" gnus-article-treat-overstrike
1629 "e" gnus-article-emphasize
1630 "w" gnus-article-fill-cited-article
1631 "Q" gnus-article-fill-long-lines
1632 "C" gnus-article-capitalize-sentences
1633 "c" gnus-article-remove-cr
1634 "q" gnus-article-de-quoted-unreadable
1635 "6" gnus-article-de-base64-unreadable
1636 "Z" gnus-article-decode-HZ
1637 "h" gnus-article-wash-html
1638 "s" gnus-summary-force-verify-and-decrypt
1639 "f" gnus-article-display-x-face
1640 "l" gnus-summary-stop-page-breaking
1641 "r" gnus-summary-caesar-message
1642 "t" gnus-summary-toggle-header
1643 "v" gnus-summary-verbose-headers
1644 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1645 "p" gnus-article-verify-x-pgp-sig
1646 "d" gnus-article-treat-dumbquotes)
1648 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1649 "a" gnus-article-hide
1650 "h" gnus-article-hide-headers
1651 "b" gnus-article-hide-boring-headers
1652 "s" gnus-article-hide-signature
1653 "c" gnus-article-hide-citation
1654 "C" gnus-article-hide-citation-in-followups
1655 "l" gnus-article-hide-list-identifiers
1656 "p" gnus-article-hide-pgp
1657 "B" gnus-article-strip-banner
1658 "P" gnus-article-hide-pem
1659 "\C-c" gnus-article-hide-citation-maybe)
1661 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1662 "a" gnus-article-highlight
1663 "h" gnus-article-highlight-headers
1664 "c" gnus-article-highlight-citation
1665 "s" gnus-article-highlight-signature)
1667 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1668 "w" gnus-article-decode-mime-words
1669 "c" gnus-article-decode-charset
1670 "v" gnus-mime-view-all-parts
1671 "b" gnus-article-view-part)
1673 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1674 "z" gnus-article-date-ut
1675 "u" gnus-article-date-ut
1676 "l" gnus-article-date-local
1677 "p" gnus-article-date-english
1678 "e" gnus-article-date-lapsed
1679 "o" gnus-article-date-original
1680 "i" gnus-article-date-iso8601
1681 "s" gnus-article-date-user)
1683 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1684 "t" gnus-article-remove-trailing-blank-lines
1685 "l" gnus-article-strip-leading-blank-lines
1686 "m" gnus-article-strip-multiple-blank-lines
1687 "a" gnus-article-strip-blank-lines
1688 "A" gnus-article-strip-all-blank-lines
1689 "s" gnus-article-strip-leading-space
1690 "e" gnus-article-strip-trailing-space
1691 "w" gnus-article-remove-leading-whitespace)
1693 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1695 "f" gnus-summary-fetch-faq
1696 "d" gnus-summary-describe-group
1697 "h" gnus-summary-describe-briefly
1698 "i" gnus-info-find-node)
1700 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1701 "e" gnus-summary-expire-articles
1702 "\M-\C-e" gnus-summary-expire-articles-now
1703 "\177" gnus-summary-delete-article
1704 [delete] gnus-summary-delete-article
1705 [backspace] gnus-summary-delete-article
1706 "m" gnus-summary-move-article
1707 "r" gnus-summary-respool-article
1708 "w" gnus-summary-edit-article
1709 "c" gnus-summary-copy-article
1710 "B" gnus-summary-crosspost-article
1711 "q" gnus-summary-respool-query
1712 "t" gnus-summary-respool-trace
1713 "i" gnus-summary-import-article
1714 "I" gnus-summary-create-article
1715 "p" gnus-summary-article-posted-p)
1717 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1718 "o" gnus-summary-save-article
1719 "m" gnus-summary-save-article-mail
1720 "F" gnus-summary-write-article-file
1721 "r" gnus-summary-save-article-rmail
1722 "f" gnus-summary-save-article-file
1723 "b" gnus-summary-save-article-body-file
1724 "h" gnus-summary-save-article-folder
1725 "v" gnus-summary-save-article-vm
1726 "p" gnus-summary-pipe-output
1727 "s" gnus-soup-add-article)
1729 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1730 "b" gnus-summary-display-buttonized
1731 "m" gnus-summary-repair-multipart
1732 "v" gnus-article-view-part
1733 "o" gnus-article-save-part
1734 "c" gnus-article-copy-part
1735 "C" gnus-article-view-part-as-charset
1736 "e" gnus-article-externalize-part
1737 "E" gnus-article-encrypt-body
1738 "i" gnus-article-inline-part
1739 "|" gnus-article-pipe-part))
1741 (defvar gnus-article-post-menu nil)
1743 (defun gnus-summary-make-menu-bar ()
1744 (gnus-turn-off-edit-menu 'summary)
1746 (unless (boundp 'gnus-summary-misc-menu)
1749 gnus-summary-kill-menu gnus-summary-mode-map ""
1754 ["Customize" gnus-score-customize t])
1755 (gnus-make-score-map 'increase)
1756 (gnus-make-score-map 'lower)
1758 ["Kill below" gnus-summary-kill-below t]
1759 ["Mark above" gnus-summary-mark-above t]
1760 ["Tick above" gnus-summary-tick-above t]
1761 ["Clear above" gnus-summary-clear-above t])
1762 ["Current score" gnus-summary-current-score t]
1763 ["Set score" gnus-summary-set-score t]
1764 ["Switch current score file..." gnus-score-change-score-file t]
1765 ["Set mark below..." gnus-score-set-mark-below t]
1766 ["Set expunge below..." gnus-score-set-expunge-below t]
1767 ["Edit current score file" gnus-score-edit-current-scores t]
1768 ["Edit score file" gnus-score-edit-file t]
1769 ["Trace score" gnus-score-find-trace t]
1770 ["Find words" gnus-score-find-favourite-words t]
1771 ["Rescore buffer" gnus-summary-rescore t]
1772 ["Increase score..." gnus-summary-increase-score t]
1773 ["Lower score..." gnus-summary-lower-score t]))))
1775 ;; Define both the Article menu in the summary buffer and the equivalent
1776 ;; Commands menu in the article buffer here for consistency.
1779 ["All" gnus-article-hide t]
1780 ["Headers" gnus-article-hide-headers t]
1781 ["Signature" gnus-article-hide-signature t]
1782 ["Citation" gnus-article-hide-citation t]
1783 ["List identifiers" gnus-article-hide-list-identifiers t]
1784 ["PGP" gnus-article-hide-pgp t]
1785 ["Banner" gnus-article-strip-banner t]
1786 ["Boring headers" gnus-article-hide-boring-headers t])
1788 ["All" gnus-article-highlight t]
1789 ["Headers" gnus-article-highlight-headers t]
1790 ["Signature" gnus-article-highlight-signature t]
1791 ["Citation" gnus-article-highlight-citation t])
1793 ["Words" gnus-article-decode-mime-words t]
1794 ["Charset" gnus-article-decode-charset t]
1795 ["QP" gnus-article-de-quoted-unreadable t]
1796 ["Base64" gnus-article-de-base64-unreadable t]
1797 ["View all" gnus-mime-view-all-parts t]
1798 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1799 ["Encrypt body" gnus-article-encrypt-body t])
1801 ["Local" gnus-article-date-local t]
1802 ["ISO8601" gnus-article-date-iso8601 t]
1803 ["UT" gnus-article-date-ut t]
1804 ["Original" gnus-article-date-original t]
1805 ["Lapsed" gnus-article-date-lapsed t]
1806 ["User-defined" gnus-article-date-user t])
1809 ["Leading" gnus-article-strip-leading-blank-lines t]
1810 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1811 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1812 ["All of the above" gnus-article-strip-blank-lines t]
1813 ["All" gnus-article-strip-all-blank-lines t]
1814 ["Leading space" gnus-article-strip-leading-space t]
1815 ["Trailing space" gnus-article-strip-trailing-space t]
1816 ["Leading space in headers"
1817 gnus-article-remove-leading-whitespace t])
1818 ["Overstrike" gnus-article-treat-overstrike t]
1819 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1820 ["Emphasis" gnus-article-emphasize t]
1821 ["Word wrap" gnus-article-fill-cited-article t]
1822 ["Fill long lines" gnus-article-fill-long-lines t]
1823 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1824 ["CR" gnus-article-remove-cr t]
1825 ["Show X-Face" gnus-article-display-x-face t]
1826 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1827 ["Base64" gnus-article-de-base64-unreadable t]
1828 ["Rot 13" gnus-summary-caesar-message
1829 ,@(if (featurep 'xemacs) '(t)
1830 '(:help "\"Caesar rotate\" article by 13"))]
1831 ["Unix pipe" gnus-summary-pipe-message t]
1832 ["Add buttons" gnus-article-add-buttons t]
1833 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1834 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1835 ["Verbose header" gnus-summary-verbose-headers t]
1836 ["Toggle header" gnus-summary-toggle-header t]
1837 ["Html" gnus-article-wash-html t]
1838 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1839 ["HZ" gnus-article-decode-HZ t])
1841 ["Save in default format" gnus-summary-save-article
1842 ,@(if (featurep 'xemacs) '(t)
1843 '(:help "Save article using default method"))]
1844 ["Save in file" gnus-summary-save-article-file
1845 ,@(if (featurep 'xemacs) '(t)
1846 '(:help "Save article in file"))]
1847 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1848 ["Save in MH folder" gnus-summary-save-article-folder t]
1849 ["Save in VM folder" gnus-summary-save-article-vm t]
1850 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1851 ["Save body in file" gnus-summary-save-article-body-file t]
1852 ["Pipe through a filter" gnus-summary-pipe-output t]
1853 ["Add to SOUP packet" gnus-soup-add-article t]
1854 ["Print" gnus-summary-print-article t])
1856 ["Respool article..." gnus-summary-respool-article t]
1857 ["Move article..." gnus-summary-move-article
1858 (gnus-check-backend-function
1859 'request-move-article gnus-newsgroup-name)]
1860 ["Copy article..." gnus-summary-copy-article t]
1861 ["Crosspost article..." gnus-summary-crosspost-article
1862 (gnus-check-backend-function
1863 'request-replace-article gnus-newsgroup-name)]
1864 ["Import file..." gnus-summary-import-article t]
1865 ["Create article..." gnus-summary-create-article t]
1866 ["Check if posted" gnus-summary-article-posted-p t]
1867 ["Edit article" gnus-summary-edit-article
1868 (not (gnus-group-read-only-p))]
1869 ["Delete article" gnus-summary-delete-article
1870 (gnus-check-backend-function
1871 'request-expire-articles gnus-newsgroup-name)]
1872 ["Query respool" gnus-summary-respool-query t]
1873 ["Trace respool" gnus-summary-respool-trace t]
1874 ["Delete expirable articles" gnus-summary-expire-articles-now
1875 (gnus-check-backend-function
1876 'request-expire-articles gnus-newsgroup-name)])
1878 ["Uudecode" gnus-uu-decode-uu
1879 ,@(if (featurep 'xemacs) '(t)
1880 '(:help "Decode uuencoded article(s)"))]
1881 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1882 ["Unshar" gnus-uu-decode-unshar t]
1883 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1884 ["Save" gnus-uu-decode-save t]
1885 ["Binhex" gnus-uu-decode-binhex t]
1886 ["Postscript" gnus-uu-decode-postscript t])
1888 ["Enter article" gnus-cache-enter-article t]
1889 ["Remove article" gnus-cache-remove-article t])
1890 ["Translate" gnus-article-babel t]
1891 ["Select article buffer" gnus-summary-select-article-buffer t]
1892 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1893 ["Isearch article..." gnus-summary-isearch-article t]
1894 ["Beginning of the article" gnus-summary-beginning-of-article t]
1895 ["End of the article" gnus-summary-end-of-article t]
1896 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1897 ["Fetch referenced articles" gnus-summary-refer-references t]
1898 ["Fetch current thread" gnus-summary-refer-thread t]
1899 ["Fetch article with id..." gnus-summary-refer-article t]
1900 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1901 ["Redisplay" gnus-summary-show-article t])))
1903 gnus-summary-article-menu gnus-summary-mode-map ""
1904 (cons "Article" innards))
1906 (if (not (keymapp gnus-summary-article-menu))
1908 gnus-article-commands-menu gnus-article-mode-map ""
1909 (cons "Commands" innards))
1910 ;; in Emacs, don't share menu.
1911 (setq gnus-article-commands-menu
1912 (copy-keymap gnus-summary-article-menu))
1913 (define-key gnus-article-mode-map [menu-bar commands]
1914 (cons "Commands" gnus-article-commands-menu))))
1917 gnus-summary-thread-menu gnus-summary-mode-map ""
1919 ["Toggle threading" gnus-summary-toggle-threads t]
1920 ["Hide threads" gnus-summary-hide-all-threads t]
1921 ["Show threads" gnus-summary-show-all-threads t]
1922 ["Hide thread" gnus-summary-hide-thread t]
1923 ["Show thread" gnus-summary-show-thread t]
1924 ["Go to next thread" gnus-summary-next-thread t]
1925 ["Go to previous thread" gnus-summary-prev-thread t]
1926 ["Go down thread" gnus-summary-down-thread t]
1927 ["Go up thread" gnus-summary-up-thread t]
1928 ["Top of thread" gnus-summary-top-thread t]
1929 ["Mark thread as read" gnus-summary-kill-thread t]
1930 ["Lower thread score" gnus-summary-lower-thread t]
1931 ["Raise thread score" gnus-summary-raise-thread t]
1932 ["Rethread current" gnus-summary-rethread-current t]))
1935 gnus-summary-post-menu gnus-summary-mode-map ""
1937 ["Post an article" gnus-summary-post-news
1938 ,@(if (featurep 'xemacs) '(t)
1939 '(:help "Post an article"))]
1940 ["Followup" gnus-summary-followup
1941 ,@(if (featurep 'xemacs) '(t)
1942 '(:help "Post followup to this article"))]
1943 ["Followup and yank" gnus-summary-followup-with-original
1944 ,@(if (featurep 'xemacs) '(t)
1945 '(:help "Post followup to this article, quoting its contents"))]
1946 ["Supersede article" gnus-summary-supersede-article t]
1947 ["Cancel article" gnus-summary-cancel-article
1948 ,@(if (featurep 'xemacs) '(t)
1949 '(:help "Cancel an article you posted"))]
1950 ["Reply" gnus-summary-reply t]
1951 ["Reply and yank" gnus-summary-reply-with-original t]
1952 ["Wide reply" gnus-summary-wide-reply t]
1953 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1954 ,@(if (featurep 'xemacs) '(t)
1955 '(:help "Mail a reply, quoting this article"))]
1956 ["Mail forward" gnus-summary-mail-forward t]
1957 ["Post forward" gnus-summary-post-forward t]
1958 ["Digest and mail" gnus-uu-digest-mail-forward t]
1959 ["Digest and post" gnus-uu-digest-post-forward t]
1960 ["Resend message" gnus-summary-resend-message t]
1961 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1962 ["Send a mail" gnus-summary-mail-other-window t]
1963 ["Uuencode and post" gnus-uu-post-news
1964 ,@(if (featurep 'xemacs) '(t)
1965 '(:help "Post a uuencoded article"))]
1966 ["Followup via news" gnus-summary-followup-to-mail t]
1967 ["Followup via news and yank"
1968 gnus-summary-followup-to-mail-with-original t]
1970 ;;["Send" gnus-summary-send-draft t]
1971 ;;["Send bounced" gnus-resend-bounced-mail t])
1975 ((not (keymapp gnus-summary-post-menu))
1976 (setq gnus-article-post-menu gnus-summary-post-menu))
1977 ((not gnus-article-post-menu)
1978 ;; Don't share post menu.
1979 (setq gnus-article-post-menu
1980 (copy-keymap gnus-summary-post-menu))))
1981 (define-key gnus-article-mode-map [menu-bar post]
1982 (cons "Post" gnus-article-post-menu))
1985 gnus-summary-misc-menu gnus-summary-mode-map ""
1988 ["Mark as read" gnus-summary-mark-as-read-forward t]
1989 ["Mark same subject and select"
1990 gnus-summary-kill-same-subject-and-select t]
1991 ["Mark same subject" gnus-summary-kill-same-subject t]
1992 ["Catchup" gnus-summary-catchup
1993 ,@(if (featurep 'xemacs) '(t)
1994 '(:help "Mark unread articles in this group as read"))]
1995 ["Catchup all" gnus-summary-catchup-all t]
1996 ["Catchup to here" gnus-summary-catchup-to-here t]
1997 ["Catchup region" gnus-summary-mark-region-as-read t]
1998 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2000 ["Tick" gnus-summary-tick-article-forward t]
2001 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2002 ["Remove marks" gnus-summary-clear-mark-forward t]
2003 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2004 ["Set bookmark" gnus-summary-set-bookmark t]
2005 ["Remove bookmark" gnus-summary-remove-bookmark t])
2007 ["Marks..." gnus-summary-limit-to-marks t]
2008 ["Subject..." gnus-summary-limit-to-subject t]
2009 ["Author..." gnus-summary-limit-to-author t]
2010 ["Age..." gnus-summary-limit-to-age t]
2011 ["Extra..." gnus-summary-limit-to-extra t]
2012 ["Score" gnus-summary-limit-to-score t]
2013 ["Unread" gnus-summary-limit-to-unread t]
2014 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2015 ["Articles" gnus-summary-limit-to-articles t]
2016 ["Pop limit" gnus-summary-pop-limit t]
2017 ["Show dormant" gnus-summary-limit-include-dormant t]
2018 ["Hide childless dormant"
2019 gnus-summary-limit-exclude-childless-dormant t]
2020 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2021 ["Hide marked" gnus-summary-limit-exclude-marks t]
2022 ["Show expunged" gnus-summary-limit-include-expunged t])
2024 ["Set mark" gnus-summary-mark-as-processable t]
2025 ["Remove mark" gnus-summary-unmark-as-processable t]
2026 ["Remove all marks" gnus-summary-unmark-all-processable t]
2027 ["Mark above" gnus-uu-mark-over t]
2028 ["Mark series" gnus-uu-mark-series t]
2029 ["Mark region" gnus-uu-mark-region t]
2030 ["Unmark region" gnus-uu-unmark-region t]
2031 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2032 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2033 ["Mark all" gnus-uu-mark-all t]
2034 ["Mark buffer" gnus-uu-mark-buffer t]
2035 ["Mark sparse" gnus-uu-mark-sparse t]
2036 ["Mark thread" gnus-uu-mark-thread t]
2037 ["Unmark thread" gnus-uu-unmark-thread t]
2038 ("Process Mark Sets"
2039 ["Kill" gnus-summary-kill-process-mark t]
2040 ["Yank" gnus-summary-yank-process-mark
2041 gnus-newsgroup-process-stack]
2042 ["Save" gnus-summary-save-process-mark t]))
2044 ["Page forward" gnus-summary-next-page
2045 ,@(if (featurep 'xemacs) '(t)
2046 '(:help "Show next page of article"))]
2047 ["Page backward" gnus-summary-prev-page
2048 ,@(if (featurep 'xemacs) '(t)
2049 '(:help "Show previous page of article"))]
2050 ["Line forward" gnus-summary-scroll-up t])
2052 ["Next unread article" gnus-summary-next-unread-article t]
2053 ["Previous unread article" gnus-summary-prev-unread-article t]
2054 ["Next article" gnus-summary-next-article t]
2055 ["Previous article" gnus-summary-prev-article t]
2056 ["Next unread subject" gnus-summary-next-unread-subject t]
2057 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2058 ["Next article same subject" gnus-summary-next-same-subject t]
2059 ["Previous article same subject" gnus-summary-prev-same-subject t]
2060 ["First unread article" gnus-summary-first-unread-article t]
2061 ["Best unread article" gnus-summary-best-unread-article t]
2062 ["Go to subject number..." gnus-summary-goto-subject t]
2063 ["Go to article number..." gnus-summary-goto-article t]
2064 ["Go to the last article" gnus-summary-goto-last-article t]
2065 ["Pop article off history" gnus-summary-pop-article t])
2067 ["Sort by number" gnus-summary-sort-by-number t]
2068 ["Sort by author" gnus-summary-sort-by-author t]
2069 ["Sort by subject" gnus-summary-sort-by-subject t]
2070 ["Sort by date" gnus-summary-sort-by-date t]
2071 ["Sort by score" gnus-summary-sort-by-score t]
2072 ["Sort by lines" gnus-summary-sort-by-lines t]
2073 ["Sort by characters" gnus-summary-sort-by-chars t]
2074 ["Original sort" gnus-summary-sort-by-original t])
2076 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2077 ["Describe group" gnus-summary-describe-group t]
2078 ["Read manual" gnus-info-find-node t])
2080 ["Pick and read" gnus-pick-mode t]
2081 ["Binary" gnus-binary-mode t])
2083 ["Regenerate" gnus-summary-prepare t]
2084 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2085 ["Toggle threading" gnus-summary-toggle-threads t])
2086 ["See old articles" gnus-summary-insert-old-articles t]
2087 ["See new articles" gnus-summary-insert-new-articles t]
2088 ["Filter articles..." gnus-summary-execute-command t]
2089 ["Run command on subjects..." gnus-summary-universal-argument t]
2090 ["Search articles forward..." gnus-summary-search-article-forward t]
2091 ["Search articles backward..." gnus-summary-search-article-backward t]
2092 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2093 ["Expand window" gnus-summary-expand-window t]
2094 ["Expire expirable articles" gnus-summary-expire-articles
2095 (gnus-check-backend-function
2096 'request-expire-articles gnus-newsgroup-name)]
2097 ["Edit local kill file" gnus-summary-edit-local-kill t]
2098 ["Edit main kill file" gnus-summary-edit-global-kill t]
2099 ["Edit group parameters" gnus-summary-edit-parameters t]
2100 ["Customize group parameters" gnus-summary-customize-parameters t]
2101 ["Send a bug report" gnus-bug t]
2103 ["Catchup and exit" gnus-summary-catchup-and-exit
2104 ,@(if (featurep 'xemacs) '(t)
2105 '(:help "Mark unread articles in this group as read, then exit"))]
2106 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2107 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2108 ["Exit group" gnus-summary-exit
2109 ,@(if (featurep 'xemacs) '(t)
2110 '(:help "Exit current group, return to group selection mode"))]
2111 ["Exit group without updating" gnus-summary-exit-no-update t]
2112 ["Exit and goto next group" gnus-summary-next-group t]
2113 ["Exit and goto prev group" gnus-summary-prev-group t]
2114 ["Reselect group" gnus-summary-reselect-current-group t]
2115 ["Rescan group" gnus-summary-rescan-group t]
2116 ["Update dribble" gnus-summary-save-newsrc t])))
2118 (gnus-run-hooks 'gnus-summary-menu-hook)))
2120 (defvar gnus-summary-tool-bar-map nil)
2122 ;; Emacs 21 tool bar. Should be no-op otherwise.
2123 (defun gnus-summary-make-tool-bar ()
2124 (if (and (fboundp 'tool-bar-add-item-from-menu)
2125 (default-value 'tool-bar-mode)
2126 (not gnus-summary-tool-bar-map))
2127 (setq gnus-summary-tool-bar-map
2128 (let ((tool-bar-map (make-sparse-keymap))
2129 (load-path (mm-image-load-path)))
2130 (tool-bar-add-item-from-menu
2131 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2132 (tool-bar-add-item-from-menu
2133 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2134 (tool-bar-add-item-from-menu
2135 'gnus-summary-post-news "post" gnus-summary-mode-map)
2136 (tool-bar-add-item-from-menu
2137 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2138 (tool-bar-add-item-from-menu
2139 'gnus-summary-followup "followup" gnus-summary-mode-map)
2140 (tool-bar-add-item-from-menu
2141 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2142 (tool-bar-add-item-from-menu
2143 'gnus-summary-reply "reply" gnus-summary-mode-map)
2144 (tool-bar-add-item-from-menu
2145 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2146 (tool-bar-add-item-from-menu
2147 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2148 (tool-bar-add-item-from-menu
2149 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2150 (tool-bar-add-item-from-menu
2151 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2152 (tool-bar-add-item-from-menu
2153 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2154 (tool-bar-add-item-from-menu
2155 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2156 (tool-bar-add-item-from-menu
2157 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2158 (tool-bar-add-item-from-menu
2159 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2161 (if gnus-summary-tool-bar-map
2162 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2164 (defun gnus-score-set-default (var value)
2165 "A version of set that updates the GNU Emacs menu-bar."
2167 ;; It is the message that forces the active status to be updated.
2170 (defun gnus-make-score-map (type)
2171 "Make a summary score map of type TYPE."
2174 (let ((headers '(("author" "from" string)
2175 ("subject" "subject" string)
2176 ("article body" "body" string)
2177 ("article head" "head" string)
2178 ("xref" "xref" string)
2179 ("extra header" "extra" string)
2180 ("lines" "lines" number)
2181 ("followups to author" "followup" string)))
2182 (types '((number ("less than" <)
2185 (string ("substring" s)
2189 (perms '(("temporary" (current-time-string))
2197 (if (eq type 'lower)
2202 (setq header (car headers))
2208 (let ((ts (cdr (assoc (nth 2 header) types)))
2224 'gnus-summary-score-entry
2226 (if (or (string= (nth 1 header)
2228 (string= (nth 1 header)
2231 (list 'gnus-summary-header
2233 (list 'quote (nth 1 (car ts)))
2234 (list 'gnus-score-delta-default
2241 (list (nreverse outp))))
2244 (list (nreverse outt))))
2246 (setq headers (cdr headers)))
2247 (list (nreverse outh))))))))
2251 (defun gnus-summary-mode (&optional group)
2252 "Major mode for reading articles.
2254 All normal editing commands are switched off.
2255 \\<gnus-summary-mode-map>
2256 Each line in this buffer represents one article. To read an
2257 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2258 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2261 You can also post articles and send mail from this buffer. To
2262 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2263 of an article, type `\\[gnus-summary-reply]'.
2265 There are approx. one gazillion commands you can execute in this
2266 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2268 The following commands are available:
2270 \\{gnus-summary-mode-map}"
2272 (kill-all-local-variables)
2273 (when (gnus-visual-p 'summary-menu 'menu)
2274 (gnus-summary-make-menu-bar)
2275 (gnus-summary-make-tool-bar))
2276 (gnus-summary-make-local-variables)
2277 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2278 (gnus-summary-make-local-variables))
2279 (gnus-make-thread-indent-array)
2280 (gnus-simplify-mode-line)
2281 (setq major-mode 'gnus-summary-mode)
2282 (setq mode-name "Summary")
2283 (make-local-variable 'minor-mode-alist)
2284 (use-local-map gnus-summary-mode-map)
2285 (buffer-disable-undo)
2286 (setq buffer-read-only t) ;Disable modification
2287 (setq truncate-lines t)
2288 (setq selective-display t)
2289 (setq selective-display-ellipses t) ;Display `...'
2290 (gnus-summary-set-display-table)
2291 (gnus-set-default-directory)
2292 (setq gnus-newsgroup-name group)
2293 (make-local-variable 'gnus-summary-line-format)
2294 (make-local-variable 'gnus-summary-line-format-spec)
2295 (make-local-variable 'gnus-summary-dummy-line-format)
2296 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2297 (make-local-variable 'gnus-summary-mark-positions)
2298 (make-local-hook 'pre-command-hook)
2299 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2300 (gnus-run-hooks 'gnus-summary-mode-hook)
2301 (turn-on-gnus-mailing-list-mode)
2302 (mm-enable-multibyte-mule4)
2303 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2304 (gnus-update-summary-mark-positions))
2306 (defun gnus-summary-make-local-variables ()
2307 "Make all the local summary buffer variables."
2309 (dolist (local gnus-summary-local-variables)
2312 (if (eq (cdr local) 'global)
2313 ;; Copy the global value of the variable.
2314 (setq global (symbol-value (car local)))
2315 ;; Use the value from the list.
2316 (setq global (eval (cdr local))))
2317 (set (make-local-variable (car local)) global))
2318 ;; Simple nil-valued local variable.
2319 (set (make-local-variable local) nil)))))
2321 (defun gnus-summary-clear-local-variables ()
2322 (let ((locals gnus-summary-local-variables))
2324 (if (consp (car locals))
2325 (and (vectorp (caar locals))
2326 (set (caar locals) nil))
2327 (and (vectorp (car locals))
2328 (set (car locals) nil)))
2329 (setq locals (cdr locals)))))
2331 ;; Summary data functions.
2333 (defmacro gnus-data-number (data)
2336 (defmacro gnus-data-set-number (data number)
2337 `(setcar ,data ,number))
2339 (defmacro gnus-data-mark (data)
2342 (defmacro gnus-data-set-mark (data mark)
2343 `(setcar (nthcdr 1 ,data) ,mark))
2345 (defmacro gnus-data-pos (data)
2348 (defmacro gnus-data-set-pos (data pos)
2349 `(setcar (nthcdr 2 ,data) ,pos))
2351 (defmacro gnus-data-header (data)
2354 (defmacro gnus-data-set-header (data header)
2355 `(setf (nth 3 ,data) ,header))
2357 (defmacro gnus-data-level (data)
2360 (defmacro gnus-data-unread-p (data)
2361 `(= (nth 1 ,data) gnus-unread-mark))
2363 (defmacro gnus-data-read-p (data)
2364 `(/= (nth 1 ,data) gnus-unread-mark))
2366 (defmacro gnus-data-pseudo-p (data)
2367 `(consp (nth 3 ,data)))
2369 (defmacro gnus-data-find (number)
2370 `(assq ,number gnus-newsgroup-data))
2372 (defmacro gnus-data-find-list (number &optional data)
2373 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2374 (memq (assq ,number bdata)
2377 (defmacro gnus-data-make (number mark pos header level)
2378 `(list ,number ,mark ,pos ,header ,level))
2380 (defun gnus-data-enter (after-article number mark pos header level offset)
2381 (let ((data (gnus-data-find-list after-article)))
2383 (error "No such article: %d" after-article))
2384 (setcdr data (cons (gnus-data-make number mark pos header level)
2386 (setq gnus-newsgroup-data-reverse nil)
2387 (gnus-data-update-list (cddr data) offset)))
2389 (defun gnus-data-enter-list (after-article list &optional offset)
2391 (let ((data (and after-article (gnus-data-find-list after-article)))
2395 (let ((odata gnus-newsgroup-data))
2396 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2398 (gnus-data-update-list odata offset)))
2399 ;; Find the last element in the list to be spliced into the main
2402 (setq list (cdr list)))
2405 (setcdr list gnus-newsgroup-data)
2406 (setq gnus-newsgroup-data ilist)
2408 (gnus-data-update-list (cdr list) offset)))
2409 (setcdr list (cdr data))
2412 (gnus-data-update-list (cdr list) offset))))
2413 (setq gnus-newsgroup-data-reverse nil))))
2415 (defun gnus-data-remove (article &optional offset)
2416 (let ((data gnus-newsgroup-data))
2417 (if (= (gnus-data-number (car data)) article)
2419 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2420 gnus-newsgroup-data-reverse nil)
2422 (gnus-data-update-list gnus-newsgroup-data offset)))
2424 (when (= (gnus-data-number (cadr data)) article)
2425 (setcdr data (cddr data))
2427 (gnus-data-update-list (cdr data) offset))
2429 gnus-newsgroup-data-reverse nil))
2430 (setq data (cdr data))))))
2432 (defmacro gnus-data-list (backward)
2434 (or gnus-newsgroup-data-reverse
2435 (setq gnus-newsgroup-data-reverse
2436 (reverse gnus-newsgroup-data)))
2437 gnus-newsgroup-data))
2439 (defun gnus-data-update-list (data offset)
2440 "Add OFFSET to the POS of all data entries in DATA."
2441 (setq gnus-newsgroup-data-reverse nil)
2443 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2444 (setq data (cdr data))))
2446 (defun gnus-summary-article-pseudo-p (article)
2447 "Say whether this article is a pseudo article or not."
2448 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2450 (defmacro gnus-summary-article-sparse-p (article)
2451 "Say whether this article is a sparse article or not."
2452 `(memq ,article gnus-newsgroup-sparse))
2454 (defmacro gnus-summary-article-ancient-p (article)
2455 "Say whether this article is a sparse article or not."
2456 `(memq ,article gnus-newsgroup-ancient))
2458 (defun gnus-article-parent-p (number)
2459 "Say whether this article is a parent or not."
2460 (let ((data (gnus-data-find-list number)))
2461 (and (cdr data) ; There has to be an article after...
2462 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2463 (gnus-data-level (nth 1 data))))))
2465 (defun gnus-article-children (number)
2466 "Return a list of all children to NUMBER."
2467 (let* ((data (gnus-data-find-list number))
2468 (level (gnus-data-level (car data)))
2470 (setq data (cdr data))
2472 (= (gnus-data-level (car data)) (1+ level)))
2473 (push (gnus-data-number (car data)) children)
2474 (setq data (cdr data)))
2477 (defmacro gnus-summary-skip-intangible ()
2478 "If the current article is intangible, then jump to a different article."
2479 '(let ((to (get-text-property (point) 'gnus-intangible)))
2480 (and to (gnus-summary-goto-subject to))))
2482 (defmacro gnus-summary-article-intangible-p ()
2483 "Say whether this article is intangible or not."
2484 '(get-text-property (point) 'gnus-intangible))
2486 (defun gnus-article-read-p (article)
2487 "Say whether ARTICLE is read or not."
2488 (not (or (memq article gnus-newsgroup-marked)
2489 (memq article gnus-newsgroup-unreads)
2490 (memq article gnus-newsgroup-unselected)
2491 (memq article gnus-newsgroup-dormant))))
2493 ;; Some summary mode macros.
2495 (defmacro gnus-summary-article-number ()
2496 "The article number of the article on the current line.
2497 If there isn's an article number here, then we return the current
2500 (gnus-summary-skip-intangible)
2501 (or (get-text-property (point) 'gnus-number)
2502 (gnus-summary-last-subject))))
2504 (defmacro gnus-summary-article-header (&optional number)
2505 "Return the header of article NUMBER."
2506 `(gnus-data-header (gnus-data-find
2507 ,(or number '(gnus-summary-article-number)))))
2509 (defmacro gnus-summary-thread-level (&optional number)
2510 "Return the level of thread that starts with article NUMBER."
2511 `(if (and (eq gnus-summary-make-false-root 'dummy)
2512 (get-text-property (point) 'gnus-intangible))
2514 (gnus-data-level (gnus-data-find
2515 ,(or number '(gnus-summary-article-number))))))
2517 (defmacro gnus-summary-article-mark (&optional number)
2518 "Return the mark of article NUMBER."
2519 `(gnus-data-mark (gnus-data-find
2520 ,(or number '(gnus-summary-article-number)))))
2522 (defmacro gnus-summary-article-pos (&optional number)
2523 "Return the position of the line of article NUMBER."
2524 `(gnus-data-pos (gnus-data-find
2525 ,(or number '(gnus-summary-article-number)))))
2527 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2528 (defmacro gnus-summary-article-subject (&optional number)
2529 "Return current subject string or nil if nothing."
2532 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2533 '(gnus-data-header (assq (gnus-summary-article-number)
2534 gnus-newsgroup-data)))))
2537 (mail-header-subject headers))))
2539 (defmacro gnus-summary-article-score (&optional number)
2540 "Return current article score."
2541 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2542 gnus-newsgroup-scored))
2543 gnus-summary-default-score 0))
2545 (defun gnus-summary-article-children (&optional number)
2546 "Return a list of article numbers that are children of article NUMBER."
2547 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2548 (level (gnus-data-level (car data)))
2550 (while (and (setq data (cdr data))
2551 (> (setq l (gnus-data-level (car data))) level))
2552 (and (= (1+ level) l)
2553 (push (gnus-data-number (car data))
2555 (nreverse children)))
2557 (defun gnus-summary-article-parent (&optional number)
2558 "Return the article number of the parent of article NUMBER."
2559 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2560 (gnus-data-list t)))
2561 (level (gnus-data-level (car data))))
2563 () ; This is a root.
2564 ;; We search until we find an article with a level less than
2565 ;; this one. That function has to be the parent.
2566 (while (and (setq data (cdr data))
2567 (not (< (gnus-data-level (car data)) level))))
2568 (and data (gnus-data-number (car data))))))
2570 (defun gnus-unread-mark-p (mark)
2571 "Say whether MARK is the unread mark."
2572 (= mark gnus-unread-mark))
2574 (defun gnus-read-mark-p (mark)
2575 "Say whether MARK is one of the marks that mark as read.
2576 This is all marks except unread, ticked, dormant, and expirable."
2577 (not (or (= mark gnus-unread-mark)
2578 (= mark gnus-ticked-mark)
2579 (= mark gnus-dormant-mark)
2580 (= mark gnus-expirable-mark))))
2582 (defmacro gnus-article-mark (number)
2583 "Return the MARK of article NUMBER.
2584 This macro should only be used when computing the mark the \"first\"
2585 time; i.e., when generating the summary lines. After that,
2586 `gnus-summary-article-mark' should be used to examine the
2589 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2590 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2591 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2592 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2593 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2594 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2595 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2596 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2597 gnus-ancient-mark))))
2599 ;; Saving hidden threads.
2601 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2602 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2604 (defmacro gnus-save-hidden-threads (&rest forms)
2605 "Save hidden threads, eval FORMS, and restore the hidden threads."
2606 (let ((config (make-symbol "config")))
2607 `(let ((,config (gnus-hidden-threads-configuration)))
2611 (gnus-restore-hidden-threads-configuration ,config)))))
2613 (defun gnus-data-compute-positions ()
2614 "Compute the positions of all articles."
2615 (setq gnus-newsgroup-data-reverse nil)
2616 (let ((data gnus-newsgroup-data))
2618 (gnus-save-hidden-threads
2619 (gnus-summary-show-all-threads)
2620 (goto-char (point-min))
2622 (while (get-text-property (point) 'gnus-intangible)
2624 (gnus-data-set-pos (car data) (+ (point) 3))
2625 (setq data (cdr data))
2626 (forward-line 1))))))
2628 (defun gnus-hidden-threads-configuration ()
2629 "Return the current hidden threads configuration."
2632 (goto-char (point-min))
2633 (while (search-forward "\r" nil t)
2634 (push (1- (point)) config))
2637 (defun gnus-restore-hidden-threads-configuration (config)
2638 "Restore hidden threads configuration from CONFIG."
2640 (let (point buffer-read-only)
2641 (while (setq point (pop config))
2642 (when (and (< point (point-max))
2644 (eq (char-after) ?\n))
2645 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2647 ;; Various summary mode internalish functions.
2649 (defun gnus-mouse-pick-article (e)
2652 (gnus-summary-next-page nil t))
2654 (defun gnus-summary-set-display-table ()
2655 "Change the display table.
2656 Odd characters have a tendency to mess
2657 up nicely formatted displays - we make all possible glyphs
2658 display only a single character."
2660 ;; We start from the standard display table, if any.
2661 (let ((table (or (copy-sequence standard-display-table)
2662 (make-display-table)))
2664 ;; Nix out all the control chars...
2665 (while (>= (setq i (1- i)) 0)
2666 (aset table i [??]))
2667 ;; ... but not newline and cr, of course. (cr is necessary for the
2668 ;; selective display).
2669 (aset table ?\n nil)
2670 (aset table ?\r nil)
2671 ;; We keep TAB as well.
2672 (aset table ?\t nil)
2673 ;; We nix out any glyphs over 126 that are not set already.
2675 (while (>= (setq i (1- i)) 127)
2676 ;; Only modify if the entry is nil.
2677 (unless (aref table i)
2678 (aset table i [??]))))
2679 (setq buffer-display-table table)))
2681 (defun gnus-summary-buffer-name (group)
2682 "Return the summary buffer name of GROUP."
2683 (concat "*Summary " group "*"))
2685 (defun gnus-summary-setup-buffer (group)
2686 "Initialize summary buffer."
2687 (let ((buffer (gnus-summary-buffer-name group)))
2688 (if (get-buffer buffer)
2691 (setq gnus-summary-buffer (current-buffer))
2692 (not gnus-newsgroup-prepared))
2693 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2694 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2695 (gnus-summary-mode group)
2697 (gnus-carpal-setup-buffer 'summary))
2698 (unless gnus-single-article-buffer
2699 (make-local-variable 'gnus-article-buffer)
2700 (make-local-variable 'gnus-article-current)
2701 (make-local-variable 'gnus-original-article-buffer))
2702 (setq gnus-newsgroup-name group)
2703 ;; Set any local variables in the group parameters.
2704 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2707 (defun gnus-set-global-variables ()
2708 "Set the global equivalents of the buffer-local variables.
2709 They are set to the latest values they had. These reflect the summary
2710 buffer that was in action when the last article was fetched."
2711 (when (eq major-mode 'gnus-summary-mode)
2712 (setq gnus-summary-buffer (current-buffer))
2713 (let ((name gnus-newsgroup-name)
2714 (marked gnus-newsgroup-marked)
2715 (unread gnus-newsgroup-unreads)
2716 (headers gnus-current-headers)
2717 (data gnus-newsgroup-data)
2718 (summary gnus-summary-buffer)
2719 (article-buffer gnus-article-buffer)
2720 (original gnus-original-article-buffer)
2721 (gac gnus-article-current)
2722 (reffed gnus-reffed-article-number)
2723 (score-file gnus-current-score-file)
2724 (default-charset gnus-newsgroup-charset)
2726 (let ((locals gnus-newsgroup-variables))
2728 (if (consp (car locals))
2729 (push (eval (caar locals)) vlist)
2730 (push (eval (car locals)) vlist))
2731 (setq locals (cdr locals)))
2732 (setq vlist (nreverse vlist)))
2734 (set-buffer gnus-group-buffer)
2735 (setq gnus-newsgroup-name name
2736 gnus-newsgroup-marked marked
2737 gnus-newsgroup-unreads unread
2738 gnus-current-headers headers
2739 gnus-newsgroup-data data
2740 gnus-article-current gac
2741 gnus-summary-buffer summary
2742 gnus-article-buffer article-buffer
2743 gnus-original-article-buffer original
2744 gnus-reffed-article-number reffed
2745 gnus-current-score-file score-file
2746 gnus-newsgroup-charset default-charset)
2747 (let ((locals gnus-newsgroup-variables))
2749 (if (consp (car locals))
2750 (set (caar locals) (pop vlist))
2751 (set (car locals) (pop vlist)))
2752 (setq locals (cdr locals))))
2753 ;; The article buffer also has local variables.
2754 (when (gnus-buffer-live-p gnus-article-buffer)
2755 (set-buffer gnus-article-buffer)
2756 (setq gnus-summary-buffer summary))))))
2758 (defun gnus-summary-article-unread-p (article)
2759 "Say whether ARTICLE is unread or not."
2760 (memq article gnus-newsgroup-unreads))
2762 (defun gnus-summary-first-article-p (&optional article)
2763 "Return whether ARTICLE is the first article in the buffer."
2764 (if (not (setq article (or article (gnus-summary-article-number))))
2766 (eq article (caar gnus-newsgroup-data))))
2768 (defun gnus-summary-last-article-p (&optional article)
2769 "Return whether ARTICLE is the last article in the buffer."
2770 (if (not (setq article (or article (gnus-summary-article-number))))
2771 ;; All non-existent numbers are the last article. :-)
2773 (not (cdr (gnus-data-find-list article)))))
2775 (defun gnus-make-thread-indent-array ()
2777 (unless (and gnus-thread-indent-array
2778 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2779 (setq gnus-thread-indent-array (make-vector 201 "")
2780 gnus-thread-indent-array-level gnus-thread-indent-level)
2782 (aset gnus-thread-indent-array n
2783 (make-string (* n gnus-thread-indent-level) ? ))
2786 (defun gnus-update-summary-mark-positions ()
2787 "Compute where the summary marks are to go."
2789 (when (gnus-buffer-exists-p gnus-summary-buffer)
2790 (set-buffer gnus-summary-buffer))
2791 (let ((gnus-replied-mark 129)
2792 (gnus-score-below-mark 130)
2793 (gnus-score-over-mark 130)
2794 (gnus-download-mark 131)
2795 (spec gnus-summary-line-format-spec)
2798 (gnus-set-work-buffer)
2799 (let ((gnus-summary-line-format-spec spec)
2800 (gnus-newsgroup-downloadable '((0 . t))))
2801 (gnus-summary-insert-line
2802 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2803 0 nil 128 t nil "" nil 1)
2804 (goto-char (point-min))
2805 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2807 (goto-char (point-min))
2808 (push (cons 'replied (and (search-forward "\201" nil t)
2811 (goto-char (point-min))
2812 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2814 (goto-char (point-min))
2815 (push (cons 'download
2816 (and (search-forward "\203" nil t) (- (point) 2)))
2818 (setq gnus-summary-mark-positions pos))))
2820 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2821 "Insert a dummy root in the summary buffer."
2823 (gnus-add-text-properties
2824 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2825 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2827 (defun gnus-summary-from-or-to-or-newsgroups (header)
2828 (let ((to (cdr (assq 'To (mail-header-extra header))))
2829 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2830 (mail-parse-charset gnus-newsgroup-charset)
2831 (mail-parse-ignored-charsets
2832 (save-excursion (set-buffer gnus-summary-buffer)
2833 gnus-newsgroup-ignored-charsets)))
2836 gnus-ignored-from-addresses
2837 (string-match gnus-ignored-from-addresses
2838 (mail-header-from header)))
2840 (or (car (funcall gnus-extract-address-components
2842 gnus-decode-encoded-word-function to)))
2843 (funcall gnus-decode-encoded-word-function to))))
2845 gnus-ignored-from-addresses
2846 (string-match gnus-ignored-from-addresses
2847 (mail-header-from header)))
2848 (concat "=> " newsgroups))
2850 (or (car (funcall gnus-extract-address-components
2851 (mail-header-from header)))
2852 (mail-header-from header))))))
2854 (defun gnus-summary-insert-line (gnus-tmp-header
2855 gnus-tmp-level gnus-tmp-current
2856 gnus-tmp-unread gnus-tmp-replied
2857 gnus-tmp-expirable gnus-tmp-subject-or-nil
2858 &optional gnus-tmp-dummy gnus-tmp-score
2860 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2861 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2862 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2863 (gnus-tmp-score-char
2864 (if (or (null gnus-summary-default-score)
2865 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2866 gnus-summary-zcore-fuzz))
2868 (if (< gnus-tmp-score gnus-summary-default-score)
2869 gnus-score-below-mark gnus-score-over-mark)))
2871 (cond (gnus-tmp-process gnus-process-mark)
2872 ((memq gnus-tmp-current gnus-newsgroup-cached)
2874 (gnus-tmp-replied gnus-replied-mark)
2875 ((memq gnus-tmp-current gnus-newsgroup-saved)
2878 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2881 ((string-match "<[^>]+> *$" gnus-tmp-from)
2882 (let ((beg (match-beginning 0)))
2883 (or (and (string-match "^\".+\"" gnus-tmp-from)
2884 (substring gnus-tmp-from 1 (1- (match-end 0))))
2885 (substring gnus-tmp-from 0 beg))))
2886 ((string-match "(.+)" gnus-tmp-from)
2887 (substring gnus-tmp-from
2888 (1+ (match-beginning 0)) (1- (match-end 0))))
2890 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2891 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2892 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2893 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2894 (buffer-read-only nil))
2895 (when (string= gnus-tmp-name "")
2896 (setq gnus-tmp-name gnus-tmp-from))
2897 (unless (numberp gnus-tmp-lines)
2898 (setq gnus-tmp-lines -1))
2899 (when (= gnus-tmp-lines -1)
2900 (setq gnus-tmp-lines "?"))
2901 (gnus-put-text-property
2903 (progn (eval gnus-summary-line-format-spec) (point))
2904 'gnus-number gnus-tmp-number)
2905 (when (gnus-visual-p 'summary-highlight 'highlight)
2907 (gnus-run-hooks 'gnus-summary-update-hook)
2910 (defun gnus-summary-update-line (&optional dont-update)
2911 "Update summary line after change."
2912 (when (and gnus-summary-default-score
2913 (not gnus-summary-inhibit-highlight))
2914 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2915 (article (gnus-summary-article-number))
2916 (score (gnus-summary-article-score article)))
2918 (if (and gnus-summary-mark-below
2919 (< (gnus-summary-article-score)
2920 gnus-summary-mark-below))
2921 ;; This article has a low score, so we mark it as read.
2922 (when (memq article gnus-newsgroup-unreads)
2923 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2924 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2925 ;; This article was previously marked as read on account
2926 ;; of a low score, but now it has risen, so we mark it as
2928 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2929 (gnus-summary-update-mark
2930 (if (or (null gnus-summary-default-score)
2931 (<= (abs (- score gnus-summary-default-score))
2932 gnus-summary-zcore-fuzz))
2934 (if (< score gnus-summary-default-score)
2935 gnus-score-below-mark gnus-score-over-mark))
2937 ;; Do visual highlighting.
2938 (when (gnus-visual-p 'summary-highlight 'highlight)
2939 (gnus-run-hooks 'gnus-summary-update-hook)))))
2941 (defvar gnus-tmp-new-adopts nil)
2943 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2944 "Return the number of articles in THREAD.
2945 This may be 0 in some cases -- if none of the articles in
2946 the thread are to be displayed."
2948 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2950 ((not (listp thread))
2952 ((and (consp thread) (cdr thread))
2955 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2958 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2961 (when (and level (zerop level) gnus-tmp-new-adopts)
2964 'gnus-summary-number-of-articles-in-thread
2965 gnus-tmp-new-adopts))))
2967 (if (> number 1) gnus-not-empty-thread-mark
2968 gnus-empty-thread-mark)
2971 (defun gnus-summary-set-local-parameters (group)
2972 "Go through the local params of GROUP and set all variable specs in that list."
2973 (let ((params (gnus-group-find-parameter group))
2976 (setq elem (car params)
2977 params (cdr params))
2978 (and (consp elem) ; Has to be a cons.
2979 (consp (cdr elem)) ; The cdr has to be a list.
2980 (symbolp (car elem)) ; Has to be a symbol in there.
2981 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2982 (ignore-errors ; So we set it.
2983 (make-local-variable (car elem))
2984 (set (car elem) (eval (nth 1 elem))))))))
2986 (defun gnus-summary-read-group (group &optional show-all no-article
2987 kill-buffer no-display backward
2989 "Start reading news in newsgroup GROUP.
2990 If SHOW-ALL is non-nil, already read articles are also listed.
2991 If NO-ARTICLE is non-nil, no article is selected initially.
2992 If NO-DISPLAY, don't generate a summary buffer."
2996 (let ((gnus-auto-select-next nil))
2997 (or (gnus-summary-read-group-1
2998 group show-all no-article
2999 kill-buffer no-display
3002 select-articles nil)))))
3003 (eq gnus-auto-select-next 'quietly))
3004 (set-buffer gnus-group-buffer)
3005 ;; The entry function called above goes to the next
3006 ;; group automatically, so we go two groups back
3007 ;; if we are searching for the previous group.
3009 (gnus-group-prev-unread-group 2))
3010 (if (not (equal group (gnus-group-group-name)))
3011 (setq group (gnus-group-group-name))
3015 (defun gnus-summary-read-group-1 (group show-all no-article
3016 kill-buffer no-display
3017 &optional select-articles)
3018 ;; Killed foreign groups can't be entered.
3019 ;; (when (and (not (gnus-group-native-p group))
3020 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3021 ;; (error "Dead non-native groups can't be entered"))
3022 (gnus-message 5 "Retrieving newsgroup: %s..."
3023 (gnus-group-decoded-name group))
3024 (let* ((new-group (gnus-summary-setup-buffer group))
3025 (quit-config (gnus-group-quit-config group))
3026 (did-select (and new-group (gnus-select-newsgroup
3027 group show-all select-articles))))
3029 ;; This summary buffer exists already, so we just select it.
3031 (gnus-set-global-variables)
3033 (gnus-kill-or-deaden-summary kill-buffer))
3034 (gnus-configure-windows 'summary 'force)
3035 (gnus-set-mode-line 'summary)
3036 (gnus-summary-position-point)
3039 ;; We couldn't select this group.
3041 (when (and (eq major-mode 'gnus-summary-mode)
3042 (not (equal (current-buffer) kill-buffer)))
3043 (kill-buffer (current-buffer))
3044 (if (not quit-config)
3046 ;; Update the info -- marks might need to be removed,
3048 (gnus-summary-update-info)
3049 (set-buffer gnus-group-buffer)
3050 (gnus-group-jump-to-group group)
3051 (gnus-group-next-unread-group 1))
3052 (gnus-handle-ephemeral-exit quit-config)))
3053 (let ((grpinfo (gnus-get-info group)))
3054 (if (null (gnus-info-read grpinfo))
3055 (gnus-message 3 "Group %s contains no messages"
3056 (gnus-group-decoded-name group))
3057 (gnus-message 3 "Can't select group")))
3059 ;; The user did a `C-g' while prompting for number of articles,
3060 ;; so we exit this group.
3061 ((eq did-select 'quit)
3062 (and (eq major-mode 'gnus-summary-mode)
3063 (not (equal (current-buffer) kill-buffer))
3064 (kill-buffer (current-buffer)))
3066 (gnus-kill-or-deaden-summary kill-buffer))
3067 (if (not quit-config)
3069 (set-buffer gnus-group-buffer)
3070 (gnus-group-jump-to-group group)
3071 (gnus-group-next-unread-group 1)
3072 (gnus-configure-windows 'group 'force))
3073 (gnus-handle-ephemeral-exit quit-config))
3074 ;; Finally signal the quit.
3076 ;; The group was successfully selected.
3078 (gnus-set-global-variables)
3079 ;; Save the active value in effect when the group was entered.
3080 (setq gnus-newsgroup-active
3082 (gnus-active gnus-newsgroup-name)))
3083 ;; You can change the summary buffer in some way with this hook.
3084 (gnus-run-hooks 'gnus-select-group-hook)
3085 (gnus-update-format-specifications
3086 nil 'summary 'summary-mode 'summary-dummy)
3087 (gnus-update-summary-mark-positions)
3088 ;; Do score processing.
3089 (when gnus-use-scoring
3090 (gnus-possibly-score-headers))
3091 ;; Check whether to fill in the gaps in the threads.
3092 (when gnus-build-sparse-threads
3093 (gnus-build-sparse-threads))
3094 ;; Find the initial limit.
3095 (if gnus-show-threads
3097 (let ((gnus-newsgroup-dormant nil))
3098 (gnus-summary-initial-limit show-all))
3099 (gnus-summary-initial-limit show-all))
3100 ;; When untreaded, all articles are always shown.
3101 (setq gnus-newsgroup-limit
3103 (lambda (header) (mail-header-number header))
3104 gnus-newsgroup-headers)))
3105 ;; Generate the summary buffer.
3107 (gnus-summary-prepare))
3108 (when gnus-use-trees
3109 (gnus-tree-open group)
3110 (setq gnus-summary-highlight-line-function
3111 'gnus-tree-highlight-article))
3112 ;; If the summary buffer is empty, but there are some low-scored
3113 ;; articles or some excluded dormants, we include these in the
3115 (when (and (zerop (buffer-size))
3117 (cond (gnus-newsgroup-dormant
3118 (gnus-summary-limit-include-dormant))
3119 ((and gnus-newsgroup-scored show-all)
3120 (gnus-summary-limit-include-expunged t))))
3121 ;; Function `gnus-apply-kill-file' must be called in this hook.
3122 (gnus-run-hooks 'gnus-apply-kill-hook)
3123 (if (and (zerop (buffer-size))
3126 ;; This newsgroup is empty.
3127 (gnus-summary-catchup-and-exit nil t)
3128 (gnus-message 6 "No unread news")
3130 (gnus-kill-or-deaden-summary kill-buffer))
3131 ;; Return nil from this function.
3133 ;; Hide conversation thread subtrees. We cannot do this in
3134 ;; gnus-summary-prepare-hook since kill processing may not
3135 ;; work with hidden articles.
3136 (and gnus-show-threads
3137 gnus-thread-hide-subtree
3138 (gnus-summary-hide-all-threads))
3140 (gnus-kill-or-deaden-summary kill-buffer))
3141 ;; Show first unread article if requested.
3142 (if (and (not no-article)
3144 gnus-newsgroup-unreads
3145 gnus-auto-select-first)
3147 (gnus-configure-windows 'summary)
3149 ((eq gnus-auto-select-first 'best)
3150 (gnus-summary-best-unread-article))
3151 ((eq gnus-auto-select-first t)
3152 (gnus-summary-first-unread-article))
3153 ((gnus-functionp gnus-auto-select-first)
3154 (funcall gnus-auto-select-first))))
3155 ;; Don't select any articles, just move point to the first
3156 ;; article in the group.
3157 (goto-char (point-min))
3158 (gnus-summary-position-point)
3159 (gnus-configure-windows 'summary 'force)
3160 (gnus-set-mode-line 'summary))
3161 (when (get-buffer-window gnus-group-buffer t)
3162 ;; Gotta use windows, because recenter does weird stuff if
3163 ;; the current buffer ain't the displayed window.
3164 (let ((owin (selected-window)))
3165 (select-window (get-buffer-window gnus-group-buffer t))
3166 (when (gnus-group-goto-group group)
3168 (select-window owin)))
3169 ;; Mark this buffer as "prepared".
3170 (setq gnus-newsgroup-prepared t)
3171 (gnus-run-hooks 'gnus-summary-prepared-hook)
3174 (defun gnus-summary-prepare ()
3175 "Generate the summary buffer."
3177 (let ((buffer-read-only nil))
3179 (setq gnus-newsgroup-data nil
3180 gnus-newsgroup-data-reverse nil)
3181 (gnus-run-hooks 'gnus-summary-generate-hook)
3182 ;; Generate the buffer, either with threads or without.
3183 (when gnus-newsgroup-headers
3184 (gnus-summary-prepare-threads
3185 (if gnus-show-threads
3186 (gnus-sort-gathered-threads
3187 (funcall gnus-summary-thread-gathering-function
3189 (gnus-cut-threads (gnus-make-threads)))))
3190 ;; Unthreaded display.
3191 (gnus-sort-articles gnus-newsgroup-headers))))
3192 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3193 ;; Call hooks for modifying summary buffer.
3194 (goto-char (point-min))
3195 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3197 (defsubst gnus-general-simplify-subject (subject)
3198 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3201 ;; Truncate the subject.
3202 (gnus-simplify-subject-functions
3203 (gnus-map-function gnus-simplify-subject-functions subject))
3204 ((numberp gnus-summary-gather-subject-limit)
3205 (setq subject (gnus-simplify-subject-re subject))
3206 (if (> (length subject) gnus-summary-gather-subject-limit)
3207 (substring subject 0 gnus-summary-gather-subject-limit)
3209 ;; Fuzzily simplify it.
3210 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3211 (gnus-simplify-subject-fuzzy subject))
3212 ;; Just remove the leading "Re:".
3214 (gnus-simplify-subject-re subject))))
3216 (if (and gnus-summary-gather-exclude-subject
3217 (string-match gnus-summary-gather-exclude-subject subject))
3218 nil ; This article shouldn't be gathered
3221 (defun gnus-summary-simplify-subject-query ()
3222 "Query where the respool algorithm would put this article."
3224 (gnus-summary-select-article)
3225 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3227 (defun gnus-gather-threads-by-subject (threads)
3228 "Gather threads by looking at Subject headers."
3229 (if (not gnus-summary-make-false-root)
3231 (let ((hashtb (gnus-make-hashtable 1024))
3234 subject hthread whole-subject)
3236 (setq subject (gnus-general-simplify-subject
3237 (setq whole-subject (mail-header-subject
3240 (if (setq hthread (gnus-gethash subject hashtb))
3242 ;; We enter a dummy root into the thread, if we
3243 ;; haven't done that already.
3244 (unless (stringp (caar hthread))
3245 (setcar hthread (list whole-subject (car hthread))))
3246 ;; We add this new gathered thread to this gathered
3248 (setcdr (car hthread)
3249 (nconc (cdar hthread) (list (car threads))))
3250 ;; Remove it from the list of threads.
3251 (setcdr prev (cdr threads))
3252 (setq threads prev))
3253 ;; Enter this thread into the hash table.
3254 (gnus-sethash subject threads hashtb)))
3256 (setq threads (cdr threads)))
3259 (defun gnus-gather-threads-by-references (threads)
3260 "Gather threads by looking at References headers."
3261 (let ((idhashtb (gnus-make-hashtable 1024))
3262 (thhashtb (gnus-make-hashtable 1024))
3265 ids references id gthread gid entered ref)
3267 (when (setq references (mail-header-references (caar threads)))
3268 (setq id (mail-header-id (caar threads))
3269 ids (gnus-split-references references)
3271 (while (setq ref (pop ids))
3272 (setq ids (delete ref ids))
3273 (if (not (setq gid (gnus-gethash ref idhashtb)))
3275 (gnus-sethash ref id idhashtb)
3276 (gnus-sethash id threads thhashtb))
3277 (setq gthread (gnus-gethash gid thhashtb))
3279 ;; We enter a dummy root into the thread, if we
3280 ;; haven't done that already.
3281 (unless (stringp (caar gthread))
3282 (setcar gthread (list (mail-header-subject (caar gthread))
3284 ;; We add this new gathered thread to this gathered
3286 (setcdr (car gthread)
3287 (nconc (cdar gthread) (list (car threads)))))
3288 ;; Add it into the thread hash table.
3289 (gnus-sethash id gthread thhashtb)
3291 ;; Remove it from the list of threads.
3292 (setcdr prev (cdr threads))
3293 (setq threads prev))))
3295 (setq threads (cdr threads)))
3298 (defun gnus-sort-gathered-threads (threads)
3299 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3300 (let ((result threads))
3302 (when (stringp (caar threads))
3303 (setcdr (car threads)
3304 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3305 (setq threads (cdr threads)))
3308 (defun gnus-thread-loop-p (root thread)
3309 "Say whether ROOT is in THREAD."
3310 (let ((stack (list thread))
3313 (while (setq thread (pop stack))
3314 (setq th (cdr thread))
3316 (not (eq (caar th) root)))
3319 ;; We have found a loop.
3321 (setcdr thread (delq (car th) (cdr thread)))
3322 (if (boundp (setq ref-dep (intern "none"
3323 gnus-newsgroup-dependencies)))
3324 (setcdr (symbol-value ref-dep)
3325 (nconc (cdr (symbol-value ref-dep))
3327 (set ref-dep (list nil (car th))))
3330 ;; Push all the subthreads onto the stack.
3331 (push (cdr thread) stack)))
3334 (defun gnus-make-threads ()
3335 "Go through the dependency hashtb and find the roots. Return all threads."
3337 (while (catch 'infloop
3340 ;; Deal with self-referencing References loops.
3341 (when (and (car (symbol-value refs))
3348 (car (symbol-value refs)) thread))
3349 (cdr (symbol-value refs)))))))
3352 (unless (car (symbol-value refs))
3353 ;; These threads do not refer back to any other articles,
3354 ;; so they're roots.
3355 (setq threads (append (cdr (symbol-value refs)) threads))))
3356 gnus-newsgroup-dependencies)))
3359 ;; Build the thread tree.
3360 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3361 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3363 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3364 if it was already present.
3366 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3367 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3368 Message-IDs will be renamed be renamed to a unique Message-ID before
3371 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3372 (let* ((id (mail-header-id header))
3373 (id-dep (and id (intern id dependencies)))
3374 ref ref-dep ref-header)
3375 ;; Enter this `header' in the `dependencies' table.
3379 ;; The first two cases do the normal part: enter a new `header'
3380 ;; in the `dependencies' table.
3381 ((not (boundp id-dep))
3382 (set id-dep (list header)))
3383 ((null (car (symbol-value id-dep)))
3384 (setcar (symbol-value id-dep) header))
3386 ;; From here the `header' was already present in the
3387 ;; `dependencies' table.
3389 ;; Overrides an existing entry;
3390 ;; just set the header part of the entry.
3391 (setcar (symbol-value id-dep) header))
3393 ;; Renames the existing `header' to a unique Message-ID.
3394 ((not gnus-summary-ignore-duplicates)
3395 ;; An article with this Message-ID has already been seen.
3396 ;; We rename the Message-ID.
3397 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3399 (mail-header-set-id header id))
3401 ;; The last case ignores an existing entry, except it adds any
3402 ;; additional Xrefs (in case the two articles came from different
3404 ;; Also sets `header' to `nil' meaning that the `dependencies'
3405 ;; table was *not* modified.
3407 (mail-header-set-xref
3408 (car (symbol-value id-dep))
3409 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3411 (or (mail-header-xref header) "")))
3415 ;; First check if that we are not creating a References loop.
3416 (setq ref (gnus-parent-id (mail-header-references header)))
3418 (setq ref-dep (intern-soft ref dependencies))
3420 (setq ref-header (car (symbol-value ref-dep))))
3421 (if (string= id ref)
3422 ;; Yuk! This is a reference loop. Make the article be a
3425 (mail-header-set-references (car (symbol-value id-dep)) "none")
3427 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3428 (setq ref (gnus-parent-id (mail-header-references header)))
3429 (setq ref-dep (intern (or ref "none") dependencies))
3430 (if (boundp ref-dep)
3431 (setcdr (symbol-value ref-dep)
3432 (nconc (cdr (symbol-value ref-dep))
3433 (list (symbol-value id-dep))))
3434 (set ref-dep (list nil (symbol-value id-dep)))))
3437 (defun gnus-build-sparse-threads ()
3438 (let ((headers gnus-newsgroup-headers)
3439 (mail-parse-charset gnus-newsgroup-charset)
3440 (gnus-summary-ignore-duplicates t)
3441 header references generation relations
3442 subject child end new-child date)
3443 ;; First we create an alist of generations/relations, where
3444 ;; generations is how much we trust the relation, and the relation
3446 (gnus-message 7 "Making sparse threads...")
3448 (nnheader-set-temp-buffer " *gnus sparse threads*")
3449 (while (setq header (pop headers))
3450 (when (and (setq references (mail-header-references header))
3451 (not (string= references "")))
3453 (setq child (mail-header-id header)
3454 subject (mail-header-subject header)
3455 date (mail-header-date header)
3457 (while (search-backward ">" nil t)
3458 (setq end (1+ (point)))
3459 (when (search-backward "<" nil t)
3460 (setq new-child (buffer-substring (point) end))
3461 (push (list (incf generation)
3462 child (setq child new-child)
3466 (push (list (1+ generation) child nil subject) relations))
3468 (kill-buffer (current-buffer)))
3469 ;; Sort over trustworthiness.
3472 (when (gnus-dependencies-add-header
3473 (make-full-mail-header
3474 gnus-reffed-article-number
3475 (nth 3 relation) "" (or (nth 4 relation) "")
3477 (or (nth 2 relation) "") 0 0 "")
3478 gnus-newsgroup-dependencies nil)
3479 (push gnus-reffed-article-number gnus-newsgroup-limit)
3480 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3481 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3482 gnus-newsgroup-reads)
3483 (decf gnus-reffed-article-number)))
3484 (sort relations 'car-less-than-car))
3485 (gnus-message 7 "Making sparse threads...done")))
3487 (defun gnus-build-old-threads ()
3488 ;; Look at all the articles that refer back to old articles, and
3489 ;; fetch the headers for the articles that aren't there. This will
3490 ;; build complete threads - if the roots haven't been expired by the
3492 (let ((mail-parse-charset gnus-newsgroup-charset)
3496 (when (not (car (symbol-value refs)))
3497 (setq heads (cdr (symbol-value refs)))
3499 (if (memq (mail-header-number (caar heads))
3500 gnus-newsgroup-dormant)
3501 (setq heads (cdr heads))
3502 (setq id (symbol-name refs))
3503 (while (and (setq id (gnus-build-get-header id))
3504 (not (car (gnus-id-to-thread id)))))
3505 (setq heads nil)))))
3506 gnus-newsgroup-dependencies)))
3508 ;; This function has to be called with point after the article number
3509 ;; on the beginning of the line.
3510 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3511 (let ((eol (gnus-point-at-eol))
3512 (buffer (current-buffer))
3515 ;; overview: [num subject from date id refs chars lines misc]
3518 (narrow-to-region (point) eol)
3523 (make-full-mail-header
3525 (funcall gnus-decode-encoded-word-function
3526 (nnheader-nov-field)) ; subject
3527 (funcall gnus-decode-encoded-word-function
3528 (nnheader-nov-field)) ; from
3529 (nnheader-nov-field) ; date
3530 (nnheader-nov-read-message-id) ; id
3531 (nnheader-nov-field) ; refs
3532 (nnheader-nov-read-integer) ; chars
3533 (nnheader-nov-read-integer) ; lines
3535 (if (looking-at "Xref: ")
3536 (goto-char (match-end 0)))
3537 (nnheader-nov-field)) ; Xref
3538 (nnheader-nov-parse-extra)))) ; extra
3542 (when gnus-alter-header-function
3543 (funcall gnus-alter-header-function header))
3544 (gnus-dependencies-add-header header dependencies force-new)))
3546 (defun gnus-build-get-header (id)
3547 "Look through the buffer of NOV lines and find the header to ID.
3548 Enter this line into the dependencies hash table, and return
3549 the id of the parent article (if any)."
3550 (let ((deps gnus-newsgroup-dependencies)
3554 (set-buffer nntp-server-buffer)
3555 (let ((case-fold-search nil))
3556 (goto-char (point-min))
3557 (while (and (not found)
3558 (search-forward id nil t))
3560 (setq found (looking-at
3561 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3562 (regexp-quote id))))
3563 (or found (beginning-of-line 2)))
3567 (setq header (gnus-nov-parse-line
3568 (read (current-buffer)) deps))
3569 (gnus-parent-id (mail-header-references header))))))
3571 (let ((number (mail-header-number header)))
3572 (push number gnus-newsgroup-limit)
3573 (push header gnus-newsgroup-headers)
3574 (if (memq number gnus-newsgroup-unselected)
3576 (push number gnus-newsgroup-unreads)
3577 (setq gnus-newsgroup-unselected
3578 (delq number gnus-newsgroup-unselected)))
3579 (push number gnus-newsgroup-ancient)))))))
3581 (defun gnus-build-all-threads ()
3582 "Read all the headers."
3583 (let ((gnus-summary-ignore-duplicates t)
3584 (mail-parse-charset gnus-newsgroup-charset)
3585 (dependencies gnus-newsgroup-dependencies)
3588 (set-buffer nntp-server-buffer)
3589 (let ((case-fold-search nil))
3590 (goto-char (point-min))
3593 (setq article (read (current-buffer))
3594 header (gnus-nov-parse-line article dependencies)))
3597 (set-buffer gnus-summary-buffer)
3598 (push header gnus-newsgroup-headers)
3599 (if (memq (setq article (mail-header-number header))
3600 gnus-newsgroup-unselected)
3602 (push article gnus-newsgroup-unreads)
3603 (setq gnus-newsgroup-unselected
3604 (delq article gnus-newsgroup-unselected)))
3605 (push article gnus-newsgroup-ancient)))
3606 (forward-line 1)))))))
3608 (defun gnus-summary-update-article-line (article header)
3609 "Update the line for ARTICLE using HEADERS."
3610 (let* ((id (mail-header-id header))
3611 (thread (gnus-id-to-thread id)))
3613 (error "Article in no thread"))
3614 ;; Update the thread.
3615 (setcar thread header)
3616 (gnus-summary-goto-subject article)
3617 (let* ((datal (gnus-data-find-list article))
3619 (length (when (cdr datal)
3620 (- (gnus-data-pos data)
3621 (gnus-data-pos (cadr datal)))))
3622 (buffer-read-only nil)
3623 (level (gnus-summary-thread-level)))
3625 (gnus-summary-insert-line
3626 header level nil (gnus-article-mark article)
3627 (memq article gnus-newsgroup-replied)
3628 (memq article gnus-newsgroup-expirable)
3629 ;; Only insert the Subject string when it's different
3630 ;; from the previous Subject string.
3635 (mail-header-subject
3638 (gnus-data-find-list
3640 (gnus-data-list t)))))
3641 ;; Error on the side of excessive subjects.
3643 (mail-header-subject header)))
3645 (mail-header-subject header))
3646 nil (cdr (assq article gnus-newsgroup-scored))
3647 (memq article gnus-newsgroup-processable))
3649 (gnus-data-update-list
3650 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3652 (defun gnus-summary-update-article (article &optional iheader)
3653 "Update ARTICLE in the summary buffer."
3654 (set-buffer gnus-summary-buffer)
3655 (let* ((header (gnus-summary-article-header article))
3656 (id (mail-header-id header))
3657 (data (gnus-data-find article))
3658 (thread (gnus-id-to-thread id))
3659 (references (mail-header-references header))
3663 (when (and references
3664 (not (equal "" references)))
3667 (buffer-read-only nil)
3673 (delq thread parent)))
3674 (if (gnus-summary-insert-subject id header)
3675 ;; Set the (possibly) new article number in the data structure.
3676 (gnus-data-set-number data (gnus-id-to-article id))
3680 (defun gnus-rebuild-thread (id &optional line)
3681 "Rebuild the thread containing ID.
3682 If LINE, insert the rebuilt thread starting on line LINE."
3683 (let ((buffer-read-only nil)
3684 old-pos current thread data)
3685 (if (not gnus-show-threads)
3686 (setq thread (list (car (gnus-id-to-thread id))))
3687 ;; Get the thread this article is part of.
3688 (setq thread (gnus-remove-thread id)))
3689 (setq old-pos (gnus-point-at-bol))
3690 (setq current (save-excursion
3691 (and (zerop (forward-line -1))
3692 (gnus-summary-article-number))))
3693 ;; If this is a gathered thread, we have to go some re-gathering.
3694 (when (stringp (car thread))
3695 (let ((subject (car thread))
3697 (setq thread (cdr thread))
3699 (unless (memq (setq thr (gnus-id-to-thread
3701 (mail-header-id (caar thread)))))
3704 (setq thread (cdr thread)))
3705 ;; We now have all (unique) roots.
3706 (if (= (length roots) 1)
3707 ;; All the loose roots are now one solid root.
3708 (setq thread (car roots))
3709 (setq thread (cons subject (gnus-sort-threads roots))))))
3711 ;; We then insert this thread into the summary buffer.
3713 (goto-char (point-min))
3714 (forward-line (1- line)))
3715 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3716 (if gnus-show-threads
3717 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3718 (gnus-summary-prepare-unthreaded thread))
3719 (setq data (nreverse gnus-newsgroup-data))
3720 (setq threads gnus-newsgroup-threads))
3721 ;; We splice the new data into the data structure.
3722 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3723 ;;!!! then we want to insert at the beginning of the buffer.
3724 ;;!!! That happens to be true with Gnus now, but that may
3725 ;;!!! change in the future. Perhaps.
3726 (gnus-data-enter-list
3727 (if line nil current) data (- (point) old-pos))
3728 (setq gnus-newsgroup-threads
3729 (nconc threads gnus-newsgroup-threads))
3730 (gnus-data-compute-positions))))
3732 (defun gnus-number-to-header (number)
3733 "Return the header for article NUMBER."
3734 (let ((headers gnus-newsgroup-headers))
3736 (not (= number (mail-header-number (car headers)))))
3741 (defun gnus-parent-headers (in-headers &optional generation)
3742 "Return the headers of the GENERATIONeth parent of HEADERS."
3744 (setq generation 1))
3746 (headers in-headers)
3749 (not (zerop generation))
3750 (setq references (mail-header-references headers)))
3751 (setq headers (if (and references
3752 (setq parent (gnus-parent-id references)))
3753 (car (gnus-id-to-thread parent))
3756 (and (not (eq headers in-headers))
3759 (defun gnus-id-to-thread (id)
3760 "Return the (sub-)thread where ID appears."
3761 (gnus-gethash id gnus-newsgroup-dependencies))
3763 (defun gnus-id-to-article (id)
3764 "Return the article number of ID."
3765 (let ((thread (gnus-id-to-thread id)))
3768 (mail-header-number (car thread)))))
3770 (defun gnus-id-to-header (id)
3771 "Return the article headers of ID."
3772 (car (gnus-id-to-thread id)))
3774 (defun gnus-article-displayed-root-p (article)
3775 "Say whether ARTICLE is a root(ish) article."
3776 (let ((level (gnus-summary-thread-level article))
3777 (refs (mail-header-references (gnus-summary-article-header article)))
3783 ((null (gnus-parent-id refs)) t)
3785 (null (setq particle (gnus-id-to-article
3786 (gnus-parent-id refs))))
3787 (null (gnus-summary-thread-level particle)))))))
3789 (defun gnus-root-id (id)
3790 "Return the id of the root of the thread where ID appears."
3792 (while (and id (setq prev (car (gnus-id-to-thread id))))
3794 id (gnus-parent-id (mail-header-references prev))))
3797 (defun gnus-articles-in-thread (thread)
3798 "Return the list of articles in THREAD."
3799 (cons (mail-header-number (car thread))
3800 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3802 (defun gnus-remove-thread (id &optional dont-remove)
3803 "Remove the thread that has ID in it."
3804 (let (headers thread last-id)
3805 ;; First go up in this thread until we find the root.
3806 (setq last-id (gnus-root-id id)
3807 headers (message-flatten-list (gnus-id-to-thread last-id)))
3808 ;; We have now found the real root of this thread. It might have
3809 ;; been gathered into some loose thread, so we have to search
3810 ;; through the threads to find the thread we wanted.
3811 (let ((threads gnus-newsgroup-threads)
3814 (setq sub (car threads))
3815 (if (stringp (car sub))
3816 ;; This is a gathered thread, so we look at the roots
3817 ;; below it to find whether this article is in this
3820 (setq sub (cdr sub))
3822 (when (member (caar sub) headers)
3823 (setq thread (car threads)
3826 (setq sub (cdr sub))))
3827 ;; It's an ordinary thread, so we check it.
3828 (when (eq (car sub) (car headers))
3831 (setq threads (cdr threads)))
3832 ;; If this article is in no thread, then it's a root.
3835 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3836 (setq thread (gnus-id-to-thread last-id)))
3839 thread ; We return this thread.
3841 (if (stringp (car thread))
3843 ;; If we use dummy roots, then we have to remove the
3844 ;; dummy root as well.
3845 (when (eq gnus-summary-make-false-root 'dummy)
3846 ;; We go to the dummy root by going to
3847 ;; the first sub-"thread", and then one line up.
3848 (gnus-summary-goto-article
3849 (mail-header-number (caadr thread)))
3852 (gnus-data-compute-positions))
3853 (setq thread (cdr thread))
3855 (gnus-remove-thread-1 (car thread))
3856 (setq thread (cdr thread))))
3857 (gnus-remove-thread-1 thread))))))))
3859 (defun gnus-remove-thread-1 (thread)
3860 "Remove the thread THREAD recursively."
3861 (let ((number (mail-header-number (pop thread)))
3863 (setq thread (reverse thread))
3865 (gnus-remove-thread-1 (pop thread)))
3866 (when (setq d (gnus-data-find number))
3867 (goto-char (gnus-data-pos d))
3868 (gnus-summary-show-thread)
3871 (- (gnus-point-at-bol)
3873 (1+ (gnus-point-at-eol))
3874 (gnus-delete-line)))))))
3876 (defun gnus-sort-threads-1 (threads func)
3877 (sort (mapcar (lambda (thread)
3880 (gnus-sort-threads-1 (cdr thread) func))))
3883 (defun gnus-sort-threads (threads)
3885 (if (not gnus-thread-sort-functions)
3887 (gnus-message 8 "Sorting threads...")
3889 (gnus-sort-threads-1
3891 (gnus-make-sort-function gnus-thread-sort-functions))
3892 (gnus-message 8 "Sorting threads...done"))))
3894 (defun gnus-sort-articles (articles)
3896 (when gnus-article-sort-functions
3897 (gnus-message 7 "Sorting articles...")
3899 (setq gnus-newsgroup-headers
3900 (sort articles (gnus-make-sort-function
3901 gnus-article-sort-functions)))
3902 (gnus-message 7 "Sorting articles...done"))))
3904 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3905 (defmacro gnus-thread-header (thread)
3906 "Return header of first article in THREAD.
3907 Note that THREAD must never, ever be anything else than a variable -
3908 using some other form will lead to serious barfage."
3909 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3910 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3911 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3914 (defsubst gnus-article-sort-by-number (h1 h2)
3915 "Sort articles by article number."
3916 (< (mail-header-number h1)
3917 (mail-header-number h2)))
3919 (defun gnus-thread-sort-by-number (h1 h2)
3920 "Sort threads by root article number."
3921 (gnus-article-sort-by-number
3922 (gnus-thread-header h1) (gnus-thread-header h2)))
3924 (defsubst gnus-article-sort-by-lines (h1 h2)
3925 "Sort articles by article Lines header."
3926 (< (mail-header-lines h1)
3927 (mail-header-lines h2)))
3929 (defun gnus-thread-sort-by-lines (h1 h2)
3930 "Sort threads by root article Lines header."
3931 (gnus-article-sort-by-lines
3932 (gnus-thread-header h1) (gnus-thread-header h2)))
3934 (defsubst gnus-article-sort-by-chars (h1 h2)
3935 "Sort articles by octet length."
3936 (< (mail-header-chars h1)
3937 (mail-header-chars h2)))
3939 (defun gnus-thread-sort-by-chars (h1 h2)
3940 "Sort threads by root article octet length."
3941 (gnus-article-sort-by-chars
3942 (gnus-thread-header h1) (gnus-thread-header h2)))
3944 (defsubst gnus-article-sort-by-author (h1 h2)
3945 "Sort articles by root author."
3947 (let ((extract (funcall
3948 gnus-extract-address-components
3949 (mail-header-from h1))))
3950 (or (car extract) (cadr extract) ""))
3951 (let ((extract (funcall
3952 gnus-extract-address-components
3953 (mail-header-from h2))))
3954 (or (car extract) (cadr extract) ""))))
3956 (defun gnus-thread-sort-by-author (h1 h2)
3957 "Sort threads by root author."
3958 (gnus-article-sort-by-author
3959 (gnus-thread-header h1) (gnus-thread-header h2)))
3961 (defsubst gnus-article-sort-by-subject (h1 h2)
3962 "Sort articles by root subject."
3964 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3965 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3967 (defun gnus-thread-sort-by-subject (h1 h2)
3968 "Sort threads by root subject."
3969 (gnus-article-sort-by-subject
3970 (gnus-thread-header h1) (gnus-thread-header h2)))
3972 (defsubst gnus-article-sort-by-date (h1 h2)
3973 "Sort articles by root article date."
3975 (gnus-date-get-time (mail-header-date h1))
3976 (gnus-date-get-time (mail-header-date h2))))
3978 (defun gnus-thread-sort-by-date (h1 h2)
3979 "Sort threads by root article date."
3980 (gnus-article-sort-by-date
3981 (gnus-thread-header h1) (gnus-thread-header h2)))
3983 (defsubst gnus-article-sort-by-score (h1 h2)
3984 "Sort articles by root article score.
3985 Unscored articles will be counted as having a score of zero."
3986 (> (or (cdr (assq (mail-header-number h1)
3987 gnus-newsgroup-scored))
3988 gnus-summary-default-score 0)
3989 (or (cdr (assq (mail-header-number h2)
3990 gnus-newsgroup-scored))
3991 gnus-summary-default-score 0)))
3993 (defun gnus-thread-sort-by-score (h1 h2)
3994 "Sort threads by root article score."
3995 (gnus-article-sort-by-score
3996 (gnus-thread-header h1) (gnus-thread-header h2)))
3998 (defun gnus-thread-sort-by-total-score (h1 h2)
3999 "Sort threads by the sum of all scores in the thread.
4000 Unscored articles will be counted as having a score of zero."
4001 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4003 (defun gnus-thread-total-score (thread)
4004 ;; This function find the total score of THREAD.
4005 (cond ((null thread)
4008 (if (stringp (car thread))
4009 (apply gnus-thread-score-function 0
4010 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4011 (gnus-thread-total-score-1 thread)))
4013 (gnus-thread-total-score-1 (list thread)))))
4015 (defun gnus-thread-total-score-1 (root)
4016 ;; This function find the total score of the thread below ROOT.
4017 (setq root (car root))
4018 (apply gnus-thread-score-function
4020 (mapcar 'gnus-thread-total-score
4021 (cdr (gnus-id-to-thread (mail-header-id root))))
4022 (when (> (mail-header-number root) 0)
4023 (list (or (cdr (assq (mail-header-number root)
4024 gnus-newsgroup-scored))
4025 gnus-summary-default-score 0))))
4026 (list gnus-summary-default-score)
4029 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4030 (defvar gnus-tmp-prev-subject nil)
4031 (defvar gnus-tmp-false-parent nil)
4032 (defvar gnus-tmp-root-expunged nil)
4033 (defvar gnus-tmp-dummy-line nil)
4035 (eval-when-compile (defvar gnus-tmp-header))
4036 (defun gnus-extra-header (type &optional header)
4037 "Return the extra header of TYPE."
4038 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4041 (defun gnus-summary-prepare-threads (threads)
4042 "Prepare summary buffer from THREADS and indentation LEVEL.
4043 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4044 or a straight list of headers."
4045 (gnus-message 7 "Generating summary...")
4047 (setq gnus-newsgroup-threads threads)
4050 (let ((gnus-tmp-level 0)
4051 (default-score (or gnus-summary-default-score 0))
4052 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4053 thread number subject stack state gnus-tmp-gathered beg-match
4054 new-roots gnus-tmp-new-adopts thread-end
4055 gnus-tmp-header gnus-tmp-unread
4056 gnus-tmp-replied gnus-tmp-subject-or-nil
4057 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4058 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4059 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4061 (setq gnus-tmp-prev-subject nil)
4063 (if (vectorp (car threads))
4064 ;; If this is a straight (sic) list of headers, then a
4065 ;; threaded summary display isn't required, so we just create
4066 ;; an unthreaded one.
4067 (gnus-summary-prepare-unthreaded threads)
4069 ;; Do the threaded display.
4071 (while (or threads stack gnus-tmp-new-adopts new-roots)
4073 (if (and (= gnus-tmp-level 0)
4076 (not gnus-tmp-false-parent)
4077 (or gnus-tmp-new-adopts new-roots))
4078 (if gnus-tmp-new-adopts
4079 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4080 thread (list (car gnus-tmp-new-adopts))
4081 gnus-tmp-header (caar thread)
4082 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4084 (setq thread (list (car new-roots))
4085 gnus-tmp-header (caar thread)
4086 new-roots (cdr new-roots))))
4089 ;; If there are some threads, we do them before the
4090 ;; threads on the stack.
4091 (setq thread threads
4092 gnus-tmp-header (caar thread))
4093 ;; There were no current threads, so we pop something off
4095 (setq state (car stack)
4096 gnus-tmp-level (car state)
4099 gnus-tmp-header (caar thread))))
4101 (setq gnus-tmp-false-parent nil)
4102 (setq gnus-tmp-root-expunged nil)
4103 (setq thread-end nil)
4105 (if (stringp gnus-tmp-header)
4106 ;; The header is a dummy root.
4108 ((eq gnus-summary-make-false-root 'adopt)
4109 ;; We let the first article adopt the rest.
4110 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4112 (setq gnus-tmp-gathered
4114 (lambda (h) (mail-header-number (car h)))
4117 (setq thread (cons (list (caar thread)
4120 (setq gnus-tmp-level -1
4121 gnus-tmp-false-parent t))
4122 ((eq gnus-summary-make-false-root 'empty)
4123 ;; We print adopted articles with empty subject fields.
4124 (setq gnus-tmp-gathered
4126 (lambda (h) (mail-header-number (car h)))
4129 (setq gnus-tmp-level -1))
4130 ((eq gnus-summary-make-false-root 'dummy)
4131 ;; We remember that we probably want to output a dummy
4133 (setq gnus-tmp-dummy-line gnus-tmp-header)
4134 (setq gnus-tmp-prev-subject gnus-tmp-header))
4136 ;; We do not make a root for the gathered
4137 ;; sub-threads at all.
4138 (setq gnus-tmp-level -1)))
4140 (setq number (mail-header-number gnus-tmp-header)
4141 subject (mail-header-subject gnus-tmp-header))
4144 ;; If the thread has changed subject, we might want to make
4145 ;; this subthread into a root.
4146 ((and (null gnus-thread-ignore-subject)
4147 (not (zerop gnus-tmp-level))
4148 gnus-tmp-prev-subject
4150 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4151 (setq new-roots (nconc new-roots (list (car thread)))
4153 gnus-tmp-header nil))
4154 ;; If the article lies outside the current limit,
4155 ;; then we do not display it.
4156 ((not (memq number gnus-newsgroup-limit))
4157 (setq gnus-tmp-gathered
4159 (lambda (h) (mail-header-number (car h)))
4162 (setq gnus-tmp-new-adopts (if (cdar thread)
4163 (append gnus-tmp-new-adopts
4165 gnus-tmp-new-adopts)
4167 gnus-tmp-header nil)
4168 (when (zerop gnus-tmp-level)
4169 (setq gnus-tmp-root-expunged t)))
4170 ;; Perhaps this article is to be marked as read?
4171 ((and gnus-summary-mark-below
4172 (< (or (cdr (assq number gnus-newsgroup-scored))
4174 gnus-summary-mark-below)
4175 ;; Don't touch sparse articles.
4176 (not (gnus-summary-article-sparse-p number))
4177 (not (gnus-summary-article-ancient-p number)))
4178 (setq gnus-newsgroup-unreads
4179 (delq number gnus-newsgroup-unreads))
4180 (if gnus-newsgroup-auto-expire
4181 (push number gnus-newsgroup-expirable)
4182 (push (cons number gnus-low-score-mark)
4183 gnus-newsgroup-reads))))
4185 (when gnus-tmp-header
4186 ;; We may have an old dummy line to output before this
4188 (when (and gnus-tmp-dummy-line
4191 (mail-header-subject gnus-tmp-header)))
4192 (gnus-summary-insert-dummy-line
4193 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4194 (setq gnus-tmp-dummy-line nil))
4196 ;; Compute the mark.
4197 (setq gnus-tmp-unread (gnus-article-mark number))
4199 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4200 gnus-tmp-header gnus-tmp-level)
4201 gnus-newsgroup-data)
4203 ;; Actually insert the line.
4205 gnus-tmp-subject-or-nil
4207 ((and gnus-thread-ignore-subject
4208 gnus-tmp-prev-subject
4209 (not (inline (gnus-subject-equal
4210 gnus-tmp-prev-subject subject))))
4212 ((zerop gnus-tmp-level)
4213 (if (and (eq gnus-summary-make-false-root 'empty)
4214 (memq number gnus-tmp-gathered)
4215 gnus-tmp-prev-subject
4216 (inline (gnus-subject-equal
4217 gnus-tmp-prev-subject subject)))
4218 gnus-summary-same-subject
4220 (t gnus-summary-same-subject)))
4221 (if (and (eq gnus-summary-make-false-root 'adopt)
4222 (= gnus-tmp-level 1)
4223 (memq number gnus-tmp-gathered))
4224 (setq gnus-tmp-opening-bracket ?\<
4225 gnus-tmp-closing-bracket ?\>)
4226 (setq gnus-tmp-opening-bracket ?\[
4227 gnus-tmp-closing-bracket ?\]))
4229 gnus-tmp-indentation
4230 (aref gnus-thread-indent-array gnus-tmp-level)
4231 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4232 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4233 gnus-summary-default-score 0)
4235 (if (or (null gnus-summary-default-score)
4236 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4237 gnus-summary-zcore-fuzz))
4239 (if (< gnus-tmp-score gnus-summary-default-score)
4240 gnus-score-below-mark gnus-score-over-mark))
4242 (cond ((memq number gnus-newsgroup-processable)
4244 ((memq number gnus-newsgroup-cached)
4246 ((memq number gnus-newsgroup-replied)
4248 ((memq number gnus-newsgroup-forwarded)
4249 gnus-forwarded-mark)
4250 ((memq number gnus-newsgroup-saved)
4253 gnus-tmp-from (mail-header-from gnus-tmp-header)
4256 ((string-match "<[^>]+> *$" gnus-tmp-from)
4257 (setq beg-match (match-beginning 0))
4258 (or (and (string-match "^\".+\"" gnus-tmp-from)
4259 (substring gnus-tmp-from 1 (1- (match-end 0))))
4260 (substring gnus-tmp-from 0 beg-match)))
4261 ((string-match "(.+)" gnus-tmp-from)
4262 (substring gnus-tmp-from
4263 (1+ (match-beginning 0)) (1- (match-end 0))))
4265 (when (string= gnus-tmp-name "")
4266 (setq gnus-tmp-name gnus-tmp-from))
4267 (unless (numberp gnus-tmp-lines)
4268 (setq gnus-tmp-lines -1))
4269 (when (= gnus-tmp-lines -1)
4270 (setq gnus-tmp-lines "?"))
4271 (gnus-put-text-property
4273 (progn (eval gnus-summary-line-format-spec) (point))
4274 'gnus-number number)
4277 (gnus-run-hooks 'gnus-summary-update-hook)
4280 (setq gnus-tmp-prev-subject subject)))
4282 (when (nth 1 thread)
4283 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4284 (incf gnus-tmp-level)
4285 (setq threads (if thread-end nil (cdar thread)))
4287 (setq gnus-tmp-level 0)))))
4288 (gnus-message 7 "Generating summary...done"))
4290 (defun gnus-summary-prepare-unthreaded (headers)
4291 "Generate an unthreaded summary buffer based on HEADERS."
4292 (let (header number mark)
4297 ;; We may have to root out some bad articles...
4298 (when (memq (setq number (mail-header-number
4299 (setq header (pop headers))))
4300 gnus-newsgroup-limit)
4301 ;; Mark article as read when it has a low score.
4302 (when (and gnus-summary-mark-below
4303 (< (or (cdr (assq number gnus-newsgroup-scored))
4304 gnus-summary-default-score 0)
4305 gnus-summary-mark-below)
4306 (not (gnus-summary-article-ancient-p number)))
4307 (setq gnus-newsgroup-unreads
4308 (delq number gnus-newsgroup-unreads))
4309 (if gnus-newsgroup-auto-expire
4310 (push number gnus-newsgroup-expirable)
4311 (push (cons number gnus-low-score-mark)
4312 gnus-newsgroup-reads)))
4314 (setq mark (gnus-article-mark number))
4315 (push (gnus-data-make number mark (1+ (point)) header 0)
4316 gnus-newsgroup-data)
4317 (gnus-summary-insert-line
4319 mark (memq number gnus-newsgroup-replied)
4320 (memq number gnus-newsgroup-expirable)
4321 (mail-header-subject header) nil
4322 (cdr (assq number gnus-newsgroup-scored))
4323 (memq number gnus-newsgroup-processable))))))
4325 (defun gnus-summary-remove-list-identifiers ()
4326 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4327 (let ((regexp (if (consp gnus-list-identifiers)
4328 (mapconcat 'identity gnus-list-identifiers " *\\|")
4329 gnus-list-identifiers))
4332 (dolist (header gnus-newsgroup-headers)
4333 (setq subject (mail-header-subject header)
4335 (while (string-match
4336 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4339 (concat (substring subject 0 (match-beginning 2))
4340 (substring subject (match-end 0)))
4344 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4346 (concat (substring subject 0 (match-beginning 1))
4347 (substring subject (match-end 1)))))
4349 (mail-header-set-subject header subject))))))
4351 (defun gnus-fetch-headers (articles)
4352 "Fetch headers of ARTICLES."
4353 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4354 (gnus-message 5 "Fetching headers for %s..." name)
4357 (setq gnus-headers-retrieved-by
4358 (gnus-retrieve-headers
4359 articles gnus-newsgroup-name
4360 ;; We might want to fetch old headers, but
4361 ;; not if there is only 1 article.
4363 (not (eq gnus-fetch-old-headers 'some))
4364 (not (numberp gnus-fetch-old-headers)))
4365 (> (length articles) 1))
4366 gnus-fetch-old-headers))))
4367 (gnus-get-newsgroup-headers-xover
4368 articles nil nil gnus-newsgroup-name t)
4369 (gnus-get-newsgroup-headers))
4370 (gnus-message 5 "Fetching headers for %s...done" name))))
4372 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4373 "Select newsgroup GROUP.
4374 If READ-ALL is non-nil, all articles in the group are selected.
4375 If SELECT-ARTICLES, only select those articles from GROUP."
4376 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4377 ;;!!! Dirty hack; should be removed.
4378 (gnus-summary-ignore-duplicates
4379 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4381 gnus-summary-ignore-duplicates))
4382 (info (nth 2 entry))
4383 articles fetched-articles cached)
4385 (unless (gnus-check-server
4386 (setq gnus-current-select-method
4387 (gnus-find-method-for-group group)))
4388 (error "Couldn't open server"))
4390 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4391 (gnus-activate-group group) ; Or we can activate it...
4392 (progn ; Or we bug out.
4393 (when (equal major-mode 'gnus-summary-mode)
4394 (kill-buffer (current-buffer)))
4395 (error "Couldn't activate group %s: %s"
4396 group (gnus-status-message group))))
4398 (unless (gnus-request-group group t)
4399 (when (equal major-mode 'gnus-summary-mode)
4400 (kill-buffer (current-buffer)))
4401 (error "Couldn't request group %s: %s"
4402 group (gnus-status-message group)))
4404 (setq gnus-newsgroup-name group)
4405 (setq gnus-newsgroup-unselected nil)
4406 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4407 (gnus-summary-setup-default-charset)
4409 ;; Adjust and set lists of article marks.
4411 (gnus-adjust-marked-articles info))
4413 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4414 (when (gnus-virtual-group-p group)
4415 (setq cached gnus-newsgroup-cached))
4417 (setq gnus-newsgroup-unreads
4418 (gnus-set-difference
4419 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4420 gnus-newsgroup-dormant))
4422 (setq gnus-newsgroup-processable nil)
4424 (gnus-update-read-articles group gnus-newsgroup-unreads)
4426 (if (setq articles select-articles)
4427 (setq gnus-newsgroup-unselected
4428 (gnus-sorted-intersection
4429 gnus-newsgroup-unreads
4430 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4431 (setq articles (gnus-articles-to-read group read-all)))
4435 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4437 ((eq articles 0) nil)
4439 ;; Init the dependencies hash table.
4440 (setq gnus-newsgroup-dependencies
4441 (gnus-make-hashtable (length articles)))
4442 (gnus-set-global-variables)
4443 ;; Retrieve the headers and read them in.
4444 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4446 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4448 (setq gnus-newsgroup-cached cached))
4450 ;; Suppress duplicates?
4451 (when gnus-suppress-duplicates
4452 (gnus-dup-suppress-articles))
4454 ;; Set the initial limit.
4455 (setq gnus-newsgroup-limit (copy-sequence articles))
4456 ;; Remove canceled articles from the list of unread articles.
4457 (setq gnus-newsgroup-unreads
4458 (gnus-set-sorted-intersection
4459 gnus-newsgroup-unreads
4460 (setq fetched-articles
4461 (mapcar (lambda (headers) (mail-header-number headers))
4462 gnus-newsgroup-headers))))
4463 ;; Removed marked articles that do not exist.
4464 (gnus-update-missing-marks
4465 (gnus-sorted-complement fetched-articles articles))
4466 ;; We might want to build some more threads first.
4467 (when (and gnus-fetch-old-headers
4468 (eq gnus-headers-retrieved-by 'nov))
4469 (if (eq gnus-fetch-old-headers 'invisible)
4470 (gnus-build-all-threads)
4471 (gnus-build-old-threads)))
4472 ;; Let the Gnus agent mark articles as read.
4474 (gnus-agent-get-undownloaded-list))
4475 ;; Remove list identifiers from subject
4476 (when gnus-list-identifiers
4477 (gnus-summary-remove-list-identifiers))
4478 ;; Check whether auto-expire is to be done in this group.
4479 (setq gnus-newsgroup-auto-expire
4480 (gnus-group-auto-expirable-p group))
4481 ;; Set up the article buffer now, if necessary.
4482 (unless gnus-single-article-buffer
4483 (gnus-article-setup-buffer))
4484 ;; First and last article in this newsgroup.
4485 (when gnus-newsgroup-headers
4486 (setq gnus-newsgroup-begin
4487 (mail-header-number (car gnus-newsgroup-headers))
4490 (gnus-last-element gnus-newsgroup-headers))))
4491 ;; GROUP is successfully selected.
4492 (or gnus-newsgroup-headers t)))))
4494 (defun gnus-articles-to-read (group &optional read-all)
4495 "Find out what articles the user wants to read."
4497 ;; Select all articles if `read-all' is non-nil, or if there
4498 ;; are no unread articles.
4500 (and (zerop (length gnus-newsgroup-marked))
4501 (zerop (length gnus-newsgroup-unreads)))
4502 (eq (gnus-group-find-parameter group 'display)
4505 (gnus-uncompress-range (gnus-active group))
4506 (gnus-cache-articles-in-group group))
4507 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4508 (copy-sequence gnus-newsgroup-unreads))
4510 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4511 (scored (length scored-list))
4512 (number (length articles))
4513 (marked (+ (length gnus-newsgroup-marked)
4514 (length gnus-newsgroup-dormant)))
4522 ((and (or (<= scored marked) (= scored number))
4523 (numberp gnus-large-newsgroup)
4524 (> number gnus-large-newsgroup))
4528 "How many articles from %s (default %d): "
4529 (gnus-limit-string gnus-newsgroup-name 35)
4531 (if (string-match "^[ \t]*$" input) number input)))
4532 ((and (> scored marked) (< scored number)
4533 (> (- scored number) 20))
4536 (format "%s %s (%d scored, %d total): "
4537 "How many articles from"
4538 group scored number))))
4539 (if (string-match "^[ \t]*$" input)
4543 (message "Quit getting the articles to read")
4545 (setq select (if (stringp select) (string-to-number select) select))
4546 (if (or (null select) (zerop select))
4548 (if (and (not (zerop scored)) (<= (abs select) scored))
4550 (setq articles (sort scored-list '<))
4551 (setq number (length articles)))
4552 (setq articles (copy-sequence articles)))
4554 (when (< (abs select) number)
4556 ;; Select the N oldest articles.
4557 (setcdr (nthcdr (1- (abs select)) articles) nil)
4558 ;; Select the N most recent articles.
4559 (setq articles (nthcdr (- number select) articles))))
4560 (setq gnus-newsgroup-unselected
4561 (gnus-sorted-intersection
4562 gnus-newsgroup-unreads
4563 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4564 (when gnus-alter-articles-to-read-function
4565 (setq gnus-newsgroup-unreads
4567 (funcall gnus-alter-articles-to-read-function
4568 gnus-newsgroup-name gnus-newsgroup-unreads)
4572 (defun gnus-killed-articles (killed articles)
4575 (when (inline (gnus-member-of-range (car articles) killed))
4576 (push (car articles) out))
4577 (setq articles (cdr articles)))
4580 (defun gnus-uncompress-marks (marks)
4581 "Uncompress the mark ranges in MARKS."
4582 (let ((uncompressed '(score bookmark))
4585 (if (memq (caar marks) uncompressed)
4586 (push (car marks) out)
4587 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4588 (setq marks (cdr marks)))
4591 (defun gnus-adjust-marked-articles (info)
4592 "Set all article lists and remove all marks that are no longer valid."
4593 (let* ((marked-lists (gnus-info-marks info))
4594 (active (gnus-active (gnus-info-group info)))
4597 (types gnus-article-mark-lists)
4598 (uncompressed '(score bookmark killed))
4599 marks var articles article mark)
4602 (setq marks (pop marked-lists))
4603 (set (setq var (intern (format "gnus-newsgroup-%s"
4604 (car (rassq (setq mark (car marks))
4606 (if (memq (car marks) uncompressed) (cdr marks)
4607 (gnus-uncompress-range (cdr marks))))
4609 (setq articles (symbol-value var))
4611 ;; All articles have to be subsets of the active articles.
4613 ;; Adjust "simple" lists.
4614 ((memq mark '(tick dormant expire reply save))
4616 (when (or (< (setq article (pop articles)) min) (> article max))
4617 (set var (delq article (symbol-value var))))))
4619 ((memq mark uncompressed)
4620 (when (not (listp (cdr (symbol-value var))))
4621 (set var (list (symbol-value var))))
4622 (when (not (listp (cdr articles)))
4623 (setq articles (list articles)))
4625 (when (or (not (consp (setq article (pop articles))))
4626 (< (car article) min)
4627 (> (car article) max))
4628 (set var (delq article (symbol-value var))))))))))
4630 (defun gnus-update-missing-marks (missing)
4631 "Go through the list of MISSING articles and remove them from the mark lists."
4633 (let ((types gnus-article-mark-lists)
4635 ;; Go through all types.
4637 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4638 (when (symbol-value var)
4639 ;; This list has articles. So we delete all missing articles
4643 (set var (delq (pop m) (symbol-value var)))))))))
4645 (defun gnus-update-marks ()
4646 "Enter the various lists of marked articles into the newsgroup info list."
4647 (let ((types gnus-article-mark-lists)
4648 (info (gnus-get-info gnus-newsgroup-name))
4649 (uncompressed '(score bookmark killed))
4650 type list newmarked symbol delta-marks)
4652 ;; Add all marks lists to the list of marks lists.
4653 (while (setq type (pop types))
4654 (setq list (symbol-value
4656 (intern (format "gnus-newsgroup-%s"
4660 ;; Get rid of the entries of the articles that have the
4662 (when (and (eq (cdr type) 'score)
4666 (prev (cons nil list))
4669 (if (or (not (consp (car arts)))
4670 (= (cdar arts) gnus-summary-default-score))
4671 (setcdr prev (cdr arts))
4673 (setq arts (cdr arts)))
4674 (setq list (cdr all)))))
4676 (unless (memq (cdr type) uncompressed)
4677 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4679 (when (gnus-check-backend-function
4680 'request-set-mark gnus-newsgroup-name)
4681 ;; propagate flags to server, with the following exceptions:
4682 ;; uncompressed:s are not proper flags (they are cons cells)
4683 ;; cache is a internal gnus flag
4684 ;; download are local to one gnus installation (well)
4685 ;; unsend are for nndraft groups only
4686 ;; xxx: generality of this? this suits nnimap anyway
4687 (unless (memq (cdr type) (append '(cache download unsend)
4689 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4690 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4691 (add (gnus-remove-from-range
4692 (gnus-copy-sequence list) old)))
4694 (push (list add 'add (list (cdr type))) delta-marks))
4696 (push (list del 'del (list (cdr type))) delta-marks)))))
4699 (push (cons (cdr type) list) newmarked)))
4702 (unless (gnus-check-group gnus-newsgroup-name)
4703 (error "Can't open server for %s" gnus-newsgroup-name))
4704 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4706 ;; Enter these new marks into the info of the group.
4708 (setcar (nthcdr 3 info) newmarked)
4709 ;; Add the marks lists to the end of the info.
4711 (setcdr (nthcdr 2 info) (list newmarked))))
4713 ;; Cut off the end of the info if there's nothing else there.
4717 (when (nthcdr (decf i) info)
4718 (setcdr (nthcdr i info) nil)))))))
4720 (defun gnus-set-mode-line (where)
4721 "Set the mode line of the article or summary buffers.
4722 If WHERE is `summary', the summary mode line format will be used."
4723 ;; Is this mode line one we keep updated?
4724 (when (and (memq where gnus-updated-mode-lines)
4726 (intern (format "gnus-%s-mode-line-format-spec" where))))
4729 ;; We evaluate this in the summary buffer since these
4730 ;; variables are buffer-local to that buffer.
4731 (set-buffer gnus-summary-buffer)
4732 ;; We bind all these variables that are used in the `eval' form
4734 (let* ((mformat (symbol-value
4736 (format "gnus-%s-mode-line-format-spec" where))))
4737 (gnus-tmp-group-name (gnus-group-decoded-name
4738 gnus-newsgroup-name))
4739 (gnus-tmp-article-number (or gnus-current-article 0))
4740 (gnus-tmp-unread gnus-newsgroup-unreads)
4741 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4742 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4743 (gnus-tmp-unread-and-unselected
4744 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4745 (zerop gnus-tmp-unselected))
4747 ((zerop gnus-tmp-unselected)
4748 (format "{%d more}" gnus-tmp-unread-and-unticked))
4749 (t (format "{%d(+%d) more}"
4750 gnus-tmp-unread-and-unticked
4751 gnus-tmp-unselected))))
4753 (if (and gnus-current-headers
4754 (vectorp gnus-current-headers))
4755 (gnus-mode-string-quote
4756 (mail-header-subject gnus-current-headers))
4758 bufname-length max-len
4759 gnus-tmp-header);; passed as argument to any user-format-funcs
4760 (setq mode-string (eval mformat))
4761 (setq bufname-length (if (string-match "%b" mode-string)
4764 (if (eq where 'summary)
4766 (get-buffer gnus-article-buffer))))
4769 (setq max-len (max 4 (if gnus-mode-non-string-length
4771 gnus-mode-non-string-length
4773 (length mode-string))))
4774 ;; We might have to chop a bit of the string off...
4775 (when (> (length mode-string) max-len)
4777 (concat (truncate-string-to-width mode-string (- max-len 3))
4779 ;; Pad the mode string a bit.
4780 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4781 ;; Update the mode line.
4782 (setq mode-line-buffer-identification
4783 (gnus-mode-line-buffer-identification (list mode-string)))
4784 (set-buffer-modified-p t))))
4786 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4787 "Go through the HEADERS list and add all Xrefs to a hash table.
4788 The resulting hash table is returned, or nil if no Xrefs were found."
4789 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4790 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4791 (xref-hashtb (gnus-make-hashtable))
4792 start group entry number xrefs header)
4794 (setq header (pop headers))
4795 (when (and (setq xrefs (mail-header-xref header))
4796 (not (memq (setq number (mail-header-number header))
4799 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4800 (setq start (match-end 0))
4801 (setq group (if prefix
4802 (concat prefix (substring xrefs (match-beginning 1)
4804 (substring xrefs (match-beginning 1) (match-end 1))))
4806 (string-to-int (substring xrefs (match-beginning 2)
4808 (if (setq entry (gnus-gethash group xref-hashtb))
4809 (setcdr entry (cons number (cdr entry)))
4810 (gnus-sethash group (cons number nil) xref-hashtb)))))
4811 (and start xref-hashtb)))
4813 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4814 "Look through all the headers and mark the Xrefs as read."
4815 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4816 name entry info xref-hashtb idlist method nth4)
4818 (set-buffer gnus-group-buffer)
4819 (when (setq xref-hashtb
4820 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4823 (unless (string= from-newsgroup (setq name (symbol-name group)))
4824 (setq idlist (symbol-value group))
4825 ;; Dead groups are not updated.
4827 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4829 (when (stringp (setq nth4 (gnus-info-method info)))
4830 (setq nth4 (gnus-server-to-method nth4))))
4831 ;; Only do the xrefs if the group has the same
4832 ;; select method as the group we have just read.
4833 (or (gnus-methods-equal-p
4834 nth4 (gnus-find-method-for-group from-newsgroup))
4836 (equal nth4 (setq method (gnus-find-method-for-group
4838 (and (equal (car nth4) (car method))
4839 (equal (nth 1 nth4) (nth 1 method))))
4840 gnus-use-cross-reference
4841 (or (not (eq gnus-use-cross-reference t))
4843 ;; Only do cross-references on subscribed
4844 ;; groups, if that is what is wanted.
4845 (<= (gnus-info-level info) gnus-level-subscribed))
4846 (gnus-group-make-articles-read name idlist))))
4849 (defun gnus-compute-read-articles (group articles)
4850 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4851 (info (nth 2 entry))
4852 (active (gnus-active group))
4855 ;; First peel off all invalid article numbers.
4857 (let ((ids articles)
4859 (while (setq id (pop ids))
4860 (when (and first (> id (cdr active)))
4861 ;; We'll end up in this situation in one particular
4862 ;; obscure situation. If you re-scan a group and get
4863 ;; a new article that is cross-posted to a different
4864 ;; group that has not been re-scanned, you might get
4865 ;; crossposted article that has a higher number than
4866 ;; Gnus believes possible. So we re-activate this
4867 ;; group as well. This might mean doing the
4868 ;; crossposting thingy will *increase* the number
4869 ;; of articles in some groups. Tsk, tsk.
4870 (setq active (or (gnus-activate-group group) active)))
4871 (when (or (> id (cdr active))
4872 (< id (car active)))
4873 (setq articles (delq id articles))))))
4874 ;; If the read list is nil, we init it.
4876 (null (gnus-info-read info))
4878 (setq ninfo (cons 1 (1- (car active))))
4879 (setq ninfo (gnus-info-read info)))
4880 ;; Then we add the read articles to the range.
4882 ninfo (setq articles (sort articles '<))))))
4884 (defun gnus-group-make-articles-read (group articles)
4885 "Update the info of GROUP to say that ARTICLES are read."
4887 (entry (gnus-gethash group gnus-newsrc-hashtb))
4888 (info (nth 2 entry))
4889 (active (gnus-active group))
4892 (setq range (gnus-compute-read-articles group articles))
4894 (set-buffer gnus-group-buffer)
4897 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4898 (gnus-info-set-read ',info ',(gnus-info-read info))
4899 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4900 (gnus-group-update-group ,group t))))
4901 ;; Add the read articles to the range.
4902 (gnus-info-set-read info range)
4903 ;; Then we have to re-compute how many unread
4904 ;; articles there are in this group.
4908 (setq num (- (1+ (cdr active)) (car active))))
4909 ((not (listp (cdr range)))
4910 (setq num (- (cdr active) (- (1+ (cdr range))
4914 (if (numberp (car range))
4916 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4917 (setq range (cdr range)))
4918 (setq num (- (cdr active) num))))
4919 ;; Update the number of unread articles.
4921 ;; Update the group buffer.
4922 (gnus-group-update-group group t)))))
4924 (defvar gnus-newsgroup-none-id 0)
4926 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4927 (let ((cur nntp-server-buffer)
4930 (save-excursion (set-buffer gnus-summary-buffer)
4931 gnus-newsgroup-dependencies)))
4933 (mail-parse-charset gnus-newsgroup-charset)
4934 (mail-parse-ignored-charsets
4935 (save-excursion (condition-case nil
4936 (set-buffer gnus-summary-buffer)
4938 gnus-newsgroup-ignored-charsets)))
4940 (set-buffer nntp-server-buffer)
4941 ;; Translate all TAB characters into SPACE characters.
4942 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4943 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4944 (gnus-run-hooks 'gnus-parse-headers-hook)
4945 (let ((case-fold-search t)
4946 in-reply-to header p lines chars)
4947 (goto-char (point-min))
4948 ;; Search to the beginning of the next header. Error messages
4949 ;; do not begin with 2 or 3.
4950 (while (re-search-forward "^[23][0-9]+ " nil t)
4953 ;; This implementation of this function, with nine
4954 ;; search-forwards instead of the one re-search-forward and
4955 ;; a case (which basically was the old function) is actually
4956 ;; about twice as fast, even though it looks messier. You
4957 ;; can't have everything, I guess. Speed and elegance
4958 ;; doesn't always go hand in hand.
4967 (narrow-to-region (point)
4968 (or (and (search-forward "\n.\n" nil t)
4974 (if (search-forward "\nsubject: " nil t)
4975 (funcall gnus-decode-encoded-word-function
4976 (nnheader-header-value))
4981 (if (or (search-forward "\nfrom: " nil t)
4982 (search-forward "\nfrom:" nil t))
4983 (funcall gnus-decode-encoded-word-function
4984 (nnheader-header-value))
4989 (if (search-forward "\ndate: " nil t)
4990 (nnheader-header-value) ""))
4994 (setq id (if (re-search-forward
4995 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4996 ;; We do it this way to make sure the Message-ID
4997 ;; is (somewhat) syntactically valid.
4998 (buffer-substring (match-beginning 1)
5000 ;; If there was no message-id, we just fake one
5001 ;; to make subsequent routines simpler.
5002 (nnheader-generate-fake-message-id))))
5006 (if (search-forward "\nreferences: " nil t)
5010 (nnheader-header-value)
5015 (search-backward ">" end t)
5018 (search-backward "<" end t)
5020 ;; Get the references from the in-reply-to header if there
5021 ;; were no references and the in-reply-to header looks
5023 (if (and (search-forward "\nin-reply-to: " nil t)
5024 (setq in-reply-to (nnheader-header-value))
5025 (string-match "<[^>]+>" in-reply-to))
5027 (setq ref (substring in-reply-to (match-beginning 0)
5029 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5030 (setq ref2 (substring in-reply-to (match-beginning 0)
5032 (when (> (length ref2) (length ref))
5039 (if (search-forward "\nchars: " nil t)
5040 (if (numberp (setq chars (ignore-errors (read cur))))
5046 (if (search-forward "\nlines: " nil t)
5047 (if (numberp (setq lines (ignore-errors (read cur))))
5053 (and (search-forward "\nxref: " nil t)
5054 (nnheader-header-value)))
5056 (when gnus-extra-headers
5057 (let ((extra gnus-extra-headers)
5061 (when (search-forward
5062 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5063 (push (cons (car extra) (nnheader-header-value))
5067 (when (equal id ref)
5070 (when gnus-alter-header-function
5071 (funcall gnus-alter-header-function header)
5072 (setq id (mail-header-id header)
5073 ref (gnus-parent-id (mail-header-references header))))
5076 (gnus-dependencies-add-header
5077 header dependencies force-new))
5078 (push header headers))
5079 (goto-char (point-max))
5081 (nreverse headers)))))
5083 ;; Goes through the xover lines and returns a list of vectors
5084 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5085 force-new dependencies
5086 group also-fetch-heads)
5087 "Parse the news overview data in the server buffer.
5088 Return a list of headers that match SEQUENCE (see
5089 `nntp-retrieve-headers')."
5090 ;; Get the Xref when the users reads the articles since most/some
5091 ;; NNTP servers do not include Xrefs when using XOVER.
5092 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5093 (let ((mail-parse-charset gnus-newsgroup-charset)
5094 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5095 (cur nntp-server-buffer)
5096 (dependencies (or dependencies gnus-newsgroup-dependencies))
5097 number headers header)
5099 (set-buffer nntp-server-buffer)
5100 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5101 ;; Allow the user to mangle the headers before parsing them.
5102 (gnus-run-hooks 'gnus-parse-headers-hook)
5103 (goto-char (point-min))
5106 (while (and sequence (not (eobp)))
5107 (setq number (read cur))
5108 (while (and sequence
5109 (< (car sequence) number))
5110 (setq sequence (cdr sequence)))
5112 (eq number (car sequence))
5114 (setq sequence (cdr sequence))
5115 (setq header (inline
5116 (gnus-nov-parse-line
5117 number dependencies force-new))))
5118 (push header headers))
5121 (gnus-error 4 "Strange nov line (%d)"
5122 (count-lines (point-min) (point)))))
5124 ;; A common bug in inn is that if you have posted an article and
5125 ;; then retrieves the active file, it will answer correctly --
5126 ;; the new article is included. However, a NOV entry for the
5127 ;; article may not have been generated yet, so this may fail.
5128 ;; We work around this problem by retrieving the last few
5129 ;; headers using HEAD.
5130 (if (or (not also-fetch-heads)
5132 ;; We (probably) got all the headers.
5134 (let ((gnus-nov-is-evil t))
5137 (when (gnus-retrieve-headers sequence group)
5138 (gnus-get-newsgroup-headers))))))))
5140 (defun gnus-article-get-xrefs ()
5141 "Fill in the Xref value in `gnus-current-headers', if necessary.
5142 This is meant to be called in `gnus-article-internal-prepare-hook'."
5143 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5144 gnus-current-headers)))
5145 (or (not gnus-use-cross-reference)
5147 (and (mail-header-xref headers)
5148 (not (string= (mail-header-xref headers) "")))
5149 (let ((case-fold-search t)
5152 (nnheader-narrow-to-headers)
5153 (goto-char (point-min))
5154 (when (or (and (not (eobp))
5155 (eq (downcase (char-after)) ?x)
5156 (looking-at "Xref:"))
5157 (search-forward "\nXref:" nil t))
5158 (goto-char (1+ (match-end 0)))
5159 (setq xref (buffer-substring (point)
5160 (progn (end-of-line) (point))))
5161 (mail-header-set-xref headers xref)))))))
5163 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5164 "Find article ID and insert the summary line for that article.
5165 OLD-HEADER can either be a header or a line number to insert
5166 the subject line on."
5167 (let* ((line (and (numberp old-header) old-header))
5168 (old-header (and (vectorp old-header) old-header))
5169 (header (cond ((and old-header use-old-header)
5172 (gnus-number-to-header id))
5173 (gnus-number-to-header id))
5175 (gnus-read-header id))))
5176 (number (and (numberp id) id))
5179 ;; Rebuild the thread that this article is part of and go to the
5180 ;; article we have fetched.
5181 (when (and (not gnus-show-threads)
5184 (setq d (gnus-data-find (mail-header-number old-header))))
5185 (goto-char (gnus-data-pos d))
5188 (- (gnus-point-at-bol)
5190 (1+ (gnus-point-at-eol))
5191 (gnus-delete-line))))))
5193 (mail-header-set-number header (mail-header-number old-header)))
5194 (setq gnus-newsgroup-sparse
5195 (delq (setq number (mail-header-number header))
5196 gnus-newsgroup-sparse))
5197 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5198 (push number gnus-newsgroup-limit)
5199 (gnus-rebuild-thread (mail-header-id header) line)
5200 (gnus-summary-goto-subject number nil t))
5201 (when (and (numberp number)
5203 ;; We have to update the boundaries even if we can't fetch the
5204 ;; article if ID is a number -- so that the next `P' or `N'
5205 ;; command will fetch the previous (or next) article even
5206 ;; if the one we tried to fetch this time has been canceled.
5207 (when (> number gnus-newsgroup-end)
5208 (setq gnus-newsgroup-end number))
5209 (when (< number gnus-newsgroup-begin)
5210 (setq gnus-newsgroup-begin number))
5211 (setq gnus-newsgroup-unselected
5212 (delq number gnus-newsgroup-unselected)))
5213 ;; Report back a success?
5214 (and header (mail-header-number header))))
5216 ;;; Process/prefix in the summary buffer
5218 (defun gnus-summary-work-articles (n)
5219 "Return a list of articles to be worked upon.
5220 The prefix argument, the list of process marked articles, and the
5221 current article will be taken into consideration."
5223 (set-buffer gnus-summary-buffer)
5226 ;; A numerical prefix has been given.
5227 (setq n (prefix-numeric-value n))
5228 (let ((backward (< n 0))
5229 (n (abs (prefix-numeric-value n)))
5234 (push (setq article (gnus-summary-article-number))
5237 (gnus-summary-find-prev nil article)
5238 (gnus-summary-find-next nil article)))
5240 (nreverse articles)))
5241 ((and (gnus-region-active-p) (mark))
5242 (message "region active")
5243 ;; Work on the region between point and mark.
5244 (let ((max (max (point) (mark)))
5247 (goto-char (min (min (point) (mark))))
5250 (push (setq article (gnus-summary-article-number)) articles)
5251 (gnus-summary-find-next nil article)
5253 (nreverse articles))))
5254 (gnus-newsgroup-processable
5255 ;; There are process-marked articles present.
5256 ;; Save current state.
5257 (gnus-summary-save-process-mark)
5259 (reverse gnus-newsgroup-processable))
5261 ;; Just return the current article.
5262 (list (gnus-summary-article-number))))))
5264 (defmacro gnus-summary-iterate (arg &rest forms)
5265 "Iterate over the process/prefixed articles and do FORMS.
5266 ARG is the interactive prefix given to the command. FORMS will be
5267 executed with point over the summary line of the articles."
5268 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5269 `(let ((,articles (gnus-summary-work-articles ,arg)))
5271 (gnus-summary-goto-subject (car ,articles))
5275 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5276 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5278 (defun gnus-summary-save-process-mark ()
5279 "Push the current set of process marked articles on the stack."
5281 (push (copy-sequence gnus-newsgroup-processable)
5282 gnus-newsgroup-process-stack))
5284 (defun gnus-summary-kill-process-mark ()
5285 "Push the current set of process marked articles on the stack and unmark."
5287 (gnus-summary-save-process-mark)
5288 (gnus-summary-unmark-all-processable))
5290 (defun gnus-summary-yank-process-mark ()
5291 "Pop the last process mark state off the stack and restore it."
5293 (unless gnus-newsgroup-process-stack
5294 (error "Empty mark stack"))
5295 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5297 (defun gnus-summary-process-mark-set (set)
5298 "Make SET into the current process marked articles."
5299 (gnus-summary-unmark-all-processable)
5301 (gnus-summary-set-process-mark (pop set))))
5303 ;;; Searching and stuff
5305 (defun gnus-summary-search-group (&optional backward use-level)
5306 "Search for next unread newsgroup.
5307 If optional argument BACKWARD is non-nil, search backward instead."
5309 (set-buffer gnus-group-buffer)
5310 (when (gnus-group-search-forward
5311 backward nil (if use-level (gnus-group-group-level) nil))
5312 (gnus-group-group-name))))
5314 (defun gnus-summary-best-group (&optional exclude-group)
5315 "Find the name of the best unread group.
5316 If EXCLUDE-GROUP, do not go to this group."
5318 (set-buffer gnus-group-buffer)
5320 (gnus-group-best-unread-group exclude-group))))
5322 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5323 (if backward (gnus-summary-find-prev)
5324 (let* ((dummy (gnus-summary-article-intangible-p))
5325 (article (or article (gnus-summary-article-number)))
5326 (arts (gnus-data-find-list article))
5328 (when (and (not dummy)
5329 (or (not gnus-summary-check-current)
5331 (not (gnus-data-unread-p (car arts)))))
5332 (setq arts (cdr arts)))
5337 (when (or (and undownloaded
5338 (eq gnus-undownloaded-mark
5339 (gnus-data-mark (car arts))))
5340 (gnus-data-unread-p (car arts)))
5341 (setq result (car arts)
5343 (setq arts (cdr arts)))
5346 (goto-char (gnus-data-pos result))
5347 (gnus-data-number result)))))
5349 (defun gnus-summary-find-prev (&optional unread article)
5350 (let* ((eobp (eobp))
5351 (article (or article (gnus-summary-article-number)))
5352 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5354 (when (and (not eobp)
5355 (or (not gnus-summary-check-current)
5357 (not (gnus-data-unread-p (car arts)))))
5358 (setq arts (cdr arts)))
5363 (when (gnus-data-unread-p (car arts))
5364 (setq result (car arts)
5366 (setq arts (cdr arts)))
5369 (goto-char (gnus-data-pos result))
5370 (gnus-data-number result))))
5372 (defun gnus-summary-find-subject (subject &optional unread backward article)
5373 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5374 (article (or article (gnus-summary-article-number)))
5375 (articles (gnus-data-list backward))
5376 (arts (gnus-data-find-list article articles))
5378 (when (or (not gnus-summary-check-current)
5380 (not (gnus-data-unread-p (car arts))))
5381 (setq arts (cdr arts)))
5383 (and (or (not unread)
5384 (gnus-data-unread-p (car arts)))
5385 (vectorp (gnus-data-header (car arts)))
5387 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5388 (setq result (car arts)
5390 (setq arts (cdr arts)))
5392 (goto-char (gnus-data-pos result))
5393 (gnus-data-number result))))
5395 (defun gnus-summary-search-forward (&optional unread subject backward)
5396 "Search forward for an article.
5397 If UNREAD, look for unread articles. If SUBJECT, look for
5398 articles with that subject. If BACKWARD, search backward instead."
5399 (cond (subject (gnus-summary-find-subject subject unread backward))
5400 (backward (gnus-summary-find-prev unread))
5401 (t (gnus-summary-find-next unread))))
5403 (defun gnus-recenter (&optional n)
5404 "Center point in window and redisplay frame.
5405 Also do horizontal recentering."
5407 (when (and gnus-auto-center-summary
5408 (not (eq gnus-auto-center-summary 'vertical)))
5409 (gnus-horizontal-recenter))
5412 (defun gnus-summary-recenter ()
5413 "Center point in the summary window.
5414 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5415 displayed, no centering will be performed."
5416 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5417 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5419 (let* ((top (cond ((< (window-height) 4) 0)
5420 ((< (window-height) 7) 1)
5421 (t (if (numberp gnus-auto-center-summary)
5422 gnus-auto-center-summary
5424 (height (1- (window-height)))
5425 (bottom (save-excursion (goto-char (point-max))
5426 (forward-line (- height))
5428 (window (get-buffer-window (current-buffer))))
5429 ;; The user has to want it.
5430 (when gnus-auto-center-summary
5431 (when (get-buffer-window gnus-article-buffer)
5432 ;; Only do recentering when the article buffer is displayed,
5433 ;; Set the window start to either `bottom', which is the biggest
5434 ;; possible valid number, or the second line from the top,
5435 ;; whichever is the least.
5436 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5437 (if (> bottom top-pos)
5438 ;; Keep the second line from the top visible
5439 (set-window-start window top-pos t)
5440 ;; Try to keep the bottom line visible; if it's partially
5441 ;; obscured, either scroll one more line to make it fully
5442 ;; visible, or revert to using TOP-POS.
5444 (goto-char (point-max))
5446 (let ((last-line-start (point)))
5448 (set-window-start window (point) t)
5449 (when (not (pos-visible-in-window-p last-line-start window))
5451 (set-window-start window (min (point) top-pos) t)))))))
5452 ;; Do horizontal recentering while we're at it.
5453 (when (and (get-buffer-window (current-buffer) t)
5454 (not (eq gnus-auto-center-summary 'vertical)))
5455 (let ((selected (selected-window)))
5456 (select-window (get-buffer-window (current-buffer) t))
5457 (gnus-summary-position-point)
5458 (gnus-horizontal-recenter)
5459 (select-window selected))))))
5461 (defun gnus-summary-jump-to-group (newsgroup)
5462 "Move point to NEWSGROUP in group mode buffer."
5463 ;; Keep update point of group mode buffer if visible.
5464 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5465 (save-window-excursion
5466 ;; Take care of tree window mode.
5467 (when (get-buffer-window gnus-group-buffer)
5468 (pop-to-buffer gnus-group-buffer))
5469 (gnus-group-jump-to-group newsgroup))
5471 ;; Take care of tree window mode.
5472 (if (get-buffer-window gnus-group-buffer)
5473 (pop-to-buffer gnus-group-buffer)
5474 (set-buffer gnus-group-buffer))
5475 (gnus-group-jump-to-group newsgroup))))
5477 ;; This function returns a list of article numbers based on the
5478 ;; difference between the ranges of read articles in this group and
5479 ;; the range of active articles.
5480 (defun gnus-list-of-unread-articles (group)
5481 (let* ((read (gnus-info-read (gnus-get-info group)))
5482 (active (or (gnus-active group) (gnus-activate-group group)))
5485 ;; If none are read, then all are unread.
5487 (setq first (car active))
5488 ;; If the range of read articles is a single range, then the
5489 ;; first unread article is the article after the last read
5490 ;; article. Sounds logical, doesn't it?
5491 (if (and (not (listp (cdr read)))
5492 (or (< (car read) (car active))
5493 (progn (setq read (list read))
5495 (setq first (max (car active) (1+ (cdr read))))
5496 ;; `read' is a list of ranges.
5497 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5500 (setq first (car active)))
5503 (while (< first nlast)
5505 (setq first (1+ first))))
5506 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5507 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5508 (setq read (cdr read)))))
5509 ;; And add the last unread articles.
5510 (while (<= first last)
5512 (setq first (1+ first)))
5513 ;; Return the list of unread articles.
5514 (delq 0 (nreverse unread))))
5516 (defun gnus-list-of-read-articles (group)
5517 "Return a list of unread, unticked and non-dormant articles."
5518 (let* ((info (gnus-get-info group))
5519 (marked (gnus-info-marks info))
5520 (active (gnus-active group)))
5522 (gnus-set-difference
5523 (gnus-sorted-complement
5524 (gnus-uncompress-range active)
5525 (gnus-list-of-unread-articles group))
5527 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5528 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5530 ;; Various summary commands
5532 (defun gnus-summary-select-article-buffer ()
5533 "Reconfigure windows to show article buffer."
5535 (if (not (gnus-buffer-live-p gnus-article-buffer))
5536 (error "There is no article buffer for this summary buffer")
5537 (gnus-configure-windows 'article)
5538 (select-window (get-buffer-window gnus-article-buffer))))
5540 (defun gnus-summary-universal-argument (arg)
5541 "Perform any operation on all articles that are process/prefixed."
5543 (let ((articles (gnus-summary-work-articles arg))
5550 (substitute-command-keys
5551 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5553 (gnus-error 1 "Undefined key")
5556 (gnus-summary-goto-subject (setq article (pop articles)))
5557 (let (gnus-newsgroup-processable)
5558 (command-execute func))
5559 (gnus-summary-remove-process-mark article)))))
5560 (gnus-summary-position-point))
5562 (defun gnus-summary-toggle-truncation (&optional arg)
5563 "Toggle truncation of summary lines.
5564 With arg, turn line truncation on iff arg is positive."
5566 (setq truncate-lines
5567 (if (null arg) (not truncate-lines)
5568 (> (prefix-numeric-value arg) 0)))
5571 (defun gnus-summary-reselect-current-group (&optional all rescan)
5572 "Exit and then reselect the current newsgroup.
5573 The prefix argument ALL means to select all articles."
5575 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5576 (error "Ephemeral groups can't be reselected"))
5577 (let ((current-subject (gnus-summary-article-number))
5578 (group gnus-newsgroup-name))
5579 (setq gnus-newsgroup-begin nil)
5581 ;; We have to adjust the point of group mode buffer because
5582 ;; point was moved to the next unread newsgroup by exiting.
5583 (gnus-summary-jump-to-group group)
5586 (gnus-group-get-new-news-this-group 1)))
5587 (gnus-group-read-group all t)
5588 (gnus-summary-goto-subject current-subject nil t)))
5590 (defun gnus-summary-rescan-group (&optional all)
5591 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5593 (gnus-summary-reselect-current-group all t))
5595 (defun gnus-summary-update-info (&optional non-destructive)
5597 (let ((group gnus-newsgroup-name))
5599 (when gnus-newsgroup-kill-headers
5600 (setq gnus-newsgroup-killed
5601 (gnus-compress-sequence
5603 (gnus-set-sorted-intersection
5604 (gnus-uncompress-range gnus-newsgroup-killed)
5605 (setq gnus-newsgroup-unselected
5606 (sort gnus-newsgroup-unselected '<)))
5607 (setq gnus-newsgroup-unreads
5608 (sort gnus-newsgroup-unreads '<)))
5610 (unless (listp (cdr gnus-newsgroup-killed))
5611 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5612 (let ((headers gnus-newsgroup-headers))
5613 ;; Set the new ranges of read articles.
5615 (set-buffer gnus-group-buffer)
5616 (gnus-undo-force-boundary))
5617 (gnus-update-read-articles
5618 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5619 ;; Set the current article marks.
5620 (let ((gnus-newsgroup-scored
5621 (if (and (not gnus-save-score)
5622 (not non-destructive))
5624 gnus-newsgroup-scored)))
5626 (gnus-update-marks)))
5627 ;; Do the cross-ref thing.
5628 (when gnus-use-cross-reference
5629 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5630 ;; Do not switch windows but change the buffer to work.
5631 (set-buffer gnus-group-buffer)
5632 (unless (gnus-ephemeral-group-p group)
5633 (gnus-group-update-group group)))))))
5635 (defun gnus-summary-save-newsrc (&optional force)
5636 "Save the current number of read/marked articles in the dribble buffer.
5637 The dribble buffer will then be saved.
5638 If FORCE (the prefix), also save the .newsrc file(s)."
5640 (gnus-summary-update-info t)
5642 (gnus-save-newsrc-file)
5643 (gnus-dribble-save)))
5645 (defun gnus-summary-exit (&optional temporary)
5646 "Exit reading current newsgroup, and then return to group selection mode.
5647 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5649 (gnus-set-global-variables)
5650 (when (gnus-buffer-live-p gnus-article-buffer)
5652 (set-buffer gnus-article-buffer)
5653 (mm-destroy-parts gnus-article-mime-handles)
5654 ;; Set it to nil for safety reason.
5655 (setq gnus-article-mime-handle-alist nil)
5656 (setq gnus-article-mime-handles nil)))
5657 (gnus-kill-save-kill-buffer)
5658 (gnus-async-halt-prefetch)
5659 (let* ((group gnus-newsgroup-name)
5660 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5663 (buf (current-buffer)))
5665 ;; Do adaptive scoring, and possibly save score files.
5666 (when gnus-newsgroup-adaptive
5667 (gnus-score-adaptive))
5668 (when gnus-use-scoring
5670 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5671 ;; If we have several article buffers, we kill them at exit.
5672 (unless gnus-single-article-buffer
5673 (gnus-kill-buffer gnus-original-article-buffer)
5674 (setq gnus-article-current nil))
5675 (when gnus-use-cache
5676 (gnus-cache-possibly-remove-articles)
5677 (gnus-cache-save-buffers))
5678 (gnus-async-prefetch-remove-group group)
5679 (when gnus-suppress-duplicates
5680 (gnus-dup-enter-articles))
5681 (when gnus-use-trees
5682 (gnus-tree-close group))
5683 (when gnus-use-cache
5684 (gnus-cache-write-active))
5685 ;; Remove entries for this group.
5686 (nnmail-purge-split-history (gnus-group-real-name group))
5687 ;; Make all changes in this group permanent.
5689 (gnus-run-hooks 'gnus-exit-group-hook)
5690 (gnus-summary-update-info))
5691 (gnus-close-group group)
5692 ;; Make sure where we were, and go to next newsgroup.
5693 (set-buffer gnus-group-buffer)
5695 (gnus-group-jump-to-group group))
5696 (gnus-run-hooks 'gnus-summary-exit-hook)
5697 (unless (or quit-config
5698 ;; If this group has disappeared from the summary
5699 ;; buffer, don't skip forwards.
5700 (not (string= group (gnus-group-group-name))))
5701 (gnus-group-next-unread-group 1))
5702 (setq group-point (point))
5705 ;; If we have several article buffers, we kill them at exit.
5706 (unless gnus-single-article-buffer
5707 (gnus-kill-buffer gnus-article-buffer)
5708 (gnus-kill-buffer gnus-original-article-buffer)
5709 (setq gnus-article-current nil))
5711 (if (not gnus-kill-summary-on-exit)
5713 (gnus-deaden-summary)
5715 ;; We set all buffer-local variables to nil. It is unclear why
5716 ;; this is needed, but if we don't, buffer-local variables are
5717 ;; not garbage-collected, it seems. This would the lead to en
5718 ;; ever-growing Emacs.
5719 (gnus-summary-clear-local-variables)
5720 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5721 (gnus-summary-clear-local-variables))
5722 (when (get-buffer gnus-article-buffer)
5723 (bury-buffer gnus-article-buffer))
5724 ;; We clear the global counterparts of the buffer-local
5725 ;; variables as well, just to be on the safe side.
5726 (set-buffer gnus-group-buffer)
5727 (gnus-summary-clear-local-variables)
5728 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5729 (gnus-summary-clear-local-variables)))
5730 (setq gnus-current-select-method gnus-select-method)
5731 (pop-to-buffer gnus-group-buffer)
5732 (if (not quit-config)
5734 (goto-char group-point)
5735 (gnus-configure-windows 'group 'force))
5736 (gnus-handle-ephemeral-exit quit-config))
5737 ;; Return to group mode buffer.
5738 (when (eq mode 'gnus-summary-mode)
5739 (gnus-kill-buffer buf))
5740 ;; Clear the current group name.
5742 (setq gnus-newsgroup-name nil)))))
5744 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5745 (defun gnus-summary-exit-no-update (&optional no-questions)
5746 "Quit reading current newsgroup without updating read article info."
5748 (let* ((group gnus-newsgroup-name)
5749 (quit-config (gnus-group-quit-config group)))
5750 (when (or no-questions
5752 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5753 (gnus-async-halt-prefetch)
5755 (delq 'gnus-summary-expire-articles
5756 (copy-sequence gnus-summary-prepare-exit-hook)))
5757 (when (gnus-buffer-live-p gnus-article-buffer)
5759 (set-buffer gnus-article-buffer)
5760 (mm-destroy-parts gnus-article-mime-handles)
5761 ;; Set it to nil for safety reason.
5762 (setq gnus-article-mime-handle-alist nil)
5763 (setq gnus-article-mime-handles nil)))
5764 ;; If we have several article buffers, we kill them at exit.
5765 (unless gnus-single-article-buffer
5766 (gnus-kill-buffer gnus-article-buffer)
5767 (gnus-kill-buffer gnus-original-article-buffer)
5768 (setq gnus-article-current nil))
5769 (if (not gnus-kill-summary-on-exit)
5770 (gnus-deaden-summary)
5771 (gnus-close-group group)
5772 (gnus-summary-clear-local-variables)
5773 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5774 (gnus-summary-clear-local-variables))
5775 (set-buffer gnus-group-buffer)
5776 (gnus-summary-clear-local-variables)
5777 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5778 (gnus-summary-clear-local-variables))
5779 (when (get-buffer gnus-summary-buffer)
5780 (kill-buffer gnus-summary-buffer)))
5781 (unless gnus-single-article-buffer
5782 (setq gnus-article-current nil))
5783 (when gnus-use-trees
5784 (gnus-tree-close group))
5785 (gnus-async-prefetch-remove-group group)
5786 (when (get-buffer gnus-article-buffer)
5787 (bury-buffer gnus-article-buffer))
5788 ;; Return to the group buffer.
5789 (gnus-configure-windows 'group 'force)
5790 ;; Clear the current group name.
5791 (setq gnus-newsgroup-name nil)
5792 (when (equal (gnus-group-group-name) group)
5793 (gnus-group-next-unread-group 1))
5795 (gnus-handle-ephemeral-exit quit-config)))))
5797 (defun gnus-handle-ephemeral-exit (quit-config)
5798 "Handle movement when leaving an ephemeral group.
5799 The state which existed when entering the ephemeral is reset."
5800 (if (not (buffer-name (car quit-config)))
5801 (gnus-configure-windows 'group 'force)
5802 (set-buffer (car quit-config))
5803 (cond ((eq major-mode 'gnus-summary-mode)
5804 (gnus-set-global-variables))
5805 ((eq major-mode 'gnus-article-mode)
5807 ;; The `gnus-summary-buffer' variable may point
5808 ;; to the old summary buffer when using a single
5810 (unless (gnus-buffer-live-p gnus-summary-buffer)
5811 (set-buffer gnus-group-buffer))
5812 (set-buffer gnus-summary-buffer)
5813 (gnus-set-global-variables))))
5814 (if (or (eq (cdr quit-config) 'article)
5815 (eq (cdr quit-config) 'pick))
5817 ;; The current article may be from the ephemeral group
5818 ;; thus it is best that we reload this article
5819 (gnus-summary-show-article)
5820 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5821 (gnus-configure-windows 'pick 'force)
5822 (gnus-configure-windows (cdr quit-config) 'force)))
5823 (gnus-configure-windows (cdr quit-config) 'force))
5824 (when (eq major-mode 'gnus-summary-mode)
5825 (gnus-summary-next-subject 1 nil t)
5826 (gnus-summary-recenter)
5827 (gnus-summary-position-point))))
5831 (defvar gnus-dead-summary-mode-map nil)
5833 (unless gnus-dead-summary-mode-map
5834 (setq gnus-dead-summary-mode-map (make-keymap))
5835 (suppress-keymap gnus-dead-summary-mode-map)
5836 (substitute-key-definition
5837 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5838 (let ((keys '("\C-d" "\r" "\177" [delete])))
5840 (define-key gnus-dead-summary-mode-map
5841 (pop keys) 'gnus-summary-wake-up-the-dead))))
5843 (defvar gnus-dead-summary-mode nil
5844 "Minor mode for Gnus summary buffers.")
5846 (defun gnus-dead-summary-mode (&optional arg)
5847 "Minor mode for Gnus summary buffers."
5849 (when (eq major-mode 'gnus-summary-mode)
5850 (make-local-variable 'gnus-dead-summary-mode)
5851 (setq gnus-dead-summary-mode
5852 (if (null arg) (not gnus-dead-summary-mode)
5853 (> (prefix-numeric-value arg) 0)))
5854 (when gnus-dead-summary-mode
5855 (gnus-add-minor-mode
5856 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5858 (defun gnus-deaden-summary ()
5859 "Make the current summary buffer into a dead summary buffer."
5860 ;; Kill any previous dead summary buffer.
5861 (when (and gnus-dead-summary
5862 (buffer-name gnus-dead-summary))
5864 (set-buffer gnus-dead-summary)
5865 (when gnus-dead-summary-mode
5866 (kill-buffer (current-buffer)))))
5867 ;; Make this the current dead summary.
5868 (setq gnus-dead-summary (current-buffer))
5869 (gnus-dead-summary-mode 1)
5870 (let ((name (buffer-name)))
5871 (when (string-match "Summary" name)
5873 (concat (substring name 0 (match-beginning 0)) "Dead "
5874 (substring name (match-beginning 0)))
5878 (defun gnus-kill-or-deaden-summary (buffer)
5879 "Kill or deaden the summary BUFFER."
5881 (when (and (buffer-name buffer)
5882 (not gnus-single-article-buffer))
5885 (gnus-kill-buffer gnus-article-buffer)
5886 (gnus-kill-buffer gnus-original-article-buffer)))
5887 (cond (gnus-kill-summary-on-exit
5888 (when (and gnus-use-trees
5889 (gnus-buffer-exists-p buffer))
5892 (gnus-tree-close gnus-newsgroup-name)))
5893 (gnus-kill-buffer buffer))
5894 ((gnus-buffer-exists-p buffer)
5897 (gnus-deaden-summary))))))
5899 (defun gnus-summary-wake-up-the-dead (&rest args)
5900 "Wake up the dead summary buffer."
5902 (gnus-dead-summary-mode -1)
5903 (let ((name (buffer-name)))
5904 (when (string-match "Dead " name)
5906 (concat (substring name 0 (match-beginning 0))
5907 (substring name (match-end 0)))
5909 (gnus-message 3 "This dead summary is now alive again"))
5911 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5912 (defun gnus-summary-fetch-faq (&optional faq-dir)
5913 "Fetch the FAQ for the current group.
5914 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5918 (when current-prefix-arg
5920 "Faq dir: " (and (listp gnus-group-faq-directory)
5921 (mapcar (lambda (file) (list file))
5922 gnus-group-faq-directory))))))
5923 (let (gnus-faq-buffer)
5924 (when (setq gnus-faq-buffer
5925 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5926 (gnus-configure-windows 'summary-faq))))
5928 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5929 (defun gnus-summary-describe-group (&optional force)
5930 "Describe the current newsgroup."
5932 (gnus-group-describe-group force gnus-newsgroup-name))
5934 (defun gnus-summary-describe-briefly ()
5935 "Describe summary mode commands briefly."
5937 (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")))
5939 ;; Walking around group mode buffer from summary mode.
5941 (defun gnus-summary-next-group (&optional no-article target-group backward)
5942 "Exit current newsgroup and then select next unread newsgroup.
5943 If prefix argument NO-ARTICLE is non-nil, no article is selected
5944 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5945 previous group instead."
5947 ;; Stop pre-fetching.
5948 (gnus-async-halt-prefetch)
5949 (let ((current-group gnus-newsgroup-name)
5950 (current-buffer (current-buffer))
5952 ;; First we semi-exit this group to update Xrefs and all variables.
5953 ;; We can't do a real exit, because the window conf must remain
5954 ;; the same in case the user is prompted for info, and we don't
5955 ;; want the window conf to change before that...
5956 (gnus-summary-exit t)
5957 (while (not entered)
5958 ;; Then we find what group we are supposed to enter.
5959 (set-buffer gnus-group-buffer)
5960 (gnus-group-jump-to-group current-group)
5963 (if (eq gnus-keep-same-level 'best)
5964 (gnus-summary-best-group gnus-newsgroup-name)
5965 (gnus-summary-search-group backward gnus-keep-same-level))))
5966 (if (not target-group)
5967 ;; There are no further groups, so we return to the group
5970 (gnus-message 5 "Returning to the group buffer")
5972 (when (gnus-buffer-live-p current-buffer)
5973 (set-buffer current-buffer)
5974 (gnus-summary-exit))
5975 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5976 ;; We try to enter the target group.
5977 (gnus-group-jump-to-group target-group)
5978 (let ((unreads (gnus-group-group-unread)))
5979 (if (and (or (eq t unreads)
5980 (and unreads (not (zerop unreads))))
5981 (gnus-summary-read-group
5982 target-group nil no-article
5983 (and (buffer-name current-buffer) current-buffer)
5986 (setq current-group target-group
5987 target-group nil)))))))
5989 (defun gnus-summary-prev-group (&optional no-article)
5990 "Exit current newsgroup and then select previous unread newsgroup.
5991 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5993 (gnus-summary-next-group no-article nil t))
5995 ;; Walking around summary lines.
5997 (defun gnus-summary-first-subject (&optional unread undownloaded)
5998 "Go to the first unread subject.
5999 If UNREAD is non-nil, go to the first unread article.
6000 Returns the article selected or nil if there are no unread articles."
6005 ((null gnus-newsgroup-data)
6006 (gnus-message 3 "No articles in the group")
6008 ;; Pick the first article.
6010 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6011 (gnus-data-number (car gnus-newsgroup-data)))
6012 ;; No unread articles.
6013 ((null gnus-newsgroup-unreads)
6014 (gnus-message 3 "No more unread articles")
6016 ;; Find the first unread article.
6018 (let ((data gnus-newsgroup-data))
6020 (and (not (and undownloaded
6021 (eq gnus-undownloaded-mark
6022 (gnus-data-mark (car data)))))
6023 (not (gnus-data-unread-p (car data)))))
6024 (setq data (cdr data)))
6026 (goto-char (gnus-data-pos (car data)))
6027 (gnus-data-number (car data))))))
6028 (gnus-summary-position-point)))
6030 (defun gnus-summary-next-subject (n &optional unread dont-display)
6031 "Go to next N'th summary line.
6032 If N is negative, go to the previous N'th subject line.
6033 If UNREAD is non-nil, only unread articles are selected.
6034 The difference between N and the actual number of steps taken is
6037 (let ((backward (< n 0))
6041 (gnus-summary-find-prev unread)
6042 (gnus-summary-find-next unread)))
6043 (unless (zerop (setq n (1- n)))
6044 (gnus-summary-show-thread)))
6046 (gnus-message 7 "No more%s articles"
6047 (if unread " unread" "")))
6048 (unless dont-display
6049 (gnus-summary-recenter)
6050 (gnus-summary-position-point))
6053 (defun gnus-summary-next-unread-subject (n)
6054 "Go to next N'th unread summary line."
6056 (gnus-summary-next-subject n t))
6058 (defun gnus-summary-prev-subject (n &optional unread)
6059 "Go to previous N'th summary line.
6060 If optional argument UNREAD is non-nil, only unread article is selected."
6062 (gnus-summary-next-subject (- n) unread))
6064 (defun gnus-summary-prev-unread-subject (n)
6065 "Go to previous N'th unread summary line."
6067 (gnus-summary-next-subject (- n) t))
6069 (defun gnus-summary-goto-subject (article &optional force silent)
6070 "Go the subject line of ARTICLE.
6071 If FORCE, also allow jumping to articles not currently shown."
6072 (interactive "nArticle number: ")
6074 (data (gnus-data-find article)))
6075 ;; We read in the article if we have to.
6078 (gnus-summary-insert-subject
6080 (if (or (numberp force) (vectorp force)) force)
6082 (setq data (gnus-data-find article)))
6087 (gnus-message 3 "Can't find article %d" article))
6089 (goto-char (gnus-data-pos data))
6090 (gnus-summary-position-point)
6093 ;; Walking around summary lines with displaying articles.
6095 (defun gnus-summary-expand-window (&optional arg)
6096 "Make the summary buffer take up the entire Emacs frame.
6097 Given a prefix, will force an `article' buffer configuration."
6100 (gnus-configure-windows 'article 'force)
6101 (gnus-configure-windows 'summary 'force)))
6103 (defun gnus-summary-display-article (article &optional all-header)
6104 "Display ARTICLE in article buffer."
6105 (when (gnus-buffer-live-p gnus-article-buffer)
6106 (with-current-buffer gnus-article-buffer
6107 (mm-enable-multibyte-mule4)))
6108 (gnus-set-global-variables)
6109 (when (gnus-buffer-live-p gnus-article-buffer)
6110 (with-current-buffer gnus-article-buffer
6111 (setq gnus-article-charset gnus-newsgroup-charset)
6112 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6113 (mm-enable-multibyte-mule4)))
6117 (if gnus-summary-display-article-function
6118 (funcall gnus-summary-display-article-function article all-header)
6119 (gnus-article-prepare article all-header))
6120 (gnus-run-hooks 'gnus-select-article-hook)
6121 (when (and gnus-current-article
6122 (not (zerop gnus-current-article)))
6123 (gnus-summary-goto-subject gnus-current-article))
6124 (gnus-summary-recenter)
6125 (when (and gnus-use-trees gnus-show-threads)
6126 (gnus-possibly-generate-tree article)
6127 (gnus-highlight-selected-tree article))
6128 ;; Successfully display article.
6129 (gnus-article-set-window-start
6130 (cdr (assq article gnus-newsgroup-bookmarks))))))
6132 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6133 "Select the current article.
6134 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6135 non-nil, the article will be re-fetched even if it already present in
6136 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6138 ;; Make sure we are in the summary buffer to work around bbdb bug.
6139 (unless (eq major-mode 'gnus-summary-mode)
6140 (set-buffer gnus-summary-buffer))
6141 (let ((article (or article (gnus-summary-article-number)))
6142 (all-headers (not (not all-headers))) ;Must be T or NIL.
6143 gnus-summary-display-article-function)
6145 (gnus-summary-article-pseudo-p article)
6146 (error "This is a pseudo-article"))
6148 (set-buffer gnus-summary-buffer)
6149 (if (or (and gnus-single-article-buffer
6150 (or (null gnus-current-article)
6151 (null gnus-article-current)
6152 (null (get-buffer gnus-article-buffer))
6153 (not (eq article (cdr gnus-article-current)))
6154 (not (equal (car gnus-article-current)
6155 gnus-newsgroup-name))))
6156 (and (not gnus-single-article-buffer)
6157 (or (null gnus-current-article)
6158 (not (eq gnus-current-article article))))
6160 ;; The requested article is different from the current article.
6162 (gnus-summary-display-article article all-headers)
6163 (when (gnus-buffer-live-p gnus-article-buffer)
6164 (with-current-buffer gnus-article-buffer
6165 (if (not gnus-article-decoded-p) ;; a local variable
6166 (mm-disable-multibyte-mule4))))
6167 (when (or all-headers gnus-show-all-headers)
6168 (gnus-article-show-all-headers))
6169 (gnus-article-set-window-start
6170 (cdr (assq article gnus-newsgroup-bookmarks)))
6172 (when (or all-headers gnus-show-all-headers)
6173 (gnus-article-show-all-headers))
6176 (defun gnus-summary-force-verify-and-decrypt ()
6178 (let ((mm-verify-option 'known)
6179 (mm-decrypt-option 'known))
6180 (gnus-summary-select-article nil 'force)))
6182 (defun gnus-summary-set-current-mark (&optional current-mark)
6183 "Obsolete function."
6186 (defun gnus-summary-next-article (&optional unread subject backward push)
6187 "Select the next article.
6188 If UNREAD, only unread articles are selected.
6189 If SUBJECT, only articles with SUBJECT are selected.
6190 If BACKWARD, the previous article is selected instead of the next."
6193 ;; Is there such an article?
6194 ((and (gnus-summary-search-forward unread subject backward)
6195 (or (gnus-summary-display-article (gnus-summary-article-number))
6196 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6197 (gnus-summary-position-point))
6198 ;; If not, we try the first unread, if that is wanted.
6200 gnus-auto-select-same
6201 (gnus-summary-first-unread-article))
6202 (gnus-summary-position-point)
6203 (gnus-message 6 "Wrapped"))
6204 ;; Try to get next/previous article not displayed in this group.
6205 ((and gnus-auto-extend-newsgroup
6206 (not unread) (not subject))
6207 (gnus-summary-goto-article
6208 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6209 nil (count-lines (point-min) (point))))
6210 ;; Go to next/previous group.
6212 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6213 (gnus-summary-jump-to-group gnus-newsgroup-name))
6214 (let ((cmd last-command-char)
6217 (set-buffer gnus-group-buffer)
6220 (if (eq gnus-keep-same-level 'best)
6221 (gnus-summary-best-group gnus-newsgroup-name)
6222 (gnus-summary-search-group backward gnus-keep-same-level))))
6223 ;; For some reason, the group window gets selected. We change
6225 (select-window (get-buffer-window (current-buffer)))
6226 ;; Select next unread newsgroup automagically.
6228 ((or (not gnus-auto-select-next)
6230 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6231 ((or (eq gnus-auto-select-next 'quietly)
6232 (and (eq gnus-auto-select-next 'slightly-quietly)
6234 (and (eq gnus-auto-select-next 'almost-quietly)
6235 (gnus-summary-last-article-p)))
6237 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6239 (gnus-message 7 "No more%s articles (%s)..."
6240 (if unread " unread" "")
6241 (if group (concat "selecting " group)
6243 (gnus-summary-next-group nil group backward)))
6245 (when (gnus-key-press-event-p last-input-event)
6246 (gnus-summary-walk-group-buffer
6247 gnus-newsgroup-name cmd unread backward point))))))))
6249 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6250 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6251 (?\C-p (gnus-group-prev-unread-group 1))))
6252 (cursor-in-echo-area t)
6253 keve key group ended)
6255 (set-buffer gnus-group-buffer)
6258 (if (eq gnus-keep-same-level 'best)
6259 (gnus-summary-best-group gnus-newsgroup-name)
6260 (gnus-summary-search-group backward gnus-keep-same-level))))
6263 5 "No more%s articles%s" (if unread " unread" "")
6265 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6266 (format " (Type %s for %s [%s])"
6267 (single-key-description cmd) group
6268 (car (gnus-gethash group gnus-newsrc-hashtb)))
6269 (format " (Type %s to exit %s)"
6270 (single-key-description cmd)
6271 gnus-newsgroup-name)))
6272 ;; Confirm auto selection.
6273 (setq key (car (setq keve (gnus-read-event-char))))
6276 ((assq key keystrokes)
6277 (let ((obuf (current-buffer)))
6278 (switch-to-buffer gnus-group-buffer)
6280 (gnus-group-jump-to-group group))
6281 (eval (cadr (assq key keystrokes)))
6282 (setq group (gnus-group-group-name))
6283 (switch-to-buffer obuf))
6287 (gnus-ephemeral-group-p gnus-newsgroup-name))
6289 (gnus-summary-next-group nil group backward)))
6291 (push (cdr keve) unread-command-events))))))
6293 (defun gnus-summary-next-unread-article ()
6294 "Select unread article after current one."
6296 (gnus-summary-next-article
6297 (or (not (eq gnus-summary-goto-unread 'never))
6298 (gnus-summary-last-article-p (gnus-summary-article-number)))
6299 (and gnus-auto-select-same
6300 (gnus-summary-article-subject))))
6302 (defun gnus-summary-prev-article (&optional unread subject)
6303 "Select the article after the current one.
6304 If UNREAD is non-nil, only unread articles are selected."
6306 (gnus-summary-next-article unread subject t))
6308 (defun gnus-summary-prev-unread-article ()
6309 "Select unread article before current one."
6311 (gnus-summary-prev-article
6312 (or (not (eq gnus-summary-goto-unread 'never))
6313 (gnus-summary-first-article-p (gnus-summary-article-number)))
6314 (and gnus-auto-select-same
6315 (gnus-summary-article-subject))))
6317 (defun gnus-summary-next-page (&optional lines circular)
6318 "Show next page of the selected article.
6319 If at the end of the current article, select the next article.
6320 LINES says how many lines should be scrolled up.
6322 If CIRCULAR is non-nil, go to the start of the article instead of
6323 selecting the next article when reaching the end of the current
6326 (setq gnus-summary-buffer (current-buffer))
6327 (gnus-set-global-variables)
6328 (let ((article (gnus-summary-article-number))
6329 (article-window (get-buffer-window gnus-article-buffer t))
6331 ;; If the buffer is empty, we have no article.
6333 (error "No article to select"))
6334 (gnus-configure-windows 'article)
6335 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6336 (if (and (eq gnus-summary-goto-unread 'never)
6337 (not (gnus-summary-last-article-p article)))
6338 (gnus-summary-next-article)
6339 (gnus-summary-next-unread-article))
6340 (if (or (null gnus-current-article)
6341 (null gnus-article-current)
6342 (/= article (cdr gnus-article-current))
6343 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6344 ;; Selected subject is different from current article's.
6345 (gnus-summary-display-article article)
6346 (when article-window
6347 (gnus-eval-in-buffer-window gnus-article-buffer
6348 (setq endp (gnus-article-next-page lines)))
6351 (gnus-summary-beginning-of-article))
6353 (gnus-message 3 "End of message"))
6355 (if (and (eq gnus-summary-goto-unread 'never)
6356 (not (gnus-summary-last-article-p article)))
6357 (gnus-summary-next-article)
6358 (gnus-summary-next-unread-article))))))))
6359 (gnus-summary-recenter)
6360 (gnus-summary-position-point)))
6362 (defun gnus-summary-prev-page (&optional lines move)
6363 "Show previous page of selected article.
6364 Argument LINES specifies lines to be scrolled down.
6365 If MOVE, move to the previous unread article if point is at
6366 the beginning of the buffer."
6368 (let ((article (gnus-summary-article-number))
6369 (article-window (get-buffer-window gnus-article-buffer t))
6371 (gnus-configure-windows 'article)
6372 (if (or (null gnus-current-article)
6373 (null gnus-article-current)
6374 (/= article (cdr gnus-article-current))
6375 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6376 ;; Selected subject is different from current article's.
6377 (gnus-summary-display-article article)
6378 (gnus-summary-recenter)
6379 (when article-window
6380 (gnus-eval-in-buffer-window gnus-article-buffer
6381 (setq endp (gnus-article-prev-page lines)))
6382 (when (and move endp)
6384 (gnus-message 3 "Beginning of message"))
6386 (if (and (eq gnus-summary-goto-unread 'never)
6387 (not (gnus-summary-first-article-p article)))
6388 (gnus-summary-prev-article)
6389 (gnus-summary-prev-unread-article))))))))
6390 (gnus-summary-position-point))
6392 (defun gnus-summary-prev-page-or-article (&optional lines)
6393 "Show previous page of selected article.
6394 Argument LINES specifies lines to be scrolled down.
6395 If at the beginning of the article, go to the next article."
6397 (gnus-summary-prev-page lines t))
6399 (defun gnus-summary-scroll-up (lines)
6400 "Scroll up (or down) one line current article.
6401 Argument LINES specifies lines to be scrolled up (or down if negative)."
6403 (gnus-configure-windows 'article)
6404 (gnus-summary-show-thread)
6405 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6406 (gnus-eval-in-buffer-window gnus-article-buffer
6408 (when (gnus-article-next-page lines)
6409 (gnus-message 3 "End of message")))
6411 (gnus-article-prev-page (- lines))))))
6412 (gnus-summary-recenter)
6413 (gnus-summary-position-point))
6415 (defun gnus-summary-scroll-down (lines)
6416 "Scroll down (or up) one line current article.
6417 Argument LINES specifies lines to be scrolled down (or up if negative)."
6419 (gnus-summary-scroll-up (- lines)))
6421 (defun gnus-summary-next-same-subject ()
6422 "Select next article which has the same subject as current one."
6424 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6426 (defun gnus-summary-prev-same-subject ()
6427 "Select previous article which has the same subject as current one."
6429 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6431 (defun gnus-summary-next-unread-same-subject ()
6432 "Select next unread article which has the same subject as current one."
6434 (gnus-summary-next-article t (gnus-summary-article-subject)))
6436 (defun gnus-summary-prev-unread-same-subject ()
6437 "Select previous unread article which has the same subject as current one."
6439 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6441 (defun gnus-summary-first-unread-article ()
6442 "Select the first unread article.
6443 Return nil if there are no unread articles."
6446 (when (gnus-summary-first-subject t)
6447 (gnus-summary-show-thread)
6448 (gnus-summary-first-subject t)
6449 (gnus-summary-display-article (gnus-summary-article-number)))
6450 (gnus-summary-position-point)))
6452 (defun gnus-summary-first-unread-subject ()
6453 "Place the point on the subject line of the first unread article.
6454 Return nil if there are no unread articles."
6457 (when (gnus-summary-first-subject t)
6458 (gnus-summary-show-thread)
6459 (gnus-summary-first-subject t))
6460 (gnus-summary-position-point)))
6462 (defun gnus-summary-first-article ()
6463 "Select the first article.
6464 Return nil if there are no articles."
6467 (when (gnus-summary-first-subject)
6468 (gnus-summary-show-thread)
6469 (gnus-summary-first-subject)
6470 (gnus-summary-display-article (gnus-summary-article-number)))
6471 (gnus-summary-position-point)))
6473 (defun gnus-summary-best-unread-article ()
6474 "Select the unread article with the highest score."
6476 (let ((best -1000000)
6477 (data gnus-newsgroup-data)
6480 (and (gnus-data-unread-p (car data))
6482 (gnus-summary-article-score (gnus-data-number (car data))))
6485 article (gnus-data-number (car data))))
6486 (setq data (cdr data)))
6489 (gnus-summary-goto-article article)
6490 (error "No unread articles"))
6491 (gnus-summary-position-point))))
6493 (defun gnus-summary-last-subject ()
6494 "Go to the last displayed subject line in the group."
6495 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6497 (gnus-summary-goto-subject article))))
6499 (defun gnus-summary-goto-article (article &optional all-headers force)
6500 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6501 If ALL-HEADERS is non-nil, no header lines are hidden.
6502 If FORCE, go to the article even if it isn't displayed. If FORCE
6503 is a number, it is the line the article is to be displayed on."
6507 "Article number or Message-ID: "
6508 (mapcar (lambda (number) (list (int-to-string number)))
6509 gnus-newsgroup-limit))
6513 (if (and (stringp article)
6514 (string-match "@" article))
6515 (gnus-summary-refer-article article)
6516 (when (stringp article)
6517 (setq article (string-to-number article)))
6518 (if (gnus-summary-goto-subject article force)
6519 (gnus-summary-display-article article all-headers)
6520 (gnus-message 4 "Couldn't go to article %s" article) nil))
6521 (gnus-summary-position-point)))
6523 (defun gnus-summary-goto-last-article ()
6524 "Go to the previously read article."
6527 (when gnus-last-article
6528 (gnus-summary-goto-article gnus-last-article nil t))
6529 (gnus-summary-position-point)))
6531 (defun gnus-summary-pop-article (number)
6532 "Pop one article off the history and go to the previous.
6533 NUMBER articles will be popped off."
6536 (setq gnus-newsgroup-history
6537 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6539 (gnus-summary-goto-article (car to) nil t)
6540 (error "Article history empty")))
6541 (gnus-summary-position-point))
6543 ;; Summary commands and functions for limiting the summary buffer.
6545 (defun gnus-summary-limit-to-articles (n)
6546 "Limit the summary buffer to the next N articles.
6547 If not given a prefix, use the process marked articles instead."
6550 (let ((articles (gnus-summary-work-articles n)))
6551 (setq gnus-newsgroup-processable nil)
6552 (gnus-summary-limit articles))
6553 (gnus-summary-position-point)))
6555 (defun gnus-summary-pop-limit (&optional total)
6556 "Restore the previous limit.
6557 If given a prefix, remove all limits."
6560 (setq gnus-newsgroup-limits
6561 (list (mapcar (lambda (h) (mail-header-number h))
6562 gnus-newsgroup-headers))))
6563 (unless gnus-newsgroup-limits
6564 (error "No limit to pop"))
6566 (gnus-summary-limit nil 'pop)
6567 (gnus-summary-position-point)))
6569 (defun gnus-summary-limit-to-subject (subject &optional header)
6570 "Limit the summary buffer to articles that have subjects that match a regexp."
6571 (interactive "sLimit to subject (regexp): ")
6573 (setq header "subject"))
6574 (when (not (equal "" subject))
6576 (let ((articles (gnus-summary-find-matching
6577 (or header "subject") subject 'all)))
6579 (error "Found no matches for \"%s\"" subject))
6580 (gnus-summary-limit articles))
6581 (gnus-summary-position-point))))
6583 (defun gnus-summary-limit-to-author (from)
6584 "Limit the summary buffer to articles that have authors that match a regexp."
6585 (interactive "sLimit to author (regexp): ")
6586 (gnus-summary-limit-to-subject from "from"))
6588 (defun gnus-summary-limit-to-age (age &optional younger-p)
6589 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6590 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6591 articles that are younger than AGE days."
6593 (let ((younger current-prefix-arg)
6596 (while (not days-got)
6597 (setq days (if younger
6598 (read-string "Limit to articles within (in days): ")
6599 (read-string "Limit to articles older than (in days): ")))
6600 (when (> (length days) 0)
6601 (setq days (read days)))
6604 (message "Please enter a number.")
6606 (list days younger)))
6608 (let ((data gnus-newsgroup-data)
6609 (cutoff (days-to-time age))
6610 articles d date is-younger)
6611 (while (setq d (pop data))
6612 (when (and (vectorp (gnus-data-header d))
6613 (setq date (mail-header-date (gnus-data-header d))))
6614 (setq is-younger (time-less-p
6615 (time-since (condition-case ()
6622 (push (gnus-data-number d) articles))))
6623 (gnus-summary-limit (nreverse articles)))
6624 (gnus-summary-position-point)))
6626 (defun gnus-summary-limit-to-extra (header regexp)
6627 "Limit the summary buffer to articles that match an 'extra' header."
6631 (gnus-completing-read
6632 (symbol-name (car gnus-extra-headers))
6633 "Limit extra header:"
6635 (cons (symbol-name x) x))
6640 (read-string (format "Limit to header %s (regexp): " header)))))
6641 (when (not (equal "" regexp))
6643 (let ((articles (gnus-summary-find-matching
6644 (cons 'extra header) regexp 'all)))
6646 (error "Found no matches for \"%s\"" regexp))
6647 (gnus-summary-limit articles))
6648 (gnus-summary-position-point))))
6650 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6652 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6654 (defun gnus-summary-limit-to-unread (&optional all)
6655 "Limit the summary buffer to articles that are not marked as read.
6656 If ALL is non-nil, limit strictly to unread articles."
6659 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6660 (gnus-summary-limit-to-marks
6661 ;; Concat all the marks that say that an article is read and have
6663 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6664 gnus-killed-mark gnus-kill-file-mark
6665 gnus-low-score-mark gnus-expirable-mark
6666 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6667 gnus-duplicate-mark gnus-souped-mark)
6670 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6671 (make-obsolete 'gnus-summary-delete-marked-with
6672 'gnus-summary-limit-exlude-marks)
6674 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6675 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6676 If REVERSE, limit the summary buffer to articles that are marked
6677 with MARKS. MARKS can either be a string of marks or a list of marks.
6678 Returns how many articles were removed."
6679 (interactive "sMarks: ")
6680 (gnus-summary-limit-to-marks marks t))
6682 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6683 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6684 If REVERSE (the prefix), limit the summary buffer to articles that are
6685 not marked with MARKS. MARKS can either be a string of marks or a
6687 Returns how many articles were removed."
6688 (interactive "sMarks: \nP")
6690 (let ((data gnus-newsgroup-data)
6691 (marks (if (listp marks) marks
6692 (append marks nil))) ; Transform to list.
6695 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6696 (memq (gnus-data-mark (car data)) marks))
6697 (push (gnus-data-number (car data)) articles))
6698 (setq data (cdr data)))
6699 (gnus-summary-limit articles))
6700 (gnus-summary-position-point)))
6702 (defun gnus-summary-limit-to-score (&optional score)
6703 "Limit to articles with score at or above SCORE."
6705 (setq score (if score
6706 (prefix-numeric-value score)
6707 (or gnus-summary-default-score 0)))
6708 (let ((data gnus-newsgroup-data)
6711 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6713 (push (gnus-data-number (car data)) articles))
6714 (setq data (cdr data)))
6716 (gnus-summary-limit articles)
6717 (gnus-summary-position-point))))
6719 (defun gnus-summary-limit-include-thread (id)
6720 "Display all the hidden articles that is in the thread with ID in it.
6721 When called interactively, ID is the Message-ID of the current
6723 (interactive (list (mail-header-id (gnus-summary-article-header))))
6724 (let ((articles (gnus-articles-in-thread
6725 (gnus-id-to-thread (gnus-root-id id)))))
6727 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6728 (gnus-summary-limit-include-matching-articles
6730 (regexp-quote (gnus-simplify-subject-re
6731 (mail-header-subject (gnus-id-to-header id)))))
6732 (gnus-summary-position-point))))
6734 (defun gnus-summary-limit-include-matching-articles (header regexp)
6735 "Display all the hidden articles that have HEADERs that match REGEXP."
6736 (interactive (list (read-string "Match on header: ")
6737 (read-string "Regexp: ")))
6738 (let ((articles (gnus-find-matching-articles header regexp)))
6740 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6741 (gnus-summary-position-point))))
6743 (defun gnus-summary-limit-include-dormant ()
6744 "Display all the hidden articles that are marked as dormant.
6745 Note that this command only works on a subset of the articles currently
6746 fetched for this group."
6748 (unless gnus-newsgroup-dormant
6749 (error "There are no dormant articles in this group"))
6751 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6752 (gnus-summary-position-point)))
6754 (defun gnus-summary-limit-exclude-dormant ()
6755 "Hide all dormant articles."
6758 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6759 (gnus-summary-position-point)))
6761 (defun gnus-summary-limit-exclude-childless-dormant ()
6762 "Hide all dormant articles that have no children."
6764 (let ((data (gnus-data-list t))
6765 articles d children)
6766 ;; Find all articles that are either not dormant or have
6768 (while (setq d (pop data))
6769 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6771 (gnus-article-children (gnus-data-number d)))
6774 (when (memq (car children) articles)
6779 (push (gnus-data-number d) articles)))
6782 (gnus-summary-limit articles)
6783 (gnus-summary-position-point))))
6785 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6786 "Mark all unread excluded articles as read.
6787 If ALL, mark even excluded ticked and dormants as read."
6789 (let ((articles (gnus-sorted-complement
6791 (mapcar (lambda (h) (mail-header-number h))
6792 gnus-newsgroup-headers)
6794 (sort gnus-newsgroup-limit '<)))
6796 (setq gnus-newsgroup-unreads
6797 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6799 (setq gnus-newsgroup-dormant nil
6800 gnus-newsgroup-marked nil
6801 gnus-newsgroup-reads
6803 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6804 gnus-newsgroup-reads))
6805 (while (setq article (pop articles))
6806 (unless (or (memq article gnus-newsgroup-dormant)
6807 (memq article gnus-newsgroup-marked))
6808 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6810 (defun gnus-summary-limit (articles &optional pop)
6812 ;; We pop the previous limit off the stack and use that.
6813 (setq articles (car gnus-newsgroup-limits)
6814 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6815 ;; We use the new limit, so we push the old limit on the stack.
6816 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6818 (setq gnus-newsgroup-limit articles)
6819 (let ((total (length gnus-newsgroup-data))
6820 (data (gnus-data-find-list (gnus-summary-article-number)))
6821 (gnus-summary-mark-below nil) ; Inhibit this.
6823 ;; This will do all the work of generating the new summary buffer
6824 ;; according to the new limit.
6825 (gnus-summary-prepare)
6826 ;; Hide any threads, possibly.
6827 (and gnus-show-threads
6828 gnus-thread-hide-subtree
6829 (gnus-summary-hide-all-threads))
6830 ;; Try to return to the article you were at, or one in the
6833 ;; We try to find some article after the current one.
6835 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6838 (setq data (cdr data))))
6840 ;; If there is no data, that means that we were after the last
6841 ;; article. The same goes when we can't find any articles
6842 ;; after the current one.
6843 (goto-char (point-max))
6844 (gnus-summary-find-prev))
6845 (gnus-set-mode-line 'summary)
6846 ;; We return how many articles were removed from the summary
6847 ;; buffer as a result of the new limit.
6848 (- total (length gnus-newsgroup-data))))
6850 (defsubst gnus-invisible-cut-children (threads)
6853 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6858 (defsubst gnus-cut-thread (thread)
6859 "Go forwards in the thread until we find an article that we want to display."
6860 (when (or (eq gnus-fetch-old-headers 'some)
6861 (eq gnus-fetch-old-headers 'invisible)
6862 (numberp gnus-fetch-old-headers)
6863 (eq gnus-build-sparse-threads 'some)
6864 (eq gnus-build-sparse-threads 'more))
6865 ;; Deal with old-fetched headers and sparse threads.
6869 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6870 (gnus-summary-article-ancient-p
6871 (mail-header-number (car thread))))
6872 (if (or (<= (length (cdr thread)) 1)
6873 (eq gnus-fetch-old-headers 'invisible))
6874 (setq gnus-newsgroup-limit
6875 (delq (mail-header-number (car thread))
6876 gnus-newsgroup-limit)
6877 thread (cadr thread))
6878 (when (gnus-invisible-cut-children (cdr thread))
6879 (let ((th (cdr thread)))
6881 (if (memq (mail-header-number (caar th))
6882 gnus-newsgroup-limit)
6883 (setq thread (car th)
6885 (setq th (cdr th))))))))))
6888 (defun gnus-cut-threads (threads)
6889 "Cut off all uninteresting articles from the beginning of threads."
6890 (when (or (eq gnus-fetch-old-headers 'some)
6891 (eq gnus-fetch-old-headers 'invisible)
6892 (numberp gnus-fetch-old-headers)
6893 (eq gnus-build-sparse-threads 'some)
6894 (eq gnus-build-sparse-threads 'more))
6897 (setcar th (gnus-cut-thread (car th)))
6898 (setq th (cdr th)))))
6899 ;; Remove nixed out threads.
6902 (defun gnus-summary-initial-limit (&optional show-if-empty)
6903 "Figure out what the initial limit is supposed to be on group entry.
6904 This entails weeding out unwanted dormants, low-scored articles,
6905 fetch-old-headers verbiage, and so on."
6906 ;; Most groups have nothing to remove.
6907 (if (or gnus-inhibit-limiting
6908 (and (null gnus-newsgroup-dormant)
6909 (not (eq gnus-fetch-old-headers 'some))
6910 (not (numberp gnus-fetch-old-headers))
6911 (not (eq gnus-fetch-old-headers 'invisible))
6912 (null gnus-summary-expunge-below)
6913 (not (eq gnus-build-sparse-threads 'some))
6914 (not (eq gnus-build-sparse-threads 'more))
6915 (null gnus-thread-expunge-below)
6916 (not gnus-use-nocem)))
6918 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6919 (setq gnus-newsgroup-limit nil)
6922 (unless (car (symbol-value node))
6923 ;; These threads have no parents -- they are roots.
6924 (let ((nodes (cdr (symbol-value node)))
6927 (if (and gnus-thread-expunge-below
6928 (< (gnus-thread-total-score (car nodes))
6929 gnus-thread-expunge-below))
6930 (gnus-expunge-thread (pop nodes))
6931 (setq thread (pop nodes))
6932 (gnus-summary-limit-children thread))))))
6933 gnus-newsgroup-dependencies)
6934 ;; If this limitation resulted in an empty group, we might
6935 ;; pop the previous limit and use it instead.
6936 (when (and (not gnus-newsgroup-limit)
6938 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6939 gnus-newsgroup-limit))
6941 (defun gnus-summary-limit-children (thread)
6942 "Return 1 if this subthread is visible and 0 if it is not."
6943 ;; First we get the number of visible children to this thread. This
6944 ;; is done by recursing down the thread using this function, so this
6945 ;; will really go down to a leaf article first, before slowly
6946 ;; working its way up towards the root.
6950 (apply '+ (mapcar 'gnus-summary-limit-children
6953 (number (mail-header-number (car thread)))
6956 (not (memq number gnus-newsgroup-marked))
6958 ;; If this article is dormant and has absolutely no visible
6959 ;; children, then this article isn't visible.
6960 (and (memq number gnus-newsgroup-dormant)
6962 ;; If this is "fetch-old-headered" and there is no
6963 ;; visible children, then we don't want this article.
6964 (and (or (eq gnus-fetch-old-headers 'some)
6965 (numberp gnus-fetch-old-headers))
6966 (gnus-summary-article-ancient-p number)
6968 ;; If this is "fetch-old-headered" and `invisible', then
6969 ;; we don't want this article.
6970 (and (eq gnus-fetch-old-headers 'invisible)
6971 (gnus-summary-article-ancient-p number))
6972 ;; If this is a sparsely inserted article with no children,
6973 ;; we don't want it.
6974 (and (eq gnus-build-sparse-threads 'some)
6975 (gnus-summary-article-sparse-p number)
6977 ;; If we use expunging, and this article is really
6978 ;; low-scored, then we don't want this article.
6979 (when (and gnus-summary-expunge-below
6981 (or (cdr (assq number gnus-newsgroup-scored))
6982 gnus-summary-default-score))
6983 gnus-summary-expunge-below))
6984 ;; We increase the expunge-tally here, but that has
6985 ;; nothing to do with the limits, really.
6986 (incf gnus-newsgroup-expunged-tally)
6987 ;; We also mark as read here, if that's wanted.
6988 (when (and gnus-summary-mark-below
6989 (< score gnus-summary-mark-below))
6990 (setq gnus-newsgroup-unreads
6991 (delq number gnus-newsgroup-unreads))
6992 (if gnus-newsgroup-auto-expire
6993 (push number gnus-newsgroup-expirable)
6994 (push (cons number gnus-low-score-mark)
6995 gnus-newsgroup-reads)))
6997 ;; Check NoCeM things.
6998 (if (and gnus-use-nocem
6999 (gnus-nocem-unwanted-article-p
7000 (mail-header-id (car thread))))
7002 (setq gnus-newsgroup-unreads
7003 (delq number gnus-newsgroup-unreads))
7005 ;; Nope, invisible article.
7007 ;; Ok, this article is to be visible, so we add it to the limit
7009 (push number gnus-newsgroup-limit)
7012 (defun gnus-expunge-thread (thread)
7013 "Mark all articles in THREAD as read."
7014 (let* ((number (mail-header-number (car thread))))
7015 (incf gnus-newsgroup-expunged-tally)
7016 ;; We also mark as read here, if that's wanted.
7017 (setq gnus-newsgroup-unreads
7018 (delq number gnus-newsgroup-unreads))
7019 (if gnus-newsgroup-auto-expire
7020 (push number gnus-newsgroup-expirable)
7021 (push (cons number gnus-low-score-mark)
7022 gnus-newsgroup-reads)))
7023 ;; Go recursively through all subthreads.
7024 (mapcar 'gnus-expunge-thread (cdr thread)))
7026 ;; Summary article oriented commands
7028 (defun gnus-summary-refer-parent-article (n)
7029 "Refer parent article N times.
7030 If N is negative, go to ancestor -N instead.
7031 The difference between N and the number of articles fetched is returned."
7035 (when (not (natnump n))
7040 (setq header (gnus-summary-article-header))
7041 (if (and (eq (mail-header-number header)
7042 (cdr gnus-article-current))
7043 (equal gnus-newsgroup-name
7044 (car gnus-article-current)))
7045 ;; If we try to find the parent of the currently
7046 ;; displayed article, then we take a look at the actual
7047 ;; References header, since this is slightly more
7048 ;; reliable than the References field we got from the
7051 (set-buffer gnus-original-article-buffer)
7052 (nnheader-narrow-to-headers)
7053 (unless (setq ref (message-fetch-field "references"))
7054 (setq ref (message-fetch-field "in-reply-to")))
7057 ;; It's not the current article, so we take a bet on
7058 ;; the value we got from the server.
7059 (mail-header-references header)))
7061 (not (equal ref "")))
7062 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7063 (gnus-message 1 "Couldn't find parent"))
7064 (gnus-message 1 "No references in article %d"
7065 (gnus-summary-article-number))
7068 (gnus-summary-position-point)
7071 (defun gnus-summary-refer-references ()
7072 "Fetch all articles mentioned in the References header.
7073 Return the number of articles fetched."
7075 (let ((ref (mail-header-references (gnus-summary-article-header)))
7076 (current (gnus-summary-article-number))
7080 (error "No References in the current article")
7081 ;; For each Message-ID in the References header...
7082 (while (string-match "<[^>]*>" ref)
7084 ;; ... fetch that article.
7085 (gnus-summary-refer-article
7086 (prog1 (match-string 0 ref)
7087 (setq ref (substring ref (match-end 0))))))
7088 (gnus-summary-goto-subject current)
7089 (gnus-summary-position-point)
7092 (defun gnus-summary-refer-thread (&optional limit)
7093 "Fetch all articles in the current thread.
7094 If LIMIT (the numerical prefix), fetch that many old headers instead
7095 of what's specified by the `gnus-refer-thread-limit' variable."
7097 (let ((id (mail-header-id (gnus-summary-article-header)))
7098 (limit (if limit (prefix-numeric-value limit)
7099 gnus-refer-thread-limit)))
7100 ;; We want to fetch LIMIT *old* headers, but we also have to
7101 ;; re-fetch all the headers in the current buffer, because many of
7102 ;; them may be undisplayed. So we adjust LIMIT.
7103 (when (numberp limit)
7104 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7105 (unless (eq gnus-fetch-old-headers 'invisible)
7106 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7107 ;; Retrieve the headers and read them in.
7108 (if (eq (gnus-retrieve-headers
7109 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7111 (gnus-build-all-threads)
7112 (error "Can't fetch thread from backends that don't support NOV"))
7113 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7114 (gnus-summary-limit-include-thread id)))
7116 (defun gnus-summary-refer-article (message-id)
7117 "Fetch an article specified by MESSAGE-ID."
7118 (interactive "sMessage-ID: ")
7119 (when (and (stringp message-id)
7120 (not (zerop (length message-id))))
7121 ;; Construct the correct Message-ID if necessary.
7122 ;; Suggested by tale@pawl.rpi.edu.
7123 (unless (string-match "^<" message-id)
7124 (setq message-id (concat "<" message-id)))
7125 (unless (string-match ">$" message-id)
7126 (setq message-id (concat message-id ">")))
7127 (let* ((header (gnus-id-to-header message-id))
7129 (gnus-summary-article-sparse-p
7130 (mail-header-number header))
7131 (memq (mail-header-number header)
7132 gnus-newsgroup-limit)))
7135 ;; If the article is present in the buffer we just go to it.
7137 (or (not (gnus-summary-article-sparse-p
7138 (mail-header-number header)))
7141 (gnus-summary-goto-article
7142 (mail-header-number header) nil t)
7144 (gnus-summary-update-article (mail-header-number header)))))
7146 ;; We fetch the article.
7148 (dolist (gnus-override-method (gnus-refer-article-methods))
7149 (gnus-check-server gnus-override-method)
7150 ;; Fetch the header, and display the article.
7151 (when (setq number (gnus-summary-insert-subject message-id))
7152 (gnus-summary-select-article nil nil nil number)
7154 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7156 (defun gnus-refer-article-methods ()
7157 "Return a list of referrable methods."
7159 ;; No method, so we default to current and native.
7160 ((null gnus-refer-article-method)
7161 (list gnus-current-select-method gnus-select-method))
7163 ((eq 'current gnus-refer-article-method)
7164 (list gnus-current-select-method))
7165 ;; List of select methods.
7166 ((not (and (symbolp (car gnus-refer-article-method))
7167 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7169 (dolist (method gnus-refer-article-method)
7170 (push (if (eq 'current method)
7171 gnus-current-select-method
7175 ;; One single select method.
7177 (list gnus-refer-article-method))))
7179 (defun gnus-summary-edit-parameters ()
7180 "Edit the group parameters of the current group."
7182 (gnus-group-edit-group gnus-newsgroup-name 'params))
7184 (defun gnus-summary-customize-parameters ()
7185 "Customize the group parameters of the current group."
7187 (gnus-group-customize gnus-newsgroup-name))
7189 (defun gnus-summary-enter-digest-group (&optional force)
7190 "Enter an nndoc group based on the current article.
7191 If FORCE, force a digest interpretation. If not, try
7192 to guess what the document format is."
7194 (let ((conf gnus-current-window-configuration))
7196 (gnus-summary-select-article))
7197 (setq gnus-current-window-configuration conf)
7198 (let* ((name (format "%s-%d"
7199 (gnus-group-prefixed-name
7200 gnus-newsgroup-name (list 'nndoc ""))
7202 (set-buffer gnus-summary-buffer)
7203 gnus-current-article)))
7204 (ogroup gnus-newsgroup-name)
7205 (params (append (gnus-info-params (gnus-get-info ogroup))
7206 (list (cons 'to-group ogroup))
7207 (list (cons 'save-article-group ogroup))))
7208 (case-fold-search t)
7209 (buf (current-buffer))
7212 (set-buffer gnus-original-article-buffer)
7213 ;; Have the digest group inherit the main mail address of
7214 ;; the parent article.
7215 (when (setq to-address (or (message-fetch-field "reply-to")
7216 (message-fetch-field "from")))
7217 (setq params (append
7218 (list (cons 'to-address
7219 (funcall gnus-decode-encoded-word-function
7221 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7222 (insert-buffer-substring gnus-original-article-buffer)
7223 ;; Remove lines that may lead nndoc to misinterpret the
7226 (goto-char (point-min))
7227 (or (search-forward "\n\n" nil t) (point)))
7228 (goto-char (point-min))
7229 (delete-matching-lines "^Path:\\|^From ")
7232 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7233 (gnus-newsgroup-ephemeral-ignored-charsets
7234 gnus-newsgroup-ignored-charsets))
7235 (gnus-group-read-ephemeral-group
7236 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7238 ,(if force 'mbox 'guess))) t))
7239 ;; Make all postings to this group go to the parent group.
7240 (nconc (gnus-info-params (gnus-get-info name))
7242 ;; Couldn't select this doc group.
7243 (switch-to-buffer buf)
7244 (gnus-set-global-variables)
7245 (gnus-configure-windows 'summary)
7246 (gnus-message 3 "Article couldn't be entered?"))
7247 (kill-buffer dig)))))
7249 (defun gnus-summary-read-document (n)
7250 "Open a new group based on the current article(s).
7251 This will allow you to read digests and other similar
7252 documents as newsgroups.
7253 Obeys the standard process/prefix convention."
7255 (let* ((articles (gnus-summary-work-articles n))
7256 (ogroup gnus-newsgroup-name)
7257 (params (append (gnus-info-params (gnus-get-info ogroup))
7258 (list (cons 'to-group ogroup))))
7259 article group egroup groups vgroup)
7260 (while (setq article (pop articles))
7261 (setq group (format "%s-%d" gnus-newsgroup-name article))
7262 (gnus-summary-remove-process-mark article)
7263 (when (gnus-summary-display-article article)
7266 (insert-buffer-substring gnus-original-article-buffer)
7267 ;; Remove some headers that may lead nndoc to make
7269 (message-narrow-to-head)
7270 (goto-char (point-min))
7271 (delete-matching-lines "^\\(Path\\):\\|^From ")
7274 (gnus-group-read-ephemeral-group
7275 group `(nndoc ,group (nndoc-address ,(current-buffer))
7276 (nndoc-article-type guess))
7279 ;; Make all postings to this group go to the parent group.
7280 (nconc (gnus-info-params (gnus-get-info egroup))
7282 (push egroup groups))
7283 ;; Couldn't select this doc group.
7284 (gnus-error 3 "Article couldn't be entered"))))))
7285 ;; Now we have selected all the documents.
7288 (error "None of the articles could be interpreted as documents"))
7289 ((gnus-group-read-ephemeral-group
7290 (setq vgroup (format
7291 "nnvirtual:%s-%s" gnus-newsgroup-name
7292 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7293 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7295 (cons (current-buffer) 'summary)))
7297 (error "Couldn't select virtual nndoc group")))))
7299 (defun gnus-summary-isearch-article (&optional regexp-p)
7300 "Do incremental search forward on the current article.
7301 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7303 (gnus-summary-select-article)
7304 (gnus-configure-windows 'article)
7305 (gnus-eval-in-buffer-window gnus-article-buffer
7308 (isearch-forward regexp-p))))
7310 (defun gnus-summary-search-article-forward (regexp &optional backward)
7311 "Search for an article containing REGEXP forward.
7312 If BACKWARD, search backward instead."
7315 (format "Search article %s (regexp%s): "
7316 (if current-prefix-arg "backward" "forward")
7317 (if gnus-last-search-regexp
7318 (concat ", default " gnus-last-search-regexp)
7320 current-prefix-arg))
7321 (if (string-equal regexp "")
7322 (setq regexp (or gnus-last-search-regexp ""))
7323 (setq gnus-last-search-regexp regexp)
7324 (setq gnus-article-before-search gnus-current-article))
7325 ;; Intentionally set gnus-last-article.
7326 (setq gnus-last-article gnus-article-before-search)
7327 (let ((gnus-last-article gnus-last-article))
7328 (if (gnus-summary-search-article regexp backward)
7329 (gnus-summary-show-thread)
7330 (error "Search failed: \"%s\"" regexp))))
7332 (defun gnus-summary-search-article-backward (regexp)
7333 "Search for an article containing REGEXP backward."
7336 (format "Search article backward (regexp%s): "
7337 (if gnus-last-search-regexp
7338 (concat ", default " gnus-last-search-regexp)
7340 (gnus-summary-search-article-forward regexp 'backward))
7342 (defun gnus-summary-search-article (regexp &optional backward)
7343 "Search for an article containing REGEXP.
7344 Optional argument BACKWARD means do search for backward.
7345 `gnus-select-article-hook' is not called during the search."
7346 ;; We have to require this here to make sure that the following
7347 ;; dynamic binding isn't shadowed by autoloading.
7348 (require 'gnus-async)
7350 (let ((gnus-select-article-hook nil) ;Disable hook.
7351 (gnus-article-prepare-hook nil)
7352 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7353 (gnus-use-article-prefetch nil)
7354 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7355 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7356 (sum (current-buffer))
7357 (gnus-display-mime-function nil)
7360 (gnus-save-hidden-threads
7361 (gnus-summary-select-article)
7362 (set-buffer gnus-article-buffer)
7363 (goto-char (window-point (get-buffer-window (current-buffer))))
7367 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7369 (re-search-backward regexp nil t)
7370 (re-search-forward regexp nil t))
7371 ;; We found the regexp.
7376 (get-buffer-window (current-buffer))
7380 (get-buffer-window (current-buffer))
7383 (setq point (point)))
7384 ;; We didn't find it, so we go to the next article.
7387 (while (eq found 'not)
7388 (if (not (if backward (gnus-summary-find-prev)
7389 (gnus-summary-find-next)))
7390 ;; No more articles.
7392 ;; Select the next article and adjust point.
7393 (unless (gnus-summary-article-sparse-p
7394 (gnus-summary-article-number))
7396 (gnus-summary-select-article)
7397 (set-buffer gnus-article-buffer)
7399 (goto-char (if backward (point-max) (point-min))))))))
7400 (gnus-message 7 ""))
7401 ;; Return whether we found the regexp.
7402 (when (eq found 'found)
7404 (gnus-summary-show-thread)
7405 (gnus-summary-goto-subject gnus-current-article)
7406 (gnus-summary-position-point)
7409 (defun gnus-find-matching-articles (header regexp)
7410 "Return a list of all articles that match REGEXP on HEADER.
7411 This search includes all articles in the current group that Gnus has
7412 fetched headers for, whether they are displayed or not."
7413 (let ((articles nil)
7414 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7415 (case-fold-search t))
7416 (dolist (header gnus-newsgroup-headers)
7417 (when (string-match regexp (funcall func header))
7418 (push (mail-header-number header) articles)))
7419 (nreverse articles)))
7421 (defun gnus-summary-find-matching (header regexp &optional backward unread
7423 "Return a list of all articles that match REGEXP on HEADER.
7424 The search stars on the current article and goes forwards unless
7425 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7426 If UNREAD is non-nil, only unread articles will
7427 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7428 in the comparisons."
7429 (let ((case-fold-search (not not-case-fold))
7432 (if (eq (car header) 'extra)
7435 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7437 (error "%s is an invalid header" header))
7438 (unless (fboundp (intern (concat "mail-header-" header)))
7439 (error "%s is not a valid header" header))
7440 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7441 (dolist (d (if (eq backward 'all)
7443 (gnus-data-find-list
7444 (gnus-summary-article-number)
7445 (gnus-data-list backward))))
7446 (when (and (or (not unread) ; We want all articles...
7447 (gnus-data-unread-p d)) ; Or just unreads.
7448 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7449 (string-match regexp
7450 (funcall func (gnus-data-header d)))) ; Match.
7451 (push (gnus-data-number d) articles))) ; Success!
7452 (nreverse articles)))
7454 (defun gnus-summary-execute-command (header regexp command &optional backward)
7455 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7456 If HEADER is an empty string (or nil), the match is done on the entire
7457 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7459 (list (let ((completion-ignore-case t))
7462 (mapcar (lambda (string) (list string))
7463 '("Number" "Subject" "From" "Lines" "Date"
7464 "Message-ID" "Xref" "References" "Body"))
7465 nil 'require-match))
7466 (read-string "Regexp: ")
7467 (read-key-sequence "Command: ")
7468 current-prefix-arg))
7469 (when (equal header "Body")
7471 ;; Hidden thread subtrees must be searched as well.
7472 (gnus-summary-show-all-threads)
7473 ;; We don't want to change current point nor window configuration.
7475 (save-window-excursion
7476 (gnus-message 6 "Executing %s..." (key-description command))
7477 ;; We'd like to execute COMMAND interactively so as to give arguments.
7478 (gnus-execute header regexp
7479 `(call-interactively ',(key-binding command))
7481 (gnus-message 6 "Executing %s...done" (key-description command)))))
7483 (defun gnus-summary-beginning-of-article ()
7484 "Scroll the article back to the beginning."
7486 (gnus-summary-select-article)
7487 (gnus-configure-windows 'article)
7488 (gnus-eval-in-buffer-window gnus-article-buffer
7490 (goto-char (point-min))
7491 (when gnus-page-broken
7492 (gnus-narrow-to-page))))
7494 (defun gnus-summary-end-of-article ()
7495 "Scroll to the end of the article."
7497 (gnus-summary-select-article)
7498 (gnus-configure-windows 'article)
7499 (gnus-eval-in-buffer-window gnus-article-buffer
7501 (goto-char (point-max))
7503 (when gnus-page-broken
7504 (gnus-narrow-to-page))))
7506 (defun gnus-summary-print-article (&optional filename n)
7507 "Generate and print a PostScript image of the N next (mail) articles.
7509 If N is negative, print the N previous articles. If N is nil and articles
7510 have been marked with the process mark, print these instead.
7512 If the optional first argument FILENAME is nil, send the image to the
7513 printer. If FILENAME is a string, save the PostScript image in a file with
7514 that name. If FILENAME is a number, prompt the user for the name of the file
7516 (interactive (list (ps-print-preprint current-prefix-arg)))
7517 (dolist (article (gnus-summary-work-articles n))
7518 (gnus-summary-select-article nil nil 'pseudo article)
7519 (gnus-eval-in-buffer-window gnus-article-buffer
7520 (let ((buffer (generate-new-buffer " *print*")))
7523 (copy-to-buffer buffer (point-min) (point-max))
7525 (gnus-article-delete-invisible-text)
7526 (when (gnus-visual-p 'article-highlight 'highlight)
7527 ;; Copy-to-buffer doesn't copy overlay. So redo
7529 (let ((gnus-article-buffer buffer))
7530 (gnus-article-highlight-citation t)
7531 (gnus-article-highlight-signature)))
7532 (let ((ps-left-header
7535 (mail-header-subject gnus-current-headers) ")")
7537 (mail-header-from gnus-current-headers) ")")))
7540 "/pagenumberstring load"
7542 (mail-header-date gnus-current-headers) ")"))))
7543 (gnus-run-hooks 'gnus-ps-print-hook)
7546 (ps-spool-buffer-with-faces)
7547 (ps-spool-buffer)))))
7548 (kill-buffer buffer))))
7549 (gnus-summary-remove-process-mark article))
7550 (ps-despool filename))
7552 (defun gnus-summary-show-article (&optional arg)
7553 "Force re-fetching of the current article.
7554 If ARG (the prefix) is a number, show the article with the charset
7555 defined in `gnus-summary-show-article-charset-alist', or the charset
7557 If ARG (the prefix) is non-nil and not a number, show the raw article
7558 without any article massaging functions being run."
7562 (let ((gnus-newsgroup-charset
7563 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7564 (read-coding-system "Charset: ")))
7565 (gnus-newsgroup-ignored-charsets 'gnus-all))
7566 (gnus-summary-select-article nil 'force)
7567 (let ((deps gnus-newsgroup-dependencies)
7570 (set-buffer gnus-original-article-buffer)
7572 (message-narrow-to-head)
7573 (setq head (buffer-string)))
7575 (insert (format "211 %d Article retrieved.\n"
7576 (cdr gnus-article-current)))
7579 (let ((nntp-server-buffer (current-buffer)))
7580 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7581 (gnus-data-set-header
7582 (gnus-data-find (cdr gnus-article-current))
7584 (gnus-summary-update-article-line
7585 (cdr gnus-article-current) header))))
7587 ;; Select the article the normal way.
7588 (gnus-summary-select-article nil 'force))
7590 ;; We have to require this here to make sure that the following
7591 ;; dynamic binding isn't shadowed by autoloading.
7592 (require 'gnus-async)
7594 ;; Bind the article treatment functions to nil.
7595 (let ((gnus-have-all-headers t)
7596 gnus-article-prepare-hook
7597 gnus-article-decode-hook
7598 gnus-display-mime-function
7600 ;; Destroy any MIME parts.
7601 (when (gnus-buffer-live-p gnus-article-buffer)
7603 (set-buffer gnus-article-buffer)
7604 (mm-destroy-parts gnus-article-mime-handles)
7605 ;; Set it to nil for safety reason.
7606 (setq gnus-article-mime-handle-alist nil)
7607 (setq gnus-article-mime-handles nil)))
7608 (gnus-summary-select-article nil 'force))))
7609 (gnus-summary-goto-subject gnus-current-article)
7610 (gnus-summary-position-point))
7612 (defun gnus-summary-verbose-headers (&optional arg)
7613 "Toggle permanent full header display.
7614 If ARG is a positive number, turn header display on.
7615 If ARG is a negative number, turn header display off."
7617 (setq gnus-show-all-headers
7618 (cond ((or (not (numberp arg))
7620 (not gnus-show-all-headers))
7623 (gnus-summary-show-article))
7625 (defun gnus-summary-toggle-header (&optional arg)
7626 "Show the headers if they are hidden, or hide them if they are shown.
7627 If ARG is a positive number, show the entire header.
7628 If ARG is a negative number, hide the unwanted header lines."
7631 (set-buffer gnus-article-buffer)
7633 (let* ((buffer-read-only nil)
7634 (inhibit-point-motion-hooks t)
7640 (article-narrow-to-head)
7641 (gnus-article-hidden-text-p 'headers))))
7642 (goto-char (point-min))
7643 (when (search-forward "\n\n" nil t)
7644 (delete-region (point-min) (1- (point))))
7645 (goto-char (point-min))
7647 (set-buffer gnus-original-article-buffer)
7648 (goto-char (point-min))
7649 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7650 (insert-buffer-substring gnus-original-article-buffer 1 e)
7652 (narrow-to-region (point-min) (point))
7653 (article-decode-encoded-words)
7655 (let ((gnus-treat-hide-headers nil)
7656 (gnus-treat-hide-boring-headers nil))
7657 (setq gnus-article-wash-types
7658 (delq 'headers gnus-article-wash-types))
7659 (gnus-treat-article 'head))
7660 (gnus-treat-article 'head)))
7661 (gnus-set-mode-line 'article)))))
7663 (defun gnus-summary-show-all-headers ()
7664 "Make all header lines visible."
7666 (gnus-summary-toggle-header 1))
7668 (defun gnus-summary-caesar-message (&optional arg)
7669 "Caesar rotate the current article by 13.
7670 The numerical prefix specifies how many places to rotate each letter
7673 (gnus-summary-select-article)
7674 (let ((mail-header-separator ""))
7675 (gnus-eval-in-buffer-window gnus-article-buffer
7678 (let ((start (window-start))
7680 (message-caesar-buffer-body arg)
7681 (set-window-start (get-buffer-window (current-buffer)) start))))))
7683 (defun gnus-summary-stop-page-breaking ()
7684 "Stop page breaking in the current article."
7686 (gnus-summary-select-article)
7687 (gnus-eval-in-buffer-window gnus-article-buffer
7689 (when (gnus-visual-p 'page-marker)
7690 (let ((buffer-read-only nil))
7691 (gnus-remove-text-with-property 'gnus-prev)
7692 (gnus-remove-text-with-property 'gnus-next))
7693 (setq gnus-page-broken nil))))
7695 (defun gnus-summary-move-article (&optional n to-newsgroup
7696 select-method action)
7697 "Move the current article to a different newsgroup.
7698 If N is a positive number, move the N next articles.
7699 If N is a negative number, move the N previous articles.
7700 If N is nil and any articles have been marked with the process mark,
7701 move those articles instead.
7702 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7703 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7704 re-spool using this method.
7706 For this function to work, both the current newsgroup and the
7707 newsgroup that you want to move to have to support the `request-move'
7708 and `request-accept' functions.
7710 ACTION can be either `move' (the default), `crosspost' or `copy'."
7713 (setq action 'move))
7714 ;; Disable marking as read.
7715 (let (gnus-mark-article-hook)
7716 (save-window-excursion
7717 (gnus-summary-select-article)))
7718 ;; Check whether the source group supports the required functions.
7719 (cond ((and (eq action 'move)
7720 (not (gnus-check-backend-function
7721 'request-move-article gnus-newsgroup-name)))
7722 (error "The current group does not support article moving"))
7723 ((and (eq action 'crosspost)
7724 (not (gnus-check-backend-function
7725 'request-replace-article gnus-newsgroup-name)))
7726 (error "The current group does not support article editing")))
7727 (let ((articles (gnus-summary-work-articles n))
7728 (prefix (if (gnus-check-backend-function
7729 'request-move-article gnus-newsgroup-name)
7730 (gnus-group-real-prefix gnus-newsgroup-name)
7732 (names '((move "Move" "Moving")
7733 (copy "Copy" "Copying")
7734 (crosspost "Crosspost" "Crossposting")))
7735 (copy-buf (save-excursion
7736 (nnheader-set-temp-buffer " *copy article*")))
7737 art-group to-method new-xref article to-groups)
7738 (unless (assq action names)
7739 (error "Unknown action %s" action))
7740 ;; Read the newsgroup name.
7741 (when (and (not to-newsgroup)
7742 (not select-method))
7744 (gnus-read-move-group-name
7745 (cadr (assq action names))
7746 (symbol-value (intern (format "gnus-current-%s-group" action)))
7748 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7749 (setq to-method (or select-method
7750 (gnus-server-to-method
7751 (gnus-group-method to-newsgroup))))
7752 ;; Check the method we are to move this article to...
7753 (unless (gnus-check-backend-function
7754 'request-accept-article (car to-method))
7755 (error "%s does not support article copying" (car to-method)))
7756 (unless (gnus-check-server to-method)
7757 (error "Can't open server %s" (car to-method)))
7758 (gnus-message 6 "%s to %s: %s..."
7759 (caddr (assq action names))
7760 (or (car select-method) to-newsgroup) articles)
7762 (setq article (pop articles))
7766 ;; Move the article.
7768 ;; Remove this article from future suppression.
7769 (gnus-dup-unsuppress-article article)
7770 (gnus-request-move-article
7771 article ; Article to move
7772 gnus-newsgroup-name ; From newsgroup
7773 (nth 1 (gnus-find-method-for-group
7774 gnus-newsgroup-name)) ; Server
7775 (list 'gnus-request-accept-article
7776 to-newsgroup (list 'quote select-method)
7777 (not articles) t) ; Accept form
7778 (not articles))) ; Only save nov last time
7779 ;; Copy the article.
7782 (set-buffer copy-buf)
7783 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7784 (gnus-request-accept-article
7785 to-newsgroup select-method (not articles) t))))
7786 ;; Crosspost the article.
7787 ((eq action 'crosspost)
7788 (let ((xref (message-tokenize-header
7789 (mail-header-xref (gnus-summary-article-header article))
7791 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7794 (setq xref (list (system-name))))
7797 (mapconcat 'identity
7798 (delete "Xref:" (delete new-xref xref))
7802 (set-buffer copy-buf)
7803 ;; First put the article in the destination group.
7804 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7805 (when (consp (setq art-group
7806 (gnus-request-accept-article
7807 to-newsgroup select-method (not articles))))
7808 (setq new-xref (concat new-xref " " (car art-group)
7809 ":" (cdr art-group)))
7810 ;; Now we have the new Xrefs header, so we insert
7811 ;; it and replace the new article.
7812 (nnheader-replace-header "Xref" new-xref)
7813 (gnus-request-replace-article
7814 (cdr art-group) to-newsgroup (current-buffer))
7818 (gnus-message 1 "Couldn't %s article %s: %s"
7819 (cadr (assq action names)) article
7820 (nnheader-get-report (car to-method))))
7821 ((eq art-group 'junk)
7822 (when (eq action 'move)
7823 (gnus-summary-mark-article article gnus-canceled-mark)
7824 (gnus-message 4 "Deleted article %s" article)))
7826 (let* ((pto-group (gnus-group-prefixed-name
7827 (car art-group) to-method))
7829 (gnus-gethash pto-group gnus-newsrc-hashtb))
7830 (info (nth 2 entry))
7831 (to-group (gnus-info-group info))
7833 ;; Update the group that has been moved to.
7835 (memq action '(move copy)))
7836 (unless (member to-group to-groups)
7837 (push to-group to-groups))
7839 (unless (memq article gnus-newsgroup-unreads)
7840 (push 'read to-marks)
7842 info (gnus-add-to-range (gnus-info-read info)
7843 (list (cdr art-group)))))
7845 ;; See whether the article is to be put in the cache.
7846 (let ((marks gnus-article-mark-lists)
7847 (to-article (cdr art-group)))
7849 ;; Enter the article into the cache in the new group,
7850 ;; if that is required.
7851 (when gnus-use-cache
7852 (gnus-cache-possibly-enter-article
7854 (memq article gnus-newsgroup-marked)
7855 (memq article gnus-newsgroup-dormant)
7856 (memq article gnus-newsgroup-unreads)))
7858 (when gnus-preserve-marks
7859 ;; Copy any marks over to the new group.
7860 (when (and (equal to-group gnus-newsgroup-name)
7861 (not (memq article gnus-newsgroup-unreads)))
7862 ;; Mark this article as read in this group.
7863 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7864 (setcdr (gnus-active to-group) to-article)
7865 (setcdr gnus-newsgroup-active to-article))
7868 (when (memq article (symbol-value
7869 (intern (format "gnus-newsgroup-%s"
7871 (push (cdar marks) to-marks)
7872 ;; If the other group is the same as this group,
7873 ;; then we have to add the mark to the list.
7874 (when (equal to-group gnus-newsgroup-name)
7875 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7878 (intern (format "gnus-newsgroup-%s"
7880 ;; Copy the marks to other group.
7881 (gnus-add-marked-articles
7882 to-group (cdar marks) (list to-article) info))
7883 (setq marks (cdr marks)))
7885 (gnus-request-set-mark to-group (list (list (list to-article)
7890 (concat "(gnus-group-set-info '"
7891 (gnus-prin1-to-string (gnus-get-info to-group))
7894 ;; Update the Xref header in this article to point to
7895 ;; the new crossposted article we have just created.
7896 (when (eq action 'crosspost)
7898 (set-buffer copy-buf)
7899 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7900 (nnheader-replace-header "Xref" new-xref)
7901 (gnus-request-replace-article
7902 article gnus-newsgroup-name (current-buffer)))))
7904 ;;;!!!Why is this necessary?
7905 (set-buffer gnus-summary-buffer)
7907 (gnus-summary-goto-subject article)
7908 (when (eq action 'move)
7909 (gnus-summary-mark-article article gnus-canceled-mark))))
7910 (gnus-summary-remove-process-mark article))
7911 ;; Re-activate all groups that have been moved to.
7914 (set-buffer gnus-group-buffer)
7915 (when (gnus-group-goto-group (car to-groups) t)
7916 (gnus-group-get-new-news-this-group 1 t))
7919 (gnus-kill-buffer copy-buf)
7920 (gnus-summary-position-point)
7921 (gnus-set-mode-line 'summary)))
7923 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7924 "Move the current article to a different newsgroup.
7925 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7926 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7927 re-spool using this method."
7929 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7931 (defun gnus-summary-crosspost-article (&optional n)
7932 "Crosspost the current article to some other group."
7934 (gnus-summary-move-article n nil nil 'crosspost))
7936 (defcustom gnus-summary-respool-default-method nil
7937 "Default method for respooling an article.
7938 If nil, use to the current newsgroup method."
7939 :type '(choice (gnus-select-method :value (nnml ""))
7941 :group 'gnus-summary-mail)
7943 (defun gnus-summary-respool-article (&optional n method)
7944 "Respool the current article.
7945 The article will be squeezed through the mail spooling process again,
7946 which means that it will be put in some mail newsgroup or other
7947 depending on `nnmail-split-methods'.
7948 If N is a positive number, respool the N next articles.
7949 If N is a negative number, respool the N previous articles.
7950 If N is nil and any articles have been marked with the process mark,
7951 respool those articles instead.
7953 Respooling can be done both from mail groups and \"real\" newsgroups.
7954 In the former case, the articles in question will be moved from the
7955 current group into whatever groups they are destined to. In the
7956 latter case, they will be copied into the relevant groups."
7958 (list current-prefix-arg
7959 (let* ((methods (gnus-methods-using 'respool))
7961 (symbol-name (or gnus-summary-respool-default-method
7962 (car (gnus-find-method-for-group
7963 gnus-newsgroup-name)))))
7965 (gnus-completing-read
7966 methname "What backend do you want to use when respooling?"
7967 methods nil t nil 'gnus-mail-method-history))
7970 ((zerop (length (setq ms (gnus-servers-using-backend
7972 (list (intern method) ""))
7976 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7977 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7980 (error "No method given for respooling"))
7981 (if (assoc (symbol-name
7982 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7983 (gnus-methods-using 'respool))
7984 (gnus-summary-move-article n nil method)
7985 (gnus-summary-copy-article n nil method)))
7987 (defun gnus-summary-import-article (file &optional edit)
7988 "Import an arbitrary file into a mail newsgroup."
7989 (interactive "fImport file: \nP")
7990 (let ((group gnus-newsgroup-name)
7991 (now (current-time))
7992 atts lines group-art)
7993 (unless (gnus-check-backend-function 'request-accept-article group)
7994 (error "%s does not support article importing" group))
7995 (or (file-readable-p file)
7996 (not (file-regular-p file))
7997 (error "Can't read %s" file))
7999 (set-buffer (gnus-get-buffer-create " *import file*"))
8001 (nnheader-insert-file-contents file)
8002 (goto-char (point-min))
8003 (unless (nnheader-article-p)
8004 ;; This doesn't look like an article, so we fudge some headers.
8005 (setq atts (file-attributes file)
8006 lines (count-lines (point-min) (point-max)))
8007 (insert "From: " (read-string "From: ") "\n"
8008 "Subject: " (read-string "Subject: ") "\n"
8009 "Date: " (message-make-date (nth 5 atts)) "\n"
8010 "Message-ID: " (message-make-message-id) "\n"
8011 "Lines: " (int-to-string lines) "\n"
8012 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8013 (setq group-art (gnus-request-accept-article group nil t))
8014 (kill-buffer (current-buffer)))
8015 (setq gnus-newsgroup-active (gnus-activate-group group))
8017 (gnus-summary-goto-article (cdr group-art) nil t)
8019 (gnus-summary-edit-article))))
8021 (defun gnus-summary-create-article ()
8022 "Create an article in a mail newsgroup."
8024 (let ((group gnus-newsgroup-name)
8025 (now (current-time))
8027 (unless (gnus-check-backend-function 'request-accept-article group)
8028 (error "%s does not support article importing" group))
8030 (set-buffer (gnus-get-buffer-create " *import file*"))
8032 (goto-char (point-min))
8033 ;; This doesn't look like an article, so we fudge some headers.
8034 (insert "From: " (read-string "From: ") "\n"
8035 "Subject: " (read-string "Subject: ") "\n"
8036 "Date: " (message-make-date now) "\n"
8037 "Message-ID: " (message-make-message-id) "\n")
8038 (setq group-art (gnus-request-accept-article group nil t))
8039 (kill-buffer (current-buffer)))
8040 (setq gnus-newsgroup-active (gnus-activate-group group))
8042 (gnus-summary-goto-article (cdr group-art) nil t)
8043 (gnus-summary-edit-article)))
8045 (defun gnus-summary-article-posted-p ()
8046 "Say whether the current (mail) article is available from news as well.
8047 This will be the case if the article has both been mailed and posted."
8049 (let ((id (mail-header-references (gnus-summary-article-header)))
8050 (gnus-override-method (car (gnus-refer-article-methods))))
8051 (if (gnus-request-head id "")
8052 (gnus-message 2 "The current message was found on %s"
8053 gnus-override-method)
8054 (gnus-message 2 "The current message couldn't be found on %s"
8055 gnus-override-method)
8058 (defun gnus-summary-expire-articles (&optional now)
8059 "Expire all articles that are marked as expirable in the current group."
8061 (when (gnus-check-backend-function
8062 'request-expire-articles gnus-newsgroup-name)
8063 ;; This backend supports expiry.
8064 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8065 (expirable (if total
8067 ;; We need to update the info for
8068 ;; this group for `gnus-list-of-read-articles'
8069 ;; to give us the right answer.
8070 (gnus-run-hooks 'gnus-exit-group-hook)
8071 (gnus-summary-update-info)
8072 (gnus-list-of-read-articles gnus-newsgroup-name))
8073 (setq gnus-newsgroup-expirable
8074 (sort gnus-newsgroup-expirable '<))))
8075 (expiry-wait (if now 'immediate
8076 (gnus-group-find-parameter
8077 gnus-newsgroup-name 'expiry-wait)))
8078 (nnmail-expiry-target
8079 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8080 nnmail-expiry-target))
8083 ;; There are expirable articles in this group, so we run them
8084 ;; through the expiry process.
8085 (gnus-message 6 "Expiring articles...")
8086 (unless (gnus-check-group gnus-newsgroup-name)
8087 (error "Can't open server for %s" gnus-newsgroup-name))
8088 ;; The list of articles that weren't expired is returned.
8091 (let ((nnmail-expiry-wait-function nil)
8092 (nnmail-expiry-wait expiry-wait))
8093 (setq es (gnus-request-expire-articles
8094 expirable gnus-newsgroup-name)))
8095 (setq es (gnus-request-expire-articles
8096 expirable gnus-newsgroup-name)))
8098 (setq gnus-newsgroup-expirable es))
8099 ;; We go through the old list of expirable, and mark all
8100 ;; really expired articles as nonexistent.
8101 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8102 (let ((gnus-use-cache nil))
8104 (unless (memq (car expirable) es)
8105 (when (gnus-data-find (car expirable))
8106 (gnus-summary-mark-article
8107 (car expirable) gnus-canceled-mark)))
8108 (setq expirable (cdr expirable))))))
8109 (gnus-message 6 "Expiring articles...done")))))
8111 (defun gnus-summary-expire-articles-now ()
8112 "Expunge all expirable articles in the current group.
8113 This means that *all* articles that are marked as expirable will be
8114 deleted forever, right now."
8116 (or gnus-expert-user
8118 "Are you really, really, really sure you want to delete all these messages? ")
8120 (gnus-summary-expire-articles t))
8122 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8123 (defun gnus-summary-delete-article (&optional n)
8124 "Delete the N next (mail) articles.
8125 This command actually deletes articles. This is not a marking
8126 command. The article will disappear forever from your life, never to
8128 If N is negative, delete backwards.
8129 If N is nil and articles have been marked with the process mark,
8130 delete these instead."
8132 (unless (gnus-check-backend-function 'request-expire-articles
8133 gnus-newsgroup-name)
8134 (error "The current newsgroup does not support article deletion"))
8135 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8136 (error "Couldn't open server"))
8137 ;; Compute the list of articles to delete.
8138 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8140 (if (and gnus-novice-user
8141 (not (gnus-yes-or-no-p
8142 (format "Do you really want to delete %s forever? "
8143 (if (> (length articles) 1)
8144 (format "these %s articles" (length articles))
8147 ;; Delete the articles.
8148 (setq not-deleted (gnus-request-expire-articles
8149 articles gnus-newsgroup-name 'force))
8151 (gnus-summary-remove-process-mark (car articles))
8152 ;; The backend might not have been able to delete the article
8154 (unless (memq (car articles) not-deleted)
8155 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8156 (setq articles (cdr articles)))
8158 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8159 (gnus-summary-position-point)
8160 (gnus-set-mode-line 'summary)
8163 (defun gnus-summary-edit-article (&optional arg)
8164 "Edit the current article.
8165 This will have permanent effect only in mail groups.
8166 If ARG is nil, edit the decoded articles.
8167 If ARG is 1, edit the raw articles.
8168 If ARG is 2, edit the raw articles even in read-only groups.
8169 If ARG is 3, edit the articles with the current handles.
8170 Otherwise, allow editing of articles even in read-only
8173 (let (force raw current-handles)
8176 ((eq arg 1) (setq raw t))
8177 ((eq arg 2) (setq raw t
8179 ((eq arg 3) (setq current-handles
8180 (and (gnus-buffer-live-p gnus-article-buffer)
8181 (with-current-buffer gnus-article-buffer
8183 gnus-article-mime-handles
8184 (setq gnus-article-mime-handles nil))))))
8186 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8187 (error "Can't edit the raw article in group nndraft:drafts."))
8189 (set-buffer gnus-summary-buffer)
8190 (let ((mail-parse-charset gnus-newsgroup-charset)
8191 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8192 (gnus-set-global-variables)
8193 (when (and (not force)
8194 (gnus-group-read-only-p))
8195 (error "The current newsgroup does not support article editing"))
8196 (gnus-summary-show-article t)
8197 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8198 (with-current-buffer gnus-article-buffer
8199 (mm-enable-multibyte-mule4)))
8200 (if (equal gnus-newsgroup-name "nndraft:drafts")
8202 (gnus-article-edit-article
8205 (let ((mbl mml-buffer-list))
8206 (setq mml-buffer-list nil)
8207 (mime-to-mml ,'current-handles)
8208 (make-local-hook 'kill-buffer-hook)
8209 (let ((mbl1 mml-buffer-list))
8210 (setq mml-buffer-list mbl)
8211 (set (make-local-variable 'mml-buffer-list) mbl1))
8212 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8213 `(lambda (no-highlight)
8214 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8215 (message-options message-options)
8216 (message-options-set-recipient)
8217 (mail-parse-ignored-charsets
8218 ',gnus-newsgroup-ignored-charsets))
8219 ,(if (not raw) '(progn
8221 (mml-destroy-buffers)
8222 (remove-hook 'kill-buffer-hook
8223 'mml-destroy-buffers t)
8224 (kill-local-variable 'mml-buffer-list)))
8225 (gnus-summary-edit-article-done
8226 ,(or (mail-header-references gnus-current-headers) "")
8227 ,(gnus-group-read-only-p)
8228 ,gnus-summary-buffer no-highlight))))))))
8230 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8232 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8234 "Make edits to the current article permanent."
8237 ;; The buffer restriction contains the entire article if it exists.
8238 (when (article-goto-body)
8239 (let ((lines (count-lines (point) (point-max)))
8240 (length (- (point-max) (point)))
8241 (case-fold-search t)
8242 (body (copy-marker (point))))
8243 (goto-char (point-min))
8244 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8245 (delete-region (match-beginning 1) (match-end 1))
8246 (insert (number-to-string length)))
8247 (goto-char (point-min))
8248 (when (re-search-forward
8249 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8250 (delete-region (match-beginning 1) (match-end 1))
8251 (insert (number-to-string length)))
8252 (goto-char (point-min))
8253 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8254 (delete-region (match-beginning 1) (match-end 1))
8255 (insert (number-to-string lines))))))
8256 ;; Replace the article.
8257 (let ((buf (current-buffer)))
8259 (insert-buffer-substring buf)
8261 (if (and (not read-only)
8262 (not (gnus-request-replace-article
8263 (cdr gnus-article-current) (car gnus-article-current)
8264 (current-buffer) t)))
8265 (error "Couldn't replace article")
8266 ;; Update the summary buffer.
8268 (equal (message-tokenize-header references " ")
8269 (message-tokenize-header
8270 (or (message-fetch-field "references") "") " ")))
8271 ;; We only have to update this line.
8274 (message-narrow-to-head)
8275 (let ((head (buffer-string))
8278 (insert (format "211 %d Article retrieved.\n"
8279 (cdr gnus-article-current)))
8282 (let ((nntp-server-buffer (current-buffer)))
8283 (setq header (car (gnus-get-newsgroup-headers
8285 (set-buffer gnus-summary-buffer)
8286 gnus-newsgroup-dependencies)
8289 (set-buffer gnus-summary-buffer)
8290 (gnus-data-set-header
8291 (gnus-data-find (cdr gnus-article-current))
8293 (gnus-summary-update-article-line
8294 (cdr gnus-article-current) header))))))
8296 (set-buffer (or buffer gnus-summary-buffer))
8297 (gnus-summary-update-article (cdr gnus-article-current)))
8298 ;; Prettify the article buffer again.
8299 (unless no-highlight
8301 (set-buffer gnus-article-buffer)
8302 ;;;!!! Fix this -- article should be rehighlighted.
8303 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8304 (set-buffer gnus-original-article-buffer)
8305 (gnus-request-article
8306 (cdr gnus-article-current)
8307 (car gnus-article-current) (current-buffer))))
8308 ;; Prettify the summary buffer line.
8309 (when (gnus-visual-p 'summary-highlight 'highlight)
8310 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8312 (defun gnus-summary-edit-wash (key)
8313 "Perform editing command KEY in the article buffer."
8317 (message "%s" (concat (this-command-keys) "- "))
8320 (gnus-summary-edit-article)
8321 (execute-kbd-macro (concat (this-command-keys) key))
8322 (gnus-article-edit-done))
8326 (defun gnus-summary-respool-query (&optional silent trace)
8327 "Query where the respool algorithm would put this article."
8329 (let (gnus-mark-article-hook)
8330 (gnus-summary-select-article)
8332 (set-buffer gnus-original-article-buffer)
8334 (message-narrow-to-head)
8335 (let ((groups (nnmail-article-group 'identity trace)))
8338 (message "This message would go to %s"
8339 (mapconcat 'car groups ", "))
8340 (message "This message would go to no groups"))
8343 (defun gnus-summary-respool-trace ()
8344 "Trace where the respool algorithm would put this article.
8345 Display a buffer showing all fancy splitting patterns which matched."
8347 (gnus-summary-respool-query nil t))
8349 ;; Summary marking commands.
8351 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8352 "Mark articles which has the same subject as read, and then select the next.
8353 If UNMARK is positive, remove any kind of mark.
8354 If UNMARK is negative, tick articles."
8357 (setq unmark (prefix-numeric-value unmark)))
8359 (gnus-summary-mark-same-subject
8360 (gnus-summary-article-subject) unmark)))
8361 ;; Select next unread article. If auto-select-same mode, should
8362 ;; select the first unread article.
8363 (gnus-summary-next-article t (and gnus-auto-select-same
8364 (gnus-summary-article-subject)))
8365 (gnus-message 7 "%d article%s marked as %s"
8366 count (if (= count 1) " is" "s are")
8367 (if unmark "unread" "read"))))
8369 (defun gnus-summary-kill-same-subject (&optional unmark)
8370 "Mark articles which has the same subject as read.
8371 If UNMARK is positive, remove any kind of mark.
8372 If UNMARK is negative, tick articles."
8375 (setq unmark (prefix-numeric-value unmark)))
8377 (gnus-summary-mark-same-subject
8378 (gnus-summary-article-subject) unmark)))
8379 ;; If marked as read, go to next unread subject.
8381 ;; Go to next unread subject.
8382 (gnus-summary-next-subject 1 t))
8383 (gnus-message 7 "%d articles are marked as %s"
8384 count (if unmark "unread" "read"))))
8386 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8387 "Mark articles with same SUBJECT as read, and return marked number.
8388 If optional argument UNMARK is positive, remove any kinds of marks.
8389 If optional argument UNMARK is negative, mark articles as unread instead."
8393 ((null unmark) ; Mark as read.
8396 (gnus-summary-mark-article-as-read gnus-killed-mark)
8397 (gnus-summary-show-thread) t)
8398 (gnus-summary-find-subject subject))
8399 (setq count (1+ count))))
8400 ((> unmark 0) ; Tick.
8403 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8404 (gnus-summary-show-thread) t)
8405 (gnus-summary-find-subject subject))
8406 (setq count (1+ count))))
8407 (t ; Mark as unread.
8410 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8411 (gnus-summary-show-thread) t)
8412 (gnus-summary-find-subject subject))
8413 (setq count (1+ count)))))
8414 (gnus-set-mode-line 'summary)
8415 ;; Return the number of marked articles.
8418 (defun gnus-summary-mark-as-processable (n &optional unmark)
8419 "Set the process mark on the next N articles.
8420 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8421 the process mark instead. The difference between N and the actual
8422 number of articles marked is returned."
8424 (if (and (null n) (gnus-region-active-p))
8425 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8426 (setq n (prefix-numeric-value n))
8427 (let ((backward (< n 0))
8432 (gnus-summary-remove-process-mark
8433 (gnus-summary-article-number))
8434 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8435 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8438 (gnus-message 7 "No more articles"))
8439 (gnus-summary-recenter)
8440 (gnus-summary-position-point)
8443 (defun gnus-summary-unmark-as-processable (n)
8444 "Remove the process mark from the next N articles.
8445 If N is negative, unmark backward instead. The difference between N and
8446 the actual number of articles unmarked is returned."
8448 (gnus-summary-mark-as-processable n t))
8450 (defun gnus-summary-unmark-all-processable ()
8451 "Remove the process mark from all articles."
8454 (while gnus-newsgroup-processable
8455 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8456 (gnus-summary-position-point))
8458 (defun gnus-summary-add-mark (article type)
8459 "Mark ARTICLE with a mark of TYPE."
8460 (let ((vtype (car (assq type gnus-article-mark-lists)))
8463 (error "No such mark type: %s" type)
8464 (setq var (intern (format "gnus-newsgroup-%s" type)))
8465 (set var (cons article (symbol-value var)))
8466 (if (memq type '(processable cached replied forwarded saved))
8467 (gnus-summary-update-secondary-mark article)
8468 ;;; !!! This is bobus. We should find out what primary
8469 ;;; !!! mark we want to set.
8470 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8472 (defun gnus-summary-mark-as-expirable (n)
8473 "Mark N articles forward as expirable.
8474 If N is negative, mark backward instead. The difference between N and
8475 the actual number of articles marked is returned."
8477 (gnus-summary-mark-forward n gnus-expirable-mark))
8479 (defun gnus-summary-mark-article-as-replied (article)
8480 "Mark ARTICLE as replied to and update the summary line.
8481 ARTICLE can also be a list of articles."
8482 (interactive (list (gnus-summary-article-number)))
8483 (let ((articles (if (listp article) article (list article))))
8484 (dolist (article articles)
8485 (push article gnus-newsgroup-replied)
8486 (let ((buffer-read-only nil))
8487 (when (gnus-summary-goto-subject article nil t)
8488 (gnus-summary-update-secondary-mark article))))))
8490 (defun gnus-summary-mark-article-as-forwarded (article)
8491 "Mark ARTICLE as forwarded and update the summary line.
8492 ARTICLE can also be a list of articles."
8493 (let ((articles (if (listp article) article (list article))))
8494 (dolist (article articles)
8495 (push article gnus-newsgroup-forwarded)
8496 (let ((buffer-read-only nil))
8497 (when (gnus-summary-goto-subject article nil t)
8498 (gnus-summary-update-secondary-mark article))))))
8500 (defun gnus-summary-set-bookmark (article)
8501 "Set a bookmark in current article."
8502 (interactive (list (gnus-summary-article-number)))
8503 (when (or (not (get-buffer gnus-article-buffer))
8504 (not gnus-current-article)
8505 (not gnus-article-current)
8506 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8507 (error "No current article selected"))
8508 ;; Remove old bookmark, if one exists.
8509 (let ((old (assq article gnus-newsgroup-bookmarks)))
8511 (setq gnus-newsgroup-bookmarks
8512 (delq old gnus-newsgroup-bookmarks))))
8513 ;; Set the new bookmark, which is on the form
8514 ;; (article-number . line-number-in-body).
8518 (set-buffer gnus-article-buffer)
8522 (goto-char (point-min))
8523 (search-forward "\n\n" nil t)
8526 gnus-newsgroup-bookmarks)
8527 (gnus-message 6 "A bookmark has been added to the current article."))
8529 (defun gnus-summary-remove-bookmark (article)
8530 "Remove the bookmark from the current article."
8531 (interactive (list (gnus-summary-article-number)))
8532 ;; Remove old bookmark, if one exists.
8533 (let ((old (assq article gnus-newsgroup-bookmarks)))
8536 (setq gnus-newsgroup-bookmarks
8537 (delq old gnus-newsgroup-bookmarks))
8538 (gnus-message 6 "Removed bookmark."))
8539 (gnus-message 6 "No bookmark in current article."))))
8541 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8542 (defun gnus-summary-mark-as-dormant (n)
8543 "Mark N articles forward as dormant.
8544 If N is negative, mark backward instead. The difference between N and
8545 the actual number of articles marked is returned."
8547 (gnus-summary-mark-forward n gnus-dormant-mark))
8549 (defun gnus-summary-set-process-mark (article)
8550 "Set the process mark on ARTICLE and update the summary line."
8551 (setq gnus-newsgroup-processable
8553 (delq article gnus-newsgroup-processable)))
8554 (when (gnus-summary-goto-subject article)
8555 (gnus-summary-show-thread)
8556 (gnus-summary-goto-subject article)
8557 (gnus-summary-update-secondary-mark article)))
8559 (defun gnus-summary-remove-process-mark (article)
8560 "Remove the process mark from ARTICLE and update the summary line."
8561 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8562 (when (gnus-summary-goto-subject article)
8563 (gnus-summary-show-thread)
8564 (gnus-summary-goto-subject article)
8565 (gnus-summary-update-secondary-mark article)))
8567 (defun gnus-summary-set-saved-mark (article)
8568 "Set the process mark on ARTICLE and update the summary line."
8569 (push article gnus-newsgroup-saved)
8570 (when (gnus-summary-goto-subject article)
8571 (gnus-summary-update-secondary-mark article)))
8573 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8574 "Mark N articles as read forwards.
8575 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8576 The difference between N and the actual number of articles marked is
8578 Iff NO-EXPIRE, auto-expiry will be inhibited."
8580 (gnus-summary-show-thread)
8581 (let ((backward (< n 0))
8582 (gnus-summary-goto-unread
8583 (and gnus-summary-goto-unread
8584 (not (eq gnus-summary-goto-unread 'never))
8585 (not (memq mark (list gnus-unread-mark
8586 gnus-ticked-mark gnus-dormant-mark)))))
8588 (mark (or mark gnus-del-mark)))
8590 (gnus-summary-mark-article nil mark no-expire)
8591 (zerop (gnus-summary-next-subject
8593 (and gnus-summary-goto-unread
8594 (not (eq gnus-summary-goto-unread 'never)))
8598 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8599 (gnus-summary-recenter)
8600 (gnus-summary-position-point)
8601 (gnus-set-mode-line 'summary)
8604 (defun gnus-summary-mark-article-as-read (mark)
8605 "Mark the current article quickly as read with MARK."
8606 (let ((article (gnus-summary-article-number)))
8607 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8608 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8609 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8610 (push (cons article mark) gnus-newsgroup-reads)
8611 ;; Possibly remove from cache, if that is used.
8612 (when gnus-use-cache
8613 (gnus-cache-enter-remove-article article))
8614 ;; Allow the backend to change the mark.
8615 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8616 ;; Check for auto-expiry.
8617 (when (and gnus-newsgroup-auto-expire
8618 (memq mark gnus-auto-expirable-marks))
8619 (setq mark gnus-expirable-mark)
8620 ;; Let the backend know about the mark change.
8621 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8622 (push article gnus-newsgroup-expirable))
8623 ;; Set the mark in the buffer.
8624 (gnus-summary-update-mark mark 'unread)
8627 (defun gnus-summary-mark-article-as-unread (mark)
8628 "Mark the current article quickly as unread with MARK."
8629 (let* ((article (gnus-summary-article-number))
8630 (old-mark (gnus-summary-article-mark article)))
8631 ;; Allow the backend to change the mark.
8632 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8633 (if (eq mark old-mark)
8637 (gnus-error 1 "Can't mark negative article numbers")
8639 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8640 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8641 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8642 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8643 (cond ((= mark gnus-ticked-mark)
8644 (push article gnus-newsgroup-marked))
8645 ((= mark gnus-dormant-mark)
8646 (push article gnus-newsgroup-dormant))
8648 (push article gnus-newsgroup-unreads)))
8649 (gnus-pull article gnus-newsgroup-reads)
8651 ;; See whether the article is to be put in the cache.
8653 (vectorp (gnus-summary-article-header article))
8655 (gnus-cache-possibly-enter-article
8656 gnus-newsgroup-name article
8657 (= mark gnus-ticked-mark)
8658 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8661 (gnus-summary-update-mark mark 'unread)
8664 (defun gnus-summary-mark-article (&optional article mark no-expire)
8665 "Mark ARTICLE with MARK. MARK can be any character.
8666 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8667 `??' (dormant) and `?E' (expirable).
8668 If MARK is nil, then the default character `?r' is used.
8669 If ARTICLE is nil, then the article on the current line will be
8671 Iff NO-EXPIRE, auto-expiry will be inhibited."
8672 ;; The mark might be a string.
8673 (when (stringp mark)
8674 (setq mark (aref mark 0)))
8675 ;; If no mark is given, then we check auto-expiring.
8677 (setq mark gnus-del-mark))
8678 (when (and (not no-expire)
8679 gnus-newsgroup-auto-expire
8680 (memq mark gnus-auto-expirable-marks))
8681 (setq mark gnus-expirable-mark))
8682 (let ((article (or article (gnus-summary-article-number)))
8683 (old-mark (gnus-summary-article-mark article)))
8684 ;; Allow the backend to change the mark.
8685 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8686 (if (eq mark old-mark)
8689 (error "No article on current line"))
8690 (if (not (if (or (= mark gnus-unread-mark)
8691 (= mark gnus-ticked-mark)
8692 (= mark gnus-dormant-mark))
8693 (gnus-mark-article-as-unread article mark)
8694 (gnus-mark-article-as-read article mark)))
8696 ;; See whether the article is to be put in the cache.
8698 (not (= mark gnus-canceled-mark))
8699 (vectorp (gnus-summary-article-header article))
8701 (gnus-cache-possibly-enter-article
8702 gnus-newsgroup-name article
8703 (= mark gnus-ticked-mark)
8704 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8706 (when (gnus-summary-goto-subject article nil t)
8707 (let ((buffer-read-only nil))
8708 (gnus-summary-show-thread)
8710 (gnus-summary-update-mark mark 'unread)
8713 (defun gnus-summary-update-secondary-mark (article)
8714 "Update the secondary (read, process, cache) mark."
8715 (gnus-summary-update-mark
8716 (cond ((memq article gnus-newsgroup-processable)
8718 ((memq article gnus-newsgroup-cached)
8720 ((memq article gnus-newsgroup-replied)
8722 ((memq article gnus-newsgroup-forwarded)
8723 gnus-forwarded-mark)
8724 ((memq article gnus-newsgroup-saved)
8728 (when (gnus-visual-p 'summary-highlight 'highlight)
8729 (gnus-run-hooks 'gnus-summary-update-hook))
8732 (defun gnus-summary-update-mark (mark type)
8733 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8734 (buffer-read-only nil))
8735 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8737 (when (looking-at "\r")
8739 (when (<= (+ forward (point)) (point-max))
8740 ;; Go to the right position on the line.
8741 (goto-char (+ forward (point)))
8742 ;; Replace the old mark with the new mark.
8743 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8744 ;; Optionally update the marks by some user rule.
8745 (when (eq type 'unread)
8747 (gnus-data-find (gnus-summary-article-number)) mark)
8748 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8750 (defun gnus-mark-article-as-read (article &optional mark)
8751 "Enter ARTICLE in the pertinent lists and remove it from others."
8752 ;; Make the article expirable.
8753 (let ((mark (or mark gnus-del-mark)))
8754 (if (= mark gnus-expirable-mark)
8755 (push article gnus-newsgroup-expirable)
8756 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8757 ;; Remove from unread and marked lists.
8758 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8759 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8760 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8761 (push (cons article mark) gnus-newsgroup-reads)
8762 ;; Possibly remove from cache, if that is used.
8763 (when gnus-use-cache
8764 (gnus-cache-enter-remove-article article))
8767 (defun gnus-mark-article-as-unread (article &optional mark)
8768 "Enter ARTICLE in the pertinent lists and remove it from others."
8769 (let ((mark (or mark gnus-ticked-mark)))
8772 (gnus-error 1 "Can't mark negative article numbers")
8774 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8775 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8776 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8777 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8779 ;; Unsuppress duplicates?
8780 (when gnus-suppress-duplicates
8781 (gnus-dup-unsuppress-article article))
8783 (cond ((= mark gnus-ticked-mark)
8784 (push article gnus-newsgroup-marked))
8785 ((= mark gnus-dormant-mark)
8786 (push article gnus-newsgroup-dormant))
8788 (push article gnus-newsgroup-unreads)))
8789 (gnus-pull article gnus-newsgroup-reads)
8792 (defalias 'gnus-summary-mark-as-unread-forward
8793 'gnus-summary-tick-article-forward)
8794 (make-obsolete 'gnus-summary-mark-as-unread-forward
8795 'gnus-summary-tick-article-forward)
8796 (defun gnus-summary-tick-article-forward (n)
8797 "Tick N articles forwards.
8798 If N is negative, tick backwards instead.
8799 The difference between N and the number of articles ticked is returned."
8801 (gnus-summary-mark-forward n gnus-ticked-mark))
8803 (defalias 'gnus-summary-mark-as-unread-backward
8804 'gnus-summary-tick-article-backward)
8805 (make-obsolete 'gnus-summary-mark-as-unread-backward
8806 'gnus-summary-tick-article-backward)
8807 (defun gnus-summary-tick-article-backward (n)
8808 "Tick N articles backwards.
8809 The difference between N and the number of articles ticked is returned."
8811 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8813 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8814 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8815 (defun gnus-summary-tick-article (&optional article clear-mark)
8816 "Mark current article as unread.
8817 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8818 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8820 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8823 (defun gnus-summary-mark-as-read-forward (n)
8824 "Mark N articles as read forwards.
8825 If N is negative, mark backwards instead.
8826 The difference between N and the actual number of articles marked is
8829 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8831 (defun gnus-summary-mark-as-read-backward (n)
8832 "Mark the N articles as read backwards.
8833 The difference between N and the actual number of articles marked is
8836 (gnus-summary-mark-forward
8837 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8839 (defun gnus-summary-mark-as-read (&optional article mark)
8840 "Mark current article as read.
8841 ARTICLE specifies the article to be marked as read.
8842 MARK specifies a string to be inserted at the beginning of the line."
8843 (gnus-summary-mark-article article mark))
8845 (defun gnus-summary-clear-mark-forward (n)
8846 "Clear marks from N articles forward.
8847 If N is negative, clear backward instead.
8848 The difference between N and the number of marks cleared is returned."
8850 (gnus-summary-mark-forward n gnus-unread-mark))
8852 (defun gnus-summary-clear-mark-backward (n)
8853 "Clear marks from N articles backward.
8854 The difference between N and the number of marks cleared is returned."
8856 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8858 (defun gnus-summary-mark-unread-as-read ()
8859 "Intended to be used by `gnus-summary-mark-article-hook'."
8860 (when (memq gnus-current-article gnus-newsgroup-unreads)
8861 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8863 (defun gnus-summary-mark-read-and-unread-as-read ()
8864 "Intended to be used by `gnus-summary-mark-article-hook'."
8865 (let ((mark (gnus-summary-article-mark)))
8866 (when (or (gnus-unread-mark-p mark)
8867 (gnus-read-mark-p mark))
8868 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8870 (defun gnus-summary-mark-unread-as-ticked ()
8871 "Intended to be used by `gnus-summary-mark-article-hook'."
8872 (when (memq gnus-current-article gnus-newsgroup-unreads)
8873 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8875 (defun gnus-summary-mark-region-as-read (point mark all)
8876 "Mark all unread articles between point and mark as read.
8877 If given a prefix, mark all articles between point and mark as read,
8878 even ticked and dormant ones."
8879 (interactive "r\nP")
8888 (memq (setq article (gnus-summary-article-number))
8889 gnus-newsgroup-unreads))
8890 (gnus-summary-mark-article article gnus-del-mark))
8892 (gnus-summary-find-next))))))
8894 (defun gnus-summary-mark-below (score mark)
8895 "Mark articles with score less than SCORE with MARK."
8896 (interactive "P\ncMark: ")
8897 (setq score (if score
8898 (prefix-numeric-value score)
8899 (or gnus-summary-default-score 0)))
8901 (set-buffer gnus-summary-buffer)
8902 (goto-char (point-min))
8905 (and (< (gnus-summary-article-score) score)
8906 (gnus-summary-mark-article nil mark))
8907 (gnus-summary-find-next)))))
8909 (defun gnus-summary-kill-below (&optional score)
8910 "Mark articles with score below SCORE as read."
8912 (gnus-summary-mark-below score gnus-killed-mark))
8914 (defun gnus-summary-clear-above (&optional score)
8915 "Clear all marks from articles with score above SCORE."
8917 (gnus-summary-mark-above score gnus-unread-mark))
8919 (defun gnus-summary-tick-above (&optional score)
8920 "Tick all articles with score above SCORE."
8922 (gnus-summary-mark-above score gnus-ticked-mark))
8924 (defun gnus-summary-mark-above (score mark)
8925 "Mark articles with score over SCORE with MARK."
8926 (interactive "P\ncMark: ")
8927 (setq score (if score
8928 (prefix-numeric-value score)
8929 (or gnus-summary-default-score 0)))
8931 (set-buffer gnus-summary-buffer)
8932 (goto-char (point-min))
8934 (when (> (gnus-summary-article-score) score)
8935 (gnus-summary-mark-article nil mark))
8937 (gnus-summary-find-next)))))
8939 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8940 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8941 (defun gnus-summary-limit-include-expunged (&optional no-error)
8942 "Display all the hidden articles that were expunged for low scores."
8944 (let ((buffer-read-only nil))
8945 (let ((scored gnus-newsgroup-scored)
8948 (unless (gnus-summary-article-header (caar scored))
8949 (and (setq h (gnus-number-to-header (caar scored)))
8950 (< (cdar scored) gnus-summary-expunge-below)
8952 (setq scored (cdr scored)))
8954 (when (not no-error)
8955 (error "No expunged articles hidden"))
8956 (goto-char (point-min))
8957 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8958 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
8959 (mapcar (lambda (x) (push (mail-header-number x)
8960 gnus-newsgroup-limit))
8962 (gnus-summary-prepare-unthreaded (nreverse headers))
8963 (goto-char (point-min))
8964 (gnus-summary-position-point)
8967 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8968 "Mark all unread articles in this newsgroup as read.
8969 If prefix argument ALL is non-nil, ticked and dormant articles will
8970 also be marked as read.
8971 If QUIETLY is non-nil, no questions will be asked.
8972 If TO-HERE is non-nil, it should be a point in the buffer. All
8973 articles before this point will be marked as read.
8974 Note that this function will only catch up the unread article
8975 in the current summary buffer limitation.
8976 The number of articles marked as read is returned."
8981 (not gnus-interactive-catchup) ;Without confirmation?
8985 "Mark absolutely all articles as read? "
8986 "Mark all unread articles as read? ")))
8988 (not gnus-newsgroup-adaptive)
8989 (not gnus-newsgroup-auto-expire)
8990 (not gnus-suppress-duplicates)
8991 (or (not gnus-use-cache)
8992 (eq gnus-use-cache 'passive)))
8995 (setq gnus-newsgroup-marked nil
8996 gnus-newsgroup-dormant nil))
8997 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8998 ;; We actually mark all articles as canceled, which we
8999 ;; have to do when using auto-expiry or adaptive scoring.
9000 (gnus-summary-show-all-threads)
9001 (when (gnus-summary-first-subject (not all) t)
9003 (if to-here (< (point) to-here) t)
9004 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9005 (gnus-summary-find-next (not all) nil nil t))))
9006 (gnus-set-mode-line 'summary))
9008 (gnus-summary-position-point)))
9010 (defun gnus-summary-catchup-to-here (&optional all)
9011 "Mark all unticked articles before the current one as read.
9012 If ALL is non-nil, also mark ticked and dormant articles as read."
9015 (gnus-save-hidden-threads
9016 (let ((beg (point)))
9017 ;; We check that there are unread articles.
9018 (when (or all (gnus-summary-find-prev))
9019 (gnus-summary-catchup all t beg)))))
9020 (gnus-summary-position-point))
9022 (defun gnus-summary-catchup-all (&optional quietly)
9023 "Mark all articles in this newsgroup as read."
9025 (gnus-summary-catchup t quietly))
9027 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9028 "Mark all unread articles in this group as read, then exit.
9029 If prefix argument ALL is non-nil, all articles are marked as read.
9030 If QUIETLY is non-nil, no questions will be asked."
9032 (when (gnus-summary-catchup all quietly nil 'fast)
9033 ;; Select next newsgroup or exit.
9034 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9035 (eq gnus-auto-select-next 'quietly))
9036 (gnus-summary-next-group nil)
9037 (gnus-summary-exit))))
9039 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9040 "Mark all articles in this newsgroup as read, and then exit."
9042 (gnus-summary-catchup-and-exit t quietly))
9044 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9045 "Mark all articles in this group as read and select the next group.
9046 If given a prefix, mark all articles, unread as well as ticked, as
9050 (gnus-summary-catchup all))
9051 (gnus-summary-next-group))
9057 (defmacro gnus-with-article (article &rest forms)
9058 "Select ARTICLE and perform FORMS in the original article buffer.
9059 Then replace the article with the result."
9061 ;; We don't want the article to be marked as read.
9062 (let (gnus-mark-article-hook)
9063 (gnus-summary-select-article t t nil ,article))
9064 (set-buffer gnus-original-article-buffer)
9066 (if (not (gnus-check-backend-function
9067 'request-replace-article (car gnus-article-current)))
9068 (gnus-message 5 "Read-only group; not replacing")
9069 (unless (gnus-request-replace-article
9070 ,article (car gnus-article-current)
9072 (error "Couldn't replace article")))
9073 ;; The cache and backlog have to be flushed somewhat.
9074 (when gnus-keep-backlog
9075 (gnus-backlog-remove-article
9076 (car gnus-article-current) (cdr gnus-article-current)))
9077 (when gnus-use-cache
9078 (gnus-cache-update-article
9079 (car gnus-article-current) (cdr gnus-article-current)))))
9081 (put 'gnus-with-article 'lisp-indent-function 1)
9082 (put 'gnus-with-article 'edebug-form-spec '(form body))
9084 ;; Thread-based commands.
9086 (defun gnus-summary-articles-in-thread (&optional article)
9087 "Return a list of all articles in the current thread.
9088 If ARTICLE is non-nil, return all articles in the thread that starts
9090 (let* ((article (or article (gnus-summary-article-number)))
9091 (data (gnus-data-find-list article))
9092 (top-level (gnus-data-level (car data)))
9094 (cond ((null gnus-thread-operation-ignore-subject)
9095 (gnus-simplify-subject-re
9096 (mail-header-subject (gnus-data-header (car data)))))
9097 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9098 (gnus-simplify-subject-fuzzy
9099 (mail-header-subject (gnus-data-header (car data)))))
9101 (end-point (save-excursion
9102 (if (gnus-summary-go-to-next-thread)
9103 (point) (point-max))))
9106 (< (gnus-data-pos (car data)) end-point))
9107 (when (or (not top-subject)
9108 (string= top-subject
9109 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9110 (gnus-simplify-subject-fuzzy
9111 (mail-header-subject
9112 (gnus-data-header (car data))))
9113 (gnus-simplify-subject-re
9114 (mail-header-subject
9115 (gnus-data-header (car data)))))))
9116 (push (gnus-data-number (car data)) articles))
9117 (unless (and (setq data (cdr data))
9118 (> (gnus-data-level (car data)) top-level))
9120 ;; Return the list of articles.
9121 (nreverse articles)))
9123 (defun gnus-summary-rethread-current ()
9124 "Rethread the thread the current article is part of."
9126 (let* ((gnus-show-threads t)
9127 (article (gnus-summary-article-number))
9128 (id (mail-header-id (gnus-summary-article-header)))
9129 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9131 (error "No article on the current line"))
9132 (gnus-rebuild-thread id)
9133 (gnus-summary-goto-subject article)))
9135 (defun gnus-summary-reparent-thread ()
9136 "Make the current article child of the marked (or previous) article.
9138 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9139 is non-nil or the Subject: of both articles are the same."
9141 (unless (not (gnus-group-read-only-p))
9142 (error "The current newsgroup does not support article editing"))
9143 (unless (<= (length gnus-newsgroup-processable) 1)
9144 (error "No more than one article may be marked"))
9145 (save-window-excursion
9146 (let ((gnus-article-buffer " *reparent*")
9147 (current-article (gnus-summary-article-number))
9148 ;; First grab the marked article, otherwise one line up.
9149 (parent-article (if (not (null gnus-newsgroup-processable))
9150 (car gnus-newsgroup-processable)
9152 (if (eq (forward-line -1) 0)
9153 (gnus-summary-article-number)
9154 (error "Beginning of summary buffer"))))))
9155 (unless (not (eq current-article parent-article))
9156 (error "An article may not be self-referential"))
9157 (let ((message-id (mail-header-id
9158 (gnus-summary-article-header parent-article))))
9159 (unless (and message-id (not (equal message-id "")))
9160 (error "No message-id in desired parent"))
9161 (gnus-with-article current-article
9163 (goto-char (point-min))
9164 (message-narrow-to-head)
9165 (if (re-search-forward "^References: " nil t)
9167 (re-search-forward "^[^ \t]" nil t)
9170 (insert " " message-id))
9171 (insert "References: " message-id "\n"))))
9172 (set-buffer gnus-summary-buffer)
9173 (gnus-summary-unmark-all-processable)
9174 (gnus-summary-update-article current-article)
9175 (gnus-summary-rethread-current)
9176 (gnus-message 3 "Article %d is now the child of article %d"
9177 current-article parent-article)))))
9179 (defun gnus-summary-toggle-threads (&optional arg)
9180 "Toggle showing conversation threads.
9181 If ARG is positive number, turn showing conversation threads on."
9183 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9184 (setq gnus-show-threads
9185 (if (null arg) (not gnus-show-threads)
9186 (> (prefix-numeric-value arg) 0)))
9187 (gnus-summary-prepare)
9188 (gnus-summary-goto-subject current)
9189 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9190 (gnus-summary-position-point)))
9192 (defun gnus-summary-show-all-threads ()
9196 (let ((buffer-read-only nil))
9197 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9198 (gnus-summary-position-point))
9200 (defun gnus-summary-show-thread ()
9201 "Show thread subtrees.
9202 Returns nil if no thread was there to be shown."
9204 (let ((buffer-read-only nil)
9206 ;; first goto end then to beg, to have point at beg after let
9207 (end (progn (end-of-line) (point)))
9208 (beg (progn (beginning-of-line) (point))))
9210 ;; Any hidden lines here?
9211 (search-forward "\r" end t)
9212 (subst-char-in-region beg end ?\^M ?\n t)
9214 (gnus-summary-position-point))))
9216 (defun gnus-summary-hide-all-threads ()
9217 "Hide all thread subtrees."
9220 (goto-char (point-min))
9221 (gnus-summary-hide-thread)
9222 (while (zerop (gnus-summary-next-thread 1 t))
9223 (gnus-summary-hide-thread)))
9224 (gnus-summary-position-point))
9226 (defun gnus-summary-hide-thread ()
9227 "Hide thread subtrees.
9228 Returns nil if no threads were there to be hidden."
9230 (let ((buffer-read-only nil)
9232 (article (gnus-summary-article-number)))
9234 ;; Go forward until either the buffer ends or the subthread
9236 (when (and (not (eobp))
9237 (or (zerop (gnus-summary-next-thread 1 t))
9238 (goto-char (point-max))))
9240 (if (and (> (point) start)
9241 (search-backward "\n" start t))
9243 (subst-char-in-region start (point) ?\n ?\^M)
9244 (gnus-summary-goto-subject article))
9248 (defun gnus-summary-go-to-next-thread (&optional previous)
9249 "Go to the same level (or less) next thread.
9250 If PREVIOUS is non-nil, go to previous thread instead.
9251 Return the article number moved to, or nil if moving was impossible."
9252 (let ((level (gnus-summary-thread-level))
9253 (way (if previous -1 1))
9256 (while (and (not (eobp))
9257 (< level (gnus-summary-thread-level)))
9265 (gnus-summary-article-number)
9268 (defun gnus-summary-next-thread (n &optional silent)
9269 "Go to the same level next N'th thread.
9270 If N is negative, search backward instead.
9271 Returns the difference between N and the number of skips actually
9274 If SILENT, don't output messages."
9276 (let ((backward (< n 0))
9279 (gnus-summary-go-to-next-thread backward))
9282 (gnus-summary-position-point))
9283 (when (and (not silent) (/= 0 n))
9284 (gnus-message 7 "No more threads"))
9287 (defun gnus-summary-prev-thread (n)
9288 "Go to the same level previous N'th thread.
9289 Returns the difference between N and the number of skips actually
9292 (gnus-summary-next-thread (- n)))
9294 (defun gnus-summary-go-down-thread ()
9295 "Go down one level in the current thread."
9296 (let ((children (gnus-summary-article-children)))
9298 (gnus-summary-goto-subject (car children)))))
9300 (defun gnus-summary-go-up-thread ()
9301 "Go up one level in the current thread."
9302 (let ((parent (gnus-summary-article-parent)))
9304 (gnus-summary-goto-subject parent))))
9306 (defun gnus-summary-down-thread (n)
9307 "Go down thread N steps.
9308 If N is negative, go up instead.
9309 Returns the difference between N and how many steps down that were
9315 (if up (gnus-summary-go-up-thread)
9316 (gnus-summary-go-down-thread)))
9318 (gnus-summary-position-point)
9320 (gnus-message 7 "Can't go further"))
9323 (defun gnus-summary-up-thread (n)
9324 "Go up thread N steps.
9325 If N is negative, go down instead.
9326 Returns the difference between N and how many steps down that were
9329 (gnus-summary-down-thread (- n)))
9331 (defun gnus-summary-top-thread ()
9332 "Go to the top of the thread."
9334 (while (gnus-summary-go-up-thread))
9335 (gnus-summary-article-number))
9337 (defun gnus-summary-kill-thread (&optional unmark)
9338 "Mark articles under current thread as read.
9339 If the prefix argument is positive, remove any kinds of marks.
9340 If the prefix argument is negative, tick articles instead."
9343 (setq unmark (prefix-numeric-value unmark)))
9344 (let ((articles (gnus-summary-articles-in-thread)))
9346 ;; Expand the thread.
9347 (gnus-summary-show-thread)
9348 ;; Mark all the articles.
9350 (gnus-summary-goto-subject (car articles))
9351 (cond ((null unmark)
9352 (gnus-summary-mark-article-as-read gnus-killed-mark))
9354 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9356 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9357 (setq articles (cdr articles))))
9358 ;; Hide killed subtrees.
9360 gnus-thread-hide-killed
9361 (gnus-summary-hide-thread))
9362 ;; If marked as read, go to next unread subject.
9364 ;; Go to next unread subject.
9365 (gnus-summary-next-subject 1 t)))
9366 (gnus-set-mode-line 'summary))
9368 ;; Summary sorting commands
9370 (defun gnus-summary-sort-by-number (&optional reverse)
9371 "Sort the summary buffer by article number.
9372 Argument REVERSE means reverse order."
9374 (gnus-summary-sort 'number reverse))
9376 (defun gnus-summary-sort-by-author (&optional reverse)
9377 "Sort the summary buffer by author name alphabetically.
9378 If `case-fold-search' is non-nil, case of letters is ignored.
9379 Argument REVERSE means reverse order."
9381 (gnus-summary-sort 'author reverse))
9383 (defun gnus-summary-sort-by-subject (&optional reverse)
9384 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9385 If `case-fold-search' is non-nil, case of letters is ignored.
9386 Argument REVERSE means reverse order."
9388 (gnus-summary-sort 'subject reverse))
9390 (defun gnus-summary-sort-by-date (&optional reverse)
9391 "Sort the summary buffer by date.
9392 Argument REVERSE means reverse order."
9394 (gnus-summary-sort 'date reverse))
9396 (defun gnus-summary-sort-by-score (&optional reverse)
9397 "Sort the summary buffer by score.
9398 Argument REVERSE means reverse order."
9400 (gnus-summary-sort 'score reverse))
9402 (defun gnus-summary-sort-by-lines (&optional reverse)
9403 "Sort the summary buffer by the number of lines.
9404 Argument REVERSE means reverse order."
9406 (gnus-summary-sort 'lines reverse))
9408 (defun gnus-summary-sort-by-chars (&optional reverse)
9409 "Sort the summary buffer by article length.
9410 Argument REVERSE means reverse order."
9412 (gnus-summary-sort 'chars reverse))
9414 (defun gnus-summary-sort-by-original (&optional reverse)
9415 "Sort the summary buffer using the default sorting method.
9416 Argument REVERSE means reverse order."
9418 (let* ((buffer-read-only)
9419 (gnus-summary-prepare-hook nil))
9420 ;; We do the sorting by regenerating the threads.
9421 (gnus-summary-prepare)
9422 ;; Hide subthreads if needed.
9423 (when (and gnus-show-threads gnus-thread-hide-subtree)
9424 (gnus-summary-hide-all-threads))))
9426 (defun gnus-summary-sort (predicate reverse)
9427 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9428 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9429 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9430 (gnus-thread-sort-functions
9435 (gnus-sort-gathered-threads-function
9436 gnus-thread-sort-functions)
9437 (gnus-article-sort-functions
9443 (gnus-summary-prepare-hook nil))
9444 ;; We do the sorting by regenerating the threads.
9445 (gnus-summary-prepare)
9446 ;; Hide subthreads if needed.
9447 (when (and gnus-show-threads gnus-thread-hide-subtree)
9448 (gnus-summary-hide-all-threads))))
9450 ;; Summary saving commands.
9452 (defun gnus-summary-save-article (&optional n not-saved)
9453 "Save the current article using the default saver function.
9454 If N is a positive number, save the N next articles.
9455 If N is a negative number, save the N previous articles.
9456 If N is nil and any articles have been marked with the process mark,
9457 save those articles instead.
9458 The variable `gnus-default-article-saver' specifies the saver function."
9460 (let* ((articles (gnus-summary-work-articles n))
9461 (save-buffer (save-excursion
9462 (nnheader-set-temp-buffer " *Gnus Save*")))
9463 (num (length articles))
9465 (dolist (article articles)
9466 (setq header (gnus-summary-article-header article))
9467 (if (not (vectorp header))
9468 ;; This is a pseudo-article.
9469 (if (assq 'name header)
9470 (gnus-copy-file (cdr (assq 'name header)))
9471 (gnus-message 1 "Article %d is unsaveable" article))
9472 ;; This is a real article.
9473 (save-window-excursion
9474 (gnus-summary-select-article t nil nil article))
9476 (set-buffer save-buffer)
9478 (insert-buffer-substring gnus-original-article-buffer))
9479 (setq file (gnus-article-save save-buffer file num))
9480 (gnus-summary-remove-process-mark article)
9482 (gnus-summary-set-saved-mark article))))
9483 (gnus-kill-buffer save-buffer)
9484 (gnus-summary-position-point)
9485 (gnus-set-mode-line 'summary)
9488 (defun gnus-summary-pipe-output (&optional arg)
9489 "Pipe the current article to a subprocess.
9490 If N is a positive number, pipe the N next articles.
9491 If N is a negative number, pipe the N previous articles.
9492 If N is nil and any articles have been marked with the process mark,
9493 pipe those articles instead."
9496 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9497 (gnus-summary-save-article arg t))
9498 (gnus-configure-windows 'pipe))
9500 (defun gnus-summary-save-article-mail (&optional arg)
9501 "Append the current article to an mail file.
9502 If N is a positive number, save the N next articles.
9503 If N is a negative number, save the N previous articles.
9504 If N is nil and any articles have been marked with the process mark,
9505 save those articles instead."
9508 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9509 (gnus-summary-save-article arg)))
9511 (defun gnus-summary-save-article-rmail (&optional arg)
9512 "Append the current article to an rmail file.
9513 If N is a positive number, save the N next articles.
9514 If N is a negative number, save the N previous articles.
9515 If N is nil and any articles have been marked with the process mark,
9516 save those articles instead."
9519 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9520 (gnus-summary-save-article arg)))
9522 (defun gnus-summary-save-article-file (&optional arg)
9523 "Append the current article to a file.
9524 If N is a positive number, save the N next articles.
9525 If N is a negative number, save the N previous articles.
9526 If N is nil and any articles have been marked with the process mark,
9527 save those articles instead."
9530 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9531 (gnus-summary-save-article arg)))
9533 (defun gnus-summary-write-article-file (&optional arg)
9534 "Write the current article to a file, deleting the previous file.
9535 If N is a positive number, save the N next articles.
9536 If N is a negative number, save the N previous articles.
9537 If N is nil and any articles have been marked with the process mark,
9538 save those articles instead."
9541 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9542 (gnus-summary-save-article arg)))
9544 (defun gnus-summary-save-article-body-file (&optional arg)
9545 "Append the current article body to a file.
9546 If N is a positive number, save the N next articles.
9547 If N is a negative number, save the N previous articles.
9548 If N is nil and any articles have been marked with the process mark,
9549 save those articles instead."
9552 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9553 (gnus-summary-save-article arg)))
9555 (defun gnus-summary-pipe-message (program)
9556 "Pipe the current article through PROGRAM."
9557 (interactive "sProgram: ")
9558 (gnus-summary-select-article)
9559 (let ((mail-header-separator ""))
9560 (gnus-eval-in-buffer-window gnus-article-buffer
9563 (let ((start (window-start))
9565 (message-pipe-buffer-body program)
9566 (set-window-start (get-buffer-window (current-buffer)) start))))))
9568 (defun gnus-get-split-value (methods)
9569 "Return a value based on the split METHODS."
9570 (let (split-name method result match)
9573 (set-buffer gnus-original-article-buffer)
9575 (nnheader-narrow-to-headers)
9576 (while (and methods (not split-name))
9577 (goto-char (point-min))
9578 (setq method (pop methods))
9579 (setq match (car method))
9582 ;; Regular expression.
9584 (re-search-forward match nil t)))
9585 ((gnus-functionp match)
9589 (setq result (funcall match gnus-newsgroup-name))))
9594 (setq result (eval match)))))
9595 (setq split-name (cdr method))
9596 (cond ((stringp result)
9597 (push (expand-file-name
9598 result gnus-article-save-directory)
9601 (setq split-name (append result split-name)))))))))
9602 (nreverse split-name)))
9604 (defun gnus-valid-move-group-p (group)
9607 (symbol-value group)
9608 (gnus-get-function (gnus-find-method-for-group
9609 (symbol-name group)) 'request-accept-article t)))
9611 (defun gnus-read-move-group-name (prompt default articles prefix)
9612 "Read a group name."
9613 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9614 (minibuffer-confirm-incomplete nil) ; XEmacs
9618 (if (> (length articles) 1)
9619 (format "these %d articles" (length articles))
9624 (gnus-completing-read default prom
9626 'gnus-valid-move-group-p
9628 'gnus-group-history))
9629 ((= 1 (length split-name))
9630 (gnus-completing-read (car split-name) prom
9632 'gnus-valid-move-group-p
9634 'gnus-group-history))
9636 (gnus-completing-read nil prom
9637 (mapcar (lambda (el) (list el))
9638 (nreverse split-name))
9640 'gnus-group-history))))
9641 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9643 (if (or (string= to-newsgroup "")
9644 (string= to-newsgroup prefix))
9645 (setq to-newsgroup default))
9646 (unless to-newsgroup
9647 (error "No group name entered"))
9648 (or (gnus-active to-newsgroup)
9649 (gnus-activate-group to-newsgroup nil nil to-method)
9650 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9652 (or (and (gnus-request-create-group to-newsgroup to-method)
9653 (gnus-activate-group
9654 to-newsgroup nil nil to-method)
9655 (gnus-subscribe-group to-newsgroup))
9656 (error "Couldn't create group %s" to-newsgroup)))
9657 (error "No such group: %s" to-newsgroup)))
9660 (defun gnus-summary-save-parts (type dir n &optional reverse)
9661 "Save parts matching TYPE to DIR.
9662 If REVERSE, save parts that do not match TYPE."
9664 (list (read-string "Save parts of type: "
9665 (or (car gnus-summary-save-parts-type-history)
9666 gnus-summary-save-parts-default-mime)
9667 'gnus-summary-save-parts-type-history)
9668 (setq gnus-summary-save-parts-last-directory
9669 (read-file-name "Save to directory: "
9670 gnus-summary-save-parts-last-directory
9672 current-prefix-arg))
9673 (gnus-summary-iterate n
9674 (let ((gnus-display-mime-function nil)
9675 (gnus-inhibit-treatment t))
9676 (gnus-summary-select-article))
9678 (set-buffer gnus-article-buffer)
9679 (let ((handles (or gnus-article-mime-handles
9680 (mm-dissect-buffer) (mm-uu-dissect))))
9682 (gnus-summary-save-parts-1 type dir handles reverse)
9683 (unless gnus-article-mime-handles ;; Don't destroy this case.
9684 (mm-destroy-parts handles)))))))
9686 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9687 (if (stringp (car handle))
9688 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9691 (not (string-match type (mm-handle-media-type handle)))
9692 (string-match type (mm-handle-media-type handle)))
9693 (let ((file (expand-file-name
9694 (file-name-nondirectory
9696 (mail-content-type-get
9697 (mm-handle-disposition handle) 'filename)
9698 (concat gnus-newsgroup-name
9699 "." (number-to-string
9700 (cdr gnus-article-current)))))
9702 (unless (file-exists-p file)
9703 (mm-save-part-to-file handle file))))))
9705 ;; Summary extract commands
9707 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9708 (let ((buffer-read-only nil)
9709 (article (gnus-summary-article-number))
9711 (unless (gnus-summary-goto-subject article)
9712 (error "No such article: %d" article))
9713 (gnus-summary-position-point)
9714 ;; If all commands are to be bunched up on one line, we collect
9716 (unless gnus-view-pseudos-separately
9717 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9720 (setq action (cdr (assq 'action (car ps))))
9721 (setq files (list (cdr (assq 'name (car ps)))))
9722 (while (and ps (cdr ps)
9723 (string= (or action "1")
9724 (or (cdr (assq 'action (cadr ps))) "2")))
9725 (push (cdr (assq 'name (cadr ps))) files)
9726 (setcdr ps (cddr ps)))
9728 (when (not (string-match "%s" action))
9731 (when (assq 'execute (car ps))
9732 (setcdr (assq 'execute (car ps))
9733 (funcall (if (string-match "%s" action)
9742 (setq ps (cdr ps)))))
9743 (if (and gnus-view-pseudos (not not-view))
9745 (when (assq 'execute (car pslist))
9746 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9747 (eq gnus-view-pseudos 'not-confirm)))
9748 (setq pslist (cdr pslist)))
9751 (setq after-article (or (cdr (assq 'article (car pslist)))
9752 (gnus-summary-article-number)))
9753 (gnus-summary-goto-subject after-article)
9756 (insert " " (file-name-nondirectory
9757 (cdr (assq 'name (car pslist))))
9758 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9760 (forward-line -1) ; back to `b'
9761 (gnus-add-text-properties
9762 b (1- e) (list 'gnus-number gnus-reffed-article-number
9763 gnus-mouse-face-prop gnus-mouse-face))
9765 after-article gnus-reffed-article-number
9766 gnus-unread-mark b (car pslist) 0 (- e b))
9767 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9768 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9769 (setq pslist (cdr pslist)))))))
9771 (defun gnus-pseudos< (p1 p2)
9772 (let ((c1 (cdr (assq 'action p1)))
9773 (c2 (cdr (assq 'action p2))))
9774 (and c1 c2 (string< c1 c2))))
9776 (defun gnus-request-pseudo-article (props)
9777 (cond ((assq 'execute props)
9778 (gnus-execute-command (cdr (assq 'execute props)))))
9779 (let ((gnus-current-article (gnus-summary-article-number)))
9780 (gnus-run-hooks 'gnus-mark-article-hook)))
9782 (defun gnus-execute-command (command &optional automatic)
9784 (gnus-article-setup-buffer)
9785 (set-buffer gnus-article-buffer)
9786 (setq buffer-read-only nil)
9787 (let ((command (if automatic command
9788 (read-string "Command: " (cons command 0)))))
9790 (insert "$ " command "\n\n")
9791 (if gnus-view-pseudo-asynchronously
9792 (start-process "gnus-execute" (current-buffer) shell-file-name
9793 shell-command-switch command)
9794 (call-process shell-file-name nil t nil
9795 shell-command-switch command)))))
9797 ;; Summary kill commands.
9799 (defun gnus-summary-edit-global-kill (article)
9800 "Edit the \"global\" kill file."
9801 (interactive (list (gnus-summary-article-number)))
9802 (gnus-group-edit-global-kill article))
9804 (defun gnus-summary-edit-local-kill ()
9805 "Edit a local kill file applied to the current newsgroup."
9807 (setq gnus-current-headers (gnus-summary-article-header))
9808 (gnus-group-edit-local-kill
9809 (gnus-summary-article-number) gnus-newsgroup-name))
9813 (defun gnus-read-header (id &optional header)
9814 "Read the headers of article ID and enter them into the Gnus system."
9815 (let ((group gnus-newsgroup-name)
9816 (gnus-override-method
9818 gnus-override-method
9819 (and (gnus-news-group-p gnus-newsgroup-name)
9820 (car (gnus-refer-article-methods)))))
9822 ;; First we check to see whether the header in question is already
9825 ;; This is a Message-ID.
9826 (setq header (or header (gnus-id-to-header id)))
9827 ;; This is an article number.
9828 (setq header (or header (gnus-summary-article-header id))))
9830 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9831 ;; We have found the header.
9833 ;; If this is a sparse article, we have to nix out its
9834 ;; previous entry in the thread hashtb.
9836 (gnus-summary-article-sparse-p (mail-header-number header)))
9837 (let* ((parent (gnus-parent-id (mail-header-references header)))
9838 (thread (and parent (gnus-id-to-thread parent))))
9840 (delq (assq header thread) thread))))
9841 ;; We have to really fetch the header to this article.
9843 (set-buffer nntp-server-buffer)
9844 (when (setq where (gnus-request-head id group))
9845 (nnheader-fold-continuation-lines)
9846 (goto-char (point-max))
9848 (goto-char (point-min))
9852 ((cdr where) (cdr where))
9853 (header (mail-header-number header))
9854 (t gnus-reffed-article-number))
9856 (insert " Article retrieved.\n"))
9858 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9859 () ; Malformed head.
9860 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9861 (when (and (stringp id)
9862 (not (string= (gnus-group-real-name group)
9864 ;; If we fetched by Message-ID and the article came
9865 ;; from a different group, we fudge some bogus article
9866 ;; numbers for this article.
9867 (mail-header-set-number header gnus-reffed-article-number))
9869 (set-buffer gnus-summary-buffer)
9870 (decf gnus-reffed-article-number)
9871 (gnus-remove-header (mail-header-number header))
9872 (push header gnus-newsgroup-headers)
9873 (setq gnus-current-headers header)
9874 (push (mail-header-number header) gnus-newsgroup-limit)))
9877 (defun gnus-remove-header (number)
9878 "Remove header NUMBER from `gnus-newsgroup-headers'."
9879 (if (and gnus-newsgroup-headers
9880 (= number (mail-header-number (car gnus-newsgroup-headers))))
9881 (pop gnus-newsgroup-headers)
9882 (let ((headers gnus-newsgroup-headers))
9883 (while (and (cdr headers)
9884 (not (= number (mail-header-number (cadr headers)))))
9887 (setcdr headers (cddr headers))))))
9890 ;;; summary highlights
9893 (defun gnus-highlight-selected-summary ()
9894 "Highlight selected article in summary buffer."
9895 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9896 (when gnus-summary-selected-face
9898 (let* ((beg (progn (beginning-of-line) (point)))
9899 (end (progn (end-of-line) (point)))
9900 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9901 (from (if (get-text-property beg gnus-mouse-face-prop)
9903 (or (next-single-property-change
9904 beg gnus-mouse-face-prop nil end)
9909 (or (next-single-property-change
9910 from gnus-mouse-face-prop nil end)
9912 ;; If no mouse-face prop on line we will have to = from = end,
9913 ;; so we highlight the entire line instead.
9914 (when (= (+ to 2) from)
9917 (if gnus-newsgroup-selected-overlay
9918 ;; Move old overlay.
9920 gnus-newsgroup-selected-overlay from to (current-buffer))
9921 ;; Create new overlay.
9923 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9924 'face gnus-summary-selected-face))))))
9926 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9927 (defun gnus-summary-highlight-line ()
9928 "Highlight current line according to `gnus-summary-highlight'."
9929 (let* ((list gnus-summary-highlight)
9931 (end (progn (end-of-line) (point)))
9932 ;; now find out where the line starts and leave point there.
9933 (beg (progn (beginning-of-line) (point)))
9934 (article (gnus-summary-article-number))
9935 (score (or (cdr (assq (or article gnus-current-article)
9936 gnus-newsgroup-scored))
9937 gnus-summary-default-score 0))
9938 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9939 (inhibit-read-only t))
9940 ;; Eval the cars of the lists until we find a match.
9941 (let ((default gnus-summary-default-score))
9943 (not (eval (caar list))))
9944 (setq list (cdr list))))
9945 (let ((face (cdar list)))
9946 (unless (eq face (get-text-property beg 'face))
9947 (gnus-put-text-property-excluding-characters-with-faces
9949 (setq face (if (boundp face) (symbol-value face) face)))
9950 (when gnus-summary-highlight-line-function
9951 (funcall gnus-summary-highlight-line-function article face))))
9954 (defun gnus-update-read-articles (group unread &optional compute)
9955 "Update the list of read articles in GROUP."
9956 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9957 (entry (gnus-gethash group gnus-newsrc-hashtb))
9958 (info (nth 2 entry))
9960 (unread (sort (copy-sequence unread) '<))
9962 (if (or (not info) (not active))
9963 ;; There is no info on this group if it was, in fact,
9964 ;; killed. Gnus stores no information on killed groups, so
9965 ;; there's nothing to be done.
9966 ;; One could store the information somewhere temporarily,
9967 ;; perhaps... Hmmm...
9969 ;; Remove any negative articles numbers.
9970 (while (and unread (< (car unread) 0))
9971 (setq unread (cdr unread)))
9972 ;; Remove any expired article numbers
9973 (while (and unread (< (car unread) (car active)))
9974 (setq unread (cdr unread)))
9975 ;; Compute the ranges of read articles by looking at the list of
9978 (when (/= (car unread) prev)
9979 (push (if (= prev (1- (car unread))) prev
9980 (cons prev (1- (car unread))))
9982 (setq prev (1+ (car unread)))
9983 (setq unread (cdr unread)))
9984 (when (<= prev (cdr active))
9985 (push (cons prev (cdr active)) read))
9986 (setq read (if (> (length read) 1) (nreverse read) read))
9991 ;; Propagate the read marks to the backend.
9992 (when (gnus-check-backend-function 'request-set-mark group)
9993 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9994 (add (gnus-remove-from-range read (gnus-info-read info))))
9996 (unless (gnus-check-group group)
9997 (error "Can't open server for %s" group))
9998 (gnus-request-set-mark
9999 group (delq nil (list (if add (list add 'add '(read)))
10000 (if del (list del 'del '(read))))))
10002 `(gnus-request-set-mark
10005 (if del (list del 'add '(read)))
10006 (if add (list add 'del '(read))))))))))
10007 (set-buffer gnus-group-buffer)
10008 (gnus-undo-register
10010 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10011 (gnus-info-set-read ',info ',(gnus-info-read info))
10012 (gnus-get-unread-articles-in-group ',info
10013 (gnus-active ,group))
10014 (gnus-group-update-group ,group t)
10016 ;; Enter this list into the group info.
10017 (gnus-info-set-read info read)
10018 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10019 (gnus-get-unread-articles-in-group info (gnus-active group))
10022 (defun gnus-offer-save-summaries ()
10023 "Offer to save all active summary buffers."
10025 ;; Go through all buffers and find all summaries.
10026 (dolist (buffer (buffer-list))
10027 (when (and (setq buffer (buffer-name buffer))
10028 (string-match "Summary" buffer)
10030 (set-buffer buffer)
10031 ;; We check that this is, indeed, a summary buffer.
10032 (and (eq major-mode 'gnus-summary-mode)
10033 ;; Also make sure this isn't bogus.
10034 gnus-newsgroup-prepared
10035 ;; Also make sure that this isn't a
10036 ;; dead summary buffer.
10037 (not gnus-dead-summary-mode))))
10038 (push buffer buffers)))
10039 ;; Go through all these summary buffers and offer to save them.
10043 "Update summary buffer %s? "
10045 (switch-to-buffer buf)
10046 (gnus-summary-exit))
10049 (defun gnus-summary-setup-default-charset ()
10050 "Setup newsgroup default charset."
10051 (if (equal gnus-newsgroup-name "nndraft:drafts")
10052 (setq gnus-newsgroup-charset nil)
10053 (let* ((ignored-charsets
10054 (or gnus-newsgroup-ephemeral-ignored-charsets
10056 (and gnus-newsgroup-name
10057 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10058 gnus-newsgroup-ignored-charsets))))
10059 (setq gnus-newsgroup-charset
10060 (or gnus-newsgroup-ephemeral-charset
10061 (and gnus-newsgroup-name
10062 (gnus-parameter-charset gnus-newsgroup-name))
10063 gnus-default-charset))
10064 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10065 ignored-charsets))))
10071 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10072 "Display the current article buffer fully MIME-buttonized.
10073 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10074 treated as multipart/mixed."
10076 (require 'gnus-art)
10077 (let ((gnus-unbuttonized-mime-types nil)
10078 (gnus-mime-display-multipart-as-mixed show-all-parts))
10079 (gnus-summary-show-article)))
10081 (defun gnus-summary-repair-multipart (article)
10082 "Add a Content-Type header to a multipart article without one."
10083 (interactive (list (gnus-summary-article-number)))
10084 (gnus-with-article article
10085 (message-narrow-to-head)
10086 (message-remove-header "Mime-Version")
10087 (goto-char (point-max))
10088 (insert "Mime-Version: 1.0\n")
10090 (when (search-forward "\n--" nil t)
10091 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10092 (message-narrow-to-head)
10093 (message-remove-header "Content-Type")
10094 (goto-char (point-max))
10095 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10098 (let (gnus-mark-article-hook)
10099 (gnus-summary-select-article t t nil article)))
10101 (defun gnus-summary-toggle-display-buttonized ()
10102 "Toggle the buttonizing of the article buffer."
10104 (require 'gnus-art)
10105 (if (setq gnus-inhibit-mime-unbuttonizing
10106 (not gnus-inhibit-mime-unbuttonizing))
10107 (let ((gnus-unbuttonized-mime-types nil))
10108 (gnus-summary-show-article))
10109 (gnus-summary-show-article)))
10112 ;;; Generic summary marking commands
10115 (defvar gnus-summary-marking-alist
10116 '((read gnus-del-mark "d")
10117 (unread gnus-unread-mark "u")
10118 (ticked gnus-ticked-mark "!")
10119 (dormant gnus-dormant-mark "?")
10120 (expirable gnus-expirable-mark "e"))
10121 "An alist of names/marks/keystrokes.")
10123 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10124 (defvar gnus-summary-mark-map)
10126 (defun gnus-summary-make-all-marking-commands ()
10127 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10128 (dolist (elem gnus-summary-marking-alist)
10129 (apply 'gnus-summary-make-marking-command elem)))
10131 (defun gnus-summary-make-marking-command (name mark keystroke)
10132 (let ((map (make-sparse-keymap)))
10133 (define-key gnus-summary-generic-mark-map keystroke map)
10134 (dolist (lway `((next "next" next nil "n")
10135 (next-unread "next unread" next t "N")
10136 (prev "previous" prev nil "p")
10137 (prev-unread "previous unread" prev t "P")
10138 (nomove "" nil nil ,keystroke)))
10139 (let ((func (gnus-summary-make-marking-command-1
10140 mark (car lway) lway name)))
10141 (setq func (eval func))
10142 (define-key map (nth 4 lway) func)))))
10144 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10146 (format "gnus-summary-put-mark-as-%s%s"
10147 name (if (eq way 'nomove)
10149 (concat "-" (symbol-name way)))))
10152 "Mark the current article as %s%s.
10153 If N, the prefix, then repeat N times.
10154 If N is negative, move in reverse order.
10155 The difference between N and the actual number of articles marked is
10159 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10161 (defun gnus-summary-generic-mark (n mark move unread)
10162 "Mark N articles with MARK."
10163 (unless (eq major-mode 'gnus-summary-mode)
10164 (error "This command can only be used in the summary buffer"))
10165 (gnus-summary-show-thread)
10168 ((eq move 'next) 1)
10169 ((eq move 'prev) -1)
10171 (if (zerop nummove)
10175 nummove (* -1 nummove))))
10176 (while (and (> n 0)
10177 (gnus-summary-mark-article nil mark)
10178 (zerop (gnus-summary-next-subject nummove unread t)))
10181 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10182 (gnus-summary-recenter)
10183 (gnus-summary-position-point)
10184 (gnus-set-mode-line 'summary)
10187 (defun gnus-summary-insert-articles (articles)
10188 (when (setq articles
10189 (gnus-set-difference articles
10190 (mapcar (lambda (h) (mail-header-number h))
10191 gnus-newsgroup-headers)))
10192 (setq gnus-newsgroup-headers
10194 gnus-newsgroup-headers
10195 (gnus-fetch-headers articles)
10196 'gnus-article-sort-by-number))
10197 ;; Suppress duplicates?
10198 (when gnus-suppress-duplicates
10199 (gnus-dup-suppress-articles))
10201 ;; We might want to build some more threads first.
10202 (when (and gnus-fetch-old-headers
10203 (eq gnus-headers-retrieved-by 'nov))
10204 (if (eq gnus-fetch-old-headers 'invisible)
10205 (gnus-build-all-threads)
10206 (gnus-build-old-threads)))
10207 ;; Let the Gnus agent mark articles as read.
10209 (gnus-agent-get-undownloaded-list))
10210 ;; Remove list identifiers from subject
10211 (when gnus-list-identifiers
10212 (gnus-summary-remove-list-identifiers))
10213 ;; First and last article in this newsgroup.
10214 (when gnus-newsgroup-headers
10215 (setq gnus-newsgroup-begin
10216 (mail-header-number (car gnus-newsgroup-headers))
10218 (mail-header-number
10219 (gnus-last-element gnus-newsgroup-headers))))
10220 (when gnus-use-scoring
10221 (gnus-possibly-score-headers))))
10223 (defun gnus-summary-insert-old-articles (&optional all)
10224 "Insert all old articles in this group.
10225 If ALL is non-nil, already read articles become readable.
10226 If ALL is a number, fetch this number of articles."
10229 (let ((old (mapcar 'car gnus-newsgroup-data))
10230 (i (car gnus-newsgroup-active))
10232 (while (<= i (cdr gnus-newsgroup-active))
10233 (or (memq i old) (push i older))
10235 (setq len (length older))
10240 (setq older (subseq older 0 all))))
10243 (if (and (numberp gnus-large-newsgroup)
10244 (> len gnus-large-newsgroup))
10248 "How many articles from %s (default %d): "
10250 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10252 (unless (string-match "^[ \t]*$" input)
10253 (setq all (string-to-number input))
10255 (setq older (subseq older 0 all))))))))
10257 (message "No old news.")
10258 (gnus-summary-insert-articles older)
10259 (gnus-summary-limit (gnus-union older old))))
10260 (gnus-summary-position-point)))
10262 (defun gnus-summary-insert-new-articles ()
10263 "Insert all new articles in this group."
10266 (let ((old (mapcar 'car gnus-newsgroup-data))
10267 (old-active gnus-newsgroup-active)
10268 (nnmail-fetched-sources (list t))
10270 (setq gnus-newsgroup-active
10271 (gnus-activate-group gnus-newsgroup-name 'scan))
10272 (setq i (1+ (cdr old-active)))
10273 (while (<= i (cdr gnus-newsgroup-active))
10277 (message "No gnus is bad news.")
10278 (setq new (nreverse new))
10279 (gnus-summary-insert-articles new)
10280 (setq gnus-newsgroup-unreads
10281 (append gnus-newsgroup-unreads new))
10282 (gnus-summary-limit (gnus-union old new))))
10283 (gnus-summary-position-point)))
10285 (gnus-summary-make-all-marking-commands)
10287 (gnus-ems-redefine)
10289 (provide 'gnus-sum)
10291 (run-hooks 'gnus-sum-load-hook)
10293 ;;; gnus-sum.el ends here