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."
959 (defcustom gnus-read-all-available-headers nil
960 "Whether Gnus should parse all headers made available to it.
961 This is mostly relevant for slow backends where the user may
962 wish to widen the summary buffer to include all headers
963 that were fetched. Say, for nnultimate groups."
965 :type '(choice boolean regexp))
967 ;;; Internal variables
969 (defvar gnus-article-mime-handles nil)
970 (defvar gnus-article-decoded-p nil)
971 (defvar gnus-article-charset nil)
972 (defvar gnus-article-ignored-charsets nil)
973 (defvar gnus-scores-exclude-files nil)
974 (defvar gnus-page-broken nil)
975 (defvar gnus-inhibit-mime-unbuttonizing nil)
977 (defvar gnus-original-article nil)
978 (defvar gnus-article-internal-prepare-hook nil)
979 (defvar gnus-newsgroup-process-stack nil)
981 (defvar gnus-thread-indent-array nil)
982 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
983 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
984 "Function called to sort the articles within a thread after it has been gathered together.")
986 (defvar gnus-summary-save-parts-type-history nil)
987 (defvar gnus-summary-save-parts-last-directory nil)
989 (defvar gnus-summary-save-parts-type-history nil)
990 (defvar gnus-summary-save-parts-last-directory nil)
992 ;; Avoid highlighting in kill files.
993 (defvar gnus-summary-inhibit-highlight nil)
994 (defvar gnus-newsgroup-selected-overlay nil)
995 (defvar gnus-inhibit-limiting nil)
996 (defvar gnus-newsgroup-adaptive-score-file nil)
997 (defvar gnus-current-score-file nil)
998 (defvar gnus-current-move-group nil)
999 (defvar gnus-current-copy-group nil)
1000 (defvar gnus-current-crosspost-group nil)
1002 (defvar gnus-newsgroup-dependencies nil)
1003 (defvar gnus-newsgroup-adaptive nil)
1004 (defvar gnus-summary-display-article-function nil)
1005 (defvar gnus-summary-highlight-line-function nil
1006 "Function called after highlighting a summary line.")
1008 (defvar gnus-summary-line-format-alist
1009 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1010 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1011 (?s gnus-tmp-subject-or-nil ?s)
1012 (?n gnus-tmp-name ?s)
1013 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1015 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1017 (?F gnus-tmp-from ?s)
1018 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1019 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1020 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1021 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1022 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1023 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1024 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1025 (?L gnus-tmp-lines ?s)
1026 (?I gnus-tmp-indentation ?s)
1027 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1028 (?R gnus-tmp-replied ?c)
1029 (?\[ gnus-tmp-opening-bracket ?c)
1030 (?\] gnus-tmp-closing-bracket ?c)
1031 (?\> (make-string gnus-tmp-level ? ) ?s)
1032 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1033 (?i gnus-tmp-score ?d)
1034 (?z gnus-tmp-score-char ?c)
1035 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1036 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1037 (?U gnus-tmp-unread ?c)
1038 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1039 (?t (gnus-summary-number-of-articles-in-thread
1040 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1042 (?e (gnus-summary-number-of-articles-in-thread
1043 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1045 (?u gnus-tmp-user-defined ?s)
1046 (?P (gnus-pick-line-number) ?d))
1047 "An alist of format specifications that can appear in summary lines.
1048 These are paired with what variables they correspond with, along with
1049 the type of the variable (string, integer, character, etc).")
1051 (defvar gnus-summary-dummy-line-format-alist
1052 `((?S gnus-tmp-subject ?s)
1053 (?N gnus-tmp-number ?d)
1054 (?u gnus-tmp-user-defined ?s)))
1056 (defvar gnus-summary-mode-line-format-alist
1057 `((?G gnus-tmp-group-name ?s)
1058 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1059 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1060 (?A gnus-tmp-article-number ?d)
1061 (?Z gnus-tmp-unread-and-unselected ?s)
1062 (?V gnus-version ?s)
1063 (?U gnus-tmp-unread-and-unticked ?d)
1064 (?S gnus-tmp-subject ?s)
1065 (?e gnus-tmp-unselected ?d)
1066 (?u gnus-tmp-user-defined ?s)
1067 (?d (length gnus-newsgroup-dormant) ?d)
1068 (?t (length gnus-newsgroup-marked) ?d)
1069 (?r (length gnus-newsgroup-reads) ?d)
1070 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1071 (?E gnus-newsgroup-expunged-tally ?d)
1072 (?s (gnus-current-score-file-nondirectory) ?s)))
1074 (defvar gnus-last-search-regexp nil
1075 "Default regexp for article search command.")
1077 (defvar gnus-last-shell-command nil
1078 "Default shell command on article.")
1080 (defvar gnus-newsgroup-begin nil)
1081 (defvar gnus-newsgroup-end nil)
1082 (defvar gnus-newsgroup-last-rmail nil)
1083 (defvar gnus-newsgroup-last-mail nil)
1084 (defvar gnus-newsgroup-last-folder nil)
1085 (defvar gnus-newsgroup-last-file nil)
1086 (defvar gnus-newsgroup-auto-expire nil)
1087 (defvar gnus-newsgroup-active nil)
1089 (defvar gnus-newsgroup-data nil)
1090 (defvar gnus-newsgroup-data-reverse nil)
1091 (defvar gnus-newsgroup-limit nil)
1092 (defvar gnus-newsgroup-limits nil)
1094 (defvar gnus-newsgroup-unreads nil
1095 "List of unread articles in the current newsgroup.")
1097 (defvar gnus-newsgroup-unselected nil
1098 "List of unselected unread articles in the current newsgroup.")
1100 (defvar gnus-newsgroup-reads nil
1101 "Alist of read articles and article marks in the current newsgroup.")
1103 (defvar gnus-newsgroup-expunged-tally nil)
1105 (defvar gnus-newsgroup-marked nil
1106 "List of ticked articles in the current newsgroup (a subset of unread art).")
1108 (defvar gnus-newsgroup-killed nil
1109 "List of ranges of articles that have been through the scoring process.")
1111 (defvar gnus-newsgroup-cached nil
1112 "List of articles that come from the article cache.")
1114 (defvar gnus-newsgroup-saved nil
1115 "List of articles that have been saved.")
1117 (defvar gnus-newsgroup-kill-headers nil)
1119 (defvar gnus-newsgroup-replied nil
1120 "List of articles that have been replied to in the current newsgroup.")
1122 (defvar gnus-newsgroup-forwarded nil
1123 "List of articles that have been forwarded in the current newsgroup.")
1125 (defvar gnus-newsgroup-expirable nil
1126 "List of articles in the current newsgroup that can be expired.")
1128 (defvar gnus-newsgroup-processable nil
1129 "List of articles in the current newsgroup that can be processed.")
1131 (defvar gnus-newsgroup-downloadable nil
1132 "List of articles in the current newsgroup that can be processed.")
1134 (defvar gnus-newsgroup-undownloaded nil
1135 "List of articles in the current newsgroup that haven't been downloaded..")
1137 (defvar gnus-newsgroup-unsendable nil
1138 "List of articles in the current newsgroup that won't be sent.")
1140 (defvar gnus-newsgroup-bookmarks nil
1141 "List of articles in the current newsgroup that have bookmarks.")
1143 (defvar gnus-newsgroup-dormant nil
1144 "List of dormant articles in the current newsgroup.")
1146 (defvar gnus-newsgroup-scored nil
1147 "List of scored articles in the current newsgroup.")
1149 (defvar gnus-newsgroup-headers nil
1150 "List of article headers in the current newsgroup.")
1152 (defvar gnus-newsgroup-threads nil)
1154 (defvar gnus-newsgroup-prepared nil
1155 "Whether the current group has been prepared properly.")
1157 (defvar gnus-newsgroup-ancient nil
1158 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1160 (defvar gnus-newsgroup-sparse nil)
1162 (defvar gnus-current-article nil)
1163 (defvar gnus-article-current nil)
1164 (defvar gnus-current-headers nil)
1165 (defvar gnus-have-all-headers nil)
1166 (defvar gnus-last-article nil)
1167 (defvar gnus-newsgroup-history nil)
1168 (defvar gnus-newsgroup-charset nil)
1169 (defvar gnus-newsgroup-ephemeral-charset nil)
1170 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1172 (defvar gnus-article-before-search nil)
1174 (defconst gnus-summary-local-variables
1175 '(gnus-newsgroup-name
1176 gnus-newsgroup-begin gnus-newsgroup-end
1177 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1178 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1179 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1180 gnus-newsgroup-unselected gnus-newsgroup-marked
1181 gnus-newsgroup-reads gnus-newsgroup-saved
1182 gnus-newsgroup-replied gnus-newsgroup-forwarded
1183 gnus-newsgroup-expirable
1184 gnus-newsgroup-processable gnus-newsgroup-killed
1185 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1186 gnus-newsgroup-unsendable
1187 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1188 gnus-newsgroup-headers gnus-newsgroup-threads
1189 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1190 gnus-current-article gnus-current-headers gnus-have-all-headers
1191 gnus-last-article gnus-article-internal-prepare-hook
1192 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1193 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1194 gnus-thread-expunge-below
1195 gnus-score-alist gnus-current-score-file
1196 (gnus-summary-expunge-below . global)
1197 (gnus-summary-mark-below . global)
1198 (gnus-orphan-score . global)
1199 gnus-newsgroup-active gnus-scores-exclude-files
1200 gnus-newsgroup-history gnus-newsgroup-ancient
1201 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1202 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1203 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1204 (gnus-newsgroup-expunged-tally . 0)
1205 gnus-cache-removable-articles gnus-newsgroup-cached
1206 gnus-newsgroup-data gnus-newsgroup-data-reverse
1207 gnus-newsgroup-limit gnus-newsgroup-limits
1208 gnus-newsgroup-charset)
1209 "Variables that are buffer-local to the summary buffers.")
1211 (defvar gnus-newsgroup-variables nil
1212 "Variables that have separate values in the newsgroups.")
1214 ;; Byte-compiler warning.
1215 (eval-when-compile (defvar gnus-article-mode-map))
1219 (defvar gnus-decode-encoded-word-methods
1220 '(mail-decode-encoded-word-string)
1221 "List of methods used to decode encoded words.
1223 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1224 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1225 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1226 whose names match REGEXP.
1229 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1230 mail-decode-encoded-word-string
1231 (\"chinese\" . rfc1843-decode-string))")
1233 (defvar gnus-decode-encoded-word-methods-cache nil)
1235 (defun gnus-multi-decode-encoded-word-string (string)
1236 "Apply the functions from `gnus-encoded-word-methods' that match."
1237 (unless (and gnus-decode-encoded-word-methods-cache
1238 (eq gnus-newsgroup-name
1239 (car gnus-decode-encoded-word-methods-cache)))
1240 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1243 (nconc gnus-decode-encoded-word-methods-cache (list x))
1244 (if (and gnus-newsgroup-name
1245 (string-match (car x) gnus-newsgroup-name))
1246 (nconc gnus-decode-encoded-word-methods-cache
1248 gnus-decode-encoded-word-methods))
1249 (let ((xlist gnus-decode-encoded-word-methods-cache))
1252 (setq string (funcall (pop xlist) string))))
1255 ;; Subject simplification.
1257 (defun gnus-simplify-whitespace (str)
1258 "Remove excessive whitespace from STR."
1261 (while (string-match "[ \t][ \t]+" mystr)
1262 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1264 (substring mystr (match-end 0)))))
1266 (when (string-match "^[ \t]+" mystr)
1267 (setq mystr (substring mystr (match-end 0))))
1269 (when (string-match "[ \t]+$" mystr)
1270 (setq mystr (substring mystr 0 (match-beginning 0))))
1273 (defsubst gnus-simplify-subject-re (subject)
1274 "Remove \"Re:\" from subject lines."
1275 (if (string-match message-subject-re-regexp subject)
1276 (substring subject (match-end 0))
1279 (defun gnus-simplify-subject (subject &optional re-only)
1280 "Remove `Re:' and words in parentheses.
1281 If RE-ONLY is non-nil, strip leading `Re:'s only."
1282 (let ((case-fold-search t)) ;Ignore case.
1283 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1284 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1285 (setq subject (substring subject (match-end 0))))
1286 ;; Remove uninteresting prefixes.
1287 (when (and (not re-only)
1288 gnus-simplify-ignored-prefixes
1289 (string-match gnus-simplify-ignored-prefixes subject))
1290 (setq subject (substring subject (match-end 0))))
1291 ;; Remove words in parentheses from end.
1293 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1294 (setq subject (substring subject 0 (match-beginning 0)))))
1295 ;; Return subject string.
1298 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1300 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1301 (goto-char (point-min))
1302 (while (re-search-forward regexp nil t)
1303 (replace-match (or newtext ""))))
1305 (defun gnus-simplify-buffer-fuzzy ()
1306 "Simplify string in the buffer fuzzily.
1307 The string in the accessible portion of the current buffer is simplified.
1308 It is assumed to be a single-line subject.
1309 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1310 matter is removed. Additional things can be deleted by setting
1311 `gnus-simplify-subject-fuzzy-regexp'."
1312 (let ((case-fold-search t)
1314 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1316 (while (not (eq modified-tick (buffer-modified-tick)))
1317 (setq modified-tick (buffer-modified-tick))
1319 ((listp gnus-simplify-subject-fuzzy-regexp)
1320 (mapcar 'gnus-simplify-buffer-fuzzy-step
1321 gnus-simplify-subject-fuzzy-regexp))
1322 (gnus-simplify-subject-fuzzy-regexp
1323 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1324 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1325 (gnus-simplify-buffer-fuzzy-step
1326 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1327 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1329 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1330 (gnus-simplify-buffer-fuzzy-step " +" " ")
1331 (gnus-simplify-buffer-fuzzy-step " $")
1332 (gnus-simplify-buffer-fuzzy-step "^ +")))
1334 (defun gnus-simplify-subject-fuzzy (subject)
1335 "Simplify a subject string fuzzily.
1336 See `gnus-simplify-buffer-fuzzy' for details."
1338 (gnus-set-work-buffer)
1339 (let ((case-fold-search t))
1340 ;; Remove uninteresting prefixes.
1341 (when (and gnus-simplify-ignored-prefixes
1342 (string-match gnus-simplify-ignored-prefixes subject))
1343 (setq subject (substring subject (match-end 0))))
1345 (inline (gnus-simplify-buffer-fuzzy))
1348 (defsubst gnus-simplify-subject-fully (subject)
1349 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1351 (gnus-simplify-subject-functions
1352 (gnus-map-function gnus-simplify-subject-functions subject))
1353 ((null gnus-summary-gather-subject-limit)
1354 (gnus-simplify-subject-re subject))
1355 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1356 (gnus-simplify-subject-fuzzy subject))
1357 ((numberp gnus-summary-gather-subject-limit)
1358 (gnus-limit-string (gnus-simplify-subject-re subject)
1359 gnus-summary-gather-subject-limit))
1363 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1364 "Check whether two subjects are equal.
1365 If optional argument simple-first is t, first argument is already
1368 ((null simple-first)
1369 (equal (gnus-simplify-subject-fully s1)
1370 (gnus-simplify-subject-fully s2)))
1373 (gnus-simplify-subject-fully s2)))))
1375 (defun gnus-summary-bubble-group ()
1376 "Increase the score of the current group.
1377 This is a handy function to add to `gnus-summary-exit-hook' to
1378 increase the score of each group you read."
1379 (gnus-group-add-score gnus-newsgroup-name))
1383 ;;; Gnus summary mode
1386 (put 'gnus-summary-mode 'mode-class 'special)
1388 (defvar gnus-article-commands-menu)
1391 ;; Non-orthogonal keys
1393 (gnus-define-keys gnus-summary-mode-map
1394 " " gnus-summary-next-page
1395 "\177" gnus-summary-prev-page
1396 [delete] gnus-summary-prev-page
1397 [backspace] gnus-summary-prev-page
1398 "\r" gnus-summary-scroll-up
1399 "\M-\r" gnus-summary-scroll-down
1400 "n" gnus-summary-next-unread-article
1401 "p" gnus-summary-prev-unread-article
1402 "N" gnus-summary-next-article
1403 "P" gnus-summary-prev-article
1404 "\M-\C-n" gnus-summary-next-same-subject
1405 "\M-\C-p" gnus-summary-prev-same-subject
1406 "\M-n" gnus-summary-next-unread-subject
1407 "\M-p" gnus-summary-prev-unread-subject
1408 "." gnus-summary-first-unread-article
1409 "," gnus-summary-best-unread-article
1410 "\M-s" gnus-summary-search-article-forward
1411 "\M-r" gnus-summary-search-article-backward
1412 "<" gnus-summary-beginning-of-article
1413 ">" gnus-summary-end-of-article
1414 "j" gnus-summary-goto-article
1415 "^" gnus-summary-refer-parent-article
1416 "\M-^" gnus-summary-refer-article
1417 "u" gnus-summary-tick-article-forward
1418 "!" gnus-summary-tick-article-forward
1419 "U" gnus-summary-tick-article-backward
1420 "d" gnus-summary-mark-as-read-forward
1421 "D" gnus-summary-mark-as-read-backward
1422 "E" gnus-summary-mark-as-expirable
1423 "\M-u" gnus-summary-clear-mark-forward
1424 "\M-U" gnus-summary-clear-mark-backward
1425 "k" gnus-summary-kill-same-subject-and-select
1426 "\C-k" gnus-summary-kill-same-subject
1427 "\M-\C-k" gnus-summary-kill-thread
1428 "\M-\C-l" gnus-summary-lower-thread
1429 "e" gnus-summary-edit-article
1430 "#" gnus-summary-mark-as-processable
1431 "\M-#" gnus-summary-unmark-as-processable
1432 "\M-\C-t" gnus-summary-toggle-threads
1433 "\M-\C-s" gnus-summary-show-thread
1434 "\M-\C-h" gnus-summary-hide-thread
1435 "\M-\C-f" gnus-summary-next-thread
1436 "\M-\C-b" gnus-summary-prev-thread
1437 [(meta down)] gnus-summary-next-thread
1438 [(meta up)] gnus-summary-prev-thread
1439 "\M-\C-u" gnus-summary-up-thread
1440 "\M-\C-d" gnus-summary-down-thread
1441 "&" gnus-summary-execute-command
1442 "c" gnus-summary-catchup-and-exit
1443 "\C-w" gnus-summary-mark-region-as-read
1444 "\C-t" gnus-summary-toggle-truncation
1445 "?" gnus-summary-mark-as-dormant
1446 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1447 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1448 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1449 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1450 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1451 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1452 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1453 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1454 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1455 "=" gnus-summary-expand-window
1456 "\C-x\C-s" gnus-summary-reselect-current-group
1457 "\M-g" gnus-summary-rescan-group
1458 "w" gnus-summary-stop-page-breaking
1459 "\C-c\C-r" gnus-summary-caesar-message
1460 "f" gnus-summary-followup
1461 "F" gnus-summary-followup-with-original
1462 "C" gnus-summary-cancel-article
1463 "r" gnus-summary-reply
1464 "R" gnus-summary-reply-with-original
1465 "\C-c\C-f" gnus-summary-mail-forward
1466 "o" gnus-summary-save-article
1467 "\C-o" gnus-summary-save-article-mail
1468 "|" gnus-summary-pipe-output
1469 "\M-k" gnus-summary-edit-local-kill
1470 "\M-K" gnus-summary-edit-global-kill
1472 "\C-c\C-d" gnus-summary-describe-group
1473 "q" gnus-summary-exit
1474 "Q" gnus-summary-exit-no-update
1475 "\C-c\C-i" gnus-info-find-node
1476 gnus-mouse-2 gnus-mouse-pick-article
1477 "m" gnus-summary-mail-other-window
1478 "a" gnus-summary-post-news
1479 "x" gnus-summary-limit-to-unread
1480 "s" gnus-summary-isearch-article
1481 "t" gnus-summary-toggle-header
1482 "g" gnus-summary-show-article
1483 "l" gnus-summary-goto-last-article
1484 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1485 "\C-d" gnus-summary-enter-digest-group
1486 "\M-\C-d" gnus-summary-read-document
1487 "\M-\C-e" gnus-summary-edit-parameters
1488 "\M-\C-a" gnus-summary-customize-parameters
1490 "*" gnus-cache-enter-article
1491 "\M-*" gnus-cache-remove-article
1492 "\M-&" gnus-summary-universal-argument
1493 "\C-l" gnus-recenter
1494 "I" gnus-summary-increase-score
1495 "L" gnus-summary-lower-score
1496 "\M-i" gnus-symbolic-argument
1497 "h" gnus-summary-select-article-buffer
1499 "b" gnus-article-view-part
1500 "\M-t" gnus-summary-toggle-display-buttonized
1502 "V" gnus-summary-score-map
1503 "X" gnus-uu-extract-map
1504 "S" gnus-summary-send-map)
1506 ;; Sort of orthogonal keymap
1507 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1508 "t" gnus-summary-tick-article-forward
1509 "!" gnus-summary-tick-article-forward
1510 "d" gnus-summary-mark-as-read-forward
1511 "r" gnus-summary-mark-as-read-forward
1512 "c" gnus-summary-clear-mark-forward
1513 " " gnus-summary-clear-mark-forward
1514 "e" gnus-summary-mark-as-expirable
1515 "x" gnus-summary-mark-as-expirable
1516 "?" gnus-summary-mark-as-dormant
1517 "b" gnus-summary-set-bookmark
1518 "B" gnus-summary-remove-bookmark
1519 "#" gnus-summary-mark-as-processable
1520 "\M-#" gnus-summary-unmark-as-processable
1521 "S" gnus-summary-limit-include-expunged
1522 "C" gnus-summary-catchup
1523 "H" gnus-summary-catchup-to-here
1524 "\C-c" gnus-summary-catchup-all
1525 "k" gnus-summary-kill-same-subject-and-select
1526 "K" gnus-summary-kill-same-subject
1527 "P" gnus-uu-mark-map)
1529 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1530 "c" gnus-summary-clear-above
1531 "u" gnus-summary-tick-above
1532 "m" gnus-summary-mark-above
1533 "k" gnus-summary-kill-below)
1535 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1536 "/" gnus-summary-limit-to-subject
1537 "n" gnus-summary-limit-to-articles
1538 "w" gnus-summary-pop-limit
1539 "s" gnus-summary-limit-to-subject
1540 "a" gnus-summary-limit-to-author
1541 "u" gnus-summary-limit-to-unread
1542 "m" gnus-summary-limit-to-marks
1543 "M" gnus-summary-limit-exclude-marks
1544 "v" gnus-summary-limit-to-score
1545 "*" gnus-summary-limit-include-cached
1546 "D" gnus-summary-limit-include-dormant
1547 "T" gnus-summary-limit-include-thread
1548 "d" gnus-summary-limit-exclude-dormant
1549 "t" gnus-summary-limit-to-age
1550 "x" gnus-summary-limit-to-extra
1551 "E" gnus-summary-limit-include-expunged
1552 "c" gnus-summary-limit-exclude-childless-dormant
1553 "C" gnus-summary-limit-mark-excluded-as-read
1554 "o" gnus-summary-insert-old-articles
1555 "N" gnus-summary-insert-new-articles)
1557 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1558 "n" gnus-summary-next-unread-article
1559 "p" gnus-summary-prev-unread-article
1560 "N" gnus-summary-next-article
1561 "P" gnus-summary-prev-article
1562 "\C-n" gnus-summary-next-same-subject
1563 "\C-p" gnus-summary-prev-same-subject
1564 "\M-n" gnus-summary-next-unread-subject
1565 "\M-p" gnus-summary-prev-unread-subject
1566 "f" gnus-summary-first-unread-article
1567 "b" gnus-summary-best-unread-article
1568 "j" gnus-summary-goto-article
1569 "g" gnus-summary-goto-subject
1570 "l" gnus-summary-goto-last-article
1571 "o" gnus-summary-pop-article)
1573 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1574 "k" gnus-summary-kill-thread
1575 "l" gnus-summary-lower-thread
1576 "i" gnus-summary-raise-thread
1577 "T" gnus-summary-toggle-threads
1578 "t" gnus-summary-rethread-current
1579 "^" gnus-summary-reparent-thread
1580 "s" gnus-summary-show-thread
1581 "S" gnus-summary-show-all-threads
1582 "h" gnus-summary-hide-thread
1583 "H" gnus-summary-hide-all-threads
1584 "n" gnus-summary-next-thread
1585 "p" gnus-summary-prev-thread
1586 "u" gnus-summary-up-thread
1587 "o" gnus-summary-top-thread
1588 "d" gnus-summary-down-thread
1589 "#" gnus-uu-mark-thread
1590 "\M-#" gnus-uu-unmark-thread)
1592 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1593 "g" gnus-summary-prepare
1594 "c" gnus-summary-insert-cached-articles)
1596 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1597 "c" gnus-summary-catchup-and-exit
1598 "C" gnus-summary-catchup-all-and-exit
1599 "E" gnus-summary-exit-no-update
1600 "Q" gnus-summary-exit
1601 "Z" gnus-summary-exit
1602 "n" gnus-summary-catchup-and-goto-next-group
1603 "R" gnus-summary-reselect-current-group
1604 "G" gnus-summary-rescan-group
1605 "N" gnus-summary-next-group
1606 "s" gnus-summary-save-newsrc
1607 "P" gnus-summary-prev-group)
1609 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1610 " " gnus-summary-next-page
1611 "n" gnus-summary-next-page
1612 "\177" gnus-summary-prev-page
1613 [delete] gnus-summary-prev-page
1614 "p" gnus-summary-prev-page
1615 "\r" gnus-summary-scroll-up
1616 "\M-\r" gnus-summary-scroll-down
1617 "<" gnus-summary-beginning-of-article
1618 ">" gnus-summary-end-of-article
1619 "b" gnus-summary-beginning-of-article
1620 "e" gnus-summary-end-of-article
1621 "^" gnus-summary-refer-parent-article
1622 "r" gnus-summary-refer-parent-article
1623 "D" gnus-summary-enter-digest-group
1624 "R" gnus-summary-refer-references
1625 "T" gnus-summary-refer-thread
1626 "g" gnus-summary-show-article
1627 "s" gnus-summary-isearch-article
1628 "P" gnus-summary-print-article
1629 "M" gnus-mailing-list-insinuate
1630 "t" gnus-article-babel)
1632 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1633 "b" gnus-article-add-buttons
1634 "B" gnus-article-add-buttons-to-head
1635 "o" gnus-article-treat-overstrike
1636 "e" gnus-article-emphasize
1637 "w" gnus-article-fill-cited-article
1638 "Q" gnus-article-fill-long-lines
1639 "C" gnus-article-capitalize-sentences
1640 "c" gnus-article-remove-cr
1641 "q" gnus-article-de-quoted-unreadable
1642 "6" gnus-article-de-base64-unreadable
1643 "Z" gnus-article-decode-HZ
1644 "h" gnus-article-wash-html
1645 "s" gnus-summary-force-verify-and-decrypt
1646 "f" gnus-article-display-x-face
1647 "l" gnus-summary-stop-page-breaking
1648 "r" gnus-summary-caesar-message
1649 "t" gnus-summary-toggle-header
1650 "v" gnus-summary-verbose-headers
1651 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1652 "p" gnus-article-verify-x-pgp-sig
1653 "d" gnus-article-treat-dumbquotes)
1655 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1656 "a" gnus-article-hide
1657 "h" gnus-article-hide-headers
1658 "b" gnus-article-hide-boring-headers
1659 "s" gnus-article-hide-signature
1660 "c" gnus-article-hide-citation
1661 "C" gnus-article-hide-citation-in-followups
1662 "l" gnus-article-hide-list-identifiers
1663 "p" gnus-article-hide-pgp
1664 "B" gnus-article-strip-banner
1665 "P" gnus-article-hide-pem
1666 "\C-c" gnus-article-hide-citation-maybe)
1668 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1669 "a" gnus-article-highlight
1670 "h" gnus-article-highlight-headers
1671 "c" gnus-article-highlight-citation
1672 "s" gnus-article-highlight-signature)
1674 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1675 "w" gnus-article-decode-mime-words
1676 "c" gnus-article-decode-charset
1677 "v" gnus-mime-view-all-parts
1678 "b" gnus-article-view-part)
1680 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1681 "z" gnus-article-date-ut
1682 "u" gnus-article-date-ut
1683 "l" gnus-article-date-local
1684 "p" gnus-article-date-english
1685 "e" gnus-article-date-lapsed
1686 "o" gnus-article-date-original
1687 "i" gnus-article-date-iso8601
1688 "s" gnus-article-date-user)
1690 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1691 "t" gnus-article-remove-trailing-blank-lines
1692 "l" gnus-article-strip-leading-blank-lines
1693 "m" gnus-article-strip-multiple-blank-lines
1694 "a" gnus-article-strip-blank-lines
1695 "A" gnus-article-strip-all-blank-lines
1696 "s" gnus-article-strip-leading-space
1697 "e" gnus-article-strip-trailing-space
1698 "w" gnus-article-remove-leading-whitespace)
1700 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1702 "f" gnus-summary-fetch-faq
1703 "d" gnus-summary-describe-group
1704 "h" gnus-summary-describe-briefly
1705 "i" gnus-info-find-node)
1707 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1708 "e" gnus-summary-expire-articles
1709 "\M-\C-e" gnus-summary-expire-articles-now
1710 "\177" gnus-summary-delete-article
1711 [delete] gnus-summary-delete-article
1712 [backspace] gnus-summary-delete-article
1713 "m" gnus-summary-move-article
1714 "r" gnus-summary-respool-article
1715 "w" gnus-summary-edit-article
1716 "c" gnus-summary-copy-article
1717 "B" gnus-summary-crosspost-article
1718 "q" gnus-summary-respool-query
1719 "t" gnus-summary-respool-trace
1720 "i" gnus-summary-import-article
1721 "I" gnus-summary-create-article
1722 "p" gnus-summary-article-posted-p)
1724 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1725 "o" gnus-summary-save-article
1726 "m" gnus-summary-save-article-mail
1727 "F" gnus-summary-write-article-file
1728 "r" gnus-summary-save-article-rmail
1729 "f" gnus-summary-save-article-file
1730 "b" gnus-summary-save-article-body-file
1731 "h" gnus-summary-save-article-folder
1732 "v" gnus-summary-save-article-vm
1733 "p" gnus-summary-pipe-output
1734 "s" gnus-soup-add-article)
1736 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1737 "b" gnus-summary-display-buttonized
1738 "m" gnus-summary-repair-multipart
1739 "v" gnus-article-view-part
1740 "o" gnus-article-save-part
1741 "c" gnus-article-copy-part
1742 "C" gnus-article-view-part-as-charset
1743 "e" gnus-article-externalize-part
1744 "E" gnus-article-encrypt-body
1745 "i" gnus-article-inline-part
1746 "|" gnus-article-pipe-part))
1748 (defvar gnus-article-post-menu nil)
1750 (defun gnus-summary-make-menu-bar ()
1751 (gnus-turn-off-edit-menu 'summary)
1753 (unless (boundp 'gnus-summary-misc-menu)
1756 gnus-summary-kill-menu gnus-summary-mode-map ""
1761 ["Customize" gnus-score-customize t])
1762 (gnus-make-score-map 'increase)
1763 (gnus-make-score-map 'lower)
1765 ["Kill below" gnus-summary-kill-below t]
1766 ["Mark above" gnus-summary-mark-above t]
1767 ["Tick above" gnus-summary-tick-above t]
1768 ["Clear above" gnus-summary-clear-above t])
1769 ["Current score" gnus-summary-current-score t]
1770 ["Set score" gnus-summary-set-score t]
1771 ["Switch current score file..." gnus-score-change-score-file t]
1772 ["Set mark below..." gnus-score-set-mark-below t]
1773 ["Set expunge below..." gnus-score-set-expunge-below t]
1774 ["Edit current score file" gnus-score-edit-current-scores t]
1775 ["Edit score file" gnus-score-edit-file t]
1776 ["Trace score" gnus-score-find-trace t]
1777 ["Find words" gnus-score-find-favourite-words t]
1778 ["Rescore buffer" gnus-summary-rescore t]
1779 ["Increase score..." gnus-summary-increase-score t]
1780 ["Lower score..." gnus-summary-lower-score t]))))
1782 ;; Define both the Article menu in the summary buffer and the equivalent
1783 ;; Commands menu in the article buffer here for consistency.
1786 ["All" gnus-article-hide t]
1787 ["Headers" gnus-article-hide-headers t]
1788 ["Signature" gnus-article-hide-signature t]
1789 ["Citation" gnus-article-hide-citation t]
1790 ["List identifiers" gnus-article-hide-list-identifiers t]
1791 ["PGP" gnus-article-hide-pgp t]
1792 ["Banner" gnus-article-strip-banner t]
1793 ["Boring headers" gnus-article-hide-boring-headers t])
1795 ["All" gnus-article-highlight t]
1796 ["Headers" gnus-article-highlight-headers t]
1797 ["Signature" gnus-article-highlight-signature t]
1798 ["Citation" gnus-article-highlight-citation t])
1800 ["Words" gnus-article-decode-mime-words t]
1801 ["Charset" gnus-article-decode-charset t]
1802 ["QP" gnus-article-de-quoted-unreadable t]
1803 ["Base64" gnus-article-de-base64-unreadable t]
1804 ["View all" gnus-mime-view-all-parts t]
1805 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1806 ["Encrypt body" gnus-article-encrypt-body t])
1808 ["Local" gnus-article-date-local t]
1809 ["ISO8601" gnus-article-date-iso8601 t]
1810 ["UT" gnus-article-date-ut t]
1811 ["Original" gnus-article-date-original t]
1812 ["Lapsed" gnus-article-date-lapsed t]
1813 ["User-defined" gnus-article-date-user t])
1816 ["Leading" gnus-article-strip-leading-blank-lines t]
1817 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1818 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1819 ["All of the above" gnus-article-strip-blank-lines t]
1820 ["All" gnus-article-strip-all-blank-lines t]
1821 ["Leading space" gnus-article-strip-leading-space t]
1822 ["Trailing space" gnus-article-strip-trailing-space t]
1823 ["Leading space in headers"
1824 gnus-article-remove-leading-whitespace t])
1825 ["Overstrike" gnus-article-treat-overstrike t]
1826 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1827 ["Emphasis" gnus-article-emphasize t]
1828 ["Word wrap" gnus-article-fill-cited-article t]
1829 ["Fill long lines" gnus-article-fill-long-lines t]
1830 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1831 ["CR" gnus-article-remove-cr t]
1832 ["Show X-Face" gnus-article-display-x-face t]
1833 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1834 ["Base64" gnus-article-de-base64-unreadable t]
1835 ["Rot 13" gnus-summary-caesar-message
1836 ,@(if (featurep 'xemacs) '(t)
1837 '(:help "\"Caesar rotate\" article by 13"))]
1838 ["Unix pipe" gnus-summary-pipe-message t]
1839 ["Add buttons" gnus-article-add-buttons t]
1840 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1841 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1842 ["Verbose header" gnus-summary-verbose-headers t]
1843 ["Toggle header" gnus-summary-toggle-header t]
1844 ["Html" gnus-article-wash-html t]
1845 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1846 ["HZ" gnus-article-decode-HZ t])
1848 ["Save in default format" gnus-summary-save-article
1849 ,@(if (featurep 'xemacs) '(t)
1850 '(:help "Save article using default method"))]
1851 ["Save in file" gnus-summary-save-article-file
1852 ,@(if (featurep 'xemacs) '(t)
1853 '(:help "Save article in file"))]
1854 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1855 ["Save in MH folder" gnus-summary-save-article-folder t]
1856 ["Save in VM folder" gnus-summary-save-article-vm t]
1857 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1858 ["Save body in file" gnus-summary-save-article-body-file t]
1859 ["Pipe through a filter" gnus-summary-pipe-output t]
1860 ["Add to SOUP packet" gnus-soup-add-article t]
1861 ["Print" gnus-summary-print-article t])
1863 ["Respool article..." gnus-summary-respool-article t]
1864 ["Move article..." gnus-summary-move-article
1865 (gnus-check-backend-function
1866 'request-move-article gnus-newsgroup-name)]
1867 ["Copy article..." gnus-summary-copy-article t]
1868 ["Crosspost article..." gnus-summary-crosspost-article
1869 (gnus-check-backend-function
1870 'request-replace-article gnus-newsgroup-name)]
1871 ["Import file..." gnus-summary-import-article t]
1872 ["Create article..." gnus-summary-create-article t]
1873 ["Check if posted" gnus-summary-article-posted-p t]
1874 ["Edit article" gnus-summary-edit-article
1875 (not (gnus-group-read-only-p))]
1876 ["Delete article" gnus-summary-delete-article
1877 (gnus-check-backend-function
1878 'request-expire-articles gnus-newsgroup-name)]
1879 ["Query respool" gnus-summary-respool-query t]
1880 ["Trace respool" gnus-summary-respool-trace t]
1881 ["Delete expirable articles" gnus-summary-expire-articles-now
1882 (gnus-check-backend-function
1883 'request-expire-articles gnus-newsgroup-name)])
1885 ["Uudecode" gnus-uu-decode-uu
1886 ,@(if (featurep 'xemacs) '(t)
1887 '(:help "Decode uuencoded article(s)"))]
1888 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1889 ["Unshar" gnus-uu-decode-unshar t]
1890 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1891 ["Save" gnus-uu-decode-save t]
1892 ["Binhex" gnus-uu-decode-binhex t]
1893 ["Postscript" gnus-uu-decode-postscript t])
1895 ["Enter article" gnus-cache-enter-article t]
1896 ["Remove article" gnus-cache-remove-article t])
1897 ["Translate" gnus-article-babel t]
1898 ["Select article buffer" gnus-summary-select-article-buffer t]
1899 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1900 ["Isearch article..." gnus-summary-isearch-article t]
1901 ["Beginning of the article" gnus-summary-beginning-of-article t]
1902 ["End of the article" gnus-summary-end-of-article t]
1903 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1904 ["Fetch referenced articles" gnus-summary-refer-references t]
1905 ["Fetch current thread" gnus-summary-refer-thread t]
1906 ["Fetch article with id..." gnus-summary-refer-article t]
1907 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1908 ["Redisplay" gnus-summary-show-article t])))
1910 gnus-summary-article-menu gnus-summary-mode-map ""
1911 (cons "Article" innards))
1913 (if (not (keymapp gnus-summary-article-menu))
1915 gnus-article-commands-menu gnus-article-mode-map ""
1916 (cons "Commands" innards))
1917 ;; in Emacs, don't share menu.
1918 (setq gnus-article-commands-menu
1919 (copy-keymap gnus-summary-article-menu))
1920 (define-key gnus-article-mode-map [menu-bar commands]
1921 (cons "Commands" gnus-article-commands-menu))))
1924 gnus-summary-thread-menu gnus-summary-mode-map ""
1926 ["Toggle threading" gnus-summary-toggle-threads t]
1927 ["Hide threads" gnus-summary-hide-all-threads t]
1928 ["Show threads" gnus-summary-show-all-threads t]
1929 ["Hide thread" gnus-summary-hide-thread t]
1930 ["Show thread" gnus-summary-show-thread t]
1931 ["Go to next thread" gnus-summary-next-thread t]
1932 ["Go to previous thread" gnus-summary-prev-thread t]
1933 ["Go down thread" gnus-summary-down-thread t]
1934 ["Go up thread" gnus-summary-up-thread t]
1935 ["Top of thread" gnus-summary-top-thread t]
1936 ["Mark thread as read" gnus-summary-kill-thread t]
1937 ["Lower thread score" gnus-summary-lower-thread t]
1938 ["Raise thread score" gnus-summary-raise-thread t]
1939 ["Rethread current" gnus-summary-rethread-current t]))
1942 gnus-summary-post-menu gnus-summary-mode-map ""
1944 ["Post an article" gnus-summary-post-news
1945 ,@(if (featurep 'xemacs) '(t)
1946 '(:help "Post an article"))]
1947 ["Followup" gnus-summary-followup
1948 ,@(if (featurep 'xemacs) '(t)
1949 '(:help "Post followup to this article"))]
1950 ["Followup and yank" gnus-summary-followup-with-original
1951 ,@(if (featurep 'xemacs) '(t)
1952 '(:help "Post followup to this article, quoting its contents"))]
1953 ["Supersede article" gnus-summary-supersede-article t]
1954 ["Cancel article" gnus-summary-cancel-article
1955 ,@(if (featurep 'xemacs) '(t)
1956 '(:help "Cancel an article you posted"))]
1957 ["Reply" gnus-summary-reply t]
1958 ["Reply and yank" gnus-summary-reply-with-original t]
1959 ["Wide reply" gnus-summary-wide-reply t]
1960 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1961 ,@(if (featurep 'xemacs) '(t)
1962 '(:help "Mail a reply, quoting this article"))]
1963 ["Mail forward" gnus-summary-mail-forward t]
1964 ["Post forward" gnus-summary-post-forward t]
1965 ["Digest and mail" gnus-uu-digest-mail-forward t]
1966 ["Digest and post" gnus-uu-digest-post-forward t]
1967 ["Resend message" gnus-summary-resend-message t]
1968 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1969 ["Send a mail" gnus-summary-mail-other-window t]
1970 ["Uuencode and post" gnus-uu-post-news
1971 ,@(if (featurep 'xemacs) '(t)
1972 '(:help "Post a uuencoded article"))]
1973 ["Followup via news" gnus-summary-followup-to-mail t]
1974 ["Followup via news and yank"
1975 gnus-summary-followup-to-mail-with-original t]
1977 ;;["Send" gnus-summary-send-draft t]
1978 ;;["Send bounced" gnus-resend-bounced-mail t])
1982 ((not (keymapp gnus-summary-post-menu))
1983 (setq gnus-article-post-menu gnus-summary-post-menu))
1984 ((not gnus-article-post-menu)
1985 ;; Don't share post menu.
1986 (setq gnus-article-post-menu
1987 (copy-keymap gnus-summary-post-menu))))
1988 (define-key gnus-article-mode-map [menu-bar post]
1989 (cons "Post" gnus-article-post-menu))
1992 gnus-summary-misc-menu gnus-summary-mode-map ""
1995 ["Mark as read" gnus-summary-mark-as-read-forward t]
1996 ["Mark same subject and select"
1997 gnus-summary-kill-same-subject-and-select t]
1998 ["Mark same subject" gnus-summary-kill-same-subject t]
1999 ["Catchup" gnus-summary-catchup
2000 ,@(if (featurep 'xemacs) '(t)
2001 '(:help "Mark unread articles in this group as read"))]
2002 ["Catchup all" gnus-summary-catchup-all t]
2003 ["Catchup to here" gnus-summary-catchup-to-here t]
2004 ["Catchup region" gnus-summary-mark-region-as-read t]
2005 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2007 ["Tick" gnus-summary-tick-article-forward t]
2008 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2009 ["Remove marks" gnus-summary-clear-mark-forward t]
2010 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2011 ["Set bookmark" gnus-summary-set-bookmark t]
2012 ["Remove bookmark" gnus-summary-remove-bookmark t])
2014 ["Marks..." gnus-summary-limit-to-marks t]
2015 ["Subject..." gnus-summary-limit-to-subject t]
2016 ["Author..." gnus-summary-limit-to-author t]
2017 ["Age..." gnus-summary-limit-to-age t]
2018 ["Extra..." gnus-summary-limit-to-extra t]
2019 ["Score" gnus-summary-limit-to-score t]
2020 ["Unread" gnus-summary-limit-to-unread t]
2021 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2022 ["Articles" gnus-summary-limit-to-articles t]
2023 ["Pop limit" gnus-summary-pop-limit t]
2024 ["Show dormant" gnus-summary-limit-include-dormant t]
2025 ["Hide childless dormant"
2026 gnus-summary-limit-exclude-childless-dormant t]
2027 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2028 ["Hide marked" gnus-summary-limit-exclude-marks t]
2029 ["Show expunged" gnus-summary-limit-include-expunged t])
2031 ["Set mark" gnus-summary-mark-as-processable t]
2032 ["Remove mark" gnus-summary-unmark-as-processable t]
2033 ["Remove all marks" gnus-summary-unmark-all-processable t]
2034 ["Mark above" gnus-uu-mark-over t]
2035 ["Mark series" gnus-uu-mark-series t]
2036 ["Mark region" gnus-uu-mark-region t]
2037 ["Unmark region" gnus-uu-unmark-region t]
2038 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2039 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2040 ["Mark all" gnus-uu-mark-all t]
2041 ["Mark buffer" gnus-uu-mark-buffer t]
2042 ["Mark sparse" gnus-uu-mark-sparse t]
2043 ["Mark thread" gnus-uu-mark-thread t]
2044 ["Unmark thread" gnus-uu-unmark-thread t]
2045 ("Process Mark Sets"
2046 ["Kill" gnus-summary-kill-process-mark t]
2047 ["Yank" gnus-summary-yank-process-mark
2048 gnus-newsgroup-process-stack]
2049 ["Save" gnus-summary-save-process-mark t]))
2051 ["Page forward" gnus-summary-next-page
2052 ,@(if (featurep 'xemacs) '(t)
2053 '(:help "Show next page of article"))]
2054 ["Page backward" gnus-summary-prev-page
2055 ,@(if (featurep 'xemacs) '(t)
2056 '(:help "Show previous page of article"))]
2057 ["Line forward" gnus-summary-scroll-up t])
2059 ["Next unread article" gnus-summary-next-unread-article t]
2060 ["Previous unread article" gnus-summary-prev-unread-article t]
2061 ["Next article" gnus-summary-next-article t]
2062 ["Previous article" gnus-summary-prev-article t]
2063 ["Next unread subject" gnus-summary-next-unread-subject t]
2064 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2065 ["Next article same subject" gnus-summary-next-same-subject t]
2066 ["Previous article same subject" gnus-summary-prev-same-subject t]
2067 ["First unread article" gnus-summary-first-unread-article t]
2068 ["Best unread article" gnus-summary-best-unread-article t]
2069 ["Go to subject number..." gnus-summary-goto-subject t]
2070 ["Go to article number..." gnus-summary-goto-article t]
2071 ["Go to the last article" gnus-summary-goto-last-article t]
2072 ["Pop article off history" gnus-summary-pop-article t])
2074 ["Sort by number" gnus-summary-sort-by-number t]
2075 ["Sort by author" gnus-summary-sort-by-author t]
2076 ["Sort by subject" gnus-summary-sort-by-subject t]
2077 ["Sort by date" gnus-summary-sort-by-date t]
2078 ["Sort by score" gnus-summary-sort-by-score t]
2079 ["Sort by lines" gnus-summary-sort-by-lines t]
2080 ["Sort by characters" gnus-summary-sort-by-chars t]
2081 ["Original sort" gnus-summary-sort-by-original t])
2083 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2084 ["Describe group" gnus-summary-describe-group t]
2085 ["Read manual" gnus-info-find-node t])
2087 ["Pick and read" gnus-pick-mode t]
2088 ["Binary" gnus-binary-mode t])
2090 ["Regenerate" gnus-summary-prepare t]
2091 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2092 ["Toggle threading" gnus-summary-toggle-threads t])
2093 ["See old articles" gnus-summary-insert-old-articles t]
2094 ["See new articles" gnus-summary-insert-new-articles t]
2095 ["Filter articles..." gnus-summary-execute-command t]
2096 ["Run command on subjects..." gnus-summary-universal-argument t]
2097 ["Search articles forward..." gnus-summary-search-article-forward t]
2098 ["Search articles backward..." gnus-summary-search-article-backward t]
2099 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2100 ["Expand window" gnus-summary-expand-window t]
2101 ["Expire expirable articles" gnus-summary-expire-articles
2102 (gnus-check-backend-function
2103 'request-expire-articles gnus-newsgroup-name)]
2104 ["Edit local kill file" gnus-summary-edit-local-kill t]
2105 ["Edit main kill file" gnus-summary-edit-global-kill t]
2106 ["Edit group parameters" gnus-summary-edit-parameters t]
2107 ["Customize group parameters" gnus-summary-customize-parameters t]
2108 ["Send a bug report" gnus-bug t]
2110 ["Catchup and exit" gnus-summary-catchup-and-exit
2111 ,@(if (featurep 'xemacs) '(t)
2112 '(:help "Mark unread articles in this group as read, then exit"))]
2113 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2114 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2115 ["Exit group" gnus-summary-exit
2116 ,@(if (featurep 'xemacs) '(t)
2117 '(:help "Exit current group, return to group selection mode"))]
2118 ["Exit group without updating" gnus-summary-exit-no-update t]
2119 ["Exit and goto next group" gnus-summary-next-group t]
2120 ["Exit and goto prev group" gnus-summary-prev-group t]
2121 ["Reselect group" gnus-summary-reselect-current-group t]
2122 ["Rescan group" gnus-summary-rescan-group t]
2123 ["Update dribble" gnus-summary-save-newsrc t])))
2125 (gnus-run-hooks 'gnus-summary-menu-hook)))
2127 (defvar gnus-summary-tool-bar-map nil)
2129 ;; Emacs 21 tool bar. Should be no-op otherwise.
2130 (defun gnus-summary-make-tool-bar ()
2131 (if (and (fboundp 'tool-bar-add-item-from-menu)
2132 (default-value 'tool-bar-mode)
2133 (not gnus-summary-tool-bar-map))
2134 (setq gnus-summary-tool-bar-map
2135 (let ((tool-bar-map (make-sparse-keymap))
2136 (load-path (mm-image-load-path)))
2137 (tool-bar-add-item-from-menu
2138 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2139 (tool-bar-add-item-from-menu
2140 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2141 (tool-bar-add-item-from-menu
2142 'gnus-summary-post-news "post" gnus-summary-mode-map)
2143 (tool-bar-add-item-from-menu
2144 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2145 (tool-bar-add-item-from-menu
2146 'gnus-summary-followup "followup" gnus-summary-mode-map)
2147 (tool-bar-add-item-from-menu
2148 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2149 (tool-bar-add-item-from-menu
2150 'gnus-summary-reply "reply" gnus-summary-mode-map)
2151 (tool-bar-add-item-from-menu
2152 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2153 (tool-bar-add-item-from-menu
2154 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2155 (tool-bar-add-item-from-menu
2156 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2157 (tool-bar-add-item-from-menu
2158 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2159 (tool-bar-add-item-from-menu
2160 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2161 (tool-bar-add-item-from-menu
2162 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2163 (tool-bar-add-item-from-menu
2164 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2165 (tool-bar-add-item-from-menu
2166 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2168 (if gnus-summary-tool-bar-map
2169 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2171 (defun gnus-score-set-default (var value)
2172 "A version of set that updates the GNU Emacs menu-bar."
2174 ;; It is the message that forces the active status to be updated.
2177 (defun gnus-make-score-map (type)
2178 "Make a summary score map of type TYPE."
2181 (let ((headers '(("author" "from" string)
2182 ("subject" "subject" string)
2183 ("article body" "body" string)
2184 ("article head" "head" string)
2185 ("xref" "xref" string)
2186 ("extra header" "extra" string)
2187 ("lines" "lines" number)
2188 ("followups to author" "followup" string)))
2189 (types '((number ("less than" <)
2192 (string ("substring" s)
2196 (perms '(("temporary" (current-time-string))
2204 (if (eq type 'lower)
2209 (setq header (car headers))
2215 (let ((ts (cdr (assoc (nth 2 header) types)))
2231 'gnus-summary-score-entry
2233 (if (or (string= (nth 1 header)
2235 (string= (nth 1 header)
2238 (list 'gnus-summary-header
2240 (list 'quote (nth 1 (car ts)))
2241 (list 'gnus-score-delta-default
2248 (list (nreverse outp))))
2251 (list (nreverse outt))))
2253 (setq headers (cdr headers)))
2254 (list (nreverse outh))))))))
2258 (defun gnus-summary-mode (&optional group)
2259 "Major mode for reading articles.
2261 All normal editing commands are switched off.
2262 \\<gnus-summary-mode-map>
2263 Each line in this buffer represents one article. To read an
2264 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2265 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2268 You can also post articles and send mail from this buffer. To
2269 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2270 of an article, type `\\[gnus-summary-reply]'.
2272 There are approx. one gazillion commands you can execute in this
2273 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2275 The following commands are available:
2277 \\{gnus-summary-mode-map}"
2279 (kill-all-local-variables)
2280 (when (gnus-visual-p 'summary-menu 'menu)
2281 (gnus-summary-make-menu-bar)
2282 (gnus-summary-make-tool-bar))
2283 (gnus-summary-make-local-variables)
2284 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2285 (gnus-summary-make-local-variables))
2286 (gnus-make-thread-indent-array)
2287 (gnus-simplify-mode-line)
2288 (setq major-mode 'gnus-summary-mode)
2289 (setq mode-name "Summary")
2290 (make-local-variable 'minor-mode-alist)
2291 (use-local-map gnus-summary-mode-map)
2292 (buffer-disable-undo)
2293 (setq buffer-read-only t) ;Disable modification
2294 (setq truncate-lines t)
2295 (setq selective-display t)
2296 (setq selective-display-ellipses t) ;Display `...'
2297 (gnus-summary-set-display-table)
2298 (gnus-set-default-directory)
2299 (setq gnus-newsgroup-name group)
2300 (make-local-variable 'gnus-summary-line-format)
2301 (make-local-variable 'gnus-summary-line-format-spec)
2302 (make-local-variable 'gnus-summary-dummy-line-format)
2303 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2304 (make-local-variable 'gnus-summary-mark-positions)
2305 (make-local-hook 'pre-command-hook)
2306 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2307 (gnus-run-hooks 'gnus-summary-mode-hook)
2308 (turn-on-gnus-mailing-list-mode)
2309 (mm-enable-multibyte-mule4)
2310 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2311 (gnus-update-summary-mark-positions))
2313 (defun gnus-summary-make-local-variables ()
2314 "Make all the local summary buffer variables."
2316 (dolist (local gnus-summary-local-variables)
2319 (if (eq (cdr local) 'global)
2320 ;; Copy the global value of the variable.
2321 (setq global (symbol-value (car local)))
2322 ;; Use the value from the list.
2323 (setq global (eval (cdr local))))
2324 (set (make-local-variable (car local)) global))
2325 ;; Simple nil-valued local variable.
2326 (set (make-local-variable local) nil)))))
2328 (defun gnus-summary-clear-local-variables ()
2329 (let ((locals gnus-summary-local-variables))
2331 (if (consp (car locals))
2332 (and (vectorp (caar locals))
2333 (set (caar locals) nil))
2334 (and (vectorp (car locals))
2335 (set (car locals) nil)))
2336 (setq locals (cdr locals)))))
2338 ;; Summary data functions.
2340 (defmacro gnus-data-number (data)
2343 (defmacro gnus-data-set-number (data number)
2344 `(setcar ,data ,number))
2346 (defmacro gnus-data-mark (data)
2349 (defmacro gnus-data-set-mark (data mark)
2350 `(setcar (nthcdr 1 ,data) ,mark))
2352 (defmacro gnus-data-pos (data)
2355 (defmacro gnus-data-set-pos (data pos)
2356 `(setcar (nthcdr 2 ,data) ,pos))
2358 (defmacro gnus-data-header (data)
2361 (defmacro gnus-data-set-header (data header)
2362 `(setf (nth 3 ,data) ,header))
2364 (defmacro gnus-data-level (data)
2367 (defmacro gnus-data-unread-p (data)
2368 `(= (nth 1 ,data) gnus-unread-mark))
2370 (defmacro gnus-data-read-p (data)
2371 `(/= (nth 1 ,data) gnus-unread-mark))
2373 (defmacro gnus-data-pseudo-p (data)
2374 `(consp (nth 3 ,data)))
2376 (defmacro gnus-data-find (number)
2377 `(assq ,number gnus-newsgroup-data))
2379 (defmacro gnus-data-find-list (number &optional data)
2380 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2381 (memq (assq ,number bdata)
2384 (defmacro gnus-data-make (number mark pos header level)
2385 `(list ,number ,mark ,pos ,header ,level))
2387 (defun gnus-data-enter (after-article number mark pos header level offset)
2388 (let ((data (gnus-data-find-list after-article)))
2390 (error "No such article: %d" after-article))
2391 (setcdr data (cons (gnus-data-make number mark pos header level)
2393 (setq gnus-newsgroup-data-reverse nil)
2394 (gnus-data-update-list (cddr data) offset)))
2396 (defun gnus-data-enter-list (after-article list &optional offset)
2398 (let ((data (and after-article (gnus-data-find-list after-article)))
2402 (let ((odata gnus-newsgroup-data))
2403 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2405 (gnus-data-update-list odata offset)))
2406 ;; Find the last element in the list to be spliced into the main
2409 (setq list (cdr list)))
2412 (setcdr list gnus-newsgroup-data)
2413 (setq gnus-newsgroup-data ilist)
2415 (gnus-data-update-list (cdr list) offset)))
2416 (setcdr list (cdr data))
2419 (gnus-data-update-list (cdr list) offset))))
2420 (setq gnus-newsgroup-data-reverse nil))))
2422 (defun gnus-data-remove (article &optional offset)
2423 (let ((data gnus-newsgroup-data))
2424 (if (= (gnus-data-number (car data)) article)
2426 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2427 gnus-newsgroup-data-reverse nil)
2429 (gnus-data-update-list gnus-newsgroup-data offset)))
2431 (when (= (gnus-data-number (cadr data)) article)
2432 (setcdr data (cddr data))
2434 (gnus-data-update-list (cdr data) offset))
2436 gnus-newsgroup-data-reverse nil))
2437 (setq data (cdr data))))))
2439 (defmacro gnus-data-list (backward)
2441 (or gnus-newsgroup-data-reverse
2442 (setq gnus-newsgroup-data-reverse
2443 (reverse gnus-newsgroup-data)))
2444 gnus-newsgroup-data))
2446 (defun gnus-data-update-list (data offset)
2447 "Add OFFSET to the POS of all data entries in DATA."
2448 (setq gnus-newsgroup-data-reverse nil)
2450 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2451 (setq data (cdr data))))
2453 (defun gnus-summary-article-pseudo-p (article)
2454 "Say whether this article is a pseudo article or not."
2455 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2457 (defmacro gnus-summary-article-sparse-p (article)
2458 "Say whether this article is a sparse article or not."
2459 `(memq ,article gnus-newsgroup-sparse))
2461 (defmacro gnus-summary-article-ancient-p (article)
2462 "Say whether this article is a sparse article or not."
2463 `(memq ,article gnus-newsgroup-ancient))
2465 (defun gnus-article-parent-p (number)
2466 "Say whether this article is a parent or not."
2467 (let ((data (gnus-data-find-list number)))
2468 (and (cdr data) ; There has to be an article after...
2469 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2470 (gnus-data-level (nth 1 data))))))
2472 (defun gnus-article-children (number)
2473 "Return a list of all children to NUMBER."
2474 (let* ((data (gnus-data-find-list number))
2475 (level (gnus-data-level (car data)))
2477 (setq data (cdr data))
2479 (= (gnus-data-level (car data)) (1+ level)))
2480 (push (gnus-data-number (car data)) children)
2481 (setq data (cdr data)))
2484 (defmacro gnus-summary-skip-intangible ()
2485 "If the current article is intangible, then jump to a different article."
2486 '(let ((to (get-text-property (point) 'gnus-intangible)))
2487 (and to (gnus-summary-goto-subject to))))
2489 (defmacro gnus-summary-article-intangible-p ()
2490 "Say whether this article is intangible or not."
2491 '(get-text-property (point) 'gnus-intangible))
2493 (defun gnus-article-read-p (article)
2494 "Say whether ARTICLE is read or not."
2495 (not (or (memq article gnus-newsgroup-marked)
2496 (memq article gnus-newsgroup-unreads)
2497 (memq article gnus-newsgroup-unselected)
2498 (memq article gnus-newsgroup-dormant))))
2500 ;; Some summary mode macros.
2502 (defmacro gnus-summary-article-number ()
2503 "The article number of the article on the current line.
2504 If there isn's an article number here, then we return the current
2507 (gnus-summary-skip-intangible)
2508 (or (get-text-property (point) 'gnus-number)
2509 (gnus-summary-last-subject))))
2511 (defmacro gnus-summary-article-header (&optional number)
2512 "Return the header of article NUMBER."
2513 `(gnus-data-header (gnus-data-find
2514 ,(or number '(gnus-summary-article-number)))))
2516 (defmacro gnus-summary-thread-level (&optional number)
2517 "Return the level of thread that starts with article NUMBER."
2518 `(if (and (eq gnus-summary-make-false-root 'dummy)
2519 (get-text-property (point) 'gnus-intangible))
2521 (gnus-data-level (gnus-data-find
2522 ,(or number '(gnus-summary-article-number))))))
2524 (defmacro gnus-summary-article-mark (&optional number)
2525 "Return the mark of article NUMBER."
2526 `(gnus-data-mark (gnus-data-find
2527 ,(or number '(gnus-summary-article-number)))))
2529 (defmacro gnus-summary-article-pos (&optional number)
2530 "Return the position of the line of article NUMBER."
2531 `(gnus-data-pos (gnus-data-find
2532 ,(or number '(gnus-summary-article-number)))))
2534 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2535 (defmacro gnus-summary-article-subject (&optional number)
2536 "Return current subject string or nil if nothing."
2539 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2540 '(gnus-data-header (assq (gnus-summary-article-number)
2541 gnus-newsgroup-data)))))
2544 (mail-header-subject headers))))
2546 (defmacro gnus-summary-article-score (&optional number)
2547 "Return current article score."
2548 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2549 gnus-newsgroup-scored))
2550 gnus-summary-default-score 0))
2552 (defun gnus-summary-article-children (&optional number)
2553 "Return a list of article numbers that are children of article NUMBER."
2554 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2555 (level (gnus-data-level (car data)))
2557 (while (and (setq data (cdr data))
2558 (> (setq l (gnus-data-level (car data))) level))
2559 (and (= (1+ level) l)
2560 (push (gnus-data-number (car data))
2562 (nreverse children)))
2564 (defun gnus-summary-article-parent (&optional number)
2565 "Return the article number of the parent of article NUMBER."
2566 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2567 (gnus-data-list t)))
2568 (level (gnus-data-level (car data))))
2570 () ; This is a root.
2571 ;; We search until we find an article with a level less than
2572 ;; this one. That function has to be the parent.
2573 (while (and (setq data (cdr data))
2574 (not (< (gnus-data-level (car data)) level))))
2575 (and data (gnus-data-number (car data))))))
2577 (defun gnus-unread-mark-p (mark)
2578 "Say whether MARK is the unread mark."
2579 (= mark gnus-unread-mark))
2581 (defun gnus-read-mark-p (mark)
2582 "Say whether MARK is one of the marks that mark as read.
2583 This is all marks except unread, ticked, dormant, and expirable."
2584 (not (or (= mark gnus-unread-mark)
2585 (= mark gnus-ticked-mark)
2586 (= mark gnus-dormant-mark)
2587 (= mark gnus-expirable-mark))))
2589 (defmacro gnus-article-mark (number)
2590 "Return the MARK of article NUMBER.
2591 This macro should only be used when computing the mark the \"first\"
2592 time; i.e., when generating the summary lines. After that,
2593 `gnus-summary-article-mark' should be used to examine the
2596 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2597 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2598 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2599 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2600 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2601 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2602 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2603 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2604 gnus-ancient-mark))))
2606 ;; Saving hidden threads.
2608 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2609 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2611 (defmacro gnus-save-hidden-threads (&rest forms)
2612 "Save hidden threads, eval FORMS, and restore the hidden threads."
2613 (let ((config (make-symbol "config")))
2614 `(let ((,config (gnus-hidden-threads-configuration)))
2618 (gnus-restore-hidden-threads-configuration ,config)))))
2620 (defun gnus-data-compute-positions ()
2621 "Compute the positions of all articles."
2622 (setq gnus-newsgroup-data-reverse nil)
2623 (let ((data gnus-newsgroup-data))
2625 (gnus-save-hidden-threads
2626 (gnus-summary-show-all-threads)
2627 (goto-char (point-min))
2629 (while (get-text-property (point) 'gnus-intangible)
2631 (gnus-data-set-pos (car data) (+ (point) 3))
2632 (setq data (cdr data))
2633 (forward-line 1))))))
2635 (defun gnus-hidden-threads-configuration ()
2636 "Return the current hidden threads configuration."
2639 (goto-char (point-min))
2640 (while (search-forward "\r" nil t)
2641 (push (1- (point)) config))
2644 (defun gnus-restore-hidden-threads-configuration (config)
2645 "Restore hidden threads configuration from CONFIG."
2647 (let (point buffer-read-only)
2648 (while (setq point (pop config))
2649 (when (and (< point (point-max))
2651 (eq (char-after) ?\n))
2652 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2654 ;; Various summary mode internalish functions.
2656 (defun gnus-mouse-pick-article (e)
2659 (gnus-summary-next-page nil t))
2661 (defun gnus-summary-set-display-table ()
2662 "Change the display table.
2663 Odd characters have a tendency to mess
2664 up nicely formatted displays - we make all possible glyphs
2665 display only a single character."
2667 ;; We start from the standard display table, if any.
2668 (let ((table (or (copy-sequence standard-display-table)
2669 (make-display-table)))
2671 ;; Nix out all the control chars...
2672 (while (>= (setq i (1- i)) 0)
2673 (aset table i [??]))
2674 ;; ... but not newline and cr, of course. (cr is necessary for the
2675 ;; selective display).
2676 (aset table ?\n nil)
2677 (aset table ?\r nil)
2678 ;; We keep TAB as well.
2679 (aset table ?\t nil)
2680 ;; We nix out any glyphs over 126 that are not set already.
2682 (while (>= (setq i (1- i)) 127)
2683 ;; Only modify if the entry is nil.
2684 (unless (aref table i)
2685 (aset table i [??]))))
2686 (setq buffer-display-table table)))
2688 (defun gnus-summary-buffer-name (group)
2689 "Return the summary buffer name of GROUP."
2690 (concat "*Summary " group "*"))
2692 (defun gnus-summary-setup-buffer (group)
2693 "Initialize summary buffer."
2694 (let ((buffer (gnus-summary-buffer-name group)))
2695 (if (get-buffer buffer)
2698 (setq gnus-summary-buffer (current-buffer))
2699 (not gnus-newsgroup-prepared))
2700 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2701 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2702 (gnus-summary-mode group)
2704 (gnus-carpal-setup-buffer 'summary))
2705 (unless gnus-single-article-buffer
2706 (make-local-variable 'gnus-article-buffer)
2707 (make-local-variable 'gnus-article-current)
2708 (make-local-variable 'gnus-original-article-buffer))
2709 (setq gnus-newsgroup-name group)
2710 ;; Set any local variables in the group parameters.
2711 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2714 (defun gnus-set-global-variables ()
2715 "Set the global equivalents of the buffer-local variables.
2716 They are set to the latest values they had. These reflect the summary
2717 buffer that was in action when the last article was fetched."
2718 (when (eq major-mode 'gnus-summary-mode)
2719 (setq gnus-summary-buffer (current-buffer))
2720 (let ((name gnus-newsgroup-name)
2721 (marked gnus-newsgroup-marked)
2722 (unread gnus-newsgroup-unreads)
2723 (headers gnus-current-headers)
2724 (data gnus-newsgroup-data)
2725 (summary gnus-summary-buffer)
2726 (article-buffer gnus-article-buffer)
2727 (original gnus-original-article-buffer)
2728 (gac gnus-article-current)
2729 (reffed gnus-reffed-article-number)
2730 (score-file gnus-current-score-file)
2731 (default-charset gnus-newsgroup-charset)
2733 (let ((locals gnus-newsgroup-variables))
2735 (if (consp (car locals))
2736 (push (eval (caar locals)) vlist)
2737 (push (eval (car locals)) vlist))
2738 (setq locals (cdr locals)))
2739 (setq vlist (nreverse vlist)))
2741 (set-buffer gnus-group-buffer)
2742 (setq gnus-newsgroup-name name
2743 gnus-newsgroup-marked marked
2744 gnus-newsgroup-unreads unread
2745 gnus-current-headers headers
2746 gnus-newsgroup-data data
2747 gnus-article-current gac
2748 gnus-summary-buffer summary
2749 gnus-article-buffer article-buffer
2750 gnus-original-article-buffer original
2751 gnus-reffed-article-number reffed
2752 gnus-current-score-file score-file
2753 gnus-newsgroup-charset default-charset)
2754 (let ((locals gnus-newsgroup-variables))
2756 (if (consp (car locals))
2757 (set (caar locals) (pop vlist))
2758 (set (car locals) (pop vlist)))
2759 (setq locals (cdr locals))))
2760 ;; The article buffer also has local variables.
2761 (when (gnus-buffer-live-p gnus-article-buffer)
2762 (set-buffer gnus-article-buffer)
2763 (setq gnus-summary-buffer summary))))))
2765 (defun gnus-summary-article-unread-p (article)
2766 "Say whether ARTICLE is unread or not."
2767 (memq article gnus-newsgroup-unreads))
2769 (defun gnus-summary-first-article-p (&optional article)
2770 "Return whether ARTICLE is the first article in the buffer."
2771 (if (not (setq article (or article (gnus-summary-article-number))))
2773 (eq article (caar gnus-newsgroup-data))))
2775 (defun gnus-summary-last-article-p (&optional article)
2776 "Return whether ARTICLE is the last article in the buffer."
2777 (if (not (setq article (or article (gnus-summary-article-number))))
2778 ;; All non-existent numbers are the last article. :-)
2780 (not (cdr (gnus-data-find-list article)))))
2782 (defun gnus-make-thread-indent-array ()
2784 (unless (and gnus-thread-indent-array
2785 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2786 (setq gnus-thread-indent-array (make-vector 201 "")
2787 gnus-thread-indent-array-level gnus-thread-indent-level)
2789 (aset gnus-thread-indent-array n
2790 (make-string (* n gnus-thread-indent-level) ? ))
2793 (defun gnus-update-summary-mark-positions ()
2794 "Compute where the summary marks are to go."
2796 (when (gnus-buffer-exists-p gnus-summary-buffer)
2797 (set-buffer gnus-summary-buffer))
2798 (let ((gnus-replied-mark 129)
2799 (gnus-score-below-mark 130)
2800 (gnus-score-over-mark 130)
2801 (gnus-download-mark 131)
2802 (spec gnus-summary-line-format-spec)
2805 (gnus-set-work-buffer)
2806 (let ((gnus-summary-line-format-spec spec)
2807 (gnus-newsgroup-downloadable '((0 . t))))
2808 (gnus-summary-insert-line
2809 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2810 0 nil 128 t nil "" nil 1)
2811 (goto-char (point-min))
2812 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2814 (goto-char (point-min))
2815 (push (cons 'replied (and (search-forward "\201" nil t)
2818 (goto-char (point-min))
2819 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2821 (goto-char (point-min))
2822 (push (cons 'download
2823 (and (search-forward "\203" nil t) (- (point) 2)))
2825 (setq gnus-summary-mark-positions pos))))
2827 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2828 "Insert a dummy root in the summary buffer."
2830 (gnus-add-text-properties
2831 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2832 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2834 (defun gnus-summary-from-or-to-or-newsgroups (header)
2835 (let ((to (cdr (assq 'To (mail-header-extra header))))
2836 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2837 (mail-parse-charset gnus-newsgroup-charset)
2838 (mail-parse-ignored-charsets
2839 (save-excursion (set-buffer gnus-summary-buffer)
2840 gnus-newsgroup-ignored-charsets)))
2843 gnus-ignored-from-addresses
2844 (string-match gnus-ignored-from-addresses
2845 (mail-header-from header)))
2847 (or (car (funcall gnus-extract-address-components
2849 gnus-decode-encoded-word-function to)))
2850 (funcall gnus-decode-encoded-word-function to))))
2852 gnus-ignored-from-addresses
2853 (string-match gnus-ignored-from-addresses
2854 (mail-header-from header)))
2855 (concat "=> " newsgroups))
2857 (or (car (funcall gnus-extract-address-components
2858 (mail-header-from header)))
2859 (mail-header-from header))))))
2861 (defun gnus-summary-insert-line (gnus-tmp-header
2862 gnus-tmp-level gnus-tmp-current
2863 gnus-tmp-unread gnus-tmp-replied
2864 gnus-tmp-expirable gnus-tmp-subject-or-nil
2865 &optional gnus-tmp-dummy gnus-tmp-score
2867 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2868 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2869 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2870 (gnus-tmp-score-char
2871 (if (or (null gnus-summary-default-score)
2872 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2873 gnus-summary-zcore-fuzz))
2875 (if (< gnus-tmp-score gnus-summary-default-score)
2876 gnus-score-below-mark gnus-score-over-mark)))
2878 (cond (gnus-tmp-process gnus-process-mark)
2879 ((memq gnus-tmp-current gnus-newsgroup-cached)
2881 (gnus-tmp-replied gnus-replied-mark)
2882 ((memq gnus-tmp-current gnus-newsgroup-saved)
2885 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2888 ((string-match "<[^>]+> *$" gnus-tmp-from)
2889 (let ((beg (match-beginning 0)))
2890 (or (and (string-match "^\".+\"" gnus-tmp-from)
2891 (substring gnus-tmp-from 1 (1- (match-end 0))))
2892 (substring gnus-tmp-from 0 beg))))
2893 ((string-match "(.+)" gnus-tmp-from)
2894 (substring gnus-tmp-from
2895 (1+ (match-beginning 0)) (1- (match-end 0))))
2897 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2898 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2899 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2900 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2901 (buffer-read-only nil))
2902 (when (string= gnus-tmp-name "")
2903 (setq gnus-tmp-name gnus-tmp-from))
2904 (unless (numberp gnus-tmp-lines)
2905 (setq gnus-tmp-lines -1))
2906 (when (= gnus-tmp-lines -1)
2907 (setq gnus-tmp-lines "?"))
2908 (gnus-put-text-property
2910 (progn (eval gnus-summary-line-format-spec) (point))
2911 'gnus-number gnus-tmp-number)
2912 (when (gnus-visual-p 'summary-highlight 'highlight)
2914 (gnus-run-hooks 'gnus-summary-update-hook)
2917 (defun gnus-summary-update-line (&optional dont-update)
2918 "Update summary line after change."
2919 (when (and gnus-summary-default-score
2920 (not gnus-summary-inhibit-highlight))
2921 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2922 (article (gnus-summary-article-number))
2923 (score (gnus-summary-article-score article)))
2925 (if (and gnus-summary-mark-below
2926 (< (gnus-summary-article-score)
2927 gnus-summary-mark-below))
2928 ;; This article has a low score, so we mark it as read.
2929 (when (memq article gnus-newsgroup-unreads)
2930 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2931 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2932 ;; This article was previously marked as read on account
2933 ;; of a low score, but now it has risen, so we mark it as
2935 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2936 (gnus-summary-update-mark
2937 (if (or (null gnus-summary-default-score)
2938 (<= (abs (- score gnus-summary-default-score))
2939 gnus-summary-zcore-fuzz))
2941 (if (< score gnus-summary-default-score)
2942 gnus-score-below-mark gnus-score-over-mark))
2944 ;; Do visual highlighting.
2945 (when (gnus-visual-p 'summary-highlight 'highlight)
2946 (gnus-run-hooks 'gnus-summary-update-hook)))))
2948 (defvar gnus-tmp-new-adopts nil)
2950 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2951 "Return the number of articles in THREAD.
2952 This may be 0 in some cases -- if none of the articles in
2953 the thread are to be displayed."
2955 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2957 ((not (listp thread))
2959 ((and (consp thread) (cdr thread))
2962 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2965 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2968 (when (and level (zerop level) gnus-tmp-new-adopts)
2971 'gnus-summary-number-of-articles-in-thread
2972 gnus-tmp-new-adopts))))
2974 (if (> number 1) gnus-not-empty-thread-mark
2975 gnus-empty-thread-mark)
2978 (defun gnus-summary-set-local-parameters (group)
2979 "Go through the local params of GROUP and set all variable specs in that list."
2980 (let ((params (gnus-group-find-parameter group))
2983 (setq elem (car params)
2984 params (cdr params))
2985 (and (consp elem) ; Has to be a cons.
2986 (consp (cdr elem)) ; The cdr has to be a list.
2987 (symbolp (car elem)) ; Has to be a symbol in there.
2988 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2989 (ignore-errors ; So we set it.
2990 (make-local-variable (car elem))
2991 (set (car elem) (eval (nth 1 elem))))))))
2993 (defun gnus-summary-read-group (group &optional show-all no-article
2994 kill-buffer no-display backward
2996 "Start reading news in newsgroup GROUP.
2997 If SHOW-ALL is non-nil, already read articles are also listed.
2998 If NO-ARTICLE is non-nil, no article is selected initially.
2999 If NO-DISPLAY, don't generate a summary buffer."
3003 (let ((gnus-auto-select-next nil))
3004 (or (gnus-summary-read-group-1
3005 group show-all no-article
3006 kill-buffer no-display
3009 select-articles nil)))))
3010 (eq gnus-auto-select-next 'quietly))
3011 (set-buffer gnus-group-buffer)
3012 ;; The entry function called above goes to the next
3013 ;; group automatically, so we go two groups back
3014 ;; if we are searching for the previous group.
3016 (gnus-group-prev-unread-group 2))
3017 (if (not (equal group (gnus-group-group-name)))
3018 (setq group (gnus-group-group-name))
3022 (defun gnus-summary-read-group-1 (group show-all no-article
3023 kill-buffer no-display
3024 &optional select-articles)
3025 ;; Killed foreign groups can't be entered.
3026 ;; (when (and (not (gnus-group-native-p group))
3027 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3028 ;; (error "Dead non-native groups can't be entered"))
3029 (gnus-message 5 "Retrieving newsgroup: %s..."
3030 (gnus-group-decoded-name group))
3031 (let* ((new-group (gnus-summary-setup-buffer group))
3032 (quit-config (gnus-group-quit-config group))
3033 (did-select (and new-group (gnus-select-newsgroup
3034 group show-all select-articles))))
3036 ;; This summary buffer exists already, so we just select it.
3038 (gnus-set-global-variables)
3040 (gnus-kill-or-deaden-summary kill-buffer))
3041 (gnus-configure-windows 'summary 'force)
3042 (gnus-set-mode-line 'summary)
3043 (gnus-summary-position-point)
3046 ;; We couldn't select this group.
3048 (when (and (eq major-mode 'gnus-summary-mode)
3049 (not (equal (current-buffer) kill-buffer)))
3050 (kill-buffer (current-buffer))
3051 (if (not quit-config)
3053 ;; Update the info -- marks might need to be removed,
3055 (gnus-summary-update-info)
3056 (set-buffer gnus-group-buffer)
3057 (gnus-group-jump-to-group group)
3058 (gnus-group-next-unread-group 1))
3059 (gnus-handle-ephemeral-exit quit-config)))
3060 (let ((grpinfo (gnus-get-info group)))
3061 (if (null (gnus-info-read grpinfo))
3062 (gnus-message 3 "Group %s contains no messages"
3063 (gnus-group-decoded-name group))
3064 (gnus-message 3 "Can't select group")))
3066 ;; The user did a `C-g' while prompting for number of articles,
3067 ;; so we exit this group.
3068 ((eq did-select 'quit)
3069 (and (eq major-mode 'gnus-summary-mode)
3070 (not (equal (current-buffer) kill-buffer))
3071 (kill-buffer (current-buffer)))
3073 (gnus-kill-or-deaden-summary kill-buffer))
3074 (if (not quit-config)
3076 (set-buffer gnus-group-buffer)
3077 (gnus-group-jump-to-group group)
3078 (gnus-group-next-unread-group 1)
3079 (gnus-configure-windows 'group 'force))
3080 (gnus-handle-ephemeral-exit quit-config))
3081 ;; Finally signal the quit.
3083 ;; The group was successfully selected.
3085 (gnus-set-global-variables)
3086 ;; Save the active value in effect when the group was entered.
3087 (setq gnus-newsgroup-active
3089 (gnus-active gnus-newsgroup-name)))
3090 ;; You can change the summary buffer in some way with this hook.
3091 (gnus-run-hooks 'gnus-select-group-hook)
3092 (gnus-update-format-specifications
3093 nil 'summary 'summary-mode 'summary-dummy)
3094 (gnus-update-summary-mark-positions)
3095 ;; Do score processing.
3096 (when gnus-use-scoring
3097 (gnus-possibly-score-headers))
3098 ;; Check whether to fill in the gaps in the threads.
3099 (when gnus-build-sparse-threads
3100 (gnus-build-sparse-threads))
3101 ;; Find the initial limit.
3102 (if gnus-show-threads
3104 (let ((gnus-newsgroup-dormant nil))
3105 (gnus-summary-initial-limit show-all))
3106 (gnus-summary-initial-limit show-all))
3107 ;; When untreaded, all articles are always shown.
3108 (setq gnus-newsgroup-limit
3110 (lambda (header) (mail-header-number header))
3111 gnus-newsgroup-headers)))
3112 ;; Generate the summary buffer.
3114 (gnus-summary-prepare))
3115 (when gnus-use-trees
3116 (gnus-tree-open group)
3117 (setq gnus-summary-highlight-line-function
3118 'gnus-tree-highlight-article))
3119 ;; If the summary buffer is empty, but there are some low-scored
3120 ;; articles or some excluded dormants, we include these in the
3122 (when (and (zerop (buffer-size))
3124 (cond (gnus-newsgroup-dormant
3125 (gnus-summary-limit-include-dormant))
3126 ((and gnus-newsgroup-scored show-all)
3127 (gnus-summary-limit-include-expunged t))))
3128 ;; Function `gnus-apply-kill-file' must be called in this hook.
3129 (gnus-run-hooks 'gnus-apply-kill-hook)
3130 (if (and (zerop (buffer-size))
3133 ;; This newsgroup is empty.
3134 (gnus-summary-catchup-and-exit nil t)
3135 (gnus-message 6 "No unread news")
3137 (gnus-kill-or-deaden-summary kill-buffer))
3138 ;; Return nil from this function.
3140 ;; Hide conversation thread subtrees. We cannot do this in
3141 ;; gnus-summary-prepare-hook since kill processing may not
3142 ;; work with hidden articles.
3143 (and gnus-show-threads
3144 gnus-thread-hide-subtree
3145 (gnus-summary-hide-all-threads))
3147 (gnus-kill-or-deaden-summary kill-buffer))
3148 ;; Show first unread article if requested.
3149 (if (and (not no-article)
3151 gnus-newsgroup-unreads
3152 gnus-auto-select-first)
3154 (gnus-configure-windows 'summary)
3156 ((eq gnus-auto-select-first 'best)
3157 (gnus-summary-best-unread-article))
3158 ((eq gnus-auto-select-first t)
3159 (gnus-summary-first-unread-article))
3160 ((gnus-functionp gnus-auto-select-first)
3161 (funcall gnus-auto-select-first))))
3162 ;; Don't select any articles, just move point to the first
3163 ;; article in the group.
3164 (goto-char (point-min))
3165 (gnus-summary-position-point)
3166 (gnus-configure-windows 'summary 'force)
3167 (gnus-set-mode-line 'summary))
3168 (when (get-buffer-window gnus-group-buffer t)
3169 ;; Gotta use windows, because recenter does weird stuff if
3170 ;; the current buffer ain't the displayed window.
3171 (let ((owin (selected-window)))
3172 (select-window (get-buffer-window gnus-group-buffer t))
3173 (when (gnus-group-goto-group group)
3175 (select-window owin)))
3176 ;; Mark this buffer as "prepared".
3177 (setq gnus-newsgroup-prepared t)
3178 (gnus-run-hooks 'gnus-summary-prepared-hook)
3181 (defun gnus-summary-prepare ()
3182 "Generate the summary buffer."
3184 (let ((buffer-read-only nil))
3186 (setq gnus-newsgroup-data nil
3187 gnus-newsgroup-data-reverse nil)
3188 (gnus-run-hooks 'gnus-summary-generate-hook)
3189 ;; Generate the buffer, either with threads or without.
3190 (when gnus-newsgroup-headers
3191 (gnus-summary-prepare-threads
3192 (if gnus-show-threads
3193 (gnus-sort-gathered-threads
3194 (funcall gnus-summary-thread-gathering-function
3196 (gnus-cut-threads (gnus-make-threads)))))
3197 ;; Unthreaded display.
3198 (gnus-sort-articles gnus-newsgroup-headers))))
3199 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3200 ;; Call hooks for modifying summary buffer.
3201 (goto-char (point-min))
3202 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3204 (defsubst gnus-general-simplify-subject (subject)
3205 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3208 ;; Truncate the subject.
3209 (gnus-simplify-subject-functions
3210 (gnus-map-function gnus-simplify-subject-functions subject))
3211 ((numberp gnus-summary-gather-subject-limit)
3212 (setq subject (gnus-simplify-subject-re subject))
3213 (if (> (length subject) gnus-summary-gather-subject-limit)
3214 (substring subject 0 gnus-summary-gather-subject-limit)
3216 ;; Fuzzily simplify it.
3217 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3218 (gnus-simplify-subject-fuzzy subject))
3219 ;; Just remove the leading "Re:".
3221 (gnus-simplify-subject-re subject))))
3223 (if (and gnus-summary-gather-exclude-subject
3224 (string-match gnus-summary-gather-exclude-subject subject))
3225 nil ; This article shouldn't be gathered
3228 (defun gnus-summary-simplify-subject-query ()
3229 "Query where the respool algorithm would put this article."
3231 (gnus-summary-select-article)
3232 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3234 (defun gnus-gather-threads-by-subject (threads)
3235 "Gather threads by looking at Subject headers."
3236 (if (not gnus-summary-make-false-root)
3238 (let ((hashtb (gnus-make-hashtable 1024))
3241 subject hthread whole-subject)
3243 (setq subject (gnus-general-simplify-subject
3244 (setq whole-subject (mail-header-subject
3247 (if (setq hthread (gnus-gethash subject hashtb))
3249 ;; We enter a dummy root into the thread, if we
3250 ;; haven't done that already.
3251 (unless (stringp (caar hthread))
3252 (setcar hthread (list whole-subject (car hthread))))
3253 ;; We add this new gathered thread to this gathered
3255 (setcdr (car hthread)
3256 (nconc (cdar hthread) (list (car threads))))
3257 ;; Remove it from the list of threads.
3258 (setcdr prev (cdr threads))
3259 (setq threads prev))
3260 ;; Enter this thread into the hash table.
3261 (gnus-sethash subject threads hashtb)))
3263 (setq threads (cdr threads)))
3266 (defun gnus-gather-threads-by-references (threads)
3267 "Gather threads by looking at References headers."
3268 (let ((idhashtb (gnus-make-hashtable 1024))
3269 (thhashtb (gnus-make-hashtable 1024))
3272 ids references id gthread gid entered ref)
3274 (when (setq references (mail-header-references (caar threads)))
3275 (setq id (mail-header-id (caar threads))
3276 ids (gnus-split-references references)
3278 (while (setq ref (pop ids))
3279 (setq ids (delete ref ids))
3280 (if (not (setq gid (gnus-gethash ref idhashtb)))
3282 (gnus-sethash ref id idhashtb)
3283 (gnus-sethash id threads thhashtb))
3284 (setq gthread (gnus-gethash gid thhashtb))
3286 ;; We enter a dummy root into the thread, if we
3287 ;; haven't done that already.
3288 (unless (stringp (caar gthread))
3289 (setcar gthread (list (mail-header-subject (caar gthread))
3291 ;; We add this new gathered thread to this gathered
3293 (setcdr (car gthread)
3294 (nconc (cdar gthread) (list (car threads)))))
3295 ;; Add it into the thread hash table.
3296 (gnus-sethash id gthread thhashtb)
3298 ;; Remove it from the list of threads.
3299 (setcdr prev (cdr threads))
3300 (setq threads prev))))
3302 (setq threads (cdr threads)))
3305 (defun gnus-sort-gathered-threads (threads)
3306 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3307 (let ((result threads))
3309 (when (stringp (caar threads))
3310 (setcdr (car threads)
3311 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3312 (setq threads (cdr threads)))
3315 (defun gnus-thread-loop-p (root thread)
3316 "Say whether ROOT is in THREAD."
3317 (let ((stack (list thread))
3320 (while (setq thread (pop stack))
3321 (setq th (cdr thread))
3323 (not (eq (caar th) root)))
3326 ;; We have found a loop.
3328 (setcdr thread (delq (car th) (cdr thread)))
3329 (if (boundp (setq ref-dep (intern "none"
3330 gnus-newsgroup-dependencies)))
3331 (setcdr (symbol-value ref-dep)
3332 (nconc (cdr (symbol-value ref-dep))
3334 (set ref-dep (list nil (car th))))
3337 ;; Push all the subthreads onto the stack.
3338 (push (cdr thread) stack)))
3341 (defun gnus-make-threads ()
3342 "Go through the dependency hashtb and find the roots. Return all threads."
3344 (while (catch 'infloop
3347 ;; Deal with self-referencing References loops.
3348 (when (and (car (symbol-value refs))
3355 (car (symbol-value refs)) thread))
3356 (cdr (symbol-value refs)))))))
3359 (unless (car (symbol-value refs))
3360 ;; These threads do not refer back to any other articles,
3361 ;; so they're roots.
3362 (setq threads (append (cdr (symbol-value refs)) threads))))
3363 gnus-newsgroup-dependencies)))
3366 ;; Build the thread tree.
3367 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3368 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3370 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3371 if it was already present.
3373 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3374 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3375 Message-IDs will be renamed be renamed to a unique Message-ID before
3378 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3379 (let* ((id (mail-header-id header))
3380 (id-dep (and id (intern id dependencies)))
3381 ref ref-dep ref-header)
3382 ;; Enter this `header' in the `dependencies' table.
3386 ;; The first two cases do the normal part: enter a new `header'
3387 ;; in the `dependencies' table.
3388 ((not (boundp id-dep))
3389 (set id-dep (list header)))
3390 ((null (car (symbol-value id-dep)))
3391 (setcar (symbol-value id-dep) header))
3393 ;; From here the `header' was already present in the
3394 ;; `dependencies' table.
3396 ;; Overrides an existing entry;
3397 ;; just set the header part of the entry.
3398 (setcar (symbol-value id-dep) header))
3400 ;; Renames the existing `header' to a unique Message-ID.
3401 ((not gnus-summary-ignore-duplicates)
3402 ;; An article with this Message-ID has already been seen.
3403 ;; We rename the Message-ID.
3404 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3406 (mail-header-set-id header id))
3408 ;; The last case ignores an existing entry, except it adds any
3409 ;; additional Xrefs (in case the two articles came from different
3411 ;; Also sets `header' to `nil' meaning that the `dependencies'
3412 ;; table was *not* modified.
3414 (mail-header-set-xref
3415 (car (symbol-value id-dep))
3416 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3418 (or (mail-header-xref header) "")))
3422 ;; First check if that we are not creating a References loop.
3423 (setq ref (gnus-parent-id (mail-header-references header)))
3425 (setq ref-dep (intern-soft ref dependencies))
3427 (setq ref-header (car (symbol-value ref-dep))))
3428 (if (string= id ref)
3429 ;; Yuk! This is a reference loop. Make the article be a
3432 (mail-header-set-references (car (symbol-value id-dep)) "none")
3434 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3435 (setq ref (gnus-parent-id (mail-header-references header)))
3436 (setq ref-dep (intern (or ref "none") dependencies))
3437 (if (boundp ref-dep)
3438 (setcdr (symbol-value ref-dep)
3439 (nconc (cdr (symbol-value ref-dep))
3440 (list (symbol-value id-dep))))
3441 (set ref-dep (list nil (symbol-value id-dep)))))
3444 (defun gnus-build-sparse-threads ()
3445 (let ((headers gnus-newsgroup-headers)
3446 (mail-parse-charset gnus-newsgroup-charset)
3447 (gnus-summary-ignore-duplicates t)
3448 header references generation relations
3449 subject child end new-child date)
3450 ;; First we create an alist of generations/relations, where
3451 ;; generations is how much we trust the relation, and the relation
3453 (gnus-message 7 "Making sparse threads...")
3455 (nnheader-set-temp-buffer " *gnus sparse threads*")
3456 (while (setq header (pop headers))
3457 (when (and (setq references (mail-header-references header))
3458 (not (string= references "")))
3460 (setq child (mail-header-id header)
3461 subject (mail-header-subject header)
3462 date (mail-header-date header)
3464 (while (search-backward ">" nil t)
3465 (setq end (1+ (point)))
3466 (when (search-backward "<" nil t)
3467 (setq new-child (buffer-substring (point) end))
3468 (push (list (incf generation)
3469 child (setq child new-child)
3473 (push (list (1+ generation) child nil subject) relations))
3475 (kill-buffer (current-buffer)))
3476 ;; Sort over trustworthiness.
3479 (when (gnus-dependencies-add-header
3480 (make-full-mail-header
3481 gnus-reffed-article-number
3482 (nth 3 relation) "" (or (nth 4 relation) "")
3484 (or (nth 2 relation) "") 0 0 "")
3485 gnus-newsgroup-dependencies nil)
3486 (push gnus-reffed-article-number gnus-newsgroup-limit)
3487 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3488 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3489 gnus-newsgroup-reads)
3490 (decf gnus-reffed-article-number)))
3491 (sort relations 'car-less-than-car))
3492 (gnus-message 7 "Making sparse threads...done")))
3494 (defun gnus-build-old-threads ()
3495 ;; Look at all the articles that refer back to old articles, and
3496 ;; fetch the headers for the articles that aren't there. This will
3497 ;; build complete threads - if the roots haven't been expired by the
3499 (let ((mail-parse-charset gnus-newsgroup-charset)
3503 (when (not (car (symbol-value refs)))
3504 (setq heads (cdr (symbol-value refs)))
3506 (if (memq (mail-header-number (caar heads))
3507 gnus-newsgroup-dormant)
3508 (setq heads (cdr heads))
3509 (setq id (symbol-name refs))
3510 (while (and (setq id (gnus-build-get-header id))
3511 (not (car (gnus-id-to-thread id)))))
3512 (setq heads nil)))))
3513 gnus-newsgroup-dependencies)))
3515 ;; This function has to be called with point after the article number
3516 ;; on the beginning of the line.
3517 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3518 (let ((eol (gnus-point-at-eol))
3519 (buffer (current-buffer))
3522 ;; overview: [num subject from date id refs chars lines misc]
3525 (narrow-to-region (point) eol)
3530 (make-full-mail-header
3532 (funcall gnus-decode-encoded-word-function
3533 (nnheader-nov-field)) ; subject
3534 (funcall gnus-decode-encoded-word-function
3535 (nnheader-nov-field)) ; from
3536 (nnheader-nov-field) ; date
3537 (nnheader-nov-read-message-id) ; id
3538 (nnheader-nov-field) ; refs
3539 (nnheader-nov-read-integer) ; chars
3540 (nnheader-nov-read-integer) ; lines
3542 (if (looking-at "Xref: ")
3543 (goto-char (match-end 0)))
3544 (nnheader-nov-field)) ; Xref
3545 (nnheader-nov-parse-extra)))) ; extra
3549 (when gnus-alter-header-function
3550 (funcall gnus-alter-header-function header))
3551 (gnus-dependencies-add-header header dependencies force-new)))
3553 (defun gnus-build-get-header (id)
3554 "Look through the buffer of NOV lines and find the header to ID.
3555 Enter this line into the dependencies hash table, and return
3556 the id of the parent article (if any)."
3557 (let ((deps gnus-newsgroup-dependencies)
3561 (set-buffer nntp-server-buffer)
3562 (let ((case-fold-search nil))
3563 (goto-char (point-min))
3564 (while (and (not found)
3565 (search-forward id nil t))
3567 (setq found (looking-at
3568 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3569 (regexp-quote id))))
3570 (or found (beginning-of-line 2)))
3574 (setq header (gnus-nov-parse-line
3575 (read (current-buffer)) deps))
3576 (gnus-parent-id (mail-header-references header))))))
3578 (let ((number (mail-header-number header)))
3579 (push number gnus-newsgroup-limit)
3580 (push header gnus-newsgroup-headers)
3581 (if (memq number gnus-newsgroup-unselected)
3583 (push number gnus-newsgroup-unreads)
3584 (setq gnus-newsgroup-unselected
3585 (delq number gnus-newsgroup-unselected)))
3586 (push number gnus-newsgroup-ancient)))))))
3588 (defun gnus-build-all-threads ()
3589 "Read all the headers."
3590 (let ((gnus-summary-ignore-duplicates t)
3591 (mail-parse-charset gnus-newsgroup-charset)
3592 (dependencies gnus-newsgroup-dependencies)
3595 (set-buffer nntp-server-buffer)
3596 (let ((case-fold-search nil))
3597 (goto-char (point-min))
3600 (setq article (read (current-buffer))
3601 header (gnus-nov-parse-line article dependencies)))
3604 (set-buffer gnus-summary-buffer)
3605 (push header gnus-newsgroup-headers)
3606 (if (memq (setq article (mail-header-number header))
3607 gnus-newsgroup-unselected)
3609 (push article gnus-newsgroup-unreads)
3610 (setq gnus-newsgroup-unselected
3611 (delq article gnus-newsgroup-unselected)))
3612 (push article gnus-newsgroup-ancient)))
3613 (forward-line 1)))))))
3615 (defun gnus-summary-update-article-line (article header)
3616 "Update the line for ARTICLE using HEADERS."
3617 (let* ((id (mail-header-id header))
3618 (thread (gnus-id-to-thread id)))
3620 (error "Article in no thread"))
3621 ;; Update the thread.
3622 (setcar thread header)
3623 (gnus-summary-goto-subject article)
3624 (let* ((datal (gnus-data-find-list article))
3626 (length (when (cdr datal)
3627 (- (gnus-data-pos data)
3628 (gnus-data-pos (cadr datal)))))
3629 (buffer-read-only nil)
3630 (level (gnus-summary-thread-level)))
3632 (gnus-summary-insert-line
3633 header level nil (gnus-article-mark article)
3634 (memq article gnus-newsgroup-replied)
3635 (memq article gnus-newsgroup-expirable)
3636 ;; Only insert the Subject string when it's different
3637 ;; from the previous Subject string.
3642 (mail-header-subject
3645 (gnus-data-find-list
3647 (gnus-data-list t)))))
3648 ;; Error on the side of excessive subjects.
3650 (mail-header-subject header)))
3652 (mail-header-subject header))
3653 nil (cdr (assq article gnus-newsgroup-scored))
3654 (memq article gnus-newsgroup-processable))
3656 (gnus-data-update-list
3657 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3659 (defun gnus-summary-update-article (article &optional iheader)
3660 "Update ARTICLE in the summary buffer."
3661 (set-buffer gnus-summary-buffer)
3662 (let* ((header (gnus-summary-article-header article))
3663 (id (mail-header-id header))
3664 (data (gnus-data-find article))
3665 (thread (gnus-id-to-thread id))
3666 (references (mail-header-references header))
3670 (when (and references
3671 (not (equal "" references)))
3674 (buffer-read-only nil)
3680 (delq thread parent)))
3681 (if (gnus-summary-insert-subject id header)
3682 ;; Set the (possibly) new article number in the data structure.
3683 (gnus-data-set-number data (gnus-id-to-article id))
3687 (defun gnus-rebuild-thread (id &optional line)
3688 "Rebuild the thread containing ID.
3689 If LINE, insert the rebuilt thread starting on line LINE."
3690 (let ((buffer-read-only nil)
3691 old-pos current thread data)
3692 (if (not gnus-show-threads)
3693 (setq thread (list (car (gnus-id-to-thread id))))
3694 ;; Get the thread this article is part of.
3695 (setq thread (gnus-remove-thread id)))
3696 (setq old-pos (gnus-point-at-bol))
3697 (setq current (save-excursion
3698 (and (zerop (forward-line -1))
3699 (gnus-summary-article-number))))
3700 ;; If this is a gathered thread, we have to go some re-gathering.
3701 (when (stringp (car thread))
3702 (let ((subject (car thread))
3704 (setq thread (cdr thread))
3706 (unless (memq (setq thr (gnus-id-to-thread
3708 (mail-header-id (caar thread)))))
3711 (setq thread (cdr thread)))
3712 ;; We now have all (unique) roots.
3713 (if (= (length roots) 1)
3714 ;; All the loose roots are now one solid root.
3715 (setq thread (car roots))
3716 (setq thread (cons subject (gnus-sort-threads roots))))))
3718 ;; We then insert this thread into the summary buffer.
3720 (goto-char (point-min))
3721 (forward-line (1- line)))
3722 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3723 (if gnus-show-threads
3724 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3725 (gnus-summary-prepare-unthreaded thread))
3726 (setq data (nreverse gnus-newsgroup-data))
3727 (setq threads gnus-newsgroup-threads))
3728 ;; We splice the new data into the data structure.
3729 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3730 ;;!!! then we want to insert at the beginning of the buffer.
3731 ;;!!! That happens to be true with Gnus now, but that may
3732 ;;!!! change in the future. Perhaps.
3733 (gnus-data-enter-list
3734 (if line nil current) data (- (point) old-pos))
3735 (setq gnus-newsgroup-threads
3736 (nconc threads gnus-newsgroup-threads))
3737 (gnus-data-compute-positions))))
3739 (defun gnus-number-to-header (number)
3740 "Return the header for article NUMBER."
3741 (let ((headers gnus-newsgroup-headers))
3743 (not (= number (mail-header-number (car headers)))))
3748 (defun gnus-parent-headers (in-headers &optional generation)
3749 "Return the headers of the GENERATIONeth parent of HEADERS."
3751 (setq generation 1))
3753 (headers in-headers)
3756 (not (zerop generation))
3757 (setq references (mail-header-references headers)))
3758 (setq headers (if (and references
3759 (setq parent (gnus-parent-id references)))
3760 (car (gnus-id-to-thread parent))
3763 (and (not (eq headers in-headers))
3766 (defun gnus-id-to-thread (id)
3767 "Return the (sub-)thread where ID appears."
3768 (gnus-gethash id gnus-newsgroup-dependencies))
3770 (defun gnus-id-to-article (id)
3771 "Return the article number of ID."
3772 (let ((thread (gnus-id-to-thread id)))
3775 (mail-header-number (car thread)))))
3777 (defun gnus-id-to-header (id)
3778 "Return the article headers of ID."
3779 (car (gnus-id-to-thread id)))
3781 (defun gnus-article-displayed-root-p (article)
3782 "Say whether ARTICLE is a root(ish) article."
3783 (let ((level (gnus-summary-thread-level article))
3784 (refs (mail-header-references (gnus-summary-article-header article)))
3790 ((null (gnus-parent-id refs)) t)
3792 (null (setq particle (gnus-id-to-article
3793 (gnus-parent-id refs))))
3794 (null (gnus-summary-thread-level particle)))))))
3796 (defun gnus-root-id (id)
3797 "Return the id of the root of the thread where ID appears."
3799 (while (and id (setq prev (car (gnus-id-to-thread id))))
3801 id (gnus-parent-id (mail-header-references prev))))
3804 (defun gnus-articles-in-thread (thread)
3805 "Return the list of articles in THREAD."
3806 (cons (mail-header-number (car thread))
3807 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3809 (defun gnus-remove-thread (id &optional dont-remove)
3810 "Remove the thread that has ID in it."
3811 (let (headers thread last-id)
3812 ;; First go up in this thread until we find the root.
3813 (setq last-id (gnus-root-id id)
3814 headers (message-flatten-list (gnus-id-to-thread last-id)))
3815 ;; We have now found the real root of this thread. It might have
3816 ;; been gathered into some loose thread, so we have to search
3817 ;; through the threads to find the thread we wanted.
3818 (let ((threads gnus-newsgroup-threads)
3821 (setq sub (car threads))
3822 (if (stringp (car sub))
3823 ;; This is a gathered thread, so we look at the roots
3824 ;; below it to find whether this article is in this
3827 (setq sub (cdr sub))
3829 (when (member (caar sub) headers)
3830 (setq thread (car threads)
3833 (setq sub (cdr sub))))
3834 ;; It's an ordinary thread, so we check it.
3835 (when (eq (car sub) (car headers))
3838 (setq threads (cdr threads)))
3839 ;; If this article is in no thread, then it's a root.
3842 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3843 (setq thread (gnus-id-to-thread last-id)))
3846 thread ; We return this thread.
3848 (if (stringp (car thread))
3850 ;; If we use dummy roots, then we have to remove the
3851 ;; dummy root as well.
3852 (when (eq gnus-summary-make-false-root 'dummy)
3853 ;; We go to the dummy root by going to
3854 ;; the first sub-"thread", and then one line up.
3855 (gnus-summary-goto-article
3856 (mail-header-number (caadr thread)))
3859 (gnus-data-compute-positions))
3860 (setq thread (cdr thread))
3862 (gnus-remove-thread-1 (car thread))
3863 (setq thread (cdr thread))))
3864 (gnus-remove-thread-1 thread))))))))
3866 (defun gnus-remove-thread-1 (thread)
3867 "Remove the thread THREAD recursively."
3868 (let ((number (mail-header-number (pop thread)))
3870 (setq thread (reverse thread))
3872 (gnus-remove-thread-1 (pop thread)))
3873 (when (setq d (gnus-data-find number))
3874 (goto-char (gnus-data-pos d))
3875 (gnus-summary-show-thread)
3878 (- (gnus-point-at-bol)
3880 (1+ (gnus-point-at-eol))
3881 (gnus-delete-line)))))))
3883 (defun gnus-sort-threads-1 (threads func)
3884 (sort (mapcar (lambda (thread)
3887 (gnus-sort-threads-1 (cdr thread) func))))
3890 (defun gnus-sort-threads (threads)
3892 (if (not gnus-thread-sort-functions)
3894 (gnus-message 8 "Sorting threads...")
3896 (gnus-sort-threads-1
3898 (gnus-make-sort-function gnus-thread-sort-functions))
3899 (gnus-message 8 "Sorting threads...done"))))
3901 (defun gnus-sort-articles (articles)
3903 (when gnus-article-sort-functions
3904 (gnus-message 7 "Sorting articles...")
3906 (setq gnus-newsgroup-headers
3907 (sort articles (gnus-make-sort-function
3908 gnus-article-sort-functions)))
3909 (gnus-message 7 "Sorting articles...done"))))
3911 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3912 (defmacro gnus-thread-header (thread)
3913 "Return header of first article in THREAD.
3914 Note that THREAD must never, ever be anything else than a variable -
3915 using some other form will lead to serious barfage."
3916 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3917 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3918 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3921 (defsubst gnus-article-sort-by-number (h1 h2)
3922 "Sort articles by article number."
3923 (< (mail-header-number h1)
3924 (mail-header-number h2)))
3926 (defun gnus-thread-sort-by-number (h1 h2)
3927 "Sort threads by root article number."
3928 (gnus-article-sort-by-number
3929 (gnus-thread-header h1) (gnus-thread-header h2)))
3931 (defsubst gnus-article-sort-by-lines (h1 h2)
3932 "Sort articles by article Lines header."
3933 (< (mail-header-lines h1)
3934 (mail-header-lines h2)))
3936 (defun gnus-thread-sort-by-lines (h1 h2)
3937 "Sort threads by root article Lines header."
3938 (gnus-article-sort-by-lines
3939 (gnus-thread-header h1) (gnus-thread-header h2)))
3941 (defsubst gnus-article-sort-by-chars (h1 h2)
3942 "Sort articles by octet length."
3943 (< (mail-header-chars h1)
3944 (mail-header-chars h2)))
3946 (defun gnus-thread-sort-by-chars (h1 h2)
3947 "Sort threads by root article octet length."
3948 (gnus-article-sort-by-chars
3949 (gnus-thread-header h1) (gnus-thread-header h2)))
3951 (defsubst gnus-article-sort-by-author (h1 h2)
3952 "Sort articles by root author."
3954 (let ((extract (funcall
3955 gnus-extract-address-components
3956 (mail-header-from h1))))
3957 (or (car extract) (cadr extract) ""))
3958 (let ((extract (funcall
3959 gnus-extract-address-components
3960 (mail-header-from h2))))
3961 (or (car extract) (cadr extract) ""))))
3963 (defun gnus-thread-sort-by-author (h1 h2)
3964 "Sort threads by root author."
3965 (gnus-article-sort-by-author
3966 (gnus-thread-header h1) (gnus-thread-header h2)))
3968 (defsubst gnus-article-sort-by-subject (h1 h2)
3969 "Sort articles by root subject."
3971 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3972 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3974 (defun gnus-thread-sort-by-subject (h1 h2)
3975 "Sort threads by root subject."
3976 (gnus-article-sort-by-subject
3977 (gnus-thread-header h1) (gnus-thread-header h2)))
3979 (defsubst gnus-article-sort-by-date (h1 h2)
3980 "Sort articles by root article date."
3982 (gnus-date-get-time (mail-header-date h1))
3983 (gnus-date-get-time (mail-header-date h2))))
3985 (defun gnus-thread-sort-by-date (h1 h2)
3986 "Sort threads by root article date."
3987 (gnus-article-sort-by-date
3988 (gnus-thread-header h1) (gnus-thread-header h2)))
3990 (defsubst gnus-article-sort-by-score (h1 h2)
3991 "Sort articles by root article score.
3992 Unscored articles will be counted as having a score of zero."
3993 (> (or (cdr (assq (mail-header-number h1)
3994 gnus-newsgroup-scored))
3995 gnus-summary-default-score 0)
3996 (or (cdr (assq (mail-header-number h2)
3997 gnus-newsgroup-scored))
3998 gnus-summary-default-score 0)))
4000 (defun gnus-thread-sort-by-score (h1 h2)
4001 "Sort threads by root article score."
4002 (gnus-article-sort-by-score
4003 (gnus-thread-header h1) (gnus-thread-header h2)))
4005 (defun gnus-thread-sort-by-total-score (h1 h2)
4006 "Sort threads by the sum of all scores in the thread.
4007 Unscored articles will be counted as having a score of zero."
4008 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4010 (defun gnus-thread-total-score (thread)
4011 ;; This function find the total score of THREAD.
4012 (cond ((null thread)
4015 (if (stringp (car thread))
4016 (apply gnus-thread-score-function 0
4017 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4018 (gnus-thread-total-score-1 thread)))
4020 (gnus-thread-total-score-1 (list thread)))))
4022 (defun gnus-thread-total-score-1 (root)
4023 ;; This function find the total score of the thread below ROOT.
4024 (setq root (car root))
4025 (apply gnus-thread-score-function
4027 (mapcar 'gnus-thread-total-score
4028 (cdr (gnus-id-to-thread (mail-header-id root))))
4029 (when (> (mail-header-number root) 0)
4030 (list (or (cdr (assq (mail-header-number root)
4031 gnus-newsgroup-scored))
4032 gnus-summary-default-score 0))))
4033 (list gnus-summary-default-score)
4036 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4037 (defvar gnus-tmp-prev-subject nil)
4038 (defvar gnus-tmp-false-parent nil)
4039 (defvar gnus-tmp-root-expunged nil)
4040 (defvar gnus-tmp-dummy-line nil)
4042 (eval-when-compile (defvar gnus-tmp-header))
4043 (defun gnus-extra-header (type &optional header)
4044 "Return the extra header of TYPE."
4045 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4048 (defun gnus-summary-prepare-threads (threads)
4049 "Prepare summary buffer from THREADS and indentation LEVEL.
4050 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4051 or a straight list of headers."
4052 (gnus-message 7 "Generating summary...")
4054 (setq gnus-newsgroup-threads threads)
4057 (let ((gnus-tmp-level 0)
4058 (default-score (or gnus-summary-default-score 0))
4059 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4060 thread number subject stack state gnus-tmp-gathered beg-match
4061 new-roots gnus-tmp-new-adopts thread-end
4062 gnus-tmp-header gnus-tmp-unread
4063 gnus-tmp-replied gnus-tmp-subject-or-nil
4064 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4065 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4066 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
4068 (setq gnus-tmp-prev-subject nil)
4070 (if (vectorp (car threads))
4071 ;; If this is a straight (sic) list of headers, then a
4072 ;; threaded summary display isn't required, so we just create
4073 ;; an unthreaded one.
4074 (gnus-summary-prepare-unthreaded threads)
4076 ;; Do the threaded display.
4078 (while (or threads stack gnus-tmp-new-adopts new-roots)
4080 (if (and (= gnus-tmp-level 0)
4083 (not gnus-tmp-false-parent)
4084 (or gnus-tmp-new-adopts new-roots))
4085 (if gnus-tmp-new-adopts
4086 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4087 thread (list (car gnus-tmp-new-adopts))
4088 gnus-tmp-header (caar thread)
4089 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4091 (setq thread (list (car new-roots))
4092 gnus-tmp-header (caar thread)
4093 new-roots (cdr new-roots))))
4096 ;; If there are some threads, we do them before the
4097 ;; threads on the stack.
4098 (setq thread threads
4099 gnus-tmp-header (caar thread))
4100 ;; There were no current threads, so we pop something off
4102 (setq state (car stack)
4103 gnus-tmp-level (car state)
4106 gnus-tmp-header (caar thread))))
4108 (setq gnus-tmp-false-parent nil)
4109 (setq gnus-tmp-root-expunged nil)
4110 (setq thread-end nil)
4112 (if (stringp gnus-tmp-header)
4113 ;; The header is a dummy root.
4115 ((eq gnus-summary-make-false-root 'adopt)
4116 ;; We let the first article adopt the rest.
4117 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4119 (setq gnus-tmp-gathered
4121 (lambda (h) (mail-header-number (car h)))
4124 (setq thread (cons (list (caar thread)
4127 (setq gnus-tmp-level -1
4128 gnus-tmp-false-parent t))
4129 ((eq gnus-summary-make-false-root 'empty)
4130 ;; We print adopted articles with empty subject fields.
4131 (setq gnus-tmp-gathered
4133 (lambda (h) (mail-header-number (car h)))
4136 (setq gnus-tmp-level -1))
4137 ((eq gnus-summary-make-false-root 'dummy)
4138 ;; We remember that we probably want to output a dummy
4140 (setq gnus-tmp-dummy-line gnus-tmp-header)
4141 (setq gnus-tmp-prev-subject gnus-tmp-header))
4143 ;; We do not make a root for the gathered
4144 ;; sub-threads at all.
4145 (setq gnus-tmp-level -1)))
4147 (setq number (mail-header-number gnus-tmp-header)
4148 subject (mail-header-subject gnus-tmp-header))
4151 ;; If the thread has changed subject, we might want to make
4152 ;; this subthread into a root.
4153 ((and (null gnus-thread-ignore-subject)
4154 (not (zerop gnus-tmp-level))
4155 gnus-tmp-prev-subject
4157 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4158 (setq new-roots (nconc new-roots (list (car thread)))
4160 gnus-tmp-header nil))
4161 ;; If the article lies outside the current limit,
4162 ;; then we do not display it.
4163 ((not (memq number gnus-newsgroup-limit))
4164 (setq gnus-tmp-gathered
4166 (lambda (h) (mail-header-number (car h)))
4169 (setq gnus-tmp-new-adopts (if (cdar thread)
4170 (append gnus-tmp-new-adopts
4172 gnus-tmp-new-adopts)
4174 gnus-tmp-header nil)
4175 (when (zerop gnus-tmp-level)
4176 (setq gnus-tmp-root-expunged t)))
4177 ;; Perhaps this article is to be marked as read?
4178 ((and gnus-summary-mark-below
4179 (< (or (cdr (assq number gnus-newsgroup-scored))
4181 gnus-summary-mark-below)
4182 ;; Don't touch sparse articles.
4183 (not (gnus-summary-article-sparse-p number))
4184 (not (gnus-summary-article-ancient-p number)))
4185 (setq gnus-newsgroup-unreads
4186 (delq number gnus-newsgroup-unreads))
4187 (if gnus-newsgroup-auto-expire
4188 (push number gnus-newsgroup-expirable)
4189 (push (cons number gnus-low-score-mark)
4190 gnus-newsgroup-reads))))
4192 (when gnus-tmp-header
4193 ;; We may have an old dummy line to output before this
4195 (when (and gnus-tmp-dummy-line
4198 (mail-header-subject gnus-tmp-header)))
4199 (gnus-summary-insert-dummy-line
4200 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4201 (setq gnus-tmp-dummy-line nil))
4203 ;; Compute the mark.
4204 (setq gnus-tmp-unread (gnus-article-mark number))
4206 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4207 gnus-tmp-header gnus-tmp-level)
4208 gnus-newsgroup-data)
4210 ;; Actually insert the line.
4212 gnus-tmp-subject-or-nil
4214 ((and gnus-thread-ignore-subject
4215 gnus-tmp-prev-subject
4216 (not (inline (gnus-subject-equal
4217 gnus-tmp-prev-subject subject))))
4219 ((zerop gnus-tmp-level)
4220 (if (and (eq gnus-summary-make-false-root 'empty)
4221 (memq number gnus-tmp-gathered)
4222 gnus-tmp-prev-subject
4223 (inline (gnus-subject-equal
4224 gnus-tmp-prev-subject subject)))
4225 gnus-summary-same-subject
4227 (t gnus-summary-same-subject)))
4228 (if (and (eq gnus-summary-make-false-root 'adopt)
4229 (= gnus-tmp-level 1)
4230 (memq number gnus-tmp-gathered))
4231 (setq gnus-tmp-opening-bracket ?\<
4232 gnus-tmp-closing-bracket ?\>)
4233 (setq gnus-tmp-opening-bracket ?\[
4234 gnus-tmp-closing-bracket ?\]))
4236 gnus-tmp-indentation
4237 (aref gnus-thread-indent-array gnus-tmp-level)
4238 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4239 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4240 gnus-summary-default-score 0)
4242 (if (or (null gnus-summary-default-score)
4243 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4244 gnus-summary-zcore-fuzz))
4246 (if (< gnus-tmp-score gnus-summary-default-score)
4247 gnus-score-below-mark gnus-score-over-mark))
4249 (cond ((memq number gnus-newsgroup-processable)
4251 ((memq number gnus-newsgroup-cached)
4253 ((memq number gnus-newsgroup-replied)
4255 ((memq number gnus-newsgroup-forwarded)
4256 gnus-forwarded-mark)
4257 ((memq number gnus-newsgroup-saved)
4260 gnus-tmp-from (mail-header-from gnus-tmp-header)
4263 ((string-match "<[^>]+> *$" gnus-tmp-from)
4264 (setq beg-match (match-beginning 0))
4265 (or (and (string-match "^\".+\"" gnus-tmp-from)
4266 (substring gnus-tmp-from 1 (1- (match-end 0))))
4267 (substring gnus-tmp-from 0 beg-match)))
4268 ((string-match "(.+)" gnus-tmp-from)
4269 (substring gnus-tmp-from
4270 (1+ (match-beginning 0)) (1- (match-end 0))))
4272 (when (string= gnus-tmp-name "")
4273 (setq gnus-tmp-name gnus-tmp-from))
4274 (unless (numberp gnus-tmp-lines)
4275 (setq gnus-tmp-lines -1))
4276 (when (= gnus-tmp-lines -1)
4277 (setq gnus-tmp-lines "?"))
4278 (gnus-put-text-property
4280 (progn (eval gnus-summary-line-format-spec) (point))
4281 'gnus-number number)
4284 (gnus-run-hooks 'gnus-summary-update-hook)
4287 (setq gnus-tmp-prev-subject subject)))
4289 (when (nth 1 thread)
4290 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4291 (incf gnus-tmp-level)
4292 (setq threads (if thread-end nil (cdar thread)))
4294 (setq gnus-tmp-level 0)))))
4295 (gnus-message 7 "Generating summary...done"))
4297 (defun gnus-summary-prepare-unthreaded (headers)
4298 "Generate an unthreaded summary buffer based on HEADERS."
4299 (let (header number mark)
4304 ;; We may have to root out some bad articles...
4305 (when (memq (setq number (mail-header-number
4306 (setq header (pop headers))))
4307 gnus-newsgroup-limit)
4308 ;; Mark article as read when it has a low score.
4309 (when (and gnus-summary-mark-below
4310 (< (or (cdr (assq number gnus-newsgroup-scored))
4311 gnus-summary-default-score 0)
4312 gnus-summary-mark-below)
4313 (not (gnus-summary-article-ancient-p number)))
4314 (setq gnus-newsgroup-unreads
4315 (delq number gnus-newsgroup-unreads))
4316 (if gnus-newsgroup-auto-expire
4317 (push number gnus-newsgroup-expirable)
4318 (push (cons number gnus-low-score-mark)
4319 gnus-newsgroup-reads)))
4321 (setq mark (gnus-article-mark number))
4322 (push (gnus-data-make number mark (1+ (point)) header 0)
4323 gnus-newsgroup-data)
4324 (gnus-summary-insert-line
4326 mark (memq number gnus-newsgroup-replied)
4327 (memq number gnus-newsgroup-expirable)
4328 (mail-header-subject header) nil
4329 (cdr (assq number gnus-newsgroup-scored))
4330 (memq number gnus-newsgroup-processable))))))
4332 (defun gnus-summary-remove-list-identifiers ()
4333 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4334 (let ((regexp (if (consp gnus-list-identifiers)
4335 (mapconcat 'identity gnus-list-identifiers " *\\|")
4336 gnus-list-identifiers))
4339 (dolist (header gnus-newsgroup-headers)
4340 (setq subject (mail-header-subject header)
4342 (while (string-match
4343 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4346 (concat (substring subject 0 (match-beginning 2))
4347 (substring subject (match-end 0)))
4351 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4353 (concat (substring subject 0 (match-beginning 1))
4354 (substring subject (match-end 1)))))
4356 (mail-header-set-subject header subject))))))
4358 (defun gnus-fetch-headers (articles)
4359 "Fetch headers of ARTICLES."
4360 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4361 (gnus-message 5 "Fetching headers for %s..." name)
4364 (setq gnus-headers-retrieved-by
4365 (gnus-retrieve-headers
4366 articles gnus-newsgroup-name
4367 ;; We might want to fetch old headers, but
4368 ;; not if there is only 1 article.
4370 (not (eq gnus-fetch-old-headers 'some))
4371 (not (numberp gnus-fetch-old-headers)))
4372 (> (length articles) 1))
4373 gnus-fetch-old-headers))))
4374 (gnus-get-newsgroup-headers-xover
4375 articles nil nil gnus-newsgroup-name t)
4376 (gnus-get-newsgroup-headers))
4377 (gnus-message 5 "Fetching headers for %s...done" name))))
4379 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4380 "Select newsgroup GROUP.
4381 If READ-ALL is non-nil, all articles in the group are selected.
4382 If SELECT-ARTICLES, only select those articles from GROUP."
4383 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4384 ;;!!! Dirty hack; should be removed.
4385 (gnus-summary-ignore-duplicates
4386 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4388 gnus-summary-ignore-duplicates))
4389 (info (nth 2 entry))
4390 articles fetched-articles cached)
4392 (unless (gnus-check-server
4393 (setq gnus-current-select-method
4394 (gnus-find-method-for-group group)))
4395 (error "Couldn't open server"))
4397 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4398 (gnus-activate-group group) ; Or we can activate it...
4399 (progn ; Or we bug out.
4400 (when (equal major-mode 'gnus-summary-mode)
4401 (kill-buffer (current-buffer)))
4402 (error "Couldn't activate group %s: %s"
4403 group (gnus-status-message group))))
4405 (unless (gnus-request-group group t)
4406 (when (equal major-mode 'gnus-summary-mode)
4407 (kill-buffer (current-buffer)))
4408 (error "Couldn't request group %s: %s"
4409 group (gnus-status-message group)))
4411 (setq gnus-newsgroup-name group)
4412 (setq gnus-newsgroup-unselected nil)
4413 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4414 (gnus-summary-setup-default-charset)
4416 ;; Adjust and set lists of article marks.
4418 (gnus-adjust-marked-articles info))
4420 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4421 (when (gnus-virtual-group-p group)
4422 (setq cached gnus-newsgroup-cached))
4424 (setq gnus-newsgroup-unreads
4425 (gnus-set-difference
4426 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4427 gnus-newsgroup-dormant))
4429 (setq gnus-newsgroup-processable nil)
4431 (gnus-update-read-articles group gnus-newsgroup-unreads)
4433 (if (setq articles select-articles)
4434 (setq gnus-newsgroup-unselected
4435 (gnus-sorted-intersection
4436 gnus-newsgroup-unreads
4437 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4438 (setq articles (gnus-articles-to-read group read-all)))
4442 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4444 ((eq articles 0) nil)
4446 ;; Init the dependencies hash table.
4447 (setq gnus-newsgroup-dependencies
4448 (gnus-make-hashtable (length articles)))
4449 (gnus-set-global-variables)
4450 ;; Retrieve the headers and read them in.
4451 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4453 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4455 (setq gnus-newsgroup-cached cached))
4457 ;; Suppress duplicates?
4458 (when gnus-suppress-duplicates
4459 (gnus-dup-suppress-articles))
4461 ;; Set the initial limit.
4462 (setq gnus-newsgroup-limit (copy-sequence articles))
4463 ;; Remove canceled articles from the list of unread articles.
4464 (setq gnus-newsgroup-unreads
4465 (gnus-set-sorted-intersection
4466 gnus-newsgroup-unreads
4467 (setq fetched-articles
4468 (mapcar (lambda (headers) (mail-header-number headers))
4469 gnus-newsgroup-headers))))
4470 ;; Removed marked articles that do not exist.
4471 (gnus-update-missing-marks
4472 (gnus-sorted-complement fetched-articles articles))
4473 ;; We might want to build some more threads first.
4474 (when (and gnus-fetch-old-headers
4475 (eq gnus-headers-retrieved-by 'nov))
4476 (if (eq gnus-fetch-old-headers 'invisible)
4477 (gnus-build-all-threads)
4478 (gnus-build-old-threads)))
4479 ;; Let the Gnus agent mark articles as read.
4481 (gnus-agent-get-undownloaded-list))
4482 ;; Remove list identifiers from subject
4483 (when gnus-list-identifiers
4484 (gnus-summary-remove-list-identifiers))
4485 ;; Check whether auto-expire is to be done in this group.
4486 (setq gnus-newsgroup-auto-expire
4487 (gnus-group-auto-expirable-p group))
4488 ;; Set up the article buffer now, if necessary.
4489 (unless gnus-single-article-buffer
4490 (gnus-article-setup-buffer))
4491 ;; First and last article in this newsgroup.
4492 (when gnus-newsgroup-headers
4493 (setq gnus-newsgroup-begin
4494 (mail-header-number (car gnus-newsgroup-headers))
4497 (gnus-last-element gnus-newsgroup-headers))))
4498 ;; GROUP is successfully selected.
4499 (or gnus-newsgroup-headers t)))))
4501 (defun gnus-articles-to-read (group &optional read-all)
4502 "Find out what articles the user wants to read."
4504 ;; Select all articles if `read-all' is non-nil, or if there
4505 ;; are no unread articles.
4507 (and (zerop (length gnus-newsgroup-marked))
4508 (zerop (length gnus-newsgroup-unreads)))
4509 (eq (gnus-group-find-parameter group 'display)
4512 (gnus-uncompress-range (gnus-active group))
4513 (gnus-cache-articles-in-group group))
4514 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4515 (copy-sequence gnus-newsgroup-unreads))
4517 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4518 (scored (length scored-list))
4519 (number (length articles))
4520 (marked (+ (length gnus-newsgroup-marked)
4521 (length gnus-newsgroup-dormant)))
4529 ((and (or (<= scored marked) (= scored number))
4530 (numberp gnus-large-newsgroup)
4531 (> number gnus-large-newsgroup))
4535 "How many articles from %s (default %d): "
4536 (gnus-limit-string gnus-newsgroup-name 35)
4538 (if (string-match "^[ \t]*$" input) number input)))
4539 ((and (> scored marked) (< scored number)
4540 (> (- scored number) 20))
4543 (format "%s %s (%d scored, %d total): "
4544 "How many articles from"
4545 group scored number))))
4546 (if (string-match "^[ \t]*$" input)
4550 (message "Quit getting the articles to read")
4552 (setq select (if (stringp select) (string-to-number select) select))
4553 (if (or (null select) (zerop select))
4555 (if (and (not (zerop scored)) (<= (abs select) scored))
4557 (setq articles (sort scored-list '<))
4558 (setq number (length articles)))
4559 (setq articles (copy-sequence articles)))
4561 (when (< (abs select) number)
4563 ;; Select the N oldest articles.
4564 (setcdr (nthcdr (1- (abs select)) articles) nil)
4565 ;; Select the N most recent articles.
4566 (setq articles (nthcdr (- number select) articles))))
4567 (setq gnus-newsgroup-unselected
4568 (gnus-sorted-intersection
4569 gnus-newsgroup-unreads
4570 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4571 (when gnus-alter-articles-to-read-function
4572 (setq gnus-newsgroup-unreads
4574 (funcall gnus-alter-articles-to-read-function
4575 gnus-newsgroup-name gnus-newsgroup-unreads)
4579 (defun gnus-killed-articles (killed articles)
4582 (when (inline (gnus-member-of-range (car articles) killed))
4583 (push (car articles) out))
4584 (setq articles (cdr articles)))
4587 (defun gnus-uncompress-marks (marks)
4588 "Uncompress the mark ranges in MARKS."
4589 (let ((uncompressed '(score bookmark))
4592 (if (memq (caar marks) uncompressed)
4593 (push (car marks) out)
4594 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4595 (setq marks (cdr marks)))
4598 (defun gnus-adjust-marked-articles (info)
4599 "Set all article lists and remove all marks that are no longer valid."
4600 (let* ((marked-lists (gnus-info-marks info))
4601 (active (gnus-active (gnus-info-group info)))
4604 (types gnus-article-mark-lists)
4605 (uncompressed '(score bookmark killed))
4606 marks var articles article mark)
4609 (setq marks (pop marked-lists))
4610 (set (setq var (intern (format "gnus-newsgroup-%s"
4611 (car (rassq (setq mark (car marks))
4613 (if (memq (car marks) uncompressed) (cdr marks)
4614 (gnus-uncompress-range (cdr marks))))
4616 (setq articles (symbol-value var))
4618 ;; All articles have to be subsets of the active articles.
4620 ;; Adjust "simple" lists.
4621 ((memq mark '(tick dormant expire reply save))
4623 (when (or (< (setq article (pop articles)) min) (> article max))
4624 (set var (delq article (symbol-value var))))))
4626 ((memq mark uncompressed)
4627 (when (not (listp (cdr (symbol-value var))))
4628 (set var (list (symbol-value var))))
4629 (when (not (listp (cdr articles)))
4630 (setq articles (list articles)))
4632 (when (or (not (consp (setq article (pop articles))))
4633 (< (car article) min)
4634 (> (car article) max))
4635 (set var (delq article (symbol-value var))))))))))
4637 (defun gnus-update-missing-marks (missing)
4638 "Go through the list of MISSING articles and remove them from the mark lists."
4640 (let ((types gnus-article-mark-lists)
4642 ;; Go through all types.
4644 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4645 (when (symbol-value var)
4646 ;; This list has articles. So we delete all missing articles
4650 (set var (delq (pop m) (symbol-value var)))))))))
4652 (defun gnus-update-marks ()
4653 "Enter the various lists of marked articles into the newsgroup info list."
4654 (let ((types gnus-article-mark-lists)
4655 (info (gnus-get-info gnus-newsgroup-name))
4656 (uncompressed '(score bookmark killed))
4657 type list newmarked symbol delta-marks)
4659 ;; Add all marks lists to the list of marks lists.
4660 (while (setq type (pop types))
4661 (setq list (symbol-value
4663 (intern (format "gnus-newsgroup-%s"
4667 ;; Get rid of the entries of the articles that have the
4669 (when (and (eq (cdr type) 'score)
4673 (prev (cons nil list))
4676 (if (or (not (consp (car arts)))
4677 (= (cdar arts) gnus-summary-default-score))
4678 (setcdr prev (cdr arts))
4680 (setq arts (cdr arts)))
4681 (setq list (cdr all)))))
4683 (unless (memq (cdr type) uncompressed)
4684 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4686 (when (gnus-check-backend-function
4687 'request-set-mark gnus-newsgroup-name)
4688 ;; propagate flags to server, with the following exceptions:
4689 ;; uncompressed:s are not proper flags (they are cons cells)
4690 ;; cache is a internal gnus flag
4691 ;; download are local to one gnus installation (well)
4692 ;; unsend are for nndraft groups only
4693 ;; xxx: generality of this? this suits nnimap anyway
4694 (unless (memq (cdr type) (append '(cache download unsend)
4696 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4697 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4698 (add (gnus-remove-from-range
4699 (gnus-copy-sequence list) old)))
4701 (push (list add 'add (list (cdr type))) delta-marks))
4703 (push (list del 'del (list (cdr type))) delta-marks)))))
4706 (push (cons (cdr type) list) newmarked)))
4709 (unless (gnus-check-group gnus-newsgroup-name)
4710 (error "Can't open server for %s" gnus-newsgroup-name))
4711 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4713 ;; Enter these new marks into the info of the group.
4715 (setcar (nthcdr 3 info) newmarked)
4716 ;; Add the marks lists to the end of the info.
4718 (setcdr (nthcdr 2 info) (list newmarked))))
4720 ;; Cut off the end of the info if there's nothing else there.
4724 (when (nthcdr (decf i) info)
4725 (setcdr (nthcdr i info) nil)))))))
4727 (defun gnus-set-mode-line (where)
4728 "Set the mode line of the article or summary buffers.
4729 If WHERE is `summary', the summary mode line format will be used."
4730 ;; Is this mode line one we keep updated?
4731 (when (and (memq where gnus-updated-mode-lines)
4733 (intern (format "gnus-%s-mode-line-format-spec" where))))
4736 ;; We evaluate this in the summary buffer since these
4737 ;; variables are buffer-local to that buffer.
4738 (set-buffer gnus-summary-buffer)
4739 ;; We bind all these variables that are used in the `eval' form
4741 (let* ((mformat (symbol-value
4743 (format "gnus-%s-mode-line-format-spec" where))))
4744 (gnus-tmp-group-name (gnus-group-decoded-name
4745 gnus-newsgroup-name))
4746 (gnus-tmp-article-number (or gnus-current-article 0))
4747 (gnus-tmp-unread gnus-newsgroup-unreads)
4748 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4749 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4750 (gnus-tmp-unread-and-unselected
4751 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4752 (zerop gnus-tmp-unselected))
4754 ((zerop gnus-tmp-unselected)
4755 (format "{%d more}" gnus-tmp-unread-and-unticked))
4756 (t (format "{%d(+%d) more}"
4757 gnus-tmp-unread-and-unticked
4758 gnus-tmp-unselected))))
4760 (if (and gnus-current-headers
4761 (vectorp gnus-current-headers))
4762 (gnus-mode-string-quote
4763 (mail-header-subject gnus-current-headers))
4765 bufname-length max-len
4766 gnus-tmp-header);; passed as argument to any user-format-funcs
4767 (setq mode-string (eval mformat))
4768 (setq bufname-length (if (string-match "%b" mode-string)
4771 (if (eq where 'summary)
4773 (get-buffer gnus-article-buffer))))
4776 (setq max-len (max 4 (if gnus-mode-non-string-length
4778 gnus-mode-non-string-length
4780 (length mode-string))))
4781 ;; We might have to chop a bit of the string off...
4782 (when (> (length mode-string) max-len)
4784 (concat (truncate-string-to-width mode-string (- max-len 3))
4786 ;; Pad the mode string a bit.
4787 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4788 ;; Update the mode line.
4789 (setq mode-line-buffer-identification
4790 (gnus-mode-line-buffer-identification (list mode-string)))
4791 (set-buffer-modified-p t))))
4793 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4794 "Go through the HEADERS list and add all Xrefs to a hash table.
4795 The resulting hash table is returned, or nil if no Xrefs were found."
4796 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4797 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4798 (xref-hashtb (gnus-make-hashtable))
4799 start group entry number xrefs header)
4801 (setq header (pop headers))
4802 (when (and (setq xrefs (mail-header-xref header))
4803 (not (memq (setq number (mail-header-number header))
4806 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4807 (setq start (match-end 0))
4808 (setq group (if prefix
4809 (concat prefix (substring xrefs (match-beginning 1)
4811 (substring xrefs (match-beginning 1) (match-end 1))))
4813 (string-to-int (substring xrefs (match-beginning 2)
4815 (if (setq entry (gnus-gethash group xref-hashtb))
4816 (setcdr entry (cons number (cdr entry)))
4817 (gnus-sethash group (cons number nil) xref-hashtb)))))
4818 (and start xref-hashtb)))
4820 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4821 "Look through all the headers and mark the Xrefs as read."
4822 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4823 name entry info xref-hashtb idlist method nth4)
4825 (set-buffer gnus-group-buffer)
4826 (when (setq xref-hashtb
4827 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4830 (unless (string= from-newsgroup (setq name (symbol-name group)))
4831 (setq idlist (symbol-value group))
4832 ;; Dead groups are not updated.
4834 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4836 (when (stringp (setq nth4 (gnus-info-method info)))
4837 (setq nth4 (gnus-server-to-method nth4))))
4838 ;; Only do the xrefs if the group has the same
4839 ;; select method as the group we have just read.
4840 (or (gnus-methods-equal-p
4841 nth4 (gnus-find-method-for-group from-newsgroup))
4843 (equal nth4 (setq method (gnus-find-method-for-group
4845 (and (equal (car nth4) (car method))
4846 (equal (nth 1 nth4) (nth 1 method))))
4847 gnus-use-cross-reference
4848 (or (not (eq gnus-use-cross-reference t))
4850 ;; Only do cross-references on subscribed
4851 ;; groups, if that is what is wanted.
4852 (<= (gnus-info-level info) gnus-level-subscribed))
4853 (gnus-group-make-articles-read name idlist))))
4856 (defun gnus-compute-read-articles (group articles)
4857 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4858 (info (nth 2 entry))
4859 (active (gnus-active group))
4862 ;; First peel off all invalid article numbers.
4864 (let ((ids articles)
4866 (while (setq id (pop ids))
4867 (when (and first (> id (cdr active)))
4868 ;; We'll end up in this situation in one particular
4869 ;; obscure situation. If you re-scan a group and get
4870 ;; a new article that is cross-posted to a different
4871 ;; group that has not been re-scanned, you might get
4872 ;; crossposted article that has a higher number than
4873 ;; Gnus believes possible. So we re-activate this
4874 ;; group as well. This might mean doing the
4875 ;; crossposting thingy will *increase* the number
4876 ;; of articles in some groups. Tsk, tsk.
4877 (setq active (or (gnus-activate-group group) active)))
4878 (when (or (> id (cdr active))
4879 (< id (car active)))
4880 (setq articles (delq id articles))))))
4881 ;; If the read list is nil, we init it.
4883 (null (gnus-info-read info))
4885 (setq ninfo (cons 1 (1- (car active))))
4886 (setq ninfo (gnus-info-read info)))
4887 ;; Then we add the read articles to the range.
4889 ninfo (setq articles (sort articles '<))))))
4891 (defun gnus-group-make-articles-read (group articles)
4892 "Update the info of GROUP to say that ARTICLES are read."
4894 (entry (gnus-gethash group gnus-newsrc-hashtb))
4895 (info (nth 2 entry))
4896 (active (gnus-active group))
4899 (setq range (gnus-compute-read-articles group articles))
4901 (set-buffer gnus-group-buffer)
4904 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4905 (gnus-info-set-read ',info ',(gnus-info-read info))
4906 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4907 (gnus-group-update-group ,group t))))
4908 ;; Add the read articles to the range.
4909 (gnus-info-set-read info range)
4910 ;; Then we have to re-compute how many unread
4911 ;; articles there are in this group.
4915 (setq num (- (1+ (cdr active)) (car active))))
4916 ((not (listp (cdr range)))
4917 (setq num (- (cdr active) (- (1+ (cdr range))
4921 (if (numberp (car range))
4923 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4924 (setq range (cdr range)))
4925 (setq num (- (cdr active) num))))
4926 ;; Update the number of unread articles.
4928 ;; Update the group buffer.
4929 (gnus-group-update-group group t)))))
4931 (defvar gnus-newsgroup-none-id 0)
4933 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4934 (let ((cur nntp-server-buffer)
4937 (save-excursion (set-buffer gnus-summary-buffer)
4938 gnus-newsgroup-dependencies)))
4940 (mail-parse-charset gnus-newsgroup-charset)
4941 (mail-parse-ignored-charsets
4942 (save-excursion (condition-case nil
4943 (set-buffer gnus-summary-buffer)
4945 gnus-newsgroup-ignored-charsets)))
4947 (set-buffer nntp-server-buffer)
4948 ;; Translate all TAB characters into SPACE characters.
4949 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4950 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4951 (gnus-run-hooks 'gnus-parse-headers-hook)
4952 (let ((case-fold-search t)
4953 in-reply-to header p lines chars)
4954 (goto-char (point-min))
4955 ;; Search to the beginning of the next header. Error messages
4956 ;; do not begin with 2 or 3.
4957 (while (re-search-forward "^[23][0-9]+ " nil t)
4960 ;; This implementation of this function, with nine
4961 ;; search-forwards instead of the one re-search-forward and
4962 ;; a case (which basically was the old function) is actually
4963 ;; about twice as fast, even though it looks messier. You
4964 ;; can't have everything, I guess. Speed and elegance
4965 ;; doesn't always go hand in hand.
4974 (narrow-to-region (point)
4975 (or (and (search-forward "\n.\n" nil t)
4981 (if (search-forward "\nsubject: " nil t)
4982 (funcall gnus-decode-encoded-word-function
4983 (nnheader-header-value))
4988 (if (or (search-forward "\nfrom: " nil t)
4989 (search-forward "\nfrom:" nil t))
4990 (funcall gnus-decode-encoded-word-function
4991 (nnheader-header-value))
4996 (if (search-forward "\ndate: " nil t)
4997 (nnheader-header-value) ""))
5001 (setq id (if (re-search-forward
5002 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5003 ;; We do it this way to make sure the Message-ID
5004 ;; is (somewhat) syntactically valid.
5005 (buffer-substring (match-beginning 1)
5007 ;; If there was no message-id, we just fake one
5008 ;; to make subsequent routines simpler.
5009 (nnheader-generate-fake-message-id))))
5013 (if (search-forward "\nreferences: " nil t)
5017 (nnheader-header-value)
5022 (search-backward ">" end t)
5025 (search-backward "<" end t)
5027 ;; Get the references from the in-reply-to header if there
5028 ;; were no references and the in-reply-to header looks
5030 (if (and (search-forward "\nin-reply-to: " nil t)
5031 (setq in-reply-to (nnheader-header-value))
5032 (string-match "<[^>]+>" in-reply-to))
5034 (setq ref (substring in-reply-to (match-beginning 0)
5036 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5037 (setq ref2 (substring in-reply-to (match-beginning 0)
5039 (when (> (length ref2) (length ref))
5046 (if (search-forward "\nchars: " nil t)
5047 (if (numberp (setq chars (ignore-errors (read cur))))
5053 (if (search-forward "\nlines: " nil t)
5054 (if (numberp (setq lines (ignore-errors (read cur))))
5060 (and (search-forward "\nxref: " nil t)
5061 (nnheader-header-value)))
5063 (when gnus-extra-headers
5064 (let ((extra gnus-extra-headers)
5068 (when (search-forward
5069 (concat "\n" (symbol-name (car extra)) ": ") nil t)
5070 (push (cons (car extra) (nnheader-header-value))
5074 (when (equal id ref)
5077 (when gnus-alter-header-function
5078 (funcall gnus-alter-header-function header)
5079 (setq id (mail-header-id header)
5080 ref (gnus-parent-id (mail-header-references header))))
5083 (gnus-dependencies-add-header
5084 header dependencies force-new))
5085 (push header headers))
5086 (goto-char (point-max))
5088 (nreverse headers)))))
5090 ;; Goes through the xover lines and returns a list of vectors
5091 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5092 force-new dependencies
5093 group also-fetch-heads)
5094 "Parse the news overview data in the server buffer.
5095 Return a list of headers that match SEQUENCE (see
5096 `nntp-retrieve-headers')."
5097 ;; Get the Xref when the users reads the articles since most/some
5098 ;; NNTP servers do not include Xrefs when using XOVER.
5099 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5100 (let ((mail-parse-charset gnus-newsgroup-charset)
5101 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5102 (cur nntp-server-buffer)
5103 (dependencies (or dependencies gnus-newsgroup-dependencies))
5105 ((eq gnus-read-all-available-headers t)
5107 ((stringp gnus-read-all-available-headers)
5108 (string-match gnus-read-all-available-headers group))
5111 number headers header)
5113 (set-buffer nntp-server-buffer)
5114 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5115 ;; Allow the user to mangle the headers before parsing them.
5116 (gnus-run-hooks 'gnus-parse-headers-hook)
5117 (goto-char (point-min))
5120 (while (and (or sequence allp)
5122 (setq number (read cur))
5124 (while (and sequence
5125 (< (car sequence) number))
5126 (setq sequence (cdr sequence))))
5129 (eq number (car sequence))))
5131 (setq sequence (cdr sequence))
5132 (setq header (inline
5133 (gnus-nov-parse-line
5134 number dependencies force-new)))))
5135 (push header headers))
5138 (gnus-error 4 "Strange nov line (%d)"
5139 (count-lines (point-min) (point)))))
5141 ;; A common bug in inn is that if you have posted an article and
5142 ;; then retrieves the active file, it will answer correctly --
5143 ;; the new article is included. However, a NOV entry for the
5144 ;; article may not have been generated yet, so this may fail.
5145 ;; We work around this problem by retrieving the last few
5146 ;; headers using HEAD.
5147 (if (or (not also-fetch-heads)
5149 ;; We (probably) got all the headers.
5151 (let ((gnus-nov-is-evil t))
5154 (when (gnus-retrieve-headers sequence group)
5155 (gnus-get-newsgroup-headers))))))))
5157 (defun gnus-article-get-xrefs ()
5158 "Fill in the Xref value in `gnus-current-headers', if necessary.
5159 This is meant to be called in `gnus-article-internal-prepare-hook'."
5160 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5161 gnus-current-headers)))
5162 (or (not gnus-use-cross-reference)
5164 (and (mail-header-xref headers)
5165 (not (string= (mail-header-xref headers) "")))
5166 (let ((case-fold-search t)
5169 (nnheader-narrow-to-headers)
5170 (goto-char (point-min))
5171 (when (or (and (not (eobp))
5172 (eq (downcase (char-after)) ?x)
5173 (looking-at "Xref:"))
5174 (search-forward "\nXref:" nil t))
5175 (goto-char (1+ (match-end 0)))
5176 (setq xref (buffer-substring (point)
5177 (progn (end-of-line) (point))))
5178 (mail-header-set-xref headers xref)))))))
5180 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5181 "Find article ID and insert the summary line for that article.
5182 OLD-HEADER can either be a header or a line number to insert
5183 the subject line on."
5184 (let* ((line (and (numberp old-header) old-header))
5185 (old-header (and (vectorp old-header) old-header))
5186 (header (cond ((and old-header use-old-header)
5189 (gnus-number-to-header id))
5190 (gnus-number-to-header id))
5192 (gnus-read-header id))))
5193 (number (and (numberp id) id))
5196 ;; Rebuild the thread that this article is part of and go to the
5197 ;; article we have fetched.
5198 (when (and (not gnus-show-threads)
5201 (setq d (gnus-data-find (mail-header-number old-header))))
5202 (goto-char (gnus-data-pos d))
5205 (- (gnus-point-at-bol)
5207 (1+ (gnus-point-at-eol))
5208 (gnus-delete-line))))))
5210 (mail-header-set-number header (mail-header-number old-header)))
5211 (setq gnus-newsgroup-sparse
5212 (delq (setq number (mail-header-number header))
5213 gnus-newsgroup-sparse))
5214 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5215 (push number gnus-newsgroup-limit)
5216 (gnus-rebuild-thread (mail-header-id header) line)
5217 (gnus-summary-goto-subject number nil t))
5218 (when (and (numberp number)
5220 ;; We have to update the boundaries even if we can't fetch the
5221 ;; article if ID is a number -- so that the next `P' or `N'
5222 ;; command will fetch the previous (or next) article even
5223 ;; if the one we tried to fetch this time has been canceled.
5224 (when (> number gnus-newsgroup-end)
5225 (setq gnus-newsgroup-end number))
5226 (when (< number gnus-newsgroup-begin)
5227 (setq gnus-newsgroup-begin number))
5228 (setq gnus-newsgroup-unselected
5229 (delq number gnus-newsgroup-unselected)))
5230 ;; Report back a success?
5231 (and header (mail-header-number header))))
5233 ;;; Process/prefix in the summary buffer
5235 (defun gnus-summary-work-articles (n)
5236 "Return a list of articles to be worked upon.
5237 The prefix argument, the list of process marked articles, and the
5238 current article will be taken into consideration."
5240 (set-buffer gnus-summary-buffer)
5243 ;; A numerical prefix has been given.
5244 (setq n (prefix-numeric-value n))
5245 (let ((backward (< n 0))
5246 (n (abs (prefix-numeric-value n)))
5251 (push (setq article (gnus-summary-article-number))
5254 (gnus-summary-find-prev nil article)
5255 (gnus-summary-find-next nil article)))
5257 (nreverse articles)))
5258 ((and (gnus-region-active-p) (mark))
5259 (message "region active")
5260 ;; Work on the region between point and mark.
5261 (let ((max (max (point) (mark)))
5264 (goto-char (min (min (point) (mark))))
5267 (push (setq article (gnus-summary-article-number)) articles)
5268 (gnus-summary-find-next nil article)
5270 (nreverse articles))))
5271 (gnus-newsgroup-processable
5272 ;; There are process-marked articles present.
5273 ;; Save current state.
5274 (gnus-summary-save-process-mark)
5276 (reverse gnus-newsgroup-processable))
5278 ;; Just return the current article.
5279 (list (gnus-summary-article-number))))))
5281 (defmacro gnus-summary-iterate (arg &rest forms)
5282 "Iterate over the process/prefixed articles and do FORMS.
5283 ARG is the interactive prefix given to the command. FORMS will be
5284 executed with point over the summary line of the articles."
5285 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5286 `(let ((,articles (gnus-summary-work-articles ,arg)))
5288 (gnus-summary-goto-subject (car ,articles))
5292 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5293 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5295 (defun gnus-summary-save-process-mark ()
5296 "Push the current set of process marked articles on the stack."
5298 (push (copy-sequence gnus-newsgroup-processable)
5299 gnus-newsgroup-process-stack))
5301 (defun gnus-summary-kill-process-mark ()
5302 "Push the current set of process marked articles on the stack and unmark."
5304 (gnus-summary-save-process-mark)
5305 (gnus-summary-unmark-all-processable))
5307 (defun gnus-summary-yank-process-mark ()
5308 "Pop the last process mark state off the stack and restore it."
5310 (unless gnus-newsgroup-process-stack
5311 (error "Empty mark stack"))
5312 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5314 (defun gnus-summary-process-mark-set (set)
5315 "Make SET into the current process marked articles."
5316 (gnus-summary-unmark-all-processable)
5318 (gnus-summary-set-process-mark (pop set))))
5320 ;;; Searching and stuff
5322 (defun gnus-summary-search-group (&optional backward use-level)
5323 "Search for next unread newsgroup.
5324 If optional argument BACKWARD is non-nil, search backward instead."
5326 (set-buffer gnus-group-buffer)
5327 (when (gnus-group-search-forward
5328 backward nil (if use-level (gnus-group-group-level) nil))
5329 (gnus-group-group-name))))
5331 (defun gnus-summary-best-group (&optional exclude-group)
5332 "Find the name of the best unread group.
5333 If EXCLUDE-GROUP, do not go to this group."
5335 (set-buffer gnus-group-buffer)
5337 (gnus-group-best-unread-group exclude-group))))
5339 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5340 (if backward (gnus-summary-find-prev)
5341 (let* ((dummy (gnus-summary-article-intangible-p))
5342 (article (or article (gnus-summary-article-number)))
5343 (arts (gnus-data-find-list article))
5345 (when (and (not dummy)
5346 (or (not gnus-summary-check-current)
5348 (not (gnus-data-unread-p (car arts)))))
5349 (setq arts (cdr arts)))
5354 (when (or (and undownloaded
5355 (eq gnus-undownloaded-mark
5356 (gnus-data-mark (car arts))))
5357 (gnus-data-unread-p (car arts)))
5358 (setq result (car arts)
5360 (setq arts (cdr arts)))
5363 (goto-char (gnus-data-pos result))
5364 (gnus-data-number result)))))
5366 (defun gnus-summary-find-prev (&optional unread article)
5367 (let* ((eobp (eobp))
5368 (article (or article (gnus-summary-article-number)))
5369 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5371 (when (and (not eobp)
5372 (or (not gnus-summary-check-current)
5374 (not (gnus-data-unread-p (car arts)))))
5375 (setq arts (cdr arts)))
5380 (when (gnus-data-unread-p (car arts))
5381 (setq result (car arts)
5383 (setq arts (cdr arts)))
5386 (goto-char (gnus-data-pos result))
5387 (gnus-data-number result))))
5389 (defun gnus-summary-find-subject (subject &optional unread backward article)
5390 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5391 (article (or article (gnus-summary-article-number)))
5392 (articles (gnus-data-list backward))
5393 (arts (gnus-data-find-list article articles))
5395 (when (or (not gnus-summary-check-current)
5397 (not (gnus-data-unread-p (car arts))))
5398 (setq arts (cdr arts)))
5400 (and (or (not unread)
5401 (gnus-data-unread-p (car arts)))
5402 (vectorp (gnus-data-header (car arts)))
5404 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5405 (setq result (car arts)
5407 (setq arts (cdr arts)))
5409 (goto-char (gnus-data-pos result))
5410 (gnus-data-number result))))
5412 (defun gnus-summary-search-forward (&optional unread subject backward)
5413 "Search forward for an article.
5414 If UNREAD, look for unread articles. If SUBJECT, look for
5415 articles with that subject. If BACKWARD, search backward instead."
5416 (cond (subject (gnus-summary-find-subject subject unread backward))
5417 (backward (gnus-summary-find-prev unread))
5418 (t (gnus-summary-find-next unread))))
5420 (defun gnus-recenter (&optional n)
5421 "Center point in window and redisplay frame.
5422 Also do horizontal recentering."
5424 (when (and gnus-auto-center-summary
5425 (not (eq gnus-auto-center-summary 'vertical)))
5426 (gnus-horizontal-recenter))
5429 (defun gnus-summary-recenter ()
5430 "Center point in the summary window.
5431 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5432 displayed, no centering will be performed."
5433 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5434 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5436 (let* ((top (cond ((< (window-height) 4) 0)
5437 ((< (window-height) 7) 1)
5438 (t (if (numberp gnus-auto-center-summary)
5439 gnus-auto-center-summary
5441 (height (1- (window-height)))
5442 (bottom (save-excursion (goto-char (point-max))
5443 (forward-line (- height))
5445 (window (get-buffer-window (current-buffer))))
5446 ;; The user has to want it.
5447 (when gnus-auto-center-summary
5448 (when (get-buffer-window gnus-article-buffer)
5449 ;; Only do recentering when the article buffer is displayed,
5450 ;; Set the window start to either `bottom', which is the biggest
5451 ;; possible valid number, or the second line from the top,
5452 ;; whichever is the least.
5453 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5454 (if (> bottom top-pos)
5455 ;; Keep the second line from the top visible
5456 (set-window-start window top-pos t)
5457 ;; Try to keep the bottom line visible; if it's partially
5458 ;; obscured, either scroll one more line to make it fully
5459 ;; visible, or revert to using TOP-POS.
5461 (goto-char (point-max))
5463 (let ((last-line-start (point)))
5465 (set-window-start window (point) t)
5466 (when (not (pos-visible-in-window-p last-line-start window))
5468 (set-window-start window (min (point) top-pos) t)))))))
5469 ;; Do horizontal recentering while we're at it.
5470 (when (and (get-buffer-window (current-buffer) t)
5471 (not (eq gnus-auto-center-summary 'vertical)))
5472 (let ((selected (selected-window)))
5473 (select-window (get-buffer-window (current-buffer) t))
5474 (gnus-summary-position-point)
5475 (gnus-horizontal-recenter)
5476 (select-window selected))))))
5478 (defun gnus-summary-jump-to-group (newsgroup)
5479 "Move point to NEWSGROUP in group mode buffer."
5480 ;; Keep update point of group mode buffer if visible.
5481 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5482 (save-window-excursion
5483 ;; Take care of tree window mode.
5484 (when (get-buffer-window gnus-group-buffer)
5485 (pop-to-buffer gnus-group-buffer))
5486 (gnus-group-jump-to-group newsgroup))
5488 ;; Take care of tree window mode.
5489 (if (get-buffer-window gnus-group-buffer)
5490 (pop-to-buffer gnus-group-buffer)
5491 (set-buffer gnus-group-buffer))
5492 (gnus-group-jump-to-group newsgroup))))
5494 ;; This function returns a list of article numbers based on the
5495 ;; difference between the ranges of read articles in this group and
5496 ;; the range of active articles.
5497 (defun gnus-list-of-unread-articles (group)
5498 (let* ((read (gnus-info-read (gnus-get-info group)))
5499 (active (or (gnus-active group) (gnus-activate-group group)))
5502 ;; If none are read, then all are unread.
5504 (setq first (car active))
5505 ;; If the range of read articles is a single range, then the
5506 ;; first unread article is the article after the last read
5507 ;; article. Sounds logical, doesn't it?
5508 (if (and (not (listp (cdr read)))
5509 (or (< (car read) (car active))
5510 (progn (setq read (list read))
5512 (setq first (max (car active) (1+ (cdr read))))
5513 ;; `read' is a list of ranges.
5514 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5517 (setq first (car active)))
5520 (while (< first nlast)
5522 (setq first (1+ first))))
5523 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5524 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5525 (setq read (cdr read)))))
5526 ;; And add the last unread articles.
5527 (while (<= first last)
5529 (setq first (1+ first)))
5530 ;; Return the list of unread articles.
5531 (delq 0 (nreverse unread))))
5533 (defun gnus-list-of-read-articles (group)
5534 "Return a list of unread, unticked and non-dormant articles."
5535 (let* ((info (gnus-get-info group))
5536 (marked (gnus-info-marks info))
5537 (active (gnus-active group)))
5539 (gnus-set-difference
5540 (gnus-sorted-complement
5541 (gnus-uncompress-range active)
5542 (gnus-list-of-unread-articles group))
5544 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5545 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5547 ;; Various summary commands
5549 (defun gnus-summary-select-article-buffer ()
5550 "Reconfigure windows to show article buffer."
5552 (if (not (gnus-buffer-live-p gnus-article-buffer))
5553 (error "There is no article buffer for this summary buffer")
5554 (gnus-configure-windows 'article)
5555 (select-window (get-buffer-window gnus-article-buffer))))
5557 (defun gnus-summary-universal-argument (arg)
5558 "Perform any operation on all articles that are process/prefixed."
5560 (let ((articles (gnus-summary-work-articles arg))
5567 (substitute-command-keys
5568 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5570 (gnus-error 1 "Undefined key")
5573 (gnus-summary-goto-subject (setq article (pop articles)))
5574 (let (gnus-newsgroup-processable)
5575 (command-execute func))
5576 (gnus-summary-remove-process-mark article)))))
5577 (gnus-summary-position-point))
5579 (defun gnus-summary-toggle-truncation (&optional arg)
5580 "Toggle truncation of summary lines.
5581 With arg, turn line truncation on iff arg is positive."
5583 (setq truncate-lines
5584 (if (null arg) (not truncate-lines)
5585 (> (prefix-numeric-value arg) 0)))
5588 (defun gnus-summary-reselect-current-group (&optional all rescan)
5589 "Exit and then reselect the current newsgroup.
5590 The prefix argument ALL means to select all articles."
5592 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5593 (error "Ephemeral groups can't be reselected"))
5594 (let ((current-subject (gnus-summary-article-number))
5595 (group gnus-newsgroup-name))
5596 (setq gnus-newsgroup-begin nil)
5598 ;; We have to adjust the point of group mode buffer because
5599 ;; point was moved to the next unread newsgroup by exiting.
5600 (gnus-summary-jump-to-group group)
5603 (gnus-group-get-new-news-this-group 1)))
5604 (gnus-group-read-group all t)
5605 (gnus-summary-goto-subject current-subject nil t)))
5607 (defun gnus-summary-rescan-group (&optional all)
5608 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5610 (gnus-summary-reselect-current-group all t))
5612 (defun gnus-summary-update-info (&optional non-destructive)
5614 (let ((group gnus-newsgroup-name))
5616 (when gnus-newsgroup-kill-headers
5617 (setq gnus-newsgroup-killed
5618 (gnus-compress-sequence
5620 (gnus-set-sorted-intersection
5621 (gnus-uncompress-range gnus-newsgroup-killed)
5622 (setq gnus-newsgroup-unselected
5623 (sort gnus-newsgroup-unselected '<)))
5624 (setq gnus-newsgroup-unreads
5625 (sort gnus-newsgroup-unreads '<)))
5627 (unless (listp (cdr gnus-newsgroup-killed))
5628 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5629 (let ((headers gnus-newsgroup-headers))
5630 ;; Set the new ranges of read articles.
5632 (set-buffer gnus-group-buffer)
5633 (gnus-undo-force-boundary))
5634 (gnus-update-read-articles
5635 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5636 ;; Set the current article marks.
5637 (let ((gnus-newsgroup-scored
5638 (if (and (not gnus-save-score)
5639 (not non-destructive))
5641 gnus-newsgroup-scored)))
5643 (gnus-update-marks)))
5644 ;; Do the cross-ref thing.
5645 (when gnus-use-cross-reference
5646 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5647 ;; Do not switch windows but change the buffer to work.
5648 (set-buffer gnus-group-buffer)
5649 (unless (gnus-ephemeral-group-p group)
5650 (gnus-group-update-group group)))))))
5652 (defun gnus-summary-save-newsrc (&optional force)
5653 "Save the current number of read/marked articles in the dribble buffer.
5654 The dribble buffer will then be saved.
5655 If FORCE (the prefix), also save the .newsrc file(s)."
5657 (gnus-summary-update-info t)
5659 (gnus-save-newsrc-file)
5660 (gnus-dribble-save)))
5662 (defun gnus-summary-exit (&optional temporary)
5663 "Exit reading current newsgroup, and then return to group selection mode.
5664 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5666 (gnus-set-global-variables)
5667 (when (gnus-buffer-live-p gnus-article-buffer)
5669 (set-buffer gnus-article-buffer)
5670 (mm-destroy-parts gnus-article-mime-handles)
5671 ;; Set it to nil for safety reason.
5672 (setq gnus-article-mime-handle-alist nil)
5673 (setq gnus-article-mime-handles nil)))
5674 (gnus-kill-save-kill-buffer)
5675 (gnus-async-halt-prefetch)
5676 (let* ((group gnus-newsgroup-name)
5677 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5680 (buf (current-buffer)))
5682 ;; Do adaptive scoring, and possibly save score files.
5683 (when gnus-newsgroup-adaptive
5684 (gnus-score-adaptive))
5685 (when gnus-use-scoring
5687 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5688 ;; If we have several article buffers, we kill them at exit.
5689 (unless gnus-single-article-buffer
5690 (gnus-kill-buffer gnus-original-article-buffer)
5691 (setq gnus-article-current nil))
5692 (when gnus-use-cache
5693 (gnus-cache-possibly-remove-articles)
5694 (gnus-cache-save-buffers))
5695 (gnus-async-prefetch-remove-group group)
5696 (when gnus-suppress-duplicates
5697 (gnus-dup-enter-articles))
5698 (when gnus-use-trees
5699 (gnus-tree-close group))
5700 (when gnus-use-cache
5701 (gnus-cache-write-active))
5702 ;; Remove entries for this group.
5703 (nnmail-purge-split-history (gnus-group-real-name group))
5704 ;; Make all changes in this group permanent.
5706 (gnus-run-hooks 'gnus-exit-group-hook)
5707 (gnus-summary-update-info))
5708 (gnus-close-group group)
5709 ;; Make sure where we were, and go to next newsgroup.
5710 (set-buffer gnus-group-buffer)
5712 (gnus-group-jump-to-group group))
5713 (gnus-run-hooks 'gnus-summary-exit-hook)
5714 (unless (or quit-config
5715 ;; If this group has disappeared from the summary
5716 ;; buffer, don't skip forwards.
5717 (not (string= group (gnus-group-group-name))))
5718 (gnus-group-next-unread-group 1))
5719 (setq group-point (point))
5722 ;; If we have several article buffers, we kill them at exit.
5723 (unless gnus-single-article-buffer
5724 (gnus-kill-buffer gnus-article-buffer)
5725 (gnus-kill-buffer gnus-original-article-buffer)
5726 (setq gnus-article-current nil))
5728 (if (not gnus-kill-summary-on-exit)
5730 (gnus-deaden-summary)
5732 ;; We set all buffer-local variables to nil. It is unclear why
5733 ;; this is needed, but if we don't, buffer-local variables are
5734 ;; not garbage-collected, it seems. This would the lead to en
5735 ;; ever-growing Emacs.
5736 (gnus-summary-clear-local-variables)
5737 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5738 (gnus-summary-clear-local-variables))
5739 (when (get-buffer gnus-article-buffer)
5740 (bury-buffer gnus-article-buffer))
5741 ;; We clear the global counterparts of the buffer-local
5742 ;; variables as well, just to be on the safe side.
5743 (set-buffer gnus-group-buffer)
5744 (gnus-summary-clear-local-variables)
5745 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5746 (gnus-summary-clear-local-variables)))
5747 (setq gnus-current-select-method gnus-select-method)
5748 (pop-to-buffer gnus-group-buffer)
5749 (if (not quit-config)
5751 (goto-char group-point)
5752 (gnus-configure-windows 'group 'force))
5753 (gnus-handle-ephemeral-exit quit-config))
5754 ;; Return to group mode buffer.
5755 (when (eq mode 'gnus-summary-mode)
5756 (gnus-kill-buffer buf))
5757 ;; Clear the current group name.
5759 (setq gnus-newsgroup-name nil)))))
5761 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5762 (defun gnus-summary-exit-no-update (&optional no-questions)
5763 "Quit reading current newsgroup without updating read article info."
5765 (let* ((group gnus-newsgroup-name)
5766 (quit-config (gnus-group-quit-config group)))
5767 (when (or no-questions
5769 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5770 (gnus-async-halt-prefetch)
5772 (delq 'gnus-summary-expire-articles
5773 (copy-sequence gnus-summary-prepare-exit-hook)))
5774 (when (gnus-buffer-live-p gnus-article-buffer)
5776 (set-buffer gnus-article-buffer)
5777 (mm-destroy-parts gnus-article-mime-handles)
5778 ;; Set it to nil for safety reason.
5779 (setq gnus-article-mime-handle-alist nil)
5780 (setq gnus-article-mime-handles nil)))
5781 ;; If we have several article buffers, we kill them at exit.
5782 (unless gnus-single-article-buffer
5783 (gnus-kill-buffer gnus-article-buffer)
5784 (gnus-kill-buffer gnus-original-article-buffer)
5785 (setq gnus-article-current nil))
5786 (if (not gnus-kill-summary-on-exit)
5787 (gnus-deaden-summary)
5788 (gnus-close-group group)
5789 (gnus-summary-clear-local-variables)
5790 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5791 (gnus-summary-clear-local-variables))
5792 (set-buffer gnus-group-buffer)
5793 (gnus-summary-clear-local-variables)
5794 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5795 (gnus-summary-clear-local-variables))
5796 (when (get-buffer gnus-summary-buffer)
5797 (kill-buffer gnus-summary-buffer)))
5798 (unless gnus-single-article-buffer
5799 (setq gnus-article-current nil))
5800 (when gnus-use-trees
5801 (gnus-tree-close group))
5802 (gnus-async-prefetch-remove-group group)
5803 (when (get-buffer gnus-article-buffer)
5804 (bury-buffer gnus-article-buffer))
5805 ;; Return to the group buffer.
5806 (gnus-configure-windows 'group 'force)
5807 ;; Clear the current group name.
5808 (setq gnus-newsgroup-name nil)
5809 (when (equal (gnus-group-group-name) group)
5810 (gnus-group-next-unread-group 1))
5812 (gnus-handle-ephemeral-exit quit-config)))))
5814 (defun gnus-handle-ephemeral-exit (quit-config)
5815 "Handle movement when leaving an ephemeral group.
5816 The state which existed when entering the ephemeral is reset."
5817 (if (not (buffer-name (car quit-config)))
5818 (gnus-configure-windows 'group 'force)
5819 (set-buffer (car quit-config))
5820 (cond ((eq major-mode 'gnus-summary-mode)
5821 (gnus-set-global-variables))
5822 ((eq major-mode 'gnus-article-mode)
5824 ;; The `gnus-summary-buffer' variable may point
5825 ;; to the old summary buffer when using a single
5827 (unless (gnus-buffer-live-p gnus-summary-buffer)
5828 (set-buffer gnus-group-buffer))
5829 (set-buffer gnus-summary-buffer)
5830 (gnus-set-global-variables))))
5831 (if (or (eq (cdr quit-config) 'article)
5832 (eq (cdr quit-config) 'pick))
5834 ;; The current article may be from the ephemeral group
5835 ;; thus it is best that we reload this article
5836 (gnus-summary-show-article)
5837 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5838 (gnus-configure-windows 'pick 'force)
5839 (gnus-configure-windows (cdr quit-config) 'force)))
5840 (gnus-configure-windows (cdr quit-config) 'force))
5841 (when (eq major-mode 'gnus-summary-mode)
5842 (gnus-summary-next-subject 1 nil t)
5843 (gnus-summary-recenter)
5844 (gnus-summary-position-point))))
5848 (defvar gnus-dead-summary-mode-map nil)
5850 (unless gnus-dead-summary-mode-map
5851 (setq gnus-dead-summary-mode-map (make-keymap))
5852 (suppress-keymap gnus-dead-summary-mode-map)
5853 (substitute-key-definition
5854 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5855 (let ((keys '("\C-d" "\r" "\177" [delete])))
5857 (define-key gnus-dead-summary-mode-map
5858 (pop keys) 'gnus-summary-wake-up-the-dead))))
5860 (defvar gnus-dead-summary-mode nil
5861 "Minor mode for Gnus summary buffers.")
5863 (defun gnus-dead-summary-mode (&optional arg)
5864 "Minor mode for Gnus summary buffers."
5866 (when (eq major-mode 'gnus-summary-mode)
5867 (make-local-variable 'gnus-dead-summary-mode)
5868 (setq gnus-dead-summary-mode
5869 (if (null arg) (not gnus-dead-summary-mode)
5870 (> (prefix-numeric-value arg) 0)))
5871 (when gnus-dead-summary-mode
5872 (gnus-add-minor-mode
5873 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5875 (defun gnus-deaden-summary ()
5876 "Make the current summary buffer into a dead summary buffer."
5877 ;; Kill any previous dead summary buffer.
5878 (when (and gnus-dead-summary
5879 (buffer-name gnus-dead-summary))
5881 (set-buffer gnus-dead-summary)
5882 (when gnus-dead-summary-mode
5883 (kill-buffer (current-buffer)))))
5884 ;; Make this the current dead summary.
5885 (setq gnus-dead-summary (current-buffer))
5886 (gnus-dead-summary-mode 1)
5887 (let ((name (buffer-name)))
5888 (when (string-match "Summary" name)
5890 (concat (substring name 0 (match-beginning 0)) "Dead "
5891 (substring name (match-beginning 0)))
5895 (defun gnus-kill-or-deaden-summary (buffer)
5896 "Kill or deaden the summary BUFFER."
5898 (when (and (buffer-name buffer)
5899 (not gnus-single-article-buffer))
5902 (gnus-kill-buffer gnus-article-buffer)
5903 (gnus-kill-buffer gnus-original-article-buffer)))
5904 (cond (gnus-kill-summary-on-exit
5905 (when (and gnus-use-trees
5906 (gnus-buffer-exists-p buffer))
5909 (gnus-tree-close gnus-newsgroup-name)))
5910 (gnus-kill-buffer buffer))
5911 ((gnus-buffer-exists-p buffer)
5914 (gnus-deaden-summary))))))
5916 (defun gnus-summary-wake-up-the-dead (&rest args)
5917 "Wake up the dead summary buffer."
5919 (gnus-dead-summary-mode -1)
5920 (let ((name (buffer-name)))
5921 (when (string-match "Dead " name)
5923 (concat (substring name 0 (match-beginning 0))
5924 (substring name (match-end 0)))
5926 (gnus-message 3 "This dead summary is now alive again"))
5928 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5929 (defun gnus-summary-fetch-faq (&optional faq-dir)
5930 "Fetch the FAQ for the current group.
5931 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5935 (when current-prefix-arg
5937 "Faq dir: " (and (listp gnus-group-faq-directory)
5938 (mapcar (lambda (file) (list file))
5939 gnus-group-faq-directory))))))
5940 (let (gnus-faq-buffer)
5941 (when (setq gnus-faq-buffer
5942 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5943 (gnus-configure-windows 'summary-faq))))
5945 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5946 (defun gnus-summary-describe-group (&optional force)
5947 "Describe the current newsgroup."
5949 (gnus-group-describe-group force gnus-newsgroup-name))
5951 (defun gnus-summary-describe-briefly ()
5952 "Describe summary mode commands briefly."
5954 (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")))
5956 ;; Walking around group mode buffer from summary mode.
5958 (defun gnus-summary-next-group (&optional no-article target-group backward)
5959 "Exit current newsgroup and then select next unread newsgroup.
5960 If prefix argument NO-ARTICLE is non-nil, no article is selected
5961 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5962 previous group instead."
5964 ;; Stop pre-fetching.
5965 (gnus-async-halt-prefetch)
5966 (let ((current-group gnus-newsgroup-name)
5967 (current-buffer (current-buffer))
5969 ;; First we semi-exit this group to update Xrefs and all variables.
5970 ;; We can't do a real exit, because the window conf must remain
5971 ;; the same in case the user is prompted for info, and we don't
5972 ;; want the window conf to change before that...
5973 (gnus-summary-exit t)
5974 (while (not entered)
5975 ;; Then we find what group we are supposed to enter.
5976 (set-buffer gnus-group-buffer)
5977 (gnus-group-jump-to-group current-group)
5980 (if (eq gnus-keep-same-level 'best)
5981 (gnus-summary-best-group gnus-newsgroup-name)
5982 (gnus-summary-search-group backward gnus-keep-same-level))))
5983 (if (not target-group)
5984 ;; There are no further groups, so we return to the group
5987 (gnus-message 5 "Returning to the group buffer")
5989 (when (gnus-buffer-live-p current-buffer)
5990 (set-buffer current-buffer)
5991 (gnus-summary-exit))
5992 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5993 ;; We try to enter the target group.
5994 (gnus-group-jump-to-group target-group)
5995 (let ((unreads (gnus-group-group-unread)))
5996 (if (and (or (eq t unreads)
5997 (and unreads (not (zerop unreads))))
5998 (gnus-summary-read-group
5999 target-group nil no-article
6000 (and (buffer-name current-buffer) current-buffer)
6003 (setq current-group target-group
6004 target-group nil)))))))
6006 (defun gnus-summary-prev-group (&optional no-article)
6007 "Exit current newsgroup and then select previous unread newsgroup.
6008 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6010 (gnus-summary-next-group no-article nil t))
6012 ;; Walking around summary lines.
6014 (defun gnus-summary-first-subject (&optional unread undownloaded)
6015 "Go to the first unread subject.
6016 If UNREAD is non-nil, go to the first unread article.
6017 Returns the article selected or nil if there are no unread articles."
6022 ((null gnus-newsgroup-data)
6023 (gnus-message 3 "No articles in the group")
6025 ;; Pick the first article.
6027 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6028 (gnus-data-number (car gnus-newsgroup-data)))
6029 ;; No unread articles.
6030 ((null gnus-newsgroup-unreads)
6031 (gnus-message 3 "No more unread articles")
6033 ;; Find the first unread article.
6035 (let ((data gnus-newsgroup-data))
6037 (and (not (and undownloaded
6038 (eq gnus-undownloaded-mark
6039 (gnus-data-mark (car data)))))
6040 (not (gnus-data-unread-p (car data)))))
6041 (setq data (cdr data)))
6043 (goto-char (gnus-data-pos (car data)))
6044 (gnus-data-number (car data))))))
6045 (gnus-summary-position-point)))
6047 (defun gnus-summary-next-subject (n &optional unread dont-display)
6048 "Go to next N'th summary line.
6049 If N is negative, go to the previous N'th subject line.
6050 If UNREAD is non-nil, only unread articles are selected.
6051 The difference between N and the actual number of steps taken is
6054 (let ((backward (< n 0))
6058 (gnus-summary-find-prev unread)
6059 (gnus-summary-find-next unread)))
6060 (unless (zerop (setq n (1- n)))
6061 (gnus-summary-show-thread)))
6063 (gnus-message 7 "No more%s articles"
6064 (if unread " unread" "")))
6065 (unless dont-display
6066 (gnus-summary-recenter)
6067 (gnus-summary-position-point))
6070 (defun gnus-summary-next-unread-subject (n)
6071 "Go to next N'th unread summary line."
6073 (gnus-summary-next-subject n t))
6075 (defun gnus-summary-prev-subject (n &optional unread)
6076 "Go to previous N'th summary line.
6077 If optional argument UNREAD is non-nil, only unread article is selected."
6079 (gnus-summary-next-subject (- n) unread))
6081 (defun gnus-summary-prev-unread-subject (n)
6082 "Go to previous N'th unread summary line."
6084 (gnus-summary-next-subject (- n) t))
6086 (defun gnus-summary-goto-subject (article &optional force silent)
6087 "Go the subject line of ARTICLE.
6088 If FORCE, also allow jumping to articles not currently shown."
6089 (interactive "nArticle number: ")
6091 (data (gnus-data-find article)))
6092 ;; We read in the article if we have to.
6095 (gnus-summary-insert-subject
6097 (if (or (numberp force) (vectorp force)) force)
6099 (setq data (gnus-data-find article)))
6104 (gnus-message 3 "Can't find article %d" article))
6106 (goto-char (gnus-data-pos data))
6107 (gnus-summary-position-point)
6110 ;; Walking around summary lines with displaying articles.
6112 (defun gnus-summary-expand-window (&optional arg)
6113 "Make the summary buffer take up the entire Emacs frame.
6114 Given a prefix, will force an `article' buffer configuration."
6117 (gnus-configure-windows 'article 'force)
6118 (gnus-configure-windows 'summary 'force)))
6120 (defun gnus-summary-display-article (article &optional all-header)
6121 "Display ARTICLE in article buffer."
6122 (when (gnus-buffer-live-p gnus-article-buffer)
6123 (with-current-buffer gnus-article-buffer
6124 (mm-enable-multibyte-mule4)))
6125 (gnus-set-global-variables)
6126 (when (gnus-buffer-live-p gnus-article-buffer)
6127 (with-current-buffer gnus-article-buffer
6128 (setq gnus-article-charset gnus-newsgroup-charset)
6129 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6130 (mm-enable-multibyte-mule4)))
6134 (if gnus-summary-display-article-function
6135 (funcall gnus-summary-display-article-function article all-header)
6136 (gnus-article-prepare article all-header))
6137 (gnus-run-hooks 'gnus-select-article-hook)
6138 (when (and gnus-current-article
6139 (not (zerop gnus-current-article)))
6140 (gnus-summary-goto-subject gnus-current-article))
6141 (gnus-summary-recenter)
6142 (when (and gnus-use-trees gnus-show-threads)
6143 (gnus-possibly-generate-tree article)
6144 (gnus-highlight-selected-tree article))
6145 ;; Successfully display article.
6146 (gnus-article-set-window-start
6147 (cdr (assq article gnus-newsgroup-bookmarks))))))
6149 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6150 "Select the current article.
6151 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6152 non-nil, the article will be re-fetched even if it already present in
6153 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6155 ;; Make sure we are in the summary buffer to work around bbdb bug.
6156 (unless (eq major-mode 'gnus-summary-mode)
6157 (set-buffer gnus-summary-buffer))
6158 (let ((article (or article (gnus-summary-article-number)))
6159 (all-headers (not (not all-headers))) ;Must be T or NIL.
6160 gnus-summary-display-article-function)
6162 (gnus-summary-article-pseudo-p article)
6163 (error "This is a pseudo-article"))
6165 (set-buffer gnus-summary-buffer)
6166 (if (or (and gnus-single-article-buffer
6167 (or (null gnus-current-article)
6168 (null gnus-article-current)
6169 (null (get-buffer gnus-article-buffer))
6170 (not (eq article (cdr gnus-article-current)))
6171 (not (equal (car gnus-article-current)
6172 gnus-newsgroup-name))))
6173 (and (not gnus-single-article-buffer)
6174 (or (null gnus-current-article)
6175 (not (eq gnus-current-article article))))
6177 ;; The requested article is different from the current article.
6179 (gnus-summary-display-article article all-headers)
6180 (when (gnus-buffer-live-p gnus-article-buffer)
6181 (with-current-buffer gnus-article-buffer
6182 (if (not gnus-article-decoded-p) ;; a local variable
6183 (mm-disable-multibyte-mule4))))
6184 (when (or all-headers gnus-show-all-headers)
6185 (gnus-article-show-all-headers))
6186 (gnus-article-set-window-start
6187 (cdr (assq article gnus-newsgroup-bookmarks)))
6189 (when (or all-headers gnus-show-all-headers)
6190 (gnus-article-show-all-headers))
6193 (defun gnus-summary-force-verify-and-decrypt ()
6195 (let ((mm-verify-option 'known)
6196 (mm-decrypt-option 'known))
6197 (gnus-summary-select-article nil 'force)))
6199 (defun gnus-summary-set-current-mark (&optional current-mark)
6200 "Obsolete function."
6203 (defun gnus-summary-next-article (&optional unread subject backward push)
6204 "Select the next article.
6205 If UNREAD, only unread articles are selected.
6206 If SUBJECT, only articles with SUBJECT are selected.
6207 If BACKWARD, the previous article is selected instead of the next."
6210 ;; Is there such an article?
6211 ((and (gnus-summary-search-forward unread subject backward)
6212 (or (gnus-summary-display-article (gnus-summary-article-number))
6213 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6214 (gnus-summary-position-point))
6215 ;; If not, we try the first unread, if that is wanted.
6217 gnus-auto-select-same
6218 (gnus-summary-first-unread-article))
6219 (gnus-summary-position-point)
6220 (gnus-message 6 "Wrapped"))
6221 ;; Try to get next/previous article not displayed in this group.
6222 ((and gnus-auto-extend-newsgroup
6223 (not unread) (not subject))
6224 (gnus-summary-goto-article
6225 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6226 nil (count-lines (point-min) (point))))
6227 ;; Go to next/previous group.
6229 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6230 (gnus-summary-jump-to-group gnus-newsgroup-name))
6231 (let ((cmd last-command-char)
6234 (set-buffer gnus-group-buffer)
6237 (if (eq gnus-keep-same-level 'best)
6238 (gnus-summary-best-group gnus-newsgroup-name)
6239 (gnus-summary-search-group backward gnus-keep-same-level))))
6240 ;; For some reason, the group window gets selected. We change
6242 (select-window (get-buffer-window (current-buffer)))
6243 ;; Select next unread newsgroup automagically.
6245 ((or (not gnus-auto-select-next)
6247 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6248 ((or (eq gnus-auto-select-next 'quietly)
6249 (and (eq gnus-auto-select-next 'slightly-quietly)
6251 (and (eq gnus-auto-select-next 'almost-quietly)
6252 (gnus-summary-last-article-p)))
6254 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6256 (gnus-message 7 "No more%s articles (%s)..."
6257 (if unread " unread" "")
6258 (if group (concat "selecting " group)
6260 (gnus-summary-next-group nil group backward)))
6262 (when (gnus-key-press-event-p last-input-event)
6263 (gnus-summary-walk-group-buffer
6264 gnus-newsgroup-name cmd unread backward point))))))))
6266 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6267 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6268 (?\C-p (gnus-group-prev-unread-group 1))))
6269 (cursor-in-echo-area t)
6270 keve key group ended)
6272 (set-buffer gnus-group-buffer)
6275 (if (eq gnus-keep-same-level 'best)
6276 (gnus-summary-best-group gnus-newsgroup-name)
6277 (gnus-summary-search-group backward gnus-keep-same-level))))
6280 5 "No more%s articles%s" (if unread " unread" "")
6282 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6283 (format " (Type %s for %s [%s])"
6284 (single-key-description cmd) group
6285 (car (gnus-gethash group gnus-newsrc-hashtb)))
6286 (format " (Type %s to exit %s)"
6287 (single-key-description cmd)
6288 gnus-newsgroup-name)))
6289 ;; Confirm auto selection.
6290 (setq key (car (setq keve (gnus-read-event-char))))
6293 ((assq key keystrokes)
6294 (let ((obuf (current-buffer)))
6295 (switch-to-buffer gnus-group-buffer)
6297 (gnus-group-jump-to-group group))
6298 (eval (cadr (assq key keystrokes)))
6299 (setq group (gnus-group-group-name))
6300 (switch-to-buffer obuf))
6304 (gnus-ephemeral-group-p gnus-newsgroup-name))
6306 (gnus-summary-next-group nil group backward)))
6308 (push (cdr keve) unread-command-events))))))
6310 (defun gnus-summary-next-unread-article ()
6311 "Select unread article after current one."
6313 (gnus-summary-next-article
6314 (or (not (eq gnus-summary-goto-unread 'never))
6315 (gnus-summary-last-article-p (gnus-summary-article-number)))
6316 (and gnus-auto-select-same
6317 (gnus-summary-article-subject))))
6319 (defun gnus-summary-prev-article (&optional unread subject)
6320 "Select the article after the current one.
6321 If UNREAD is non-nil, only unread articles are selected."
6323 (gnus-summary-next-article unread subject t))
6325 (defun gnus-summary-prev-unread-article ()
6326 "Select unread article before current one."
6328 (gnus-summary-prev-article
6329 (or (not (eq gnus-summary-goto-unread 'never))
6330 (gnus-summary-first-article-p (gnus-summary-article-number)))
6331 (and gnus-auto-select-same
6332 (gnus-summary-article-subject))))
6334 (defun gnus-summary-next-page (&optional lines circular)
6335 "Show next page of the selected article.
6336 If at the end of the current article, select the next article.
6337 LINES says how many lines should be scrolled up.
6339 If CIRCULAR is non-nil, go to the start of the article instead of
6340 selecting the next article when reaching the end of the current
6343 (setq gnus-summary-buffer (current-buffer))
6344 (gnus-set-global-variables)
6345 (let ((article (gnus-summary-article-number))
6346 (article-window (get-buffer-window gnus-article-buffer t))
6348 ;; If the buffer is empty, we have no article.
6350 (error "No article to select"))
6351 (gnus-configure-windows 'article)
6352 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6353 (if (and (eq gnus-summary-goto-unread 'never)
6354 (not (gnus-summary-last-article-p article)))
6355 (gnus-summary-next-article)
6356 (gnus-summary-next-unread-article))
6357 (if (or (null gnus-current-article)
6358 (null gnus-article-current)
6359 (/= article (cdr gnus-article-current))
6360 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6361 ;; Selected subject is different from current article's.
6362 (gnus-summary-display-article article)
6363 (when article-window
6364 (gnus-eval-in-buffer-window gnus-article-buffer
6365 (setq endp (gnus-article-next-page lines)))
6368 (gnus-summary-beginning-of-article))
6370 (gnus-message 3 "End of message"))
6372 (if (and (eq gnus-summary-goto-unread 'never)
6373 (not (gnus-summary-last-article-p article)))
6374 (gnus-summary-next-article)
6375 (gnus-summary-next-unread-article))))))))
6376 (gnus-summary-recenter)
6377 (gnus-summary-position-point)))
6379 (defun gnus-summary-prev-page (&optional lines move)
6380 "Show previous page of selected article.
6381 Argument LINES specifies lines to be scrolled down.
6382 If MOVE, move to the previous unread article if point is at
6383 the beginning of the buffer."
6385 (let ((article (gnus-summary-article-number))
6386 (article-window (get-buffer-window gnus-article-buffer t))
6388 (gnus-configure-windows 'article)
6389 (if (or (null gnus-current-article)
6390 (null gnus-article-current)
6391 (/= article (cdr gnus-article-current))
6392 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6393 ;; Selected subject is different from current article's.
6394 (gnus-summary-display-article article)
6395 (gnus-summary-recenter)
6396 (when article-window
6397 (gnus-eval-in-buffer-window gnus-article-buffer
6398 (setq endp (gnus-article-prev-page lines)))
6399 (when (and move endp)
6401 (gnus-message 3 "Beginning of message"))
6403 (if (and (eq gnus-summary-goto-unread 'never)
6404 (not (gnus-summary-first-article-p article)))
6405 (gnus-summary-prev-article)
6406 (gnus-summary-prev-unread-article))))))))
6407 (gnus-summary-position-point))
6409 (defun gnus-summary-prev-page-or-article (&optional lines)
6410 "Show previous page of selected article.
6411 Argument LINES specifies lines to be scrolled down.
6412 If at the beginning of the article, go to the next article."
6414 (gnus-summary-prev-page lines t))
6416 (defun gnus-summary-scroll-up (lines)
6417 "Scroll up (or down) one line current article.
6418 Argument LINES specifies lines to be scrolled up (or down if negative)."
6420 (gnus-configure-windows 'article)
6421 (gnus-summary-show-thread)
6422 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6423 (gnus-eval-in-buffer-window gnus-article-buffer
6425 (when (gnus-article-next-page lines)
6426 (gnus-message 3 "End of message")))
6428 (gnus-article-prev-page (- lines))))))
6429 (gnus-summary-recenter)
6430 (gnus-summary-position-point))
6432 (defun gnus-summary-scroll-down (lines)
6433 "Scroll down (or up) one line current article.
6434 Argument LINES specifies lines to be scrolled down (or up if negative)."
6436 (gnus-summary-scroll-up (- lines)))
6438 (defun gnus-summary-next-same-subject ()
6439 "Select next article which has the same subject as current one."
6441 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6443 (defun gnus-summary-prev-same-subject ()
6444 "Select previous article which has the same subject as current one."
6446 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6448 (defun gnus-summary-next-unread-same-subject ()
6449 "Select next unread article which has the same subject as current one."
6451 (gnus-summary-next-article t (gnus-summary-article-subject)))
6453 (defun gnus-summary-prev-unread-same-subject ()
6454 "Select previous unread article which has the same subject as current one."
6456 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6458 (defun gnus-summary-first-unread-article ()
6459 "Select the first unread article.
6460 Return nil if there are no unread articles."
6463 (when (gnus-summary-first-subject t)
6464 (gnus-summary-show-thread)
6465 (gnus-summary-first-subject t)
6466 (gnus-summary-display-article (gnus-summary-article-number)))
6467 (gnus-summary-position-point)))
6469 (defun gnus-summary-first-unread-subject ()
6470 "Place the point on the subject line of the first unread article.
6471 Return nil if there are no unread articles."
6474 (when (gnus-summary-first-subject t)
6475 (gnus-summary-show-thread)
6476 (gnus-summary-first-subject t))
6477 (gnus-summary-position-point)))
6479 (defun gnus-summary-first-article ()
6480 "Select the first article.
6481 Return nil if there are no articles."
6484 (when (gnus-summary-first-subject)
6485 (gnus-summary-show-thread)
6486 (gnus-summary-first-subject)
6487 (gnus-summary-display-article (gnus-summary-article-number)))
6488 (gnus-summary-position-point)))
6490 (defun gnus-summary-best-unread-article ()
6491 "Select the unread article with the highest score."
6493 (let ((best -1000000)
6494 (data gnus-newsgroup-data)
6497 (and (gnus-data-unread-p (car data))
6499 (gnus-summary-article-score (gnus-data-number (car data))))
6502 article (gnus-data-number (car data))))
6503 (setq data (cdr data)))
6506 (gnus-summary-goto-article article)
6507 (error "No unread articles"))
6508 (gnus-summary-position-point))))
6510 (defun gnus-summary-last-subject ()
6511 "Go to the last displayed subject line in the group."
6512 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6514 (gnus-summary-goto-subject article))))
6516 (defun gnus-summary-goto-article (article &optional all-headers force)
6517 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6518 If ALL-HEADERS is non-nil, no header lines are hidden.
6519 If FORCE, go to the article even if it isn't displayed. If FORCE
6520 is a number, it is the line the article is to be displayed on."
6524 "Article number or Message-ID: "
6525 (mapcar (lambda (number) (list (int-to-string number)))
6526 gnus-newsgroup-limit))
6530 (if (and (stringp article)
6531 (string-match "@" article))
6532 (gnus-summary-refer-article article)
6533 (when (stringp article)
6534 (setq article (string-to-number article)))
6535 (if (gnus-summary-goto-subject article force)
6536 (gnus-summary-display-article article all-headers)
6537 (gnus-message 4 "Couldn't go to article %s" article) nil))
6538 (gnus-summary-position-point)))
6540 (defun gnus-summary-goto-last-article ()
6541 "Go to the previously read article."
6544 (when gnus-last-article
6545 (gnus-summary-goto-article gnus-last-article nil t))
6546 (gnus-summary-position-point)))
6548 (defun gnus-summary-pop-article (number)
6549 "Pop one article off the history and go to the previous.
6550 NUMBER articles will be popped off."
6553 (setq gnus-newsgroup-history
6554 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6556 (gnus-summary-goto-article (car to) nil t)
6557 (error "Article history empty")))
6558 (gnus-summary-position-point))
6560 ;; Summary commands and functions for limiting the summary buffer.
6562 (defun gnus-summary-limit-to-articles (n)
6563 "Limit the summary buffer to the next N articles.
6564 If not given a prefix, use the process marked articles instead."
6567 (let ((articles (gnus-summary-work-articles n)))
6568 (setq gnus-newsgroup-processable nil)
6569 (gnus-summary-limit articles))
6570 (gnus-summary-position-point)))
6572 (defun gnus-summary-pop-limit (&optional total)
6573 "Restore the previous limit.
6574 If given a prefix, remove all limits."
6577 (setq gnus-newsgroup-limits
6578 (list (mapcar (lambda (h) (mail-header-number h))
6579 gnus-newsgroup-headers))))
6580 (unless gnus-newsgroup-limits
6581 (error "No limit to pop"))
6583 (gnus-summary-limit nil 'pop)
6584 (gnus-summary-position-point)))
6586 (defun gnus-summary-limit-to-subject (subject &optional header)
6587 "Limit the summary buffer to articles that have subjects that match a regexp."
6588 (interactive "sLimit to subject (regexp): ")
6590 (setq header "subject"))
6591 (when (not (equal "" subject))
6593 (let ((articles (gnus-summary-find-matching
6594 (or header "subject") subject 'all)))
6596 (error "Found no matches for \"%s\"" subject))
6597 (gnus-summary-limit articles))
6598 (gnus-summary-position-point))))
6600 (defun gnus-summary-limit-to-author (from)
6601 "Limit the summary buffer to articles that have authors that match a regexp."
6602 (interactive "sLimit to author (regexp): ")
6603 (gnus-summary-limit-to-subject from "from"))
6605 (defun gnus-summary-limit-to-age (age &optional younger-p)
6606 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6607 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6608 articles that are younger than AGE days."
6610 (let ((younger current-prefix-arg)
6613 (while (not days-got)
6614 (setq days (if younger
6615 (read-string "Limit to articles within (in days): ")
6616 (read-string "Limit to articles older than (in days): ")))
6617 (when (> (length days) 0)
6618 (setq days (read days)))
6621 (message "Please enter a number.")
6623 (list days younger)))
6625 (let ((data gnus-newsgroup-data)
6626 (cutoff (days-to-time age))
6627 articles d date is-younger)
6628 (while (setq d (pop data))
6629 (when (and (vectorp (gnus-data-header d))
6630 (setq date (mail-header-date (gnus-data-header d))))
6631 (setq is-younger (time-less-p
6632 (time-since (condition-case ()
6639 (push (gnus-data-number d) articles))))
6640 (gnus-summary-limit (nreverse articles)))
6641 (gnus-summary-position-point)))
6643 (defun gnus-summary-limit-to-extra (header regexp)
6644 "Limit the summary buffer to articles that match an 'extra' header."
6648 (gnus-completing-read
6649 (symbol-name (car gnus-extra-headers))
6650 "Limit extra header:"
6652 (cons (symbol-name x) x))
6657 (read-string (format "Limit to header %s (regexp): " header)))))
6658 (when (not (equal "" regexp))
6660 (let ((articles (gnus-summary-find-matching
6661 (cons 'extra header) regexp 'all)))
6663 (error "Found no matches for \"%s\"" regexp))
6664 (gnus-summary-limit articles))
6665 (gnus-summary-position-point))))
6667 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6669 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6671 (defun gnus-summary-limit-to-unread (&optional all)
6672 "Limit the summary buffer to articles that are not marked as read.
6673 If ALL is non-nil, limit strictly to unread articles."
6676 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6677 (gnus-summary-limit-to-marks
6678 ;; Concat all the marks that say that an article is read and have
6680 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6681 gnus-killed-mark gnus-kill-file-mark
6682 gnus-low-score-mark gnus-expirable-mark
6683 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6684 gnus-duplicate-mark gnus-souped-mark)
6687 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6688 (make-obsolete 'gnus-summary-delete-marked-with
6689 'gnus-summary-limit-exlude-marks)
6691 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6692 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6693 If REVERSE, limit the summary buffer to articles that are marked
6694 with MARKS. MARKS can either be a string of marks or a list of marks.
6695 Returns how many articles were removed."
6696 (interactive "sMarks: ")
6697 (gnus-summary-limit-to-marks marks t))
6699 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6700 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6701 If REVERSE (the prefix), limit the summary buffer to articles that are
6702 not marked with MARKS. MARKS can either be a string of marks or a
6704 Returns how many articles were removed."
6705 (interactive "sMarks: \nP")
6707 (let ((data gnus-newsgroup-data)
6708 (marks (if (listp marks) marks
6709 (append marks nil))) ; Transform to list.
6712 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6713 (memq (gnus-data-mark (car data)) marks))
6714 (push (gnus-data-number (car data)) articles))
6715 (setq data (cdr data)))
6716 (gnus-summary-limit articles))
6717 (gnus-summary-position-point)))
6719 (defun gnus-summary-limit-to-score (&optional score)
6720 "Limit to articles with score at or above SCORE."
6722 (setq score (if score
6723 (prefix-numeric-value score)
6724 (or gnus-summary-default-score 0)))
6725 (let ((data gnus-newsgroup-data)
6728 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6730 (push (gnus-data-number (car data)) articles))
6731 (setq data (cdr data)))
6733 (gnus-summary-limit articles)
6734 (gnus-summary-position-point))))
6736 (defun gnus-summary-limit-include-thread (id)
6737 "Display all the hidden articles that is in the thread with ID in it.
6738 When called interactively, ID is the Message-ID of the current
6740 (interactive (list (mail-header-id (gnus-summary-article-header))))
6741 (let ((articles (gnus-articles-in-thread
6742 (gnus-id-to-thread (gnus-root-id id)))))
6744 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6745 (gnus-summary-limit-include-matching-articles
6747 (regexp-quote (gnus-simplify-subject-re
6748 (mail-header-subject (gnus-id-to-header id)))))
6749 (gnus-summary-position-point))))
6751 (defun gnus-summary-limit-include-matching-articles (header regexp)
6752 "Display all the hidden articles that have HEADERs that match REGEXP."
6753 (interactive (list (read-string "Match on header: ")
6754 (read-string "Regexp: ")))
6755 (let ((articles (gnus-find-matching-articles header regexp)))
6757 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6758 (gnus-summary-position-point))))
6760 (defun gnus-summary-limit-include-dormant ()
6761 "Display all the hidden articles that are marked as dormant.
6762 Note that this command only works on a subset of the articles currently
6763 fetched for this group."
6765 (unless gnus-newsgroup-dormant
6766 (error "There are no dormant articles in this group"))
6768 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6769 (gnus-summary-position-point)))
6771 (defun gnus-summary-limit-exclude-dormant ()
6772 "Hide all dormant articles."
6775 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6776 (gnus-summary-position-point)))
6778 (defun gnus-summary-limit-exclude-childless-dormant ()
6779 "Hide all dormant articles that have no children."
6781 (let ((data (gnus-data-list t))
6782 articles d children)
6783 ;; Find all articles that are either not dormant or have
6785 (while (setq d (pop data))
6786 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6788 (gnus-article-children (gnus-data-number d)))
6791 (when (memq (car children) articles)
6796 (push (gnus-data-number d) articles)))
6799 (gnus-summary-limit articles)
6800 (gnus-summary-position-point))))
6802 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6803 "Mark all unread excluded articles as read.
6804 If ALL, mark even excluded ticked and dormants as read."
6806 (let ((articles (gnus-sorted-complement
6808 (mapcar (lambda (h) (mail-header-number h))
6809 gnus-newsgroup-headers)
6811 (sort gnus-newsgroup-limit '<)))
6813 (setq gnus-newsgroup-unreads
6814 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6816 (setq gnus-newsgroup-dormant nil
6817 gnus-newsgroup-marked nil
6818 gnus-newsgroup-reads
6820 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6821 gnus-newsgroup-reads))
6822 (while (setq article (pop articles))
6823 (unless (or (memq article gnus-newsgroup-dormant)
6824 (memq article gnus-newsgroup-marked))
6825 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6827 (defun gnus-summary-limit (articles &optional pop)
6829 ;; We pop the previous limit off the stack and use that.
6830 (setq articles (car gnus-newsgroup-limits)
6831 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6832 ;; We use the new limit, so we push the old limit on the stack.
6833 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6835 (setq gnus-newsgroup-limit articles)
6836 (let ((total (length gnus-newsgroup-data))
6837 (data (gnus-data-find-list (gnus-summary-article-number)))
6838 (gnus-summary-mark-below nil) ; Inhibit this.
6840 ;; This will do all the work of generating the new summary buffer
6841 ;; according to the new limit.
6842 (gnus-summary-prepare)
6843 ;; Hide any threads, possibly.
6844 (and gnus-show-threads
6845 gnus-thread-hide-subtree
6846 (gnus-summary-hide-all-threads))
6847 ;; Try to return to the article you were at, or one in the
6850 ;; We try to find some article after the current one.
6852 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6855 (setq data (cdr data))))
6857 ;; If there is no data, that means that we were after the last
6858 ;; article. The same goes when we can't find any articles
6859 ;; after the current one.
6860 (goto-char (point-max))
6861 (gnus-summary-find-prev))
6862 (gnus-set-mode-line 'summary)
6863 ;; We return how many articles were removed from the summary
6864 ;; buffer as a result of the new limit.
6865 (- total (length gnus-newsgroup-data))))
6867 (defsubst gnus-invisible-cut-children (threads)
6870 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6875 (defsubst gnus-cut-thread (thread)
6876 "Go forwards in the thread until we find an article that we want to display."
6877 (when (or (eq gnus-fetch-old-headers 'some)
6878 (eq gnus-fetch-old-headers 'invisible)
6879 (numberp gnus-fetch-old-headers)
6880 (eq gnus-build-sparse-threads 'some)
6881 (eq gnus-build-sparse-threads 'more))
6882 ;; Deal with old-fetched headers and sparse threads.
6886 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6887 (gnus-summary-article-ancient-p
6888 (mail-header-number (car thread))))
6889 (if (or (<= (length (cdr thread)) 1)
6890 (eq gnus-fetch-old-headers 'invisible))
6891 (setq gnus-newsgroup-limit
6892 (delq (mail-header-number (car thread))
6893 gnus-newsgroup-limit)
6894 thread (cadr thread))
6895 (when (gnus-invisible-cut-children (cdr thread))
6896 (let ((th (cdr thread)))
6898 (if (memq (mail-header-number (caar th))
6899 gnus-newsgroup-limit)
6900 (setq thread (car th)
6902 (setq th (cdr th))))))))))
6905 (defun gnus-cut-threads (threads)
6906 "Cut off all uninteresting articles from the beginning of threads."
6907 (when (or (eq gnus-fetch-old-headers 'some)
6908 (eq gnus-fetch-old-headers 'invisible)
6909 (numberp gnus-fetch-old-headers)
6910 (eq gnus-build-sparse-threads 'some)
6911 (eq gnus-build-sparse-threads 'more))
6914 (setcar th (gnus-cut-thread (car th)))
6915 (setq th (cdr th)))))
6916 ;; Remove nixed out threads.
6919 (defun gnus-summary-initial-limit (&optional show-if-empty)
6920 "Figure out what the initial limit is supposed to be on group entry.
6921 This entails weeding out unwanted dormants, low-scored articles,
6922 fetch-old-headers verbiage, and so on."
6923 ;; Most groups have nothing to remove.
6924 (if (or gnus-inhibit-limiting
6925 (and (null gnus-newsgroup-dormant)
6926 (not (eq gnus-fetch-old-headers 'some))
6927 (not (numberp gnus-fetch-old-headers))
6928 (not (eq gnus-fetch-old-headers 'invisible))
6929 (null gnus-summary-expunge-below)
6930 (not (eq gnus-build-sparse-threads 'some))
6931 (not (eq gnus-build-sparse-threads 'more))
6932 (null gnus-thread-expunge-below)
6933 (not gnus-use-nocem)))
6935 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6936 (setq gnus-newsgroup-limit nil)
6939 (unless (car (symbol-value node))
6940 ;; These threads have no parents -- they are roots.
6941 (let ((nodes (cdr (symbol-value node)))
6944 (if (and gnus-thread-expunge-below
6945 (< (gnus-thread-total-score (car nodes))
6946 gnus-thread-expunge-below))
6947 (gnus-expunge-thread (pop nodes))
6948 (setq thread (pop nodes))
6949 (gnus-summary-limit-children thread))))))
6950 gnus-newsgroup-dependencies)
6951 ;; If this limitation resulted in an empty group, we might
6952 ;; pop the previous limit and use it instead.
6953 (when (and (not gnus-newsgroup-limit)
6955 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6956 gnus-newsgroup-limit))
6958 (defun gnus-summary-limit-children (thread)
6959 "Return 1 if this subthread is visible and 0 if it is not."
6960 ;; First we get the number of visible children to this thread. This
6961 ;; is done by recursing down the thread using this function, so this
6962 ;; will really go down to a leaf article first, before slowly
6963 ;; working its way up towards the root.
6967 (apply '+ (mapcar 'gnus-summary-limit-children
6970 (number (mail-header-number (car thread)))
6973 (not (memq number gnus-newsgroup-marked))
6975 ;; If this article is dormant and has absolutely no visible
6976 ;; children, then this article isn't visible.
6977 (and (memq number gnus-newsgroup-dormant)
6979 ;; If this is "fetch-old-headered" and there is no
6980 ;; visible children, then we don't want this article.
6981 (and (or (eq gnus-fetch-old-headers 'some)
6982 (numberp gnus-fetch-old-headers))
6983 (gnus-summary-article-ancient-p number)
6985 ;; If this is "fetch-old-headered" and `invisible', then
6986 ;; we don't want this article.
6987 (and (eq gnus-fetch-old-headers 'invisible)
6988 (gnus-summary-article-ancient-p number))
6989 ;; If this is a sparsely inserted article with no children,
6990 ;; we don't want it.
6991 (and (eq gnus-build-sparse-threads 'some)
6992 (gnus-summary-article-sparse-p number)
6994 ;; If we use expunging, and this article is really
6995 ;; low-scored, then we don't want this article.
6996 (when (and gnus-summary-expunge-below
6998 (or (cdr (assq number gnus-newsgroup-scored))
6999 gnus-summary-default-score))
7000 gnus-summary-expunge-below))
7001 ;; We increase the expunge-tally here, but that has
7002 ;; nothing to do with the limits, really.
7003 (incf gnus-newsgroup-expunged-tally)
7004 ;; We also mark as read here, if that's wanted.
7005 (when (and gnus-summary-mark-below
7006 (< score gnus-summary-mark-below))
7007 (setq gnus-newsgroup-unreads
7008 (delq number gnus-newsgroup-unreads))
7009 (if gnus-newsgroup-auto-expire
7010 (push number gnus-newsgroup-expirable)
7011 (push (cons number gnus-low-score-mark)
7012 gnus-newsgroup-reads)))
7014 ;; Check NoCeM things.
7015 (if (and gnus-use-nocem
7016 (gnus-nocem-unwanted-article-p
7017 (mail-header-id (car thread))))
7019 (setq gnus-newsgroup-unreads
7020 (delq number gnus-newsgroup-unreads))
7022 ;; Nope, invisible article.
7024 ;; Ok, this article is to be visible, so we add it to the limit
7026 (push number gnus-newsgroup-limit)
7029 (defun gnus-expunge-thread (thread)
7030 "Mark all articles in THREAD as read."
7031 (let* ((number (mail-header-number (car thread))))
7032 (incf gnus-newsgroup-expunged-tally)
7033 ;; We also mark as read here, if that's wanted.
7034 (setq gnus-newsgroup-unreads
7035 (delq number gnus-newsgroup-unreads))
7036 (if gnus-newsgroup-auto-expire
7037 (push number gnus-newsgroup-expirable)
7038 (push (cons number gnus-low-score-mark)
7039 gnus-newsgroup-reads)))
7040 ;; Go recursively through all subthreads.
7041 (mapcar 'gnus-expunge-thread (cdr thread)))
7043 ;; Summary article oriented commands
7045 (defun gnus-summary-refer-parent-article (n)
7046 "Refer parent article N times.
7047 If N is negative, go to ancestor -N instead.
7048 The difference between N and the number of articles fetched is returned."
7052 (when (not (natnump n))
7057 (setq header (gnus-summary-article-header))
7058 (if (and (eq (mail-header-number header)
7059 (cdr gnus-article-current))
7060 (equal gnus-newsgroup-name
7061 (car gnus-article-current)))
7062 ;; If we try to find the parent of the currently
7063 ;; displayed article, then we take a look at the actual
7064 ;; References header, since this is slightly more
7065 ;; reliable than the References field we got from the
7068 (set-buffer gnus-original-article-buffer)
7069 (nnheader-narrow-to-headers)
7070 (unless (setq ref (message-fetch-field "references"))
7071 (setq ref (message-fetch-field "in-reply-to")))
7074 ;; It's not the current article, so we take a bet on
7075 ;; the value we got from the server.
7076 (mail-header-references header)))
7078 (not (equal ref "")))
7079 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7080 (gnus-message 1 "Couldn't find parent"))
7081 (gnus-message 1 "No references in article %d"
7082 (gnus-summary-article-number))
7085 (gnus-summary-position-point)
7088 (defun gnus-summary-refer-references ()
7089 "Fetch all articles mentioned in the References header.
7090 Return the number of articles fetched."
7092 (let ((ref (mail-header-references (gnus-summary-article-header)))
7093 (current (gnus-summary-article-number))
7097 (error "No References in the current article")
7098 ;; For each Message-ID in the References header...
7099 (while (string-match "<[^>]*>" ref)
7101 ;; ... fetch that article.
7102 (gnus-summary-refer-article
7103 (prog1 (match-string 0 ref)
7104 (setq ref (substring ref (match-end 0))))))
7105 (gnus-summary-goto-subject current)
7106 (gnus-summary-position-point)
7109 (defun gnus-summary-refer-thread (&optional limit)
7110 "Fetch all articles in the current thread.
7111 If LIMIT (the numerical prefix), fetch that many old headers instead
7112 of what's specified by the `gnus-refer-thread-limit' variable."
7114 (let ((id (mail-header-id (gnus-summary-article-header)))
7115 (limit (if limit (prefix-numeric-value limit)
7116 gnus-refer-thread-limit)))
7117 ;; We want to fetch LIMIT *old* headers, but we also have to
7118 ;; re-fetch all the headers in the current buffer, because many of
7119 ;; them may be undisplayed. So we adjust LIMIT.
7120 (when (numberp limit)
7121 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7122 (unless (eq gnus-fetch-old-headers 'invisible)
7123 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7124 ;; Retrieve the headers and read them in.
7125 (if (eq (gnus-retrieve-headers
7126 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7128 (gnus-build-all-threads)
7129 (error "Can't fetch thread from backends that don't support NOV"))
7130 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7131 (gnus-summary-limit-include-thread id)))
7133 (defun gnus-summary-refer-article (message-id)
7134 "Fetch an article specified by MESSAGE-ID."
7135 (interactive "sMessage-ID: ")
7136 (when (and (stringp message-id)
7137 (not (zerop (length message-id))))
7138 ;; Construct the correct Message-ID if necessary.
7139 ;; Suggested by tale@pawl.rpi.edu.
7140 (unless (string-match "^<" message-id)
7141 (setq message-id (concat "<" message-id)))
7142 (unless (string-match ">$" message-id)
7143 (setq message-id (concat message-id ">")))
7144 (let* ((header (gnus-id-to-header message-id))
7146 (gnus-summary-article-sparse-p
7147 (mail-header-number header))
7148 (memq (mail-header-number header)
7149 gnus-newsgroup-limit)))
7152 ;; If the article is present in the buffer we just go to it.
7154 (or (not (gnus-summary-article-sparse-p
7155 (mail-header-number header)))
7158 (gnus-summary-goto-article
7159 (mail-header-number header) nil t)
7161 (gnus-summary-update-article (mail-header-number header)))))
7163 ;; We fetch the article.
7165 (dolist (gnus-override-method (gnus-refer-article-methods))
7166 (gnus-check-server gnus-override-method)
7167 ;; Fetch the header, and display the article.
7168 (when (setq number (gnus-summary-insert-subject message-id))
7169 (gnus-summary-select-article nil nil nil number)
7171 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7173 (defun gnus-refer-article-methods ()
7174 "Return a list of referrable methods."
7176 ;; No method, so we default to current and native.
7177 ((null gnus-refer-article-method)
7178 (list gnus-current-select-method gnus-select-method))
7180 ((eq 'current gnus-refer-article-method)
7181 (list gnus-current-select-method))
7182 ;; List of select methods.
7183 ((not (and (symbolp (car gnus-refer-article-method))
7184 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7186 (dolist (method gnus-refer-article-method)
7187 (push (if (eq 'current method)
7188 gnus-current-select-method
7192 ;; One single select method.
7194 (list gnus-refer-article-method))))
7196 (defun gnus-summary-edit-parameters ()
7197 "Edit the group parameters of the current group."
7199 (gnus-group-edit-group gnus-newsgroup-name 'params))
7201 (defun gnus-summary-customize-parameters ()
7202 "Customize the group parameters of the current group."
7204 (gnus-group-customize gnus-newsgroup-name))
7206 (defun gnus-summary-enter-digest-group (&optional force)
7207 "Enter an nndoc group based on the current article.
7208 If FORCE, force a digest interpretation. If not, try
7209 to guess what the document format is."
7211 (let ((conf gnus-current-window-configuration))
7213 (gnus-summary-select-article))
7214 (setq gnus-current-window-configuration conf)
7215 (let* ((name (format "%s-%d"
7216 (gnus-group-prefixed-name
7217 gnus-newsgroup-name (list 'nndoc ""))
7219 (set-buffer gnus-summary-buffer)
7220 gnus-current-article)))
7221 (ogroup gnus-newsgroup-name)
7222 (params (append (gnus-info-params (gnus-get-info ogroup))
7223 (list (cons 'to-group ogroup))
7224 (list (cons 'save-article-group ogroup))))
7225 (case-fold-search t)
7226 (buf (current-buffer))
7229 (set-buffer gnus-original-article-buffer)
7230 ;; Have the digest group inherit the main mail address of
7231 ;; the parent article.
7232 (when (setq to-address (or (message-fetch-field "reply-to")
7233 (message-fetch-field "from")))
7234 (setq params (append
7235 (list (cons 'to-address
7236 (funcall gnus-decode-encoded-word-function
7238 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7239 (insert-buffer-substring gnus-original-article-buffer)
7240 ;; Remove lines that may lead nndoc to misinterpret the
7243 (goto-char (point-min))
7244 (or (search-forward "\n\n" nil t) (point)))
7245 (goto-char (point-min))
7246 (delete-matching-lines "^Path:\\|^From ")
7249 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7250 (gnus-newsgroup-ephemeral-ignored-charsets
7251 gnus-newsgroup-ignored-charsets))
7252 (gnus-group-read-ephemeral-group
7253 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7255 ,(if force 'mbox 'guess))) t))
7256 ;; Make all postings to this group go to the parent group.
7257 (nconc (gnus-info-params (gnus-get-info name))
7259 ;; Couldn't select this doc group.
7260 (switch-to-buffer buf)
7261 (gnus-set-global-variables)
7262 (gnus-configure-windows 'summary)
7263 (gnus-message 3 "Article couldn't be entered?"))
7264 (kill-buffer dig)))))
7266 (defun gnus-summary-read-document (n)
7267 "Open a new group based on the current article(s).
7268 This will allow you to read digests and other similar
7269 documents as newsgroups.
7270 Obeys the standard process/prefix convention."
7272 (let* ((articles (gnus-summary-work-articles n))
7273 (ogroup gnus-newsgroup-name)
7274 (params (append (gnus-info-params (gnus-get-info ogroup))
7275 (list (cons 'to-group ogroup))))
7276 article group egroup groups vgroup)
7277 (while (setq article (pop articles))
7278 (setq group (format "%s-%d" gnus-newsgroup-name article))
7279 (gnus-summary-remove-process-mark article)
7280 (when (gnus-summary-display-article article)
7283 (insert-buffer-substring gnus-original-article-buffer)
7284 ;; Remove some headers that may lead nndoc to make
7286 (message-narrow-to-head)
7287 (goto-char (point-min))
7288 (delete-matching-lines "^\\(Path\\):\\|^From ")
7291 (gnus-group-read-ephemeral-group
7292 group `(nndoc ,group (nndoc-address ,(current-buffer))
7293 (nndoc-article-type guess))
7296 ;; Make all postings to this group go to the parent group.
7297 (nconc (gnus-info-params (gnus-get-info egroup))
7299 (push egroup groups))
7300 ;; Couldn't select this doc group.
7301 (gnus-error 3 "Article couldn't be entered"))))))
7302 ;; Now we have selected all the documents.
7305 (error "None of the articles could be interpreted as documents"))
7306 ((gnus-group-read-ephemeral-group
7307 (setq vgroup (format
7308 "nnvirtual:%s-%s" gnus-newsgroup-name
7309 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7310 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7312 (cons (current-buffer) 'summary)))
7314 (error "Couldn't select virtual nndoc group")))))
7316 (defun gnus-summary-isearch-article (&optional regexp-p)
7317 "Do incremental search forward on the current article.
7318 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7320 (gnus-summary-select-article)
7321 (gnus-configure-windows 'article)
7322 (gnus-eval-in-buffer-window gnus-article-buffer
7325 (isearch-forward regexp-p))))
7327 (defun gnus-summary-search-article-forward (regexp &optional backward)
7328 "Search for an article containing REGEXP forward.
7329 If BACKWARD, search backward instead."
7332 (format "Search article %s (regexp%s): "
7333 (if current-prefix-arg "backward" "forward")
7334 (if gnus-last-search-regexp
7335 (concat ", default " gnus-last-search-regexp)
7337 current-prefix-arg))
7338 (if (string-equal regexp "")
7339 (setq regexp (or gnus-last-search-regexp ""))
7340 (setq gnus-last-search-regexp regexp)
7341 (setq gnus-article-before-search gnus-current-article))
7342 ;; Intentionally set gnus-last-article.
7343 (setq gnus-last-article gnus-article-before-search)
7344 (let ((gnus-last-article gnus-last-article))
7345 (if (gnus-summary-search-article regexp backward)
7346 (gnus-summary-show-thread)
7347 (error "Search failed: \"%s\"" regexp))))
7349 (defun gnus-summary-search-article-backward (regexp)
7350 "Search for an article containing REGEXP backward."
7353 (format "Search article backward (regexp%s): "
7354 (if gnus-last-search-regexp
7355 (concat ", default " gnus-last-search-regexp)
7357 (gnus-summary-search-article-forward regexp 'backward))
7359 (defun gnus-summary-search-article (regexp &optional backward)
7360 "Search for an article containing REGEXP.
7361 Optional argument BACKWARD means do search for backward.
7362 `gnus-select-article-hook' is not called during the search."
7363 ;; We have to require this here to make sure that the following
7364 ;; dynamic binding isn't shadowed by autoloading.
7365 (require 'gnus-async)
7367 (let ((gnus-select-article-hook nil) ;Disable hook.
7368 (gnus-article-prepare-hook nil)
7369 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7370 (gnus-use-article-prefetch nil)
7371 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7372 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7373 (sum (current-buffer))
7374 (gnus-display-mime-function nil)
7377 (gnus-save-hidden-threads
7378 (gnus-summary-select-article)
7379 (set-buffer gnus-article-buffer)
7380 (goto-char (window-point (get-buffer-window (current-buffer))))
7384 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7386 (re-search-backward regexp nil t)
7387 (re-search-forward regexp nil t))
7388 ;; We found the regexp.
7393 (get-buffer-window (current-buffer))
7397 (get-buffer-window (current-buffer))
7400 (setq point (point)))
7401 ;; We didn't find it, so we go to the next article.
7404 (while (eq found 'not)
7405 (if (not (if backward (gnus-summary-find-prev)
7406 (gnus-summary-find-next)))
7407 ;; No more articles.
7409 ;; Select the next article and adjust point.
7410 (unless (gnus-summary-article-sparse-p
7411 (gnus-summary-article-number))
7413 (gnus-summary-select-article)
7414 (set-buffer gnus-article-buffer)
7416 (goto-char (if backward (point-max) (point-min))))))))
7417 (gnus-message 7 ""))
7418 ;; Return whether we found the regexp.
7419 (when (eq found 'found)
7421 (gnus-summary-show-thread)
7422 (gnus-summary-goto-subject gnus-current-article)
7423 (gnus-summary-position-point)
7426 (defun gnus-find-matching-articles (header regexp)
7427 "Return a list of all articles that match REGEXP on HEADER.
7428 This search includes all articles in the current group that Gnus has
7429 fetched headers for, whether they are displayed or not."
7430 (let ((articles nil)
7431 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7432 (case-fold-search t))
7433 (dolist (header gnus-newsgroup-headers)
7434 (when (string-match regexp (funcall func header))
7435 (push (mail-header-number header) articles)))
7436 (nreverse articles)))
7438 (defun gnus-summary-find-matching (header regexp &optional backward unread
7440 "Return a list of all articles that match REGEXP on HEADER.
7441 The search stars on the current article and goes forwards unless
7442 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7443 If UNREAD is non-nil, only unread articles will
7444 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7445 in the comparisons."
7446 (let ((case-fold-search (not not-case-fold))
7449 (if (eq (car header) 'extra)
7452 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7454 (error "%s is an invalid header" header))
7455 (unless (fboundp (intern (concat "mail-header-" header)))
7456 (error "%s is not a valid header" header))
7457 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7458 (dolist (d (if (eq backward 'all)
7460 (gnus-data-find-list
7461 (gnus-summary-article-number)
7462 (gnus-data-list backward))))
7463 (when (and (or (not unread) ; We want all articles...
7464 (gnus-data-unread-p d)) ; Or just unreads.
7465 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7466 (string-match regexp
7467 (funcall func (gnus-data-header d)))) ; Match.
7468 (push (gnus-data-number d) articles))) ; Success!
7469 (nreverse articles)))
7471 (defun gnus-summary-execute-command (header regexp command &optional backward)
7472 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7473 If HEADER is an empty string (or nil), the match is done on the entire
7474 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7476 (list (let ((completion-ignore-case t))
7479 (mapcar (lambda (string) (list string))
7480 '("Number" "Subject" "From" "Lines" "Date"
7481 "Message-ID" "Xref" "References" "Body"))
7482 nil 'require-match))
7483 (read-string "Regexp: ")
7484 (read-key-sequence "Command: ")
7485 current-prefix-arg))
7486 (when (equal header "Body")
7488 ;; Hidden thread subtrees must be searched as well.
7489 (gnus-summary-show-all-threads)
7490 ;; We don't want to change current point nor window configuration.
7492 (save-window-excursion
7493 (gnus-message 6 "Executing %s..." (key-description command))
7494 ;; We'd like to execute COMMAND interactively so as to give arguments.
7495 (gnus-execute header regexp
7496 `(call-interactively ',(key-binding command))
7498 (gnus-message 6 "Executing %s...done" (key-description command)))))
7500 (defun gnus-summary-beginning-of-article ()
7501 "Scroll the article back to the beginning."
7503 (gnus-summary-select-article)
7504 (gnus-configure-windows 'article)
7505 (gnus-eval-in-buffer-window gnus-article-buffer
7507 (goto-char (point-min))
7508 (when gnus-page-broken
7509 (gnus-narrow-to-page))))
7511 (defun gnus-summary-end-of-article ()
7512 "Scroll to the end of the article."
7514 (gnus-summary-select-article)
7515 (gnus-configure-windows 'article)
7516 (gnus-eval-in-buffer-window gnus-article-buffer
7518 (goto-char (point-max))
7520 (when gnus-page-broken
7521 (gnus-narrow-to-page))))
7523 (defun gnus-summary-print-article (&optional filename n)
7524 "Generate and print a PostScript image of the N next (mail) articles.
7526 If N is negative, print the N previous articles. If N is nil and articles
7527 have been marked with the process mark, print these instead.
7529 If the optional first argument FILENAME is nil, send the image to the
7530 printer. If FILENAME is a string, save the PostScript image in a file with
7531 that name. If FILENAME is a number, prompt the user for the name of the file
7533 (interactive (list (ps-print-preprint current-prefix-arg)))
7534 (dolist (article (gnus-summary-work-articles n))
7535 (gnus-summary-select-article nil nil 'pseudo article)
7536 (gnus-eval-in-buffer-window gnus-article-buffer
7537 (let ((buffer (generate-new-buffer " *print*")))
7540 (copy-to-buffer buffer (point-min) (point-max))
7542 (gnus-article-delete-invisible-text)
7543 (when (gnus-visual-p 'article-highlight 'highlight)
7544 ;; Copy-to-buffer doesn't copy overlay. So redo
7546 (let ((gnus-article-buffer buffer))
7547 (gnus-article-highlight-citation t)
7548 (gnus-article-highlight-signature)))
7549 (let ((ps-left-header
7552 (mail-header-subject gnus-current-headers) ")")
7554 (mail-header-from gnus-current-headers) ")")))
7557 "/pagenumberstring load"
7559 (mail-header-date gnus-current-headers) ")"))))
7560 (gnus-run-hooks 'gnus-ps-print-hook)
7563 (ps-spool-buffer-with-faces)
7564 (ps-spool-buffer)))))
7565 (kill-buffer buffer))))
7566 (gnus-summary-remove-process-mark article))
7567 (ps-despool filename))
7569 (defun gnus-summary-show-article (&optional arg)
7570 "Force re-fetching of the current article.
7571 If ARG (the prefix) is a number, show the article with the charset
7572 defined in `gnus-summary-show-article-charset-alist', or the charset
7574 If ARG (the prefix) is non-nil and not a number, show the raw article
7575 without any article massaging functions being run."
7579 (let ((gnus-newsgroup-charset
7580 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7581 (read-coding-system "Charset: ")))
7582 (gnus-newsgroup-ignored-charsets 'gnus-all))
7583 (gnus-summary-select-article nil 'force)
7584 (let ((deps gnus-newsgroup-dependencies)
7587 (set-buffer gnus-original-article-buffer)
7589 (message-narrow-to-head)
7590 (setq head (buffer-string)))
7592 (insert (format "211 %d Article retrieved.\n"
7593 (cdr gnus-article-current)))
7596 (let ((nntp-server-buffer (current-buffer)))
7597 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7598 (gnus-data-set-header
7599 (gnus-data-find (cdr gnus-article-current))
7601 (gnus-summary-update-article-line
7602 (cdr gnus-article-current) header))))
7604 ;; Select the article the normal way.
7605 (gnus-summary-select-article nil 'force))
7607 ;; We have to require this here to make sure that the following
7608 ;; dynamic binding isn't shadowed by autoloading.
7609 (require 'gnus-async)
7611 ;; Bind the article treatment functions to nil.
7612 (let ((gnus-have-all-headers t)
7613 gnus-article-prepare-hook
7614 gnus-article-decode-hook
7615 gnus-display-mime-function
7617 ;; Destroy any MIME parts.
7618 (when (gnus-buffer-live-p gnus-article-buffer)
7620 (set-buffer gnus-article-buffer)
7621 (mm-destroy-parts gnus-article-mime-handles)
7622 ;; Set it to nil for safety reason.
7623 (setq gnus-article-mime-handle-alist nil)
7624 (setq gnus-article-mime-handles nil)))
7625 (gnus-summary-select-article nil 'force))))
7626 (gnus-summary-goto-subject gnus-current-article)
7627 (gnus-summary-position-point))
7629 (defun gnus-summary-verbose-headers (&optional arg)
7630 "Toggle permanent full header display.
7631 If ARG is a positive number, turn header display on.
7632 If ARG is a negative number, turn header display off."
7634 (setq gnus-show-all-headers
7635 (cond ((or (not (numberp arg))
7637 (not gnus-show-all-headers))
7640 (gnus-summary-show-article))
7642 (defun gnus-summary-toggle-header (&optional arg)
7643 "Show the headers if they are hidden, or hide them if they are shown.
7644 If ARG is a positive number, show the entire header.
7645 If ARG is a negative number, hide the unwanted header lines."
7648 (set-buffer gnus-article-buffer)
7650 (let* ((buffer-read-only nil)
7651 (inhibit-point-motion-hooks t)
7657 (article-narrow-to-head)
7658 (gnus-article-hidden-text-p 'headers))))
7659 (goto-char (point-min))
7660 (when (search-forward "\n\n" nil t)
7661 (delete-region (point-min) (1- (point))))
7662 (goto-char (point-min))
7664 (set-buffer gnus-original-article-buffer)
7665 (goto-char (point-min))
7666 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7667 (insert-buffer-substring gnus-original-article-buffer 1 e)
7669 (narrow-to-region (point-min) (point))
7670 (article-decode-encoded-words)
7672 (let ((gnus-treat-hide-headers nil)
7673 (gnus-treat-hide-boring-headers nil))
7674 (setq gnus-article-wash-types
7675 (delq 'headers gnus-article-wash-types))
7676 (gnus-treat-article 'head))
7677 (gnus-treat-article 'head)))
7678 (gnus-set-mode-line 'article)))))
7680 (defun gnus-summary-show-all-headers ()
7681 "Make all header lines visible."
7683 (gnus-summary-toggle-header 1))
7685 (defun gnus-summary-caesar-message (&optional arg)
7686 "Caesar rotate the current article by 13.
7687 The numerical prefix specifies how many places to rotate each letter
7690 (gnus-summary-select-article)
7691 (let ((mail-header-separator ""))
7692 (gnus-eval-in-buffer-window gnus-article-buffer
7695 (let ((start (window-start))
7697 (message-caesar-buffer-body arg)
7698 (set-window-start (get-buffer-window (current-buffer)) start))))))
7700 (defun gnus-summary-stop-page-breaking ()
7701 "Stop page breaking in the current article."
7703 (gnus-summary-select-article)
7704 (gnus-eval-in-buffer-window gnus-article-buffer
7706 (when (gnus-visual-p 'page-marker)
7707 (let ((buffer-read-only nil))
7708 (gnus-remove-text-with-property 'gnus-prev)
7709 (gnus-remove-text-with-property 'gnus-next))
7710 (setq gnus-page-broken nil))))
7712 (defun gnus-summary-move-article (&optional n to-newsgroup
7713 select-method action)
7714 "Move the current article to a different newsgroup.
7715 If N is a positive number, move the N next articles.
7716 If N is a negative number, move the N previous articles.
7717 If N is nil and any articles have been marked with the process mark,
7718 move those articles instead.
7719 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7720 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7721 re-spool using this method.
7723 For this function to work, both the current newsgroup and the
7724 newsgroup that you want to move to have to support the `request-move'
7725 and `request-accept' functions.
7727 ACTION can be either `move' (the default), `crosspost' or `copy'."
7730 (setq action 'move))
7731 ;; Disable marking as read.
7732 (let (gnus-mark-article-hook)
7733 (save-window-excursion
7734 (gnus-summary-select-article)))
7735 ;; Check whether the source group supports the required functions.
7736 (cond ((and (eq action 'move)
7737 (not (gnus-check-backend-function
7738 'request-move-article gnus-newsgroup-name)))
7739 (error "The current group does not support article moving"))
7740 ((and (eq action 'crosspost)
7741 (not (gnus-check-backend-function
7742 'request-replace-article gnus-newsgroup-name)))
7743 (error "The current group does not support article editing")))
7744 (let ((articles (gnus-summary-work-articles n))
7745 (prefix (if (gnus-check-backend-function
7746 'request-move-article gnus-newsgroup-name)
7747 (gnus-group-real-prefix gnus-newsgroup-name)
7749 (names '((move "Move" "Moving")
7750 (copy "Copy" "Copying")
7751 (crosspost "Crosspost" "Crossposting")))
7752 (copy-buf (save-excursion
7753 (nnheader-set-temp-buffer " *copy article*")))
7754 art-group to-method new-xref article to-groups)
7755 (unless (assq action names)
7756 (error "Unknown action %s" action))
7757 ;; Read the newsgroup name.
7758 (when (and (not to-newsgroup)
7759 (not select-method))
7761 (gnus-read-move-group-name
7762 (cadr (assq action names))
7763 (symbol-value (intern (format "gnus-current-%s-group" action)))
7765 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7766 (setq to-method (or select-method
7767 (gnus-server-to-method
7768 (gnus-group-method to-newsgroup))))
7769 ;; Check the method we are to move this article to...
7770 (unless (gnus-check-backend-function
7771 'request-accept-article (car to-method))
7772 (error "%s does not support article copying" (car to-method)))
7773 (unless (gnus-check-server to-method)
7774 (error "Can't open server %s" (car to-method)))
7775 (gnus-message 6 "%s to %s: %s..."
7776 (caddr (assq action names))
7777 (or (car select-method) to-newsgroup) articles)
7779 (setq article (pop articles))
7783 ;; Move the article.
7785 ;; Remove this article from future suppression.
7786 (gnus-dup-unsuppress-article article)
7787 (gnus-request-move-article
7788 article ; Article to move
7789 gnus-newsgroup-name ; From newsgroup
7790 (nth 1 (gnus-find-method-for-group
7791 gnus-newsgroup-name)) ; Server
7792 (list 'gnus-request-accept-article
7793 to-newsgroup (list 'quote select-method)
7794 (not articles) t) ; Accept form
7795 (not articles))) ; Only save nov last time
7796 ;; Copy the article.
7799 (set-buffer copy-buf)
7800 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7801 (gnus-request-accept-article
7802 to-newsgroup select-method (not articles) t))))
7803 ;; Crosspost the article.
7804 ((eq action 'crosspost)
7805 (let ((xref (message-tokenize-header
7806 (mail-header-xref (gnus-summary-article-header article))
7808 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7811 (setq xref (list (system-name))))
7814 (mapconcat 'identity
7815 (delete "Xref:" (delete new-xref xref))
7819 (set-buffer copy-buf)
7820 ;; First put the article in the destination group.
7821 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7822 (when (consp (setq art-group
7823 (gnus-request-accept-article
7824 to-newsgroup select-method (not articles))))
7825 (setq new-xref (concat new-xref " " (car art-group)
7826 ":" (cdr art-group)))
7827 ;; Now we have the new Xrefs header, so we insert
7828 ;; it and replace the new article.
7829 (nnheader-replace-header "Xref" new-xref)
7830 (gnus-request-replace-article
7831 (cdr art-group) to-newsgroup (current-buffer))
7835 (gnus-message 1 "Couldn't %s article %s: %s"
7836 (cadr (assq action names)) article
7837 (nnheader-get-report (car to-method))))
7838 ((eq art-group 'junk)
7839 (when (eq action 'move)
7840 (gnus-summary-mark-article article gnus-canceled-mark)
7841 (gnus-message 4 "Deleted article %s" article)))
7843 (let* ((pto-group (gnus-group-prefixed-name
7844 (car art-group) to-method))
7846 (gnus-gethash pto-group gnus-newsrc-hashtb))
7847 (info (nth 2 entry))
7848 (to-group (gnus-info-group info))
7850 ;; Update the group that has been moved to.
7852 (memq action '(move copy)))
7853 (unless (member to-group to-groups)
7854 (push to-group to-groups))
7856 (unless (memq article gnus-newsgroup-unreads)
7857 (push 'read to-marks)
7859 info (gnus-add-to-range (gnus-info-read info)
7860 (list (cdr art-group)))))
7862 ;; See whether the article is to be put in the cache.
7863 (let ((marks gnus-article-mark-lists)
7864 (to-article (cdr art-group)))
7866 ;; Enter the article into the cache in the new group,
7867 ;; if that is required.
7868 (when gnus-use-cache
7869 (gnus-cache-possibly-enter-article
7871 (memq article gnus-newsgroup-marked)
7872 (memq article gnus-newsgroup-dormant)
7873 (memq article gnus-newsgroup-unreads)))
7875 (when gnus-preserve-marks
7876 ;; Copy any marks over to the new group.
7877 (when (and (equal to-group gnus-newsgroup-name)
7878 (not (memq article gnus-newsgroup-unreads)))
7879 ;; Mark this article as read in this group.
7880 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7881 (setcdr (gnus-active to-group) to-article)
7882 (setcdr gnus-newsgroup-active to-article))
7885 (when (memq article (symbol-value
7886 (intern (format "gnus-newsgroup-%s"
7888 (push (cdar marks) to-marks)
7889 ;; If the other group is the same as this group,
7890 ;; then we have to add the mark to the list.
7891 (when (equal to-group gnus-newsgroup-name)
7892 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7895 (intern (format "gnus-newsgroup-%s"
7897 ;; Copy the marks to other group.
7898 (gnus-add-marked-articles
7899 to-group (cdar marks) (list to-article) info))
7900 (setq marks (cdr marks)))
7902 (gnus-request-set-mark to-group (list (list (list to-article)
7907 (concat "(gnus-group-set-info '"
7908 (gnus-prin1-to-string (gnus-get-info to-group))
7911 ;; Update the Xref header in this article to point to
7912 ;; the new crossposted article we have just created.
7913 (when (eq action 'crosspost)
7915 (set-buffer copy-buf)
7916 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7917 (nnheader-replace-header "Xref" new-xref)
7918 (gnus-request-replace-article
7919 article gnus-newsgroup-name (current-buffer)))))
7921 ;;;!!!Why is this necessary?
7922 (set-buffer gnus-summary-buffer)
7924 (gnus-summary-goto-subject article)
7925 (when (eq action 'move)
7926 (gnus-summary-mark-article article gnus-canceled-mark))))
7927 (gnus-summary-remove-process-mark article))
7928 ;; Re-activate all groups that have been moved to.
7931 (set-buffer gnus-group-buffer)
7932 (when (gnus-group-goto-group (car to-groups) t)
7933 (gnus-group-get-new-news-this-group 1 t))
7936 (gnus-kill-buffer copy-buf)
7937 (gnus-summary-position-point)
7938 (gnus-set-mode-line 'summary)))
7940 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7941 "Move the current article to a different newsgroup.
7942 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7943 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7944 re-spool using this method."
7946 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7948 (defun gnus-summary-crosspost-article (&optional n)
7949 "Crosspost the current article to some other group."
7951 (gnus-summary-move-article n nil nil 'crosspost))
7953 (defcustom gnus-summary-respool-default-method nil
7954 "Default method for respooling an article.
7955 If nil, use to the current newsgroup method."
7956 :type '(choice (gnus-select-method :value (nnml ""))
7958 :group 'gnus-summary-mail)
7960 (defun gnus-summary-respool-article (&optional n method)
7961 "Respool the current article.
7962 The article will be squeezed through the mail spooling process again,
7963 which means that it will be put in some mail newsgroup or other
7964 depending on `nnmail-split-methods'.
7965 If N is a positive number, respool the N next articles.
7966 If N is a negative number, respool the N previous articles.
7967 If N is nil and any articles have been marked with the process mark,
7968 respool those articles instead.
7970 Respooling can be done both from mail groups and \"real\" newsgroups.
7971 In the former case, the articles in question will be moved from the
7972 current group into whatever groups they are destined to. In the
7973 latter case, they will be copied into the relevant groups."
7975 (list current-prefix-arg
7976 (let* ((methods (gnus-methods-using 'respool))
7978 (symbol-name (or gnus-summary-respool-default-method
7979 (car (gnus-find-method-for-group
7980 gnus-newsgroup-name)))))
7982 (gnus-completing-read
7983 methname "What backend do you want to use when respooling?"
7984 methods nil t nil 'gnus-mail-method-history))
7987 ((zerop (length (setq ms (gnus-servers-using-backend
7989 (list (intern method) ""))
7993 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7994 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7997 (error "No method given for respooling"))
7998 (if (assoc (symbol-name
7999 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8000 (gnus-methods-using 'respool))
8001 (gnus-summary-move-article n nil method)
8002 (gnus-summary-copy-article n nil method)))
8004 (defun gnus-summary-import-article (file &optional edit)
8005 "Import an arbitrary file into a mail newsgroup."
8006 (interactive "fImport file: \nP")
8007 (let ((group gnus-newsgroup-name)
8008 (now (current-time))
8009 atts lines group-art)
8010 (unless (gnus-check-backend-function 'request-accept-article group)
8011 (error "%s does not support article importing" group))
8012 (or (file-readable-p file)
8013 (not (file-regular-p file))
8014 (error "Can't read %s" file))
8016 (set-buffer (gnus-get-buffer-create " *import file*"))
8018 (nnheader-insert-file-contents file)
8019 (goto-char (point-min))
8020 (unless (nnheader-article-p)
8021 ;; This doesn't look like an article, so we fudge some headers.
8022 (setq atts (file-attributes file)
8023 lines (count-lines (point-min) (point-max)))
8024 (insert "From: " (read-string "From: ") "\n"
8025 "Subject: " (read-string "Subject: ") "\n"
8026 "Date: " (message-make-date (nth 5 atts)) "\n"
8027 "Message-ID: " (message-make-message-id) "\n"
8028 "Lines: " (int-to-string lines) "\n"
8029 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8030 (setq group-art (gnus-request-accept-article group nil t))
8031 (kill-buffer (current-buffer)))
8032 (setq gnus-newsgroup-active (gnus-activate-group group))
8034 (gnus-summary-goto-article (cdr group-art) nil t)
8036 (gnus-summary-edit-article))))
8038 (defun gnus-summary-create-article ()
8039 "Create an article in a mail newsgroup."
8041 (let ((group gnus-newsgroup-name)
8042 (now (current-time))
8044 (unless (gnus-check-backend-function 'request-accept-article group)
8045 (error "%s does not support article importing" group))
8047 (set-buffer (gnus-get-buffer-create " *import file*"))
8049 (goto-char (point-min))
8050 ;; This doesn't look like an article, so we fudge some headers.
8051 (insert "From: " (read-string "From: ") "\n"
8052 "Subject: " (read-string "Subject: ") "\n"
8053 "Date: " (message-make-date now) "\n"
8054 "Message-ID: " (message-make-message-id) "\n")
8055 (setq group-art (gnus-request-accept-article group nil t))
8056 (kill-buffer (current-buffer)))
8057 (setq gnus-newsgroup-active (gnus-activate-group group))
8059 (gnus-summary-goto-article (cdr group-art) nil t)
8060 (gnus-summary-edit-article)))
8062 (defun gnus-summary-article-posted-p ()
8063 "Say whether the current (mail) article is available from news as well.
8064 This will be the case if the article has both been mailed and posted."
8066 (let ((id (mail-header-references (gnus-summary-article-header)))
8067 (gnus-override-method (car (gnus-refer-article-methods))))
8068 (if (gnus-request-head id "")
8069 (gnus-message 2 "The current message was found on %s"
8070 gnus-override-method)
8071 (gnus-message 2 "The current message couldn't be found on %s"
8072 gnus-override-method)
8075 (defun gnus-summary-expire-articles (&optional now)
8076 "Expire all articles that are marked as expirable in the current group."
8078 (when (gnus-check-backend-function
8079 'request-expire-articles gnus-newsgroup-name)
8080 ;; This backend supports expiry.
8081 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8082 (expirable (if total
8084 ;; We need to update the info for
8085 ;; this group for `gnus-list-of-read-articles'
8086 ;; to give us the right answer.
8087 (gnus-run-hooks 'gnus-exit-group-hook)
8088 (gnus-summary-update-info)
8089 (gnus-list-of-read-articles gnus-newsgroup-name))
8090 (setq gnus-newsgroup-expirable
8091 (sort gnus-newsgroup-expirable '<))))
8092 (expiry-wait (if now 'immediate
8093 (gnus-group-find-parameter
8094 gnus-newsgroup-name 'expiry-wait)))
8095 (nnmail-expiry-target
8096 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8097 nnmail-expiry-target))
8100 ;; There are expirable articles in this group, so we run them
8101 ;; through the expiry process.
8102 (gnus-message 6 "Expiring articles...")
8103 (unless (gnus-check-group gnus-newsgroup-name)
8104 (error "Can't open server for %s" gnus-newsgroup-name))
8105 ;; The list of articles that weren't expired is returned.
8108 (let ((nnmail-expiry-wait-function nil)
8109 (nnmail-expiry-wait expiry-wait))
8110 (setq es (gnus-request-expire-articles
8111 expirable gnus-newsgroup-name)))
8112 (setq es (gnus-request-expire-articles
8113 expirable gnus-newsgroup-name)))
8115 (setq gnus-newsgroup-expirable es))
8116 ;; We go through the old list of expirable, and mark all
8117 ;; really expired articles as nonexistent.
8118 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8119 (let ((gnus-use-cache nil))
8121 (unless (memq (car expirable) es)
8122 (when (gnus-data-find (car expirable))
8123 (gnus-summary-mark-article
8124 (car expirable) gnus-canceled-mark)))
8125 (setq expirable (cdr expirable))))))
8126 (gnus-message 6 "Expiring articles...done")))))
8128 (defun gnus-summary-expire-articles-now ()
8129 "Expunge all expirable articles in the current group.
8130 This means that *all* articles that are marked as expirable will be
8131 deleted forever, right now."
8133 (or gnus-expert-user
8135 "Are you really, really, really sure you want to delete all these messages? ")
8137 (gnus-summary-expire-articles t))
8139 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8140 (defun gnus-summary-delete-article (&optional n)
8141 "Delete the N next (mail) articles.
8142 This command actually deletes articles. This is not a marking
8143 command. The article will disappear forever from your life, never to
8145 If N is negative, delete backwards.
8146 If N is nil and articles have been marked with the process mark,
8147 delete these instead."
8149 (unless (gnus-check-backend-function 'request-expire-articles
8150 gnus-newsgroup-name)
8151 (error "The current newsgroup does not support article deletion"))
8152 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8153 (error "Couldn't open server"))
8154 ;; Compute the list of articles to delete.
8155 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8157 (if (and gnus-novice-user
8158 (not (gnus-yes-or-no-p
8159 (format "Do you really want to delete %s forever? "
8160 (if (> (length articles) 1)
8161 (format "these %s articles" (length articles))
8164 ;; Delete the articles.
8165 (setq not-deleted (gnus-request-expire-articles
8166 articles gnus-newsgroup-name 'force))
8168 (gnus-summary-remove-process-mark (car articles))
8169 ;; The backend might not have been able to delete the article
8171 (unless (memq (car articles) not-deleted)
8172 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8173 (setq articles (cdr articles)))
8175 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8176 (gnus-summary-position-point)
8177 (gnus-set-mode-line 'summary)
8180 (defun gnus-summary-edit-article (&optional arg)
8181 "Edit the current article.
8182 This will have permanent effect only in mail groups.
8183 If ARG is nil, edit the decoded articles.
8184 If ARG is 1, edit the raw articles.
8185 If ARG is 2, edit the raw articles even in read-only groups.
8186 If ARG is 3, edit the articles with the current handles.
8187 Otherwise, allow editing of articles even in read-only
8190 (let (force raw current-handles)
8193 ((eq arg 1) (setq raw t))
8194 ((eq arg 2) (setq raw t
8196 ((eq arg 3) (setq current-handles
8197 (and (gnus-buffer-live-p gnus-article-buffer)
8198 (with-current-buffer gnus-article-buffer
8200 gnus-article-mime-handles
8201 (setq gnus-article-mime-handles nil))))))
8203 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8204 (error "Can't edit the raw article in group nndraft:drafts."))
8206 (set-buffer gnus-summary-buffer)
8207 (let ((mail-parse-charset gnus-newsgroup-charset)
8208 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8209 (gnus-set-global-variables)
8210 (when (and (not force)
8211 (gnus-group-read-only-p))
8212 (error "The current newsgroup does not support article editing"))
8213 (gnus-summary-show-article t)
8214 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8215 (with-current-buffer gnus-article-buffer
8216 (mm-enable-multibyte-mule4)))
8217 (if (equal gnus-newsgroup-name "nndraft:drafts")
8219 (gnus-article-edit-article
8222 (let ((mbl mml-buffer-list))
8223 (setq mml-buffer-list nil)
8224 (mime-to-mml ,'current-handles)
8225 (make-local-hook 'kill-buffer-hook)
8226 (let ((mbl1 mml-buffer-list))
8227 (setq mml-buffer-list mbl)
8228 (set (make-local-variable 'mml-buffer-list) mbl1))
8229 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8230 `(lambda (no-highlight)
8231 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8232 (message-options message-options)
8233 (message-options-set-recipient)
8234 (mail-parse-ignored-charsets
8235 ',gnus-newsgroup-ignored-charsets))
8236 ,(if (not raw) '(progn
8238 (mml-destroy-buffers)
8239 (remove-hook 'kill-buffer-hook
8240 'mml-destroy-buffers t)
8241 (kill-local-variable 'mml-buffer-list)))
8242 (gnus-summary-edit-article-done
8243 ,(or (mail-header-references gnus-current-headers) "")
8244 ,(gnus-group-read-only-p)
8245 ,gnus-summary-buffer no-highlight))))))))
8247 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8249 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8251 "Make edits to the current article permanent."
8254 ;; The buffer restriction contains the entire article if it exists.
8255 (when (article-goto-body)
8256 (let ((lines (count-lines (point) (point-max)))
8257 (length (- (point-max) (point)))
8258 (case-fold-search t)
8259 (body (copy-marker (point))))
8260 (goto-char (point-min))
8261 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8262 (delete-region (match-beginning 1) (match-end 1))
8263 (insert (number-to-string length)))
8264 (goto-char (point-min))
8265 (when (re-search-forward
8266 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8267 (delete-region (match-beginning 1) (match-end 1))
8268 (insert (number-to-string length)))
8269 (goto-char (point-min))
8270 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8271 (delete-region (match-beginning 1) (match-end 1))
8272 (insert (number-to-string lines))))))
8273 ;; Replace the article.
8274 (let ((buf (current-buffer)))
8276 (insert-buffer-substring buf)
8278 (if (and (not read-only)
8279 (not (gnus-request-replace-article
8280 (cdr gnus-article-current) (car gnus-article-current)
8281 (current-buffer) t)))
8282 (error "Couldn't replace article")
8283 ;; Update the summary buffer.
8285 (equal (message-tokenize-header references " ")
8286 (message-tokenize-header
8287 (or (message-fetch-field "references") "") " ")))
8288 ;; We only have to update this line.
8291 (message-narrow-to-head)
8292 (let ((head (buffer-string))
8295 (insert (format "211 %d Article retrieved.\n"
8296 (cdr gnus-article-current)))
8299 (let ((nntp-server-buffer (current-buffer)))
8300 (setq header (car (gnus-get-newsgroup-headers
8302 (set-buffer gnus-summary-buffer)
8303 gnus-newsgroup-dependencies)
8306 (set-buffer gnus-summary-buffer)
8307 (gnus-data-set-header
8308 (gnus-data-find (cdr gnus-article-current))
8310 (gnus-summary-update-article-line
8311 (cdr gnus-article-current) header))))))
8313 (set-buffer (or buffer gnus-summary-buffer))
8314 (gnus-summary-update-article (cdr gnus-article-current)))
8315 ;; Prettify the article buffer again.
8316 (unless no-highlight
8318 (set-buffer gnus-article-buffer)
8319 ;;;!!! Fix this -- article should be rehighlighted.
8320 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8321 (set-buffer gnus-original-article-buffer)
8322 (gnus-request-article
8323 (cdr gnus-article-current)
8324 (car gnus-article-current) (current-buffer))))
8325 ;; Prettify the summary buffer line.
8326 (when (gnus-visual-p 'summary-highlight 'highlight)
8327 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8329 (defun gnus-summary-edit-wash (key)
8330 "Perform editing command KEY in the article buffer."
8334 (message "%s" (concat (this-command-keys) "- "))
8337 (gnus-summary-edit-article)
8338 (execute-kbd-macro (concat (this-command-keys) key))
8339 (gnus-article-edit-done))
8343 (defun gnus-summary-respool-query (&optional silent trace)
8344 "Query where the respool algorithm would put this article."
8346 (let (gnus-mark-article-hook)
8347 (gnus-summary-select-article)
8349 (set-buffer gnus-original-article-buffer)
8351 (message-narrow-to-head)
8352 (let ((groups (nnmail-article-group 'identity trace)))
8355 (message "This message would go to %s"
8356 (mapconcat 'car groups ", "))
8357 (message "This message would go to no groups"))
8360 (defun gnus-summary-respool-trace ()
8361 "Trace where the respool algorithm would put this article.
8362 Display a buffer showing all fancy splitting patterns which matched."
8364 (gnus-summary-respool-query nil t))
8366 ;; Summary marking commands.
8368 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8369 "Mark articles which has the same subject as read, and then select the next.
8370 If UNMARK is positive, remove any kind of mark.
8371 If UNMARK is negative, tick articles."
8374 (setq unmark (prefix-numeric-value unmark)))
8376 (gnus-summary-mark-same-subject
8377 (gnus-summary-article-subject) unmark)))
8378 ;; Select next unread article. If auto-select-same mode, should
8379 ;; select the first unread article.
8380 (gnus-summary-next-article t (and gnus-auto-select-same
8381 (gnus-summary-article-subject)))
8382 (gnus-message 7 "%d article%s marked as %s"
8383 count (if (= count 1) " is" "s are")
8384 (if unmark "unread" "read"))))
8386 (defun gnus-summary-kill-same-subject (&optional unmark)
8387 "Mark articles which has the same subject as read.
8388 If UNMARK is positive, remove any kind of mark.
8389 If UNMARK is negative, tick articles."
8392 (setq unmark (prefix-numeric-value unmark)))
8394 (gnus-summary-mark-same-subject
8395 (gnus-summary-article-subject) unmark)))
8396 ;; If marked as read, go to next unread subject.
8398 ;; Go to next unread subject.
8399 (gnus-summary-next-subject 1 t))
8400 (gnus-message 7 "%d articles are marked as %s"
8401 count (if unmark "unread" "read"))))
8403 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8404 "Mark articles with same SUBJECT as read, and return marked number.
8405 If optional argument UNMARK is positive, remove any kinds of marks.
8406 If optional argument UNMARK is negative, mark articles as unread instead."
8410 ((null unmark) ; Mark as read.
8413 (gnus-summary-mark-article-as-read gnus-killed-mark)
8414 (gnus-summary-show-thread) t)
8415 (gnus-summary-find-subject subject))
8416 (setq count (1+ count))))
8417 ((> unmark 0) ; Tick.
8420 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8421 (gnus-summary-show-thread) t)
8422 (gnus-summary-find-subject subject))
8423 (setq count (1+ count))))
8424 (t ; Mark as unread.
8427 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8428 (gnus-summary-show-thread) t)
8429 (gnus-summary-find-subject subject))
8430 (setq count (1+ count)))))
8431 (gnus-set-mode-line 'summary)
8432 ;; Return the number of marked articles.
8435 (defun gnus-summary-mark-as-processable (n &optional unmark)
8436 "Set the process mark on the next N articles.
8437 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8438 the process mark instead. The difference between N and the actual
8439 number of articles marked is returned."
8441 (if (and (null n) (gnus-region-active-p))
8442 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8443 (setq n (prefix-numeric-value n))
8444 (let ((backward (< n 0))
8449 (gnus-summary-remove-process-mark
8450 (gnus-summary-article-number))
8451 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8452 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8455 (gnus-message 7 "No more articles"))
8456 (gnus-summary-recenter)
8457 (gnus-summary-position-point)
8460 (defun gnus-summary-unmark-as-processable (n)
8461 "Remove the process mark from the next N articles.
8462 If N is negative, unmark backward instead. The difference between N and
8463 the actual number of articles unmarked is returned."
8465 (gnus-summary-mark-as-processable n t))
8467 (defun gnus-summary-unmark-all-processable ()
8468 "Remove the process mark from all articles."
8471 (while gnus-newsgroup-processable
8472 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8473 (gnus-summary-position-point))
8475 (defun gnus-summary-add-mark (article type)
8476 "Mark ARTICLE with a mark of TYPE."
8477 (let ((vtype (car (assq type gnus-article-mark-lists)))
8480 (error "No such mark type: %s" type)
8481 (setq var (intern (format "gnus-newsgroup-%s" type)))
8482 (set var (cons article (symbol-value var)))
8483 (if (memq type '(processable cached replied forwarded saved))
8484 (gnus-summary-update-secondary-mark article)
8485 ;;; !!! This is bobus. We should find out what primary
8486 ;;; !!! mark we want to set.
8487 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8489 (defun gnus-summary-mark-as-expirable (n)
8490 "Mark N articles forward as expirable.
8491 If N is negative, mark backward instead. The difference between N and
8492 the actual number of articles marked is returned."
8494 (gnus-summary-mark-forward n gnus-expirable-mark))
8496 (defun gnus-summary-mark-article-as-replied (article)
8497 "Mark ARTICLE as replied to and update the summary line.
8498 ARTICLE can also be a list of articles."
8499 (interactive (list (gnus-summary-article-number)))
8500 (let ((articles (if (listp article) article (list article))))
8501 (dolist (article articles)
8502 (push article gnus-newsgroup-replied)
8503 (let ((buffer-read-only nil))
8504 (when (gnus-summary-goto-subject article nil t)
8505 (gnus-summary-update-secondary-mark article))))))
8507 (defun gnus-summary-mark-article-as-forwarded (article)
8508 "Mark ARTICLE as forwarded and update the summary line.
8509 ARTICLE can also be a list of articles."
8510 (let ((articles (if (listp article) article (list article))))
8511 (dolist (article articles)
8512 (push article gnus-newsgroup-forwarded)
8513 (let ((buffer-read-only nil))
8514 (when (gnus-summary-goto-subject article nil t)
8515 (gnus-summary-update-secondary-mark article))))))
8517 (defun gnus-summary-set-bookmark (article)
8518 "Set a bookmark in current article."
8519 (interactive (list (gnus-summary-article-number)))
8520 (when (or (not (get-buffer gnus-article-buffer))
8521 (not gnus-current-article)
8522 (not gnus-article-current)
8523 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8524 (error "No current article selected"))
8525 ;; Remove old bookmark, if one exists.
8526 (let ((old (assq article gnus-newsgroup-bookmarks)))
8528 (setq gnus-newsgroup-bookmarks
8529 (delq old gnus-newsgroup-bookmarks))))
8530 ;; Set the new bookmark, which is on the form
8531 ;; (article-number . line-number-in-body).
8535 (set-buffer gnus-article-buffer)
8539 (goto-char (point-min))
8540 (search-forward "\n\n" nil t)
8543 gnus-newsgroup-bookmarks)
8544 (gnus-message 6 "A bookmark has been added to the current article."))
8546 (defun gnus-summary-remove-bookmark (article)
8547 "Remove the bookmark from the current article."
8548 (interactive (list (gnus-summary-article-number)))
8549 ;; Remove old bookmark, if one exists.
8550 (let ((old (assq article gnus-newsgroup-bookmarks)))
8553 (setq gnus-newsgroup-bookmarks
8554 (delq old gnus-newsgroup-bookmarks))
8555 (gnus-message 6 "Removed bookmark."))
8556 (gnus-message 6 "No bookmark in current article."))))
8558 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8559 (defun gnus-summary-mark-as-dormant (n)
8560 "Mark N articles forward as dormant.
8561 If N is negative, mark backward instead. The difference between N and
8562 the actual number of articles marked is returned."
8564 (gnus-summary-mark-forward n gnus-dormant-mark))
8566 (defun gnus-summary-set-process-mark (article)
8567 "Set the process mark on ARTICLE and update the summary line."
8568 (setq gnus-newsgroup-processable
8570 (delq article gnus-newsgroup-processable)))
8571 (when (gnus-summary-goto-subject article)
8572 (gnus-summary-show-thread)
8573 (gnus-summary-goto-subject article)
8574 (gnus-summary-update-secondary-mark article)))
8576 (defun gnus-summary-remove-process-mark (article)
8577 "Remove the process mark from ARTICLE and update the summary line."
8578 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8579 (when (gnus-summary-goto-subject article)
8580 (gnus-summary-show-thread)
8581 (gnus-summary-goto-subject article)
8582 (gnus-summary-update-secondary-mark article)))
8584 (defun gnus-summary-set-saved-mark (article)
8585 "Set the process mark on ARTICLE and update the summary line."
8586 (push article gnus-newsgroup-saved)
8587 (when (gnus-summary-goto-subject article)
8588 (gnus-summary-update-secondary-mark article)))
8590 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8591 "Mark N articles as read forwards.
8592 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8593 The difference between N and the actual number of articles marked is
8595 Iff NO-EXPIRE, auto-expiry will be inhibited."
8597 (gnus-summary-show-thread)
8598 (let ((backward (< n 0))
8599 (gnus-summary-goto-unread
8600 (and gnus-summary-goto-unread
8601 (not (eq gnus-summary-goto-unread 'never))
8602 (not (memq mark (list gnus-unread-mark
8603 gnus-ticked-mark gnus-dormant-mark)))))
8605 (mark (or mark gnus-del-mark)))
8607 (gnus-summary-mark-article nil mark no-expire)
8608 (zerop (gnus-summary-next-subject
8610 (and gnus-summary-goto-unread
8611 (not (eq gnus-summary-goto-unread 'never)))
8615 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8616 (gnus-summary-recenter)
8617 (gnus-summary-position-point)
8618 (gnus-set-mode-line 'summary)
8621 (defun gnus-summary-mark-article-as-read (mark)
8622 "Mark the current article quickly as read with MARK."
8623 (let ((article (gnus-summary-article-number)))
8624 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8625 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8626 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8627 (push (cons article mark) gnus-newsgroup-reads)
8628 ;; Possibly remove from cache, if that is used.
8629 (when gnus-use-cache
8630 (gnus-cache-enter-remove-article article))
8631 ;; Allow the backend to change the mark.
8632 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8633 ;; Check for auto-expiry.
8634 (when (and gnus-newsgroup-auto-expire
8635 (memq mark gnus-auto-expirable-marks))
8636 (setq mark gnus-expirable-mark)
8637 ;; Let the backend know about the mark change.
8638 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8639 (push article gnus-newsgroup-expirable))
8640 ;; Set the mark in the buffer.
8641 (gnus-summary-update-mark mark 'unread)
8644 (defun gnus-summary-mark-article-as-unread (mark)
8645 "Mark the current article quickly as unread with MARK."
8646 (let* ((article (gnus-summary-article-number))
8647 (old-mark (gnus-summary-article-mark article)))
8648 ;; Allow the backend to change the mark.
8649 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8650 (if (eq mark old-mark)
8654 (gnus-error 1 "Can't mark negative article numbers")
8656 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8657 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8658 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8659 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8660 (cond ((= mark gnus-ticked-mark)
8661 (push article gnus-newsgroup-marked))
8662 ((= mark gnus-dormant-mark)
8663 (push article gnus-newsgroup-dormant))
8665 (push article gnus-newsgroup-unreads)))
8666 (gnus-pull article gnus-newsgroup-reads)
8668 ;; See whether the article is to be put in the cache.
8670 (vectorp (gnus-summary-article-header article))
8672 (gnus-cache-possibly-enter-article
8673 gnus-newsgroup-name article
8674 (= mark gnus-ticked-mark)
8675 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8678 (gnus-summary-update-mark mark 'unread)
8681 (defun gnus-summary-mark-article (&optional article mark no-expire)
8682 "Mark ARTICLE with MARK. MARK can be any character.
8683 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8684 `??' (dormant) and `?E' (expirable).
8685 If MARK is nil, then the default character `?r' is used.
8686 If ARTICLE is nil, then the article on the current line will be
8688 Iff NO-EXPIRE, auto-expiry will be inhibited."
8689 ;; The mark might be a string.
8690 (when (stringp mark)
8691 (setq mark (aref mark 0)))
8692 ;; If no mark is given, then we check auto-expiring.
8694 (setq mark gnus-del-mark))
8695 (when (and (not no-expire)
8696 gnus-newsgroup-auto-expire
8697 (memq mark gnus-auto-expirable-marks))
8698 (setq mark gnus-expirable-mark))
8699 (let ((article (or article (gnus-summary-article-number)))
8700 (old-mark (gnus-summary-article-mark article)))
8701 ;; Allow the backend to change the mark.
8702 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8703 (if (eq mark old-mark)
8706 (error "No article on current line"))
8707 (if (not (if (or (= mark gnus-unread-mark)
8708 (= mark gnus-ticked-mark)
8709 (= mark gnus-dormant-mark))
8710 (gnus-mark-article-as-unread article mark)
8711 (gnus-mark-article-as-read article mark)))
8713 ;; See whether the article is to be put in the cache.
8715 (not (= mark gnus-canceled-mark))
8716 (vectorp (gnus-summary-article-header article))
8718 (gnus-cache-possibly-enter-article
8719 gnus-newsgroup-name article
8720 (= mark gnus-ticked-mark)
8721 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8723 (when (gnus-summary-goto-subject article nil t)
8724 (let ((buffer-read-only nil))
8725 (gnus-summary-show-thread)
8727 (gnus-summary-update-mark mark 'unread)
8730 (defun gnus-summary-update-secondary-mark (article)
8731 "Update the secondary (read, process, cache) mark."
8732 (gnus-summary-update-mark
8733 (cond ((memq article gnus-newsgroup-processable)
8735 ((memq article gnus-newsgroup-cached)
8737 ((memq article gnus-newsgroup-replied)
8739 ((memq article gnus-newsgroup-forwarded)
8740 gnus-forwarded-mark)
8741 ((memq article gnus-newsgroup-saved)
8745 (when (gnus-visual-p 'summary-highlight 'highlight)
8746 (gnus-run-hooks 'gnus-summary-update-hook))
8749 (defun gnus-summary-update-mark (mark type)
8750 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8751 (buffer-read-only nil))
8752 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8754 (when (looking-at "\r")
8756 (when (<= (+ forward (point)) (point-max))
8757 ;; Go to the right position on the line.
8758 (goto-char (+ forward (point)))
8759 ;; Replace the old mark with the new mark.
8760 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8761 ;; Optionally update the marks by some user rule.
8762 (when (eq type 'unread)
8764 (gnus-data-find (gnus-summary-article-number)) mark)
8765 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8767 (defun gnus-mark-article-as-read (article &optional mark)
8768 "Enter ARTICLE in the pertinent lists and remove it from others."
8769 ;; Make the article expirable.
8770 (let ((mark (or mark gnus-del-mark)))
8771 (if (= mark gnus-expirable-mark)
8772 (push article gnus-newsgroup-expirable)
8773 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8774 ;; Remove from unread and marked lists.
8775 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8776 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8777 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8778 (push (cons article mark) gnus-newsgroup-reads)
8779 ;; Possibly remove from cache, if that is used.
8780 (when gnus-use-cache
8781 (gnus-cache-enter-remove-article article))
8784 (defun gnus-mark-article-as-unread (article &optional mark)
8785 "Enter ARTICLE in the pertinent lists and remove it from others."
8786 (let ((mark (or mark gnus-ticked-mark)))
8789 (gnus-error 1 "Can't mark negative article numbers")
8791 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8792 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8793 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8794 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8796 ;; Unsuppress duplicates?
8797 (when gnus-suppress-duplicates
8798 (gnus-dup-unsuppress-article article))
8800 (cond ((= mark gnus-ticked-mark)
8801 (push article gnus-newsgroup-marked))
8802 ((= mark gnus-dormant-mark)
8803 (push article gnus-newsgroup-dormant))
8805 (push article gnus-newsgroup-unreads)))
8806 (gnus-pull article gnus-newsgroup-reads)
8809 (defalias 'gnus-summary-mark-as-unread-forward
8810 'gnus-summary-tick-article-forward)
8811 (make-obsolete 'gnus-summary-mark-as-unread-forward
8812 'gnus-summary-tick-article-forward)
8813 (defun gnus-summary-tick-article-forward (n)
8814 "Tick N articles forwards.
8815 If N is negative, tick backwards instead.
8816 The difference between N and the number of articles ticked is returned."
8818 (gnus-summary-mark-forward n gnus-ticked-mark))
8820 (defalias 'gnus-summary-mark-as-unread-backward
8821 'gnus-summary-tick-article-backward)
8822 (make-obsolete 'gnus-summary-mark-as-unread-backward
8823 'gnus-summary-tick-article-backward)
8824 (defun gnus-summary-tick-article-backward (n)
8825 "Tick N articles backwards.
8826 The difference between N and the number of articles ticked is returned."
8828 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8830 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8831 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8832 (defun gnus-summary-tick-article (&optional article clear-mark)
8833 "Mark current article as unread.
8834 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8835 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8837 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8840 (defun gnus-summary-mark-as-read-forward (n)
8841 "Mark N articles as read forwards.
8842 If N is negative, mark backwards instead.
8843 The difference between N and the actual number of articles marked is
8846 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8848 (defun gnus-summary-mark-as-read-backward (n)
8849 "Mark the N articles as read backwards.
8850 The difference between N and the actual number of articles marked is
8853 (gnus-summary-mark-forward
8854 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8856 (defun gnus-summary-mark-as-read (&optional article mark)
8857 "Mark current article as read.
8858 ARTICLE specifies the article to be marked as read.
8859 MARK specifies a string to be inserted at the beginning of the line."
8860 (gnus-summary-mark-article article mark))
8862 (defun gnus-summary-clear-mark-forward (n)
8863 "Clear marks from N articles forward.
8864 If N is negative, clear backward instead.
8865 The difference between N and the number of marks cleared is returned."
8867 (gnus-summary-mark-forward n gnus-unread-mark))
8869 (defun gnus-summary-clear-mark-backward (n)
8870 "Clear marks from N articles backward.
8871 The difference between N and the number of marks cleared is returned."
8873 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8875 (defun gnus-summary-mark-unread-as-read ()
8876 "Intended to be used by `gnus-summary-mark-article-hook'."
8877 (when (memq gnus-current-article gnus-newsgroup-unreads)
8878 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8880 (defun gnus-summary-mark-read-and-unread-as-read ()
8881 "Intended to be used by `gnus-summary-mark-article-hook'."
8882 (let ((mark (gnus-summary-article-mark)))
8883 (when (or (gnus-unread-mark-p mark)
8884 (gnus-read-mark-p mark))
8885 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8887 (defun gnus-summary-mark-unread-as-ticked ()
8888 "Intended to be used by `gnus-summary-mark-article-hook'."
8889 (when (memq gnus-current-article gnus-newsgroup-unreads)
8890 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
8892 (defun gnus-summary-mark-region-as-read (point mark all)
8893 "Mark all unread articles between point and mark as read.
8894 If given a prefix, mark all articles between point and mark as read,
8895 even ticked and dormant ones."
8896 (interactive "r\nP")
8905 (memq (setq article (gnus-summary-article-number))
8906 gnus-newsgroup-unreads))
8907 (gnus-summary-mark-article article gnus-del-mark))
8909 (gnus-summary-find-next))))))
8911 (defun gnus-summary-mark-below (score mark)
8912 "Mark articles with score less than SCORE with MARK."
8913 (interactive "P\ncMark: ")
8914 (setq score (if score
8915 (prefix-numeric-value score)
8916 (or gnus-summary-default-score 0)))
8918 (set-buffer gnus-summary-buffer)
8919 (goto-char (point-min))
8922 (and (< (gnus-summary-article-score) score)
8923 (gnus-summary-mark-article nil mark))
8924 (gnus-summary-find-next)))))
8926 (defun gnus-summary-kill-below (&optional score)
8927 "Mark articles with score below SCORE as read."
8929 (gnus-summary-mark-below score gnus-killed-mark))
8931 (defun gnus-summary-clear-above (&optional score)
8932 "Clear all marks from articles with score above SCORE."
8934 (gnus-summary-mark-above score gnus-unread-mark))
8936 (defun gnus-summary-tick-above (&optional score)
8937 "Tick all articles with score above SCORE."
8939 (gnus-summary-mark-above score gnus-ticked-mark))
8941 (defun gnus-summary-mark-above (score mark)
8942 "Mark articles with score over SCORE with MARK."
8943 (interactive "P\ncMark: ")
8944 (setq score (if score
8945 (prefix-numeric-value score)
8946 (or gnus-summary-default-score 0)))
8948 (set-buffer gnus-summary-buffer)
8949 (goto-char (point-min))
8951 (when (> (gnus-summary-article-score) score)
8952 (gnus-summary-mark-article nil mark))
8954 (gnus-summary-find-next)))))
8956 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8957 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8958 (defun gnus-summary-limit-include-expunged (&optional no-error)
8959 "Display all the hidden articles that were expunged for low scores."
8961 (let ((buffer-read-only nil))
8962 (let ((scored gnus-newsgroup-scored)
8965 (unless (gnus-summary-article-header (caar scored))
8966 (and (setq h (gnus-number-to-header (caar scored)))
8967 (< (cdar scored) gnus-summary-expunge-below)
8969 (setq scored (cdr scored)))
8971 (when (not no-error)
8972 (error "No expunged articles hidden"))
8973 (goto-char (point-min))
8974 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8975 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
8976 (mapcar (lambda (x) (push (mail-header-number x)
8977 gnus-newsgroup-limit))
8979 (gnus-summary-prepare-unthreaded (nreverse headers))
8980 (goto-char (point-min))
8981 (gnus-summary-position-point)
8984 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8985 "Mark all unread articles in this newsgroup as read.
8986 If prefix argument ALL is non-nil, ticked and dormant articles will
8987 also be marked as read.
8988 If QUIETLY is non-nil, no questions will be asked.
8989 If TO-HERE is non-nil, it should be a point in the buffer. All
8990 articles before this point will be marked as read.
8991 Note that this function will only catch up the unread article
8992 in the current summary buffer limitation.
8993 The number of articles marked as read is returned."
8998 (not gnus-interactive-catchup) ;Without confirmation?
9002 "Mark absolutely all articles as read? "
9003 "Mark all unread articles as read? ")))
9005 (not gnus-newsgroup-adaptive)
9006 (not gnus-newsgroup-auto-expire)
9007 (not gnus-suppress-duplicates)
9008 (or (not gnus-use-cache)
9009 (eq gnus-use-cache 'passive)))
9012 (setq gnus-newsgroup-marked nil
9013 gnus-newsgroup-dormant nil))
9014 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9015 ;; We actually mark all articles as canceled, which we
9016 ;; have to do when using auto-expiry or adaptive scoring.
9017 (gnus-summary-show-all-threads)
9018 (when (gnus-summary-first-subject (not all) t)
9020 (if to-here (< (point) to-here) t)
9021 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9022 (gnus-summary-find-next (not all) nil nil t))))
9023 (gnus-set-mode-line 'summary))
9025 (gnus-summary-position-point)))
9027 (defun gnus-summary-catchup-to-here (&optional all)
9028 "Mark all unticked articles before the current one as read.
9029 If ALL is non-nil, also mark ticked and dormant articles as read."
9032 (gnus-save-hidden-threads
9033 (let ((beg (point)))
9034 ;; We check that there are unread articles.
9035 (when (or all (gnus-summary-find-prev))
9036 (gnus-summary-catchup all t beg)))))
9037 (gnus-summary-position-point))
9039 (defun gnus-summary-catchup-all (&optional quietly)
9040 "Mark all articles in this newsgroup as read."
9042 (gnus-summary-catchup t quietly))
9044 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9045 "Mark all unread articles in this group as read, then exit.
9046 If prefix argument ALL is non-nil, all articles are marked as read.
9047 If QUIETLY is non-nil, no questions will be asked."
9049 (when (gnus-summary-catchup all quietly nil 'fast)
9050 ;; Select next newsgroup or exit.
9051 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9052 (eq gnus-auto-select-next 'quietly))
9053 (gnus-summary-next-group nil)
9054 (gnus-summary-exit))))
9056 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9057 "Mark all articles in this newsgroup as read, and then exit."
9059 (gnus-summary-catchup-and-exit t quietly))
9061 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9062 "Mark all articles in this group as read and select the next group.
9063 If given a prefix, mark all articles, unread as well as ticked, as
9067 (gnus-summary-catchup all))
9068 (gnus-summary-next-group))
9074 (defmacro gnus-with-article (article &rest forms)
9075 "Select ARTICLE and perform FORMS in the original article buffer.
9076 Then replace the article with the result."
9078 ;; We don't want the article to be marked as read.
9079 (let (gnus-mark-article-hook)
9080 (gnus-summary-select-article t t nil ,article))
9081 (set-buffer gnus-original-article-buffer)
9083 (if (not (gnus-check-backend-function
9084 'request-replace-article (car gnus-article-current)))
9085 (gnus-message 5 "Read-only group; not replacing")
9086 (unless (gnus-request-replace-article
9087 ,article (car gnus-article-current)
9089 (error "Couldn't replace article")))
9090 ;; The cache and backlog have to be flushed somewhat.
9091 (when gnus-keep-backlog
9092 (gnus-backlog-remove-article
9093 (car gnus-article-current) (cdr gnus-article-current)))
9094 (when gnus-use-cache
9095 (gnus-cache-update-article
9096 (car gnus-article-current) (cdr gnus-article-current)))))
9098 (put 'gnus-with-article 'lisp-indent-function 1)
9099 (put 'gnus-with-article 'edebug-form-spec '(form body))
9101 ;; Thread-based commands.
9103 (defun gnus-summary-articles-in-thread (&optional article)
9104 "Return a list of all articles in the current thread.
9105 If ARTICLE is non-nil, return all articles in the thread that starts
9107 (let* ((article (or article (gnus-summary-article-number)))
9108 (data (gnus-data-find-list article))
9109 (top-level (gnus-data-level (car data)))
9111 (cond ((null gnus-thread-operation-ignore-subject)
9112 (gnus-simplify-subject-re
9113 (mail-header-subject (gnus-data-header (car data)))))
9114 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9115 (gnus-simplify-subject-fuzzy
9116 (mail-header-subject (gnus-data-header (car data)))))
9118 (end-point (save-excursion
9119 (if (gnus-summary-go-to-next-thread)
9120 (point) (point-max))))
9123 (< (gnus-data-pos (car data)) end-point))
9124 (when (or (not top-subject)
9125 (string= top-subject
9126 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9127 (gnus-simplify-subject-fuzzy
9128 (mail-header-subject
9129 (gnus-data-header (car data))))
9130 (gnus-simplify-subject-re
9131 (mail-header-subject
9132 (gnus-data-header (car data)))))))
9133 (push (gnus-data-number (car data)) articles))
9134 (unless (and (setq data (cdr data))
9135 (> (gnus-data-level (car data)) top-level))
9137 ;; Return the list of articles.
9138 (nreverse articles)))
9140 (defun gnus-summary-rethread-current ()
9141 "Rethread the thread the current article is part of."
9143 (let* ((gnus-show-threads t)
9144 (article (gnus-summary-article-number))
9145 (id (mail-header-id (gnus-summary-article-header)))
9146 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9148 (error "No article on the current line"))
9149 (gnus-rebuild-thread id)
9150 (gnus-summary-goto-subject article)))
9152 (defun gnus-summary-reparent-thread ()
9153 "Make the current article child of the marked (or previous) article.
9155 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9156 is non-nil or the Subject: of both articles are the same."
9158 (unless (not (gnus-group-read-only-p))
9159 (error "The current newsgroup does not support article editing"))
9160 (unless (<= (length gnus-newsgroup-processable) 1)
9161 (error "No more than one article may be marked"))
9162 (save-window-excursion
9163 (let ((gnus-article-buffer " *reparent*")
9164 (current-article (gnus-summary-article-number))
9165 ;; First grab the marked article, otherwise one line up.
9166 (parent-article (if (not (null gnus-newsgroup-processable))
9167 (car gnus-newsgroup-processable)
9169 (if (eq (forward-line -1) 0)
9170 (gnus-summary-article-number)
9171 (error "Beginning of summary buffer"))))))
9172 (unless (not (eq current-article parent-article))
9173 (error "An article may not be self-referential"))
9174 (let ((message-id (mail-header-id
9175 (gnus-summary-article-header parent-article))))
9176 (unless (and message-id (not (equal message-id "")))
9177 (error "No message-id in desired parent"))
9178 (gnus-with-article current-article
9180 (goto-char (point-min))
9181 (message-narrow-to-head)
9182 (if (re-search-forward "^References: " nil t)
9184 (re-search-forward "^[^ \t]" nil t)
9187 (insert " " message-id))
9188 (insert "References: " message-id "\n"))))
9189 (set-buffer gnus-summary-buffer)
9190 (gnus-summary-unmark-all-processable)
9191 (gnus-summary-update-article current-article)
9192 (gnus-summary-rethread-current)
9193 (gnus-message 3 "Article %d is now the child of article %d"
9194 current-article parent-article)))))
9196 (defun gnus-summary-toggle-threads (&optional arg)
9197 "Toggle showing conversation threads.
9198 If ARG is positive number, turn showing conversation threads on."
9200 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9201 (setq gnus-show-threads
9202 (if (null arg) (not gnus-show-threads)
9203 (> (prefix-numeric-value arg) 0)))
9204 (gnus-summary-prepare)
9205 (gnus-summary-goto-subject current)
9206 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9207 (gnus-summary-position-point)))
9209 (defun gnus-summary-show-all-threads ()
9213 (let ((buffer-read-only nil))
9214 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9215 (gnus-summary-position-point))
9217 (defun gnus-summary-show-thread ()
9218 "Show thread subtrees.
9219 Returns nil if no thread was there to be shown."
9221 (let ((buffer-read-only nil)
9223 ;; first goto end then to beg, to have point at beg after let
9224 (end (progn (end-of-line) (point)))
9225 (beg (progn (beginning-of-line) (point))))
9227 ;; Any hidden lines here?
9228 (search-forward "\r" end t)
9229 (subst-char-in-region beg end ?\^M ?\n t)
9231 (gnus-summary-position-point))))
9233 (defun gnus-summary-hide-all-threads ()
9234 "Hide all thread subtrees."
9237 (goto-char (point-min))
9238 (gnus-summary-hide-thread)
9239 (while (zerop (gnus-summary-next-thread 1 t))
9240 (gnus-summary-hide-thread)))
9241 (gnus-summary-position-point))
9243 (defun gnus-summary-hide-thread ()
9244 "Hide thread subtrees.
9245 Returns nil if no threads were there to be hidden."
9247 (let ((buffer-read-only nil)
9249 (article (gnus-summary-article-number)))
9251 ;; Go forward until either the buffer ends or the subthread
9253 (when (and (not (eobp))
9254 (or (zerop (gnus-summary-next-thread 1 t))
9255 (goto-char (point-max))))
9257 (if (and (> (point) start)
9258 (search-backward "\n" start t))
9260 (subst-char-in-region start (point) ?\n ?\^M)
9261 (gnus-summary-goto-subject article))
9265 (defun gnus-summary-go-to-next-thread (&optional previous)
9266 "Go to the same level (or less) next thread.
9267 If PREVIOUS is non-nil, go to previous thread instead.
9268 Return the article number moved to, or nil if moving was impossible."
9269 (let ((level (gnus-summary-thread-level))
9270 (way (if previous -1 1))
9273 (while (and (not (eobp))
9274 (< level (gnus-summary-thread-level)))
9282 (gnus-summary-article-number)
9285 (defun gnus-summary-next-thread (n &optional silent)
9286 "Go to the same level next N'th thread.
9287 If N is negative, search backward instead.
9288 Returns the difference between N and the number of skips actually
9291 If SILENT, don't output messages."
9293 (let ((backward (< n 0))
9296 (gnus-summary-go-to-next-thread backward))
9299 (gnus-summary-position-point))
9300 (when (and (not silent) (/= 0 n))
9301 (gnus-message 7 "No more threads"))
9304 (defun gnus-summary-prev-thread (n)
9305 "Go to the same level previous N'th thread.
9306 Returns the difference between N and the number of skips actually
9309 (gnus-summary-next-thread (- n)))
9311 (defun gnus-summary-go-down-thread ()
9312 "Go down one level in the current thread."
9313 (let ((children (gnus-summary-article-children)))
9315 (gnus-summary-goto-subject (car children)))))
9317 (defun gnus-summary-go-up-thread ()
9318 "Go up one level in the current thread."
9319 (let ((parent (gnus-summary-article-parent)))
9321 (gnus-summary-goto-subject parent))))
9323 (defun gnus-summary-down-thread (n)
9324 "Go down thread N steps.
9325 If N is negative, go up instead.
9326 Returns the difference between N and how many steps down that were
9332 (if up (gnus-summary-go-up-thread)
9333 (gnus-summary-go-down-thread)))
9335 (gnus-summary-position-point)
9337 (gnus-message 7 "Can't go further"))
9340 (defun gnus-summary-up-thread (n)
9341 "Go up thread N steps.
9342 If N is negative, go down instead.
9343 Returns the difference between N and how many steps down that were
9346 (gnus-summary-down-thread (- n)))
9348 (defun gnus-summary-top-thread ()
9349 "Go to the top of the thread."
9351 (while (gnus-summary-go-up-thread))
9352 (gnus-summary-article-number))
9354 (defun gnus-summary-kill-thread (&optional unmark)
9355 "Mark articles under current thread as read.
9356 If the prefix argument is positive, remove any kinds of marks.
9357 If the prefix argument is negative, tick articles instead."
9360 (setq unmark (prefix-numeric-value unmark)))
9361 (let ((articles (gnus-summary-articles-in-thread)))
9363 ;; Expand the thread.
9364 (gnus-summary-show-thread)
9365 ;; Mark all the articles.
9367 (gnus-summary-goto-subject (car articles))
9368 (cond ((null unmark)
9369 (gnus-summary-mark-article-as-read gnus-killed-mark))
9371 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9373 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9374 (setq articles (cdr articles))))
9375 ;; Hide killed subtrees.
9377 gnus-thread-hide-killed
9378 (gnus-summary-hide-thread))
9379 ;; If marked as read, go to next unread subject.
9381 ;; Go to next unread subject.
9382 (gnus-summary-next-subject 1 t)))
9383 (gnus-set-mode-line 'summary))
9385 ;; Summary sorting commands
9387 (defun gnus-summary-sort-by-number (&optional reverse)
9388 "Sort the summary buffer by article number.
9389 Argument REVERSE means reverse order."
9391 (gnus-summary-sort 'number reverse))
9393 (defun gnus-summary-sort-by-author (&optional reverse)
9394 "Sort the summary buffer by author name alphabetically.
9395 If `case-fold-search' is non-nil, case of letters is ignored.
9396 Argument REVERSE means reverse order."
9398 (gnus-summary-sort 'author reverse))
9400 (defun gnus-summary-sort-by-subject (&optional reverse)
9401 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9402 If `case-fold-search' is non-nil, case of letters is ignored.
9403 Argument REVERSE means reverse order."
9405 (gnus-summary-sort 'subject reverse))
9407 (defun gnus-summary-sort-by-date (&optional reverse)
9408 "Sort the summary buffer by date.
9409 Argument REVERSE means reverse order."
9411 (gnus-summary-sort 'date reverse))
9413 (defun gnus-summary-sort-by-score (&optional reverse)
9414 "Sort the summary buffer by score.
9415 Argument REVERSE means reverse order."
9417 (gnus-summary-sort 'score reverse))
9419 (defun gnus-summary-sort-by-lines (&optional reverse)
9420 "Sort the summary buffer by the number of lines.
9421 Argument REVERSE means reverse order."
9423 (gnus-summary-sort 'lines reverse))
9425 (defun gnus-summary-sort-by-chars (&optional reverse)
9426 "Sort the summary buffer by article length.
9427 Argument REVERSE means reverse order."
9429 (gnus-summary-sort 'chars reverse))
9431 (defun gnus-summary-sort-by-original (&optional reverse)
9432 "Sort the summary buffer using the default sorting method.
9433 Argument REVERSE means reverse order."
9435 (let* ((buffer-read-only)
9436 (gnus-summary-prepare-hook nil))
9437 ;; We do the sorting by regenerating the threads.
9438 (gnus-summary-prepare)
9439 ;; Hide subthreads if needed.
9440 (when (and gnus-show-threads gnus-thread-hide-subtree)
9441 (gnus-summary-hide-all-threads))))
9443 (defun gnus-summary-sort (predicate reverse)
9444 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9445 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9446 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9447 (gnus-thread-sort-functions
9452 (gnus-sort-gathered-threads-function
9453 gnus-thread-sort-functions)
9454 (gnus-article-sort-functions
9460 (gnus-summary-prepare-hook nil))
9461 ;; We do the sorting by regenerating the threads.
9462 (gnus-summary-prepare)
9463 ;; Hide subthreads if needed.
9464 (when (and gnus-show-threads gnus-thread-hide-subtree)
9465 (gnus-summary-hide-all-threads))))
9467 ;; Summary saving commands.
9469 (defun gnus-summary-save-article (&optional n not-saved)
9470 "Save the current article using the default saver function.
9471 If N is a positive number, save the N next articles.
9472 If N is a negative number, save the N previous articles.
9473 If N is nil and any articles have been marked with the process mark,
9474 save those articles instead.
9475 The variable `gnus-default-article-saver' specifies the saver function."
9477 (let* ((articles (gnus-summary-work-articles n))
9478 (save-buffer (save-excursion
9479 (nnheader-set-temp-buffer " *Gnus Save*")))
9480 (num (length articles))
9482 (dolist (article articles)
9483 (setq header (gnus-summary-article-header article))
9484 (if (not (vectorp header))
9485 ;; This is a pseudo-article.
9486 (if (assq 'name header)
9487 (gnus-copy-file (cdr (assq 'name header)))
9488 (gnus-message 1 "Article %d is unsaveable" article))
9489 ;; This is a real article.
9490 (save-window-excursion
9491 (gnus-summary-select-article t nil nil article))
9493 (set-buffer save-buffer)
9495 (insert-buffer-substring gnus-original-article-buffer))
9496 (setq file (gnus-article-save save-buffer file num))
9497 (gnus-summary-remove-process-mark article)
9499 (gnus-summary-set-saved-mark article))))
9500 (gnus-kill-buffer save-buffer)
9501 (gnus-summary-position-point)
9502 (gnus-set-mode-line 'summary)
9505 (defun gnus-summary-pipe-output (&optional arg)
9506 "Pipe the current article to a subprocess.
9507 If N is a positive number, pipe the N next articles.
9508 If N is a negative number, pipe the N previous articles.
9509 If N is nil and any articles have been marked with the process mark,
9510 pipe those articles instead."
9513 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9514 (gnus-summary-save-article arg t))
9515 (gnus-configure-windows 'pipe))
9517 (defun gnus-summary-save-article-mail (&optional arg)
9518 "Append the current article to an mail file.
9519 If N is a positive number, save the N next articles.
9520 If N is a negative number, save the N previous articles.
9521 If N is nil and any articles have been marked with the process mark,
9522 save those articles instead."
9525 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9526 (gnus-summary-save-article arg)))
9528 (defun gnus-summary-save-article-rmail (&optional arg)
9529 "Append the current article to an rmail file.
9530 If N is a positive number, save the N next articles.
9531 If N is a negative number, save the N previous articles.
9532 If N is nil and any articles have been marked with the process mark,
9533 save those articles instead."
9536 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9537 (gnus-summary-save-article arg)))
9539 (defun gnus-summary-save-article-file (&optional arg)
9540 "Append the current article to a file.
9541 If N is a positive number, save the N next articles.
9542 If N is a negative number, save the N previous articles.
9543 If N is nil and any articles have been marked with the process mark,
9544 save those articles instead."
9547 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9548 (gnus-summary-save-article arg)))
9550 (defun gnus-summary-write-article-file (&optional arg)
9551 "Write the current article to a file, deleting the previous file.
9552 If N is a positive number, save the N next articles.
9553 If N is a negative number, save the N previous articles.
9554 If N is nil and any articles have been marked with the process mark,
9555 save those articles instead."
9558 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9559 (gnus-summary-save-article arg)))
9561 (defun gnus-summary-save-article-body-file (&optional arg)
9562 "Append the current article body to a file.
9563 If N is a positive number, save the N next articles.
9564 If N is a negative number, save the N previous articles.
9565 If N is nil and any articles have been marked with the process mark,
9566 save those articles instead."
9569 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9570 (gnus-summary-save-article arg)))
9572 (defun gnus-summary-pipe-message (program)
9573 "Pipe the current article through PROGRAM."
9574 (interactive "sProgram: ")
9575 (gnus-summary-select-article)
9576 (let ((mail-header-separator ""))
9577 (gnus-eval-in-buffer-window gnus-article-buffer
9580 (let ((start (window-start))
9582 (message-pipe-buffer-body program)
9583 (set-window-start (get-buffer-window (current-buffer)) start))))))
9585 (defun gnus-get-split-value (methods)
9586 "Return a value based on the split METHODS."
9587 (let (split-name method result match)
9590 (set-buffer gnus-original-article-buffer)
9592 (nnheader-narrow-to-headers)
9593 (while (and methods (not split-name))
9594 (goto-char (point-min))
9595 (setq method (pop methods))
9596 (setq match (car method))
9599 ;; Regular expression.
9601 (re-search-forward match nil t)))
9602 ((gnus-functionp match)
9606 (setq result (funcall match gnus-newsgroup-name))))
9611 (setq result (eval match)))))
9612 (setq split-name (cdr method))
9613 (cond ((stringp result)
9614 (push (expand-file-name
9615 result gnus-article-save-directory)
9618 (setq split-name (append result split-name)))))))))
9619 (nreverse split-name)))
9621 (defun gnus-valid-move-group-p (group)
9624 (symbol-value group)
9625 (gnus-get-function (gnus-find-method-for-group
9626 (symbol-name group)) 'request-accept-article t)))
9628 (defun gnus-read-move-group-name (prompt default articles prefix)
9629 "Read a group name."
9630 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9631 (minibuffer-confirm-incomplete nil) ; XEmacs
9635 (if (> (length articles) 1)
9636 (format "these %d articles" (length articles))
9641 (gnus-completing-read default prom
9643 'gnus-valid-move-group-p
9645 'gnus-group-history))
9646 ((= 1 (length split-name))
9647 (gnus-completing-read (car split-name) prom
9649 'gnus-valid-move-group-p
9651 'gnus-group-history))
9653 (gnus-completing-read nil prom
9654 (mapcar (lambda (el) (list el))
9655 (nreverse split-name))
9657 'gnus-group-history))))
9658 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9660 (if (or (string= to-newsgroup "")
9661 (string= to-newsgroup prefix))
9662 (setq to-newsgroup default))
9663 (unless to-newsgroup
9664 (error "No group name entered"))
9665 (or (gnus-active to-newsgroup)
9666 (gnus-activate-group to-newsgroup nil nil to-method)
9667 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9669 (or (and (gnus-request-create-group to-newsgroup to-method)
9670 (gnus-activate-group
9671 to-newsgroup nil nil to-method)
9672 (gnus-subscribe-group to-newsgroup))
9673 (error "Couldn't create group %s" to-newsgroup)))
9674 (error "No such group: %s" to-newsgroup)))
9677 (defun gnus-summary-save-parts (type dir n &optional reverse)
9678 "Save parts matching TYPE to DIR.
9679 If REVERSE, save parts that do not match TYPE."
9681 (list (read-string "Save parts of type: "
9682 (or (car gnus-summary-save-parts-type-history)
9683 gnus-summary-save-parts-default-mime)
9684 'gnus-summary-save-parts-type-history)
9685 (setq gnus-summary-save-parts-last-directory
9686 (read-file-name "Save to directory: "
9687 gnus-summary-save-parts-last-directory
9689 current-prefix-arg))
9690 (gnus-summary-iterate n
9691 (let ((gnus-display-mime-function nil)
9692 (gnus-inhibit-treatment t))
9693 (gnus-summary-select-article))
9695 (set-buffer gnus-article-buffer)
9696 (let ((handles (or gnus-article-mime-handles
9697 (mm-dissect-buffer) (mm-uu-dissect))))
9699 (gnus-summary-save-parts-1 type dir handles reverse)
9700 (unless gnus-article-mime-handles ;; Don't destroy this case.
9701 (mm-destroy-parts handles)))))))
9703 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9704 (if (stringp (car handle))
9705 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9708 (not (string-match type (mm-handle-media-type handle)))
9709 (string-match type (mm-handle-media-type handle)))
9710 (let ((file (expand-file-name
9711 (file-name-nondirectory
9713 (mail-content-type-get
9714 (mm-handle-disposition handle) 'filename)
9715 (concat gnus-newsgroup-name
9716 "." (number-to-string
9717 (cdr gnus-article-current)))))
9719 (unless (file-exists-p file)
9720 (mm-save-part-to-file handle file))))))
9722 ;; Summary extract commands
9724 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9725 (let ((buffer-read-only nil)
9726 (article (gnus-summary-article-number))
9728 (unless (gnus-summary-goto-subject article)
9729 (error "No such article: %d" article))
9730 (gnus-summary-position-point)
9731 ;; If all commands are to be bunched up on one line, we collect
9733 (unless gnus-view-pseudos-separately
9734 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9737 (setq action (cdr (assq 'action (car ps))))
9738 (setq files (list (cdr (assq 'name (car ps)))))
9739 (while (and ps (cdr ps)
9740 (string= (or action "1")
9741 (or (cdr (assq 'action (cadr ps))) "2")))
9742 (push (cdr (assq 'name (cadr ps))) files)
9743 (setcdr ps (cddr ps)))
9745 (when (not (string-match "%s" action))
9748 (when (assq 'execute (car ps))
9749 (setcdr (assq 'execute (car ps))
9750 (funcall (if (string-match "%s" action)
9759 (setq ps (cdr ps)))))
9760 (if (and gnus-view-pseudos (not not-view))
9762 (when (assq 'execute (car pslist))
9763 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9764 (eq gnus-view-pseudos 'not-confirm)))
9765 (setq pslist (cdr pslist)))
9768 (setq after-article (or (cdr (assq 'article (car pslist)))
9769 (gnus-summary-article-number)))
9770 (gnus-summary-goto-subject after-article)
9773 (insert " " (file-name-nondirectory
9774 (cdr (assq 'name (car pslist))))
9775 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9777 (forward-line -1) ; back to `b'
9778 (gnus-add-text-properties
9779 b (1- e) (list 'gnus-number gnus-reffed-article-number
9780 gnus-mouse-face-prop gnus-mouse-face))
9782 after-article gnus-reffed-article-number
9783 gnus-unread-mark b (car pslist) 0 (- e b))
9784 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9785 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9786 (setq pslist (cdr pslist)))))))
9788 (defun gnus-pseudos< (p1 p2)
9789 (let ((c1 (cdr (assq 'action p1)))
9790 (c2 (cdr (assq 'action p2))))
9791 (and c1 c2 (string< c1 c2))))
9793 (defun gnus-request-pseudo-article (props)
9794 (cond ((assq 'execute props)
9795 (gnus-execute-command (cdr (assq 'execute props)))))
9796 (let ((gnus-current-article (gnus-summary-article-number)))
9797 (gnus-run-hooks 'gnus-mark-article-hook)))
9799 (defun gnus-execute-command (command &optional automatic)
9801 (gnus-article-setup-buffer)
9802 (set-buffer gnus-article-buffer)
9803 (setq buffer-read-only nil)
9804 (let ((command (if automatic command
9805 (read-string "Command: " (cons command 0)))))
9807 (insert "$ " command "\n\n")
9808 (if gnus-view-pseudo-asynchronously
9809 (start-process "gnus-execute" (current-buffer) shell-file-name
9810 shell-command-switch command)
9811 (call-process shell-file-name nil t nil
9812 shell-command-switch command)))))
9814 ;; Summary kill commands.
9816 (defun gnus-summary-edit-global-kill (article)
9817 "Edit the \"global\" kill file."
9818 (interactive (list (gnus-summary-article-number)))
9819 (gnus-group-edit-global-kill article))
9821 (defun gnus-summary-edit-local-kill ()
9822 "Edit a local kill file applied to the current newsgroup."
9824 (setq gnus-current-headers (gnus-summary-article-header))
9825 (gnus-group-edit-local-kill
9826 (gnus-summary-article-number) gnus-newsgroup-name))
9830 (defun gnus-read-header (id &optional header)
9831 "Read the headers of article ID and enter them into the Gnus system."
9832 (let ((group gnus-newsgroup-name)
9833 (gnus-override-method
9835 gnus-override-method
9836 (and (gnus-news-group-p gnus-newsgroup-name)
9837 (car (gnus-refer-article-methods)))))
9839 ;; First we check to see whether the header in question is already
9842 ;; This is a Message-ID.
9843 (setq header (or header (gnus-id-to-header id)))
9844 ;; This is an article number.
9845 (setq header (or header (gnus-summary-article-header id))))
9847 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9848 ;; We have found the header.
9850 ;; If this is a sparse article, we have to nix out its
9851 ;; previous entry in the thread hashtb.
9853 (gnus-summary-article-sparse-p (mail-header-number header)))
9854 (let* ((parent (gnus-parent-id (mail-header-references header)))
9855 (thread (and parent (gnus-id-to-thread parent))))
9857 (delq (assq header thread) thread))))
9858 ;; We have to really fetch the header to this article.
9860 (set-buffer nntp-server-buffer)
9861 (when (setq where (gnus-request-head id group))
9862 (nnheader-fold-continuation-lines)
9863 (goto-char (point-max))
9865 (goto-char (point-min))
9869 ((cdr where) (cdr where))
9870 (header (mail-header-number header))
9871 (t gnus-reffed-article-number))
9873 (insert " Article retrieved.\n"))
9875 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9876 () ; Malformed head.
9877 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9878 (when (and (stringp id)
9879 (not (string= (gnus-group-real-name group)
9881 ;; If we fetched by Message-ID and the article came
9882 ;; from a different group, we fudge some bogus article
9883 ;; numbers for this article.
9884 (mail-header-set-number header gnus-reffed-article-number))
9886 (set-buffer gnus-summary-buffer)
9887 (decf gnus-reffed-article-number)
9888 (gnus-remove-header (mail-header-number header))
9889 (push header gnus-newsgroup-headers)
9890 (setq gnus-current-headers header)
9891 (push (mail-header-number header) gnus-newsgroup-limit)))
9894 (defun gnus-remove-header (number)
9895 "Remove header NUMBER from `gnus-newsgroup-headers'."
9896 (if (and gnus-newsgroup-headers
9897 (= number (mail-header-number (car gnus-newsgroup-headers))))
9898 (pop gnus-newsgroup-headers)
9899 (let ((headers gnus-newsgroup-headers))
9900 (while (and (cdr headers)
9901 (not (= number (mail-header-number (cadr headers)))))
9904 (setcdr headers (cddr headers))))))
9907 ;;; summary highlights
9910 (defun gnus-highlight-selected-summary ()
9911 "Highlight selected article in summary buffer."
9912 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9913 (when gnus-summary-selected-face
9915 (let* ((beg (progn (beginning-of-line) (point)))
9916 (end (progn (end-of-line) (point)))
9917 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9918 (from (if (get-text-property beg gnus-mouse-face-prop)
9920 (or (next-single-property-change
9921 beg gnus-mouse-face-prop nil end)
9926 (or (next-single-property-change
9927 from gnus-mouse-face-prop nil end)
9929 ;; If no mouse-face prop on line we will have to = from = end,
9930 ;; so we highlight the entire line instead.
9931 (when (= (+ to 2) from)
9934 (if gnus-newsgroup-selected-overlay
9935 ;; Move old overlay.
9937 gnus-newsgroup-selected-overlay from to (current-buffer))
9938 ;; Create new overlay.
9940 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9941 'face gnus-summary-selected-face))))))
9943 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9944 (defun gnus-summary-highlight-line ()
9945 "Highlight current line according to `gnus-summary-highlight'."
9946 (let* ((list gnus-summary-highlight)
9948 (end (progn (end-of-line) (point)))
9949 ;; now find out where the line starts and leave point there.
9950 (beg (progn (beginning-of-line) (point)))
9951 (article (gnus-summary-article-number))
9952 (score (or (cdr (assq (or article gnus-current-article)
9953 gnus-newsgroup-scored))
9954 gnus-summary-default-score 0))
9955 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9956 (inhibit-read-only t))
9957 ;; Eval the cars of the lists until we find a match.
9958 (let ((default gnus-summary-default-score))
9960 (not (eval (caar list))))
9961 (setq list (cdr list))))
9962 (let ((face (cdar list)))
9963 (unless (eq face (get-text-property beg 'face))
9964 (gnus-put-text-property-excluding-characters-with-faces
9966 (setq face (if (boundp face) (symbol-value face) face)))
9967 (when gnus-summary-highlight-line-function
9968 (funcall gnus-summary-highlight-line-function article face))))
9971 (defun gnus-update-read-articles (group unread &optional compute)
9972 "Update the list of read articles in GROUP."
9973 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9974 (entry (gnus-gethash group gnus-newsrc-hashtb))
9975 (info (nth 2 entry))
9977 (unread (sort (copy-sequence unread) '<))
9979 (if (or (not info) (not active))
9980 ;; There is no info on this group if it was, in fact,
9981 ;; killed. Gnus stores no information on killed groups, so
9982 ;; there's nothing to be done.
9983 ;; One could store the information somewhere temporarily,
9984 ;; perhaps... Hmmm...
9986 ;; Remove any negative articles numbers.
9987 (while (and unread (< (car unread) 0))
9988 (setq unread (cdr unread)))
9989 ;; Remove any expired article numbers
9990 (while (and unread (< (car unread) (car active)))
9991 (setq unread (cdr unread)))
9992 ;; Compute the ranges of read articles by looking at the list of
9995 (when (/= (car unread) prev)
9996 (push (if (= prev (1- (car unread))) prev
9997 (cons prev (1- (car unread))))
9999 (setq prev (1+ (car unread)))
10000 (setq unread (cdr unread)))
10001 (when (<= prev (cdr active))
10002 (push (cons prev (cdr active)) read))
10003 (setq read (if (> (length read) 1) (nreverse read) read))
10008 ;; Propagate the read marks to the backend.
10009 (when (gnus-check-backend-function 'request-set-mark group)
10010 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10011 (add (gnus-remove-from-range read (gnus-info-read info))))
10013 (unless (gnus-check-group group)
10014 (error "Can't open server for %s" group))
10015 (gnus-request-set-mark
10016 group (delq nil (list (if add (list add 'add '(read)))
10017 (if del (list del 'del '(read))))))
10019 `(gnus-request-set-mark
10022 (if del (list del 'add '(read)))
10023 (if add (list add 'del '(read))))))))))
10024 (set-buffer gnus-group-buffer)
10025 (gnus-undo-register
10027 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10028 (gnus-info-set-read ',info ',(gnus-info-read info))
10029 (gnus-get-unread-articles-in-group ',info
10030 (gnus-active ,group))
10031 (gnus-group-update-group ,group t)
10033 ;; Enter this list into the group info.
10034 (gnus-info-set-read info read)
10035 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10036 (gnus-get-unread-articles-in-group info (gnus-active group))
10039 (defun gnus-offer-save-summaries ()
10040 "Offer to save all active summary buffers."
10042 ;; Go through all buffers and find all summaries.
10043 (dolist (buffer (buffer-list))
10044 (when (and (setq buffer (buffer-name buffer))
10045 (string-match "Summary" buffer)
10047 (set-buffer buffer)
10048 ;; We check that this is, indeed, a summary buffer.
10049 (and (eq major-mode 'gnus-summary-mode)
10050 ;; Also make sure this isn't bogus.
10051 gnus-newsgroup-prepared
10052 ;; Also make sure that this isn't a
10053 ;; dead summary buffer.
10054 (not gnus-dead-summary-mode))))
10055 (push buffer buffers)))
10056 ;; Go through all these summary buffers and offer to save them.
10060 "Update summary buffer %s? "
10062 (switch-to-buffer buf)
10063 (gnus-summary-exit))
10066 (defun gnus-summary-setup-default-charset ()
10067 "Setup newsgroup default charset."
10068 (if (equal gnus-newsgroup-name "nndraft:drafts")
10069 (setq gnus-newsgroup-charset nil)
10070 (let* ((ignored-charsets
10071 (or gnus-newsgroup-ephemeral-ignored-charsets
10073 (and gnus-newsgroup-name
10074 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10075 gnus-newsgroup-ignored-charsets))))
10076 (setq gnus-newsgroup-charset
10077 (or gnus-newsgroup-ephemeral-charset
10078 (and gnus-newsgroup-name
10079 (gnus-parameter-charset gnus-newsgroup-name))
10080 gnus-default-charset))
10081 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10082 ignored-charsets))))
10088 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10089 "Display the current article buffer fully MIME-buttonized.
10090 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10091 treated as multipart/mixed."
10093 (require 'gnus-art)
10094 (let ((gnus-unbuttonized-mime-types nil)
10095 (gnus-mime-display-multipart-as-mixed show-all-parts))
10096 (gnus-summary-show-article)))
10098 (defun gnus-summary-repair-multipart (article)
10099 "Add a Content-Type header to a multipart article without one."
10100 (interactive (list (gnus-summary-article-number)))
10101 (gnus-with-article article
10102 (message-narrow-to-head)
10103 (message-remove-header "Mime-Version")
10104 (goto-char (point-max))
10105 (insert "Mime-Version: 1.0\n")
10107 (when (search-forward "\n--" nil t)
10108 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10109 (message-narrow-to-head)
10110 (message-remove-header "Content-Type")
10111 (goto-char (point-max))
10112 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10115 (let (gnus-mark-article-hook)
10116 (gnus-summary-select-article t t nil article)))
10118 (defun gnus-summary-toggle-display-buttonized ()
10119 "Toggle the buttonizing of the article buffer."
10121 (require 'gnus-art)
10122 (if (setq gnus-inhibit-mime-unbuttonizing
10123 (not gnus-inhibit-mime-unbuttonizing))
10124 (let ((gnus-unbuttonized-mime-types nil))
10125 (gnus-summary-show-article))
10126 (gnus-summary-show-article)))
10129 ;;; Generic summary marking commands
10132 (defvar gnus-summary-marking-alist
10133 '((read gnus-del-mark "d")
10134 (unread gnus-unread-mark "u")
10135 (ticked gnus-ticked-mark "!")
10136 (dormant gnus-dormant-mark "?")
10137 (expirable gnus-expirable-mark "e"))
10138 "An alist of names/marks/keystrokes.")
10140 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10141 (defvar gnus-summary-mark-map)
10143 (defun gnus-summary-make-all-marking-commands ()
10144 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10145 (dolist (elem gnus-summary-marking-alist)
10146 (apply 'gnus-summary-make-marking-command elem)))
10148 (defun gnus-summary-make-marking-command (name mark keystroke)
10149 (let ((map (make-sparse-keymap)))
10150 (define-key gnus-summary-generic-mark-map keystroke map)
10151 (dolist (lway `((next "next" next nil "n")
10152 (next-unread "next unread" next t "N")
10153 (prev "previous" prev nil "p")
10154 (prev-unread "previous unread" prev t "P")
10155 (nomove "" nil nil ,keystroke)))
10156 (let ((func (gnus-summary-make-marking-command-1
10157 mark (car lway) lway name)))
10158 (setq func (eval func))
10159 (define-key map (nth 4 lway) func)))))
10161 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10163 (format "gnus-summary-put-mark-as-%s%s"
10164 name (if (eq way 'nomove)
10166 (concat "-" (symbol-name way)))))
10169 "Mark the current article as %s%s.
10170 If N, the prefix, then repeat N times.
10171 If N is negative, move in reverse order.
10172 The difference between N and the actual number of articles marked is
10176 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10178 (defun gnus-summary-generic-mark (n mark move unread)
10179 "Mark N articles with MARK."
10180 (unless (eq major-mode 'gnus-summary-mode)
10181 (error "This command can only be used in the summary buffer"))
10182 (gnus-summary-show-thread)
10185 ((eq move 'next) 1)
10186 ((eq move 'prev) -1)
10188 (if (zerop nummove)
10192 nummove (* -1 nummove))))
10193 (while (and (> n 0)
10194 (gnus-summary-mark-article nil mark)
10195 (zerop (gnus-summary-next-subject nummove unread t)))
10198 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10199 (gnus-summary-recenter)
10200 (gnus-summary-position-point)
10201 (gnus-set-mode-line 'summary)
10204 (defun gnus-summary-insert-articles (articles)
10205 (when (setq articles
10206 (gnus-set-difference articles
10207 (mapcar (lambda (h) (mail-header-number h))
10208 gnus-newsgroup-headers)))
10209 (setq gnus-newsgroup-headers
10211 gnus-newsgroup-headers
10212 (gnus-fetch-headers articles)
10213 'gnus-article-sort-by-number))
10214 ;; Suppress duplicates?
10215 (when gnus-suppress-duplicates
10216 (gnus-dup-suppress-articles))
10218 ;; We might want to build some more threads first.
10219 (when (and gnus-fetch-old-headers
10220 (eq gnus-headers-retrieved-by 'nov))
10221 (if (eq gnus-fetch-old-headers 'invisible)
10222 (gnus-build-all-threads)
10223 (gnus-build-old-threads)))
10224 ;; Let the Gnus agent mark articles as read.
10226 (gnus-agent-get-undownloaded-list))
10227 ;; Remove list identifiers from subject
10228 (when gnus-list-identifiers
10229 (gnus-summary-remove-list-identifiers))
10230 ;; First and last article in this newsgroup.
10231 (when gnus-newsgroup-headers
10232 (setq gnus-newsgroup-begin
10233 (mail-header-number (car gnus-newsgroup-headers))
10235 (mail-header-number
10236 (gnus-last-element gnus-newsgroup-headers))))
10237 (when gnus-use-scoring
10238 (gnus-possibly-score-headers))))
10240 (defun gnus-summary-insert-old-articles (&optional all)
10241 "Insert all old articles in this group.
10242 If ALL is non-nil, already read articles become readable.
10243 If ALL is a number, fetch this number of articles."
10246 (let ((old (mapcar 'car gnus-newsgroup-data))
10247 (i (car gnus-newsgroup-active))
10249 (while (<= i (cdr gnus-newsgroup-active))
10250 (or (memq i old) (push i older))
10252 (setq len (length older))
10257 (setq older (subseq older 0 all))))
10260 (if (and (numberp gnus-large-newsgroup)
10261 (> len gnus-large-newsgroup))
10265 "How many articles from %s (default %d): "
10267 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10269 (unless (string-match "^[ \t]*$" input)
10270 (setq all (string-to-number input))
10272 (setq older (subseq older 0 all))))))))
10274 (message "No old news.")
10275 (gnus-summary-insert-articles older)
10276 (gnus-summary-limit (gnus-union older old))))
10277 (gnus-summary-position-point)))
10279 (defun gnus-summary-insert-new-articles ()
10280 "Insert all new articles in this group."
10283 (let ((old (mapcar 'car gnus-newsgroup-data))
10284 (old-active gnus-newsgroup-active)
10285 (nnmail-fetched-sources (list t))
10287 (setq gnus-newsgroup-active
10288 (gnus-activate-group gnus-newsgroup-name 'scan))
10289 (setq i (1+ (cdr old-active)))
10290 (while (<= i (cdr gnus-newsgroup-active))
10294 (message "No gnus is bad news.")
10295 (setq new (nreverse new))
10296 (gnus-summary-insert-articles new)
10297 (setq gnus-newsgroup-unreads
10298 (append gnus-newsgroup-unreads new))
10299 (gnus-summary-limit (gnus-union old new))))
10300 (gnus-summary-position-point)))
10302 (gnus-summary-make-all-marking-commands)
10304 (gnus-ems-redefine)
10306 (provide 'gnus-sum)
10308 (run-hooks 'gnus-sum-load-hook)
10310 ;;; gnus-sum.el ends here